electron-packager
Advanced tools
Comparing version 15.3.0 to 15.4.0
15
NEWS.md
@@ -5,4 +5,17 @@ # Electron Packager: Changes by Version | ||
[Unreleased]: https://github.com/electron/electron-packager/compare/v15.3.0...main | ||
[Unreleased]: https://github.com/electron/electron-packager/compare/v15.4.0...main | ||
## [15.4.0] - 2021-09-10 | ||
[15.4.0]: https://github.com/electron/electron-packager/compare/v15.3.0...v15.4.0 | ||
### Added | ||
* `extendHelperInfo` option to allow extending helper app `Info.plist` files (#1233) | ||
* Automatically insert `ElectronAsarIntegrity` into `Info.plist` files (#1279) | ||
### Fixed | ||
* Compatibility with `electron-notarize@^1.1.0` (#1278) | ||
## [15.3.0] - 2021-07-17 | ||
@@ -9,0 +22,0 @@ |
{ | ||
"name": "electron-packager", | ||
"version": "15.3.0", | ||
"version": "15.4.0", | ||
"description": "Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI", | ||
@@ -30,6 +30,6 @@ "main": "src/index.js", | ||
"@electron/get": "^1.6.0", | ||
"asar": "^3.0.0", | ||
"asar": "^3.1.0", | ||
"cross-spawn-windows-exe": "^1.2.0", | ||
"debug": "^4.0.1", | ||
"electron-notarize": "^1.0.0", | ||
"electron-notarize": "^1.1.1", | ||
"electron-osx-sign": "^0.5.0", | ||
@@ -36,0 +36,0 @@ "extract-zip": "^2.0.0", |
@@ -13,5 +13,11 @@ // Originally based on the type definitions for electron-packager 14.0 | ||
import { ElectronDownloadRequestOptions as ElectronDownloadOptions } from '@electron/get'; | ||
import { NotarizeCredentials, TransporterOptions as NotarizeTransporterOptions } from 'electron-notarize'; | ||
import { | ||
LegacyNotarizeCredentials, | ||
NotaryToolCredentials, | ||
TransporterOptions | ||
} from 'electron-notarize/lib/types'; | ||
import { SignOptions } from 'electron-osx-sign'; | ||
type NotarizeLegacyOptions = LegacyNotarizeCredentials & TransporterOptions; | ||
/** | ||
@@ -122,3 +128,5 @@ * Bundles Electron-based application source code with a renamed/customized Electron executable and | ||
*/ | ||
type OsxNotarizeOptions = NotarizeCredentials & NotarizeTransporterOptions; | ||
type OsxNotarizeOptions = | ||
| ({ tool?: 'legacy' } & NotarizeLegacyOptions) | ||
| ({ tool: 'notarytool' } & NotaryToolCredentials); | ||
@@ -339,2 +347,15 @@ /** | ||
/** | ||
* When the value is a string, specifies the filename of a `plist` file. Its contents are merged | ||
* into all the Helper apps' `Info.plist` files. | ||
* When the value is an `Object`, it specifies an already-parsed `plist` data structure that is | ||
* merged into all the Helper apps' `Info.plist` files. | ||
* | ||
* Entries from `extendHelperInfo` override entries in the helper apps' `Info.plist` file supplied by | ||
* `electron`, `electron-prebuilt-compile`, or `electron-prebuilt`, but are overridden by other | ||
* options such as [[appVersion]] or [[appBundleId]]. | ||
* | ||
* @category macOS | ||
*/ | ||
extendHelperInfo?: string | { [property: string]: any }; // eslint-disable-line @typescript-eslint/no-explicit-any | ||
/** | ||
* One or more files to be copied directly into the app's `Contents/Resources` directory for | ||
@@ -341,0 +362,0 @@ * macOS target platforms, and the `resources` directory for other target platforms. The |
@@ -9,3 +9,3 @@ 'use strict' | ||
const plist = require('plist') | ||
const { notarize, validateAuthorizationArgs } = require('electron-notarize') | ||
const { notarize } = require('electron-notarize') | ||
const { signAsync } = require('electron-osx-sign') | ||
@@ -109,4 +109,4 @@ | ||
updatePlist (base, displayName, identifier, name) { | ||
return Object.assign(base, { | ||
updatePlist (basePlist, displayName, identifier, name) { | ||
return Object.assign(basePlist, { | ||
CFBundleDisplayName: displayName, | ||
@@ -119,3 +119,3 @@ CFBundleExecutable: common.sanitizeAppName(displayName), | ||
updateHelperPlist (base, suffix, identifierIgnoresSuffix) { | ||
updateHelperPlist (basePlist, suffix, identifierIgnoresSuffix) { | ||
let helperSuffix, identifier, name | ||
@@ -135,6 +135,6 @@ if (suffix) { | ||
} | ||
return this.updatePlist(base, `${this.appName} ${helperSuffix}`, identifier, name) | ||
return this.updatePlist(basePlist, `${this.appName} ${helperSuffix}`, identifier, name) | ||
} | ||
async extendAppPlist (propsOrFilename) { | ||
async extendPlist (basePlist, propsOrFilename) { | ||
if (!propsOrFilename) { | ||
@@ -146,5 +146,5 @@ return Promise.resolve() | ||
const plist = await this.loadPlist(propsOrFilename) | ||
return Object.assign(this.appPlist, plist) | ||
return Object.assign(basePlist, plist) | ||
} else { | ||
return Object.assign(this.appPlist, propsOrFilename) | ||
return Object.assign(basePlist, propsOrFilename) | ||
} | ||
@@ -191,2 +191,6 @@ } | ||
appRelativePath (p) { | ||
return path.relative(this.contentsPath, p) | ||
} | ||
async updatePlistFiles () { | ||
@@ -198,5 +202,10 @@ const appBundleIdentifier = this.bundleName | ||
await Promise.all(plists.map(plistArgs => this.loadPlist(...plistArgs))) | ||
await this.extendAppPlist(this.opts.extendInfo) | ||
await this.extendPlist(this.appPlist, this.opts.extendInfo) | ||
if (this.asarIntegrity) { | ||
await this.extendPlist(this.appPlist, { | ||
ElectronAsarIntegrity: this.asarIntegrity | ||
}) | ||
} | ||
this.appPlist = this.updatePlist(this.appPlist, this.executableName, appBundleIdentifier, this.appName) | ||
this.helperPlist = this.updateHelperPlist(this.helperPlist) | ||
const updateIfExists = [ | ||
@@ -209,2 +218,9 @@ ['helperRendererPlist', '(Renderer)', true], | ||
] | ||
for (const [plistKey] of [...updateIfExists, ['helperPlist']]) { | ||
if (!this[plistKey]) continue | ||
await this.extendPlist(this[plistKey], this.opts.extendHelperInfo) | ||
} | ||
this.helperPlist = this.updateHelperPlist(this.helperPlist) | ||
for (const [plistKey, ...suffixArgs] of updateIfExists) { | ||
@@ -215,2 +231,8 @@ if (!this[plistKey]) continue | ||
// Some properties need to go on all helpers as well, version, usage info, etc. | ||
const plistsToUpdate = updateIfExists | ||
.filter(([key]) => !!this[key]) | ||
.map(([key]) => key) | ||
.concat(['appPlist', 'helperPlist']) | ||
if (this.loginHelperPlist) { | ||
@@ -224,7 +246,13 @@ const loginHelperName = common.sanitizeAppName(`${this.appName} Login Helper`) | ||
if (this.appVersion) { | ||
this.appPlist.CFBundleShortVersionString = this.appPlist.CFBundleVersion = '' + this.appVersion | ||
const appVersionString = '' + this.appVersion | ||
for (const plistKey of plistsToUpdate) { | ||
this[plistKey].CFBundleShortVersionString = this[plistKey].CFBundleVersion = appVersionString | ||
} | ||
} | ||
if (this.buildVersion) { | ||
this.appPlist.CFBundleVersion = '' + this.buildVersion | ||
const buildVersionString = '' + this.buildVersion | ||
for (const plistKey of plistsToUpdate) { | ||
this[plistKey].CFBundleVersion = buildVersionString | ||
} | ||
} | ||
@@ -250,3 +278,7 @@ | ||
for (const [type, description] of Object.entries(this.usageDescription)) { | ||
this.appPlist[`NS${type}UsageDescription`] = description | ||
const usageTypeKey = `NS${type}UsageDescription` | ||
for (const plistKey of plistsToUpdate) { | ||
this[plistKey][usageTypeKey] = description | ||
} | ||
this.appPlist[usageTypeKey] = description | ||
} | ||
@@ -408,13 +440,8 @@ } | ||
function createNotarizeOpts (properties, appBundleId, appPath, quiet) { | ||
try { | ||
validateAuthorizationArgs(properties) | ||
} catch (e) { | ||
common.warning(`Failed validation, notarization will not run: ${e.message}`) | ||
return | ||
} | ||
// osxNotarize options are handed off to the electron-notarize module, but with a few | ||
// additions from the main options. The user may think they can pass bundle ID or appPath, | ||
// but they will be ignored. | ||
common.subOptionWarning(properties, 'osxNotarize', 'appBundleId', appBundleId, quiet) | ||
if (properties.tool !== 'notarytool') { | ||
common.subOptionWarning(properties, 'osxNotarize', 'appBundleId', appBundleId, quiet) | ||
} | ||
common.subOptionWarning(properties, 'osxNotarize', 'appPath', appPath, quiet) | ||
@@ -421,0 +448,0 @@ return properties |
'use strict' | ||
const asar = require('asar') | ||
const crypto = require('crypto') | ||
const debug = require('debug')('electron-packager') | ||
@@ -194,2 +195,6 @@ const fs = require('fs-extra') | ||
appRelativePath (p) { | ||
return path.relative(this.stagingPath, p) | ||
} | ||
async asarApp () { | ||
@@ -202,2 +207,9 @@ if (!this.asarOptions) { | ||
await asar.createPackageWithOptions(this.originalResourcesAppDir, this.appAsarPath, this.asarOptions) | ||
const { headerString } = asar.getRawHeader(this.appAsarPath) | ||
this.asarIntegrity = { | ||
[this.appRelativePath(this.appAsarPath)]: { | ||
algorithm: 'SHA256', | ||
hash: crypto.createHash('SHA256').update(headerString).digest('hex') | ||
} | ||
} | ||
await fs.remove(this.originalResourcesAppDir) | ||
@@ -204,0 +216,0 @@ } |
133385
2114
Updatedasar@^3.1.0
Updatedelectron-notarize@^1.1.1