insomnia/packages/insomnia-app/scripts/afterSignHook.js

49 lines
1.4 KiB
JavaScript
Raw Normal View History

// TODO(TSCONVERSION) not entirely sure if this can be in TypeScript or not. If so, need to convert.
2019-10-08 23:31:32 +00:00
const fs = require('fs');
const path = require('path');
const electronNotarize = require('electron-notarize');
const appConfig = require('../config/config.json');
2019-10-08 23:31:32 +00:00
// See: https://medium.com/@TwitterArchiveEraser/notarize-electron-apps-7a5f988406db
module.exports = async function(params) {
// Only notarize the app on Mac OS only.
if (process.platform !== 'darwin') {
return;
}
// Same appId in electron-builder.
2020-04-26 20:33:39 +00:00
const { appId } = appConfig;
2019-10-08 23:31:32 +00:00
2019-10-10 18:34:43 +00:00
const appName = `${params.packager.appInfo.productFilename}.app`;
const appPath = path.join(params.appOutDir, appName);
2019-10-08 23:31:32 +00:00
if (!fs.existsSync(appPath)) {
2019-10-10 18:34:43 +00:00
throw new Error(`Cannot find application at: ${appName}`);
2019-10-08 23:31:32 +00:00
}
2019-10-30 14:24:32 +00:00
if (!process.env.APPLE_ID) {
console.log('[aftersign] APPLE_ID env variable not set. Skipping notarization');
return;
}
if (!process.env.APPLE_ID_PASSWORD) {
console.log('[aftersign] APPLE_ID env variable not set. Skipping notarization');
return;
}
const args = {
appBundleId: appId,
appPath: appPath,
appleId: process.env.APPLE_ID,
appleIdPassword: process.env.APPLE_ID_PASSWORD,
};
2019-10-30 14:24:32 +00:00
console.log(`[afterSign] Notarizing ${appName} (${appId})`);
2019-10-08 23:31:32 +00:00
try {
await electronNotarize.notarize(args);
} catch (err) {
console.error(err);
process.exit(1);
2019-10-08 23:31:32 +00:00
}
};