Skip to content

Commit

Permalink
feat: osx entitlements location by convention
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed May 2, 2016
1 parent 974f7f3 commit af1165b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/osxPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createKeychain, deleteKeychain, CodeSigningInfo, generateKeychainName }
import { path7za } from "7zip-bin"
import deepAssign = require("deep-assign")
import { sign, flat, BaseSignOptions, SignOptions, FlatOptions } from "electron-osx-sign-tf"
import { readdir } from "fs-extra-p"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
Expand All @@ -16,6 +17,8 @@ export default class OsXPackager extends PlatformPackager<OsXBuildOptions> {

readonly targets: Array<string>

readonly resourceList: Promise<Array<string>>

constructor(info: BuildInfo, cleanupTasks: Array<() => Promise<any>>) {
super(info)

Expand All @@ -37,6 +40,8 @@ export default class OsXPackager extends PlatformPackager<OsXBuildOptions> {
}
}
this.targets = targets == null ? ["default"] : targets

this.resourceList = readdir(this.buildResourcesDir)
}

get platform() {
Expand Down Expand Up @@ -94,13 +99,28 @@ export default class OsXPackager extends PlatformPackager<OsXBuildOptions> {
identity: codeSigningInfo.name,
}, (<any>this.devMetadata.build)["osx-sign"], baseSignOptions)

const resourceList = await this.resourceList

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

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

await this.doSign(signOptions)

Expand Down
32 changes: 31 additions & 1 deletion test/src/osxPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from "./helpers/avaEx"
import { assertPack, platform, modifyPackageJson } from "./helpers/packTester"
import { Platform } from "out"
import OsXPackager from "out/osxPackager"
import { move } from "fs-extra-p"
import { move, writeFile } from "fs-extra-p"
import * as path from "path"
import { BuildInfo } from "out/platformPackager"
import { Promise as BluebirdPromise } from "bluebird"
Expand Down Expand Up @@ -107,6 +107,36 @@ test.ifOsx("identity in package.json", () => {
})
})

test.ifOsx("entitlements in build dir", () => {
let platformPackager: CheckingOsXPackager = null
return assertPack("test-app-one", {
platform: [Platform.OSX],
platformPackagerFactory: (packager, platform, cleanupTasks) => platformPackager = new CheckingOsXPackager(packager, cleanupTasks),
cscLink: null,
cscInstallerLink: null,
devMetadata: {
build: {
osx: {
identity: "osx",
}
}
}
}, {
tempDirCreated: projectDir => BluebirdPromise.all([
writeFile(path.join(projectDir, "build", "osx.entitlements"), ""),
writeFile(path.join(projectDir, "build", "osx.inherit.entitlements"), ""),
]),
packed: projectDir => {
assertThat(platformPackager.effectiveSignOptions).has.properties({
identity: "osx",
entitlements: path.join(projectDir, "build", "osx.entitlements"),
"entitlements-inherit": path.join(projectDir, "build", "osx.inherit.entitlements"),
})
return BluebirdPromise.resolve(null)
}
})
})

// test.ifOsx("no background", (t: any) => assertPack("test-app-one", platform(Platform.OSX), {
// tempDirCreated: projectDir => deleteFile(path.join(projectDir, "build", "background.png"))
// }))
Expand Down

0 comments on commit af1165b

Please sign in to comment.