Skip to content

Commit

Permalink
fix: Can't build on OSX (x64) since electron-builder 5.19.0
Browse files Browse the repository at this point in the history
Closes #635
  • Loading branch information
develar committed Aug 4, 2016
1 parent 090473e commit 753cd08
Show file tree
Hide file tree
Showing 16 changed files with 151 additions and 306 deletions.
3 changes: 0 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ platform:
- x64

cache:
- node_modules
- '%APPDATA%\npm-cache'
- '%USERPROFILE%\.electron'
- '%USERPROFILE%\.cache\nsis'

install:
- ps: Install-Product node 6 x64
- npm install npm -g
- npm install
- npm prune

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
"diff": "^2.2.3",
"json8": "^0.9.2",
"pre-git": "^3.10.0",
"should": "^10.0.0",
"ts-babel": "^1.0.4",
"tslint": "3.14.0",
"typescript": "^2.1.0-dev.20160802",
Expand Down
4 changes: 1 addition & 3 deletions src/targets/archive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn, debug, debug7zArgs } from "../util/util"
import { spawn, debug7zArgs } from "../util/util"
import { CompressionLevel } from "../metadata"
import * as path from "path"
import { unlink } from "fs-extra-p"
Expand Down Expand Up @@ -34,7 +34,6 @@ export async function archiveApp(compression: CompressionLevel | n, format: stri

await spawn(process.platform === "darwin" || process.platform === "freebsd" ? "gtar" : "tar", [info.flag, "--transform", `s,^\.,${path.basename(outFile, "." + format)},`, "-cf", outFile, "."], {
cwd: dirToArchive,
stdio: ["ignore", debug.enabled ? "inherit" : "ignore", "inherit"],
env: tarEnv
})
return outFile
Expand Down Expand Up @@ -74,7 +73,6 @@ export async function archiveApp(compression: CompressionLevel | n, format: stri

await spawn(path7za, args, {
cwd: withoutDir ? dirToArchive : path.dirname(dirToArchive),
stdio: ["ignore", debug.enabled ? "inherit" : "ignore", "inherit"],
})

return outFile
Expand Down
5 changes: 2 additions & 3 deletions src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,8 @@ export default class NsisTarget extends Target {
// we use NSIS_CONFIG_CONST_DATA_PATH=no to build makensis on Linux, but in any case it doesn't use stubs as MacOS/Windows version, so, we explicitly set NSISDIR
env: Object.assign({}, process.env, {NSISDIR: nsisPath}),
cwd: nsisTemplatesDir,
stdio: ["pipe", "pipe", process.stderr]
})
handleProcess("close", childProcess, command, resolve, reject, true)
}, true)
handleProcess("close", childProcess, command, resolve, reject)

childProcess.stdin.end(script)
})
Expand Down
1 change: 0 additions & 1 deletion src/util/binDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ async function doGetBin(name: string, dirName: string, url: string, sha2?: strin

await spawn(path7za, debug7zArgs("x").concat(archiveName, `-o${tempUnpackDir}`), {
cwd: cachePath,
stdio: ["ignore", debug.enabled ? "inherit" : "ignore", "inherit"],
})

const isOldMethod = sha2 == null
Expand Down
24 changes: 14 additions & 10 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export function spawnNpmProduction(command: string, appDir: string, env?: any):

return spawn(npmExecPath, npmExecArgs, {
cwd: appDir,
stdio: ["ignore", "pipe", process.stderr],
env: env || process.env
})
}
Expand Down Expand Up @@ -98,25 +97,31 @@ export function exec(file: string, args?: Array<string> | null, options?: ExecOp
})
}

