Skip to content

Commit

Permalink
perf(mas): flat on electron-builder side
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Nov 6, 2016
1 parent 9d31b42 commit adacf1e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/develar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 15 additions & 18 deletions src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import BluebirdPromise from "bluebird-lst-c"
import { log, warn, task } from "./util/log"
import { createKeychain, CodeSigningInfo, findIdentity } from "./codeSign"
import { deepAssign } from "./util/deepAssign"
import { signAsync, flatAsync, BaseSignOptions, SignOptions, FlatOptions } from "electron-osx-sign-tf"
import { signAsync, BaseSignOptions, SignOptions } from "electron-osx-sign-tf"
import { DmgTarget } from "./targets/dmg"
import { createCommonTarget, DEFAULT_TARGET } from "./targets/targetFactory"
import { AppInfo } from "./appInfo"
import { flatApplication } from "./targets/pkg"

export default class MacPackager extends PlatformPackager<MacOptions> {
codeSigningInfo: Promise<CodeSigningInfo>
Expand Down Expand Up @@ -133,13 +134,13 @@ export default class MacPackager extends PlatformPackager<MacOptions> {

const baseSignOptions: BaseSignOptions = {
app: path.join(appOutDir, `${this.appInfo.productFilename}.app`),
platform: isMas ? "mas" : "darwin",
keychain: keychainName || undefined,
version: this.info.electronVersion
}

const signOptions = Object.assign({
identity: name,
platform: isMas ? "mas" : "darwin",
version: this.info.electronVersion,
}, (<any>this.devMetadata.build)["osx-sign"], baseSignOptions)

const resourceList = await this.resourceList
Expand All @@ -151,35 +152,31 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
}

const customSignOptions = masOptions || this.platformSpecificBuildOptions
if (customSignOptions.entitlements != null) {
signOptions.entitlements = customSignOptions.entitlements
}
else {
if (customSignOptions.entitlements == null) {
const p = `entitlements.${isMas ? "mas" : "mac"}.plist`
if (resourceList.includes(p)) {
signOptions.entitlements = path.join(this.buildResourcesDir, p)
}
}

if (customSignOptions.entitlementsInherit != null) {
signOptions["entitlements-inherit"] = customSignOptions.entitlementsInherit
}
else {
signOptions.entitlements = customSignOptions.entitlements
}

if (customSignOptions.entitlementsInherit == null) {
const p = `entitlements.${isMas ? "mas" : "mac"}.inherit.plist`
if (resourceList.includes(p)) {
signOptions["entitlements-inherit"] = path.join(this.buildResourcesDir, p)
}
}
else {
signOptions["entitlements-inherit"] = customSignOptions.entitlementsInherit
}

await task(`Signing app (identity: ${name})`, this.doSign(signOptions))

if (masOptions != null) {
await task(`Signing app (identity: ${name})`, this.doSign(signOptions))
const pkg = path.join(appOutDir, `${this.appInfo.productFilename}-${this.appInfo.version}.pkg`)
await this.doFlat(Object.assign({
pkg: pkg,
identity: installerName,
}, baseSignOptions))
await this.doFlat(baseSignOptions, pkg, installerName!!)
this.dispatchArtifactCreated(pkg, `${this.appInfo.name}-${this.appInfo.version}.pkg`)
}
}
Expand All @@ -190,8 +187,8 @@ export default class MacPackager extends PlatformPackager<MacOptions> {
}

//noinspection JSMethodCanBeStatic
protected async doFlat(opts: FlatOptions): Promise<any> {
return flatAsync(opts)
protected async doFlat(opts: BaseSignOptions, outFile: string, identity: string): Promise<any> {
return flatApplication(opts, outFile, identity)
}

protected packageInDistributableFormat(appOutDir: string, targets: Array<Target>, promises: Array<Promise<any>>): void {
Expand Down
14 changes: 14 additions & 0 deletions src/targets/pkg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { exec } from "../util/util"
import { BaseSignOptions } from "electron-osx-sign-tf"

export function flatApplication(opts: BaseSignOptions, outFile: string, identity: string): Promise<any> {
const args = [
"--component", opts.app, "/Applications",
"--sign", identity,
]
if (opts.keychain != null) {
args.push("--keychain", opts.keychain)
}
args.push(outFile)
return exec("productbuild", args)
}

0 comments on commit adacf1e

Please sign in to comment.