mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-11 09:11:50 +00:00
* Unify the version source Changes the development config to use version from package.json and makes the production config use the same utility function. Also removes the version file as it's no longer needed. * Remove some Steam references from build process Removes files needed to publish the game on Steam and related tasks that can be only used by the developer anyway. Only the build process is affected, the actual game part still supports Steam integration. * Refactor/add packaging tasks Adds new Gulp tasks to create a distributable package of the game. A task for macOS is not provided because signing needs to be figured out first. Package creation tasks are also aliased in package.json for future usage in external tools or CI. Aside from that, alternative methods of downloading the libGDX Texture Packer are dropped.
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import glob from "glob";
|
|
import { execSync } from "child_process";
|
|
import fs from "fs";
|
|
|
|
export function getRevision(useLast = false) {
|
|
const commitHash = execSync("git rev-parse --short " + (useLast ? "HEAD^1" : "HEAD")).toString("ascii");
|
|
return commitHash.replace(/^\s+|\s+$/g, "");
|
|
}
|
|
|
|
export function getAllResourceImages() {
|
|
return glob
|
|
.sync("res/**/*.@(png|svg|jpg)", { cwd: ".." })
|
|
.map(f => f.replace(/^res\//gi, ""))
|
|
.filter(f => {
|
|
if (f.indexOf("ui") >= 0) {
|
|
// We drop all ui images except for the noinline ones
|
|
return f.indexOf("noinline") >= 0;
|
|
}
|
|
return true;
|
|
});
|
|
}
|
|
|
|
export function getTag() {
|
|
try {
|
|
return execSync("git describe --tag --exact-match").toString("ascii");
|
|
} catch (e) {
|
|
throw new Error("Current git HEAD is not a version tag");
|
|
}
|
|
}
|
|
|
|
export function getVersion() {
|
|
// Use the version number specified in package.json
|
|
return JSON.parse(fs.readFileSync("../package.json", "utf-8")).version;
|
|
}
|
|
|
|
/**
|
|
* @param {string} url
|
|
* @param {string} commitHash
|
|
*/
|
|
export function cachebust(url, commitHash) {
|
|
return "/v/" + commitHash + "/" + url;
|
|
}
|