Switch to gulp 4

This commit is contained in:
Ivan Demchuk 2020-06-13 18:59:25 +03:00
parent 2367d787a0
commit 506193b8c8
11 changed files with 970 additions and 1169 deletions

27
gulp/cordova.js vendored
View File

@ -2,13 +2,15 @@ const path = require("path");
const fs = require("fs"); const fs = require("fs");
const buildUtils = require("./buildutils"); const buildUtils = require("./buildutils");
export function gulptasksCordova($, gulp, buildFolder) { function gulptasksCordova($, gulp, buildFolder) {
const cdvRes = path.join("..", "..", "res"); const cdvRes = path.join("..", "..", "res");
// Cleans up the app assets // Cleans up the app assets
// Removes all temporary folders used while optimizing the assets // Removes all temporary folders used while optimizing the assets
gulp.task("cleanupAppAssetsBuiltFolder", () => { gulp.task("cleanupAppAssetsBuiltFolder", () => {
return gulp.src(path.join(cdvRes, "built"), { read: false }).pipe($.clean({ force: true })); return gulp
.src(path.join(cdvRes, "built"), { read: false, allowEmpty: true })
.pipe($.clean({ force: true }));
}); });
// Optimizes all built assets // Optimizes all built assets
@ -64,7 +66,7 @@ export function gulptasksCordova($, gulp, buildFolder) {
.pipe(gulp.dest(path.join(cdvRes, "built", "ios"))); .pipe(gulp.dest(path.join(cdvRes, "built", "ios")));
}); });
gulp.task("prepareIosRes", ["scaleIconIos", "copyOtherIosResources"]); gulp.task("prepareIosRes", gulp.series("scaleIconIos", "copyOtherIosResources"));
gulp.task("copyAndroidResources", () => { gulp.task("copyAndroidResources", () => {
return gulp return gulp
@ -72,19 +74,20 @@ export function gulptasksCordova($, gulp, buildFolder) {
.pipe(gulp.dest(path.join(cdvRes, "built", "android"))); .pipe(gulp.dest(path.join(cdvRes, "built", "android")));
}); });
gulp.task("prepareAndroidRes", ["copyAndroidResources"]); gulp.task("prepareAndroidRes", gulp.series("copyAndroidResources"));
gulp.task("prepareCordovaAssets", cb => { gulp.task(
return $.sequence( "prepareCordovaAssets",
gulp.series(
"cleanupAppAssetsBuiltFolder", "cleanupAppAssetsBuiltFolder",
["prepareIosRes", "prepareAndroidRes"], gulp.parallel("prepareIosRes", "prepareAndroidRes"),
"optimizeBuiltAppAssets" "optimizeBuiltAppAssets"
)(cb); )
}); );
// Patches the config.xml by replacing the app id to app_beta // Patches the config.xml by replacing the app id to app_beta
gulp.task("patchConfigXML", () => { gulp.task("patchConfigXML", cb => {
const configUrl = path.join("..", "..", "config.xml"); const configUrl = path.join("..", "..", "config.xml");
let configContent = fs.readFileSync(configUrl).toString(); let configContent = fs.readFileSync(configUrl).toString();
const version = buildUtils.getVersion(); const version = buildUtils.getVersion();
@ -92,14 +95,16 @@ export function gulptasksCordova($, gulp, buildFolder) {
configContent = configContent.replace(' id="io.shapez.app" ', ' id="io.shapez.app_beta" '); configContent = configContent.replace(' id="io.shapez.app" ', ' id="io.shapez.app_beta" ');
configContent = configContent.replace("<name>Shapez.io</name>", "<name>Shapez.io BETA</name>"); configContent = configContent.replace("<name>Shapez.io</name>", "<name>Shapez.io BETA</name>");
fs.writeFileSync(configUrl, configContent); fs.writeFileSync(configUrl, configContent);
cb();
}); });
gulp.task("patchConfigXMLChangeStagingToProd", () => { gulp.task("patchConfigXMLChangeStagingToProd", cb => {
const configUrl = path.join("..", "..", "config.xml"); const configUrl = path.join("..", "..", "config.xml");
let configContent = fs.readFileSync(configUrl).toString(); let configContent = fs.readFileSync(configUrl).toString();
configContent = configContent.replace(' id="io.shapez.app_beta" ', ' id="io.shapez.app" '); configContent = configContent.replace(' id="io.shapez.app_beta" ', ' id="io.shapez.app" ');
configContent = configContent.replace("<name>Shapez.io BETA</name>", "<name>Shapez.io</name>"); configContent = configContent.replace("<name>Shapez.io BETA</name>", "<name>Shapez.io</name>");
fs.writeFileSync(configUrl, configContent); fs.writeFileSync(configUrl, configContent);
cb();
}); });
// Triggers a new build on phonegap // Triggers a new build on phonegap

View File

@ -13,7 +13,7 @@ function gulptasksDocs($, gulp, buildFolder) {
.pipe(gulp.dest(path.join("..", "tsc_temp"))); .pipe(gulp.dest(path.join("..", "tsc_temp")));
}); });
gulp.task("docs.copyTsconfigForHints", () => { gulp.task("docs.copyTsconfigForHints", cb => {
const src = fs.readFileSync(path.join("..", "src", "js", "tsconfig.json")).toString(); const src = fs.readFileSync(path.join("..", "src", "js", "tsconfig.json")).toString();
const baseConfig = JSON.parse($.stripJsonComments(src)); const baseConfig = JSON.parse($.stripJsonComments(src));
@ -28,9 +28,10 @@ function gulptasksDocs($, gulp, buildFolder) {
baseConfig.composite = true; baseConfig.composite = true;
baseConfig.outFile = "bundled-ts.js"; baseConfig.outFile = "bundled-ts.js";
fs.writeFileSync(path.join("..", "tsc_temp", "tsconfig.json"), JSON.stringify(baseConfig)); fs.writeFileSync(path.join("..", "tsc_temp", "tsconfig.json"), JSON.stringify(baseConfig));
cb();
}); });
gulp.task("main.prepareDocs", $.sequence("docs.convertJsToTs", "docs.copyTsconfigForHints")); gulp.task("main.prepareDocs", gulp.series("docs.convertJsToTs", "docs.copyTsconfigForHints"));
} }
module.exports = { module.exports = {

View File

@ -28,7 +28,7 @@ function gulptasksFTP($, gulp, buildFolder) {
}; };
// Write the "commit.txt" file // Write the "commit.txt" file
gulp.task("ftp.writeVersion", () => { gulp.task("ftp.writeVersion", cb => {
fs.writeFileSync( fs.writeFileSync(
path.join(buildFolder, "version.json"), path.join(buildFolder, "version.json"),
JSON.stringify( JSON.stringify(
@ -41,6 +41,7 @@ function gulptasksFTP($, gulp, buildFolder) {
4 4
) )
); );
cb();
}); });
const gameSrcGlobs = [ const gameSrcGlobs = [
@ -78,13 +79,13 @@ function gulptasksFTP($, gulp, buildFolder) {
.pipe($.sftp(deployCredentials)); .pipe($.sftp(deployCredentials));
}); });
gulp.task(`ftp.upload.${deployEnv}`, cb => { gulp.task(`ftp.upload.${deployEnv}`, () => {
$.sequence( return gulp.series(
"ftp.writeVersion", "ftp.writeVersion",
`ftp.upload.${deployEnv}.game`, `ftp.upload.${deployEnv}.game`,
`ftp.upload.${deployEnv}.indexHtml`, `ftp.upload.${deployEnv}.indexHtml`,
`ftp.upload.${deployEnv}.additionalFiles` `ftp.upload.${deployEnv}.additionalFiles`
)(cb); );
}); });
} }
} }

