From 05470b489c708e61d5e96e2a299770589dbe58d3 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 29 Oct 2021 15:48:43 +0200 Subject: [PATCH] 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 --- scripts/after-sign.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/scripts/after-sign.js b/scripts/after-sign.js index b5c389793c..92feb96219 100644 --- a/scripts/after-sign.js +++ b/scripts/after-sign.js @@ -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`;