diff options
author | Sefa Eyeoglu <contact@scrumplex.net> | 2023-08-25 14:15:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-25 14:15:02 +0200 |
commit | 714d87241ceb07dfd6c08cee55347a937e97a279 (patch) | |
tree | e65caebca7a459c3bd29e69573fcac9398132218 /scripts/build | |
parent | f628aa7a70fdf33757995836bca90dcd4d759d37 (diff) | |
download | Vencord-714d87241ceb07dfd6c08cee55347a937e97a279.tar.gz Vencord-714d87241ceb07dfd6c08cee55347a937e97a279.tar.bz2 Vencord-714d87241ceb07dfd6c08cee55347a937e97a279.zip |
build: allow overriding git details & disabling updating (#1677)
Co-authored-by: V <vendicated@riseup.net>
Diffstat (limited to 'scripts/build')
-rwxr-xr-x | scripts/build/build.mjs | 5 | ||||
-rw-r--r-- | scripts/build/buildWeb.mjs | 5 | ||||
-rw-r--r-- | scripts/build/common.mjs | 18 |
3 files changed, 18 insertions, 10 deletions
diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs index e044378..ce84fed 100755 --- a/scripts/build/build.mjs +++ b/scripts/build/build.mjs @@ -19,13 +19,14 @@ import esbuild from "esbuild"; -import { commonOpts, globPlugins, isStandalone, VERSION, watch } from "./common.mjs"; +import { BUILD_TIMESTAMP, commonOpts, globPlugins, isStandalone, updaterDisabled, VERSION, watch } from "./common.mjs"; const defines = { IS_STANDALONE: isStandalone, IS_DEV: JSON.stringify(watch), + IS_UPDATER_DISABLED: updaterDisabled, VERSION: JSON.stringify(VERSION), - BUILD_TIMESTAMP: Date.now(), + BUILD_TIMESTAMP, }; if (defines.IS_STANDALONE === "false") // If this is a local build (not standalone), optimise diff --git a/scripts/build/buildWeb.mjs b/scripts/build/buildWeb.mjs index 434d176..aab82d0 100644 --- a/scripts/build/buildWeb.mjs +++ b/scripts/build/buildWeb.mjs @@ -24,7 +24,7 @@ import { readFileSync } from "fs"; import { appendFile, mkdir, readFile, rm, writeFile } from "fs/promises"; import { join } from "path"; -import { commonOpts, globPlugins, VERSION, watch } from "./common.mjs"; +import { BUILD_TIMESTAMP, commonOpts, globPlugins, VERSION, watch } from "./common.mjs"; /** * @type {esbuild.BuildOptions} @@ -46,8 +46,9 @@ const commonOptions = { IS_DEV: JSON.stringify(watch), IS_DISCORD_DESKTOP: "false", IS_VESKTOP: "false", + IS_UPDATER_DISABLED: "true", VERSION: JSON.stringify(VERSION), - BUILD_TIMESTAMP: Date.now(), + BUILD_TIMESTAMP, } }; diff --git a/scripts/build/common.mjs b/scripts/build/common.mjs index b63ea61..a12e9ee 100644 --- a/scripts/build/common.mjs +++ b/scripts/build/common.mjs @@ -30,15 +30,18 @@ import PackageJSON from "../../package.json" assert { type: "json" }; import { getPluginTarget } from "../utils.mjs"; export const VERSION = PackageJSON.version; -export const BUILD_TIMESTAMP = Date.now(); +// https://reproducible-builds.org/docs/source-date-epoch/ +export const BUILD_TIMESTAMP = Number(process.env.SOURCE_DATE_EPOCH) || Date.now(); export const watch = process.argv.includes("--watch"); export const isStandalone = JSON.stringify(process.argv.includes("--standalone")); -export const gitHash = execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim(); +export const updaterDisabled = JSON.stringify(process.argv.includes("--disable-updater")); +export const gitHash = process.env.VENCORD_HASH || execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim(); export const banner = { js: ` // Vencord ${gitHash} // Standalone: ${isStandalone} // Platform: ${isStandalone === "false" ? process.platform : "Universal"} +// Updater disabled: ${updaterDisabled} `.trim() }; @@ -133,11 +136,14 @@ export const gitRemotePlugin = { namespace: "git-remote", path: args.path })); build.onLoad({ filter, namespace: "git-remote" }, async () => { + let remote = process.env.VENCORD_REMOTE; + if (!remote) { const res = await promisify(exec)("git remote get-url origin", { encoding: "utf-8" }); - const remote = res.stdout.trim() - .replace("https://github.com/", "") - .replace("git@github.com:", "") - .replace(/.git$/, ""); + remote = res.stdout.trim() + .replace("https://github.com/", "") + .replace("git@github.com:", "") + .replace(/.git$/, ""); + } return { contents: `export default "${remote}"` }; }); |