diff options
Diffstat (limited to 'bundle.ts')
| -rw-r--r-- | bundle.ts | 37 |
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(); |
