diff options
Diffstat (limited to 'build.js')
-rwxr-xr-x | build.js | 81 |
1 files changed, 4 insertions, 77 deletions
@@ -4,18 +4,7 @@ const zlib = require('zlib'); const child_process = require("child_process"); const crypto = require("crypto"); -console.log("Note: use './build.js stable' to release a stable version."); -console.log(" use './build.js launcher' to build the launchers."); - -if (process.argv[2] === "stable" && fs.readFileSync("./client/index.html").toString().replaceAll(" ", "").includes("window.betaVersion=true;")) { - console.error("Error: stable version is marked as beta through the 'window.betaVersion' property."); - process.exit(2); -} - -if (process.argv[2] !== "stable" && fs.readFileSync("./client/index.html").toString().replaceAll(" ", "").includes("window.betaVersion=false;")) { - console.error("Error: beta version is marked as stable through the 'window.betaVersion' property."); - process.exit(2); -} +console.log("Note: use './build.js launcher' to build the launchers."); let ignore = [ "bans.json", @@ -48,8 +37,6 @@ function scandir(path) { return list; } -// Client - let list = scandir("./client"); let pack = []; @@ -72,71 +59,11 @@ for (let item of list) { fs.writeFileSync("build/client.lctpk", zlib.brotliCompressSync(JSON.stringify(pack))); -// Server - -list = scandir("./server"); -pack = []; - -for (let item of list) { - if (fs.lstatSync(item).isDirectory()) { - pack.push({ - type: "directory", - name: item, - content: null - }); - } else { - pack.push({ - type: "file", - name: item, - content: zlib.brotliCompressSync(fs.readFileSync(item)).toString("base64"), - hash: crypto.createHash("sha256").update(fs.readFileSync(item)).digest("base64") - }); - } -} - -fs.writeFileSync("build/server.lctpk", zlib.brotliCompressSync(JSON.stringify(pack))); - -// Shared - -list = scandir("./shared"); -pack = []; - -for (let item of list) { - if (fs.lstatSync(item).isDirectory()) { - pack.push({ - type: "directory", - name: item, - content: null, - hash: null - }); - } else { - pack.push({ - type: "file", - name: item, - content: zlib.brotliCompressSync(fs.readFileSync(item)).toString("base64"), - hash: crypto.createHash("sha256").update(fs.readFileSync(item)).digest("base64") - }); - } -} - -fs.writeFileSync("build/shared.lctpk", zlib.brotliCompressSync(JSON.stringify(pack))); - -if (process.argv[2] === "stable") { - console.log("Uploading to stable channel"); - child_process.execSync("scp build/client.lctpk bridlewood:/opt/localchat/update/client.stable.lctpk", { stdio: "inherit" }); - child_process.execSync("scp build/server.lctpk bridlewood:/opt/localchat/update/server.stable.lctpk", { stdio: "inherit" }); - child_process.execSync("scp build/shared.lctpk bridlewood:/opt/localchat/update/shared.stable.lctpk", { stdio: "inherit" }); -} else { - console.log("Uploading to beta channel"); - child_process.execSync("scp build/client.lctpk bridlewood:/opt/localchat/update/client.beta.lctpk", { stdio: "inherit" }); - child_process.execSync("scp build/server.lctpk bridlewood:/opt/localchat/update/server.beta.lctpk", { stdio: "inherit" }); - child_process.execSync("scp build/shared.lctpk bridlewood:/opt/localchat/update/shared.beta.lctpk", { stdio: "inherit" }); -} +child_process.execSync("scp build/client.lctpk bridlewood:/opt/localchat/update/client.stable.lctpk", { stdio: "inherit" }); +child_process.execSync("scp build/client.lctpk bridlewood:/opt/localchat/update/client.beta.lctpk", { stdio: "inherit" }); +child_process.execSync("scp build/client.lctpk bridlewood:/opt/localchat/update/client.lctpk", { stdio: "inherit" }); if (process.argv[2] === "launcher") { - child_process.execSync("npx pkg -C GZip -o ../../build/server/mac/lcts -t node18-darwin-arm64 index.js", { cwd: "./launcher/server", stdio: "inherit" }); - child_process.execSync("npx pkg -C GZip -o ../../build/server/linux/lcts -t node18-linuxstatic-x64 index.js", { cwd: "./launcher/server", stdio: "inherit" }); - child_process.execSync("npx pkg -C GZip -o ../../build/server/win32/lcts.exe -t node18-win32-x64 index.js", { cwd: "./launcher/server", stdio: "inherit" }); child_process.execSync("npx electron-packager . Chatroom --ignore build --ignore scripts --overwrite --icon icon.icns --platform=darwin --arch=arm64 --out=../../build/client", { cwd: "./launcher/client", stdio: "inherit" }) child_process.execSync("npx electron-packager . Chatroom --ignore build --ignore scripts --overwrite --icon icon.icns --platform=win32 --arch=x64 --out=../../build/client", { cwd: "./launcher/client", stdio: "inherit" }) child_process.execSync("npx electron-packager . Chatroom --ignore build --ignore scripts --overwrite --icon icon.png --platform=linux --arch=x64 --out=../../build/client", { cwd: "./launcher/client", stdio: "inherit" }) |