app-builder-lib 26.12.0 → 26.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/binDownload.js +32 -5
- package/out/binDownload.js.map +1 -1
- package/out/codeSign/macCodeSign.js +2 -2
- package/out/codeSign/macCodeSign.js.map +1 -1
- package/out/electron/ElectronFramework.js +4 -1
- package/out/electron/ElectronFramework.js.map +1 -1
- package/out/electron/electronVersion.js +9 -4
- package/out/electron/electronVersion.js.map +1 -1
- package/out/fileTransformer.js +2 -1
- package/out/fileTransformer.js.map +1 -1
- package/out/forge-maker.js +6 -2
- package/out/forge-maker.js.map +1 -1
- package/out/mac/MacTargetHelper.d.ts +24 -0
- package/out/mac/MacTargetHelper.js +267 -0
- package/out/mac/MacTargetHelper.js.map +1 -0
- package/out/macPackager.d.ts +21 -7
- package/out/macPackager.js +218 -346
- package/out/macPackager.js.map +1 -1
- package/out/packager.js +4 -4
- package/out/packager.js.map +1 -1
- package/out/platformPackager.js +8 -4
- package/out/platformPackager.js.map +1 -1
- package/out/targets/AppxTarget.js +2 -1
- package/out/targets/AppxTarget.js.map +1 -1
- package/out/targets/FlatpakTarget.js +2 -4
- package/out/targets/FlatpakTarget.js.map +1 -1
- package/out/targets/FpmTarget.js +30 -6
- package/out/targets/FpmTarget.js.map +1 -1
- package/out/targets/LinuxTargetHelper.d.ts +1 -1
- package/out/targets/LinuxTargetHelper.js +69 -11
- package/out/targets/LinuxTargetHelper.js.map +1 -1
- package/out/targets/MsiTarget.js +1 -1
- package/out/targets/MsiTarget.js.map +1 -1
- package/out/targets/MsiWrappedTarget.js +1 -1
- package/out/targets/MsiWrappedTarget.js.map +1 -1
- package/out/targets/appimage/AppImageTarget.js +2 -1
- package/out/targets/appimage/AppImageTarget.js.map +1 -1
- package/out/targets/nsis/NsisTarget.js +14 -4
- package/out/targets/nsis/NsisTarget.js.map +1 -1
- package/out/targets/nsis/nsisScriptGenerator.js +2 -3
- package/out/targets/nsis/nsisScriptGenerator.js.map +1 -1
- package/out/targets/pkg.js +1 -1
- package/out/targets/pkg.js.map +1 -1
- package/out/targets/snap/SnapTarget.js +2 -1
- package/out/targets/snap/SnapTarget.js.map +1 -1
- package/out/targets/snap/core24.js +5 -4
- package/out/targets/snap/core24.js.map +1 -1
- package/out/targets/snap/coreLegacy.js +5 -5
- package/out/targets/snap/coreLegacy.js.map +1 -1
- package/out/targets/snap/snapcraftBuilder.js +4 -3
- package/out/targets/snap/snapcraftBuilder.js.map +1 -1
- package/out/toolsets/linux.js +3 -3
- package/out/toolsets/linux.js.map +1 -1
- package/out/toolsets/windows.js +7 -17
- package/out/toolsets/windows.js.map +1 -1
- package/out/util/bundledTool.js +2 -1
- package/out/util/bundledTool.js.map +1 -1
- package/out/util/config/config.js +4 -3
- package/out/util/config/config.js.map +1 -1
- package/out/util/electronGet.d.ts +2 -0
- package/out/util/electronGet.js +7 -1
- package/out/util/electronGet.js.map +1 -1
- package/out/util/packageMetadata.js +2 -1
- package/out/util/packageMetadata.js.map +1 -1
- package/out/util/yarn.js +1 -1
- package/out/util/yarn.js.map +1 -1
- package/out/version.d.ts +1 -1
- package/out/version.js +1 -1
- package/out/version.js.map +1 -1
- package/package.json +8 -8
package/out/macPackager.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MacPackager = void 0;
|
|
4
|
-
const
|
|
5
|
-
const util_identities_1 = require("@electron/osx-sign/dist/cjs/util-identities");
|
|
4
|
+
const universal_1 = require("@electron/universal");
|
|
6
5
|
const builder_util_1 = require("builder-util");
|
|
7
6
|
const builder_util_runtime_1 = require("builder-util-runtime");
|
|
8
7
|
const fs = require("fs/promises");
|
|
@@ -12,15 +11,14 @@ const path = require("path");
|
|
|
12
11
|
const appInfo_1 = require("./appInfo");
|
|
13
12
|
const macCodeSign_1 = require("./codeSign/macCodeSign");
|
|
14
13
|
const core_1 = require("./core");
|
|
14
|
+
const MacTargetHelper_1 = require("./mac/MacTargetHelper");
|
|
15
15
|
const platformPackager_1 = require("./platformPackager");
|
|
16
16
|
const ArchiveTarget_1 = require("./targets/ArchiveTarget");
|
|
17
17
|
const pkg_1 = require("./targets/pkg");
|
|
18
18
|
const targetFactory_1 = require("./targets/targetFactory");
|
|
19
19
|
const macosVersion_1 = require("./util/macosVersion");
|
|
20
|
-
const pathManager_1 = require("./util/pathManager");
|
|
21
|
-
const resolve_1 = require("./util/resolve");
|
|
22
20
|
const macroExpander_1 = require("./util/macroExpander");
|
|
23
|
-
const
|
|
21
|
+
const resolve_1 = require("./util/resolve");
|
|
24
22
|
class MacPackager extends platformPackager_1.PlatformPackager {
|
|
25
23
|
constructor(info) {
|
|
26
24
|
super(info, core_1.Platform.MAC);
|
|
@@ -51,10 +49,43 @@ class MacPackager extends platformPackager_1.PlatformPackager {
|
|
|
51
49
|
return Promise.resolve({ keychainFile: process.env.CSC_KEYCHAIN || null });
|
|
52
50
|
});
|
|
53
51
|
this._iconPath = new lazy_val_1.Lazy(() => this.getOrConvertIcon("icns"));
|
|
52
|
+
// Set/cleared in doPack so applyCommonInfo can read the per-pack platformSpecificBuildOptions
|
|
53
|
+
// (the framework call chain doesn't thread it through to applyCommonInfo). Fixes #8909.
|
|
54
|
+
this._activePackConfig = null;
|
|
55
|
+
this.helper = new MacTargetHelper_1.MacTargetHelper(this);
|
|
54
56
|
}
|
|
55
57
|
get defaultTarget() {
|
|
56
58
|
return this.info.framework.macOsDefaultTargets;
|
|
57
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the merged configuration for a specific platform type
|
|
62
|
+
*/
|
|
63
|
+
getPlatformConfig(platformType) {
|
|
64
|
+
let config;
|
|
65
|
+
let isDevelopment = false;
|
|
66
|
+
let platformName;
|
|
67
|
+
switch (platformType) {
|
|
68
|
+
case "mas":
|
|
69
|
+
config = (0, builder_util_1.deepAssign)({}, this.platformSpecificBuildOptions, this.config.mas);
|
|
70
|
+
isDevelopment = false;
|
|
71
|
+
platformName = "mas";
|
|
72
|
+
break;
|
|
73
|
+
case "mas-dev":
|
|
74
|
+
config = (0, builder_util_1.deepAssign)({}, this.platformSpecificBuildOptions, this.config.mas, this.config.masDev, {
|
|
75
|
+
type: "development",
|
|
76
|
+
});
|
|
77
|
+
isDevelopment = true;
|
|
78
|
+
platformName = "mas";
|
|
79
|
+
break;
|
|
80
|
+
case "mac":
|
|
81
|
+
default:
|
|
82
|
+
config = this.platformSpecificBuildOptions;
|
|
83
|
+
isDevelopment = false;
|
|
84
|
+
platformName = this.platform.nodeName;
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
return { type: platformType, config, isDevelopment, platformName };
|
|
88
|
+
}
|
|
58
89
|
expandArch(pattern, arch) {
|
|
59
90
|
if (arch === builder_util_1.Arch.universal) {
|
|
60
91
|
// Universal build has `app-x64.asar.unpacked` & `app-arm64.asar.unpacked`
|
|
@@ -89,318 +120,205 @@ class MacPackager extends platformPackager_1.PlatformPackager {
|
|
|
89
120
|
mapper(name, outDir => new pkg_1.PkgTarget(this, outDir));
|
|
90
121
|
break;
|
|
91
122
|
default:
|
|
92
|
-
mapper(name, outDir => (name
|
|
123
|
+
mapper(name, outDir => (MacTargetHelper_1.MacTargetHelper.isMasTarget(name) ? new targetFactory_1.NoOpTarget(name) : (0, targetFactory_1.createCommonTarget)(name, outDir, this)));
|
|
93
124
|
break;
|
|
94
125
|
}
|
|
95
126
|
}
|
|
96
127
|
}
|
|
97
128
|
async doPack(config) {
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
129
|
+
if (config.arch === builder_util_1.Arch.universal) {
|
|
130
|
+
return this.doUniversalPack(config);
|
|
131
|
+
}
|
|
132
|
+
// Bridge the per-pack platformSpecificBuildOptions to applyCommonInfo, which is called deep in the
|
|
133
|
+
// framework stack (doPack → beforeCopyExtraFiles → createMacApp → applyCommonInfo) without it.
|
|
134
|
+
this._activePackConfig = config.platformSpecificBuildOptions;
|
|
135
|
+
try {
|
|
136
|
+
return await super.doPack(config);
|
|
137
|
+
}
|
|
138
|
+
finally {
|
|
139
|
+
this._activePackConfig = null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Handle universal build packing
|
|
144
|
+
*/
|
|
145
|
+
async doUniversalPack(config) {
|
|
146
|
+
var _a, _b, _c;
|
|
147
|
+
this._activePackConfig = config.platformSpecificBuildOptions;
|
|
148
|
+
try {
|
|
149
|
+
const { outDir, appOutDir, platformName, arch, platformSpecificBuildOptions, targets } = config;
|
|
150
|
+
const outDirName = (arch) => `${appOutDir}-${builder_util_1.Arch[arch]}-temp`;
|
|
151
|
+
const options = {
|
|
152
|
+
...config,
|
|
153
|
+
options: {
|
|
154
|
+
sign: false,
|
|
155
|
+
disableAsarIntegrity: true,
|
|
156
|
+
disableFuses: true,
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
const x64Arch = builder_util_1.Arch.x64;
|
|
160
|
+
const x64AppOutDir = outDirName(x64Arch);
|
|
161
|
+
await super.doPack({ ...options, appOutDir: x64AppOutDir, arch: x64Arch });
|
|
162
|
+
if (this.info.cancellationToken.cancelled) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const arm64Arch = builder_util_1.Arch.arm64;
|
|
166
|
+
const arm64AppOutPath = outDirName(arm64Arch);
|
|
167
|
+
await super.doPack({ ...options, appOutDir: arm64AppOutPath, arch: arm64Arch });
|
|
168
|
+
if (this.info.cancellationToken.cancelled) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const framework = this.info.framework;
|
|
172
|
+
builder_util_1.log.info({
|
|
173
|
+
platform: platformName,
|
|
174
|
+
arch: builder_util_1.Arch[arch],
|
|
175
|
+
[`${framework.name}`]: framework.version,
|
|
176
|
+
appOutDir: builder_util_1.log.filePath(appOutDir),
|
|
177
|
+
}, `packaging`);
|
|
178
|
+
const appFile = `${this.appInfo.productFilename}.app`;
|
|
179
|
+
// Make sure the Assets.car file is the same for both architectures
|
|
180
|
+
const safeX64AppOutDir = (0, builder_util_1.sanitizeDirPath)(x64AppOutDir);
|
|
181
|
+
const safeArm64AppOutPath = (0, builder_util_1.sanitizeDirPath)(arm64AppOutPath);
|
|
182
|
+
const safeAppOutDir = (0, builder_util_1.sanitizeDirPath)(appOutDir);
|
|
183
|
+
const sourceCatalogPath = path.join(safeX64AppOutDir, appFile, "Contents/Resources/Assets.car");
|
|
184
|
+
if (await (0, builder_util_1.exists)(sourceCatalogPath)) {
|
|
185
|
+
const targetCatalogPath = path.join(safeArm64AppOutPath, appFile, "Contents/Resources/Assets.car");
|
|
186
|
+
await fs.copyFile(sourceCatalogPath, targetCatalogPath);
|
|
187
|
+
}
|
|
188
|
+
await (0, universal_1.makeUniversalApp)({
|
|
189
|
+
x64AppPath: path.join(safeX64AppOutDir, appFile),
|
|
190
|
+
arm64AppPath: path.join(safeArm64AppOutPath, appFile),
|
|
191
|
+
outAppPath: path.join(safeAppOutDir, appFile),
|
|
192
|
+
force: true,
|
|
193
|
+
mergeASARs: (_a = platformSpecificBuildOptions.mergeASARs) !== null && _a !== void 0 ? _a : true, // must be ?? to allow false
|
|
194
|
+
singleArchFiles: platformSpecificBuildOptions.singleArchFiles || undefined,
|
|
195
|
+
x64ArchFiles: platformSpecificBuildOptions.x64ArchFiles || undefined,
|
|
196
|
+
});
|
|
197
|
+
await fs.rm(x64AppOutDir, { recursive: true, force: true });
|
|
198
|
+
await fs.rm(arm64AppOutPath, { recursive: true, force: true });
|
|
199
|
+
// Give users a final opportunity to perform things on the combined universal package before signing
|
|
200
|
+
const packContext = {
|
|
201
|
+
appOutDir,
|
|
202
|
+
outDir,
|
|
203
|
+
arch,
|
|
204
|
+
targets,
|
|
205
|
+
packager: this,
|
|
206
|
+
electronPlatformName: platformName,
|
|
207
|
+
};
|
|
208
|
+
await this.info.emitAfterPack(packContext);
|
|
209
|
+
if (this.info.cancellationToken.cancelled) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
await this.doAddElectronFuses(packContext);
|
|
213
|
+
// Mirror the base-class guard: skip signing when the caller explicitly set sign:false
|
|
214
|
+
// (e.g. packMasTargets passes sign:false so that signMas() is the sole signing step).
|
|
215
|
+
if ((_c = (_b = config.options) === null || _b === void 0 ? void 0 : _b.sign) !== null && _c !== void 0 ? _c : true) {
|
|
165
216
|
await this.doSignAfterPack(outDir, appOutDir, platformName, arch, platformSpecificBuildOptions, targets);
|
|
166
|
-
break;
|
|
167
217
|
}
|
|
168
218
|
}
|
|
219
|
+
finally {
|
|
220
|
+
this._activePackConfig = null;
|
|
221
|
+
}
|
|
169
222
|
}
|
|
170
223
|
async pack(outDir, arch, targets, taskManager) {
|
|
171
|
-
const
|
|
224
|
+
const masTargets = targets.filter(it => MacTargetHelper_1.MacTargetHelper.isMasTarget(it.name));
|
|
225
|
+
const nonMasTargets = targets.filter(it => !MacTargetHelper_1.MacTargetHelper.isMasTarget(it.name));
|
|
172
226
|
const prepackaged = this.packagerOptions.prepackaged;
|
|
227
|
+
const hasMas = masTargets.length > 0;
|
|
228
|
+
// mas always first
|
|
229
|
+
await this.packMasTargets(outDir, arch, masTargets, prepackaged);
|
|
230
|
+
// Mirror master's condition: skip the non-MAS darwin pack only when there are exclusively MAS
|
|
231
|
+
// targets (hasMas=true, targets.length=1). DIR_TARGET passes targets=[] to pack() because
|
|
232
|
+
// MacPackager.createTargets() doesn't call mapper() for it, so hasMas=false and doPack still runs.
|
|
233
|
+
if (!hasMas || targets.length > 1) {
|
|
234
|
+
await this.packMacTargets(outDir, arch, nonMasTargets, prepackaged, taskManager);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async packMasTargets(outDir, arch, targets, prepackaged) {
|
|
238
|
+
const resolvedOutDir = path.resolve(outDir);
|
|
239
|
+
MacTargetHelper_1.MacTargetHelper.assertSafePathForCommandUsage(resolvedOutDir, "output directory");
|
|
173
240
|
for (const target of targets) {
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
const
|
|
179
|
-
if (
|
|
180
|
-
|
|
181
|
-
type: "development",
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
const targetOutDir = path.join(outDir, `${targetName}${(0, builder_util_1.getArchSuffix)(arch, this.platformSpecificBuildOptions.defaultArch)}`);
|
|
185
|
-
if (prepackaged == null) {
|
|
186
|
-
await this.doPack({ outDir, appOutDir: targetOutDir, platformName: "mas", arch, platformSpecificBuildOptions: masBuildOptions, targets: [target] });
|
|
187
|
-
await this.sign(path.join(targetOutDir, `${this.appInfo.productFilename}.app`), targetOutDir, masBuildOptions, arch);
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
await this.sign(prepackaged, targetOutDir, masBuildOptions, arch);
|
|
241
|
+
const platformType = MacTargetHelper_1.MacTargetHelper.getPlatformTypeFromTarget(target.name);
|
|
242
|
+
const platformConfig = this.getPlatformConfig(platformType);
|
|
243
|
+
const targetOutDir = path.resolve(resolvedOutDir, `${target.name}${(0, builder_util_1.getArchSuffix)(arch, this.platformSpecificBuildOptions.defaultArch)}`);
|
|
244
|
+
MacTargetHelper_1.MacTargetHelper.assertSafePathForCommandUsage(targetOutDir, "target output directory");
|
|
245
|
+
const relativeTargetOutDir = path.relative(resolvedOutDir, targetOutDir);
|
|
246
|
+
if (relativeTargetOutDir.startsWith("..") || path.isAbsolute(relativeTargetOutDir)) {
|
|
247
|
+
throw new builder_util_1.InvalidConfigurationError(`Invalid target output directory: ${targetOutDir}`);
|
|
191
248
|
}
|
|
192
|
-
}
|
|
193
|
-
if (!hasMas || targets.length > 1) {
|
|
194
|
-
const appPath = prepackaged == null ? path.join(this.computeAppOutDir(outDir, arch), `${this.appInfo.productFilename}.app`) : prepackaged;
|
|
195
249
|
if (prepackaged == null) {
|
|
196
250
|
await this.doPack({
|
|
197
|
-
outDir,
|
|
198
|
-
appOutDir:
|
|
199
|
-
platformName:
|
|
251
|
+
outDir: resolvedOutDir,
|
|
252
|
+
appOutDir: targetOutDir,
|
|
253
|
+
platformName: platformConfig.platformName,
|
|
200
254
|
arch,
|
|
201
|
-
platformSpecificBuildOptions:
|
|
202
|
-
targets,
|
|
255
|
+
platformSpecificBuildOptions: platformConfig.config,
|
|
256
|
+
targets: [target],
|
|
257
|
+
options: { sign: false },
|
|
203
258
|
});
|
|
259
|
+
MacTargetHelper_1.MacTargetHelper.assertSafePathForCommandUsage(this.appInfo.productFilename, "product filename");
|
|
260
|
+
await this.signMas(path.resolve(targetOutDir, `${path.basename(this.appInfo.productFilename)}.app`), targetOutDir, platformConfig, arch);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
await this.signMas(prepackaged, targetOutDir, platformConfig, arch);
|
|
204
264
|
}
|
|
205
|
-
this.packageInDistributableFormat(appPath, arch, targets, taskManager);
|
|
206
265
|
}
|
|
207
266
|
}
|
|
208
|
-
async
|
|
267
|
+
async packMacTargets(outDir, arch, targets, prepackaged, taskManager) {
|
|
268
|
+
const appPath = prepackaged == null ? path.join(this.computeAppOutDir(outDir, arch), `${path.basename(this.appInfo.productFilename)}.app`) : prepackaged;
|
|
269
|
+
if (prepackaged == null) {
|
|
270
|
+
const platformConfig = this.getPlatformConfig("mac");
|
|
271
|
+
await this.doPack({
|
|
272
|
+
outDir,
|
|
273
|
+
appOutDir: path.dirname(appPath),
|
|
274
|
+
platformName: platformConfig.platformName,
|
|
275
|
+
arch,
|
|
276
|
+
platformSpecificBuildOptions: platformConfig.config,
|
|
277
|
+
targets,
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
this.packageInDistributableFormat(appPath, arch, targets, taskManager);
|
|
281
|
+
}
|
|
282
|
+
async signMas(appPath, outDir, platformConfig, arch) {
|
|
283
|
+
const signed = await this.sign(appPath, outDir, platformConfig.config, arch, true);
|
|
284
|
+
return signed;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Main signing method with platform awareness
|
|
288
|
+
*/
|
|
289
|
+
async sign(appPath, outDir, options, arch, isMas = false) {
|
|
209
290
|
if (!(0, macCodeSign_1.isSignAllowed)()) {
|
|
210
291
|
return false;
|
|
211
292
|
}
|
|
212
|
-
const
|
|
213
|
-
const
|
|
214
|
-
const qualifier = options.identity;
|
|
293
|
+
const config = options !== null && options !== void 0 ? options : this.platformSpecificBuildOptions;
|
|
294
|
+
const qualifier = config.identity;
|
|
215
295
|
const fallBackToAdhoc = (arch === builder_util_1.Arch.arm64 || arch === builder_util_1.Arch.universal) && !this.forceCodeSigning;
|
|
216
296
|
if (qualifier === null) {
|
|
217
|
-
|
|
218
|
-
throw new builder_util_1.InvalidConfigurationError("identity explicitly is set to null, but forceCodeSigning is set to true");
|
|
219
|
-
}
|
|
220
|
-
builder_util_1.log.info({ reason: "identity explicitly is set to null" }, "skipped macOS code signing");
|
|
221
|
-
if (fallBackToAdhoc) {
|
|
222
|
-
builder_util_1.log.warn("arm64 requires signing, but identity is set to null and signing is being skipped");
|
|
223
|
-
}
|
|
224
|
-
return false;
|
|
297
|
+
return this.helper.handleNullIdentity(fallBackToAdhoc);
|
|
225
298
|
}
|
|
226
299
|
const keychainFile = (await this.codeSigningInfo.value).keychainFile;
|
|
227
|
-
const explicitType =
|
|
300
|
+
const explicitType = config.type;
|
|
228
301
|
const type = explicitType || "distribution";
|
|
229
302
|
const isDevelopment = type === "development";
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
identity = await (0, macCodeSign_1.findIdentity)(certificateType, qualifier, keychainFile);
|
|
234
|
-
if (identity != null) {
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if (identity == null) {
|
|
239
|
-
if (!isMas && !isDevelopment && explicitType !== "distribution") {
|
|
240
|
-
identity = await (0, macCodeSign_1.findIdentity)("Mac Developer", qualifier, keychainFile);
|
|
241
|
-
if (identity != null) {
|
|
242
|
-
builder_util_1.log.warn("Mac Developer is used to sign app — it is only for development and testing, not for production");
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
const noIdentity = !options.sign && identity == null;
|
|
246
|
-
if (qualifier === "-") {
|
|
247
|
-
identity = new util_identities_1.Identity("-", undefined);
|
|
248
|
-
}
|
|
249
|
-
else if (noIdentity && fallBackToAdhoc) {
|
|
250
|
-
builder_util_1.log.warn(null, "falling back to ad-hoc signature for macOS application code signing");
|
|
251
|
-
identity = new util_identities_1.Identity("-", undefined);
|
|
252
|
-
}
|
|
253
|
-
else if (noIdentity) {
|
|
254
|
-
await (0, macCodeSign_1.reportError)(isMas, certificateTypes, qualifier, keychainFile, this.forceCodeSigning);
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
303
|
+
const identity = await this.helper.findSigningIdentity(isMas, isDevelopment, qualifier, keychainFile, config, fallBackToAdhoc);
|
|
304
|
+
if (!identity) {
|
|
305
|
+
return false;
|
|
257
306
|
}
|
|
258
307
|
if (!(0, macosVersion_1.isMacOsHighSierra)()) {
|
|
259
308
|
throw new builder_util_1.InvalidConfigurationError("macOS High Sierra 10.13.6 is required to sign");
|
|
260
309
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
else if (filter != null) {
|
|
268
|
-
filter = filter.length === 0 ? null : [filter];
|
|
269
|
-
}
|
|
270
|
-
const filterRe = filter == null
|
|
271
|
-
? null
|
|
272
|
-
: filter.map(it => {
|
|
273
|
-
try {
|
|
274
|
-
return new RegExp(it);
|
|
275
|
-
}
|
|
276
|
-
catch (e) {
|
|
277
|
-
throw new builder_util_1.InvalidConfigurationError(`Invalid regex filter pattern: ${it}. ${e.message}`);
|
|
278
|
-
}
|
|
279
|
-
});
|
|
280
|
-
let binaries = options.binaries || undefined;
|
|
281
|
-
if (binaries) {
|
|
282
|
-
// Accept absolute paths for external binaries, else resolve relative paths from the artifact's app Contents path.
|
|
283
|
-
binaries = (await Promise.all(binaries.flatMap(async (destination) => {
|
|
284
|
-
const expandedDestination = this.expandArch(destination, arch);
|
|
285
|
-
return await Promise.all(expandedDestination.map(async (d) => {
|
|
286
|
-
if (await (0, builder_util_1.statOrNull)(d)) {
|
|
287
|
-
return d;
|
|
288
|
-
}
|
|
289
|
-
return path.resolve(appPath, d);
|
|
290
|
-
}));
|
|
291
|
-
}))).flat();
|
|
292
|
-
builder_util_1.log.info({ binaries, arch: arch == null ? null : builder_util_1.Arch[arch] }, "signing additional user-defined binaries for arch");
|
|
293
|
-
}
|
|
294
|
-
const customSignOptions = (isMas ? masOptions : this.platformSpecificBuildOptions) || this.platformSpecificBuildOptions;
|
|
295
|
-
const signOptions = {
|
|
296
|
-
identityValidation: false,
|
|
297
|
-
// https://github.com/electron-userland/electron-builder/issues/1699
|
|
298
|
-
// kext are signed by the chipset manufacturers. You need a special certificate (only available on request) from Apple to be able to sign kext.
|
|
299
|
-
ignore: (file) => {
|
|
300
|
-
if (filterRe != null) {
|
|
301
|
-
for (const regExp of filterRe) {
|
|
302
|
-
if (regExp.test(file)) {
|
|
303
|
-
return true;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return (file.endsWith(".kext") ||
|
|
308
|
-
file.startsWith("/Contents/PlugIns", appPath.length) ||
|
|
309
|
-
file.includes("/node_modules/puppeteer/.local-chromium") ||
|
|
310
|
-
file.includes("/node_modules/playwright-firefox/.local-browsers") ||
|
|
311
|
-
file.includes("/node_modules/playwright/.local-browsers"));
|
|
312
|
-
/* Those are browser automating modules, browser (chromium, nightly) cannot be signed
|
|
313
|
-
https://github.com/electron-userland/electron-builder/issues/2010
|
|
314
|
-
https://github.com/electron-userland/electron-builder/issues/5383
|
|
315
|
-
*/
|
|
316
|
-
},
|
|
317
|
-
identity: identity ? identity.hash || identity.name : undefined,
|
|
318
|
-
type,
|
|
319
|
-
platform: isMas ? "mas" : "darwin",
|
|
320
|
-
version: this.config.electronVersion || undefined,
|
|
321
|
-
app: appPath,
|
|
322
|
-
keychain: keychainFile || undefined,
|
|
323
|
-
binaries,
|
|
324
|
-
// https://github.com/electron-userland/electron-builder/issues/1480
|
|
325
|
-
strictVerify: options.strictVerify,
|
|
326
|
-
preAutoEntitlements: options.preAutoEntitlements,
|
|
327
|
-
optionsForFile: await this.getOptionsForFile(appPath, isMas, customSignOptions),
|
|
328
|
-
provisioningProfile: customSignOptions.provisioningProfile || undefined,
|
|
329
|
-
};
|
|
330
|
-
await this.doSign(signOptions, customSignOptions, identity);
|
|
331
|
-
// https://github.com/electron-userland/electron-builder/issues/1196#issuecomment-312310209
|
|
332
|
-
if (masOptions != null && !isDevelopment) {
|
|
333
|
-
const certType = isDevelopment ? "Mac Developer" : "3rd Party Mac Developer Installer";
|
|
334
|
-
const masInstallerIdentity = await (0, macCodeSign_1.findIdentity)(certType, masOptions.identity, keychainFile);
|
|
335
|
-
if (masInstallerIdentity == null) {
|
|
336
|
-
throw new builder_util_1.InvalidConfigurationError(`Cannot find valid "${certType}" identity to sign MAS installer, please see https://electron.build/code-signing`);
|
|
337
|
-
}
|
|
338
|
-
// mas uploaded to AppStore, so, use "-" instead of space for name
|
|
339
|
-
const artifactName = this.expandArtifactNamePattern(masOptions, "pkg", arch);
|
|
340
|
-
const artifactPath = path.join(outDir, artifactName);
|
|
341
|
-
await this.doFlat(appPath, artifactPath, masInstallerIdentity, keychainFile);
|
|
342
|
-
await this.info.emitArtifactBuildCompleted({
|
|
343
|
-
file: artifactPath,
|
|
344
|
-
target: null,
|
|
345
|
-
arch: builder_util_1.Arch.x64,
|
|
346
|
-
safeArtifactName: this.computeSafeArtifactName(artifactName, "pkg", arch, true, this.platformSpecificBuildOptions.defaultArch),
|
|
347
|
-
packager: this,
|
|
348
|
-
});
|
|
310
|
+
const signOptions = await this.helper.buildSignOptions(appPath, identity, type, isMas, config, keychainFile, arch);
|
|
311
|
+
await this.doSign(signOptions, config, identity);
|
|
312
|
+
// Handle MAS installer creation
|
|
313
|
+
if (isMas && !isDevelopment && outDir) {
|
|
314
|
+
await this.helper.createMasInstaller(appPath, outDir, config, keychainFile, isDevelopment, arch);
|
|
349
315
|
}
|
|
316
|
+
// Handle notarization for non-MAS builds
|
|
350
317
|
if (!isMas) {
|
|
351
|
-
await this.notarizeIfProvided(appPath);
|
|
318
|
+
await this.helper.notarizeIfProvided(appPath);
|
|
352
319
|
}
|
|
353
320
|
return true;
|
|
354
321
|
}
|
|
355
|
-
async getOptionsForFile(appPath, isMas, customSignOptions) {
|
|
356
|
-
const resourceList = await this.resourceList;
|
|
357
|
-
const entitlementsSuffix = isMas ? "mas" : "mac";
|
|
358
|
-
const getEntitlements = (filePath) => {
|
|
359
|
-
// check if root app, then use main entitlements
|
|
360
|
-
if (filePath === appPath) {
|
|
361
|
-
if (customSignOptions.entitlements) {
|
|
362
|
-
return customSignOptions.entitlements;
|
|
363
|
-
}
|
|
364
|
-
const p = `entitlements.${entitlementsSuffix}.plist`;
|
|
365
|
-
if (resourceList.includes(p)) {
|
|
366
|
-
return path.join(this.info.buildResourcesDir, p);
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
369
|
-
return (0, pathManager_1.getTemplatePath)("entitlements.mac.plist");
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
// It's a login helper...
|
|
373
|
-
if (filePath.includes("Library/LoginItems")) {
|
|
374
|
-
return customSignOptions.entitlementsLoginHelper;
|
|
375
|
-
}
|
|
376
|
-
// Only remaining option is that it's inherited entitlements
|
|
377
|
-
if (customSignOptions.entitlementsInherit) {
|
|
378
|
-
return customSignOptions.entitlementsInherit;
|
|
379
|
-
}
|
|
380
|
-
const p = `entitlements.${entitlementsSuffix}.inherit.plist`;
|
|
381
|
-
if (resourceList.includes(p)) {
|
|
382
|
-
return path.join(this.info.buildResourcesDir, p);
|
|
383
|
-
}
|
|
384
|
-
else {
|
|
385
|
-
return (0, pathManager_1.getTemplatePath)("entitlements.mac.plist");
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
const requirements = isMas || this.platformSpecificBuildOptions.requirements == null ? undefined : await this.getResource(this.platformSpecificBuildOptions.requirements);
|
|
389
|
-
// harden by default for mac builds. Only harden mas builds if explicitly true (backward compatibility)
|
|
390
|
-
const hardenedRuntime = isMas ? customSignOptions.hardenedRuntime === true : customSignOptions.hardenedRuntime !== false;
|
|
391
|
-
const optionsForFile = filePath => {
|
|
392
|
-
const entitlements = getEntitlements(filePath);
|
|
393
|
-
const args = {
|
|
394
|
-
entitlements: entitlements || undefined,
|
|
395
|
-
hardenedRuntime: hardenedRuntime !== null && hardenedRuntime !== void 0 ? hardenedRuntime : undefined,
|
|
396
|
-
timestamp: customSignOptions.timestamp || undefined,
|
|
397
|
-
requirements: requirements || undefined,
|
|
398
|
-
additionalArguments: customSignOptions.additionalArguments || [],
|
|
399
|
-
};
|
|
400
|
-
return args;
|
|
401
|
-
};
|
|
402
|
-
return optionsForFile;
|
|
403
|
-
}
|
|
404
322
|
//noinspection JSMethodCanBeStatic
|
|
405
323
|
async doSign(opts, customSignOptions, identity) {
|
|
406
324
|
const customSign = await (0, resolve_1.resolveFunction)(this.appInfo.type, customSignOptions.sign, "sign", await this.info.getWorkspaceRoot());
|
|
@@ -417,11 +335,13 @@ class MacPackager extends platformPackager_1.PlatformPackager {
|
|
|
417
335
|
}
|
|
418
336
|
//noinspection JSMethodCanBeStatic
|
|
419
337
|
async doFlat(appPath, outFile, identity, keychain) {
|
|
338
|
+
const safeAppPath = (0, builder_util_1.sanitizeDirPath)(appPath);
|
|
339
|
+
const safeOutFile = (0, builder_util_1.sanitizeDirPath)(outFile);
|
|
420
340
|
// productbuild doesn't created directory for out file
|
|
421
|
-
await (0, promises_1.mkdir)(path.dirname(
|
|
341
|
+
await (0, promises_1.mkdir)(path.dirname(safeOutFile), { recursive: true });
|
|
422
342
|
const args = (0, pkg_1.prepareProductBuildArgs)(identity, keychain);
|
|
423
|
-
args.push("--component",
|
|
424
|
-
args.push(
|
|
343
|
+
args.push("--component", safeAppPath, "/Applications");
|
|
344
|
+
args.push(safeOutFile);
|
|
425
345
|
return await (0, builder_util_1.exec)("productbuild", args);
|
|
426
346
|
}
|
|
427
347
|
getElectronSrcDir(dist) {
|
|
@@ -432,6 +352,7 @@ class MacPackager extends platformPackager_1.PlatformPackager {
|
|
|
432
352
|
}
|
|
433
353
|
// todo fileAssociations
|
|
434
354
|
async applyCommonInfo(appPlist, contentsPath) {
|
|
355
|
+
var _a;
|
|
435
356
|
const appInfo = this.appInfo;
|
|
436
357
|
const appFilename = appInfo.productFilename;
|
|
437
358
|
// https://github.com/electron-userland/electron-builder/issues/1278
|
|
@@ -472,8 +393,9 @@ class MacPackager extends platformPackager_1.PlatformPackager {
|
|
|
472
393
|
if (minimumSystemVersion != null) {
|
|
473
394
|
appPlist.LSMinimumSystemVersion = minimumSystemVersion;
|
|
474
395
|
}
|
|
475
|
-
|
|
476
|
-
appPlist.
|
|
396
|
+
const activeOpts = (_a = this._activePackConfig) !== null && _a !== void 0 ? _a : this.platformSpecificBuildOptions;
|
|
397
|
+
appPlist.CFBundleShortVersionString = activeOpts.bundleShortVersion || appInfo.version;
|
|
398
|
+
appPlist.CFBundleVersion = activeOpts.bundleVersion || appInfo.buildVersion;
|
|
477
399
|
(0, builder_util_1.use)(this.platformSpecificBuildOptions.category || this.config.category, it => (appPlist.LSApplicationCategoryType = it));
|
|
478
400
|
appPlist.NSHumanReadableCopyright = appInfo.copyright;
|
|
479
401
|
if (this.platformSpecificBuildOptions.darkModeSupport) {
|
|
@@ -490,10 +412,21 @@ class MacPackager extends platformPackager_1.PlatformPackager {
|
|
|
490
412
|
}
|
|
491
413
|
}
|
|
492
414
|
async signApp(packContext, isAsar) {
|
|
415
|
+
var _a;
|
|
416
|
+
const isMas = packContext.electronPlatformName === "mas";
|
|
417
|
+
const activeConfig = (_a = this._activePackConfig) !== null && _a !== void 0 ? _a : this.platformSpecificBuildOptions;
|
|
493
418
|
const readDirectoryAndSign = async (sourceDirectory, directories, shouldSign) => {
|
|
419
|
+
const normalizedSourceDirectory = path.resolve(sourceDirectory);
|
|
420
|
+
MacTargetHelper_1.MacTargetHelper.assertSafePathForCommandUsage(normalizedSourceDirectory, "application output directory");
|
|
494
421
|
await Promise.all(directories.map(async (file) => {
|
|
495
422
|
if (shouldSign(file)) {
|
|
496
|
-
|
|
423
|
+
const entryName = path.basename(file);
|
|
424
|
+
if (file !== entryName) {
|
|
425
|
+
throw new builder_util_1.InvalidConfigurationError(`Invalid entry name in source directory: ${file}`);
|
|
426
|
+
}
|
|
427
|
+
const signTarget = path.resolve(normalizedSourceDirectory, entryName);
|
|
428
|
+
const safeSignTarget = (0, builder_util_1.sanitizeDirPath)(signTarget, normalizedSourceDirectory);
|
|
429
|
+
await this.sign(safeSignTarget, null, isMas ? activeConfig : null, packContext.arch, isMas);
|
|
497
430
|
}
|
|
498
431
|
}));
|
|
499
432
|
return true;
|
|
@@ -507,67 +440,6 @@ class MacPackager extends platformPackager_1.PlatformPackager {
|
|
|
507
440
|
await readDirectoryAndSign(outResourcesDir, await (0, builder_util_1.orIfFileNotExist)((0, promises_1.readdir)(outResourcesDir), []), file => file.endsWith(".app"));
|
|
508
441
|
return true;
|
|
509
442
|
}
|
|
510
|
-
async notarizeIfProvided(appPath) {
|
|
511
|
-
const notarizeOptions = this.platformSpecificBuildOptions.notarize;
|
|
512
|
-
if (notarizeOptions === false) {
|
|
513
|
-
builder_util_1.log.info({ reason: "`notarize` options were set explicitly `false`" }, "skipped macOS notarization");
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
const options = this.getNotarizeOptions(appPath);
|
|
517
|
-
if (!options) {
|
|
518
|
-
builder_util_1.log.warn({ reason: "`notarize` options were unable to be generated" }, "skipped macOS notarization");
|
|
519
|
-
return;
|
|
520
|
-
}
|
|
521
|
-
await (0, notarize_1.notarize)(options);
|
|
522
|
-
builder_util_1.log.info(null, "notarization successful");
|
|
523
|
-
}
|
|
524
|
-
getNotarizeOptions(appPath) {
|
|
525
|
-
const teamId = process.env.APPLE_TEAM_ID;
|
|
526
|
-
const appleId = process.env.APPLE_ID;
|
|
527
|
-
const appleIdPassword = process.env.APPLE_APP_SPECIFIC_PASSWORD;
|
|
528
|
-
const tool = "notarytool";
|
|
529
|
-
// option 1: app specific password
|
|
530
|
-
if (appleId || appleIdPassword) {
|
|
531
|
-
if (!appleId) {
|
|
532
|
-
throw new builder_util_1.InvalidConfigurationError(`APPLE_ID env var needs to be set`);
|
|
533
|
-
}
|
|
534
|
-
if (!appleIdPassword) {
|
|
535
|
-
throw new builder_util_1.InvalidConfigurationError(`APPLE_APP_SPECIFIC_PASSWORD env var needs to be set`);
|
|
536
|
-
}
|
|
537
|
-
if (!teamId) {
|
|
538
|
-
throw new builder_util_1.InvalidConfigurationError(`APPLE_TEAM_ID env var needs to be set`);
|
|
539
|
-
}
|
|
540
|
-
return { tool, appPath, appleId, appleIdPassword, teamId };
|
|
541
|
-
}
|
|
542
|
-
// option 2: API key
|
|
543
|
-
const appleApiKey = process.env.APPLE_API_KEY;
|
|
544
|
-
const appleApiKeyId = process.env.APPLE_API_KEY_ID;
|
|
545
|
-
const appleApiIssuer = process.env.APPLE_API_ISSUER;
|
|
546
|
-
if (appleApiKey || appleApiKeyId || appleApiIssuer) {
|
|
547
|
-
if (!appleApiKey || !appleApiKeyId || !appleApiIssuer) {
|
|
548
|
-
throw new builder_util_1.InvalidConfigurationError(`Env vars APPLE_API_KEY, APPLE_API_KEY_ID and APPLE_API_ISSUER need to be set`);
|
|
549
|
-
}
|
|
550
|
-
return { tool, appPath, appleApiKey, appleApiKeyId, appleApiIssuer };
|
|
551
|
-
}
|
|
552
|
-
// option 3: keychain
|
|
553
|
-
const keychain = process.env.APPLE_KEYCHAIN;
|
|
554
|
-
const keychainProfile = process.env.APPLE_KEYCHAIN_PROFILE;
|
|
555
|
-
if (keychainProfile) {
|
|
556
|
-
let args = { keychainProfile };
|
|
557
|
-
if (keychain) {
|
|
558
|
-
args = { ...args, keychain };
|
|
559
|
-
}
|
|
560
|
-
return { tool, appPath, ...args };
|
|
561
|
-
}
|
|
562
|
-
// if no credentials provided, skip silently
|
|
563
|
-
return undefined;
|
|
564
|
-
}
|
|
565
443
|
}
|
|
566
444
|
exports.MacPackager = MacPackager;
|
|
567
|
-
function getCertificateTypes(isMas, isDevelopment) {
|
|
568
|
-
if (isDevelopment) {
|
|
569
|
-
return isMas ? ["Mac Developer", "Apple Development"] : ["Mac Developer", "Developer ID Application"];
|
|
570
|
-
}
|
|
571
|
-
return isMas ? ["Apple Distribution", "3rd Party Mac Developer Application"] : ["Developer ID Application"];
|
|
572
|
-
}
|
|
573
445
|
//# sourceMappingURL=macPackager.js.map
|