forked from hoangsonww/Claude-Code-Agent-Monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotarize.js
More file actions
executable file
·48 lines (42 loc) · 1.71 KB
/
Copy pathnotarize.js
File metadata and controls
executable file
·48 lines (42 loc) · 1.71 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
/**
* @file electron-builder afterSign hook for Apple notarization.
*
* This is opt-in: it only does anything when all three Apple credentials
* are present as environment variables. In every other case (local builds,
* fork CI without secrets) the hook is a no-op. That keeps the default
* `npm run dmg` working for contributors without an Apple Developer
* account while letting the project maintainer flip a switch later.
* @author Son Nguyen <hoangson091104@gmail.com>
*/
exports.default = async function notarizeIfConfigured(context) {
const { electronPlatformName, appOutDir, packager } = context;
if (electronPlatformName !== "darwin") return;
const { APPLE_ID, APPLE_TEAM_ID, APPLE_APP_SPECIFIC_PASSWORD } = process.env;
if (!APPLE_ID || !APPLE_TEAM_ID || !APPLE_APP_SPECIFIC_PASSWORD) {
console.log("[notarize] Apple credentials not set — skipping notarization (ad-hoc only).");
return;
}
// Lazy-require: @electron/notarize is only needed when we actually notarize,
// so contributors without Apple credentials don't have to install it.
let notarize;
try {
({ notarize } = require("@electron/notarize"));
} catch {
console.log(
"[notarize] Apple credentials present but @electron/notarize is not installed. Run `npm install --save-dev @electron/notarize` in desktop/."
);
return;
}
const appName = packager.appInfo.productFilename;
const appPath = `${appOutDir}/${appName}.app`;
console.log(`[notarize] notarizing ${appPath}`);
await notarize({
tool: "notarytool",
appBundleId: packager.appInfo.id,
appPath,
appleId: APPLE_ID,
appleIdPassword: APPLE_APP_SPECIFIC_PASSWORD,
teamId: APPLE_TEAM_ID,
});
console.log("[notarize] done");
};