forked from NanoAdblocker/NanoBuild
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
143 lines (124 loc) · 3.81 KB
/
index.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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/**
* Build engine entry point.
*/
"use strict";
/**
* Load modules.
* @const {Module}
*/
const assert = require("assert");
const del = require("del");
const nanoAdblocker = require("./src/nano-adblocker.js");
const nanoDefender = require("./src/nano-defender.js");
const nanoDefenderMaintenance = require("./src/nano-defender-maintenance.js");
process.on("unhandledRejection", (e) => {
throw e;
});
assert(/[\\/]NanoBuild$/.test(process.cwd()));
(async () => {
let action = null;
let target = null;
let pack = null;
let publish = null;
let capability = "standard";
const argv = process.argv.slice(2);
for (const arg of argv) {
switch (arg) {
case "--chromium":
assert(action === null);
action = "chromium";
break;
case "--firefox":
assert(action === null);
action = "firefox";
break;
case "--edge":
assert(action === null);
action = "edge";
break;
case "--maintenance":
assert(action === null);
action = "maintenance";
break;
case "--clean":
assert(action === null);
action = "clean";
break;
case "--both":
assert(target === null);
target = "both";
break;
case "--adblocker":
assert(target === null);
target = "adblocker";
break;
case "--defender":
assert(target === null);
target = "defender";
break;
case "--pro":
assert(capability === "standard");
capability = "pro";
break;
case "--pack":
assert(pack === null);
pack = true;
break;
case "--publish":
assert(publish === null);
publish = true;
break;
case "--list-only":
case "--trace-fs":
break;
default:
assert(false);
break;
}
}
assert(action !== null);
if (target === null) {
target = "both";
}
if (pack === null) {
pack = false;
}
if (publish === null) {
publish = false;
}
if (action === "maintenance") {
if (target === "both" || target === "adblocker") {
console.log("No Maintenance Needed for Nano Adblocker.");
}
if (target === "both" || target === "defender") {
await nanoDefenderMaintenance.performMaintenance();
}
} else if (action === "clean") {
await del("./dist");
} else {
if (target === "both" || target === "adblocker") {
await nanoAdblocker.buildCore(action);
await nanoAdblocker.buildFilter(action);
await nanoAdblocker.buildResources(action);
await nanoAdblocker.buildLocale(action);
if (pack || publish) {
await nanoAdblocker.test(action);
await nanoAdblocker.pack(action);
}
if (publish) {
await nanoAdblocker.publish(action);
}
}
if (target === "both" || target === "defender") {
await nanoDefender.buildList(action, capability);
await nanoDefender.buildExtension(action, capability);
if (pack || publish) {
await nanoDefender.test(action, capability);
await nanoDefender.pack(action, capability);
}
if (publish) {
await nanoDefender.publish(action, capability);
}
}
}
})();