chore: move build script into scripts folder, copy it to the dist on run

This commit is contained in:
2026-06-01 14:27:53 +02:00
parent 31507041a5
commit 8c4f6d6c2e
4 changed files with 6 additions and 41 deletions
+40
View File
@@ -0,0 +1,40 @@
import fs from "fs";
import archiver from "archiver";
import path from "path";
export const toSafeName = (name: string) => {
return name
.toLowerCase()
.replace(/[<>:"/\\|?*]/g, "_")
.replace(/[\x00-\x1F\x7F]/g, "_")
.replace(/[\s-]+/g, "_")
.replace(/_+/g, "_")
.replace(/[. ]+$/g, "_");
};
const themeInfo = JSON.parse(fs.readFileSync("theme.json", "utf-8"));
const distDir = path.resolve("dist");
const output = fs.createWriteStream(
path.join(distDir, `${toSafeName(themeInfo.name)}.ezpplauncher-theme`),
);
const archive = archiver("zip", { zlib: { level: 9 } });
archive.pipe(output);
archive.file("theme.json", { name: "theme.json" });
archive.file(path.join(distDir, "bundle.js"), { name: "bundle.js" });
if (fs.existsSync(path.join(distDir, "ezpp-theme.css"))) {
archive.file(path.join(distDir, "ezpp-theme.css"), { name: "style.css" });
}
if (fs.existsSync("public/assets")) {
archive.directory("public/assets", "assets");
}
archive.finalize();
output.on("close", () => {
console.log("✅ Theme packaged:", output.path);
});