export function doSpawn(command: string, args: Array<string>, options?: SpawnOptions): ChildProcess {
export function doSpawn(command: string, args: Array<string>, options?: SpawnOptions, pipeInput?: Boolean): ChildProcess {
if (options == null) {
options = {}
}
if (options.stdio == null) {
options.stdio = [pipeInput ? "pipe" : "ignore", debug.enabled ? "inherit" : "pipe", "inherit"]
}

if (debug.enabled) {
debug(`Spawning ${command} ${args.join(" ")}`)
}
return _spawn(command, args, options)
}

export function spawn(command: string, args?: Array<string> | null, options?: SpawnOptions): BluebirdPromise<any> {
export function spawn(command: string, args?: Array<string> | null, options?: SpawnOptions, pipeInput?: Boolean): BluebirdPromise<any> {
return new BluebirdPromise<any>((resolve, reject) => {
handleProcess("close", doSpawn(command, args || [], options), command, resolve, reject)
handleProcess("close", doSpawn(command, args || [], options, pipeInput), command, resolve, reject)
})
}

export function handleProcess(event: string, childProcess: ChildProcess, command: string, resolve: ((value?: any) => void) | null, reject: (reason?: any) => void, printOut: boolean = false) {
export function handleProcess(event: string, childProcess: ChildProcess, command: string, resolve: ((value?: any) => void) | null, reject: (reason?: any) => void) {
childProcess.on("error", reject)

let out: string | null = null
if (printOut) {
out = ""
let out = ""
if (!debug.enabled && childProcess.stdout != null) {
childProcess.stdout.on("data", (data: string) => {
out += data
})
Expand All @@ -125,11 +130,10 @@ export function handleProcess(event: string, childProcess: ChildProcess, command
childProcess.on(event, (code: number) => {
if (code === 0 && debug.enabled) {
debug(`${command} (${childProcess.pid}) exited with code ${code}`)
debug(out)
}

if (code !== 0) {
reject(new Error(`${command} exited with code ${code}${out == null ? "" : `\n${out}`}`))
reject(new Error(`${command} exited with code ${code}${out.length === 0 ? "" : `\n${out}`}`))
}
else if (resolve != null) {
resolve()
Expand Down
4 changes: 1 addition & 3 deletions src/windowsCodeSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ async function spawnSign(options: any, inputPath: string, outputPath: string, ha
args.push(inputPath)
}

return await spawn(await getToolPath(options), args, {
stdio: ["ignore", "ignore", "inherit"],
})
return await spawn(await getToolPath(options), args)
}

// async function verify(options: any) {
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 @@ -8,7 +8,7 @@
"author": "Foo Bar <[email protected]>",
"license": "MIT",
"build": {
"electronVersion": "1.3.1",
"electronVersion": "1.3.2",
"appId": "org.electron-builder.testApp",
"app-category-type": "your.app.category.type",
"iconUrl": "https://raw.githubusercontent.com/szwacz/electron-boilerplate/master/resources/windows/icon.ico",
Expand Down
6 changes: 4 additions & 2 deletions test/src/ArtifactPublisherTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from "./helpers/avaEx"
import { GitHubPublisher } from "out/publish/gitHubPublisher"
import { HttpError } from "out/publish/gitHubRequest"
import { join } from "path"
import * as assertThat from "should/as-function"
import { assertThat } from "./helpers/fileAssert"
import { BintrayPublisher } from "out/publish/BintrayPublisher"

//noinspection JSUnusedLocalSymbols
Expand All @@ -16,6 +16,7 @@ function versionNumber() {
return `${getRandomInt(0, 99)}.${getRandomInt(0, 99)}.${getRandomInt(0, 99)}`
}

//noinspection SpellCheckingInspection
const token = new Buffer("Y2Y5NDdhZDJhYzJlMzg1OGNiNzQzYzcwOWZhNGI0OTk2NWQ4ZDg3Yg==", "base64").toString()
const iconPath = join(__dirname, "..", "fixtures", "test-app", "build", "icon.icns")

Expand Down Expand Up @@ -51,6 +52,7 @@ function testAndIgnoreApiRate(name: string, testFunction: () => Promise<any>) {

test("Bintray upload", async () => {
const version = versionNumber()
//noinspection SpellCheckingInspection
const publisher = new BintrayPublisher("actperepo", "5df2cadec86dff91392e4c419540785813c3db15", version, "test")
try {
const artifactName = `icon-${version}.icns`
Expand Down Expand Up @@ -85,7 +87,7 @@ testAndIgnoreApiRate("prerelease", async () => {
try {
await publisher.upload(iconPath)
const r = await publisher.getRelease()
assertThat(r).has.properties({
assertThat(r).hasProperties({
prerelease: true,
draft: false,
})
Expand Down
39 changes: 22 additions & 17 deletions test/src/CodeSignTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createKeychain, deleteKeychain, generateKeychainName } from "out/codeSign"
import * as assertThat from "should/as-function"
import { assertThat } from "./helpers/fileAssert"
import test from "./helpers/avaEx"
import { CSC_LINK } from "./helpers/codeSignData"
import { executeFinally, all } from "out/util/promise"
Expand All @@ -8,23 +8,28 @@ import { removePassword } from "out/util/util"
//noinspection JSUnusedLocalSymbols
const __awaiter = require("out/util/awaiter")

test.ifOsx("create keychain", async () => {
const keychainName = generateKeychainName()
await executeFinally(createKeychain(keychainName, CSC_LINK, process.env.CSC_KEY_PASSWORD)
.then(result => {
assertThat(result.keychainName).not.empty()
}), () => all([deleteKeychain(keychainName)]))
})
if (process.env.CSC_KEY_PASSWORD == null) {
console.warn("Skip keychain-specific tests because CSC_KEY_PASSWORD is not defined")
}
else {
test.ifOsx("create keychain", async() => {
const keychainName = generateKeychainName()
await executeFinally(createKeychain(keychainName, CSC_LINK, process.env.CSC_KEY_PASSWORD)
.then(result => {
assertThat(result.keychainName).isNotEmpty()
}), () => all([deleteKeychain(keychainName)]))
})

test.ifOsx("create keychain with installers", async () => {
const keychainName = generateKeychainName()
await executeFinally(createKeychain(keychainName, CSC_LINK, process.env.CSC_KEY_PASSWORD)
.then(result => {
assertThat(result.keychainName).not.empty()
}), () => all([deleteKeychain(keychainName)]))
})
test.ifOsx("create keychain with installers", async() => {
const keychainName = generateKeychainName()
await executeFinally(createKeychain(keychainName, CSC_LINK, process.env.CSC_KEY_PASSWORD)
.then(result => {
assertThat(result.keychainName).isNotEmpty()
}), () => all([deleteKeychain(keychainName)]))
})
}

test.ifOsx("remove password from log", async () => {
assertThat(removePassword("seq -P foo -B")).equal("seq -P 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae (sha256 hash) -B")
assertThat(removePassword("pass:foo")).equal("pass:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae (sha256 hash)")
assertThat(removePassword("seq -P foo -B")).isEqualTo("seq -P 2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae (sha256 hash) -B")
assertThat(removePassword("pass:foo")).isEqualTo("pass:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae (sha256 hash)")
})
6 changes: 3 additions & 3 deletions test/src/RepoSlugTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Info } from "hosted-git-info"
import * as assertThat from "should/as-function"
import { assertThat } from "./helpers/fileAssert"
import test from "ava-tf"
import { Promise as BluebirdPromise } from "bluebird"
import { getRepositoryInfo } from "out/repositoryInfo"
Expand All @@ -12,7 +12,7 @@ test("repo slug from TRAVIS_REPO_SLUG", () => {
try {
process.env.TRAVIS_REPO_SLUG = "travis-ci/travis-build"
const info = (<BluebirdPromise<Info>>getRepositoryInfo()).value()
assertThat(info).has.properties({
assertThat(info).hasProperties({
user: "travis-ci",
project: "travis-build",
})
Expand Down Expand Up @@ -43,7 +43,7 @@ test("repo slug from APPVEYOR", () => {
process.env.APPVEYOR_ACCOUNT_NAME = "travis-ci"
process.env.APPVEYOR_PROJECT_NAME = "travis-build"
const info = (<BluebirdPromise<Info>>getRepositoryInfo()).value()
assertThat(info).has.properties({
assertThat(info).hasProperties({
user: "travis-ci",
project: "travis-build",
})
Expand Down
10 changes: 6 additions & 4 deletions test/src/helpers/expectedContents.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//noinspection SpellCheckingInspection
export const expectedLinuxContents = [
"/",
export const expectedLinuxContents = ["/",
"/opt/",
"/usr/",
"/opt/TestApp/",
"/opt/TestApp/blink_image_resources_200_percent.pak",
"/opt/TestApp/content_resources_200_percent.pak",
"/opt/TestApp/content_shell.pak",
"/opt/TestApp/icudtl.dat",
"/opt/TestApp/libffmpeg.so",
Expand All @@ -13,6 +14,8 @@ export const expectedLinuxContents = [
"/opt/TestApp/natives_blob.bin",
"/opt/TestApp/snapshot_blob.bin",
"/opt/TestApp/TestApp",
"/opt/TestApp/ui_resources_200_percent.pak",
"/opt/TestApp/views_resources_200_percent.pak",
"/usr/share/",
"/opt/TestApp/resources/",
"/opt/TestApp/resources/app.asar",
Expand Down Expand Up @@ -50,8 +53,7 @@ export const expectedLinuxContents = [
"/usr/share/icons/hicolor/64x64/apps/",
"/usr/share/icons/hicolor/64x64/apps/TestApp.png",
"/usr/share/icons/hicolor/96x96/apps/",
"/usr/share/icons/hicolor/96x96/apps/TestApp.png"
]
"/usr/share/icons/hicolor/96x96/apps/TestApp.png"]

//noinspection SpellCheckingInspection
export const expectedWinContents = [
Expand Down
18 changes: 16 additions & 2 deletions test/src/helpers/fileAssert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ class Assertions {
compare(this.actual, expected)
}

isNotEqualTo(expected: any) {
compare(this.actual, expected, true)
}

isNotEmpty() {
compare(this.actual, "", true)
}

doesNotMatch(pattern: RegExp) {
if ((<string>this.actual).match(pattern)) {
throw new Error(`${this.actual} matches ${pattern}`)
}
}

containsAll<T>(expected: Iterable<T>) {
compare(this.actual.slice().sort(), Array.from(expected).slice().sort())
}
Expand Down Expand Up @@ -89,8 +103,8 @@ function prettyDiff(actual: any, expected: any): string {
return `\n${diff}\n`
}

function compare(actual: any, expected: any) {
if (!json8.equal(actual, expected)) {
function compare(actual: any, expected: any, not: boolean = false) {
if (json8.equal(actual, expected) === not) {
const actualJson = JSON.stringify(actual, jsonReplacer, 2)
const expectedJson = JSON.stringify(expected, jsonReplacer, 2)
const stack = new Error().stack
Expand Down
7 changes: 3 additions & 4 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { copy, emptyDir, remove, writeJson, readJson, readFile } from "fs-extra-p"
import * as assertThat2 from "should/as-function"
import { assertThat } from "./fileAssert"
import * as path from "path"
import { parse as parsePlist } from "plist"
Expand Down Expand Up @@ -172,7 +171,7 @@ async function checkLinuxResult(projectDir: string, packager: Packager, checkOpt
assertThat(await getContents(`${projectDir}/${outDirName}/TestApp-${appInfo.version}-i386.deb`)).isEqualTo(expectedContents)
}

assertThat2(parseDebControl(await exec("dpkg", ["--info", packageFile]))).has.properties({
assertThat(parseDebControl(await exec("dpkg", ["--info", packageFile]))).hasProperties({
License: "MIT",
Homepage: "http://foo.example.com",
Maintainer: "Foo Bar <[email protected]>",
Expand Down Expand Up @@ -206,7 +205,7 @@ async function checkOsXResult(packager: Packager, packagerOptions: PackagerOptio
const appInfo = packager.appInfo
const packedAppDir = path.join(path.dirname(artifacts[0].file), `${appInfo.productFilename}.app`)
const info = parsePlist(await readFile(path.join(packedAppDir, "Contents", "Info.plist"), "utf8"))
assertThat2(info).has.properties({
assertThat(info).hasProperties({
CFBundleDisplayName: appInfo.productName,
CFBundleIdentifier: "org.electron-builder.testApp",
LSApplicationCategoryType: "your.app.category.type",
Expand All @@ -215,7 +214,7 @@ async function checkOsXResult(packager: Packager, packagerOptions: PackagerOptio

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

const actualFiles = artifacts.map(it => path.basename(it.file)).sort()
Expand Down
Loading

0 comments on commit 753cd08

Please sign in to comment.