-
Notifications
You must be signed in to change notification settings - Fork 168
/
Copy pathbuild.ts
61 lines (45 loc) · 1.38 KB
/
build.ts
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import archiver from "archiver";
import fs from "fs";
import path from "path";
const releaseTarget = process.argv[process.argv.length - 1];
const extensionName = "apollo-client-devtools";
async function createSrcArchive() {
console.log("Creating src archive");
const curDir = path.resolve(path.dirname(""));
const outputFile = `${curDir}/${extensionName}-src.zip`;
const output = fs.createWriteStream(outputFile);
const archive = archiver("zip", {
zlib: {
level: 5,
},
});
archive.pipe(output);
archive.directory("src", "src").glob("*", {
ignore: [`${extensionName}-*.zip`, "*/"],
});
await archive.finalize();
console.log("Created src archive");
}
export default async function createDistributable() {
console.log(`Creating distributable for ${releaseTarget}`);
const curDir = path.resolve(path.dirname(""));
const outputFile = `${curDir}/${extensionName}-${releaseTarget}.zip`;
const output = fs.createWriteStream(outputFile);
const archive = archiver("zip", {
zlib: {
level: 5,
},
});
archive.pipe(output);
archive.directory(`build`, false);
await archive.finalize();
console.log(`Created distributable for ${releaseTarget}`);
// Create a zipped copy of the source code for Firefox
if (releaseTarget === "firefox") {
await createSrcArchive();
}
}
async function main() {
await createDistributable();
}
main();