Ensure safari extension is included in mas and not only darwin (#1128)

* Ensure safari extension is included in mas and not only darwin

* Add support for re-signing mas

* Add support for mas-dev
This commit is contained in:
Oscar Hinton 2021-10-29 15:48:43 +02:00 committed by GitHub
parent 59bed9b12e
commit 05470b489c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 5 deletions

View File

@ -2,6 +2,7 @@ require('dotenv').config();
const path = require('path');
const fse = require('fs-extra');
const { notarize } = require('electron-notarize');
const { deepAssign } = require('builder-util');
exports.default = run;
@ -12,18 +13,33 @@ async function run(context) {
const appName = context.packager.appInfo.productFilename;
const appPath = `${context.appOutDir}/${appName}.app`;
const macBuild = context.electronPlatformName === 'darwin';
const copyPlugIn = ['darwin', 'mas'].includes(context.electronPlatformName);
if (macBuild) {
if (copyPlugIn) {
// Copy Safari plugin to work-around https://github.com/electron-userland/electron-builder/issues/5552
const plugIn = path.join(__dirname, '../PlugIns');
if (fse.existsSync(plugIn)) {
fse.mkdirSync(path.join(appPath, 'Contents/PlugIns'));
fse.copySync(path.join(plugIn, 'safari.appex'), path.join(appPath, 'Contents/PlugIns/safari.appex'));
// Resign to sign safari extension
await context.packager.signApp(context, true);
}
// Resign to sign safari extension
if (context.electronPlatformName === 'mas') {
const masBuildOptions = deepAssign({}, context.packager.platformSpecificBuildOptions, context.packager.config.mas);
if (context.targets.some(e => e.name === 'mas-dev')) {
deepAssign(masBuildOptions, {
type: 'development',
});
}
if (context.packager.packagerOptions.prepackaged == null) {
await context.packager.sign(appPath, context.appOutDir, masBuildOptions, context.arch);
}
} else {
await context.packager.signApp(context, true);
}
}
}
if (macBuild) {
console.log('### Notarizing ' + appPath);
const appleId = process.env.APPLE_ID_USERNAME || process.env.APPLEID;
const appleIdPassword = process.env.APPLE_ID_PASSWORD || `@keychain:AC_PASSWORD`;