aboutsummaryrefslogtreecommitdiff
path: root/scripts/build
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/build')
-rwxr-xr-xscripts/build/build.mjs6
-rw-r--r--scripts/build/buildWeb.mjs12
-rw-r--r--scripts/build/common.mjs6
3 files changed, 16 insertions, 8 deletions
diff --git a/scripts/build/build.mjs b/scripts/build/build.mjs
index 45cda74..e37feb5 100755
--- a/scripts/build/build.mjs
+++ b/scripts/build/build.mjs
@@ -19,11 +19,13 @@
import esbuild from "esbuild";
-import { commonOpts, globPlugins, isStandalone, watch } from "./common.mjs";
+import { commonOpts, globPlugins, isStandalone, VERSION, watch } from "./common.mjs";
const defines = {
IS_STANDALONE: isStandalone,
- IS_DEV: JSON.stringify(watch)
+ IS_DEV: JSON.stringify(watch),
+ VERSION: JSON.stringify(VERSION),
+ BUILD_TIMESTAMP: Date.now(),
};
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 cc27ea8..5c1cc78 100644
--- a/scripts/build/buildWeb.mjs
+++ b/scripts/build/buildWeb.mjs
@@ -24,9 +24,7 @@ import { readFileSync } from "fs";
import { appendFile, mkdir, readFile, rm, writeFile } from "fs/promises";
import { join } from "path";
-// wtf is this assert syntax
-import PackageJSON from "../../package.json" assert { type: "json" };
-import { commonOpts, globPlugins, watch } from "./common.mjs";
+import { commonOpts, globPlugins, VERSION, watch } from "./common.mjs";
/**
* @type {esbuild.BuildOptions}
@@ -47,7 +45,9 @@ const commonOptions = {
IS_STANDALONE: "true",
IS_DEV: JSON.stringify(watch),
IS_DISCORD_DESKTOP: "false",
- IS_VENCORD_DESKTOP: "false"
+ IS_VENCORD_DESKTOP: "false",
+ VERSION: JSON.stringify(VERSION),
+ BUILD_TIMESTAMP: Date.now(),
}
};
@@ -67,7 +67,7 @@ await Promise.all(
},
outfile: "dist/Vencord.user.js",
banner: {
- js: readFileSync("browser/userscript.meta.js", "utf-8").replace("%version%", `${PackageJSON.version}.${new Date().getTime()}`)
+ js: readFileSync("browser/userscript.meta.js", "utf-8").replace("%version%", `${VERSION}.${new Date().getTime()}`)
},
footer: {
// UserScripts get wrapped in an iife, so define Vencord prop on window that returns our local
@@ -88,7 +88,7 @@ async function buildPluginZip(target, files, shouldZip) {
let content = await readFile(join("browser", f));
if (f.startsWith("manifest")) {
const json = JSON.parse(content.toString("utf-8"));
- json.version = PackageJSON.version;
+ json.version = VERSION;
content = new TextEncoder().encode(JSON.stringify(json));
}
diff --git a/scripts/build/common.mjs b/scripts/build/common.mjs
index a6b170a..2875a9c 100644
--- a/scripts/build/common.mjs
+++ b/scripts/build/common.mjs
@@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import "../suppressExperimentalWarnings.js";
import "../checkNodeVersion.js";
import { exec, execSync } from "child_process";
@@ -24,6 +25,11 @@ import { readdir, readFile } from "fs/promises";
import { join, relative } from "path";
import { promisify } from "util";
+// wtf is this assert syntax
+import PackageJSON from "../../package.json" assert { type: "json" };
+
+export const VERSION = PackageJSON.version;
+export const BUILD_TIMESTAMP = 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();