diff --git a/package.json b/package.json index b6f80e5d8b2..8f6a220e061 100644 --- a/package.json +++ b/package.json @@ -64,11 +64,11 @@ "archiver": "^1.0.1", "archiver-utils": "^1.2.0", "asar-electron-builder": "^0.13.2", - "bluebird": "^3.4.1", + "bluebird": "^3.4.3", "chalk": "^1.1.3", "chromium-pickle-js": "^0.1.0", "cli-cursor": "^1.0.2", - "cuint": "^0.2.1", + "cuint": "^0.2.2", "debug": "^2.2.0", "electron-download": "^2.1.2", "electron-osx-sign": "^0.4.0-beta4", @@ -109,7 +109,7 @@ "@types/debug": "0.0.28", "@types/mime": "0.0.28", "@types/progress": "^1.1.27", - "@types/semver": "^5.3.28", + "@types/semver": "^5.3.29", "@types/source-map-support": "^0.2.27", "ava-tf": "^0.16.0", "babel-plugin-array-includes": "^2.0.3", @@ -117,13 +117,13 @@ "babel-plugin-transform-es2015-parameters": "^6.11.4", "babel-plugin-transform-es2015-spread": "^6.8.0", "decompress-zip": "^0.3.0", - "diff": "^2.2.3", + "diff": "^3.0.0", "json8": "^0.9.2", "path-sort": "^0.1.0", "pre-git": "^3.10.0", "ts-babel": "^1.0.4", - "tslint": "^3.14.0-dev.1", - "typescript": "^2.1.0-dev.20160802", + "tslint": "^3.15.1", + "typescript": "^2.1.0-dev.20160826", "whitespace": "^2.1.0" }, "babel": { diff --git a/src/platformPackager.ts b/src/platformPackager.ts index 34db6a2d304..75f070bcfbb 100644 --- a/src/platformPackager.ts +++ b/src/platformPackager.ts @@ -222,7 +222,7 @@ export abstract class PlatformPackager } protected computeAppOutDir(outDir: string, arch: Arch): string { - return path.join(outDir, `${this.platform.buildConfigurationKey}${arch === Arch.x64 ? "" : `-${Arch[arch]}`}`) + return path.join(outDir, `${this.platform.buildConfigurationKey}${getArchSuffix(arch)}${this.platform === Platform.MAC ? "" : "-unpacked"}`) } dispatchArtifactCreated(file: string, artifactName?: string) { diff --git a/src/util/filter.ts b/src/util/filter.ts index ce8e75ed39c..9fa113181f3 100644 --- a/src/util/filter.ts +++ b/src/util/filter.ts @@ -88,8 +88,8 @@ function flatDependencies(data: any, seen: Set): any { return flatDependencies(deps[d], seen) }) .filter(it => it !== null) - .reduce(function FLAT(l, r) { - return l.concat(Array.isArray(r) ? r.reduce(FLAT, []) : r) + .reduce(function flat(l, r): Array { + return l.concat(Array.isArray(r) ? r.reduce(flat, []) : r) }, []) } diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts index 1844ee1aa1f..dd4a43d3182 100755 --- a/test/src/BuildTest.ts +++ b/test/src/BuildTest.ts @@ -84,8 +84,8 @@ test("custom output dir", app(allPlatforms(false), { app: ".", } }), - packed: async (projectDir) => { - await assertThat(path.join(projectDir, "customDist")).isDirectory() + packed: async context => { + await assertThat(path.join(context.projectDir, "customDist")).isDirectory() } })) @@ -225,10 +225,9 @@ test.ifDevOrLinuxCi("extra metadata", () => { existingProp: 22, } }), - packed: async (projectDir) => { - const out = path.join(projectDir, "dist", "linux") - await assertThat(path.join(out, "NewName")).isFile() - assertThat(JSON.parse(extractFile(path.join(out, "resources", "app.asar"), "package.json").toString())).hasProperties({ + packed: async context => { + await assertThat(path.join(context.getContent(Platform.LINUX), "NewName")).isFile() + assertThat(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "package.json").toString())).hasProperties({ foo: { bar: 12, existingProp: 22, @@ -246,9 +245,8 @@ test.ifDevOrLinuxCi("extra metadata - two", () => { targets: Platform.LINUX.createTarget(DIR_TARGET), extraMetadata: extraMetadata, }, { - packed: async (projectDir, outDir) => { - const out = path.join(outDir, "linux") - await assertThat(path.join(out, "NewName")).isFile() + packed: async context => { + await assertThat(path.join(context.getContent(Platform.LINUX), "NewName")).isFile() } }) }) @@ -265,9 +263,8 @@ test.ifOsx("extra metadata - override icon", t => t.throws((() => { targets: Platform.OSX.createTarget(DIR_TARGET), extraMetadata: extraMetadata, }, { - packed: async (projectDir, outDir) => { - const out = path.join(outDir, "linux") - await assertThat(path.join(out, "NewName")).isFile() + packed: async context => { + await assertThat(path.join(context.getContent(Platform.LINUX), "NewName")).isFile() } }) })(), /ENOENT: no such file or directory/)) @@ -277,8 +274,8 @@ test.ifOsx("app-executable-deps", () => { targets: Platform.current().createTarget(DIR_TARGET), }, { useTempDir: false, - packed: async (projectDir, outDir) => { - const data = await readJson(path.join(outDir, "mac/app-executable-deps.app/Contents/Resources/app.asar.unpacked", "node_modules", "node-notifier", "package.json")) + packed: async context => { + const data = await readJson(path.join(context.outDir, "mac/app-executable-deps.app/Contents/Resources/app.asar.unpacked", "node_modules", "node-notifier", "package.json")) for (let name of Object.getOwnPropertyNames(data)) { if (name[0] === "_") { throw new Error("Property name starts with _") @@ -299,8 +296,8 @@ test.ifDevOrLinuxCi("smart unpack", () => { "edge-cs": "^1.0.0" } }), - packed: (projectDir, outDir) => { - assertThat(JSON.parse(extractFile(path.join(outDir, "linux", "resources", "app.asar"), "node_modules/debug/package.json").toString())).hasProperties({ + packed: context => { + assertThat(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "node_modules/debug/package.json").toString())).hasProperties({ name: "debug" }) return BluebirdPromise.resolve() diff --git a/test/src/globTest.ts b/test/src/globTest.ts index a1393364d93..510c8932eaf 100644 --- a/test/src/globTest.ts +++ b/test/src/globTest.ts @@ -22,8 +22,8 @@ test.ifDevOrLinuxCi("ignore build resources", app({ projectDirCreated: projectDir => { return outputFile(path.join(projectDir, "one/build/foo.txt"), "data") }, - packed: (projectDir, outDir) => { - return assertThat(path.join(outDir, "linux", "resources", "app", "one", "build", "foo.txt")).isFile() + packed: context => { + return assertThat(path.join(context.getResources(Platform.LINUX), "app", "one", "build", "foo.txt")).isFile() }, })) @@ -39,8 +39,8 @@ test.ifDevOrLinuxCi("files", app({ projectDirCreated: projectDir => { return outputFile(path.join(projectDir, "ignoreMe", "foo"), "data") }, - packed: (projectDir, outDir) => { - return assertThat(path.join(outDir, "linux", "resources", "app", "ignoreMe")).doesNotExist() + packed: context => { + return assertThat(path.join(context.getResources(Platform.LINUX), "app", "ignoreMe")).doesNotExist() }, })) @@ -60,10 +60,10 @@ test.ifDevOrLinuxCi("unpackDir one", app({ outputFile(path.join(projectDir, "b2", "file"), "data"), ]) }, - packed: (projectDir, outDir) => { + packed: context => { return BluebirdPromise.all([ - assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "assets")).isDirectory(), - assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "b2")).isDirectory(), + assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "assets")).isDirectory(), + assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "b2")).isDirectory(), ]) }, })) @@ -85,10 +85,10 @@ test.ifDevOrLinuxCi("unpackDir", () => { outputFile(path.join(projectDir, "app", "b2", "file"), "data"), ]) }, - packed: (projectDir, outDir) => { + packed: context => { return BluebirdPromise.all([ - assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "assets")).isDirectory(), - assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "b2")).isDirectory(), + assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "assets")).isDirectory(), + assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "b2")).isDirectory(), ]) }, }) @@ -120,10 +120,10 @@ test.ifNotCiOsx("ignore node_modules known dev dep", () => { outputFile(path.join(projectDir, "ignoreMe"), ""), ]) }, - packed: (projectDir, outDir) => { + packed: context => { return BluebirdPromise.all([ - assertThat(path.join(outDir, "linux", "resources", "app", "node_modules", "electron-osx-sign")).doesNotExist(), - assertThat(path.join(outDir, "linux", "resources", "app", "ignoreMe")).doesNotExist(), + assertThat(path.join(context.getResources(Platform.LINUX), "app", "node_modules", "electron-osx-sign")).doesNotExist(), + assertThat(path.join(context.getResources(Platform.LINUX), "app", "ignoreMe")).doesNotExist(), ]) }, }) @@ -185,15 +185,12 @@ test("extraResources", async () => { outputFile(path.join(projectDir, "ignoreMe.txt"), "ignoreMe"), ]) }, - packed: async (projectDir, outDir) => { - const base = path.join(outDir, platform.buildConfigurationKey) + packed: async context => { + const base = path.join(context.outDir, platform.buildConfigurationKey + `${platform === Platform.MAC ? "" : "-unpacked"}`) let resourcesDir = path.join(base, "resources") if (platform === Platform.MAC) { resourcesDir = path.join(base, "TestApp.app", "Contents", "Resources") } - else if (platform === Platform.WINDOWS) { - resourcesDir = path.join(base + "-unpacked", "resources") - } await assertThat(path.join(resourcesDir, "foo")).isDirectory() await assertThat(path.join(resourcesDir, "foo", "nameWithoutDot")).isFile() await assertThat(path.join(resourcesDir, "bar", "hello.txt")).isFile() @@ -258,15 +255,12 @@ test("extraResources - one-package", async () => { outputFile(path.join(projectDir, "ignoreMe.txt"), "ignoreMe"), ]) }, - packed: async (projectDir, outDir) => { - const base = path.join(outDir, platform.buildConfigurationKey) + packed: async context => { + const base = path.join(context.outDir, platform.buildConfigurationKey + `${platform === Platform.MAC ? "" : "-unpacked"}`) let resourcesDir = path.join(base, "resources") if (platform === Platform.MAC) { resourcesDir = path.join(base, "TestApp.app", "Contents", "Resources") } - else if (platform === Platform.WINDOWS) { - resourcesDir = path.join(base + "-unpacked", "resources") - } const appDir = path.join(resourcesDir, "app") await assertThat(path.join(resourcesDir, "foo")).isDirectory() diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index dc6564e2cb0..684abbffa65 100755 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -29,7 +29,7 @@ const OUT_DIR_NAME = "dist" interface AssertPackOptions { readonly projectDirCreated?: (projectDir: string) => Promise - readonly packed?: (projectDir: string, outDir: string) => Promise + readonly packed?: (context: PackedContext) => Promise readonly expectedContents?: Array readonly expectedArtifacts?: Array @@ -41,6 +41,14 @@ interface AssertPackOptions { readonly npmInstallBefore?: boolean } +interface PackedContext { + readonly projectDir: string, + readonly outDir: string + + readonly getResources: (platform: Platform) => string + readonly getContent: (platform: Platform) => string +} + let tmpDirCounter = 0 export function appThrows(error: RegExp, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions = {}) { @@ -106,7 +114,16 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO }, packagerOptions), checkOptions) if (checkOptions.packed != null) { - await checkOptions.packed(projectDir, outDir) + function base(platform: Platform): string { + return path.join(outDir, `${platform.buildConfigurationKey}${platform === Platform.MAC ? "" : "-unpacked"}`) + } + + await checkOptions.packed({ + projectDir: projectDir, + outDir: outDir, + getResources: platform => path.join(base(platform), "resources"), + getContent: platform => base(platform), + }) } } finally { diff --git a/test/src/macPackagerTest.ts b/test/src/macPackagerTest.ts index 3e4330fd54b..6ec311abd06 100644 --- a/test/src/macPackagerTest.ts +++ b/test/src/macPackagerTest.ts @@ -110,10 +110,10 @@ else { writeFile(path.join(projectDir, "build", "entitlements.mac.plist"), ""), writeFile(path.join(projectDir, "build", "entitlements.mac.inherit.plist"), ""), ]), - packed: projectDir => { + packed: context => { assertThat(platformPackager.effectiveSignOptions).hasProperties({ - entitlements: path.join(projectDir, "build", "entitlements.mac.plist"), - "entitlements-inherit": path.join(projectDir, "build", "entitlements.mac.inherit.plist"), + entitlements: path.join(context.projectDir, "build", "entitlements.mac.plist"), + "entitlements-inherit": path.join(context.projectDir, "build", "entitlements.mac.inherit.plist"), }) return BluebirdPromise.resolve() } @@ -178,10 +178,10 @@ test.ifOsx("custom background - new way", () => { } }) ]), - packed: async (projectDir) => { + packed: async context => { assertThat(platformPackager.effectiveDistOptions.background).isEqualTo(customBackground) assertThat(platformPackager.effectiveDistOptions.icon).isEqualTo("foo.icns") - assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(projectDir, "customIcon.icns")) + assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(context.projectDir, "customIcon.icns")) }, }) }) diff --git a/test/src/nsisTest.ts b/test/src/nsisTest.ts index f0b8eed88fe..99cb4a7ff2f 100644 --- a/test/src/nsisTest.ts +++ b/test/src/nsisTest.ts @@ -26,8 +26,8 @@ test("one-click", app({ }, { useTempDir: true, signed: true, - packed: (projectDir, outDir) => { - return doTest(outDir, true) + packed: context => { + return doTest(context.outDir, true) } })) @@ -54,8 +54,8 @@ test.ifDevOrLinuxCi("perMachine, no run after finish", app({ let headerIconPath = path.join(projectDir, "build", "foo.ico") return copy(getTestAsset("headerIcon.ico"), headerIconPath) }, - packed: (projectDir, outDir) => { - return doTest(outDir, false) + packed: context => { + return doTest(context.outDir, false) }, })) @@ -194,14 +194,14 @@ test.ifNotCiOsx("boring, MUI_HEADER as option", () => { test.ifDevOrLinuxCi("custom include", () => assertPack("test-app-one", {targets: nsisTarget}, { projectDirCreated: projectDir => copy(getTestAsset("installer.nsh"), path.join(projectDir, "build", "installer.nsh")), - packed: projectDir => BluebirdPromise.all([ - assertThat(path.join(projectDir, "build", "customHeader")).isFile(), - assertThat(path.join(projectDir, "build", "customInit")).isFile(), - assertThat(path.join(projectDir, "build", "customInstall")).isFile(), + packed: context => BluebirdPromise.all([ + assertThat(path.join(context.projectDir, "build", "customHeader")).isFile(), + assertThat(path.join(context.projectDir, "build", "customInit")).isFile(), + assertThat(path.join(context.projectDir, "build", "customInstall")).isFile(), ]), })) test.ifDevOrLinuxCi("custom script", app({targets: nsisTarget}, { projectDirCreated: projectDir => copy(getTestAsset("installer.nsi"), path.join(projectDir, "build", "installer.nsi")), - packed: projectDir => assertThat(path.join(projectDir, "build", "customInstallerScript")).isFile(), + packed: context => assertThat(path.join(context.projectDir, "build", "customInstallerScript")).isFile(), })) \ No newline at end of file diff --git a/test/src/winPackagerTest.ts b/test/src/winPackagerTest.ts index 979749b2b6f..2cf1ea13fdd 100755 --- a/test/src/winPackagerTest.ts +++ b/test/src/winPackagerTest.ts @@ -108,8 +108,8 @@ test.ifOsx("custom icon", () => { } }) ]), - packed: async (projectDir) => { - assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(projectDir, "customIcon.ico")) + packed: async context => { + assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(context.projectDir, "customIcon.ico")) return BluebirdPromise.resolve() }, })