aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorVen <vendicated@riseup.net>2023-01-26 22:38:02 +0100
committerGitHub <noreply@github.com>2023-01-26 22:38:02 +0100
commit399305fd8a51de8f0e14d1898d9dd904c540f062 (patch)
treed3b34626c19d7af6549040648e340f1a041d30a2 /scripts
parent0c030a3a27e4c34409143261975fb3bd0e481fcb (diff)
downloadVencord-399305fd8a51de8f0e14d1898d9dd904c540f062.tar.gz
Vencord-399305fd8a51de8f0e14d1898d9dd904c540f062.tar.bz2
Vencord-399305fd8a51de8f0e14d1898d9dd904c540f062.zip
Automatic extension publishing (#453)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/buildWeb.mjs33
1 files changed, 22 insertions, 11 deletions
diff --git a/scripts/build/buildWeb.mjs b/scripts/build/buildWeb.mjs
index ceddbcb..dd7d32e 100644
--- a/scripts/build/buildWeb.mjs
+++ b/scripts/build/buildWeb.mjs
@@ -82,10 +82,19 @@ async function buildPluginZip(target, files, shouldZip) {
const entries = {
"dist/Vencord.js": await readFile("dist/browser.js"),
"dist/Vencord.css": await readFile("dist/browser.css"),
- ...Object.fromEntries(await Promise.all(files.map(async f => [
- (f.startsWith("manifest") ? "manifest.json" : f),
- await readFile(join("browser", f))
- ]))),
+ ...Object.fromEntries(await Promise.all(files.map(async f => {
+ let content = await readFile(join("browser", f));
+ if (f.startsWith("manifest")) {
+ const json = JSON.parse(content.toString("utf-8"));
+ json.version = PackageJSON.version;
+ content = new TextEncoder().encode(JSON.stringify(json));
+ }
+
+ return [
+ f.startsWith("manifest") ? "manifest.json" : f,
+ content
+ ];
+ }))),
};
if (shouldZip) {
@@ -115,20 +124,22 @@ async function buildPluginZip(target, files, shouldZip) {
}
}
-const cssText = "`" + readFileSync("dist/Vencord.user.css", "utf-8").replaceAll("`", "\\`") + "`";
-const cssRuntime = `
+const appendCssRuntime = readFile("dist/Vencord.user.css", "utf-8").then(content => {
+ const cssRuntime = `
;document.addEventListener("DOMContentLoaded", () => document.documentElement.appendChild(
Object.assign(document.createElement("style"), {
- textContent: ${cssText},
+ textContent: \`${content.replaceAll("`", "\\`")}\`,
id: "vencord-css-core"
})
), { once: true });
`;
+ return appendFile("dist/Vencord.user.js", cssRuntime);
+});
+
await Promise.all([
- appendFile("dist/Vencord.user.js", cssRuntime),
- buildPluginZip("extension-v3.zip", ["modifyResponseHeaders.json", "content.js", "manifestv3.json"], true),
- buildPluginZip("extension-v2.zip", ["background.js", "content.js", "manifestv2.json"], true),
- buildPluginZip("extension-v2-unpacked", ["background.js", "content.js", "manifestv2.json"], false),
+ appendCssRuntime,
+ buildPluginZip("extension.zip", ["modifyResponseHeaders.json", "content.js", "manifest.json", "icon.png"], true),
+ buildPluginZip("extension-unpacked", ["modifyResponseHeaders.json", "content.js", "manifest.json", "icon.png"], false),
]);