-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.js
executable file
·46 lines (42 loc) · 1.19 KB
/
make.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
import dotenv from "dotenv";
import esbuild from "esbuild";
import pkg from "@yao-pkg/pkg";
dotenv.config();
esbuild
.build({
entryPoints: ["src/index.js"],
bundle: true,
platform: "node",
target: "node20",
outfile: "bin/bundle.js",
minify: true,
sourcemap: false,
define: getGlobalVars(),
})
.then(() => {
if (process.argv[2] === "--nopkg") return;
pkg.exec([
"bin/bundle.js",
"--targets",
getBuildTargets(process),
"--output",
"bin/aceo-rpc",
// "--no-warnings",
]);
});
function getGlobalVars() {
const clientId = process.env["CLIENT_ID"];
if (!clientId) throw new Error("Missing CLIENT_ID environment variable.");
console.log("CLIENT_ID:", "*".repeat(clientId?.length - 1)); // hunter2
return {
__ESBUILD_GLOBAL_PROD_CLIENT_ID: `"${clientId}"`,
};
}
function getBuildTargets({ argv }) {
const [tgt, args] = [[], argv.slice(2) || []];
const has = (flags) => flags.some((flag) => args.includes(flag));
has(["-w", "--win", "--windows"]) && tgt.push("latest-win-x64");
has(["-l", "--lin", "--linux"]) && tgt.push("latest-linux-x64");
!tgt.length && tgt.push("latest-win-x64");
return tgt.join(",");
}