mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Merge steam-demo branch
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
[[actions]]
|
||||
name = "play"
|
||||
path = "shapezio.exe"
|
||||
platform = "windows"
|
||||
|
||||
[[actions]]
|
||||
name = "play"
|
||||
path = "play.sh"
|
||||
platform = "linux"
|
||||
66
gulp/build_variants.js
Normal file
66
gulp/build_variants.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* @type {Record<string, {
|
||||
* standalone: boolean,
|
||||
* environment?: 'dev' | 'staging' | 'prod',
|
||||
* electronBaseDir?: string,
|
||||
* steamAppId?: number,
|
||||
* executableName?: string,
|
||||
* buildArgs: {
|
||||
* chineseVersion?: boolean,
|
||||
* wegameVersion?: boolean,
|
||||
* steamDemo?: boolean
|
||||
* }}>}
|
||||
*/
|
||||
const BUILD_VARIANTS = {
|
||||
"web-localhost": {
|
||||
standalone: false,
|
||||
environment: "dev",
|
||||
buildArgs: {},
|
||||
},
|
||||
"web-shapezio-beta": {
|
||||
standalone: false,
|
||||
environment: "staging",
|
||||
buildArgs: {},
|
||||
},
|
||||
"web-shapezio": {
|
||||
standalone: false,
|
||||
environment: "prod",
|
||||
buildArgs: {},
|
||||
},
|
||||
"standalone-steam": {
|
||||
standalone: true,
|
||||
executableName: "shapez",
|
||||
steamAppId: 1318690,
|
||||
buildArgs: {},
|
||||
},
|
||||
"standalone-steam-china": {n
|
||||
standalone: true,
|
||||
steamAppId: 1318690,
|
||||
buildArgs: {
|
||||
chineseVersion: true,
|
||||
},
|
||||
},
|
||||
"standalone-steam-demo": {
|
||||
standalone: true,
|
||||
steamAppId: 1930750,
|
||||
buildArgs: {
|
||||
steamDemo: true,
|
||||
},
|
||||
},
|
||||
"standalone-steam-china-demo": {
|
||||
standalone: true,
|
||||
steamAppId: 1930750,
|
||||
buildArgs: {
|
||||
steamDemo: true,
|
||||
chineseVersion: true,
|
||||
},
|
||||
},
|
||||
"standalone-wegame": {
|
||||
standalone: true,
|
||||
electronBaseDir: "electron_wegame",
|
||||
buildArgs: {
|
||||
wegameVersion: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
module.exports = { BUILD_VARIANTS };
|
||||
139
gulp/cordova.js
vendored
139
gulp/cordova.js
vendored
@@ -1,139 +0,0 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const buildUtils = require("./buildutils");
|
||||
|
||||
function gulptasksCordova($, gulp, buildFolder) {
|
||||
const cdvRes = path.join("..", "..", "res");
|
||||
|
||||
// Cleans up the app assets
|
||||
// Removes all temporary folders used while optimizing the assets
|
||||
gulp.task("cleanupAppAssetsBuiltFolder", () => {
|
||||
return gulp
|
||||
.src(path.join(cdvRes, "built"), { read: false, allowEmpty: true })
|
||||
.pipe($.clean({ force: true }));
|
||||
});
|
||||
|
||||
// Optimizes all built assets
|
||||
gulp.task("optimizeBuiltAppAssets", () => {
|
||||
return gulp
|
||||
.src(path.join(cdvRes, "built", "**", "*.png"))
|
||||
.pipe($.flatten())
|
||||
.pipe($.imagemin([$.imagemin.optipng({ optimizationLevel: 1 })]))
|
||||
.pipe(gulp.dest(path.join(cdvRes, "built")));
|
||||
});
|
||||
|
||||
// Scales the icon resources
|
||||
gulp.task("scaleIconIos", async () => {
|
||||
const sizes = [
|
||||
180,
|
||||
60,
|
||||
120,
|
||||
76,
|
||||
152,
|
||||
40,
|
||||
80,
|
||||
57,
|
||||
114,
|
||||
72,
|
||||
144,
|
||||
167,
|
||||
29,
|
||||
58,
|
||||
87,
|
||||
50,
|
||||
100,
|
||||
167,
|
||||
20,
|
||||
1024,
|
||||
24,
|
||||
48,
|
||||
55,
|
||||
172,
|
||||
196,
|
||||
];
|
||||
for (let i = 0; i < sizes.length; ++i) {
|
||||
const size = sizes[i];
|
||||
console.log("Scaling icon to", size, "x", size);
|
||||
const img = await $.jimp.read(path.join(cdvRes, "ios", "icon-prefab.png"));
|
||||
await img.resize(size, size).write(path.join(cdvRes, "built", "ios", "icon@" + size + ".png"));
|
||||
}
|
||||
});
|
||||
|
||||
gulp.task("copyOtherIosResources", () => {
|
||||
return gulp
|
||||
.src(path.join(cdvRes, "ios", "splash-prefab.png"))
|
||||
.pipe($.rename("Default@2x~universal~anyany.png"))
|
||||
.pipe(gulp.dest(path.join(cdvRes, "built", "ios")));
|
||||
});
|
||||
|
||||
gulp.task("prepareIosRes", gulp.series("scaleIconIos", "copyOtherIosResources"));
|
||||
|
||||
gulp.task("copyAndroidResources", () => {
|
||||
return gulp
|
||||
.src(path.join(cdvRes, "android", "**", "*.*"))
|
||||
.pipe(gulp.dest(path.join(cdvRes, "built", "android")));
|
||||
});
|
||||
|
||||
gulp.task("prepareAndroidRes", gulp.series("copyAndroidResources"));
|
||||
|
||||
gulp.task(
|
||||
"prepareCordovaAssets",
|
||||
gulp.series(
|
||||
"cleanupAppAssetsBuiltFolder",
|
||||
gulp.parallel("prepareIosRes", "prepareAndroidRes"),
|
||||
"optimizeBuiltAppAssets"
|
||||
)
|
||||
);
|
||||
|
||||
// Patches the config.xml by replacing the app id to app_beta
|
||||
|
||||
gulp.task("patchConfigXML", cb => {
|
||||
const configUrl = path.join("..", "..", "config.xml");
|
||||
let configContent = fs.readFileSync(configUrl).toString();
|
||||
const version = buildUtils.getVersion();
|
||||
configContent = configContent.replace("%VERSION%", version);
|
||||
configContent = configContent.replace(' id="io.shapez.app" ', ' id="io.shapez.app_beta" ');
|
||||
configContent = configContent.replace("<name>Shapez.io</name>", "<name>Shapez.io BETA</name>");
|
||||
fs.writeFileSync(configUrl, configContent);
|
||||
cb();
|
||||
});
|
||||
|
||||
gulp.task("patchConfigXMLChangeStagingToProd", cb => {
|
||||
const configUrl = path.join("..", "..", "config.xml");
|
||||
let configContent = fs.readFileSync(configUrl).toString();
|
||||
configContent = configContent.replace(' id="io.shapez.app_beta" ', ' id="io.shapez.app" ');
|
||||
configContent = configContent.replace("<name>Shapez.io BETA</name>", "<name>Shapez.io</name>");
|
||||
fs.writeFileSync(configUrl, configContent);
|
||||
cb();
|
||||
});
|
||||
|
||||
// Triggers a new build on phonegap
|
||||
gulp.task("triggerPhonegapBuild", () => {
|
||||
return gulp
|
||||
.src("src/html/", { dot: false })
|
||||
.pipe(
|
||||
$.phonegapBuild({
|
||||
isRepository: true,
|
||||
appId: "3339820",
|
||||
platforms: ["android", "ios"],
|
||||
user: {
|
||||
token: process.env.SHAPEZ_CLI_PHONEGAP_KEY,
|
||||
},
|
||||
})
|
||||
)
|
||||
.pipe(
|
||||
$.phonegapBuild({
|
||||
isRepository: true,
|
||||
appId: "3537816",
|
||||
platforms: ["android", "ios"],
|
||||
user: {
|
||||
token: process.env.SHAPEZ_CLI_PHONEGAP_KEY,
|
||||
},
|
||||
})
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
gulptasksCordova,
|
||||
};
|
||||
228
gulp/gulpfile.js
228
gulp/gulpfile.js
@@ -18,7 +18,6 @@ const $ = require("gulp-load-plugins")({
|
||||
|
||||
const envVars = [
|
||||
"SHAPEZ_CLI_SERVER_HOST",
|
||||
// "SHAPEZ_CLI_PHONEGAP_KEY",
|
||||
"SHAPEZ_CLI_ALPHA_FTP_USER",
|
||||
"SHAPEZ_CLI_ALPHA_FTP_PW",
|
||||
"SHAPEZ_CLI_STAGING_FTP_USER",
|
||||
@@ -33,8 +32,7 @@ const envVars = [
|
||||
|
||||
for (let i = 0; i < envVars.length; ++i) {
|
||||
if (!process.env[envVars[i]]) {
|
||||
console.warn("Please set", envVars[i]);
|
||||
// process.exit(1);
|
||||
console.warn("Unset environment variable, might cause issues:", envVars[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +55,7 @@ const js = require("./js");
|
||||
js.gulptasksJS($, gulp, buildFolder, browserSync);
|
||||
|
||||
const html = require("./html");
|
||||
html.gulptasksHTML($, gulp, buildFolder, browserSync);
|
||||
html.gulptasksHTML($, gulp, buildFolder);
|
||||
|
||||
const ftp = require("./ftp");
|
||||
ftp.gulptasksFTP($, gulp, buildFolder);
|
||||
@@ -66,13 +64,11 @@ const docs = require("./docs");
|
||||
docs.gulptasksDocs($, gulp, buildFolder);
|
||||
|
||||
const standalone = require("./standalone");
|
||||
standalone.gulptasksStandalone($, gulp, buildFolder);
|
||||
|
||||
const releaseUploader = require("./release-uploader");
|
||||
releaseUploader.gulptasksReleaseUploader($, gulp, buildFolder);
|
||||
standalone.gulptasksStandalone($, gulp);
|
||||
|
||||
const translations = require("./translations");
|
||||
translations.gulptasksTranslations($, gulp, buildFolder);
|
||||
const { BUILD_VARIANTS } = require("./build_variants");
|
||||
translations.gulptasksTranslations($, gulp);
|
||||
|
||||
///////////////////// BUILD TASKS /////////////////////
|
||||
|
||||
@@ -142,9 +138,9 @@ gulp.task("main.webserver", () => {
|
||||
/**
|
||||
*
|
||||
* @param {object} param0
|
||||
* @param {"web"|"standalone"|"china"|"wegame"} param0.version
|
||||
* @param {keyof typeof BUILD_VARIANTS} param0.version
|
||||
*/
|
||||
function serve({ version = "web" }) {
|
||||
function serveHTML({ version = "web-dev" }) {
|
||||
browserSync.init({
|
||||
server: [buildFolder, path.join(baseDir, "mod_examples")],
|
||||
port: 3005,
|
||||
@@ -168,10 +164,7 @@ function serve({ version = "web" }) {
|
||||
gulp.watch(["../src/**/*.scss"], gulp.series("css.dev"));
|
||||
|
||||
// Watch .html files, those trigger a html rebuild
|
||||
gulp.watch("../src/**/*.html", gulp.series(version === "web" ? "html.dev" : "html.standalone-dev"));
|
||||
|
||||
// Watch sound files
|
||||
// gulp.watch(["../res_raw/sounds/**/*.mp3", "../res_raw/sounds/**/*.wav"], gulp.series("sounds.dev"));
|
||||
gulp.watch("../src/**/*.html", gulp.series("html." + version + ".dev"));
|
||||
|
||||
// Watch translations
|
||||
gulp.watch("../translations/**/*.yaml", gulp.series("translations.convertToJson"));
|
||||
@@ -204,27 +197,7 @@ function serve({ version = "web" }) {
|
||||
return gulp.src(path).pipe(browserSync.reload({ stream: true }));
|
||||
});
|
||||
|
||||
switch (version) {
|
||||
case "web": {
|
||||
gulp.series("js.dev.watch")(() => true);
|
||||
break;
|
||||
}
|
||||
case "standalone": {
|
||||
gulp.series("js.standalone-dev.watch")(() => true);
|
||||
break;
|
||||
}
|
||||
case "china": {
|
||||
gulp.series("china.js.dev.watch")(() => true);
|
||||
break;
|
||||
}
|
||||
case "wegame": {
|
||||
gulp.series("wegame.js.dev.watch")(() => true);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new Error("Unknown version " + version);
|
||||
}
|
||||
}
|
||||
gulp.series("js." + version + ".dev.watch")(() => true);
|
||||
}
|
||||
|
||||
///////////////////// RUNNABLE TASKS /////////////////////
|
||||
@@ -238,9 +211,9 @@ gulp.task("step.deleteEmpty", cb => {
|
||||
|
||||
gulp.task("step.postbuild", gulp.series("imgres.cleanupUnusedCssInlineImages", "step.deleteEmpty"));
|
||||
|
||||
// Builds everything (dev)
|
||||
// // Builds everything (dev)
|
||||
gulp.task(
|
||||
"build.dev",
|
||||
"build.prepare.dev",
|
||||
gulp.series(
|
||||
"utils.cleanup",
|
||||
"utils.copyAdditionalBuildFiles",
|
||||
@@ -252,146 +225,95 @@ gulp.task(
|
||||
"imgres.copyImageResources",
|
||||
"imgres.copyNonImageResources",
|
||||
"translations.fullBuild",
|
||||
"css.dev",
|
||||
"html.dev"
|
||||
"css.dev"
|
||||
)
|
||||
);
|
||||
|
||||
// Builds everything (standalone -dev)
|
||||
gulp.task(
|
||||
"build.standalone.dev",
|
||||
gulp.series(
|
||||
"utils.cleanup",
|
||||
"localConfig.findOrCreate",
|
||||
"imgres.buildAtlas",
|
||||
"imgres.atlasToJson",
|
||||
"imgres.atlas",
|
||||
"sounds.dev",
|
||||
"imgres.copyImageResources",
|
||||
"imgres.copyNonImageResources",
|
||||
"translations.fullBuild",
|
||||
"css.dev",
|
||||
"html.standalone-dev"
|
||||
)
|
||||
);
|
||||
// // Builds everything (staging)
|
||||
// gulp.task("step.staging.code", gulp.series("sounds.fullbuild", "translations.fullBuild", "js.staging"));
|
||||
// gulp.task(
|
||||
// "step.staging.mainbuild",
|
||||
// gulp.parallel("utils.copyAdditionalBuildFiles", "step.baseResources", "step.staging.code")
|
||||
// );
|
||||
// gulp.task("step.staging.all", gulp.series("step.staging.mainbuild", "css.prod", "html.staging"));
|
||||
// gulp.task("build.staging", gulp.series("utils.cleanup", "step.staging.all", "step.postbuild"));
|
||||
|
||||
// Builds everything (staging)
|
||||
gulp.task("step.staging.code", gulp.series("sounds.fullbuild", "translations.fullBuild", "js.staging"));
|
||||
gulp.task(
|
||||
"step.staging.mainbuild",
|
||||
gulp.parallel("utils.copyAdditionalBuildFiles", "step.baseResources", "step.staging.code")
|
||||
);
|
||||
gulp.task("step.staging.all", gulp.series("step.staging.mainbuild", "css.prod", "html.staging"));
|
||||
gulp.task("build.staging", gulp.series("utils.cleanup", "step.staging.all", "step.postbuild"));
|
||||
// // Builds everything (prod)
|
||||
// gulp.task("step.prod.code", gulp.series("sounds.fullbuild", "translations.fullBuild", "js.prod"));
|
||||
// gulp.task(
|
||||
// "step.prod.mainbuild",
|
||||
// gulp.parallel("utils.copyAdditionalBuildFiles", "step.baseResources", "step.prod.code")
|
||||
// );
|
||||
// gulp.task("step.prod.all", gulp.series("step.prod.mainbuild", "css.prod", "html.prod"));
|
||||
// gulp.task("build.prod", gulp.series("utils.cleanup", "step.prod.all", "step.postbuild"));
|
||||
|
||||
// Builds everything (prod)
|
||||
gulp.task("step.prod.code", gulp.series("sounds.fullbuild", "translations.fullBuild", "js.prod"));
|
||||
gulp.task(
|
||||
"step.prod.mainbuild",
|
||||
gulp.parallel("utils.copyAdditionalBuildFiles", "step.baseResources", "step.prod.code")
|
||||
);
|
||||
gulp.task("step.prod.all", gulp.series("step.prod.mainbuild", "css.prod", "html.prod"));
|
||||
gulp.task("build.prod", gulp.series("utils.cleanup", "step.prod.all", "step.postbuild"));
|
||||
// Builds everything for every variant
|
||||
for (const variant in BUILD_VARIANTS) {
|
||||
const data = BUILD_VARIANTS[variant];
|
||||
const buildName = "build." + variant;
|
||||
|
||||
// Builds everything (standalone-beta)
|
||||
gulp.task(
|
||||
"step.standalone-beta.code",
|
||||
gulp.series("sounds.fullbuildHQ", "translations.fullBuild", "js.standalone-beta")
|
||||
);
|
||||
gulp.task("step.standalone-beta.mainbuild", gulp.parallel("step.baseResources", "step.standalone-beta.code"));
|
||||
gulp.task(
|
||||
"step.standalone-beta.all",
|
||||
gulp.series("step.standalone-beta.mainbuild", "css.prod-standalone", "html.standalone-beta")
|
||||
);
|
||||
gulp.task(
|
||||
"build.standalone-beta",
|
||||
gulp.series("utils.cleanup", "step.standalone-beta.all", "step.postbuild")
|
||||
);
|
||||
|
||||
// Builds everything (standalone-prod)
|
||||
|
||||
for (const prefix of ["", "china.", "wegame."]) {
|
||||
gulp.task(
|
||||
prefix + "step.standalone-prod.code",
|
||||
gulp.series("sounds.fullbuildHQ", "translations.fullBuild", prefix + "js.standalone-prod")
|
||||
buildName + ".code",
|
||||
gulp.series(
|
||||
data.standalone ? "sounds.fullbuildHQ" : "sounds.fullbuild",
|
||||
"translations.fullBuild",
|
||||
"js." + variant + ".prod"
|
||||
)
|
||||
);
|
||||
|
||||
gulp.task(
|
||||
prefix + "step.standalone-prod.mainbuild",
|
||||
gulp.parallel("step.baseResources", prefix + "step.standalone-prod.code")
|
||||
);
|
||||
gulp.task(buildName + ".resourcesAndCode", gulp.parallel("step.baseResources", buildName + ".code"));
|
||||
|
||||
gulp.task(
|
||||
prefix + "step.standalone-prod.all",
|
||||
gulp.series(prefix + "step.standalone-prod.mainbuild", "css.prod-standalone", "html.standalone-prod")
|
||||
buildName + ".all",
|
||||
gulp.series(buildName + ".resourcesAndCode", "css.prod-standalone", "html." + variant + ".prod")
|
||||
);
|
||||
|
||||
gulp.task(buildName, gulp.series("utils.cleanup", buildName + ".all", "step.postbuild"));
|
||||
|
||||
// serve
|
||||
gulp.task(
|
||||
prefix + "build.standalone-prod",
|
||||
gulp.series("utils.cleanup", prefix + "step.standalone-prod.all", "step.postbuild")
|
||||
"serve." + variant,
|
||||
gulp.series("build.prepare.dev", "html." + variant + ".dev", () => serveHTML({ version: variant }))
|
||||
);
|
||||
}
|
||||
|
||||
// OS X build and release upload
|
||||
gulp.task(
|
||||
"build.darwin64-prod",
|
||||
gulp.series(
|
||||
"build.standalone-prod",
|
||||
"standalone.prepare",
|
||||
"standalone.package.prod.darwin64.signManually"
|
||||
)
|
||||
);
|
||||
// gulp.task(
|
||||
// "build.darwin64-prod",
|
||||
// gulp.series(
|
||||
// "build.standalone-prod",
|
||||
// "standalone.prepare",
|
||||
// "standalone.package.prod.darwin64.signManually"
|
||||
// )
|
||||
// );
|
||||
|
||||
// Deploying!
|
||||
gulp.task(
|
||||
"main.deploy.alpha",
|
||||
gulp.series("utils.requireCleanWorkingTree", "build.staging", "ftp.upload.alpha")
|
||||
"deploy.staging",
|
||||
gulp.series("utils.requireCleanWorkingTree", "build.web-shapezio-beta", "ftp.upload.staging")
|
||||
);
|
||||
gulp.task(
|
||||
"main.deploy.staging",
|
||||
gulp.series("utils.requireCleanWorkingTree", "build.staging", "ftp.upload.staging")
|
||||
);
|
||||
gulp.task("main.deploy.prod", gulp.series("utils.requireCleanWorkingTree", "build.prod", "ftp.upload.prod"));
|
||||
gulp.task("main.deploy.all", gulp.series("main.deploy.staging", "main.deploy.prod"));
|
||||
|
||||
// steam
|
||||
gulp.task("regular.main.standalone", gulp.series("build.standalone-prod", "standalone.package.prod"));
|
||||
|
||||
// china
|
||||
gulp.task(
|
||||
"china.main.standalone",
|
||||
gulp.series("china.build.standalone-prod", "china.standalone.package.prod")
|
||||
"deploy.prod",
|
||||
gulp.series("utils.requireCleanWorkingTree", "build.web-shapezio", "ftp.upload.prod")
|
||||
);
|
||||
|
||||
// wegame
|
||||
gulp.task(
|
||||
"wegame.main.standalone",
|
||||
gulp.series("wegame.build.standalone-prod", "wegame.standalone.package.prod")
|
||||
);
|
||||
// // china
|
||||
// gulp.task(
|
||||
// "china.main.standalone",
|
||||
// gulp.series("china.build.standalone-prod", "china.standalone.package.prod")
|
||||
// );
|
||||
|
||||
// all (except wegame)
|
||||
gulp.task("standalone.steam", gulp.series("regular.main.standalone", "china.main.standalone"));
|
||||
gulp.task(
|
||||
"standalone.all",
|
||||
gulp.series("regular.main.standalone", "china.main.standalone", "wegame.main.standalone")
|
||||
);
|
||||
// // wegame
|
||||
// gulp.task(
|
||||
// "wegame.main.standalone",
|
||||
// gulp.series("wegame.build.standalone-prod", "wegame.standalone.package.prod")
|
||||
// );
|
||||
|
||||
// Live-development
|
||||
gulp.task(
|
||||
"main.serveDev",
|
||||
gulp.series("build.dev", () => serve({ version: "web" }))
|
||||
);
|
||||
gulp.task(
|
||||
"main.serveStandalone",
|
||||
gulp.series("build.standalone.dev", () => serve({ version: "standalone" }))
|
||||
);
|
||||
gulp.task(
|
||||
"china.main.serveDev",
|
||||
gulp.series("build.dev", () => serve({ version: "china" }))
|
||||
);
|
||||
gulp.task(
|
||||
"wegame.main.serveDev",
|
||||
gulp.series("build.dev", () => serve({ version: "wegame" }))
|
||||
);
|
||||
// // all (except wegame)
|
||||
// gulp.task("standalone.steam", gulp.series("regular.main.standalone", "china.main.standalone"));
|
||||
// gulp.task(
|
||||
// "standalone.all",
|
||||
// gulp.series("regular.main.standalone", "china.main.standalone", "wegame.main.standalone")
|
||||
// );
|
||||
|
||||
gulp.task("default", gulp.series("main.serveDev"));
|
||||
gulp.task("default", gulp.series("serve.web-localhost"));
|
||||
|
||||
118
gulp/html.js
118
gulp/html.js
@@ -2,6 +2,7 @@ const buildUtils = require("./buildutils");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const crypto = require("crypto");
|
||||
const { BUILD_VARIANTS } = require("./build_variants");
|
||||
|
||||
function computeIntegrityHash(fullPath, algorithm = "sha256") {
|
||||
const file = fs.readFileSync(fullPath);
|
||||
@@ -9,12 +10,20 @@ function computeIntegrityHash(fullPath, algorithm = "sha256") {
|
||||
return algorithm + "-" + hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* PROVIDES (per <variant>)
|
||||
*
|
||||
* html.<variant>.dev
|
||||
* html.<variant>.prod
|
||||
*/
|
||||
function gulptasksHTML($, gulp, buildFolder) {
|
||||
const commitHash = buildUtils.getRevision();
|
||||
async function buildHtml(
|
||||
apiUrl,
|
||||
{ analytics = false, standalone = false, app = false, integrity = true, enableCachebust = true }
|
||||
) {
|
||||
async function buildHtml({
|
||||
googleAnalytics = false,
|
||||
standalone = false,
|
||||
integrity = true,
|
||||
enableCachebust = true,
|
||||
}) {
|
||||
function cachebust(url) {
|
||||
if (enableCachebust) {
|
||||
return buildUtils.cachebust(url, commitHash);
|
||||
@@ -22,7 +31,7 @@ function gulptasksHTML($, gulp, buildFolder) {
|
||||
return url;
|
||||
}
|
||||
|
||||
const hasLocalFiles = standalone || app;
|
||||
const hasLocalFiles = standalone;
|
||||
|
||||
return gulp
|
||||
.src("../src/html/" + (standalone ? "index.standalone.html" : "index.html"))
|
||||
@@ -31,13 +40,6 @@ function gulptasksHTML($, gulp, buildFolder) {
|
||||
/** @this {Document} **/ function () {
|
||||
const document = this;
|
||||
|
||||
// Preconnect to api
|
||||
const prefetchLink = document.createElement("link");
|
||||
prefetchLink.rel = "preconnect";
|
||||
prefetchLink.href = apiUrl;
|
||||
prefetchLink.setAttribute("crossorigin", "anonymous");
|
||||
document.head.appendChild(prefetchLink);
|
||||
|
||||
// Append css
|
||||
const css = document.createElement("link");
|
||||
css.rel = "stylesheet";
|
||||
@@ -53,31 +55,8 @@ function gulptasksHTML($, gulp, buildFolder) {
|
||||
}
|
||||
document.head.appendChild(css);
|
||||
|
||||
// Append async css
|
||||
// const asyncCss = document.createElement("link");
|
||||
// asyncCss.rel = "stylesheet";
|
||||
// asyncCss.type = "text/css";
|
||||
// asyncCss.media = "none";
|
||||
// asyncCss.setAttribute("onload", "this.media='all'");
|
||||
// asyncCss.href = cachebust("async-resources.css");
|
||||
// if (integrity) {
|
||||
// asyncCss.setAttribute(
|
||||
// "integrity",
|
||||
// computeIntegrityHash(path.join(buildFolder, "async-resources.css"))
|
||||
// );
|
||||
// }
|
||||
// document.head.appendChild(asyncCss);
|
||||
|
||||
if (app) {
|
||||
// Append cordova link
|
||||
const cdv = document.createElement("script");
|
||||
cdv.src = "cordova.js";
|
||||
cdv.type = "text/javascript";
|
||||
document.head.appendChild(cdv);
|
||||
}
|
||||
|
||||
// Google analytics
|
||||
if (analytics) {
|
||||
if (googleAnalytics) {
|
||||
const tagManagerScript = document.createElement("script");
|
||||
tagManagerScript.src =
|
||||
"https://www.googletagmanager.com/gtag/js?id=UA-165342524-1";
|
||||
@@ -92,14 +71,6 @@ function gulptasksHTML($, gulp, buildFolder) {
|
||||
gtag('config', 'UA-165342524-1', { anonymize_ip: true });
|
||||
`;
|
||||
document.head.appendChild(initScript);
|
||||
|
||||
const abTestingScript = document.createElement("script");
|
||||
abTestingScript.setAttribute(
|
||||
"src",
|
||||
"https://www.googleoptimize.com/optimize.js?id=OPT-M5NHCV7"
|
||||
);
|
||||
abTestingScript.setAttribute("async", "");
|
||||
document.head.appendChild(abTestingScript);
|
||||
}
|
||||
|
||||
// Do not need to preload in app or standalone
|
||||
@@ -250,50 +221,25 @@ function gulptasksHTML($, gulp, buildFolder) {
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
}
|
||||
|
||||
gulp.task("html.dev", () => {
|
||||
return buildHtml("http://localhost:5005", {
|
||||
analytics: false,
|
||||
integrity: false,
|
||||
enableCachebust: false,
|
||||
for (const variant in BUILD_VARIANTS) {
|
||||
const data = BUILD_VARIANTS[variant];
|
||||
gulp.task("html." + variant + ".dev", () => {
|
||||
return buildHtml({
|
||||
googleAnalytics: false,
|
||||
standalone: data.standalone,
|
||||
integrity: false,
|
||||
enableCachebust: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task("html.staging", () => {
|
||||
return buildHtml("https://api-staging.shapez.io", {
|
||||
analytics: true,
|
||||
gulp.task("html." + variant + ".prod", () => {
|
||||
return buildHtml({
|
||||
googleAnalytics: !data.standalone,
|
||||
standalone: data.standalone,
|
||||
integrity: true,
|
||||
enableCachebust: !data.standalone,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task("html.prod", () => {
|
||||
return buildHtml("https://analytics.shapez.io", {
|
||||
analytics: true,
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task("html.standalone-dev", () => {
|
||||
return buildHtml("https://localhost:5005", {
|
||||
analytics: false,
|
||||
standalone: true,
|
||||
integrity: false,
|
||||
enableCachebust: false,
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task("html.standalone-beta", () => {
|
||||
return buildHtml("https://api-staging.shapez.io", {
|
||||
analytics: false,
|
||||
standalone: true,
|
||||
enableCachebust: false,
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task("html.standalone-prod", () => {
|
||||
return buildHtml("https://analytics.shapez.io", {
|
||||
analytics: false,
|
||||
standalone: true,
|
||||
enableCachebust: false,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
346
gulp/js.js
346
gulp/js.js
@@ -1,260 +1,122 @@
|
||||
const path = require("path");
|
||||
const { BUILD_VARIANTS } = require("./build_variants");
|
||||
|
||||
function requireUncached(module) {
|
||||
delete require.cache[require.resolve(module)];
|
||||
return require(module);
|
||||
}
|
||||
|
||||
/**
|
||||
* PROVIDES (per <variant>)
|
||||
*
|
||||
* js.<variant>.dev.watch
|
||||
* js.<variant>.dev
|
||||
* js.<variant>.prod
|
||||
*
|
||||
*/
|
||||
|
||||
function gulptasksJS($, gulp, buildFolder, browserSync) {
|
||||
//// DEV
|
||||
|
||||
gulp.task("js.dev.watch", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.config.js")({
|
||||
watch: true,
|
||||
})
|
||||
for (const variant in BUILD_VARIANTS) {
|
||||
const data = BUILD_VARIANTS[variant];
|
||||
|
||||
gulp.task("js." + variant + ".dev.watch", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.config.js")({
|
||||
...data.buildArgs,
|
||||
standalone: data.standalone,
|
||||
watch: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder))
|
||||
.pipe(browserSync.stream());
|
||||
});
|
||||
.pipe(gulp.dest(buildFolder))
|
||||
.pipe(browserSync.stream());
|
||||
});
|
||||
|
||||
gulp.task("js.dev", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe($.webpackStream(requireUncached("./webpack.config.js")({})))
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
if (!data.standalone) {
|
||||
// WEB
|
||||
|
||||
//// DEV CHINA
|
||||
gulp.task("js." + variant + ".dev", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.config.js")({
|
||||
...data.buildArgs,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
|
||||
gulp.task("china.js.dev.watch", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.config.js")({
|
||||
watch: true,
|
||||
chineseVersion: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder))
|
||||
.pipe(browserSync.stream());
|
||||
});
|
||||
gulp.task("js." + variant + ".prod.transpiled", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.production.config.js")({
|
||||
es6: false,
|
||||
...data.buildArgs,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe($.rename("bundle-transpiled.js"))
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
|
||||
gulp.task("china.js.dev", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.config.js")({
|
||||
chineseVersion: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
|
||||
//// DEV WEGAME
|
||||
|
||||
gulp.task("wegame.js.dev.watch", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.config.js")({
|
||||
watch: true,
|
||||
wegameVersion: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder))
|
||||
.pipe(browserSync.stream());
|
||||
});
|
||||
|
||||
gulp.task("wegame.js.dev", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.config.js")({
|
||||
wegameVersion: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
|
||||
//// STAGING
|
||||
|
||||
gulp.task("js.staging.transpiled", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.production.config.js")({
|
||||
enableAssert: true,
|
||||
environment: "staging",
|
||||
es6: false,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe($.rename("bundle-transpiled.js"))
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
|
||||
gulp.task("js.staging.latest", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.production.config.js")({
|
||||
enableAssert: true,
|
||||
environment: "staging",
|
||||
es6: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
gulp.task("js.staging", gulp.parallel("js.staging.transpiled", "js.staging.latest"));
|
||||
|
||||
//// PROD
|
||||
|
||||
gulp.task("js.prod.transpiled", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.production.config.js")({
|
||||
enableAssert: false,
|
||||
environment: "prod",
|
||||
es6: false,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe($.rename("bundle-transpiled.js"))
|
||||
.pipe(gulp.dest(buildFolder))
|
||||
.pipe(browserSync.stream());
|
||||
});
|
||||
|
||||
gulp.task("js.prod.latest", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.production.config.js")({
|
||||
enableAssert: false,
|
||||
environment: "prod",
|
||||
es6: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder))
|
||||
.pipe(browserSync.stream());
|
||||
});
|
||||
|
||||
gulp.task("js.prod", gulp.parallel("js.prod.transpiled", "js.prod.latest"));
|
||||
|
||||
//// STANDALONE
|
||||
|
||||
gulp.task("js.standalone-dev.watch", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.config.js")({
|
||||
watch: true,
|
||||
standalone: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder))
|
||||
.pipe(browserSync.stream());
|
||||
});
|
||||
|
||||
gulp.task("js.standalone-dev", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.config.js")({
|
||||
standalone: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
|
||||
gulp.task("js.standalone-beta", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.production.config.js")({
|
||||
enableAssert: true,
|
||||
environment: "staging",
|
||||
es6: true,
|
||||
standalone: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
|
||||
gulp.task("js.standalone-prod", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.production.config.js")({
|
||||
enableAssert: false,
|
||||
environment: "prod",
|
||||
es6: true,
|
||||
standalone: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
|
||||
gulp.task("china.js.standalone-prod", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.production.config.js")({
|
||||
enableAssert: false,
|
||||
environment: "prod",
|
||||
es6: true,
|
||||
standalone: true,
|
||||
chineseVersion: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
|
||||
gulp.task("wegame.js.standalone-prod", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.production.config.js")({
|
||||
enableAssert: false,
|
||||
environment: "prod",
|
||||
es6: false,
|
||||
standalone: true,
|
||||
wegameVersion: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
gulp.task("js." + variant + ".prod.es6", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.production.config.js")({
|
||||
es6: true,
|
||||
...data.buildArgs,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
gulp.task(
|
||||
"js." + variant + ".prod",
|
||||
gulp.parallel("js." + variant + ".prod.transpiled", "js." + variant + ".prod.es6")
|
||||
);
|
||||
} else {
|
||||
// STANDALONE
|
||||
gulp.task("js." + variant + ".dev", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.config.js")({
|
||||
...data.buildArgs,
|
||||
standalone: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
gulp.task("js." + variant + ".prod", () => {
|
||||
return gulp
|
||||
.src("../src/js/main.js")
|
||||
.pipe(
|
||||
$.webpackStream(
|
||||
requireUncached("./webpack.production.config.js")({
|
||||
...data.buildArgs,
|
||||
environment: "prod",
|
||||
es6: true,
|
||||
standalone: true,
|
||||
})
|
||||
)
|
||||
)
|
||||
.pipe(gulp.dest(buildFolder));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
const path = require("path");
|
||||
const fs = require("fs");
|
||||
const execSync = require("child_process").execSync;
|
||||
const { Octokit } = require("@octokit/rest");
|
||||
const buildutils = require("./buildutils");
|
||||
|
||||
function gulptasksReleaseUploader($, gulp, buildFolder) {
|
||||
const standaloneDir = path.join(__dirname, "..", "tmp_standalone_files");
|
||||
const darwinApp = path.join(standaloneDir, "shapez.io-standalone-darwin-x64", "shapez.io-standalone.app");
|
||||
const dmgName = "shapez.io-standalone.dmg";
|
||||
const dmgPath = path.join(standaloneDir, "shapez.io-standalone-darwin-x64", dmgName);
|
||||
|
||||
gulp.task("standalone.uploadRelease.darwin64.cleanup", () => {
|
||||
return gulp.src(dmgPath, { read: false, allowEmpty: true }).pipe($.clean({ force: true }));
|
||||
});
|
||||
|
||||
gulp.task("standalone.uploadRelease.darwin64.compress", cb => {
|
||||
console.log("Packaging disk image", dmgPath);
|
||||
execSync(`hdiutil create -format UDBZ -srcfolder ${darwinApp} ${dmgPath}`);
|
||||
cb();
|
||||
});
|
||||
|
||||
gulp.task("standalone.uploadRelease.darwin64.upload", async cb => {
|
||||
const currentTag = buildutils.getTag();
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: process.env.SHAPEZ_CLI_GITHUB_TOKEN
|
||||
});
|
||||
|
||||
const createdRelease = await octokit.request("POST /repos/{owner}/{repo}/releases", {
|
||||
owner: process.env.SHAPEZ_CLI_GITHUB_USER,
|
||||
repo: "shapez.io",
|
||||
tag_name: currentTag,
|
||||
name: currentTag,
|
||||
draft: true
|
||||
});
|
||||
|
||||
const { data: { id, upload_url } } = createdRelease;
|
||||
console.log(`Created release ${id} for tag ${currentTag}`);
|
||||
|
||||
const dmgContents = fs.readFileSync(dmgPath);
|
||||
const dmgSize = fs.statSync(dmgPath).size;
|
||||
console.log("Uploading", dmgContents.length / 1024 / 1024, "MB to", upload_url);
|
||||
|
||||
await octokit.request({
|
||||
method: "POST",
|
||||
url: upload_url,
|
||||
headers: {
|
||||
"content-type": "application/x-apple-diskimage"
|
||||
},
|
||||
name: dmgName,
|
||||
data: dmgContents
|
||||
});
|
||||
|
||||
cb();
|
||||
});
|
||||
|
||||
gulp.task("standalone.uploadRelease.darwin64",
|
||||
gulp.series(
|
||||
"standalone.uploadRelease.darwin64.cleanup",
|
||||
"standalone.uploadRelease.darwin64.compress",
|
||||
"standalone.uploadRelease.darwin64.upload"
|
||||
));
|
||||
}
|
||||
|
||||
module.exports = { gulptasksReleaseUploader };
|
||||
@@ -8,6 +8,7 @@ const fse = require("fs-extra");
|
||||
const buildutils = require("./buildutils");
|
||||
const execSync = require("child_process").execSync;
|
||||
const electronNotarize = require("electron-notarize");
|
||||
const { BUILD_VARIANTS } = require("./build_variants");
|
||||
|
||||
let signAsync;
|
||||
try {
|
||||
@@ -17,56 +18,32 @@ try {
|
||||
}
|
||||
|
||||
function gulptasksStandalone($, gulp) {
|
||||
const targets = [
|
||||
{
|
||||
tempDestDir: path.join(__dirname, "..", "tmp_standalone_files"),
|
||||
suffix: "",
|
||||
taskPrefix: "",
|
||||
electronBaseDir: path.join(__dirname, "..", "electron"),
|
||||
steam: true,
|
||||
},
|
||||
{
|
||||
tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_china"),
|
||||
suffix: "china",
|
||||
taskPrefix: "china.",
|
||||
electronBaseDir: path.join(__dirname, "..", "electron"),
|
||||
steam: true,
|
||||
},
|
||||
{
|
||||
tempDestDir: path.join(__dirname, "..", "tmp_standalone_files_wegame"),
|
||||
suffix: "wegame",
|
||||
taskPrefix: "wegame.",
|
||||
electronBaseDir: path.join(__dirname, "..", "electron_wegame"),
|
||||
steam: false,
|
||||
},
|
||||
];
|
||||
|
||||
for (const { tempDestDir, suffix, taskPrefix, electronBaseDir, steam } of targets) {
|
||||
for (const variant in BUILD_VARIANTS) {
|
||||
const variantData = BUILD_VARIANTS[variant];
|
||||
if (!variantData.standalone) {
|
||||
continue;
|
||||
}
|
||||
const tempDestDir = path.join(__dirname, "..", "build_output", variant);
|
||||
const taskPrefix = "standalone." + variant;
|
||||
const electronBaseDir = path.join(__dirname, "..", variantData.electronBaseDir || "electron");
|
||||
const tempDestBuildDir = path.join(tempDestDir, "built");
|
||||
|
||||
gulp.task(taskPrefix + "standalone.prepare.cleanup", () => {
|
||||
gulp.task(taskPrefix + ".prepare.cleanup", () => {
|
||||
return gulp.src(tempDestDir, { read: false, allowEmpty: true }).pipe($.clean({ force: true }));
|
||||
});
|
||||
|
||||
gulp.task(taskPrefix + "standalone.prepare.copyPrefab", () => {
|
||||
gulp.task(taskPrefix + ".prepare.copyPrefab", () => {
|
||||
const requiredFiles = [
|
||||
path.join(electronBaseDir, "node_modules", "**", "*.*"),
|
||||
path.join(electronBaseDir, "node_modules", "**", ".*"),
|
||||
path.join(electronBaseDir, "wegame_sdk", "**", "*.*"),
|
||||
path.join(electronBaseDir, "wegame_sdk", "**", ".*"),
|
||||
path.join(electronBaseDir, "favicon*"),
|
||||
|
||||
// fails on platforms which support symlinks
|
||||
// https://github.com/gulpjs/gulp/issues/1427
|
||||
// path.join(electronBaseDir, "node_modules", "**", "*"),
|
||||
];
|
||||
if (steam) {
|
||||
requiredFiles.push(path.join(electronBaseDir, "steam_appid.txt"));
|
||||
}
|
||||
return gulp.src(requiredFiles, { base: electronBaseDir }).pipe(gulp.dest(tempDestBuildDir));
|
||||
});
|
||||
|
||||
gulp.task(taskPrefix + "standalone.prepare.writePackageJson", cb => {
|
||||
gulp.task(taskPrefix + ".prepare.writePackageJson", cb => {
|
||||
const packageJsonString = JSON.stringify(
|
||||
{
|
||||
scripts: {
|
||||
@@ -85,52 +62,15 @@ function gulptasksStandalone($, gulp) {
|
||||
cb();
|
||||
});
|
||||
|
||||
gulp.task(taskPrefix + "standalone.prepareVDF", cb => {
|
||||
if (!steam) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
const hash = buildutils.getRevision();
|
||||
|
||||
const steampipeDir = path.join(__dirname, "steampipe", "scripts");
|
||||
const templateContents = fs
|
||||
.readFileSync(path.join(steampipeDir, "app.vdf.template"), { encoding: "utf-8" })
|
||||
.toString();
|
||||
|
||||
const convertedContents = templateContents.replace("$DESC$", "Commit " + hash);
|
||||
fs.writeFileSync(path.join(steampipeDir, "app.vdf"), convertedContents);
|
||||
|
||||
cb();
|
||||
});
|
||||
|
||||
gulp.task(taskPrefix + "standalone.prepareVDF.darwin", cb => {
|
||||
if (!steam) {
|
||||
cb();
|
||||
return;
|
||||
}
|
||||
|
||||
const hash = buildutils.getRevision();
|
||||
const steampipeDir = path.join(__dirname, "steampipe-darwin", "scripts");
|
||||
const templateContents = fs
|
||||
.readFileSync(path.join(steampipeDir, "app.vdf.template"), { encoding: "utf-8" })
|
||||
.toString();
|
||||
|
||||
const convertedContents = templateContents.replace("$DESC$", "Commit " + hash);
|
||||
fs.writeFileSync(path.join(steampipeDir, "app.vdf"), convertedContents);
|
||||
|
||||
cb();
|
||||
});
|
||||
|
||||
gulp.task(taskPrefix + "standalone.prepare.minifyCode", () => {
|
||||
gulp.task(taskPrefix + ".prepare.minifyCode", () => {
|
||||
return gulp.src(path.join(electronBaseDir, "*.js")).pipe(gulp.dest(tempDestBuildDir));
|
||||
});
|
||||
|
||||
gulp.task(taskPrefix + "standalone.prepare.copyGamefiles", () => {
|
||||
gulp.task(taskPrefix + ".prepare.copyGamefiles", () => {
|
||||
return gulp.src("../build/**/*.*", { base: "../build" }).pipe(gulp.dest(tempDestBuildDir));
|
||||
});
|
||||
|
||||
gulp.task(taskPrefix + "standalone.killRunningInstances", cb => {
|
||||
gulp.task(taskPrefix + ".killRunningInstances", cb => {
|
||||
try {
|
||||
execSync("taskkill /F /IM shapezio.exe");
|
||||
} catch (ex) {
|
||||
@@ -140,14 +80,14 @@ function gulptasksStandalone($, gulp) {
|
||||
});
|
||||
|
||||
gulp.task(
|
||||
taskPrefix + "standalone.prepare",
|
||||
taskPrefix + ".prepare",
|
||||
gulp.series(
|
||||
taskPrefix + "standalone.killRunningInstances",
|
||||
taskPrefix + "standalone.prepare.cleanup",
|
||||
taskPrefix + "standalone.prepare.copyPrefab",
|
||||
taskPrefix + "standalone.prepare.writePackageJson",
|
||||
taskPrefix + "standalone.prepare.minifyCode",
|
||||
taskPrefix + "standalone.prepare.copyGamefiles"
|
||||
taskPrefix + ".killRunningInstances",
|
||||
taskPrefix + ".prepare.cleanup",
|
||||
taskPrefix + ".prepare.copyPrefab",
|
||||
taskPrefix + ".prepare.writePackageJson",
|
||||
taskPrefix + ".prepare.minifyCode",
|
||||
taskPrefix + ".prepare.copyGamefiles"
|
||||
)
|
||||
);
|
||||
|
||||
@@ -158,11 +98,13 @@ function gulptasksStandalone($, gulp) {
|
||||
* @param {function():void} cb
|
||||
*/
|
||||
function packageStandalone(platform, arch, cb, isRelease = true) {
|
||||
const tomlFile = fs.readFileSync(path.join(__dirname, ".itch.toml"));
|
||||
const privateArtifactsPath = "node_modules/shapez.io-private-artifacts";
|
||||
|
||||
let asar = steam;
|
||||
if (steam && fs.existsSync(path.join(tempDestBuildDir, privateArtifactsPath))) {
|
||||
// Only use asar on steam builds (not supported by wegame)
|
||||
let asar = Boolean(variantData.steamAppId);
|
||||
|
||||
// Unpack private artifacts though
|
||||
if (asar && fs.existsSync(path.join(tempDestBuildDir, privateArtifactsPath))) {
|
||||
// @ts-expect-error
|
||||
asar = { unpackDir: privateArtifactsPath };
|
||||
}
|
||||
@@ -177,10 +119,10 @@ function gulptasksStandalone($, gulp) {
|
||||
asar: asar,
|
||||
executableName: "shapezio",
|
||||
icon: path.join(electronBaseDir, "favicon"),
|
||||
name: "shapez.io-standalone" + suffix,
|
||||
name: "shapez-" + variant,
|
||||
out: tempDestDir,
|
||||
overwrite: true,
|
||||
appBundleId: "tobspr.shapezio.standalone",
|
||||
appBundleId: "tobspr.shapezio." + variant,
|
||||
appCategoryType: "public.app-category.games",
|
||||
...(isRelease &&
|
||||
platform === "darwin" && {
|
||||
@@ -189,6 +131,7 @@ function gulptasksStandalone($, gulp) {
|
||||
"hardenedRuntime": true,
|
||||
"entitlements": "entitlements.plist",
|
||||
"entitlements-inherit": "entitlements.plist",
|
||||
// @ts-ignore
|
||||
"signatureFlags": ["library"],
|
||||
"version": "16.0.7",
|
||||
},
|
||||
@@ -202,43 +145,42 @@ function gulptasksStandalone($, gulp) {
|
||||
console.log("Packages created:", appPaths);
|
||||
appPaths.forEach(appPath => {
|
||||
if (!fs.existsSync(appPath)) {
|
||||
console.error("Bad app path gotten:", appPath);
|
||||
console.error("Bad app path:", appPath);
|
||||
return;
|
||||
}
|
||||
|
||||
if (steam) {
|
||||
if (variantData.steamAppId) {
|
||||
fs.writeFileSync(
|
||||
path.join(appPath, "LICENSE"),
|
||||
fs.readFileSync(path.join(__dirname, "..", "LICENSE"))
|
||||
);
|
||||
|
||||
fse.copySync(
|
||||
path.join(tempDestBuildDir, "steam_appid.txt"),
|
||||
path.join(appPath, "steam_appid.txt")
|
||||
fs.writeFileSync(
|
||||
path.join(appPath, "steam_appid.txt"),
|
||||
String(variantData.steamAppId)
|
||||
);
|
||||
|
||||
fs.writeFileSync(path.join(appPath, ".itch.toml"), tomlFile);
|
||||
|
||||
if (platform === "linux") {
|
||||
// Write launcher script
|
||||
fs.writeFileSync(
|
||||
path.join(appPath, "play.sh"),
|
||||
'#!/usr/bin/env bash\n./shapezio --no-sandbox "$@"\n'
|
||||
);
|
||||
fs.chmodSync(path.join(appPath, "play.sh"), 0o775);
|
||||
}
|
||||
|
||||
if (platform === "darwin") {
|
||||
if (!isRelease) {
|
||||
fse.copySync(
|
||||
path.join(tempDestBuildDir, "steam_appid.txt"),
|
||||
// Needs special location
|
||||
fs.writeFileSync(
|
||||
path.join(
|
||||
path.join(
|
||||
appPath,
|
||||
"shapez.io-standalone.app",
|
||||
"Contents",
|
||||
"MacOS"
|
||||
),
|
||||
appPath,
|
||||
"shapez.io-standalone.app",
|
||||
"Contents",
|
||||
"MacOS",
|
||||
"steam_appid.txt"
|
||||
)
|
||||
),
|
||||
String(variantData.steamAppId)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -255,7 +197,7 @@ function gulptasksStandalone($, gulp) {
|
||||
}
|
||||
|
||||
// Manual signing with patched @electron/osx-sign (we need --no-strict)
|
||||
gulp.task(taskPrefix + "standalone.package.prod.darwin64.signManually", cb =>
|
||||
gulp.task(taskPrefix + ".package.darwin64", cb =>
|
||||
packageStandalone(
|
||||
"darwin",
|
||||
"x64",
|
||||
@@ -327,29 +269,44 @@ function gulptasksStandalone($, gulp) {
|
||||
)
|
||||
);
|
||||
|
||||
gulp.task(taskPrefix + "standalone.package.prod.win64", cb => packageStandalone("win32", "x64", cb));
|
||||
gulp.task(taskPrefix + "standalone.package.prod.linux64", cb =>
|
||||
packageStandalone("linux", "x64", cb)
|
||||
);
|
||||
gulp.task(taskPrefix + "standalone.package.prod.darwin64", cb =>
|
||||
packageStandalone("darwin", "x64", cb)
|
||||
);
|
||||
gulp.task(taskPrefix + "standalone.package.prod.darwin64.unsigned", cb =>
|
||||
packageStandalone("darwin", "x64", cb, false)
|
||||
);
|
||||
|
||||
gulp.task(taskPrefix + ".package.win64", cb => packageStandalone("win32", "x64", cb));
|
||||
gulp.task(taskPrefix + ".package.linux64", cb => packageStandalone("linux", "x64", cb));
|
||||
gulp.task(
|
||||
taskPrefix + "standalone.package.prod",
|
||||
taskPrefix + ".build-from-windows",
|
||||
gulp.series(
|
||||
taskPrefix + "standalone.prepare",
|
||||
gulp.parallel(
|
||||
taskPrefix + "standalone.package.prod.win64",
|
||||
taskPrefix + "standalone.package.prod.linux64",
|
||||
taskPrefix + "standalone.package.prod.darwin64"
|
||||
)
|
||||
taskPrefix + ".prepare",
|
||||
gulp.parallel(taskPrefix + ".package.win64", taskPrefix + ".package.linux64")
|
||||
)
|
||||
);
|
||||
gulp.task(
|
||||
taskPrefix + ".build-from-darwin",
|
||||
gulp.series(taskPrefix + ".prepare", gulp.parallel(taskPrefix + ".package.darwin64"))
|
||||
);
|
||||
}
|
||||
|
||||
// Steam helpers
|
||||
gulp.task("standalone.prepareVDF", cb => {
|
||||
const hash = buildutils.getRevision();
|
||||
const version = buildutils.getVersion();
|
||||
|
||||
for (const platform of ["steampipe", "steampipe-darwin"]) {
|
||||
const steampipeDir = path.join(__dirname, platform, "scripts");
|
||||
for (const buildVariant of ["app", "app-demo"]) {
|
||||
const templateContents = fs
|
||||
.readFileSync(path.join(steampipeDir, buildVariant + ".vdf.template"), {
|
||||
encoding: "utf-8",
|
||||
})
|
||||
.toString();
|
||||
|
||||
const convertedContents = templateContents.replace(
|
||||
"$DESC$",
|
||||
platform + " " + buildVariant + " version " + version + ", commit " + hash
|
||||
);
|
||||
fs.writeFileSync(path.join(steampipeDir, buildVariant + ".vdf"), convertedContents);
|
||||
}
|
||||
}
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { gulptasksStandalone };
|
||||
|
||||
14
gulp/steampipe-darwin/scripts/app-demo.vdf.template
Normal file
14
gulp/steampipe-darwin/scripts/app-demo.vdf.template
Normal file
@@ -0,0 +1,14 @@
|
||||
"appbuild"
|
||||
{
|
||||
"appid" "1930750"
|
||||
"desc" "$DESC$"
|
||||
"buildoutput" "$STEAMPIPE_DIR$/steamtmp"
|
||||
"contentroot" ""
|
||||
"setlive" ""
|
||||
"preview" "0"
|
||||
"local" ""
|
||||
"depots"
|
||||
{
|
||||
"1930756" "$STEAMPIPE_DIR$/scripts/demo-darwin.vdf"
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
{
|
||||
"appid" "1318690"
|
||||
"desc" "$DESC$"
|
||||
"buildoutput" "/Users/tobiasspringer/work/shapez.io/gulp/steampipe-darwin/steamtmp"
|
||||
"buildoutput" "$PROJECT_DIR$/gulp/steampipe-darwin/steamtmp"
|
||||
"contentroot" ""
|
||||
"setlive" ""
|
||||
"preview" "0"
|
||||
"local" ""
|
||||
"depots"
|
||||
{
|
||||
"1318693" "/Users/tobiasspringer/work/shapez.io/gulp/steampipe-darwin/scripts/darwin.vdf"
|
||||
"1318693" "$PROJECT_DIR$/gulp/steampipe-darwin/scripts/darwin.vdf"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"DepotBuildConfig"
|
||||
{
|
||||
"DepotID" "1318693"
|
||||
"contentroot" "/Users/tobiasspringer/work/shapez.io/tmp_standalone_files/shapez.io-standalone-darwin-x64"
|
||||
"contentroot" "$PROJECT_DIR$/tmp_standalone_files/shapez.io-standalone-darwin-x64"
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "*"
|
||||
|
||||
12
gulp/steampipe-darwin/scripts/demo-darwin.vdf
Normal file
12
gulp/steampipe-darwin/scripts/demo-darwin.vdf
Normal file
@@ -0,0 +1,12 @@
|
||||
"DepotBuildConfig"
|
||||
{
|
||||
"DepotID" "1930756"
|
||||
"contentroot" "$PROJECT_DIR$/tmp_standalone_files/shapez.io-demo-darwin-x64"
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "*"
|
||||
"DepotPath" "."
|
||||
"recursive" "1"
|
||||
}
|
||||
"FileExclusion" "*.pdb"
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/sh
|
||||
yarn gulp standalone.prepareVDF.darwin
|
||||
yarn gulp standalone.prepareVDF
|
||||
steamcmd.sh +login $STEAM_UPLOAD_SHAPEZ_ID $STEAM_UPLOAD_SHAPEZ_USER +run_app_build $PWD/scripts/app.vdf +quit
|
||||
|
||||
17
gulp/steampipe/scripts/app-demo.vdf.template
Normal file
17
gulp/steampipe/scripts/app-demo.vdf.template
Normal file
@@ -0,0 +1,17 @@
|
||||
"appbuild"
|
||||
{
|
||||
"appid" "1930750"
|
||||
"desc" "$DESC$"
|
||||
"buildoutput" "$STEAMPIPE_DIR$\steamtemp"
|
||||
"contentroot" ""
|
||||
"setlive" ""
|
||||
"preview" "0"
|
||||
"local" ""
|
||||
"depots"
|
||||
{
|
||||
"1930753" "$STEAMPIPE_DIR$\scripts\demo-windows.vdf"
|
||||
"1930754" "$STEAMPIPE_DIR$\scripts\demo-china-windows.vdf"
|
||||
"1930752" "$STEAMPIPE_DIR$\scripts\demo-linux.vdf"
|
||||
"1930755" "$STEAMPIPE_DIR$\scripts\demo-china-linux.vdf"
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,16 @@
|
||||
{
|
||||
"appid" "1318690"
|
||||
"desc" "$DESC$"
|
||||
"buildoutput" "C:\work\shapez\shapez.io\gulp\steampipe\steamtemp"
|
||||
"buildoutput" "$STEAMPIPE_DIR$\steamtemp"
|
||||
"contentroot" ""
|
||||
"setlive" ""
|
||||
"preview" "0"
|
||||
"local" ""
|
||||
"depots"
|
||||
{
|
||||
"1318691" "C:\work\shapez\shapez.io\gulp\steampipe\scripts\windows.vdf"
|
||||
"1318694" "C:\work\shapez\shapez.io\gulp\steampipe\scripts\china-windows.vdf"
|
||||
"1318692" "C:\work\shapez\shapez.io\gulp\steampipe\scripts\linux.vdf"
|
||||
"1318695" "C:\work\shapez\shapez.io\gulp\steampipe\scripts\china-linux.vdf"
|
||||
"1318691" "$STEAMPIPE_DIR$\scripts\windows.vdf"
|
||||
"1318694" "$STEAMPIPE_DIR$\scripts\china-windows.vdf"
|
||||
"1318692" "$STEAMPIPE_DIR$\scripts\linux.vdf"
|
||||
"1318695" "$STEAMPIPE_DIR$\scripts\china-linux.vdf"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"DepotBuildConfig"
|
||||
{
|
||||
"DepotID" "1318695"
|
||||
"contentroot" "C:\work\shapez\shapez.io\tmp_standalone_files_china\shapez.io-standalonechina-linux-x64"
|
||||
"contentroot" "$PROJECT_DIR$\tmp_standalone_files_china\shapez.io-standalonechina-linux-x64"
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "*"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"DepotBuildConfig"
|
||||
{
|
||||
"DepotID" "1318694"
|
||||
"contentroot" "C:\work\shapez\shapez.io\tmp_standalone_files_china\shapez.io-standalonechina-win32-x64"
|
||||
"contentroot" "$PROJECT_DIR$\shapez.io-standalonechina-win32-x64"
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "*"
|
||||
|
||||
12
gulp/steampipe/scripts/demo-china-linux.vdf
Normal file
12
gulp/steampipe/scripts/demo-china-linux.vdf
Normal file
@@ -0,0 +1,12 @@
|
||||
"DepotBuildConfig"
|
||||
{
|
||||
"DepotID" "1930755"
|
||||
"contentroot" "$PROJECT_DIR$\tmp_standalone_files_china\shapez.io-demochina-linux-x64"
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "*"
|
||||
"DepotPath" "."
|
||||
"recursive" "1"
|
||||
}
|
||||
"FileExclusion" "*.pdb"
|
||||
}
|
||||
12
gulp/steampipe/scripts/demo-china-windows.vdf
Normal file
12
gulp/steampipe/scripts/demo-china-windows.vdf
Normal file
@@ -0,0 +1,12 @@
|
||||
"DepotBuildConfig"
|
||||
{
|
||||
"DepotID" "1930754"
|
||||
"contentroot" "$PROJECT_DIR$\tmp_standalone_files_china\shapez.io-demochina-win32-x64"
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "*"
|
||||
"DepotPath" "."
|
||||
"recursive" "1"
|
||||
}
|
||||
"FileExclusion" "*.pdb"
|
||||
}
|
||||
12
gulp/steampipe/scripts/demo-linux.vdf
Normal file
12
gulp/steampipe/scripts/demo-linux.vdf
Normal file
@@ -0,0 +1,12 @@
|
||||
"DepotBuildConfig"
|
||||
{
|
||||
"DepotID" "1930752"
|
||||
"contentroot" "$PROJECT_DIR$\tmp_standalone_files\shapez.io-demo-linux-x64"
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "*"
|
||||
"DepotPath" "."
|
||||
"recursive" "1"
|
||||
}
|
||||
"FileExclusion" "*.pdb"
|
||||
}
|
||||
12
gulp/steampipe/scripts/demo-windows.vdf
Normal file
12
gulp/steampipe/scripts/demo-windows.vdf
Normal file
@@ -0,0 +1,12 @@
|
||||
"DepotBuildConfig"
|
||||
{
|
||||
"DepotID" "1930753"
|
||||
"contentroot" "$PROJECT_DIR$\tmp_standalone_files\shapez.io-demo-win32-x64"
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "*"
|
||||
"DepotPath" "."
|
||||
"recursive" "1"
|
||||
}
|
||||
"FileExclusion" "*.pdb"
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
"DepotBuildConfig"
|
||||
{
|
||||
"DepotID" "1318692"
|
||||
"contentroot" "C:\work\shapez\shapez.io\tmp_standalone_files\shapez.io-standalone-linux-x64"
|
||||
"contentroot" "$PROJECT_DIR$\tmp_standalone_files\shapez.io-standalone-linux-x64"
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "*"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"DepotBuildConfig"
|
||||
{
|
||||
"DepotID" "1318691"
|
||||
"contentroot" "C:\work\shapez\shapez.io\tmp_standalone_files\shapez.io-standalone-win32-x64"
|
||||
"contentroot" "$PROJECT_DIR$\tmp_standalone_files\shapez.io-standalone-win32-x64"
|
||||
"FileMapping"
|
||||
{
|
||||
"LocalPath" "*"
|
||||
|
||||
3
gulp/steampipe/upload-demo.bat
Normal file
3
gulp/steampipe/upload-demo.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
cmd /c yarn gulp standalone.prepareVDF
|
||||
steamcmd +login %STEAM_UPLOAD_SHAPEZ_ID% %STEAM_UPLOAD_SHAPEZ_USER% +run_app_build %cd%/scripts/app-demo.vdf +quit
|
||||
@@ -1,4 +1,3 @@
|
||||
@echo off
|
||||
cmd /c yarn gulp standalone.prepareVDF
|
||||
steamcmd +login %STEAM_UPLOAD_SHAPEZ_ID% %STEAM_UPLOAD_SHAPEZ_USER% +run_app_build %cd%/scripts/app.vdf +quit
|
||||
start https://partner.steamgames.com/apps/builds/1318690
|
||||
|
||||
@@ -3,10 +3,15 @@
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const { getRevision, getVersion, getAllResourceImages } = require("./buildutils");
|
||||
const lzString = require("lz-string");
|
||||
const CircularDependencyPlugin = require("circular-dependency-plugin");
|
||||
|
||||
module.exports = ({ watch = false, standalone = false, chineseVersion = false, wegameVersion = false }) => {
|
||||
module.exports = ({
|
||||
watch = false,
|
||||
standalone = false,
|
||||
chineseVersion = false,
|
||||
wegameVersion = false,
|
||||
steamDemo = false,
|
||||
}) => {
|
||||
return {
|
||||
mode: "development",
|
||||
devtool: "cheap-source-map",
|
||||
@@ -31,16 +36,13 @@ module.exports = ({ watch = false, standalone = false, chineseVersion = false, w
|
||||
"window.assert(false, 'abstract method called of: ' + (this.name || (this.constructor && this.constructor.name)));",
|
||||
G_HAVE_ASSERT: "true",
|
||||
G_APP_ENVIRONMENT: JSON.stringify("dev"),
|
||||
G_TRACKING_ENDPOINT: JSON.stringify(
|
||||
lzString.compressToEncodedURIComponent("http://localhost:10005/v1")
|
||||
),
|
||||
G_CHINA_VERSION: JSON.stringify(chineseVersion),
|
||||
G_WEGAME_VERSION: JSON.stringify(wegameVersion),
|
||||
G_IS_DEV: "true",
|
||||
G_IS_RELEASE: "false",
|
||||
G_IS_MOBILE_APP: "false",
|
||||
G_IS_BROWSER: "true",
|
||||
G_IS_STANDALONE: standalone ? "true" : "false",
|
||||
G_IS_STANDALONE: JSON.stringify(standalone),
|
||||
G_IS_STEAM_DEMO: JSON.stringify(steamDemo),
|
||||
G_BUILD_TIME: "" + new Date().getTime(),
|
||||
G_BUILD_COMMIT_HASH: JSON.stringify(getRevision()),
|
||||
G_BUILD_VERSION: JSON.stringify(getVersion()),
|
||||
|
||||
@@ -3,24 +3,24 @@
|
||||
const path = require("path");
|
||||
const webpack = require("webpack");
|
||||
const { getRevision, getVersion, getAllResourceImages } = require("./buildutils");
|
||||
const lzString = require("lz-string");
|
||||
|
||||
const TerserPlugin = require("terser-webpack-plugin");
|
||||
const StringReplacePlugin = require("string-replace-webpack-plugin");
|
||||
const UnusedFilesPlugin = require("unused-files-webpack-plugin").UnusedFilesWebpackPlugin;
|
||||
|
||||
module.exports = ({
|
||||
enableAssert = false,
|
||||
environment,
|
||||
es6 = false,
|
||||
|
||||
standalone = false,
|
||||
isBrowser = true,
|
||||
mobileApp = false,
|
||||
|
||||
chineseVersion = false,
|
||||
wegameVersion = false,
|
||||
steamDemo = false,
|
||||
}) => {
|
||||
const globalDefs = {
|
||||
assert: enableAssert ? "window.assert" : "false && window.assert",
|
||||
assert: "false && window.assert",
|
||||
assertAlways: "window.assert",
|
||||
abstract: "window.assert(false, 'abstract method called');",
|
||||
G_IS_DEV: "false",
|
||||
@@ -29,13 +29,10 @@ module.exports = ({
|
||||
G_WEGAME_VERSION: JSON.stringify(wegameVersion),
|
||||
G_IS_RELEASE: environment === "prod" ? "true" : "false",
|
||||
G_IS_STANDALONE: standalone ? "true" : "false",
|
||||
G_IS_STEAM_DEMO: JSON.stringify(steamDemo),
|
||||
G_IS_BROWSER: isBrowser ? "true" : "false",
|
||||
G_IS_MOBILE_APP: mobileApp ? "true" : "false",
|
||||
G_TRACKING_ENDPOINT: JSON.stringify(
|
||||
lzString.compressToEncodedURIComponent("https://tracking.shapez.io/v1")
|
||||
),
|
||||
G_APP_ENVIRONMENT: JSON.stringify(environment),
|
||||
G_HAVE_ASSERT: enableAssert ? "true" : "false",
|
||||
G_HAVE_ASSERT: "false",
|
||||
G_BUILD_TIME: "" + new Date().getTime(),
|
||||
G_BUILD_COMMIT_HASH: JSON.stringify(getRevision()),
|
||||
G_BUILD_VERSION: JSON.stringify(getVersion()),
|
||||
|
||||
Reference in New Issue
Block a user