From a2e58c0ad4e9124d28e51df0189e635fb4166a4e Mon Sep 17 00:00:00 2001 From: Trevor Feeney Date: Tue, 23 May 2017 21:44:23 +0200 Subject: [PATCH] feat(mac): allow passing through binaries and requirements options Close #1574 --- docs/Options.md | 7 +++- packages/electron-builder/src/macPackager.ts | 11 ++++-- .../src/options/macOptions.ts | 37 +++++++++++++------ 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/docs/Options.md b/docs/Options.md index c6420e7af1f..5e43eebfc4a 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -441,7 +441,7 @@ macOS Options ([mac](#Config-mac)). | Name | Type | Description | | --- | --- | --- | | category| string \| null | The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory.

For example, `"category": "public.app-category.developer-tools"` will set the application category to *Developer Tools*.

Valid values are listed in [Apple's documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8). | -| target| Array<[TargetConfig](electron-builder-core#TargetConfig) \| "default" \| "dmg" \| "mas" \| "pkg" \| "7z" \| "zip" \| "tar.xz" \| "tar.lz" \| "tar.gz" \| "tar.bz2" \| "dir"> \| "default" \| "dmg" \| "mas" \| "pkg" \| "7z" \| "zip" \| "tar.xz" \| "tar.lz" \| "tar.gz" \| "tar.bz2" \| "dir" \| [TargetConfig](electron-builder-core#TargetConfig) \| null | The target package type: list of `default`, `dmg`, `mas`, `pkg`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `default` (dmg and zip for Squirrel.Mac). | +| target| Array<[TargetConfig](electron-builder-core#TargetConfig) \| "default" \| "dmg" \| "mas" \| "mas-dev" \| "pkg" \| "7z" \| "zip" \| "tar.xz" \| "tar.lz" \| "tar.gz" \| "tar.bz2" \| "dir"> \| "default" \| "dmg" \| "mas" \| "mas-dev" \| "pkg" \| "7z" \| "zip" \| "tar.xz" \| "tar.lz" \| "tar.gz" \| "tar.bz2" \| "dir" \| [TargetConfig](electron-builder-core#TargetConfig) \| null | The target package type: list of `default`, `dmg`, `mas`, `pkg`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `default` (dmg and zip for Squirrel.Mac). | | identity| string \| null | The name of certificate to use when signing. Consider using environment variables [CSC_LINK or CSC_NAME](https://github.com/electron-userland/electron-builder/wiki/Code-Signing) instead of specifying this option. MAS installer identity is specified in the [mas](#MasBuildOptions-identity). | | icon = "build/icon.icns"| string \| null | The path to application icon. | | entitlements| string \| null | The path to entitlements file for signing the app. `build/entitlements.mac.plist` will be used if exists (it is a recommended way to set). MAS entitlements is specified in the [mas](#MasBuildOptions-entitlements). | @@ -450,6 +450,8 @@ macOS Options ([mac](#Config-mac)). | helperBundleId = "${appBundleIdentifier}.helper"| string \| null | The bundle identifier to use in the application helper's plist. | | type = distribution| "distribution" \| "development" \| null | Whether to sign app for development or for distribution. | | extendInfo| any | The extra entries for `Info.plist`. | +| binaries| Array<string> \| null | Paths of any extra binaries that need to be signed. | +| requirements| string \| null | Path of [requirements file](https://developer.apple.com/library/mac/documentation/Security/Conceptual/CodeSigningGuide/RequirementLang/RequirementLang.html) used in signing. Not applicable for MAS. | @@ -464,6 +466,7 @@ MAS (Mac Application Store) Options ([mas](#Config-mas)). | --- | --- | --- | | entitlements| string \| null | The path to entitlements file for signing the app. `build/entitlements.mas.plist` will be used if exists (it is a recommended way to set). Otherwise [default](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.mas.plist). | | entitlementsInherit| string \| null | The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. `build/entitlements.mas.inherit.plist` will be used if exists (it is a recommended way to set). Otherwise [default](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.mas.inherit.plist). | +| binaries| Array<string> \| null | Paths of any extra binaries that need to be signed. | @@ -603,8 +606,10 @@ Portable Specific Options ([portable](#Config-portable)). | summary| string \| null | The 78 character long summary. Defaults to [productName](#AppMetadata-productName). | | grade = stable| "devel" \| "stable" \| null | The quality grade of the snap. It can be either `devel` (i.e. a development version of the snap, so not to be published to the “stable” or “candidate” channels) or “stable” (i.e. a stable release or release candidate, which can be released to all channels). | | assumes| Array<string> \| null | The list of features that must be supported by the core in order for this snap to install. | +| buildPackages| Array<string> \| null | The list of debian packages needs to be installed for building this snap. | | stagePackages| Array<string> \| null | The list of Ubuntu packages to use that are needed to support the `app` part creation. Like `depends` for `deb`. Defaults to `["libnotify4", "libappindicator1", "libxtst6", "libnss3", "libxss1", "fontconfig-config", "gconf2", "libasound2", "pulseaudio"]`.

If list contains `default`, it will be replaced to default list, so, `["default", "foo"]` can be used to add custom package `foo` in addition to defaults. | | plugs| Array<string> \| null | The list of [plugs](https://snapcraft.io/docs/reference/interfaces). Defaults to `["home", "x11", "unity7", "browser-support", "network", "gsettings", "pulseaudio", "opengl"]`.

If list contains `default`, it will be replaced to default list, so, `["default", "foo"]` can be used to add custom plug `foo` in addition to defaults. | +| after| Array<string> \| null | Specifies any [parts](https://snapcraft.io/docs/reference/parts) that should be built before this part. Defaults to `["desktop-only""]`.

If list contains `default`, it will be replaced to default list, so, `["default", "foo"]` can be used to add custom parts `foo` in addition to defaults. | | ubuntuAppPlatformContent| string \| null | Specify `ubuntu-app-platform1` to use [ubuntu-app-platform](https://insights.ubuntu.com/2016/11/17/how-to-create-snap-packages-on-qt-applications/). Snap size will be greatly reduced, but it is not recommended for now because "the snaps must be connected before running uitk-gallery for the first time". | diff --git a/packages/electron-builder/src/macPackager.ts b/packages/electron-builder/src/macPackager.ts index 9728b7a691c..0f9c4af7476 100644 --- a/packages/electron-builder/src/macPackager.ts +++ b/packages/electron-builder/src/macPackager.ts @@ -134,7 +134,8 @@ export default class MacPackager extends PlatformPackager { const keychainName = (await this.codeSigningInfo).keychainName const isMas = masOptions != null - const qualifier = this.platformSpecificBuildOptions.identity + const macOptions = this.platformSpecificBuildOptions + const qualifier = macOptions.identity if (!isMas && qualifier === null) { if (this.forceCodeSigning) { @@ -146,7 +147,7 @@ export default class MacPackager extends PlatformPackager { const masQualifier = isMas ? (masOptions!!.identity || qualifier) : null - const explicitType = masOptions == null ? this.platformSpecificBuildOptions.type : masOptions.type + const explicitType = masOptions == null ? macOptions.type : masOptions.type const type = explicitType || "distribution" const isDevelopment = type === "development" let name = await findIdentity(isDevelopment ? "Mac Developer" : (isMas ? "3rd Party Mac Developer Application" : "Developer ID Application"), isMas ? masQualifier : qualifier, keychainName) @@ -183,6 +184,8 @@ export default class MacPackager extends PlatformPackager { version: this.info.electronVersion, app: appPath, keychain: keychainName || undefined, + binaries: (isMas && masOptions != null ? masOptions.binaries : macOptions.binaries) || undefined, + requirements: isMas || macOptions.requirements == null ? undefined : await this.getResource(macOptions.requirements), "gatekeeper-assess": appleCertificatePrefixes.find(it => name!.startsWith(it)) != null } @@ -194,7 +197,7 @@ export default class MacPackager extends PlatformPackager { throw new Error("entitlements.osx.inherit.plist is deprecated name, please use entitlements.mac.inherit.plist") } - const customSignOptions = masOptions || this.platformSpecificBuildOptions + const customSignOptions = masOptions || macOptions if (customSignOptions.entitlements == null) { const p = `entitlements.${isMas ? "mas" : "mac"}.plist` if (resourceList.includes(p)) { @@ -253,4 +256,4 @@ export default class MacPackager extends PlatformPackager { public getElectronDestDir(appOutDir: string) { return path.join(appOutDir, this.electronDistMacOsAppName) } -} \ No newline at end of file +} diff --git a/packages/electron-builder/src/options/macOptions.ts b/packages/electron-builder/src/options/macOptions.ts index d20ccbdb51f..0775250b489 100644 --- a/packages/electron-builder/src/options/macOptions.ts +++ b/packages/electron-builder/src/options/macOptions.ts @@ -1,6 +1,6 @@ import { PlatformSpecificBuildOptions, TargetConfig, TargetSpecificOptions } from "electron-builder-core" -export type MacOsTargetName = "default" | "dmg" | "mas" | "pkg" | "7z" | "zip" | "tar.xz" | "tar.lz" | "tar.gz" | "tar.bz2" | "dir" +export type MacOsTargetName = "default" | "dmg" | "mas" | "mas-dev" | "pkg" | "7z" | "zip" | "tar.xz" | "tar.lz" | "tar.gz" | "tar.bz2" | "dir" /** * macOS Options ([mac](#Config-mac)). @@ -8,9 +8,9 @@ export type MacOsTargetName = "default" | "dmg" | "mas" | "pkg" | "7z" | "zip" | export interface MacOptions extends PlatformSpecificBuildOptions { /** * The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory. - * + * * For example, `"category": "public.app-category.developer-tools"` will set the application category to *Developer Tools*. - * + * * Valid values are listed in [Apple's documentation](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8). */ readonly category?: string | null @@ -41,7 +41,7 @@ export interface MacOptions extends PlatformSpecificBuildOptions { /** * The path to child entitlements which inherit the security settings for signing frameworks and bundles of a distribution. `build/entitlements.mac.inherit.plist` will be used if exists (it is a recommended way to set). * Otherwise [default](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.darwin.inherit.plist). - * + * * This option only applies when signing with `entitlements` provided. */ readonly entitlementsInherit?: string | null @@ -67,6 +67,16 @@ export interface MacOptions extends PlatformSpecificBuildOptions { * The extra entries for `Info.plist`. */ readonly extendInfo?: any + + /** + * Paths of any extra binaries that need to be signed. + */ + readonly binaries?: Array | null + + /** + * Path of [requirements file](https://developer.apple.com/library/mac/documentation/Security/Conceptual/CodeSigningGuide/RequirementLang/RequirementLang.html) used in signing. Not applicable for MAS. + */ + readonly requirements?: string | null } /** @@ -136,7 +146,7 @@ export interface DmgOptions extends TargetSpecificOptions { /** * The title of the produced DMG, which will be shown when mounted (volume name). - * + * * Macro `${productName}`, `${version}` and `${name}` are supported. * @default ${productName} ${version} */ @@ -168,18 +178,18 @@ export interface DmgWindow { * @default 400 */ x?: number - + /** * The Y position relative to top of the screen. * @default 100 */ y?: number - + /** * The width. Defaults to background image width or 540. */ width?: number - + /** * The height. Defaults to background image height or 380. */ @@ -190,12 +200,12 @@ export interface DmgContent { x: number y: number type?: "link" | "file" - + /** * The name of the file within the DMG. Defaults to basename of `path`. */ name?: string - + path?: string } @@ -214,4 +224,9 @@ export interface MasBuildOptions extends MacOptions { * Otherwise [default](https://github.com/electron-userland/electron-osx-sign/blob/master/default.entitlements.mas.inherit.plist). */ readonly entitlementsInherit?: string | null -} \ No newline at end of file + + /** + * Paths of any extra binaries that need to be signed. + */ + readonly binaries?: Array | null +}