forked from olcxjas-softworks/LarpixClient
update electron to v43
This commit is contained in:
parent
68ac0beedf
commit
fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions
598
electron/node_modules/app-builder-lib/out/macPackager.js
generated
vendored
598
electron/node_modules/app-builder-lib/out/macPackager.js
generated
vendored
|
|
@ -1,54 +1,103 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const bluebird_lst_1 = require("bluebird-lst");
|
||||
exports.MacPackager = void 0;
|
||||
const builder_util_1 = require("builder-util");
|
||||
const electron_osx_sign_1 = require("electron-osx-sign");
|
||||
const builder_util_runtime_1 = require("builder-util-runtime");
|
||||
const fs = require("fs/promises");
|
||||
const promises_1 = require("fs/promises");
|
||||
const lazy_val_1 = require("lazy-val");
|
||||
const path = require("path");
|
||||
const fs_1 = require("builder-util/out/fs");
|
||||
const promise_1 = require("builder-util/out/promise");
|
||||
const appInfo_1 = require("./appInfo");
|
||||
const macCodeSign_1 = require("./codeSign/macCodeSign");
|
||||
const core_1 = require("./core");
|
||||
const MacTargetHelper_1 = require("./mac/MacTargetHelper");
|
||||
const platformPackager_1 = require("./platformPackager");
|
||||
const ArchiveTarget_1 = require("./targets/ArchiveTarget");
|
||||
const pkg_1 = require("./targets/pkg");
|
||||
const targetFactory_1 = require("./targets/targetFactory");
|
||||
const dynamicImport_1 = require("./util/dynamicImport");
|
||||
const macosVersion_1 = require("./util/macosVersion");
|
||||
const pathManager_1 = require("./util/pathManager");
|
||||
const fs = require("fs/promises");
|
||||
const macroExpander_1 = require("./util/macroExpander");
|
||||
const resolve_1 = require("./util/resolve");
|
||||
class MacPackager extends platformPackager_1.PlatformPackager {
|
||||
constructor(info) {
|
||||
super(info, core_1.Platform.MAC);
|
||||
this.codeSigningInfo = new lazy_val_1.Lazy(() => {
|
||||
this.codeSigningInfo = new builder_util_runtime_1.MemoLazy(() => {
|
||||
const cscLink = this.getCscLink();
|
||||
if (cscLink == null || process.platform !== "darwin") {
|
||||
return Promise.resolve({ keychainFile: process.env.CSC_KEYCHAIN || null });
|
||||
return null;
|
||||
}
|
||||
return macCodeSign_1.createKeychain({
|
||||
const selected = {
|
||||
tmpDir: this.info.tempDirManager,
|
||||
cscLink,
|
||||
cscKeyPassword: this.getCscPassword(),
|
||||
cscILink: platformPackager_1.chooseNotNull(this.platformSpecificBuildOptions.cscInstallerLink, process.env.CSC_INSTALLER_LINK),
|
||||
cscIKeyPassword: platformPackager_1.chooseNotNull(this.platformSpecificBuildOptions.cscInstallerKeyPassword, process.env.CSC_INSTALLER_KEY_PASSWORD),
|
||||
cscILink: (0, platformPackager_1.chooseNotNull)(this.platformSpecificBuildOptions.cscInstallerLink, process.env.CSC_INSTALLER_LINK),
|
||||
cscIKeyPassword: (0, platformPackager_1.chooseNotNull)(this.platformSpecificBuildOptions.cscInstallerKeyPassword, process.env.CSC_INSTALLER_KEY_PASSWORD),
|
||||
currentDir: this.projectDir,
|
||||
}).then(result => {
|
||||
const keychainFile = result.keychainFile;
|
||||
if (keychainFile != null) {
|
||||
this.info.disposeOnBuildFinish(() => macCodeSign_1.removeKeychain(keychainFile));
|
||||
}
|
||||
return result;
|
||||
});
|
||||
};
|
||||
return selected;
|
||||
}, async (selected) => {
|
||||
if (selected) {
|
||||
return (0, macCodeSign_1.createKeychain)(selected).then(result => {
|
||||
const keychainFile = result.keychainFile;
|
||||
if (keychainFile != null) {
|
||||
this.info.disposeOnBuildFinish(() => (0, macCodeSign_1.removeKeychain)(keychainFile));
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
return Promise.resolve({ keychainFile: process.env.CSC_KEYCHAIN || null });
|
||||
});
|
||||
this._iconPath = new lazy_val_1.Lazy(() => this.getOrConvertIcon("icns"));
|
||||
// Set/cleared in doPack so applyCommonInfo can read the per-pack platformSpecificBuildOptions
|
||||
// (the framework call chain doesn't thread it through to applyCommonInfo). Fixes #8909.
|
||||
this._activePackConfig = null;
|
||||
this.helper = new MacTargetHelper_1.MacTargetHelper(this);
|
||||
}
|
||||
get defaultTarget() {
|
||||
return this.info.framework.macOsDefaultTargets;
|
||||
}
|
||||
/**
|
||||
* Get the merged configuration for a specific platform type
|
||||
*/
|
||||
getPlatformConfig(platformType) {
|
||||
let config;
|
||||
let isDevelopment = false;
|
||||
let platformName;
|
||||
switch (platformType) {
|
||||
case "mas":
|
||||
config = (0, builder_util_1.deepAssign)({}, this.platformSpecificBuildOptions, this.config.mas);
|
||||
isDevelopment = false;
|
||||
platformName = "mas";
|
||||
break;
|
||||
case "mas-dev":
|
||||
config = (0, builder_util_1.deepAssign)({}, this.platformSpecificBuildOptions, this.config.mas, this.config.masDev, {
|
||||
type: "development",
|
||||
});
|
||||
isDevelopment = true;
|
||||
platformName = "mas";
|
||||
break;
|
||||
case "mac":
|
||||
default:
|
||||
config = this.platformSpecificBuildOptions;
|
||||
isDevelopment = false;
|
||||
platformName = this.platform.nodeName;
|
||||
break;
|
||||
}
|
||||
return { type: platformType, config, isDevelopment, platformName };
|
||||
}
|
||||
expandArch(pattern, arch) {
|
||||
if (arch === builder_util_1.Arch.universal) {
|
||||
// Universal build has `app-x64.asar.unpacked` & `app-arm64.asar.unpacked`
|
||||
return [(0, macroExpander_1.expandMacro)(pattern, builder_util_1.Arch[builder_util_1.Arch.arm64], this.appInfo, {}, false), (0, macroExpander_1.expandMacro)(pattern, builder_util_1.Arch[builder_util_1.Arch.x64], this.appInfo, {}, false)];
|
||||
}
|
||||
// Every other build keeps the name as `app.asar.unpacked`
|
||||
return [(0, macroExpander_1.expandMacro)(pattern, null, this.appInfo, {}, false)];
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
prepareAppInfo(appInfo) {
|
||||
return new appInfo_1.AppInfo(this.info, this.platformSpecificBuildOptions.bundleVersion, this.platformSpecificBuildOptions);
|
||||
// codesign requires the filename to be normalized to the NFD form
|
||||
return new appInfo_1.AppInfo(this.info, this.platformSpecificBuildOptions.bundleVersion, this.platformSpecificBuildOptions, true);
|
||||
}
|
||||
async getIconPath() {
|
||||
return this._iconPath.value;
|
||||
|
|
@ -59,7 +108,6 @@ class MacPackager extends platformPackager_1.PlatformPackager {
|
|||
case core_1.DIR_TARGET:
|
||||
break;
|
||||
case "dmg": {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { DmgTarget } = require("dmg-builder");
|
||||
mapper(name, outDir => new DmgTarget(this, outDir));
|
||||
break;
|
||||
|
|
@ -72,258 +120,229 @@ class MacPackager extends platformPackager_1.PlatformPackager {
|
|||
mapper(name, outDir => new pkg_1.PkgTarget(this, outDir));
|
||||
break;
|
||||
default:
|
||||
mapper(name, outDir => (name === "mas" || name === "mas-dev" ? new targetFactory_1.NoOpTarget(name) : targetFactory_1.createCommonTarget(name, outDir, this)));
|
||||
mapper(name, outDir => (MacTargetHelper_1.MacTargetHelper.isMasTarget(name) ? new targetFactory_1.NoOpTarget(name) : (0, targetFactory_1.createCommonTarget)(name, outDir, this)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
async doPack(outDir, appOutDir, platformName, arch, platformSpecificBuildOptions, targets) {
|
||||
var _a;
|
||||
switch (arch) {
|
||||
default: {
|
||||
return super.doPack(outDir, appOutDir, platformName, arch, platformSpecificBuildOptions, targets);
|
||||
async doPack(config) {
|
||||
if (config.arch === builder_util_1.Arch.universal) {
|
||||
return this.doUniversalPack(config);
|
||||
}
|
||||
// Bridge the per-pack platformSpecificBuildOptions to applyCommonInfo, which is called deep in the
|
||||
// framework stack (doPack → beforeCopyExtraFiles → createMacApp → applyCommonInfo) without it.
|
||||
this._activePackConfig = config.platformSpecificBuildOptions;
|
||||
try {
|
||||
return await super.doPack(config);
|
||||
}
|
||||
finally {
|
||||
this._activePackConfig = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Handle universal build packing
|
||||
*/
|
||||
async doUniversalPack(config) {
|
||||
var _a, _b, _c;
|
||||
this._activePackConfig = config.platformSpecificBuildOptions;
|
||||
try {
|
||||
const { outDir, appOutDir, platformName, arch, platformSpecificBuildOptions, targets } = config;
|
||||
const outDirName = (arch) => `${appOutDir}-${builder_util_1.Arch[arch]}-temp`;
|
||||
const options = {
|
||||
...config,
|
||||
options: {
|
||||
sign: false,
|
||||
disableAsarIntegrity: true,
|
||||
disableFuses: true,
|
||||
},
|
||||
};
|
||||
const x64Arch = builder_util_1.Arch.x64;
|
||||
const x64AppOutDir = outDirName(x64Arch);
|
||||
await super.doPack({ ...options, appOutDir: x64AppOutDir, arch: x64Arch });
|
||||
if (this.info.cancellationToken.cancelled) {
|
||||
return;
|
||||
}
|
||||
case builder_util_1.Arch.universal: {
|
||||
const x64Arch = builder_util_1.Arch.x64;
|
||||
const x64AppOutDir = appOutDir + "--" + builder_util_1.Arch[x64Arch];
|
||||
await super.doPack(outDir, x64AppOutDir, platformName, x64Arch, platformSpecificBuildOptions, targets, false, true);
|
||||
const arm64Arch = builder_util_1.Arch.arm64;
|
||||
const arm64AppOutPath = appOutDir + "--" + builder_util_1.Arch[arm64Arch];
|
||||
await super.doPack(outDir, arm64AppOutPath, platformName, arm64Arch, platformSpecificBuildOptions, targets, false, true);
|
||||
const framework = this.info.framework;
|
||||
builder_util_1.log.info({
|
||||
platform: platformName,
|
||||
arch: builder_util_1.Arch[arch],
|
||||
[`${framework.name}`]: framework.version,
|
||||
appOutDir: builder_util_1.log.filePath(appOutDir),
|
||||
}, `packaging`);
|
||||
const appFile = `${this.appInfo.productFilename}.app`;
|
||||
const { makeUniversalApp } = require("@electron/universal");
|
||||
await makeUniversalApp({
|
||||
x64AppPath: path.join(x64AppOutDir, appFile),
|
||||
arm64AppPath: path.join(arm64AppOutPath, appFile),
|
||||
outAppPath: path.join(appOutDir, appFile),
|
||||
force: true,
|
||||
mergeASARs: (_a = platformSpecificBuildOptions.mergeASARs) !== null && _a !== void 0 ? _a : true,
|
||||
singleArchFiles: platformSpecificBuildOptions.singleArchFiles,
|
||||
x64ArchFiles: platformSpecificBuildOptions.x64ArchFiles,
|
||||
});
|
||||
await fs.rm(x64AppOutDir, { recursive: true, force: true });
|
||||
await fs.rm(arm64AppOutPath, { recursive: true, force: true });
|
||||
// Give users a final opportunity to perform things on the combined universal package before signing
|
||||
const packContext = {
|
||||
appOutDir,
|
||||
outDir,
|
||||
arch,
|
||||
targets,
|
||||
packager: this,
|
||||
electronPlatformName: platformName,
|
||||
};
|
||||
await this.info.afterPack(packContext);
|
||||
const arm64Arch = builder_util_1.Arch.arm64;
|
||||
const arm64AppOutPath = outDirName(arm64Arch);
|
||||
await super.doPack({ ...options, appOutDir: arm64AppOutPath, arch: arm64Arch });
|
||||
if (this.info.cancellationToken.cancelled) {
|
||||
return;
|
||||
}
|
||||
const framework = this.info.framework;
|
||||
builder_util_1.log.info({
|
||||
platform: platformName,
|
||||
arch: builder_util_1.Arch[arch],
|
||||
[`${framework.name}`]: framework.version,
|
||||
appOutDir: builder_util_1.log.filePath(appOutDir),
|
||||
}, `packaging`);
|
||||
const appFile = `${this.appInfo.productFilename}.app`;
|
||||
// Make sure the Assets.car file is the same for both architectures
|
||||
const safeX64AppOutDir = (0, builder_util_1.sanitizeDirPath)(x64AppOutDir);
|
||||
const safeArm64AppOutPath = (0, builder_util_1.sanitizeDirPath)(arm64AppOutPath);
|
||||
const safeAppOutDir = (0, builder_util_1.sanitizeDirPath)(appOutDir);
|
||||
const sourceCatalogPath = path.join(safeX64AppOutDir, appFile, "Contents/Resources/Assets.car");
|
||||
if (await (0, builder_util_1.exists)(sourceCatalogPath)) {
|
||||
const targetCatalogPath = path.join(safeArm64AppOutPath, appFile, "Contents/Resources/Assets.car");
|
||||
await fs.copyFile(sourceCatalogPath, targetCatalogPath);
|
||||
}
|
||||
const { makeUniversalApp } = await (0, dynamicImport_1.dynamicImport)("@electron/universal");
|
||||
await makeUniversalApp({
|
||||
x64AppPath: path.join(safeX64AppOutDir, appFile),
|
||||
arm64AppPath: path.join(safeArm64AppOutPath, appFile),
|
||||
outAppPath: path.join(safeAppOutDir, appFile),
|
||||
force: true,
|
||||
mergeASARs: (_a = platformSpecificBuildOptions.mergeASARs) !== null && _a !== void 0 ? _a : true, // must be ?? to allow false
|
||||
singleArchFiles: platformSpecificBuildOptions.singleArchFiles || undefined,
|
||||
x64ArchFiles: platformSpecificBuildOptions.x64ArchFiles || undefined,
|
||||
});
|
||||
await fs.rm(x64AppOutDir, { recursive: true, force: true });
|
||||
await fs.rm(arm64AppOutPath, { recursive: true, force: true });
|
||||
// Give users a final opportunity to perform things on the combined universal package before signing
|
||||
const packContext = {
|
||||
appOutDir,
|
||||
outDir,
|
||||
arch,
|
||||
targets,
|
||||
packager: this,
|
||||
electronPlatformName: platformName,
|
||||
};
|
||||
await this.info.emitAfterPack(packContext);
|
||||
if (this.info.cancellationToken.cancelled) {
|
||||
return;
|
||||
}
|
||||
await this.doAddElectronFuses(packContext);
|
||||
// Mirror the base-class guard: skip signing when the caller explicitly set sign:false
|
||||
// (e.g. packMasTargets passes sign:false so that signMas() is the sole signing step).
|
||||
if ((_c = (_b = config.options) === null || _b === void 0 ? void 0 : _b.sign) !== null && _c !== void 0 ? _c : true) {
|
||||
await this.doSignAfterPack(outDir, appOutDir, platformName, arch, platformSpecificBuildOptions, targets);
|
||||
break;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
this._activePackConfig = null;
|
||||
}
|
||||
}
|
||||
async pack(outDir, arch, targets, taskManager) {
|
||||
let nonMasPromise = null;
|
||||
const hasMas = targets.length !== 0 && targets.some(it => it.name === "mas" || it.name === "mas-dev");
|
||||
const masTargets = targets.filter(it => MacTargetHelper_1.MacTargetHelper.isMasTarget(it.name));
|
||||
const nonMasTargets = targets.filter(it => !MacTargetHelper_1.MacTargetHelper.isMasTarget(it.name));
|
||||
const prepackaged = this.packagerOptions.prepackaged;
|
||||
const hasMas = masTargets.length > 0;
|
||||
// mas always first
|
||||
await this.packMasTargets(outDir, arch, masTargets, prepackaged);
|
||||
// Mirror master's condition: skip the non-MAS darwin pack only when there are exclusively MAS
|
||||
// targets (hasMas=true, targets.length=1). DIR_TARGET passes targets=[] to pack() because
|
||||
// MacPackager.createTargets() doesn't call mapper() for it, so hasMas=false and doPack still runs.
|
||||
if (!hasMas || targets.length > 1) {
|
||||
const appPath = prepackaged == null ? path.join(this.computeAppOutDir(outDir, arch), `${this.appInfo.productFilename}.app`) : prepackaged;
|
||||
nonMasPromise = (prepackaged
|
||||
? Promise.resolve()
|
||||
: this.doPack(outDir, path.dirname(appPath), this.platform.nodeName, arch, this.platformSpecificBuildOptions, targets)).then(() => this.packageInDistributableFormat(appPath, arch, targets, taskManager));
|
||||
}
|
||||
for (const target of targets) {
|
||||
const targetName = target.name;
|
||||
if (!(targetName === "mas" || targetName === "mas-dev")) {
|
||||
continue;
|
||||
}
|
||||
const masBuildOptions = builder_util_1.deepAssign({}, this.platformSpecificBuildOptions, this.config.mas);
|
||||
if (targetName === "mas-dev") {
|
||||
builder_util_1.deepAssign(masBuildOptions, this.config.masDev, {
|
||||
type: "development",
|
||||
});
|
||||
}
|
||||
const targetOutDir = path.join(outDir, `${targetName}${builder_util_1.getArchSuffix(arch)}`);
|
||||
if (prepackaged == null) {
|
||||
await this.doPack(outDir, targetOutDir, "mas", arch, masBuildOptions, [target]);
|
||||
await this.sign(path.join(targetOutDir, `${this.appInfo.productFilename}.app`), targetOutDir, masBuildOptions, arch);
|
||||
}
|
||||
else {
|
||||
await this.sign(prepackaged, targetOutDir, masBuildOptions, arch);
|
||||
}
|
||||
}
|
||||
if (nonMasPromise != null) {
|
||||
await nonMasPromise;
|
||||
await this.packMacTargets(outDir, arch, nonMasTargets, prepackaged, taskManager);
|
||||
}
|
||||
}
|
||||
async sign(appPath, outDir, masOptions, arch) {
|
||||
if (!macCodeSign_1.isSignAllowed()) {
|
||||
return;
|
||||
}
|
||||
const isMas = masOptions != null;
|
||||
const options = masOptions == null ? this.platformSpecificBuildOptions : masOptions;
|
||||
const qualifier = options.identity;
|
||||
if (!isMas && qualifier === null) {
|
||||
if (this.forceCodeSigning) {
|
||||
throw new builder_util_1.InvalidConfigurationError("identity explicitly is set to null, but forceCodeSigning is set to true");
|
||||
async packMasTargets(outDir, arch, targets, prepackaged) {
|
||||
const resolvedOutDir = path.resolve(outDir);
|
||||
MacTargetHelper_1.MacTargetHelper.assertSafePathForCommandUsage(resolvedOutDir, "output directory");
|
||||
for (const target of targets) {
|
||||
const platformType = MacTargetHelper_1.MacTargetHelper.getPlatformTypeFromTarget(target.name);
|
||||
const platformConfig = this.getPlatformConfig(platformType);
|
||||
const targetOutDir = path.resolve(resolvedOutDir, `${target.name}${(0, builder_util_1.getArchSuffix)(arch, this.platformSpecificBuildOptions.defaultArch)}`);
|
||||
MacTargetHelper_1.MacTargetHelper.assertSafePathForCommandUsage(targetOutDir, "target output directory");
|
||||
const relativeTargetOutDir = path.relative(resolvedOutDir, targetOutDir);
|
||||
if (relativeTargetOutDir.startsWith("..") || path.isAbsolute(relativeTargetOutDir)) {
|
||||
throw new builder_util_1.InvalidConfigurationError(`Invalid target output directory: ${targetOutDir}`);
|
||||
}
|
||||
builder_util_1.log.info({ reason: "identity explicitly is set to null" }, "skipped macOS code signing");
|
||||
return;
|
||||
if (prepackaged == null) {
|
||||
await this.doPack({
|
||||
outDir: resolvedOutDir,
|
||||
appOutDir: targetOutDir,
|
||||
platformName: platformConfig.platformName,
|
||||
arch,
|
||||
platformSpecificBuildOptions: platformConfig.config,
|
||||
targets: [target],
|
||||
options: { sign: false },
|
||||
});
|
||||
MacTargetHelper_1.MacTargetHelper.assertSafePathForCommandUsage(this.appInfo.productFilename, "product filename");
|
||||
await this.signMas(path.resolve(targetOutDir, `${path.basename(this.appInfo.productFilename)}.app`), targetOutDir, platformConfig, arch);
|
||||
}
|
||||
else {
|
||||
await this.signMas(prepackaged, targetOutDir, platformConfig, arch);
|
||||
}
|
||||
}
|
||||
}
|
||||
async packMacTargets(outDir, arch, targets, prepackaged, taskManager) {
|
||||
const appPath = prepackaged == null ? path.join(this.computeAppOutDir(outDir, arch), `${path.basename(this.appInfo.productFilename)}.app`) : prepackaged;
|
||||
if (prepackaged == null) {
|
||||
const platformConfig = this.getPlatformConfig("mac");
|
||||
await this.doPack({
|
||||
outDir,
|
||||
appOutDir: path.dirname(appPath),
|
||||
platformName: platformConfig.platformName,
|
||||
arch,
|
||||
platformSpecificBuildOptions: platformConfig.config,
|
||||
targets,
|
||||
});
|
||||
}
|
||||
this.packageInDistributableFormat(appPath, arch, targets, taskManager);
|
||||
}
|
||||
async signMas(appPath, outDir, platformConfig, arch) {
|
||||
const signed = await this.sign(appPath, outDir, platformConfig.config, arch, true);
|
||||
return signed;
|
||||
}
|
||||
/**
|
||||
* Main signing method with platform awareness
|
||||
*/
|
||||
async sign(appPath, outDir, options, arch, isMas = false) {
|
||||
if (!(0, macCodeSign_1.isSignAllowed)()) {
|
||||
return false;
|
||||
}
|
||||
const config = options !== null && options !== void 0 ? options : this.platformSpecificBuildOptions;
|
||||
const qualifier = config.identity;
|
||||
if (qualifier === null) {
|
||||
return this.helper.handleNullIdentity();
|
||||
}
|
||||
const keychainFile = (await this.codeSigningInfo.value).keychainFile;
|
||||
const explicitType = options.type;
|
||||
const explicitType = config.type;
|
||||
const type = explicitType || "distribution";
|
||||
const isDevelopment = type === "development";
|
||||
const certificateTypes = getCertificateTypes(isMas, isDevelopment);
|
||||
let identity = null;
|
||||
for (const certificateType of certificateTypes) {
|
||||
identity = await macCodeSign_1.findIdentity(certificateType, qualifier, keychainFile);
|
||||
if (identity != null) {
|
||||
break;
|
||||
}
|
||||
const identity = await this.helper.findSigningIdentity(isMas, isDevelopment, qualifier, keychainFile, config);
|
||||
if (!identity) {
|
||||
return false;
|
||||
}
|
||||
if (identity == null) {
|
||||
if (!isMas && !isDevelopment && explicitType !== "distribution") {
|
||||
identity = await macCodeSign_1.findIdentity("Mac Developer", qualifier, keychainFile);
|
||||
if (identity != null) {
|
||||
builder_util_1.log.warn("Mac Developer is used to sign app — it is only for development and testing, not for production");
|
||||
}
|
||||
}
|
||||
if (identity == null) {
|
||||
await macCodeSign_1.reportError(isMas, certificateTypes, qualifier, keychainFile, this.forceCodeSigning);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!macosVersion_1.isMacOsHighSierra()) {
|
||||
if (!(0, macosVersion_1.isMacOsHighSierra)()) {
|
||||
throw new builder_util_1.InvalidConfigurationError("macOS High Sierra 10.13.6 is required to sign");
|
||||
}
|
||||
let filter = options.signIgnore;
|
||||
if (Array.isArray(filter)) {
|
||||
if (filter.length == 0) {
|
||||
filter = null;
|
||||
}
|
||||
const signOptions = await this.helper.buildSignOptions(appPath, identity, type, isMas, config, keychainFile, arch);
|
||||
await this.doSign(signOptions, config, identity);
|
||||
// Handle MAS installer creation
|
||||
if (isMas && !isDevelopment && outDir) {
|
||||
await this.helper.createMasInstaller(appPath, outDir, config, keychainFile, isDevelopment, arch);
|
||||
}
|
||||
else if (filter != null) {
|
||||
filter = filter.length === 0 ? null : [filter];
|
||||
// Handle notarization for non-MAS builds
|
||||
if (!isMas) {
|
||||
await this.helper.notarizeIfProvided(appPath);
|
||||
}
|
||||
const filterRe = filter == null ? null : filter.map(it => new RegExp(it));
|
||||
let binaries = options.binaries || undefined;
|
||||
if (binaries) {
|
||||
// Accept absolute paths for external binaries, else resolve relative paths from the artifact's app Contents path.
|
||||
binaries = await Promise.all(binaries.map(async (destination) => {
|
||||
if (await fs_1.statOrNull(destination)) {
|
||||
return destination;
|
||||
}
|
||||
return path.resolve(appPath, destination);
|
||||
}));
|
||||
builder_util_1.log.info("Signing addtional user-defined binaries: " + JSON.stringify(binaries, null, 1));
|
||||
}
|
||||
const signOptions = {
|
||||
"identity-validation": false,
|
||||
// https://github.com/electron-userland/electron-builder/issues/1699
|
||||
// kext are signed by the chipset manufacturers. You need a special certificate (only available on request) from Apple to be able to sign kext.
|
||||
ignore: (file) => {
|
||||
if (filterRe != null) {
|
||||
for (const regExp of filterRe) {
|
||||
if (regExp.test(file)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (file.endsWith(".kext") ||
|
||||
file.startsWith("/Contents/PlugIns", appPath.length) ||
|
||||
file.includes("/node_modules/puppeteer/.local-chromium") ||
|
||||
file.includes("/node_modules/playwright-firefox/.local-browsers") ||
|
||||
file.includes("/node_modules/playwright/.local-browsers"));
|
||||
/* Those are browser automating modules, browser (chromium, nightly) cannot be signed
|
||||
https://github.com/electron-userland/electron-builder/issues/2010
|
||||
https://github.com/electron-userland/electron-builder/issues/5383
|
||||
*/
|
||||
},
|
||||
identity: identity,
|
||||
type,
|
||||
platform: isMas ? "mas" : "darwin",
|
||||
version: this.config.electronVersion,
|
||||
app: appPath,
|
||||
keychain: keychainFile || undefined,
|
||||
binaries,
|
||||
timestamp: isMas ? masOptions === null || masOptions === void 0 ? void 0 : masOptions.timestamp : options.timestamp,
|
||||
requirements: isMas || this.platformSpecificBuildOptions.requirements == null ? undefined : await this.getResource(this.platformSpecificBuildOptions.requirements),
|
||||
// https://github.com/electron-userland/electron-osx-sign/issues/196
|
||||
// will fail on 10.14.5+ because a signed but unnotarized app is also rejected.
|
||||
"gatekeeper-assess": options.gatekeeperAssess === true,
|
||||
// https://github.com/electron-userland/electron-builder/issues/1480
|
||||
"strict-verify": options.strictVerify,
|
||||
hardenedRuntime: isMas ? masOptions && masOptions.hardenedRuntime === true : options.hardenedRuntime !== false,
|
||||
};
|
||||
await this.adjustSignOptions(signOptions, masOptions);
|
||||
builder_util_1.log.info({
|
||||
file: builder_util_1.log.filePath(appPath),
|
||||
identityName: identity.name,
|
||||
identityHash: identity.hash,
|
||||
provisioningProfile: signOptions["provisioning-profile"] || "none",
|
||||
}, "signing");
|
||||
await this.doSign(signOptions);
|
||||
// https://github.com/electron-userland/electron-builder/issues/1196#issuecomment-312310209
|
||||
if (masOptions != null && !isDevelopment) {
|
||||
const certType = isDevelopment ? "Mac Developer" : "3rd Party Mac Developer Installer";
|
||||
const masInstallerIdentity = await macCodeSign_1.findIdentity(certType, masOptions.identity, keychainFile);
|
||||
if (masInstallerIdentity == null) {
|
||||
throw new builder_util_1.InvalidConfigurationError(`Cannot find valid "${certType}" identity to sign MAS installer, please see https://electron.build/code-signing`);
|
||||
}
|
||||
// mas uploaded to AppStore, so, use "-" instead of space for name
|
||||
const artifactName = this.expandArtifactNamePattern(masOptions, "pkg", arch);
|
||||
const artifactPath = path.join(outDir, artifactName);
|
||||
await this.doFlat(appPath, artifactPath, masInstallerIdentity, keychainFile);
|
||||
await this.dispatchArtifactCreated(artifactPath, null, builder_util_1.Arch.x64, this.computeSafeArtifactName(artifactName, "pkg", arch, true, this.platformSpecificBuildOptions.defaultArch));
|
||||
}
|
||||
}
|
||||
async adjustSignOptions(signOptions, masOptions) {
|
||||
const resourceList = await this.resourceList;
|
||||
const customSignOptions = masOptions || this.platformSpecificBuildOptions;
|
||||
const entitlementsSuffix = masOptions == null ? "mac" : "mas";
|
||||
let entitlements = customSignOptions.entitlements;
|
||||
if (entitlements == null) {
|
||||
const p = `entitlements.${entitlementsSuffix}.plist`;
|
||||
if (resourceList.includes(p)) {
|
||||
entitlements = path.join(this.info.buildResourcesDir, p);
|
||||
}
|
||||
else {
|
||||
entitlements = pathManager_1.getTemplatePath("entitlements.mac.plist");
|
||||
}
|
||||
}
|
||||
signOptions.entitlements = entitlements;
|
||||
let entitlementsInherit = customSignOptions.entitlementsInherit;
|
||||
if (entitlementsInherit == null) {
|
||||
const p = `entitlements.${entitlementsSuffix}.inherit.plist`;
|
||||
if (resourceList.includes(p)) {
|
||||
entitlementsInherit = path.join(this.info.buildResourcesDir, p);
|
||||
}
|
||||
else {
|
||||
entitlementsInherit = pathManager_1.getTemplatePath("entitlements.mac.plist");
|
||||
}
|
||||
}
|
||||
signOptions["entitlements-inherit"] = entitlementsInherit;
|
||||
if (customSignOptions.provisioningProfile != null) {
|
||||
signOptions["provisioning-profile"] = customSignOptions.provisioningProfile;
|
||||
}
|
||||
signOptions["entitlements-loginhelper"] = customSignOptions.entitlementsLoginHelper;
|
||||
return true;
|
||||
}
|
||||
//noinspection JSMethodCanBeStatic
|
||||
async doSign(opts) {
|
||||
return electron_osx_sign_1.signAsync(opts);
|
||||
async doSign(opts, customSignOptions, identity) {
|
||||
const customSign = await (0, resolve_1.resolveFunction)(this.appInfo.type, customSignOptions.sign, "sign", await this.info.getWorkspaceRoot());
|
||||
const { app, platform, type, provisioningProfile } = opts;
|
||||
builder_util_1.log.info({
|
||||
file: builder_util_1.log.filePath(app),
|
||||
platform,
|
||||
type,
|
||||
identityName: (identity === null || identity === void 0 ? void 0 : identity.name) || "none",
|
||||
identityHash: (identity === null || identity === void 0 ? void 0 : identity.hash) || "none",
|
||||
provisioningProfile: provisioningProfile || "none",
|
||||
}, customSign ? "executing custom sign" : "signing");
|
||||
return customSign ? Promise.resolve(customSign(opts, this)) : (0, macCodeSign_1.sign)({ ...opts, identity: identity ? identity.name : undefined });
|
||||
}
|
||||
//noinspection JSMethodCanBeStatic
|
||||
async doFlat(appPath, outFile, identity, keychain) {
|
||||
const safeAppPath = (0, builder_util_1.sanitizeDirPath)(appPath);
|
||||
const safeOutFile = (0, builder_util_1.sanitizeDirPath)(outFile);
|
||||
// productbuild doesn't created directory for out file
|
||||
await promises_1.mkdir(path.dirname(outFile), { recursive: true });
|
||||
const args = pkg_1.prepareProductBuildArgs(identity, keychain);
|
||||
args.push("--component", appPath, "/Applications");
|
||||
args.push(outFile);
|
||||
return await builder_util_1.exec("productbuild", args);
|
||||
await (0, promises_1.mkdir)(path.dirname(safeOutFile), { recursive: true });
|
||||
const args = (0, pkg_1.prepareProductBuildArgs)(identity, keychain);
|
||||
args.push("--component", safeAppPath, "/Applications");
|
||||
args.push(safeOutFile);
|
||||
return await (0, builder_util_1.exec)("productbuild", args);
|
||||
}
|
||||
getElectronSrcDir(dist) {
|
||||
return path.resolve(this.projectDir, dist, this.info.framework.distMacOsAppName);
|
||||
|
|
@ -333,67 +352,94 @@ class MacPackager extends platformPackager_1.PlatformPackager {
|
|||
}
|
||||
// todo fileAssociations
|
||||
async applyCommonInfo(appPlist, contentsPath) {
|
||||
var _a;
|
||||
const appInfo = this.appInfo;
|
||||
const appFilename = appInfo.productFilename;
|
||||
// https://github.com/electron-userland/electron-builder/issues/1278
|
||||
appPlist.CFBundleExecutable = appFilename.endsWith(" Helper") ? appFilename.substring(0, appFilename.length - " Helper".length) : appFilename;
|
||||
const icon = await this.getIconPath();
|
||||
if (icon != null) {
|
||||
const resourcesPath = path.join(contentsPath, "Resources");
|
||||
// Support both legacy `.icns` and modern `.icon` (Icon Composer) inputs via `mac.icon`.
|
||||
// Prefer `.icon` if provided; still accept `.icns`.
|
||||
const configuredIcon = this.platformSpecificBuildOptions.icon;
|
||||
const isIconComposer = typeof configuredIcon === "string" && configuredIcon.toLowerCase().endsWith(".icon");
|
||||
// Set the app name
|
||||
appPlist.CFBundleName = appInfo.productName;
|
||||
appPlist.CFBundleDisplayName = appInfo.productName;
|
||||
// Bundle legacy `icns` format - this should also run when `.icon` is provided
|
||||
const setIcnsFile = async (iconPath) => {
|
||||
const oldIcon = appPlist.CFBundleIconFile;
|
||||
const resourcesPath = path.join(contentsPath, "Resources");
|
||||
if (oldIcon != null) {
|
||||
await fs_1.unlinkIfExists(path.join(resourcesPath, oldIcon));
|
||||
await (0, builder_util_1.unlinkIfExists)(path.join(resourcesPath, oldIcon));
|
||||
}
|
||||
const iconFileName = "icon.icns";
|
||||
appPlist.CFBundleIconFile = iconFileName;
|
||||
await fs_1.copyFile(icon, path.join(resourcesPath, iconFileName));
|
||||
await (0, builder_util_1.copyFile)(iconPath, path.join(resourcesPath, iconFileName));
|
||||
};
|
||||
const icnsFilePath = await this.getIconPath();
|
||||
if (icnsFilePath != null) {
|
||||
await setIcnsFile(icnsFilePath);
|
||||
}
|
||||
// Bundle new `icon` format
|
||||
if (isIconComposer && configuredIcon) {
|
||||
const iconComposerPath = await this.getResource(configuredIcon);
|
||||
if (iconComposerPath) {
|
||||
const { assetCatalog } = await this.generateAssetCatalogData(iconComposerPath);
|
||||
// Create and setup the asset catalog
|
||||
appPlist.CFBundleIconName = "Icon";
|
||||
await fs.writeFile(path.join(resourcesPath, "Assets.car"), assetCatalog);
|
||||
}
|
||||
}
|
||||
appPlist.CFBundleName = appInfo.productName;
|
||||
appPlist.CFBundleDisplayName = appInfo.productName;
|
||||
const minimumSystemVersion = this.platformSpecificBuildOptions.minimumSystemVersion;
|
||||
if (minimumSystemVersion != null) {
|
||||
appPlist.LSMinimumSystemVersion = minimumSystemVersion;
|
||||
}
|
||||
appPlist.CFBundleIdentifier = appInfo.macBundleIdentifier;
|
||||
appPlist.CFBundleShortVersionString = this.platformSpecificBuildOptions.bundleShortVersion || appInfo.version;
|
||||
appPlist.CFBundleVersion = appInfo.buildVersion;
|
||||
builder_util_1.use(this.platformSpecificBuildOptions.category || this.config.category, it => (appPlist.LSApplicationCategoryType = it));
|
||||
const activeOpts = (_a = this._activePackConfig) !== null && _a !== void 0 ? _a : this.platformSpecificBuildOptions;
|
||||
appPlist.CFBundleShortVersionString = activeOpts.bundleShortVersion || appInfo.version;
|
||||
appPlist.CFBundleVersion = activeOpts.bundleVersion || appInfo.buildVersion;
|
||||
(0, builder_util_1.use)(this.platformSpecificBuildOptions.category || this.config.category, it => (appPlist.LSApplicationCategoryType = it));
|
||||
appPlist.NSHumanReadableCopyright = appInfo.copyright;
|
||||
if (this.platformSpecificBuildOptions.darkModeSupport) {
|
||||
appPlist.NSRequiresAquaSystemAppearance = false;
|
||||
}
|
||||
const extendInfo = this.platformSpecificBuildOptions.extendInfo;
|
||||
if (extendInfo != null) {
|
||||
Object.assign(appPlist, extendInfo);
|
||||
(0, builder_util_1.deepAssign)(appPlist, extendInfo);
|
||||
}
|
||||
for (const [k, v] of Object.entries(appPlist)) {
|
||||
if (v === null || v === undefined) {
|
||||
delete appPlist[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
async signApp(packContext, isAsar) {
|
||||
var _a;
|
||||
const isMas = packContext.electronPlatformName === "mas";
|
||||
const activeConfig = (_a = this._activePackConfig) !== null && _a !== void 0 ? _a : this.platformSpecificBuildOptions;
|
||||
const readDirectoryAndSign = async (sourceDirectory, directories, shouldSign) => {
|
||||
const normalizedSourceDirectory = path.resolve(sourceDirectory);
|
||||
MacTargetHelper_1.MacTargetHelper.assertSafePathForCommandUsage(normalizedSourceDirectory, "application output directory");
|
||||
await Promise.all(directories.map(async (file) => {
|
||||
if (shouldSign(file)) {
|
||||
const entryName = path.basename(file);
|
||||
if (file !== entryName) {
|
||||
throw new builder_util_1.InvalidConfigurationError(`Invalid entry name in source directory: ${file}`);
|
||||
}
|
||||
const signTarget = path.resolve(normalizedSourceDirectory, entryName);
|
||||
const safeSignTarget = (0, builder_util_1.sanitizeDirPath)(signTarget, normalizedSourceDirectory);
|
||||
await this.sign(safeSignTarget, null, isMas ? activeConfig : null, packContext.arch, isMas);
|
||||
}
|
||||
}));
|
||||
return true;
|
||||
};
|
||||
const appFileName = `${this.appInfo.productFilename}.app`;
|
||||
await bluebird_lst_1.default.map(promises_1.readdir(packContext.appOutDir), (file) => {
|
||||
if (file === appFileName) {
|
||||
return this.sign(path.join(packContext.appOutDir, file), null, null, null);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
await readDirectoryAndSign(packContext.appOutDir, await (0, promises_1.readdir)(packContext.appOutDir), file => file === appFileName);
|
||||
if (!isAsar) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
const outResourcesDir = path.join(packContext.appOutDir, "resources", "app.asar.unpacked");
|
||||
await bluebird_lst_1.default.map(promise_1.orIfFileNotExist(promises_1.readdir(outResourcesDir), []), (file) => {
|
||||
if (file.endsWith(".app")) {
|
||||
return this.sign(path.join(outResourcesDir, file), null, null, null);
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
await readDirectoryAndSign(outResourcesDir, await (0, builder_util_1.orIfFileNotExist)((0, promises_1.readdir)(outResourcesDir), []), file => file.endsWith(".app"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
exports.default = MacPackager;
|
||||
function getCertificateTypes(isMas, isDevelopment) {
|
||||
if (isDevelopment) {
|
||||
return isMas ? ["Mac Developer", "Apple Development"] : ["Mac Developer", "Developer ID Application"];
|
||||
}
|
||||
return isMas ? ["Apple Distribution", "3rd Party Mac Developer Application"] : ["Developer ID Application"];
|
||||
}
|
||||
exports.MacPackager = MacPackager;
|
||||
//# sourceMappingURL=macPackager.js.map
|
||||
Loading…
Add table
Add a link
Reference in a new issue