View File

@ -1,11 +1,5 @@
/* eslint-disable */ /* eslint-disable */
const nodeVersion = process.versions.node.split(".")[0];
if (nodeVersion !== "10") {
console.error("This cli requires exactly Node.js 10. You are using Node.js " + nodeVersion);
process.exit(1);
}
require("colors"); require("colors");
const gulp = require("gulp"); const gulp = require("gulp");
@ -95,15 +89,15 @@ translations.gulptasksTranslations($, gulp, buildFolder);
// Cleans up everything // Cleans up everything
gulp.task("utils.cleanBuildFolder", () => { gulp.task("utils.cleanBuildFolder", () => {
return gulp.src(buildFolder, { read: false }).pipe($.clean({ force: true })); return gulp.src(buildFolder, { read: false, allowEmpty: true }).pipe($.clean({ force: true }));
}); });
gulp.task("utils.cleanBuildTempFolder", () => { gulp.task("utils.cleanBuildTempFolder", () => {
return gulp return gulp
.src(path.join(__dirname, "..", "src", "js", "built-temp"), { read: false }) .src(path.join(__dirname, "..", "src", "js", "built-temp"), { read: false, allowEmpty: true })
.pipe($.clean({ force: true })); .pipe($.clean({ force: true }));
}); });
gulp.task("utils.cleanup", $.sequence("utils.cleanBuildFolder", "utils.cleanBuildTempFolder")); gulp.task("utils.cleanup", gulp.series("utils.cleanBuildFolder", "utils.cleanBuildTempFolder"));
// Requires no uncomitted files // Requires no uncomitted files
gulp.task("utils.requireCleanWorkingTree", cb => { gulp.task("utils.requireCleanWorkingTree", cb => {
@ -166,32 +160,32 @@ function serve({ standalone }) {
}); });
// Watch .scss files, those trigger a css rebuild // Watch .scss files, those trigger a css rebuild
gulp.watch(["../src/**/*.scss"], ["css.dev"]); gulp.watch(["../src/**/*.scss"], gulp.series("css.dev"));
// Watch .html files, those trigger a html rebuild // Watch .html files, those trigger a html rebuild
gulp.watch("../src/**/*.html", [standalone ? "html.standalone-dev" : "html.dev"]); gulp.watch("../src/**/*.html", gulp.series(standalone ? "html.standalone-dev" : "html.dev"));
// Watch sound files // Watch sound files
// gulp.watch(["../res_raw/sounds/**/*.mp3", "../res_raw/sounds/**/*.wav"], ["sounds.dev"]); // gulp.watch(["../res_raw/sounds/**/*.mp3", "../res_raw/sounds/**/*.wav"], gulp.series("sounds.dev"));
// Watch translations // Watch translations
gulp.watch("../translations/**/*.yaml", ["translations.convertToJson"]); gulp.watch("../translations/**/*.yaml", gulp.series("translations.convertToJson"));
gulp.watch( gulp.watch(
["../res_raw/sounds/sfx/*.mp3", "../res_raw/sounds/sfx/*.wav"], ["../res_raw/sounds/sfx/*.mp3", "../res_raw/sounds/sfx/*.wav"],
$.sequence("sounds.sfx", "sounds.copy") gulp.series("sounds.sfx", "sounds.copy")
); );
gulp.watch( gulp.watch(
["../res_raw/sounds/music/*.mp3", "../res_raw/sounds/music/*.wav"], ["../res_raw/sounds/music/*.mp3", "../res_raw/sounds/music/*.wav"],
$.sequence("sounds.music", "sounds.copy") gulp.series("sounds.music", "sounds.copy")
); );
// Watch resource files and copy them on change // Watch resource files and copy them on change
gulp.watch(imgres.nonImageResourcesGlobs, ["imgres.copyNonImageResources"]); gulp.watch(imgres.nonImageResourcesGlobs, gulp.series("imgres.copyNonImageResources"));
gulp.watch(imgres.imageResourcesGlobs, ["imgres.copyImageResources"]); gulp.watch(imgres.imageResourcesGlobs, gulp.series("imgres.copyImageResources"));
// Watch .atlas files and recompile the atlas on change // Watch .atlas files and recompile the atlas on change
gulp.watch("../res_built/atlas/*.json", ["imgres.atlas"]); gulp.watch("../res_built/atlas/*.json", gulp.series("imgres.atlas"));
// Watch the build folder and reload when anything changed // Watch the build folder and reload when anything changed
const extensions = ["html", "js", "png", "gif", "jpg", "svg", "mp3", "ico", "woff2", "json"]; const extensions = ["html", "js", "png", "gif", "jpg", "svg", "mp3", "ico", "woff2", "json"];
@ -205,32 +199,26 @@ function serve({ standalone }) {
// Start the webpack watching server (Will never return) // Start the webpack watching server (Will never return)
if (standalone) { if (standalone) {
$.sequence("js.standalone-dev.watch")(() => true); gulp.series("js.standalone-dev.watch")(() => true);
} else { } else {
$.sequence("js.dev.watch")(() => true); gulp.series("js.dev.watch")(() => true);
} }
} }
// Live-development
gulp.task("main.serveDev", ["build.dev"], () => serve({ standalone: false }));
gulp.task("main.serveStandalone", ["build.standalone.dev"], () => serve({ standalone: true }));
gulp.task("default", ["main.serveDev"]);
///////////////////// RUNNABLE TASKS ///////////////////// ///////////////////// RUNNABLE TASKS /////////////////////
// Pre and postbuild // Pre and postbuild
gulp.task("step.baseResources", cb => $.sequence("imgres.allOptimized")(cb)); gulp.task("step.baseResources", gulp.series("imgres.allOptimized"));
gulp.task("step.deleteEmpty", cb => { gulp.task("step.deleteEmpty", cb => {
deleteEmpty.sync(buildFolder); deleteEmpty.sync(buildFolder);
cb(); cb();
}); });
gulp.task("step.postbuild", $.sequence("imgres.cleanupUnusedCssInlineImages", "step.deleteEmpty")); gulp.task("step.postbuild", gulp.series("imgres.cleanupUnusedCssInlineImages", "step.deleteEmpty"));
// Builds everything (dev) // Builds everything (dev)
gulp.task("build.dev", cb => { gulp.task("build.dev", () =>
$.sequence( gulp.series(
"utils.cleanup", "utils.cleanup",
"utils.copyAdditionalBuildFiles", "utils.copyAdditionalBuildFiles",
"imgres.atlas", "imgres.atlas",
@ -240,12 +228,12 @@ gulp.task("build.dev", cb => {
"translations.fullBuild", "translations.fullBuild",
"css.dev", "css.dev",
"html.dev" "html.dev"
)(cb); )
}); );
// Builds everything (standalone -dev) // Builds everything (standalone -dev)
gulp.task("build.standalone.dev", cb => { gulp.task("build.standalone.dev", () =>
$.sequence( gulp.series(
"utils.cleanup", "utils.cleanup",
"imgres.atlas", "imgres.atlas",
"sounds.dev", "sounds.dev",
@ -255,58 +243,76 @@ gulp.task("build.standalone.dev", cb => {
"js.standalone-dev", "js.standalone-dev",
"css.dev", "css.dev",
"html.standalone-dev" "html.standalone-dev"
)(cb); )
}); );
// Builds everything (staging) // Builds everything (staging)
gulp.task("step.staging.code", $.sequence("sounds.fullbuild", "translations.fullBuild", "js.staging")); gulp.task("step.staging.code", gulp.series("sounds.fullbuild", "translations.fullBuild", "js.staging"));
gulp.task("step.staging.mainbuild", cb => gulp.task("step.staging.mainbuild", cb =>
$.multiProcess(["utils.copyAdditionalBuildFiles", "step.baseResources", "step.staging.code"], cb, false) $.multiProcess(["utils.copyAdditionalBuildFiles", "step.baseResources", "step.staging.code"], cb, false)
); );
gulp.task("step.staging.all", $.sequence("step.staging.mainbuild", "css.prod", "html.staging")); gulp.task("step.staging.all", gulp.series("step.staging.mainbuild", "css.prod", "html.staging"));
gulp.task("build.staging", $.sequence("utils.cleanup", "step.staging.all", "step.postbuild")); gulp.task("build.staging", gulp.series("utils.cleanup", "step.staging.all", "step.postbuild"));
// Builds everything (prod) // Builds everything (prod)
gulp.task("step.prod.code", $.sequence("sounds.fullbuild", "translations.fullBuild", "js.prod")); gulp.task("step.prod.code", gulp.series("sounds.fullbuild", "translations.fullBuild", "js.prod"));
gulp.task("step.prod.mainbuild", cb => gulp.task("step.prod.mainbuild", cb =>
$.multiProcess(["utils.copyAdditionalBuildFiles", "step.baseResources", "step.prod.code"], cb, false) $.multiProcess(["utils.copyAdditionalBuildFiles", "step.baseResources", "step.prod.code"], cb, false)
); );
gulp.task("step.prod.all", $.sequence("step.prod.mainbuild", "css.prod", "html.prod")); gulp.task("step.prod.all", gulp.series("step.prod.mainbuild", "css.prod", "html.prod"));
gulp.task("build.prod", $.sequence("utils.cleanup", "step.prod.all", "step.postbuild")); gulp.task("build.prod", gulp.series("utils.cleanup", "step.prod.all", "step.postbuild"));
// Builds everything (standalone-beta) // Builds everything (standalone-beta)
gulp.task( gulp.task(
"step.standalone-beta.code", "step.standalone-beta.code",
$.sequence("sounds.fullbuild", "translations.fullBuild", "js.standalone-beta") gulp.series("sounds.fullbuild", "translations.fullBuild", "js.standalone-beta")
); );
gulp.task("step.standalone-beta.mainbuild", cb => gulp.task("step.standalone-beta.mainbuild", cb =>
$.multiProcess(["step.baseResources", "step.standalone-beta.code"], cb, false) $.multiProcess(["step.baseResources", "step.standalone-beta.code"], cb, false)
); );
gulp.task( gulp.task(
"step.standalone-beta.all", "step.standalone-beta.all",
$.sequence("step.standalone-beta.mainbuild", "css.prod-standalone", "html.standalone-beta") 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")
); );
gulp.task("build.standalone-beta", $.sequence("utils.cleanup", "step.standalone-beta.all", "step.postbuild"));
// Builds everything (standalone-prod) // Builds everything (standalone-prod)
gulp.task( gulp.task(
"step.standalone-prod.code", "step.standalone-prod.code",
$.sequence("sounds.fullbuild", "translations.fullBuild", "js.standalone-prod") gulp.series("sounds.fullbuild", "translations.fullBuild", "js.standalone-prod")
); );
gulp.task("step.standalone-prod.mainbuild", cb => gulp.task("step.standalone-prod.mainbuild", cb =>
$.multiProcess(["step.baseResources", "step.standalone-prod.code"], cb, false) $.multiProcess(["step.baseResources", "step.standalone-prod.code"], cb, false)
); );
gulp.task( gulp.task(
"step.standalone-prod.all", "step.standalone-prod.all",
$.sequence("step.standalone-prod.mainbuild", "css.prod-standalone", "html.standalone-prod") gulp.series("step.standalone-prod.mainbuild", "css.prod-standalone", "html.standalone-prod")
);
gulp.task(
"build.standalone-prod",
gulp.series("utils.cleanup", "step.standalone-prod.all", "step.postbuild")
); );
gulp.task("build.standalone-prod", $.sequence("utils.cleanup", "step.standalone-prod.all", "step.postbuild"));
// Deploying! // Deploying!
gulp.task( gulp.task(
"main.deploy.staging", "main.deploy.staging",
$.sequence("utils.requireCleanWorkingTree", "build.staging", "ftp.upload.staging") gulp.series("utils.requireCleanWorkingTree", "build.staging", "ftp.upload.staging")
); );
gulp.task("main.deploy.prod", $.sequence("utils.requireCleanWorkingTree", "build.prod", "ftp.upload.prod")); gulp.task("main.deploy.prod", gulp.series("utils.requireCleanWorkingTree", "build.prod", "ftp.upload.prod"));
gulp.task("main.deploy.all", $.sequence("main.deploy.staging", "main.deploy.prod")); gulp.task("main.deploy.all", gulp.series("main.deploy.staging", "main.deploy.prod"));
gulp.task("main.standalone", $.sequence("build.standalone-prod", "standalone.package.prod")); gulp.task("main.standalone", gulp.series("build.standalone-prod", "standalone.package.prod"));
// Live-development
gulp.task(
"main.serveDev",
gulp.series("build.dev", () => serve({ standalone: false }))
);
gulp.task(
"main.serveStandalone",
gulp.series("build.standalone.dev", () => serve({ standalone: true }))
);
gulp.task("default", gulp.series("main.serveDev"));

View File

@ -10,7 +10,7 @@ const imageResourcesGlobs = ["../res/**/*.png", "../res/**/*.svg", "../res/**/*.
function gulptasksImageResources($, gulp, buildFolder) { function gulptasksImageResources($, gulp, buildFolder) {
// Lossless options // Lossless options
const minifyImagesOptsLossless = () => [ const minifyImagesOptsLossless = () => [
$.imagemin.jpegtran({ $.imageminJpegtran({
progressive: true, progressive: true,
}), }),
$.imagemin.svgo({}), $.imagemin.svgo({}),
@ -25,7 +25,7 @@ function gulptasksImageResources($, gulp, buildFolder) {
// Lossy options // Lossy options
const minifyImagesOpts = () => [ const minifyImagesOpts = () => [
$.imageminMozjpeg({ $.imagemin.mozjpeg({
quality: 80, quality: 80,
maxMemory: 1024 * 1024 * 8, maxMemory: 1024 * 1024 * 8,
}), }),

View File

@ -70,40 +70,39 @@
"css-mqpacker": "^7.0.0", "css-mqpacker": "^7.0.0",
"cssnano": "^4.1.10", "cssnano": "^4.1.10",
"electron-packager": "^14.0.6", "electron-packager": "^14.0.6",
"imagemin-gifsicle": "^7.0.0",
"faster.js": "^1.1.0", "faster.js": "^1.1.0",
"glob": "^7.1.3", "glob": "^7.1.3",
"gulp": "^3.9.1", "gulp": "^4.0.2",
"gulp-cache": "^1.1.3", "gulp-cache": "^1.1.3",
"gulp-cached": "^1.1.1", "gulp-cached": "^1.1.1",
"gulp-clean": "^0.4.0", "gulp-clean": "^0.4.0",
"gulp-cssbeautify": "^1.0.1", "gulp-cssbeautify": "^2.0.1",
"gulp-csslint": "^1.0.1", "gulp-csslint": "^1.0.1",
"gulp-dom": "^1.0.0", "gulp-dom": "^1.0.0",
"gulp-flatten": "^0.4.0", "gulp-flatten": "^0.4.0",
"gulp-fluent-ffmpeg": "^1.0.2", "gulp-fluent-ffmpeg": "^2.0.0",
"gulp-html-beautify": "^1.0.1", "gulp-html-beautify": "^1.0.1",
"gulp-htmlmin": "^5.0.1", "gulp-htmlmin": "^5.0.1",
"gulp-if": "^2.0.2", "gulp-if": "^3.0.0",
"gulp-imagemin": "^5.0.3", "gulp-imagemin": "^7.1.0",
"gulp-javascript-obfuscator": "^1.1.5", "gulp-javascript-obfuscator": "^1.1.5",
"gulp-jsbeautifier": "^3.0.0", "gulp-jsbeautifier": "^3.0.0",
"gulp-load-plugins": "^1.5.0", "gulp-load-plugins": "^2.0.3",
"gulp-multi-process": "^1.3.1", "gulp-multi-process": "^1.3.1",
"gulp-phonegap-build": "^0.1.5", "gulp-phonegap-build": "^0.1.5",
"gulp-plumber": "^1.2.1", "gulp-plumber": "^1.2.1",
"gulp-pngquant": "^1.0.12", "gulp-pngquant": "^1.0.13",
"gulp-postcss": "^8.0.0", "gulp-postcss": "^8.0.0",
"gulp-rename": "^1.4.0", "gulp-rename": "^2.0.0",
"gulp-sass": "^4.0.1", "gulp-sass": "^4.1.0",
"gulp-sass-lint": "^1.4.0", "gulp-sass-lint": "^1.4.0",
"gulp-sequence": "^1.0.0",
"gulp-sftp": "^0.1.5", "gulp-sftp": "^0.1.5",
"gulp-terser": "^1.2.0", "gulp-terser": "^1.2.0",
"gulp-webserver": "^0.9.1", "gulp-webserver": "^0.9.1",
"gulp-yaml": "^2.0.4", "gulp-yaml": "^2.0.4",
"imagemin-mozjpeg": "^8.0.0", "imagemin-gifsicle": "^7.0.0",
"imagemin-pngquant": "^8.0.0", "imagemin-jpegtran": "^7.0.0",
"imagemin-pngquant": "^9.0.0",
"jimp": "^0.6.1", "jimp": "^0.6.1",
"js-yaml": "^3.13.1", "js-yaml": "^3.13.1",
"onesky-fetch": "^0.0.7", "onesky-fetch": "^0.0.7",

View File

@ -79,7 +79,7 @@ function gulptasksSounds($, gulp, buildFolder) {
gulp.task( gulp.task(
"sounds.sfx", "sounds.sfx",
$.sequence("sounds.sfxGenerateSprites", "sounds.sfxOptimize", "sounds.sfxCopyAtlas") gulp.series("sounds.sfxGenerateSprites", "sounds.sfxOptimize", "sounds.sfxCopyAtlas")
); );
gulp.task("sounds.copy", () => { gulp.task("sounds.copy", () => {
@ -92,8 +92,8 @@ function gulptasksSounds($, gulp, buildFolder) {
gulp.task("sounds.buildall", cb => $.multiProcess(["sounds.music", "sounds.sfx"], cb, true)); gulp.task("sounds.buildall", cb => $.multiProcess(["sounds.music", "sounds.sfx"], cb, true));
gulp.task("sounds.fullbuild", cb => $.sequence("sounds.clear", "sounds.buildall", "sounds.copy")(cb)); gulp.task("sounds.fullbuild", gulp.series("sounds.clear", "sounds.buildall", "sounds.copy"));
gulp.task("sounds.dev", cb => $.sequence("sounds.buildall", "sounds.copy")(cb)); gulp.task("sounds.dev", gulp.series("sounds.buildall", "sounds.copy"));
} }
module.exports = { module.exports = {

View File

@ -12,7 +12,7 @@ function gulptasksStandalone($, gulp, buildFolder) {
const tempDestBuildDir = path.join(tempDestDir, "built"); const tempDestBuildDir = path.join(tempDestDir, "built");
gulp.task("standalone.prepare.cleanup", () => { gulp.task("standalone.prepare.cleanup", () => {
return gulp.src(tempDestDir, { read: false }).pipe($.clean({ force: true })); return gulp.src(tempDestDir, { read: false, allowEmpty: true }).pipe($.clean({ force: true }));
}); });
gulp.task("standalone.prepare.copyPrefab", () => { gulp.task("standalone.prepare.copyPrefab", () => {
@ -30,7 +30,7 @@ function gulptasksStandalone($, gulp, buildFolder) {
return gulp.src(requiredFiles, { base: electronBaseDir }).pipe(gulp.dest(tempDestBuildDir)); return gulp.src(requiredFiles, { base: electronBaseDir }).pipe(gulp.dest(tempDestBuildDir));
}); });
gulp.task("standalone.prepare.writePackageJson", () => { gulp.task("standalone.prepare.writePackageJson", cb => {
fs.writeFileSync( fs.writeFileSync(
path.join(tempDestBuildDir, "package.json"), path.join(tempDestBuildDir, "package.json"),
JSON.stringify( JSON.stringify(
@ -43,6 +43,7 @@ function gulptasksStandalone($, gulp, buildFolder) {
4 4
) )
); );
cb();
}); });
gulp.task("standalone.prepare.minifyCode", () => { gulp.task("standalone.prepare.minifyCode", () => {
@ -93,17 +94,18 @@ function gulptasksStandalone($, gulp, buildFolder) {
return gulp.src("../build/**/*.*", { base: "../build" }).pipe(gulp.dest(tempDestBuildDir)); return gulp.src("../build/**/*.*", { base: "../build" }).pipe(gulp.dest(tempDestBuildDir));
}); });
gulp.task("standalone.killRunningInstances", () => { gulp.task("standalone.killRunningInstances", cb => {
try { try {
execSync("taskkill /F /IM shapezio.exe"); execSync("taskkill /F /IM shapezio.exe");
} catch (ex) { } catch (ex) {
console.warn("Failed to kill running instances, maybe none are up."); console.warn("Failed to kill running instances, maybe none are up.");
} }
cb();
}); });
gulp.task( gulp.task(
"standalone.prepare", "standalone.prepare",
$.sequence( gulp.series(
"standalone.killRunningInstances", "standalone.killRunningInstances",
"standalone.prepare.cleanup", "standalone.prepare.cleanup",
"standalone.prepare.copyPrefab", "standalone.prepare.copyPrefab",
@ -190,13 +192,16 @@ function gulptasksStandalone($, gulp, buildFolder) {
gulp.task( gulp.task(
"standalone.package.prod", "standalone.package.prod",
$.sequence("standalone.prepare", [ gulp.series(
"standalone.package.prod.win64", "standalone.prepare",
"standalone.package.prod.linux64", gulp.parallel(
"standalone.package.prod.darwin64", "standalone.package.prod.win64",
// "standalone.package.prod.win32", "standalone.package.prod.linux64",
// "standalone.package.prod.linux32", "standalone.package.prod.darwin64"
]) // "standalone.package.prod.win32",
// "standalone.package.prod.linux32",
)
)
); );
} }

View File

@ -14,7 +14,7 @@ function gulptasksTranslations($, gulp, buildFolder) {
.pipe(gulp.dest(translationsJsonDir)); .pipe(gulp.dest(translationsJsonDir));
}); });
gulp.task("translations.fullBuild", $.sequence("translations.convertToJson")); gulp.task("translations.fullBuild", gulp.series("translations.convertToJson"));
} }
module.exports = { module.exports = {

File diff suppressed because it is too large Load Diff

View File

@ -54,5 +54,5 @@
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"resolveJsonModule": true "resolveJsonModule": true
}, }
} }