| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- /**
- * Build JS then zip loadable extension files.
- */
- import { spawnSync } from "node:child_process";
- import { mkdirSync, existsSync } from "node:fs";
- import { join, dirname } from "node:path";
- import { fileURLToPath } from "node:url";
- const root = join(dirname(fileURLToPath(import.meta.url)), "..");
- const outDir = join(root, "dist-pack");
- const zipPath = join(outDir, "mavi-extension.zip");
- const build = spawnSync("bun", ["run", "scripts/build.mjs"], {
- cwd: root,
- encoding: "utf8",
- stdio: "inherit",
- });
- if (build.status !== 0) process.exit(build.status ?? 1);
- mkdirSync(outDir, { recursive: true });
- const files = [
- "manifest.json",
- "popup.html",
- "create.html",
- "import.html",
- "shared.css",
- "dist/popup.js",
- "dist/create.js",
- "dist/import.js",
- "icons/16.png",
- "icons/48.png",
- "icons/128.png",
- "icons/mavi.svg",
- "README.md",
- ];
- for (const f of files) {
- if (!existsSync(join(root, f))) {
- console.error("Missing", f);
- process.exit(1);
- }
- }
- const r = spawnSync("zip", ["-r", zipPath, ...files], {
- cwd: root,
- encoding: "utf8",
- });
- if (r.status !== 0) {
- console.error(r.stderr || r.stdout);
- process.exit(r.status ?? 1);
- }
- console.log("Packed", zipPath);
|