aboutsummaryrefslogtreecommitdiff
path: root/bundle.ts
blob: c7d4e9d8acd39e7df643248ed60c3c8e920238ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const fs = require("fs");
const path = require("path");
const AdmZip = require("adm-zip");

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();