From 0bba4fe51d7f6b1e7f584e81883f27140f12c3f7 Mon Sep 17 00:00:00 2001 From: develar Date: Tue, 28 Feb 2017 13:49:35 +0100 Subject: [PATCH] fix: dmg/pkg in the out dir, not in the subdir mac BREAKING CHANGE: dmg/pkg in the out dir, not in the subdir mac --- .idea/dictionaries/develar.xml | 1 + packages/electron-builder/src/macPackager.ts | 4 +- test/out/__snapshots__/BuildTest.js.snap | 87 ------------ test/out/__snapshots__/ExtraBuildTest.js.snap | 88 ++++++++++++ test/out/__snapshots__/filesTest.js.snap | 21 +-- test/out/linux/__snapshots__/debTest.js.snap | 10 +- test/out/linux/__snapshots__/fpmTest.js.snap | 35 ++++- .../__snapshots__/linuxArchiveTest.js.snap | 15 ++- .../__snapshots__/linuxPackagerTest.js.snap | 10 +- test/out/linux/__snapshots__/snapTest.js.snap | 5 +- .../mac/__snapshots__/macPackagerTest.js.snap | 32 ++--- .../__snapshots__/installerTest.js.snap | 46 +++---- .../oneClickInstallerTest.js.snap | 123 +++++++++-------- .../__snapshots__/squirrelWindowsTest.js.snap | 27 ++-- test/src/BuildTest.ts | 93 +------------ test/src/ExtraBuildTest.ts | 95 +++++++++++++ test/src/helpers/CheckingPackager.ts | 81 ++++++++++++ test/src/helpers/packTester.ts | 125 ++++-------------- test/src/mac/dmgTest.ts | 4 +- test/src/mac/macArchiveTest.ts | 5 +- test/src/mac/masTest.ts | 3 +- test/src/windows/squirrelWindowsTest.ts | 3 +- test/src/windows/winPackagerTest.ts | 3 +- 23 files changed, 484 insertions(+), 432 deletions(-) create mode 100644 test/out/__snapshots__/ExtraBuildTest.js.snap create mode 100644 test/src/ExtraBuildTest.ts create mode 100644 test/src/helpers/CheckingPackager.ts diff --git a/.idea/dictionaries/develar.xml b/.idea/dictionaries/develar.xml index 84ca243227c..2d1f41f16fb 100644 --- a/.idea/dictionaries/develar.xml +++ b/.idea/dictionaries/develar.xml @@ -165,6 +165,7 @@ prerelease productbuild progexe + proguard promisify psmdcp pulseaudio diff --git a/packages/electron-builder/src/macPackager.ts b/packages/electron-builder/src/macPackager.ts index 367cf6c62c1..be4694594d8 100644 --- a/packages/electron-builder/src/macPackager.ts +++ b/packages/electron-builder/src/macPackager.ts @@ -52,11 +52,11 @@ export default class MacPackager extends PlatformPackager { break case "dmg": - mapper("dmg", outDir => new DmgTarget(this, path.join(outDir, "mac"))) + mapper("dmg", outDir => new DmgTarget(this, outDir)) break case "pkg": - mapper("pkg", outDir => new PkgTarget(this, path.join(outDir, "mac"))) + mapper("pkg", outDir => new PkgTarget(this, outDir)) break default: diff --git a/test/out/__snapshots__/BuildTest.js.snap b/test/out/__snapshots__/BuildTest.js.snap index 4321c110971..cc5a3149500 100644 --- a/test/out/__snapshots__/BuildTest.js.snap +++ b/test/out/__snapshots__/BuildTest.js.snap @@ -237,90 +237,3 @@ Object { }, } `; - -exports[`sign custom buildResources and output dirs: linux 1`] = ` -Array [ - "TestApp-1.1.0-x86_64.AppImage", -] -`; - -exports[`sign custom buildResources and output dirs: win 1`] = ` -Array [ - "Test App ßW Setup 1.1.0.exe", -] -`; - -exports[`sign custom buildResources and output dirs: win 2`] = ` -Array [ - "TestApp-Setup-1.1.0.exe", -] -`; - -exports[`sign scheme validation 1`] = ` -"Config is invalid: -{ - \\"foo\\": \\"Unknown option\\", - \\"mac\\": [ - { - \\"foo\\": \\"Unknown option\\" - }, - \\"Invalid option object\\" - ] -} - -Raw validation errors: [ - { - \\"keyword\\": \\"additionalProperties\\", - \\"dataPath\\": \\"\\", - \\"schemaPath\\": \\"#/additionalProperties\\", - \\"params\\": { - \\"additionalProperty\\": \\"foo\\" - }, - \\"message\\": \\"should NOT have additional properties\\" - }, - { - \\"keyword\\": \\"additionalProperties\\", - \\"dataPath\\": \\".mac\\", - \\"schemaPath\\": \\"#/additionalProperties\\", - \\"params\\": { - \\"additionalProperty\\": \\"foo\\" - }, - \\"message\\": \\"should NOT have additional properties\\" - }, - { - \\"keyword\\": \\"type\\", - \\"dataPath\\": \\".mac\\", - \\"schemaPath\\": \\"#/properties/mac/anyOf/1/type\\", - \\"params\\": { - \\"type\\": \\"null\\" - }, - \\"message\\": \\"should be null\\" - }, - { - \\"keyword\\": \\"anyOf\\", - \\"dataPath\\": \\".mac\\", - \\"schemaPath\\": \\"#/properties/mac/anyOf\\", - \\"params\\": {}, - \\"message\\": \\"should match some schema in anyOf\\" - } -]" -`; - -exports[`sign scheme validation 2 1`] = ` -"Config is invalid: -{ - \\"appId\\": \\"Should be null,string\\" -} - -Raw validation errors: [ - { - \\"keyword\\": \\"type\\", - \\"dataPath\\": \\".appId\\", - \\"schemaPath\\": \\"#/properties/appId/type\\", - \\"params\\": { - \\"type\\": \\"null,string\\" - }, - \\"message\\": \\"should be null,string\\" - } -]" -`; diff --git a/test/out/__snapshots__/ExtraBuildTest.js.snap b/test/out/__snapshots__/ExtraBuildTest.js.snap new file mode 100644 index 00000000000..b78c9509dce --- /dev/null +++ b/test/out/__snapshots__/ExtraBuildTest.js.snap @@ -0,0 +1,88 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`custom buildResources and output dirs: linux 1`] = ` +Array [ + Object { + "file": "TestApp-1.1.0-x86_64.AppImage", + "safeArtifactName": undefined, + }, +] +`; + +exports[`custom buildResources and output dirs: win 1`] = ` +Array [ + Object { + "file": "Test App ßW Setup 1.1.0.exe", + "safeArtifactName": "TestApp-Setup-1.1.0.exe", + }, +] +`; + +exports[`scheme validation 1`] = ` +"Config is invalid: +{ + \\"foo\\": \\"Unknown option\\", + \\"mac\\": [ + { + \\"foo\\": \\"Unknown option\\" + }, + \\"Invalid option object\\" + ] +} + +Raw validation errors: [ + { + \\"keyword\\": \\"additionalProperties\\", + \\"dataPath\\": \\"\\", + \\"schemaPath\\": \\"#/additionalProperties\\", + \\"params\\": { + \\"additionalProperty\\": \\"foo\\" + }, + \\"message\\": \\"should NOT have additional properties\\" + }, + { + \\"keyword\\": \\"additionalProperties\\", + \\"dataPath\\": \\".mac\\", + \\"schemaPath\\": \\"#/additionalProperties\\", + \\"params\\": { + \\"additionalProperty\\": \\"foo\\" + }, + \\"message\\": \\"should NOT have additional properties\\" + }, + { + \\"keyword\\": \\"type\\", + \\"dataPath\\": \\".mac\\", + \\"schemaPath\\": \\"#/properties/mac/anyOf/1/type\\", + \\"params\\": { + \\"type\\": \\"null\\" + }, + \\"message\\": \\"should be null\\" + }, + { + \\"keyword\\": \\"anyOf\\", + \\"dataPath\\": \\".mac\\", + \\"schemaPath\\": \\"#/properties/mac/anyOf\\", + \\"params\\": {}, + \\"message\\": \\"should match some schema in anyOf\\" + } +]" +`; + +exports[`scheme validation 2 1`] = ` +"Config is invalid: +{ + \\"appId\\": \\"Should be null,string\\" +} + +Raw validation errors: [ + { + \\"keyword\\": \\"type\\", + \\"dataPath\\": \\".appId\\", + \\"schemaPath\\": \\"#/properties/appId/type\\", + \\"params\\": { + \\"type\\": \\"null,string\\" + }, + \\"message\\": \\"should be null,string\\" + } +]" +`; diff --git a/test/out/__snapshots__/filesTest.js.snap b/test/out/__snapshots__/filesTest.js.snap index 0df08ccf746..b90783f6c97 100644 --- a/test/out/__snapshots__/filesTest.js.snap +++ b/test/out/__snapshots__/filesTest.js.snap @@ -4,14 +4,17 @@ exports[`expand not defined env 1`] = `"Env FOO_NOT_DEFINED is not defined"`; exports[`extraResources on Linux and Windows 1`] = ` Array [ - "RELEASES", - "Test App ßW Setup 1.1.0.exe", - "TestApp-1.1.0-full.nupkg", -] -`; - -exports[`extraResources on Linux and Windows 2`] = ` -Array [ - "TestApp-Setup-1.1.0.exe", + Object { + "file": "Test App ßW Setup 1.1.0.exe", + "safeArtifactName": "TestApp-Setup-1.1.0.exe", + }, + Object { + "file": "TestApp-1.1.0-full.nupkg", + "safeArtifactName": undefined, + }, + Object { + "file": "RELEASES", + "safeArtifactName": undefined, + }, ] `; diff --git a/test/out/linux/__snapshots__/debTest.js.snap b/test/out/linux/__snapshots__/debTest.js.snap index 12ee759de19..e1cdbdaf536 100644 --- a/test/out/linux/__snapshots__/debTest.js.snap +++ b/test/out/linux/__snapshots__/debTest.js.snap @@ -2,7 +2,10 @@ exports[`arm deb 1`] = ` Array [ - "TestApp_1.1.0_armv7l.deb", + Object { + "file": "TestApp_1.1.0_armv7l.deb", + "safeArtifactName": undefined, + }, ] `; @@ -20,6 +23,9 @@ Categories=Development; exports[`deb 1`] = ` Array [ - "TestApp_1.1.0_amd64.deb", + Object { + "file": "TestApp_1.1.0_amd64.deb", + "safeArtifactName": undefined, + }, ] `; diff --git a/test/out/linux/__snapshots__/fpmTest.js.snap b/test/out/linux/__snapshots__/fpmTest.js.snap index 0e5497403f5..bdfbaa83c7c 100644 --- a/test/out/linux/__snapshots__/fpmTest.js.snap +++ b/test/out/linux/__snapshots__/fpmTest.js.snap @@ -2,17 +2,38 @@ exports[`rpm and tar.gz 1`] = ` Array [ - "TestApp-1.1.0.rpm", - "TestApp-1.1.0.tar.gz", + Object { + "file": "TestApp-1.1.0.rpm", + "safeArtifactName": undefined, + }, + Object { + "file": "TestApp-1.1.0.tar.gz", + "safeArtifactName": "TestApp-1.1.0.tar.gz", + }, ] `; exports[`targets 1`] = ` Array [ - "TestApp-1.1.0.7z", - "TestApp-1.1.0.freebsd", - "TestApp-1.1.0.pacman", - "TestApp-1.1.0.sh", - "TestApp-1.1.0.zip", + Object { + "file": "TestApp-1.1.0.7z", + "safeArtifactName": "TestApp-1.1.0.7z", + }, + Object { + "file": "TestApp-1.1.0.freebsd", + "safeArtifactName": undefined, + }, + Object { + "file": "TestApp-1.1.0.pacman", + "safeArtifactName": undefined, + }, + Object { + "file": "TestApp-1.1.0.sh", + "safeArtifactName": undefined, + }, + Object { + "file": "TestApp-1.1.0.zip", + "safeArtifactName": "TestApp-1.1.0.zip", + }, ] `; diff --git a/test/out/linux/__snapshots__/linuxArchiveTest.js.snap b/test/out/linux/__snapshots__/linuxArchiveTest.js.snap index c18a5506aa6..7ef14d3b198 100644 --- a/test/out/linux/__snapshots__/linuxArchiveTest.js.snap +++ b/test/out/linux/__snapshots__/linuxArchiveTest.js.snap @@ -2,8 +2,17 @@ exports[`tar 1`] = ` Array [ - "TestApp-1.1.0.tar.bz2", - "TestApp-1.1.0.tar.lz", - "TestApp-1.1.0.tar.xz", + Object { + "file": "TestApp-1.1.0.tar.bz2", + "safeArtifactName": "TestApp-1.1.0.tar.bz2", + }, + Object { + "file": "TestApp-1.1.0.tar.lz", + "safeArtifactName": "TestApp-1.1.0.tar.lz", + }, + Object { + "file": "TestApp-1.1.0.tar.xz", + "safeArtifactName": "TestApp-1.1.0.tar.xz", + }, ] `; diff --git a/test/out/linux/__snapshots__/linuxPackagerTest.js.snap b/test/out/linux/__snapshots__/linuxPackagerTest.js.snap index b856da6b77d..13debef6948 100644 --- a/test/out/linux/__snapshots__/linuxPackagerTest.js.snap +++ b/test/out/linux/__snapshots__/linuxPackagerTest.js.snap @@ -15,13 +15,19 @@ Categories=Development; exports[`AppImage 1`] = ` Array [ - "TestApp-1.1.0-x86_64.AppImage", + Object { + "file": "TestApp-1.1.0-x86_64.AppImage", + "safeArtifactName": undefined, + }, ] `; exports[`icons from ICNS 1`] = ` Array [ - "TestApp-1.1.0-x86_64.AppImage", + Object { + "file": "TestApp-1.1.0-x86_64.AppImage", + "safeArtifactName": undefined, + }, ] `; diff --git a/test/out/linux/__snapshots__/snapTest.js.snap b/test/out/linux/__snapshots__/snapTest.js.snap index d056dc6b797..688962d4c70 100644 --- a/test/out/linux/__snapshots__/snapTest.js.snap +++ b/test/out/linux/__snapshots__/snapTest.js.snap @@ -257,6 +257,9 @@ Categories=Development; exports[`snap 1`] = ` Array [ - "sep_1.1.0_amd64.snap", + Object { + "file": "sep_1.1.0_amd64.snap", + "safeArtifactName": undefined, + }, ] `; diff --git a/test/out/mac/__snapshots__/macPackagerTest.js.snap b/test/out/mac/__snapshots__/macPackagerTest.js.snap index 8a7a9dd9d23..56102c1e790 100644 --- a/test/out/mac/__snapshots__/macPackagerTest.js.snap +++ b/test/out/mac/__snapshots__/macPackagerTest.js.snap @@ -3,6 +3,22 @@ exports[`electronDist 1`] = `"ENOENT: no such file or directory, scandir '/Electron.app'"`; exports[`one-package 1`] = ` +Array [ + Object { + "file": "latest-mac.json", + }, + Object { + "file": "Test App ßW-1.1.0.dmg", + "safeArtifactName": "TestApp-1.1.0.dmg", + }, + Object { + "file": "Test App ßW-1.1.0-mac.zip", + "safeArtifactName": "TestApp-1.1.0-mac.zip", + }, +] +`; + +exports[`one-package 2`] = ` Object { "BuildMachineOSBuild": "15G31", "CFBundleDisplayName": "Test App ßW", @@ -54,22 +70,6 @@ Object { } `; -exports[`one-package 2`] = ` -Array [ - Object { - "file": "latest-mac.json", - }, - Object { - "file": "Test App ßW-1.1.0.dmg", - "safeArtifactName": "TestApp-1.1.0.dmg", - }, - Object { - "file": "Test App ßW-1.1.0-mac.zip", - "safeArtifactName": "TestApp-1.1.0-mac.zip", - }, -] -`; - exports[`one-package 3`] = ` Object { "releaseDate": "1970-01-01T00:00:00.000Z", diff --git a/test/out/windows/__snapshots__/installerTest.js.snap b/test/out/windows/__snapshots__/installerTest.js.snap index fd99e6283c3..b8b84b8eeab 100644 --- a/test/out/windows/__snapshots__/installerTest.js.snap +++ b/test/out/windows/__snapshots__/installerTest.js.snap @@ -2,17 +2,14 @@ exports[`allowToChangeInstallationDirectory 1`] = ` Array [ - "Test Custom Installation Dir Setup 1.1.0.exe", + Object { + "file": "Test Custom Installation Dir Setup 1.1.0.exe", + "safeArtifactName": "test-custom-inst-dir-Setup-1.1.0.exe", + }, ] `; exports[`allowToChangeInstallationDirectory 2`] = ` -Array [ - "test-custom-inst-dir-Setup-1.1.0.exe", -] -`; - -exports[`allowToChangeInstallationDirectory 3`] = ` Object { "owner": "foo", "provider": "github", @@ -20,7 +17,7 @@ Object { } `; -exports[`allowToChangeInstallationDirectory 4`] = ` +exports[`allowToChangeInstallationDirectory 3`] = ` Object { "githubArtifactName": "test-custom-inst-dir-Setup-1.1.0.exe", "path": "Test Custom Installation Dir Setup 1.1.0.exe", @@ -30,36 +27,27 @@ Object { exports[`boring 1`] = ` Array [ - "Test App ßW Setup 1.1.0.exe", -] -`; - -exports[`boring 2`] = ` -Array [ - "TestApp-Setup-1.1.0.exe", + Object { + "file": "Test App ßW Setup 1.1.0.exe", + "safeArtifactName": "TestApp-Setup-1.1.0.exe", + }, ] `; exports[`boring, only perMachine 1`] = ` Array [ - "Test App ßW Setup 1.1.0.exe", -] -`; - -exports[`boring, only perMachine 2`] = ` -Array [ - "TestApp-Setup-1.1.0.exe", + Object { + "file": "Test App ßW Setup 1.1.0.exe", + "safeArtifactName": "TestApp-Setup-1.1.0.exe", + }, ] `; exports[`portable 1`] = ` Array [ - "Test App ßW 1.1.0.exe", -] -`; - -exports[`portable 2`] = ` -Array [ - "TestApp-1.1.0.exe", + Object { + "file": "Test App ßW 1.1.0.exe", + "safeArtifactName": "TestApp-1.1.0.exe", + }, ] `; diff --git a/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap b/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap index d7754d6b280..d07818f5829 100644 --- a/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap +++ b/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap @@ -2,25 +2,19 @@ exports[`custom include 1`] = ` Array [ - "Test App ßW Setup 1.1.0.exe", -] -`; - -exports[`custom include 2`] = ` -Array [ - "TestApp-Setup-1.1.0.exe", + Object { + "file": "Test App ßW Setup 1.1.0.exe", + "safeArtifactName": "TestApp-Setup-1.1.0.exe", + }, ] `; exports[`custom script 1`] = ` Array [ - "Test App ßW Setup 1.1.0.exe", -] -`; - -exports[`custom script 2`] = ` -Array [ - "TestApp-Setup-1.1.0.exe", + Object { + "file": "Test App ßW Setup 1.1.0.exe", + "safeArtifactName": "TestApp-Setup-1.1.0.exe", + }, ] `; @@ -28,29 +22,23 @@ exports[`file associations only perMachine 1`] = `"Please set perMachine to true exports[`menuCategory 1`] = ` Array [ - "Test Menu Category CustomName 1.1.0.exe", -] -`; - -exports[`menuCategory 2`] = ` -Array [ - "test-menu-category-Setup-1.1.0.exe", + Object { + "file": "Test Menu Category CustomName 1.1.0.exe", + "safeArtifactName": "test-menu-category-Setup-1.1.0.exe", + }, ] `; exports[`one-click 1`] = ` Array [ - "Test App ßW Setup 1.1.0.exe", + Object { + "file": "Test App ßW Setup 1.1.0.exe", + "safeArtifactName": "TestApp-Setup-1.1.0.exe", + }, ] `; exports[`one-click 2`] = ` -Array [ - "TestApp-Setup-1.1.0.exe", -] -`; - -exports[`one-click 3`] = ` Object { "owner": "actperepo", "package": "TestApp", @@ -60,25 +48,24 @@ Object { exports[`perMachine, no run after finish 1`] = ` Array [ - "TestApp Setup 1.1.0.exe", - "latest.yml", + Object { + "file": "latest.yml", + }, + Object { + "file": "TestApp Setup 1.1.0.exe", + "safeArtifactName": "TestApp-Setup-1.1.0.exe", + }, ] `; exports[`perMachine, no run after finish 2`] = ` -Array [ - "TestApp-Setup-1.1.0.exe", -] -`; - -exports[`perMachine, no run after finish 3`] = ` Object { "provider": "generic", "url": "https://develar.s3.amazonaws.com/test/win", } `; -exports[`perMachine, no run after finish 4`] = ` +exports[`perMachine, no run after finish 3`] = ` Object { "githubArtifactName": "TestApp-Setup-1.1.0.exe", "path": "TestApp Setup 1.1.0.exe", @@ -88,33 +75,39 @@ Object { exports[`web installer (default github) 1`] = ` Array [ - "Test App ßW Web Setup 1.1.0.exe", - "TestApp-1.1.0-ia32.nsis.7z", - "TestApp-1.1.0-x64.nsis.7z", + Object { + "file": "TestApp-1.1.0-ia32.nsis.7z", + "safeArtifactName": undefined, + }, + Object { + "file": "TestApp-1.1.0-x64.nsis.7z", + "safeArtifactName": undefined, + }, + Object { + "file": "Test App ßW Web Setup 1.1.0.exe", + "safeArtifactName": "TestApp-WebSetup-1.1.0.exe", + }, ] `; exports[`web installer (default github) 2`] = ` Array [ - "TestApp-WebSetup-1.1.0.exe", + Object { + "file": "TestApp-1.1.0-ia32.nsis.7z", + "safeArtifactName": undefined, + }, + Object { + "file": "TestApp-1.1.0-x64.nsis.7z", + "safeArtifactName": undefined, + }, + Object { + "file": "Test App ßW Web Setup 1.1.0.exe", + "safeArtifactName": "TestApp-WebSetup-1.1.0.exe", + }, ] `; exports[`web installer (default github) 3`] = ` -Array [ - "Test App ßW Web Setup 1.1.0.exe", - "TestApp-1.1.0-ia32.nsis.7z", - "TestApp-1.1.0-x64.nsis.7z", -] -`; - -exports[`web installer (default github) 4`] = ` -Array [ - "TestApp-WebSetup-1.1.0.exe", -] -`; - -exports[`web installer (default github) 5`] = ` Object { "githubArtifactName": "TestApp-WebSetup-1.1.0.exe", "path": "Test App ßW Web Setup 1.1.0.exe", @@ -124,14 +117,16 @@ Object { exports[`web installer 1`] = ` Array [ - "Test App ßW Web Setup 1.1.0.exe", - "TestApp-1.1.0-x64.nsis.7z", - "latest.yml", -] -`; - -exports[`web installer 2`] = ` -Array [ - "TestApp-WebSetup-1.1.0.exe", + Object { + "file": "latest.yml", + }, + Object { + "file": "TestApp-1.1.0-x64.nsis.7z", + "safeArtifactName": undefined, + }, + Object { + "file": "Test App ßW Web Setup 1.1.0.exe", + "safeArtifactName": "TestApp-WebSetup-1.1.0.exe", + }, ] `; diff --git a/test/out/windows/__snapshots__/squirrelWindowsTest.js.snap b/test/out/windows/__snapshots__/squirrelWindowsTest.js.snap index 108892a3d8e..27cda917aeb 100644 --- a/test/out/windows/__snapshots__/squirrelWindowsTest.js.snap +++ b/test/out/windows/__snapshots__/squirrelWindowsTest.js.snap @@ -2,16 +2,21 @@ exports[`Squirrel.Windows 1`] = ` Array [ - "RELEASES", - "Test App ßW Setup 1.1.0.exe", - "Test App ßW-1.1.0-win.zip", - "TestApp-1.1.0-full.nupkg", -] -`; - -exports[`Squirrel.Windows 2`] = ` -Array [ - "TestApp-1.1.0-win.zip", - "TestApp-Setup-1.1.0.exe", + Object { + "file": "Test App ßW Setup 1.1.0.exe", + "safeArtifactName": "TestApp-Setup-1.1.0.exe", + }, + Object { + "file": "TestApp-1.1.0-full.nupkg", + "safeArtifactName": undefined, + }, + Object { + "file": "RELEASES", + "safeArtifactName": undefined, + }, + Object { + "file": "Test App ßW-1.1.0-win.zip", + "safeArtifactName": "TestApp-1.1.0-win.zip", + }, ] `; diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts index 19b7a36c5c5..d7989dd08d4 100644 --- a/test/src/BuildTest.ts +++ b/test/src/BuildTest.ts @@ -1,15 +1,14 @@ import { extractFile } from "asar" import BluebirdPromise from "bluebird-lst" import { Arch, BuildOptions, DIR_TARGET, Platform } from "electron-builder" -import { build, normalizeOptions } from "electron-builder/out/builder" +import { normalizeOptions } from "electron-builder/out/builder" import { createYargs } from "electron-builder/out/cli/cliOptions" import { checkWineVersion } from "electron-builder/out/packager" import { move, outputJson } from "fs-extra-p" import isCi from "is-ci" import * as path from "path" import { ELECTRON_VERSION } from "./helpers/config" -import { assertThat } from "./helpers/fileAssert" -import { allPlatforms, app, appThrows, appTwo, appTwoThrows, assertPack, getPossiblePlatforms, modifyPackageJson, packageJson } from "./helpers/packTester" +import { allPlatforms, app, appTwo, appTwoThrows, assertPack, getPossiblePlatforms, modifyPackageJson, packageJson } from "./helpers/packTester" const linuxDirTarget = Platform.LINUX.createTarget(DIR_TARGET) @@ -58,26 +57,6 @@ test("cli", async () => { expect(parseExtraMetadata("--em.foo=bar")) }) -function createBuildResourcesTest(platform: Platform) { - return app({ - // only dir - avoid DMG - targets: platform.createTarget(platform === Platform.MAC ? DIR_TARGET : null), - config: { - directories: { - buildResources: "custom", - output: "customDist", - // https://github.com/electron-userland/electron-builder/issues/601 - app: ".", - } - }, - }, { - packed: async context => { - await assertThat(path.join(context.projectDir, "customDist")).isDirectory() - }, - projectDirCreated: projectDir => move(path.join(projectDir, "build"), path.join(projectDir, "custom")) - }) -} - test("build in the app package.json", appTwoThrows(linuxDirTarget, { projectDirCreated: it => modifyPackageJson(it, data => { data.build = { @@ -193,70 +172,4 @@ test.ifDevOrLinuxCi("smart unpack", app({ test("wine version", async () => { await checkWineVersion(BluebirdPromise.resolve("1.9.23 (Staging)")) await checkWineVersion(BluebirdPromise.resolve("2.0-rc2")) -}) - -describe.ifAll("sign", () => { - test.ifNotWindows("custom buildResources and output dirs: mac", createBuildResourcesTest(Platform.MAC)) - test.ifNotCiMac("custom buildResources and output dirs: win", createBuildResourcesTest(Platform.WINDOWS)) - test.ifNotWindows("custom buildResources and output dirs: linux", createBuildResourcesTest(Platform.LINUX)) - - test.ifDevOrLinuxCi("prepackaged", app({ - targets: linuxDirTarget, - }, { - packed: async (context) => { - await build(normalizeOptions({ - prepackaged: path.join(context.outDir, "linux-unpacked"), - project: context.projectDir, - linux: ["deb"] - })) - await assertThat(path.join(context.projectDir, "dist", "TestApp_1.1.0_amd64.deb")).isFile() - } - })) - - test.ifDevOrLinuxCi("scheme validation", appThrows({ - targets: linuxDirTarget, - config: { - foo: 123, - mac: { - foo: 12123, - }, - }, - })) - - test.ifDevOrLinuxCi("scheme validation 2", appThrows({ - targets: linuxDirTarget, - config: { - appId: 123, - }, - })) - - // https://github.com/electron-userland/electron-builder/issues/1302 - test.ifDevOrLinuxCi("scheme validation extraFiles", app({ - targets: linuxDirTarget, - config: { - "extraFiles": [ - "lib/*.jar", - "lib/Proguard/**/*", - { - "from": "lib/", - "to": ".", - "filter": [ - "*.dll" - ] - }, - { - "from": "lib/", - "to": ".", - "filter": [ - "*.exe" - ] - }, - "BLClient/BLClient.json", - { - "from": "include/", - "to": "." - } - ], - }, - })) -}) +}) \ No newline at end of file diff --git a/test/src/ExtraBuildTest.ts b/test/src/ExtraBuildTest.ts new file mode 100644 index 00000000000..bf2c7d62022 --- /dev/null +++ b/test/src/ExtraBuildTest.ts @@ -0,0 +1,95 @@ +import { DIR_TARGET, Platform } from "electron-builder" +import { build, normalizeOptions } from "electron-builder/out/builder" +import { move } from "fs-extra-p" +import * as path from "path" +import { assertThat } from "./helpers/fileAssert" +import { app, appThrows } from "./helpers/packTester" + +function createBuildResourcesTest(platform: Platform) { + return app({ + // only dir - avoid DMG + targets: platform.createTarget(platform === Platform.MAC ? DIR_TARGET : null), + config: { + directories: { + buildResources: "custom", + output: "customDist", + // https://github.com/electron-userland/electron-builder/issues/601 + app: ".", + } + }, + }, { + packed: async context => { + await assertThat(path.join(context.projectDir, "customDist")).isDirectory() + }, + projectDirCreated: projectDir => move(path.join(projectDir, "build"), path.join(projectDir, "custom")) + }) +} + +const linuxDirTarget = Platform.LINUX.createTarget(DIR_TARGET) + +test.ifAll.ifNotWindows("custom buildResources and output dirs: mac", createBuildResourcesTest(Platform.MAC)) +test.ifAll.ifNotCiMac("custom buildResources and output dirs: win", createBuildResourcesTest(Platform.WINDOWS)) +test.ifAll.ifNotWindows("custom buildResources and output dirs: linux", createBuildResourcesTest(Platform.LINUX)) + +test.ifAll.ifDevOrLinuxCi("prepackaged", app({ + targets: linuxDirTarget, +}, { + packed: async (context) => { + await build(normalizeOptions({ + prepackaged: path.join(context.outDir, "linux-unpacked"), + project: context.projectDir, + linux: ["deb"], + config: { + compression: "store" + } + })) + await assertThat(path.join(context.projectDir, "dist", "TestApp_1.1.0_amd64.deb")).isFile() + } +})) + +test.ifAll.ifDevOrLinuxCi("scheme validation", appThrows({ + targets: linuxDirTarget, + config: { + foo: 123, + mac: { + foo: 12123, + }, + }, +})) + +test.ifAll.ifDevOrLinuxCi("scheme validation 2", appThrows({ + targets: linuxDirTarget, + config: { + appId: 123, + }, +})) + +// https://github.com/electron-userland/electron-builder/issues/1302 +test.ifAll.ifDevOrLinuxCi("scheme validation extraFiles", app({ + targets: linuxDirTarget, + config: { + "extraFiles": [ + "lib/*.jar", + "lib/Proguard/**/*", + { + "from": "lib/", + "to": ".", + "filter": [ + "*.dll" + ] + }, + { + "from": "lib/", + "to": ".", + "filter": [ + "*.exe" + ] + }, + "BLClient/BLClient.json", + { + "from": "include/", + "to": "." + } + ], + }, +})) diff --git a/test/src/helpers/CheckingPackager.ts b/test/src/helpers/CheckingPackager.ts new file mode 100644 index 00000000000..dbaadd1d581 --- /dev/null +++ b/test/src/helpers/CheckingPackager.ts @@ -0,0 +1,81 @@ +import { BuildInfo, MacOptions } from "electron-builder" +import { Arch, Target } from "electron-builder-core" +import SquirrelWindowsTarget from "electron-builder-squirrel-windows" +import OsXPackager from "electron-builder/out/macPackager" +import { DmgTarget } from "electron-builder/out/targets/dmg" +import { SignOptions } from "electron-builder/out/windowsCodeSign" +import { WinPackager } from "electron-builder/out/winPackager" +import { SignOptions as MacSignOptions } from "electron-macos-sign" + +export class CheckingWinPackager extends WinPackager { + effectiveDistOptions: any + signOptions: SignOptions | null + + constructor(info: BuildInfo) { + super(info) + } + + //noinspection JSUnusedLocalSymbols + async pack(outDir: string, arch: Arch, targets: Array, postAsyncTasks: Array>): Promise { + // skip pack + const helperClass: typeof SquirrelWindowsTarget = require("electron-builder-squirrel-windows").default + this.effectiveDistOptions = await (new helperClass(this, outDir).computeEffectiveDistOptions()) + + await this.sign(this.computeAppOutDir(outDir, arch)) + } + + //noinspection JSUnusedLocalSymbols + packageInDistributableFormat(appOutDir: string, arch: Arch, targets: Array, promises: Array>): void { + // skip + } + + //noinspection JSUnusedGlobalSymbols + protected async doSign(opts: SignOptions): Promise { + this.signOptions = opts + } +} + +export class CheckingMacPackager extends OsXPackager { + effectiveDistOptions: any + effectiveSignOptions: MacSignOptions + + constructor(info: BuildInfo) { + super(info) + } + + async pack(outDir: string, arch: Arch, targets: Array, postAsyncTasks: Array>): Promise { + for (const target of targets) { + // do not use instanceof to avoid dmg require + if (target.name === "dmg") { + this.effectiveDistOptions = await (target).computeDmgOptions() + break + } + } + // http://madole.xyz/babel-plugin-transform-async-to-module-method-gotcha/ + return await OsXPackager.prototype.pack.call(this, outDir, arch, targets, postAsyncTasks) + } + + //noinspection JSUnusedLocalSymbols + async doPack(outDir: string, appOutDir: string, platformName: string, arch: Arch, customBuildOptions: MacOptions, targets: Array) { + // skip + } + + //noinspection JSUnusedGlobalSymbols + async doSign(opts: MacSignOptions): Promise { + this.effectiveSignOptions = opts + } + + //noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols + async doFlat(appPath: string, outFile: string, identity: string, keychain?: string | null): Promise { + // skip + } + + //noinspection JSUnusedGlobalSymbols,JSUnusedLocalSymbols + packageInDistributableFormat(appOutDir: string, arch: Arch, targets: Array, promises: Array>): void { + // skip + } + + protected async writeUpdateInfo(appOutDir: string, outDir: string) { + // ignored + } +} diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index b12c1e63c27..ce5d8ba0917 100755 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -1,18 +1,12 @@ import DecompressZip from "decompress-zip" -import { Arch, ArtifactCreated, BuildInfo, Config, createTargets, DIR_TARGET, getArchSuffix, MacOptions, MacOsTargetName, Packager, PackagerOptions, Platform, Target } from "electron-builder" +import { Arch, ArtifactCreated, Config, createTargets, DIR_TARGET, getArchSuffix, MacOsTargetName, Packager, PackagerOptions, Platform, Target } from "electron-builder" import { CancellationToken } from "electron-builder-http/out/CancellationToken" -import SquirrelWindowsTarget from "electron-builder-squirrel-windows" import { convertVersion } from "electron-builder-squirrel-windows/out/squirrelPack" import { exec, getTempName, spawn } from "electron-builder-util" import { deepAssign } from "electron-builder-util/out/deepAssign" import { copyDir, FileCopier } from "electron-builder-util/out/fs" import { log, warn } from "electron-builder-util/out/log" -import OsXPackager from "electron-builder/out/macPackager" import { PublishManager } from "electron-builder/out/publish/PublishManager" -import { DmgTarget } from "electron-builder/out/targets/dmg" -import { SignOptions } from "electron-builder/out/windowsCodeSign" -import { WinPackager } from "electron-builder/out/winPackager" -import { SignOptions as MacSignOptions } from "electron-macos-sign" import { emptyDir, mkdir, readFile, readJson, remove, writeJson } from "fs-extra-p" import * as path from "path" import pathSorter from "path-sort" @@ -200,14 +194,32 @@ async function packAndCheck(outDir: string, packagerOptions: PackagerOptions, ch } const nameToTarget = platformToTarget.get(platform) + const platformArtifacts = artifacts.get(platform) + + const emptyTarget = {name: ""} + expect(platformArtifacts + .sort((a, b) => (a.target || emptyTarget).name.localeCompare((b.target || emptyTarget).name)) + .map(it => { + const result: any = Object.assign({}, it) + if (result.file != null) { + result.file = path.basename(result.file) + } + delete result.packager + delete result.target + delete result.publishConfig + return result + })).toMatchSnapshot() + if (platform === Platform.MAC) { - await checkMacResult(packager, packagerOptions, checkOptions, artifacts.get(Platform.MAC)) + const outDir = path.resolve(packager.projectDir, path.join((packager.config.directories == null ? null : packager.config.directories!.output) || "dist")) + const packedAppDir = path.join(outDir, nameToTarget.has("mas") ? "mas" : "mac", `${packager.appInfo.productFilename}.app`) + await checkMacResult(packager, packagerOptions, checkOptions, packedAppDir) } else if (platform === Platform.LINUX) { - await checkLinuxResult(outDir, packager, checkOptions, artifacts.get(Platform.LINUX), arch, nameToTarget) + await checkLinuxResult(outDir, packager, checkOptions, arch, nameToTarget) } else if (platform === Platform.WINDOWS) { - await checkWindowsResult(packager, checkOptions, artifacts.get(Platform.WINDOWS), nameToTarget) + await checkWindowsResult(packager, checkOptions, platformArtifacts, nameToTarget) } } } @@ -215,9 +227,7 @@ async function packAndCheck(outDir: string, packagerOptions: PackagerOptions, ch return packager } -async function checkLinuxResult(outDir: string, packager: Packager, checkOptions: AssertPackOptions, artifacts: Array, arch: Arch, nameToTarget: Map) { - expect(getFileNames(artifacts)).toMatchSnapshot() - +async function checkLinuxResult(outDir: string, packager: Packager, checkOptions: AssertPackOptions, arch: Arch, nameToTarget: Map) { if (!nameToTarget.has("deb")) { return } @@ -270,9 +280,8 @@ function parseDebControl(info: string): any { return metadata } -async function checkMacResult(packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, artifacts: Array) { +async function checkMacResult(packager: Packager, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions, packedAppDir: string) { const appInfo = packager.appInfo - const packedAppDir = path.join(path.dirname(artifacts.find(it => it.file != null && !it.file.endsWith("json")).file), `${appInfo.productFilename}.app`) const info = parsePlist(await readFile(path.join(packedAppDir, "Contents", "Info.plist"), "utf8")) expect(info).toMatchObject({ CFBundleDisplayName: appInfo.productName, @@ -292,30 +301,10 @@ async function checkMacResult(packager: Packager, packagerOptions: PackagerOptio const result = await exec("codesign", ["--verify", packedAppDir]) expect(result).not.toMatch(/is not signed at all/) } - - const emptyTarget = {name: ""} - expect(artifacts.sort((a, b) => (a.target || emptyTarget).name.localeCompare((b.target || emptyTarget).name)).map(it => { - const result: any = Object.assign({}, it) - if (result.file != null) { - result.file = path.basename(result.file) - } - delete result.packager - delete result.target - delete result.publishConfig - return result - })).toMatchSnapshot() -} - -function getFileNames(list: Array): Array { - return list.map(it => path.basename(it.file)).sort() } async function checkWindowsResult(packager: Packager, checkOptions: AssertPackOptions, artifacts: Array, nameToTarget: Map) { const appInfo = packager.appInfo - - expect(getFileNames(artifacts)).toMatchSnapshot() - expect(artifacts.map(it => it.safeArtifactName).filter(it => it != null).sort()).toMatchSnapshot() - let squirrel = false for (const target of nameToTarget.keys()) { if (target === "squirrel") { @@ -436,72 +425,6 @@ export function getPossiblePlatforms(type?: string): Map, postAsyncTasks: Array>): Promise { - // skip pack - const helperClass: typeof SquirrelWindowsTarget = require("electron-builder-squirrel-windows").default - this.effectiveDistOptions = await (new helperClass(this, outDir).computeEffectiveDistOptions()) - - await this.sign(this.computeAppOutDir(outDir, arch)) - } - - packageInDistributableFormat(appOutDir: string, arch: Arch, targets: Array, promises: Array>): void { - // skip - } - - protected async doSign(opts: SignOptions): Promise { - this.signOptions = opts - } -} - -export class CheckingMacPackager extends OsXPackager { - effectiveDistOptions: any - effectiveSignOptions: MacSignOptions - - constructor(info: BuildInfo) { - super(info) - } - - async pack(outDir: string, arch: Arch, targets: Array, postAsyncTasks: Array>): Promise { - for (const target of targets) { - // do not use instanceof to avoid dmg require - if (target.name === "dmg") { - this.effectiveDistOptions = await (target).computeDmgOptions() - break - } - } - // http://madole.xyz/babel-plugin-transform-async-to-module-method-gotcha/ - return await OsXPackager.prototype.pack.call(this, outDir, arch, targets, postAsyncTasks) - } - - async doPack(outDir: string, appOutDir: string, platformName: string, arch: Arch, customBuildOptions: MacOptions, targets: Array) { - // skip - } - - async doSign(opts: MacSignOptions): Promise { - this.effectiveSignOptions = opts - } - - async doFlat(appPath: string, outFile: string, identity: string, keychain?: string | null): Promise { - // skip - } - - packageInDistributableFormat(appOutDir: string, arch: Arch, targets: Array, promises: Array>): void { - // skip - } - - protected async writeUpdateInfo(appOutDir: string, outDir: string) { - // ignored - } -} - export function createMacTargetTest(target: Array) { return app({ targets: Platform.MAC.createTarget(), diff --git a/test/src/mac/dmgTest.ts b/test/src/mac/dmgTest.ts index b41340ff05c..36017fce20c 100644 --- a/test/src/mac/dmgTest.ts +++ b/test/src/mac/dmgTest.ts @@ -99,7 +99,7 @@ test.ifMac("unset dmg icon", app({ } }, { packed: (context) => { - return attachAndExecute(path.join(context.outDir, "mac/Test ß No Volume Icon-1.1.0.dmg"), false, () => { + return attachAndExecute(path.join(context.outDir, "Test ß No Volume Icon-1.1.0.dmg"), false, () => { return BluebirdPromise.all([ assertThat(path.join("/Volumes/Test ß No Volume Icon 1.1.0/.background/background.tiff")).isFile(), assertThat(path.join("/Volumes/Test ß No Volume Icon 1.1.0/.VolumeIcon.icns")).doesNotExist(), @@ -121,7 +121,7 @@ test.ifMac("no background", app({ } }, { packed: (context) => { - return attachAndExecute(path.join(context.outDir, "mac/NoBackground-1.1.0.dmg"), false, () => { + return attachAndExecute(path.join(context.outDir, "NoBackground-1.1.0.dmg"), false, () => { return assertThat(path.join("/Volumes/NoBackground 1.1.0/.background")).doesNotExist() }) } diff --git a/test/src/mac/macArchiveTest.ts b/test/src/mac/macArchiveTest.ts index d9c659910d9..ed1d4195374 100644 --- a/test/src/mac/macArchiveTest.ts +++ b/test/src/mac/macArchiveTest.ts @@ -26,12 +26,11 @@ test.ifMac("pkg scripts", app({ await symlink(path.join(getFixtureDir(), "pkg-scripts"), path.join(projectDir, "build", "pkg-scripts")) }, packed: async (context) => { - const macOutDir = context.getContent(Platform.MAC) - const pkgPath = path.join(macOutDir, "Test App ßW-1.1.0.pkg") + const pkgPath = path.join(context.outDir, "Test App ßW-1.1.0.pkg") const fileList = pathSorter(parseFileList(await exec("pkgutil", ["--payload-files", pkgPath]), false)) expect(fileList).toMatchSnapshot() - const unpackedDir = path.join(macOutDir, "pkg-unpacked") + const unpackedDir = path.join(context.outDir, "pkg-unpacked") await exec("pkgutil", ["--expand", pkgPath, unpackedDir]) const m: any = BluebirdPromise.promisify(parseString) diff --git a/test/src/mac/masTest.ts b/test/src/mac/masTest.ts index 7f7c36a39c7..0bedef65ba4 100644 --- a/test/src/mac/masTest.ts +++ b/test/src/mac/masTest.ts @@ -2,7 +2,8 @@ import BluebirdPromise from "bluebird-lst" import { Platform } from "electron-builder" import { writeFile } from "fs-extra-p" import * as path from "path" -import { assertPack, CheckingMacPackager, createMacTargetTest, signed } from "../helpers/packTester" +import { CheckingMacPackager } from "../helpers/CheckingPackager" +import { assertPack, createMacTargetTest, signed } from "../helpers/packTester" if (process.platform !== "darwin") { fit("Skip mas tests because platform is not macOS", () => { diff --git a/test/src/windows/squirrelWindowsTest.ts b/test/src/windows/squirrelWindowsTest.ts index 95ff662348e..9f6fe3d80a5 100644 --- a/test/src/windows/squirrelWindowsTest.ts +++ b/test/src/windows/squirrelWindowsTest.ts @@ -1,7 +1,8 @@ import BluebirdPromise from "bluebird-lst" import { Arch, Platform } from "electron-builder" import * as path from "path" -import { app, assertPack, CheckingWinPackager, copyTestAsset, modifyPackageJson } from "../helpers/packTester" +import { CheckingWinPackager } from "../helpers/CheckingPackager" +import { app, assertPack, copyTestAsset, modifyPackageJson } from "../helpers/packTester" test.ifAll.ifNotCiMac("Squirrel.Windows", app({targets: Platform.WINDOWS.createTarget(["squirrel", "zip"])}, {signed: true})) diff --git a/test/src/windows/winPackagerTest.ts b/test/src/windows/winPackagerTest.ts index 5fa88a0afb1..a8f07886aab 100755 --- a/test/src/windows/winPackagerTest.ts +++ b/test/src/windows/winPackagerTest.ts @@ -1,7 +1,8 @@ import { Platform } from "electron-builder" import { rename, unlink, writeFile } from "fs-extra-p" import * as path from "path" -import { app, appThrows, assertPack, CheckingWinPackager, platform } from "../helpers/packTester" +import { CheckingWinPackager } from "../helpers/CheckingPackager" +import { app, appThrows, assertPack, platform } from "../helpers/packTester" test.ifWinCi("beta version", app({ targets: Platform.WINDOWS.createTarget(["squirrel", "nsis"]),