diff --git a/.gitignore b/.gitignore index 3d488cd8..29d1fd55 100644 --- a/.gitignore +++ b/.gitignore @@ -54,9 +54,6 @@ config.local.js # Editor artifacts *.*.swp *.*.swo -app.vdf -steamtmp build_output -built_vdfs tmp diff --git a/Dockerfile b/Dockerfile index 0fc1601a..453cb893 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ WORKDIR /shapez.io RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg default-jre \ && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* COPY package.json yarn.lock ./ RUN yarn @@ -20,7 +20,6 @@ WORKDIR /shapez.io COPY res ./res COPY src/html ./src/html COPY src/css ./src/css -COPY version ./version COPY sync-translations.js ./ COPY translations ./translations COPY src/js ./src/js diff --git a/README.md b/README.md index 46c3f25c..5729c57c 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,10 @@ and does not intend to provide compatibility for older clients. - [Node.js 16](https://nodejs.org/en/about/previous-releases) (not 17+, see ) - [Yarn 1](https://classic.yarnpkg.com/en/docs/install) (not 2, we haven't migrated yet) -- [Java](https://www.oracle.com/java/technologies/downloads/) (or [OpenJDK](https://openjdk.org/)) (to run texture packer) +- [Java](https://www.oracle.com/java/technologies/downloads/) (or [OpenJDK](https://openjdk.org/)) to run the texture packer +- [cURL](https://curl.se/download.html)[^1] to download the texture packer + +[^1]: cURL is already installed on most Windows, Linux and macOS systems. ### Development @@ -72,13 +75,11 @@ and does not intend to provide compatibility for older clients. ### Release -> [!CAUTION] -> Release steps are currently unchecked and unmaintained and will likely be revised in the future. +> [!IMPORTANT] +> While there is partial macOS support, it is not tested and adapted yet. Therefore, macOS package creation task is not provided. - Run `yarn` in the root folder and in `electron/`. -- In the root folder, run `yarn gulp build.standalone-steam`. -- Run `yarn gulp standalone.standalone-steam.prepare`. -- Run `yarn gulp standalone.standalone-steam.package.$PLATFORM` where `$PLATFORM` is `win64`, `linux64`, or `darwin64` depending on your system. +- In the root folder, run `yarn package-$PLATFORM` where `$PLATFORM` is `win32` or `linux` depending on your system. - The build will be found under `build_output/standalone-steam` as `shapez-...-x64`. ## Credits diff --git a/gulp/build_variants.js b/gulp/build_variants.js index 686b7b4d..54ec0ab7 100644 --- a/gulp/build_variants.js +++ b/gulp/build_variants.js @@ -3,7 +3,6 @@ * standalone: boolean, * environment?: 'dev' | 'staging' | 'prod', * electronBaseDir?: string, - * steamAppId?: number, * executableName?: string * }>} */ @@ -23,6 +22,5 @@ export const BUILD_VARIANTS = { "standalone-steam": { standalone: true, executableName: "shapez", - steamAppId: 1318690, }, }; diff --git a/gulp/buildutils.js b/gulp/buildutils.js index 762844a4..2164bc25 100644 --- a/gulp/buildutils.js +++ b/gulp/buildutils.js @@ -1,7 +1,6 @@ import glob from "glob"; import { execSync } from "child_process"; import fs from "fs"; -import path from "path/posix"; export function getRevision(useLast = false) { const commitHash = execSync("git rev-parse --short " + (useLast ? "HEAD^1" : "HEAD")).toString("ascii"); @@ -30,7 +29,8 @@ export function getTag() { } export function getVersion() { - return fs.readFileSync(path.join("..", "version")).toString().trim(); + // Use the version number specified in package.json + return JSON.parse(fs.readFileSync("../package.json", "utf-8")).version; } /** diff --git a/gulp/gulpfile.js b/gulp/gulpfile.js index e32b3d11..6771058b 100644 --- a/gulp/gulpfile.js +++ b/gulp/gulpfile.js @@ -258,16 +258,22 @@ for (const variant in BUILD_VARIANTS) { gulp.task(buildName, gulp.series("utils.cleanup", buildName + ".all", "step.postbuild")); - // bundle + // Tasks for creating distributable packages if (data.standalone) { - gulp.task( - "bundle." + variant + ".from-windows", - gulp.series(buildName, "standalone." + variant + ".build-from-windows") - ); - gulp.task( - "bundle." + variant + ".from-darwin", - gulp.series(buildName, "standalone." + variant + ".build-from-darwin") - ); + // TODO: Figure out macOS support as a non-published app + const packagePlatforms = ["win32", "linux"]; + + for (const platform of packagePlatforms) { + gulp.task( + `package.${variant}.${platform}`, + gulp.series( + `build.${variant}`, + "utils.cleanBuildOutputFolder", + `standalone.${variant}.prepare`, + `standalone.${variant}.package.${platform}` + ) + ); + } } // serve @@ -287,15 +293,5 @@ gulp.task( gulp.series("utils.requireCleanWorkingTree", "build.web-shapezio", "ftp.upload.prod") ); -// Bundling (pre upload) -gulp.task( - "bundle.steam.from-darwin", - gulp.series("utils.cleanBuildOutputFolder", "bundle.standalone-steam.from-darwin") -); -gulp.task( - "bundle.steam.from-windows", - gulp.series("utils.cleanBuildOutputFolder", "bundle.standalone-steam.from-windows") -); - // Default task (dev, localhost) gulp.task("default", gulp.series("serve.standalone-steam")); diff --git a/gulp/image-resources.js b/gulp/image-resources.js index d71b2472..d247c231 100644 --- a/gulp/image-resources.js +++ b/gulp/image-resources.js @@ -96,28 +96,12 @@ export default function gulptasksImageResources(gulp, buildFolder) { execute("java -version"); // Now check and try downloading runnable-texturepacker.jar (22MB) if (!fs.existsSync("./runnable-texturepacker.jar")) { - const safeLink = JSON.stringify(runnableTPSource); - const commands = [ - // linux/macos if installed - `wget -O runnable-texturepacker.jar ${safeLink}`, - // linux/macos, latest windows 10 - `curl -o runnable-texturepacker.jar ${safeLink}`, - // windows 10 / updated windows 7+ - "powershell.exe -Command (new-object System.Net.WebClient)" + - `.DownloadFile(${safeLink.replace(/"/g, "'")}, 'runnable-texturepacker.jar')`, - // windows 7+, vulnerability exploit - `certutil.exe -urlcache -split -f ${safeLink} runnable-texturepacker.jar`, - ]; + const escapedLink = JSON.stringify(runnableTPSource); - while (commands.length) { - try { - execute(commands.shift()); - break; - } catch { - if (!commands.length) { - throw new Error("Failed to download runnable-texturepacker.jar!"); - } - } + try { + execute(`curl -o runnable-texturepacker.jar ${escapedLink}`); + } catch { + throw new Error("Failed to download runnable-texturepacker.jar!"); } } diff --git a/gulp/standalone.js b/gulp/standalone.js index ce40193e..4e9479e1 100644 --- a/gulp/standalone.js +++ b/gulp/standalone.js @@ -24,7 +24,7 @@ export default function gulptasksStandalone(gulp) { } const tempDestDir = path.join("..", "build_output", variant); const taskPrefix = "standalone." + variant; - const electronBaseDir = path.join("..", variantData.electronBaseDir || "electron"); + const electronBaseDir = path.join("..", "electron"); const tempDestBuildDir = path.join(tempDestDir, "built"); gulp.task(taskPrefix + ".prepare.cleanup", () => { @@ -40,16 +40,6 @@ export default function gulptasksStandalone(gulp) { return gulp.src(requiredFiles, { base: electronBaseDir }).pipe(gulp.dest(tempDestBuildDir)); }); - gulp.task(taskPrefix + ".prepare.writeAppId", cb => { - if (variantData.steamAppId) { - fs.writeFileSync( - path.join(tempDestBuildDir, "steam_appid.txt"), - String(variantData.steamAppId) - ); - } - cb(); - }); - gulp.task(taskPrefix + ".prepare.writePackageJson", cb => { const packageJsonString = JSON.stringify( { @@ -94,8 +84,7 @@ export default function gulptasksStandalone(gulp) { taskPrefix + ".prepare.copyPrefab", taskPrefix + ".prepare.writePackageJson", taskPrefix + ".prepare.minifyCode", - taskPrefix + ".prepare.copyGamefiles", - taskPrefix + ".prepare.writeAppId" + taskPrefix + ".prepare.copyGamefiles" ) ); @@ -155,41 +144,18 @@ export default function gulptasksStandalone(gulp) { return; } - if (variantData.steamAppId) { + fs.writeFileSync( + path.join(appPath, "LICENSE"), + fs.readFileSync(path.join("..", "LICENSE")) + ); + + if (platform === "linux") { + // Write launcher script fs.writeFileSync( - path.join(appPath, "LICENSE"), - fs.readFileSync(path.join("..", "LICENSE")) + path.join(appPath, "play.sh"), + '#!/usr/bin/env bash\n./shapezio --no-sandbox "$@"\n' ); - - fs.writeFileSync( - path.join(appPath, "steam_appid.txt"), - String(variantData.steamAppId) - ); - - 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) { - // Needs special location - fs.writeFileSync( - path.join( - appPath, - "shapez.app", - "Contents", - "MacOS", - "steam_appid.txt" - ), - String(variantData.steamAppId) - ); - } - } + fs.chmodSync(path.join(appPath, "play.sh"), 0o775); } }); @@ -203,7 +169,7 @@ export default function gulptasksStandalone(gulp) { } // Manual signing with patched @electron/osx-sign (we need --no-strict) - gulp.task(taskPrefix + ".package.darwin64", cb => + gulp.task(taskPrefix + ".package.darwin", cb => packageStandalone( "darwin", "x64", @@ -212,26 +178,6 @@ export default function gulptasksStandalone(gulp) { const appFileInner = path.join(appFile, "shapez.app"); console.warn("++ Signing ++"); - if (variantData.steamAppId) { - const appIdDest = path.join( - path.join(appFileInner, "Contents", "MacOS"), - "steam_appid.txt" - ); - // console.warn("++ Preparing ++"); - // fse.copySync(path.join(tempDestBuildDir, "steam_appid.txt"), appIdDest); - - console.warn("Signing steam_appid.txt"); - - execSync( - `codesign --force --verbose --options runtime --timestamp --no-strict --sign "${ - process.env.SHAPEZ_CLI_APPLE_CERT_NAME - }" --entitlements "${path.join("entitlements.plist")}" ${appIdDest}`, - { - cwd: appFile, - } - ); - } - console.warn("Base dir:", appFile); signAsync({ @@ -275,58 +221,7 @@ export default function gulptasksStandalone(gulp) { ) ); - gulp.task(taskPrefix + ".package.win64", cb => packageStandalone("win32", "x64", cb)); - gulp.task(taskPrefix + ".package.linux64", cb => packageStandalone("linux", "x64", cb)); - gulp.task( - taskPrefix + ".build-from-windows", - gulp.series( - 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")) - ); + gulp.task(taskPrefix + ".package.win32", cb => packageStandalone("win32", "x64", cb)); + gulp.task(taskPrefix + ".package.linux", cb => packageStandalone("linux", "x64", cb)); } - - // Steam helpers - gulp.task("standalone.prepareVDF", cb => { - const hash = getRevision(); - const version = getVersion(); - - // for (const platform of ["steampipe", "steampipe-darwin"]) { - const templatesSource = path.join("steampipe", "templates"); - const templatesDest = path.join("steampipe", "built_vdfs"); - - const variables = { - PROJECT_DIR: path.resolve(path.join("..")).replace(/\\/g, "/"), - BUNDLE_DIR: path.resolve(path.join("..", "build_output")).replace(/\\/g, "/"), - - TMP_DIR: path.resolve(path.join("steampipe", "tmp")).replace(/\\/g, "/"), - // BUILD_DESC: "v" + version + " @ " + hash, - VDF_DIR: path.resolve(path.join("steampipe", "built_vdfs")).replace(/\\/g, "/"), - }; - - const files = fs.readdirSync(templatesSource); - for (const file of files) { - if (!file.endsWith(".vdf")) { - continue; - } - - variables.BUILD_DESC = file.replace(".vdf", "") + " - v" + version + " @ " + hash; - - let content = fs.readFileSync(path.join(templatesSource, file)).toString("utf-8"); - content = content.replace(/\$([^$]+)\$/gi, (_, variable) => { - if (!variables[variable]) { - throw new Error("Unknown variable " + variable + " in " + file); - } - - return variables[variable]; - }); - - fs.writeFileSync(path.join(templatesDest, file), content, { encoding: "utf8" }); - } - cb(); - }); } diff --git a/gulp/steampipe/.gitignore b/gulp/steampipe/.gitignore deleted file mode 100644 index 0fced5d4..00000000 --- a/gulp/steampipe/.gitignore +++ /dev/null @@ -1 +0,0 @@ -steamtemp diff --git a/gulp/steampipe/templates/app-darwin.vdf b/gulp/steampipe/templates/app-darwin.vdf deleted file mode 100644 index fa63b846..00000000 --- a/gulp/steampipe/templates/app-darwin.vdf +++ /dev/null @@ -1,14 +0,0 @@ -"appbuild" -{ - "appid" "1318690" - "desc" "$BUILD_DESC$" - "buildoutput" "$TMP_DIR$" - "contentroot" "" - "setlive" "" - "preview" "0" - "local" "" - "depots" - { - "1318693" "$VDF_DIR$/standalone-darwin.vdf" - } -} diff --git a/gulp/steampipe/templates/app-winlinux.vdf b/gulp/steampipe/templates/app-winlinux.vdf deleted file mode 100644 index 26b7cc39..00000000 --- a/gulp/steampipe/templates/app-winlinux.vdf +++ /dev/null @@ -1,15 +0,0 @@ -"appbuild" -{ - "appid" "1318690" - "desc" "$BUILD_DESC$" - "buildoutput" "$TMP_DIR$" - "contentroot" "" - "setlive" "" - "preview" "0" - "local" "" - "depots" - { - "1318691" "$VDF_DIR$\standalone-windows.vdf" - "1318692" "$VDF_DIR$\standalone-linux.vdf" - } -} diff --git a/gulp/steampipe/templates/standalone-darwin.vdf b/gulp/steampipe/templates/standalone-darwin.vdf deleted file mode 100644 index 026ab768..00000000 --- a/gulp/steampipe/templates/standalone-darwin.vdf +++ /dev/null @@ -1,12 +0,0 @@ -"DepotBuildConfig" -{ - "DepotID" "1318693" - "contentroot" "$BUNDLE_DIR$\standalone-steam\shapez-darwin-x64" - "FileMapping" - { - "LocalPath" "*" - "DepotPath" "." - "recursive" "1" - } - "FileExclusion" "*.pdb" -} \ No newline at end of file diff --git a/gulp/steampipe/templates/standalone-linux.vdf b/gulp/steampipe/templates/standalone-linux.vdf deleted file mode 100644 index 9edb1963..00000000 --- a/gulp/steampipe/templates/standalone-linux.vdf +++ /dev/null @@ -1,12 +0,0 @@ -"DepotBuildConfig" -{ - "DepotID" "1318692" - "contentroot" "$BUNDLE_DIR$\standalone-steam\shapez-linux-x64" - "FileMapping" - { - "LocalPath" "*" - "DepotPath" "." - "recursive" "1" - } - "FileExclusion" "*.pdb" -} \ No newline at end of file diff --git a/gulp/steampipe/templates/standalone-windows.vdf b/gulp/steampipe/templates/standalone-windows.vdf deleted file mode 100644 index 6f7cb408..00000000 --- a/gulp/steampipe/templates/standalone-windows.vdf +++ /dev/null @@ -1,12 +0,0 @@ -"DepotBuildConfig" -{ - "DepotID" "1318691" - "contentroot" "$BUNDLE_DIR$\standalone-steam\shapez-win32-x64" - "FileMapping" - { - "LocalPath" "*" - "DepotPath" "." - "recursive" "1" - } - "FileExclusion" "*.pdb" -} \ No newline at end of file diff --git a/gulp/steampipe/upload-darwin-demo.sh b/gulp/steampipe/upload-darwin-demo.sh deleted file mode 100755 index 77bb29dc..00000000 --- a/gulp/steampipe/upload-darwin-demo.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -yarn gulp standalone.prepareVDF -steamcmd.sh +login $STEAM_UPLOAD_SHAPEZ_ID $STEAM_UPLOAD_SHAPEZ_USER +run_app_build $PWD/built_vdfs/app-darwin-demo.vdf +quit diff --git a/gulp/steampipe/upload-darwin.sh b/gulp/steampipe/upload-darwin.sh deleted file mode 100755 index 06412dcd..00000000 --- a/gulp/steampipe/upload-darwin.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -yarn gulp standalone.prepareVDF -steamcmd.sh +login $STEAM_UPLOAD_SHAPEZ_ID $STEAM_UPLOAD_SHAPEZ_USER +run_app_build $PWD/built_vdfs/app-darwin.vdf +quit diff --git a/gulp/steampipe/upload-winlinux-demo.bat b/gulp/steampipe/upload-winlinux-demo.bat deleted file mode 100644 index e19f7f55..00000000 --- a/gulp/steampipe/upload-winlinux-demo.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -cmd /c yarn gulp standalone.prepareVDF -steamcmd +login %STEAM_UPLOAD_SHAPEZ_ID% %STEAM_UPLOAD_SHAPEZ_USER% +run_app_build %cd%/built_vdfs/app-winlinux-demo.vdf +quit diff --git a/gulp/steampipe/upload-winlinux.bat b/gulp/steampipe/upload-winlinux.bat deleted file mode 100644 index 1c9bdfe7..00000000 --- a/gulp/steampipe/upload-winlinux.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -cmd /c yarn gulp standalone.prepareVDF -steamcmd +login %STEAM_UPLOAD_SHAPEZ_ID% %STEAM_UPLOAD_SHAPEZ_USER% +run_app_build %cd%/built_vdfs/app-winlinux.vdf +quit diff --git a/gulp/translations.js b/gulp/translations.js index f569e5a8..257ca885 100644 --- a/gulp/translations.js +++ b/gulp/translations.js @@ -18,43 +18,4 @@ export default function gulptasksTranslations(gulp) { }); gulp.task("translations.fullBuild", gulp.series("translations.convertToJson")); - - gulp.task("translations.prepareSteamPage", cb => { - const files = fs.readdirSync(translationsSourceDir); - - files - .filter(name => name.endsWith(".yaml")) - .forEach(fname => { - console.log("Loading", fname); - const languageName = fname.replace(".yaml", ""); - const abspath = path.join(translationsSourceDir, fname); - - const destpath = path.join(translationsSourceDir, "tmp", languageName + "-store.txt"); - - const contents = fs.readFileSync(abspath, { encoding: "utf-8" }); - const data = YAML.parse(contents); - - const storePage = data.steamPage; - - const content = ` - [img]{STEAM_APP_IMAGE}/extras/store_page_gif.gif[/img] - - ${storePage.intro.replace(/\n/gi, "\n\n")} - - [h2]${storePage.what_others_say}[/h2] - - [list] - [*] [i]${storePage.nothernlion_comment}[/i] [b]- Northernlion, YouTube[/b] - [*] [i]${storePage.notch_comment}[/i] [b]- Notch[/b] - [*] [i]${storePage.steam_review_comment}[/i] [b]- Steam User[/b] - [/list] - `; - - fs.writeFileSync(destpath, content.replace(/(\n[ \t\r]*)/gi, "\n").trim(), { - encoding: "utf-8", - }); - }); - - cb(); - }); } diff --git a/gulp/webpack.production.config.js b/gulp/webpack.production.config.js index 0e5265e1..f01badbc 100644 --- a/gulp/webpack.production.config.js +++ b/gulp/webpack.production.config.js @@ -3,9 +3,7 @@ import TerserPlugin from "terser-webpack-plugin"; import webpack from "webpack"; const { DefinePlugin, IgnorePlugin } = webpack; import DeadCodePlugin from "webpack-deadcode-plugin"; -import pj from "../package.json" assert { type: "json" }; -const { version } = pj; -import { getAllResourceImages, getRevision } from "./buildutils.js"; +import { getAllResourceImages, getRevision, getVersion } from "./buildutils.js"; const globalDefs = { "assert": "false && window.assert", @@ -16,7 +14,7 @@ const globalDefs = { "G_APP_ENVIRONMENT": JSON.stringify("release"), "G_BUILD_TIME": new Date().getTime().toString(), "G_BUILD_COMMIT_HASH": JSON.stringify(getRevision()), - "G_BUILD_VERSION": JSON.stringify(version), + "G_BUILD_VERSION": JSON.stringify(getVersion()), "G_ALL_UI_IMAGES": JSON.stringify(getAllResourceImages()), "G_IS_RELEASE": "true", diff --git a/package.json b/package.json index d17b3f69..fc2bbafb 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,9 @@ "gulp": "gulp --cwd gulp", "lint": "eslint src/js", "prettier-all": "prettier --write src/**/*.* && prettier --write gulp/**/*.*", - "buildTypes": "tsc src/js/application.js --declaration --allowJs --emitDeclarationOnly --skipLibCheck --out types.js" + "buildTypes": "tsc src/js/application.js --declaration --allowJs --emitDeclarationOnly --skipLibCheck --out types.js", + "package-win32": "gulp package.standalone-steam.win32", + "package-linux": "gulp package.standalone-steam.linux" }, "dependencies": { "ajv": "^6.10.2", diff --git a/version b/version deleted file mode 100644 index 03082db7..00000000 --- a/version +++ /dev/null @@ -1 +0,0 @@ -1.5.6 \ No newline at end of file