Skip to content

Commit

Permalink
feat(mac): allow passing through binaries and requirements options
Browse files Browse the repository at this point in the history
  • Loading branch information
feens authored and develar committed May 23, 2017
1 parent 94d89eb commit a2e58c0
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
7 changes: 6 additions & 1 deletion docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ macOS Options ([mac](#Config-mac)).
| Name | Type | Description |
| --- | --- | --- |
| category| <code>string</code> \| <code>null</code> | <a name="MacOptions-category"></a>The application category type, as shown in the Finder via *View -> Arrange by Application Category* when viewing the Applications directory.<br><br>For example, `"category": "public.app-category.developer-tools"` will set the application category to *Developer Tools*.<br><br>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| <code>Array&lt;[TargetConfig](electron-builder-core#TargetConfig) \| "default" \| "dmg" \| "mas" \| "pkg" \| "7z" \| "zip" \| "tar.xz" \| "tar.lz" \| "tar.gz" \| "tar.bz2" \| "dir"&gt;</code> \| <code>"default"</code> \| <code>"dmg"</code> \| <code>"mas"</code> \| <code>"pkg"</code> \| <code>"7z"</code> \| <code>"zip"</code> \| <code>"tar.xz"</code> \| <code>"tar.lz"</code> \| <code>"tar.gz"</code> \| <code>"tar.bz2"</code> \| <code>"dir"</code> \| <code>[TargetConfig](electron-builder-core#TargetConfig)</code> \| <code>null</code> | <a name="MacOptions-target"></a>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| <code>Array&lt;[TargetConfig](electron-builder-core#TargetConfig) \| "default" \| "dmg" \| "mas" \| "mas-dev" \| "pkg" \| "7z" \| "zip" \| "tar.xz" \| "tar.lz" \| "tar.gz" \| "tar.bz2" \| "dir"&gt;</code> \| <code>"default"</code> \| <code>"dmg"</code> \| <code>"mas"</code> \| <code>"mas-dev"</code> \| <code>"pkg"</code> \| <code>"7z"</code> \| <code>"zip"</code> \| <code>"tar.xz"</code> \| <code>"tar.lz"</code> \| <code>"tar.gz"</code> \| <code>"tar.bz2"</code> \| <code>"dir"</code> \| <code>[TargetConfig](electron-builder-core#TargetConfig)</code> \| <code>null</code> | <a name="MacOptions-target"></a>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| <code>string</code> \| <code>null</code> | <a name="MacOptions-identity"></a>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 = <code>&quot;build/icon.icns&quot;</code>| <code>string</code> \| <code>null</code> | <a name="MacOptions-icon"></a>The path to application icon. |
| entitlements| <code>string</code> \| <code>null</code> | <a name="MacOptions-entitlements"></a>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). |
Expand All @@ -450,6 +450,8 @@ macOS Options ([mac](#Config-mac)).
| helperBundleId = <code>&quot;${appBundleIdentifier}.helper&quot;</code>| <code>string</code> \| <code>null</code> | <a name="MacOptions-helperBundleId"></a>The bundle identifier to use in the application helper's plist. |
| type = <code>distribution</code>| <code>"distribution"</code> \| <code>"development"</code> \| <code>null</code> | <a name="MacOptions-type"></a>Whether to sign app for development or for distribution. |
| extendInfo| <code>any</code> | <a name="MacOptions-extendInfo"></a>The extra entries for `Info.plist`. |
| binaries| <code>Array&lt;string&gt;</code> \| <code>null</code> | <a name="MacOptions-binaries"></a>Paths of any extra binaries that need to be signed. |
| requirements| <code>string</code> \| <code>null</code> | <a name="MacOptions-requirements"></a>Path of [requirements file](https://developer.apple.com/library/mac/documentation/Security/Conceptual/CodeSigningGuide/RequirementLang/RequirementLang.html) used in signing. Not applicable for MAS. |

<a name="MasBuildOptions"></a>

Expand All @@ -464,6 +466,7 @@ MAS (Mac Application Store) Options ([mas](#Config-mas)).
| --- | --- | --- |
| entitlements| <code>string</code> \| <code>null</code> | <a name="MasBuildOptions-entitlements"></a>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| <code>string</code> \| <code>null</code> | <a name="MasBuildOptions-entitlementsInherit"></a>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| <code>Array&lt;string&gt;</code> \| <code>null</code> | <a name="MasBuildOptions-binaries"></a>Paths of any extra binaries that need to be signed. |

<a name="Metadata"></a>

Expand Down Expand Up @@ -603,8 +606,10 @@ Portable Specific Options ([portable](#Config-portable)).
| summary| <code>string</code> \| <code>null</code> | <a name="SnapOptions-summary"></a>The 78 character long summary. Defaults to [productName](#AppMetadata-productName). |
| grade = <code>stable</code>| <code>"devel"</code> \| <code>"stable"</code> \| <code>null</code> | <a name="SnapOptions-grade"></a>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| <code>Array&lt;string&gt;</code> \| <code>null</code> | <a name="SnapOptions-assumes"></a>The list of features that must be supported by the core in order for this snap to install. |
| buildPackages| <code>Array&lt;string&gt;</code> \| <code>null</code> | <a name="SnapOptions-buildPackages"></a>The list of debian packages needs to be installed for building this snap. |
| stagePackages| <code>Array&lt;string&gt;</code> \| <code>null</code> | <a name="SnapOptions-stagePackages"></a>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"]`.<br><br>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| <code>Array&lt;string&gt;</code> \| <code>null</code> | <a name="SnapOptions-plugs"></a>The list of [plugs](https://snapcraft.io/docs/reference/interfaces). Defaults to `["home", "x11", "unity7", "browser-support", "network", "gsettings", "pulseaudio", "opengl"]`.<br><br>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| <code>Array&lt;string&gt;</code> \| <code>null</code> | <a name="SnapOptions-after"></a>Specifies any [parts](https://snapcraft.io/docs/reference/parts) that should be built before this part. Defaults to `["desktop-only""]`.<br><br>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| <code>string</code> \| <code>null</code> | <a name="SnapOptions-ubuntuAppPlatformContent"></a>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". |

<a name="SquirrelWindowsOptions"></a>
Expand Down
11 changes: 7 additions & 4 deletions packages/electron-builder/src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ export default class MacPackager extends PlatformPackager<MacOptions> {

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) {
Expand All @@ -146,7 +147,7 @@ export default class MacPackager extends PlatformPackager<MacOptions> {

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)
Expand Down Expand Up @@ -183,6 +184,8 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
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
}

Expand All @@ -194,7 +197,7 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
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)) {
Expand Down Expand Up @@ -253,4 +256,4 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
public getElectronDestDir(appOutDir: string) {
return path.join(appOutDir, this.electronDistMacOsAppName)
}
}
}
37 changes: 26 additions & 11 deletions packages/electron-builder/src/options/macOptions.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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)).
*/
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
Expand Down Expand Up @@ -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
Expand All @@ -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<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.
*/
readonly requirements?: string | null
}

/**
Expand Down Expand Up @@ -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}
*/
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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
}

Expand All @@ -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
}

/**
* Paths of any extra binaries that need to be signed.
*/
readonly binaries?: Array<string> | null
}

0 comments on commit a2e58c0

Please sign in to comment.