Skip to content
This repository has been archived by the owner on Jul 23, 2022. It is now read-only.

Commit

Permalink
Ensure safari extension is included in mas and not only darwin (#1128)
Browse files Browse the repository at this point in the history
* Ensure safari extension is included in mas and not only darwin

* Add support for re-signing mas

* Add support for mas-dev

(cherry picked from commit 05470b4)
  • Loading branch information
Hinton authored and vgrassia committed Oct 29, 2021
1 parent 32836fc commit 7cd97bb
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions scripts/after-sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
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`;
Expand Down

0 comments on commit 7cd97bb

Please sign in to comment.