-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Expand file tree
/
Copy pathelectron-builder-unsigned.mjs
More file actions
79 lines (66 loc) · 1.61 KB
/
electron-builder-unsigned.mjs
File metadata and controls
79 lines (66 loc) · 1.61 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
#!/usr/bin/env node
import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
import path from "node:path";
export const appleSigningEnvKeys = [
"APPLE_ID",
"APPLE_APP_SPECIFIC_PASSWORD",
"APPLE_TEAM_ID",
"APPLE_API_KEY",
"APPLE_API_KEY_ID",
"APPLE_API_ISSUER",
"APPLE_KEYCHAIN",
"APPLE_KEYCHAIN_PROFILE",
];
export const codeSigningEnvKeys = [
"CSC_LINK",
"CSC_KEY_PASSWORD",
"CSC_NAME",
"WIN_CSC_LINK",
"WIN_CSC_KEY_PASSWORD",
];
const unsignedElectronBuilderBaseArgs = [
"exec",
"electron-builder",
"--config",
"electron-builder.yml",
"--publish",
"never",
"-c.mac.hardenedRuntime=false",
];
export const unsignedElectronBuilderArgs = (extraArgs = []) => [
...unsignedElectronBuilderBaseArgs,
...extraArgs,
];
export const unsignedBuildEnv = (baseEnv = process.env) => {
const env = {
...baseEnv,
CSC_IDENTITY_AUTO_DISCOVERY: "false",
};
for (const key of [...appleSigningEnvKeys, ...codeSigningEnvKeys]) {
delete env[key];
}
return env;
};
export const runUnsignedElectronBuilder = ({
cwd = process.cwd(),
env = process.env,
extraArgs = process.argv.slice(2),
} = {}) => {
const result = spawnSync("pnpm", unsignedElectronBuilderArgs(extraArgs), {
cwd,
env: unsignedBuildEnv(env),
shell: process.platform === "win32",
stdio: "inherit",
});
if (result.error) {
throw result.error;
}
return result.status ?? 1;
};
const isEntrypoint =
process.argv[1] &&
path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
if (isEntrypoint) {
process.exitCode = runUnsignedElectronBuilder();
}