1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-07 09:31:31 +01:00

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

View File

@ -2,6 +2,7 @@ require('dotenv').config();
const path = require('path'); const path = require('path');
const fse = require('fs-extra'); const fse = require('fs-extra');
const { notarize } = require('electron-notarize'); const { notarize } = require('electron-notarize');
const { deepAssign } = require('builder-util');
exports.default = run; exports.default = run;
@ -12,8 +13,9 @@ async function run(context) {
const appName = context.packager.appInfo.productFilename; const appName = context.packager.appInfo.productFilename;
const appPath = `${context.appOutDir}/${appName}.app`; const appPath = `${context.appOutDir}/${appName}.app`;
const macBuild = context.electronPlatformName === 'darwin'; 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 // Copy Safari plugin to work-around https://github.com/electron-userland/electron-builder/issues/5552
const plugIn = path.join(__dirname, '../PlugIns'); const plugIn = path.join(__dirname, '../PlugIns');
if (fse.existsSync(plugIn)) { if (fse.existsSync(plugIn)) {
@ -21,9 +23,23 @@ async function run(context) {
fse.copySync(path.join(plugIn, 'safari.appex'), path.join(appPath, 'Contents/PlugIns/safari.appex')); fse.copySync(path.join(plugIn, 'safari.appex'), path.join(appPath, 'Contents/PlugIns/safari.appex'));
// Resign to sign safari extension // 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); console.log('### Notarizing ' + appPath);
const appleId = process.env.APPLE_ID_USERNAME || process.env.APPLEID; const appleId = process.env.APPLE_ID_USERNAME || process.env.APPLEID;
const appleIdPassword = process.env.APPLE_ID_PASSWORD || `@keychain:AC_PASSWORD`; const appleIdPassword = process.env.APPLE_ID_PASSWORD || `@keychain:AC_PASSWORD`;