1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-28 17:27:50 +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,18 +13,33 @@ 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)) {
fse.mkdirSync(path.join(appPath, 'Contents/PlugIns')); fse.mkdirSync(path.join(appPath, 'Contents/PlugIns'));
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
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); 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`;