Skip to content

Commit

Permalink
fix: update electron-osx-sign to 0.4 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jun 1, 2016
1 parent e923e72 commit bf93b24
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 30 deletions.
1 change: 1 addition & 0 deletions docker/test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
set -e

npm install
npm prune
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
"compare-versions": "^2.0.1",
"debug": "^2.2.0",
"deep-assign": "^2.0.0",
"electron-osx-sign-tf": "0.5.1",
"electron-packager-tf": "~7.2.0",
"electron-winstaller-fixed": "~2.9.3",
"electron-osx-sign-tf": "0.6.0",
"electron-packager-tf": "~7.3.0",
"electron-winstaller-fixed": "~2.9.4",
"fs-extra-p": "^1.0.1",
"globby": "^4.1.0",
"hosted-git-info": "^2.1.5",
Expand Down
7 changes: 4 additions & 3 deletions src/osxPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Promise as BluebirdPromise } from "bluebird"
import { log, debug, warn, isEmptyOrSpaces } from "./util"
import { createKeychain, deleteKeychain, CodeSigningInfo, generateKeychainName, findIdentity } from "./codeSign"
import deepAssign = require("deep-assign")
import { sign, flat, BaseSignOptions, SignOptions, FlatOptions } from "electron-osx-sign-tf"
import { signAsync, flatAsync, BaseSignOptions, SignOptions, FlatOptions } from "electron-osx-sign-tf"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")
Expand Down Expand Up @@ -134,6 +134,7 @@ export default class OsXPackager extends PlatformPackager<OsXBuildOptions> {
app: path.join(appOutDir, `${this.appName}.app`),
platform: masOptions == null ? "darwin" : "mas",
keychain: <any>codeSigningInfo.keychainName,
version: this.info.electronVersion
}

