aboutsummaryrefslogtreecommitdiff
path: root/bundle.ts
diff options
context:
space:
mode:
authorBobby <[email protected]>2025-09-24 20:01:57 +0530
committerBobby <[email protected]>2025-09-24 20:01:57 +0530
commitfd7dec9de4dc1d9496ecc475433e8350d0ed667c (patch)
tree81473b8de758f9fb9c772a84be59873c74af7bac /bundle.ts
parentc2d3c104987e35aa3d124d7c358d98ea17771a82 (diff)
downloadthunderbird-ai-compose-fd7dec9de4dc1d9496ecc475433e8350d0ed667c.tar.xz
thunderbird-ai-compose-fd7dec9de4dc1d9496ecc475433e8350d0ed667c.zip
add bundler script
Diffstat (limited to 'bundle.ts')
-rw-r--r--bundle.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/bundle.ts b/bundle.ts
new file mode 100644
index 0000000..40471e8
--- /dev/null
+++ b/bundle.ts
@@ -0,0 +1,37 @@
+import fs from "fs";
+import path from "path";
+import { fileURLToPath } from "url";
+import AdmZip from "adm-zip";
+
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = path.dirname(__filename);
+
+const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf-8"));
+const version: string = pkg.version || "0.0.0";
+
+const buildDir = path.join(__dirname, "build");
+const releaseDir = path.join(__dirname, "release");
+const outFile = path.join(releaseDir, `thunderbird-ai-compose-v${version}.xpi`);
+
+function run(): void {
+ if (!fs.existsSync(buildDir)) {
+ console.error("❌ Build directory not found. Run `npm run build` first.");
+ process.exit(1);
+ }
+
+ if (!fs.existsSync(releaseDir)) {
+ fs.mkdirSync(releaseDir);
+ }
+
+ try {
+ const zip = new AdmZip();
+ zip.addLocalFolder(buildDir);
+ zip.writeZip(outFile);
+ console.log(`✅ Bundle created at ${outFile}`);
+ } catch (err) {
+ console.error("❌ Failed to create bundle:", err);
+ process.exit(1);
+ }
+}
+
+run();