-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathbuild.mjs
More file actions
83 lines (74 loc) · 2.13 KB
/
Copy pathbuild.mjs
File metadata and controls
83 lines (74 loc) · 2.13 KB
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
import { build } from 'esbuild';
import { copyFile, mkdir } from 'node:fs/promises';
const isProprietary = process.env.BUILD_MODE === 'proprietary';
const commonDefine = {
'__PROPRIETARY_BUILD__': String(isProprietary),
};
const internalStubPlugin = {
name: 'internal-stub',
setup(b) {
if (isProprietary) return;
b.onResolve({ filter: /\.internal/ }, (args) => ({
path: args.path,
namespace: 'internal-stub',
}));
b.onLoad({ filter: /alarm-sender\.internal/, namespace: 'internal-stub' }, () => ({
contents: 'export function sendAlarm() {} export function sendStatus() {}',
loader: 'ts',
}));
b.onLoad({ filter: /statistic\.internal/, namespace: 'internal-stub' }, () => ({
contents: 'export function sendRunningStatus() {}',
loader: 'ts',
}));
},
};
const commonPlugins = [internalStubPlugin];
await build({
entryPoints: ['src/index.ts'],
outfile: 'dist/index.js',
platform: 'node',
target: 'es2022',
format: 'esm',
bundle: true,
minify: true,
treeShaking: true,
packages: 'external',
define: commonDefine,
plugins: commonPlugins,
});
await build({
entryPoints: ['src/cli-probe.ts'],
outfile: 'dist/cli-probe.cjs',
platform: 'node',
target: 'es2022',
format: 'cjs',
bundle: true,
banner: { js: "process.env.LOG_LEVEL = 'silent';" },
minifySyntax: true,
define: commonDefine,
plugins: commonPlugins,
});
await build({
entryPoints: ['src/updater/index.ts'],
outdir: 'dist/updater',
platform: 'node',
target: 'es2022',
format: 'esm',
bundle: true,
minify: true,
treeShaking: true,
packages: 'external',
define: commonDefine,
plugins: commonPlugins,
});
await mkdir('dist', { recursive: true });
await copyFile('src/mask/sensitive-rules.json', 'dist/sensitive-rules.json');
// Best-effort: build macOS status bar app (Swift)
if (process.platform === 'darwin') {
try {
const { execFileSync } = await import('node:child_process');
execFileSync('node', ['scripts/build-status-bar-app.mjs'], { stdio: 'inherit', timeout: 200_000 });
} catch {
// non-fatal — status bar app build failure doesn't block the main build
}
}