forked from Pete9xi/ThirdEye
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbundle.ts
More file actions
25 lines (20 loc) · 855 Bytes
/
bundle.ts
File metadata and controls
25 lines (20 loc) · 855 Bytes
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
import { createWriteStream, mkdirSync, existsSync } from "fs";
import { dirname } from "path";
import archiver from "archiver";
import packageJson from "./package.json" with { type: "json" };
const outputZip = `dist/phoenixepsilon-v${packageJson.version}.zip`;
// Create dist directory if it doesn't exist
const distDir = dirname(outputZip);
if (!existsSync(distDir)) {
mkdirSync(distDir, { recursive: true });
}
const output = createWriteStream(outputZip);
const archive = archiver("zip", { zlib: { level: 9 } });
output.on("close", () => console.log(`Bundle created: ${outputZip} (${archive.pointer()} bytes)`));
archive.on("error", (err) => {
throw err;
});
archive.pipe(output as unknown as NodeJS.WritableStream);
archive.directory(".build/", false);
archive.file("local.env.example", { name: "local.env.example" });
archive.finalize();