const signOptions = Object.assign({
Expand Down Expand Up @@ -176,11 +177,11 @@ export default class OsXPackager extends PlatformPackager<OsXBuildOptions> {
}

protected async doSign(opts: SignOptions): Promise<any> {
return BluebirdPromise.promisify(sign)(opts)
return signAsync(opts)
}

protected async doFlat(opts: FlatOptions): Promise<any> {
return BluebirdPromise.promisify(flat)(opts)
return flatAsync(opts)
}

protected async computeEffectiveDistOptions(appOutDir: string): Promise<appdmg.Specification> {
Expand Down
1 change: 1 addition & 0 deletions src/winPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {
usePackageJson: false,
extraMetadataSpecs: projectUrl == null ? null : `\n <projectUrl>${projectUrl}</projectUrl>`,
copyright: packOptions["app-copyright"],
packageCompressionLevel: this.devMetadata.build.compression === "store" ? 0 : 9,
sign: {
name: this.appName,
site: projectUrl,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/test-app-one/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "Foo Bar <[email protected]>",
"license": "MIT",
"devDependencies": {
"electron-prebuilt": "^0.37.8"
"electron-prebuilt": "^1.2.1"
},
"build": {
"app-bundle-id": "your.id",
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"start": "electron ."
},
"devDependencies": {
"electron-prebuilt": "^0.37.8"
"electron-prebuilt": "^1.2.1"
},
"build": {
"app-bundle-id": "your.id",
Expand Down
4 changes: 2 additions & 2 deletions test/src/BuildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Promise as BluebirdPromise } from "bluebird"
import * as path from "path"
import { assertThat } from "./helpers/fileAssert"
import { archFromString, BuildOptions, Platform, Arch, PackagerOptions, DIR_TARGET, createTargets } from "out"
import pathSorter = require("path-sort")
import { normalizeOptions } from "out/builder"
import { createYargs } from "out/cliOptions"
import pathSorter = require("path-sort")

//noinspection JSUnusedLocalSymbols
const __awaiter = require("out/awaiter")
Expand Down Expand Up @@ -128,7 +128,7 @@ test("relative index", () => assertPack("test-app", allPlatforms(false), {
}, true)
}))

const electronVersion = "0.37.8"
const electronVersion = "1.2.1"

test.ifNotWindows("electron version from electron-prebuilt dependency", () => assertPack("test-app-one", {
targets: Platform.LINUX.createTarget(DIR_TARGET),
Expand Down
3 changes: 0 additions & 3 deletions test/src/helpers/expectedContents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,12 @@ export const expectedWinContents = [
"lib/net45/libGLESv2.dll",
"lib/net45/LICENSE",
"lib/net45/LICENSES.chromium.html",
"lib/net45/msvcp120.dll",
"lib/net45/msvcr120.dll",
"lib/net45/natives_blob.bin",
"lib/net45/node.dll",
"lib/net45/snapshot_blob.bin",
"lib/net45/TestApp.exe",
"lib/net45/ui_resources_200_percent.pak",
"lib/net45/Update.exe",
"lib/net45/vccorlib120.dll",
"lib/net45/version",
"lib/net45/xinput1_3.dll",
"lib/net45/locales/en-US.pak",
Expand Down
7 changes: 7 additions & 0 deletions test/src/helpers/fileAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as json8 from "json8"
import { green, red, gray } from "chalk"
import { diffJson } from "diff"
import { AssertionError } from "assert"
import * as path from "path"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("out/awaiter")
Expand Down Expand Up @@ -31,6 +32,12 @@ class Assertions {
}
}

isAbsolute() {
if (!path.isAbsolute(this.actual)) {
throw new Error(`Path ${this.actual} is not absolute`)
}
}

async isFile() {
const info = await stat(this.actual)
if (!info.isFile()) {
Expand Down
33 changes: 17 additions & 16 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { copy, emptyDir, remove, writeJson, readJson, readFile } from "fs-extra-p"
import * as assertThat from "should/as-function"
import * as assertThat2 from "should/as-function"
import { assertThat } from "./fileAssert"
import * as path from "path"
import { parse as parsePlist } from "plist"
import { CSC_LINK, CSC_KEY_PASSWORD, CSC_INSTALLER_LINK, CSC_INSTALLER_KEY_PASSWORD } from "./codeSignData"
import { expectedLinuxContents, expectedWinContents } from "./expectedContents"
import { Packager, PackagerOptions, Platform, getProductName, ArtifactCreated, Arch, DIR_TARGET } from "out"
import { exec, getTempName } from "out/util"
import { tmpdir } from "os"
import DecompressZip = require("decompress-zip")
import { getArchSuffix } from "out/platformPackager"
import pathSorter = require("path-sort")
import DecompressZip = require("decompress-zip")

//noinspection JSUnusedLocalSymbols
const __awaiter = require("out/awaiter")
Expand Down Expand Up @@ -83,7 +84,7 @@ async function packAndCheck(projectDir: string, packagerOptions: PackagerOptions

const artifacts: Map<Platform, Array<ArtifactCreated>> = new Map()
packager.artifactCreated(event => {
assertThat(path.isAbsolute(event.file)).true()
assertThat(event.file).isAbsolute()
let list = artifacts.get(event.platform)
if (list == null) {
list = []
Expand Down Expand Up @@ -129,7 +130,7 @@ async function checkLinuxResult(projectDir: string, packager: Packager, checkOpt
return result
}

assertThat(getFileNames(artifacts)).deepEqual((checkOptions == null || checkOptions.expectedArtifacts == null ? getExpected() : checkOptions.expectedArtifacts.slice()).sort())
assertThat(getFileNames(artifacts)).isEqualTo((checkOptions == null || checkOptions.expectedArtifacts == null ? getExpected() : checkOptions.expectedArtifacts.slice()).sort())

if (!targets.includes("deb") || !targets.includes("default")) {
return
Expand All @@ -152,12 +153,12 @@ async function checkLinuxResult(projectDir: string, packager: Packager, checkOpt
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb", productName), null, 2))

const packageFile = `${projectDir}/${outDirName}/TestApp-1.1.0-amd64.deb`
assertThat(await getContents(packageFile, productName)).deepEqual(expectedContents)
assertThat(await getContents(packageFile, productName)).isEqualTo(expectedContents)
if (arch === Arch.ia32) {
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-1.1.0-i386.deb`, productName)).deepEqual(expectedContents)
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-1.1.0-i386.deb`, productName)).isEqualTo(expectedContents)
}

assertThat(parseDebControl(await exec("dpkg", ["--info", packageFile]))).has.properties({
assertThat2(parseDebControl(await exec("dpkg", ["--info", packageFile]))).has.properties({
License: "MIT",
Homepage: "http://foo.example.com",
Maintainer: "Foo Bar <[email protected]>",
Expand Down Expand Up @@ -191,7 +192,7 @@ async function checkOsXResult(packager: Packager, packagerOptions: PackagerOptio
const productName = getProductName(packager.metadata, packager.devMetadata)
const packedAppDir = path.join(path.dirname(artifacts[0].file), (productName || packager.metadata.name) + ".app")
const info = parsePlist(await readFile(path.join(packedAppDir, "Contents", "Info.plist"), "utf8"))
assertThat(info).has.properties({
assertThat2(info).has.properties({
CFBundleDisplayName: productName,
CFBundleIdentifier: "your.id",
LSApplicationCategoryType: "your.app.category.type",
Expand All @@ -200,20 +201,20 @@ async function checkOsXResult(packager: Packager, packagerOptions: PackagerOptio

if (packagerOptions.cscLink != null) {
const result = await exec("codesign", ["--verify", packedAppDir])
assertThat(result).not.match(/is not signed at all/)
assertThat2(result).not.match(/is not signed at all/)
}

const actualFiles = artifacts.map(it => path.basename(it.file)).sort()
if (checkOptions != null && checkOptions.expectedContents != null) {
assertThat(actualFiles).deepEqual(checkOptions.expectedContents)
assertThat(actualFiles).isEqualTo(checkOptions.expectedContents)
}
else {
assertThat(actualFiles).deepEqual([
assertThat(actualFiles).isEqualTo([
`${productName}-1.1.0-mac.zip`,
`${productName}-1.1.0.dmg`,
].sort())

assertThat(artifacts.map(it => it.artifactName).sort()).deepEqual([
assertThat(artifacts.map(it => it.artifactName).sort()).isEqualTo([
"TestApp-1.1.0-mac.zip",
"TestApp-1.1.0.dmg",
].sort())
Expand Down Expand Up @@ -241,13 +242,13 @@ async function checkWindowsResult(packager: Packager, checkOptions: AssertPackOp
}

const archSuffix = getArchSuffix(arch)
assertThat(getFileNames(artifacts)).deepEqual((checkOptions == null || checkOptions.expectedArtifacts == null ? getExpectedFileNames(archSuffix) : checkOptions.expectedArtifacts.slice()).sort())
assertThat(getFileNames(artifacts)).isEqualTo((checkOptions == null || checkOptions.expectedArtifacts == null ? getExpectedFileNames(archSuffix) : checkOptions.expectedArtifacts.slice()).sort())

if (checkOptions != null && checkOptions.expectedArtifacts != null) {
return
}

assertThat(artifacts.map(it => it.artifactName).filter(it => it != null)).deepEqual([`TestApp-Setup-1.1.0${archSuffix}.exe`])
assertThat(artifacts.map(it => it.artifactName).filter(it => it != null)).isEqualTo([`TestApp-Setup-1.1.0${archSuffix}.exe`])

const packageFile = path.join(path.dirname(artifacts[0].file), `TestApp-1.1.0-full.nupkg`)
const unZipper = new DecompressZip(packageFile)
Expand All @@ -257,7 +258,7 @@ async function checkWindowsResult(packager: Packager, checkOptions: AssertPackOp

// console.log(JSON.stringify(files, null, 2))
const expectedContents = checkOptions == null || checkOptions.expectedContents == null ? expectedWinContents : checkOptions.expectedContents
assertThat(files).deepEqual(expectedContents.map(it => {
assertThat(files).isEqualTo(expectedContents.map(it => {
if (it === "lib/net45/TestApp.exe") {
return `lib/net45/${encodeURI(productName)}.exe`
}
Expand All @@ -272,7 +273,7 @@ async function checkWindowsResult(packager: Packager, checkOptions: AssertPackOp
})
const expectedSpec = (await readFile(path.join(path.dirname(packageFile), "TestApp.nuspec"), "utf8")).replace(/\r\n/g, "\n")
// console.log(expectedSpec)
assertThat(expectedSpec).equal(`<?xml version="1.0"?>
assertThat(expectedSpec).isEqualTo(`<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>TestApp</id>
Expand Down
2 changes: 1 addition & 1 deletion test/src/helpers/runTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const rootDir = path.join(__dirname, "..", "..", "..")
const testPackageDir = path.join(require("os").tmpdir(), "electron_builder_published")
const testNodeModules = path.join(testPackageDir, "node_modules")

const electronVersion = "0.37.8"
const electronVersion = "1.2.1"

async function main() {
await BluebirdPromise.all([
Expand Down

0 comments on commit bf93b24

Please sign in to comment.