From 1398af4aeba8b2ae18816eb3df3f5e2620c90ea9 Mon Sep 17 00:00:00 2001 From: develar Date: Thu, 1 Sep 2016 08:31:38 +0200 Subject: [PATCH] fix(mac): build mac targets on non-macOs --- package.json | 10 +++++----- src/macPackager.ts | 6 +++++- src/targets/dmg.ts | 3 +-- test/src/helpers/runTests.ts | 3 +-- test/src/macPackagerTest.ts | 15 +++++---------- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index a4abed18814..319adad3f38 100644 --- a/package.json +++ b/package.json @@ -61,12 +61,12 @@ "dependencies": { "7zip-bin": "^1.0.6", "ansi-escapes": "^1.4.0", - "archiver": "^1.0.1", + "archiver": "^1.1.0", "archiver-utils": "^1.3.0", - "asar-electron-builder": "^0.13.2", - "bluebird": "^3.4.3", + "asar-electron-builder": "^0.13.5", + "bluebird": "^3.4.5", "chalk": "^1.1.3", - "chromium-pickle-js": "^0.1.0", + "chromium-pickle-js": "^0.2.0", "cli-cursor": "^1.0.2", "cuint": "^0.2.2", "debug": "^2.2.0", @@ -123,7 +123,7 @@ "pre-git": "^3.10.0", "ts-babel": "^1.0.4", "tslint": "^3.15.1", - "typescript": "^2.1.0-dev.20160826", + "typescript": "^2.0.2", "whitespace": "^2.1.0" }, "babel": { diff --git a/src/macPackager.ts b/src/macPackager.ts index 1b07ef2fea0..8a3c311a839 100644 --- a/src/macPackager.ts +++ b/src/macPackager.ts @@ -19,7 +19,7 @@ export default class MacPackager extends PlatformPackager { constructor(info: BuildInfo) { super(info) - if (this.options.cscLink == null) { + if (this.options.cscLink == null || process.platform !== "darwin") { this.codeSigningInfo = BluebirdPromise.resolve({}) } else { @@ -96,6 +96,10 @@ export default class MacPackager extends PlatformPackager { } private async sign(appOutDir: string, masOptions: MasBuildOptions | null): Promise { + if (process.platform !== "darwin") { + return + } + let keychainName = (await this.codeSigningInfo).keychainName const masQualifier = masOptions == null ? null : (masOptions.identity || this.platformSpecificBuildOptions.identity) diff --git a/src/targets/dmg.ts b/src/targets/dmg.ts index fbfae33b613..90f1601ba3c 100644 --- a/src/targets/dmg.ts +++ b/src/targets/dmg.ts @@ -5,7 +5,6 @@ import { Target, PlatformPackager } from "../platformPackager" import { MacOptions, DmgOptions } from "../metadata" import { Promise as BluebirdPromise } from "bluebird" import { debug, use } from "../util/util" -import appdmg = require("appdmg") //noinspection JSUnusedLocalSymbols const __awaiter = require("../util/awaiter") @@ -46,7 +45,7 @@ export class DmgTarget extends Target { debug(`appdmg: ${JSON.stringify(dmgOptions, null, 2)}`) } - const emitter = appdmg(dmgOptions) + const emitter = require("appdmg")(dmgOptions) emitter.on("error", reject) emitter.on("finish", () => resolve()) if (debug.enabled) { diff --git a/test/src/helpers/runTests.ts b/test/src/helpers/runTests.ts index e84c69073b9..bf64bc91bcf 100755 --- a/test/src/helpers/runTests.ts +++ b/test/src/helpers/runTests.ts @@ -152,8 +152,7 @@ function runTests(): BluebirdPromise { args.push(path.join(baseDir, "linuxPackagerTest.js"), path.join(baseDir, "BuildTest.js"), path.join(baseDir, "globTest.js")) } else { - args.push(path.join(baseDir, "winPackagerTest.js")) - args.push(path.join(baseDir, "nsisTest.js")) + args.push(path.join(baseDir, "winPackagerTest.js"), path.join(baseDir, "nsisTest.js"), path.join(baseDir, "macPackagerTest.js")) args.push(...baseForLinuxTests) } console.log(`Test files for node ${circleNodeIndex}: ${args.join(", ")}`) diff --git a/test/src/macPackagerTest.ts b/test/src/macPackagerTest.ts index 6ec311abd06..4753f5b22a5 100644 --- a/test/src/macPackagerTest.ts +++ b/test/src/macPackagerTest.ts @@ -3,7 +3,7 @@ import { assertPack, platform, modifyPackageJson, signed, app } from "./helpers/ import OsXPackager from "out/macPackager" import { move, writeFile, deleteFile, remove } from "fs-extra-p" import * as path from "path" -import { BuildInfo, PackagerOptions } from "out/platformPackager" +import { BuildInfo } from "out/platformPackager" import { Promise as BluebirdPromise } from "bluebird" import { assertThat } from "./helpers/fileAssert" import { ElectronPackagerOptions } from "out/packager/dirPackager" @@ -21,7 +21,7 @@ test.ifOsx("two-package", () => assertPack("test-app", {targets: createTargets([ test.ifOsx("one-package", app(platform(Platform.MAC), {signed: true})) function createTargetTest(target: Array, expectedContents: Array) { - let options: PackagerOptions = { + return app({ targets: Platform.MAC.createTarget(), devMetadata: { build: { @@ -30,19 +30,14 @@ function createTargetTest(target: Array, expectedContents: Array } } } - } - if (target.includes("mas")) { - options = signed(options) - } - - return app(options, {expectedContents: expectedContents}) + }, {expectedContents: expectedContents, signed: target.includes("mas")}) } test.ifOsx("only dmg", createTargetTest(["dmg"], ["Test App ßW-1.1.0.dmg"])) -test.ifOsx("only zip", createTargetTest(["zip"], ["Test App ßW-1.1.0-mac.zip"])) +test("only zip", createTargetTest(["zip"], ["Test App ßW-1.1.0-mac.zip"])) test.ifOsx("invalid target", t => t.throws(createTargetTest(["ttt"], [])(), "Unknown target: ttt")) -if (process.env.CSC_KEY_PASSWORD == null) { +if (process.env.CSC_KEY_PASSWORD == null || process.platform !== "darwin") { console.warn("Skip mas tests because CSC_KEY_PASSWORD is not defined") } else {