-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathzip-dist.js
34 lines (26 loc) · 939 Bytes
/
zip-dist.js
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
34
import AdmZip from "adm-zip";
import { readFileSync, mkdirSync, existsSync } from "fs";
import { join, dirname } from "path";
import { fileURLToPath } from "url";
// Get __dirname equivalent in ES modules
const __dirname = dirname(fileURLToPath(import.meta.url));
// Create releases directory if it doesn't exist
const releasesDir = join(__dirname, "releases");
if (!existsSync(releasesDir)) {
mkdirSync(releasesDir);
}
// Read manifest.json to get version
const manifest = JSON.parse(
readFileSync(join(__dirname, "dist", "manifest.json"), "utf8"),
);
const version = manifest.version;
// Initialize zip
const zip = new AdmZip();
// Add dist directory to zip
zip.addLocalFolder(join(__dirname, "dist"));
// Generate zip file name with version
const zipFileName = `extension-v${version}.zip`;
const zipFilePath = join(releasesDir, zipFileName);
// Write zip file
zip.writeZip(zipFilePath);
console.log(`Created ${zipFilePath}`);