From 68e55733421199048a2c89b255c1361f4c4814a3 Mon Sep 17 00:00:00 2001 From: develar Date: Fri, 16 Nov 2018 18:33:52 +0100 Subject: [PATCH] feat: product name for AppImage file Close #1895, Close #3334 --- appveyor.yml | 2 +- package.json | 2 +- packages/app-builder-lib/package.json | 2 +- packages/app-builder-lib/src/macPackager.ts | 1 + .../app-builder-lib/src/platformPackager.ts | 5 +++ .../src/remoteBuilder/builder-cli.ts | 8 ++-- .../src/targets/AppImageTarget.ts | 2 +- .../app-builder-lib/src/targets/AppxTarget.ts | 2 +- .../app-builder-lib/src/targets/MsiTarget.ts | 2 +- packages/app-builder-lib/src/targets/pkg.ts | 1 + packages/builder-util/package.json | 2 +- test/babel-jest.js | 4 +- test/out/__snapshots__/ExtraBuildTest.js.snap | 3 +- .../__snapshots__/PublishManagerTest.js.snap | 3 +- .../configurationValidationTest.js.snap | 3 +- test/out/__snapshots__/protonTest.js.snap | 3 +- .../__snapshots__/linuxPackagerTest.js.snap | 42 ++++++++++++------- .../differentialUpdateTest.js.snap | 28 +++++++------ .../windows/__snapshots__/appxTest.js.snap | 8 ++-- .../out/windows/__snapshots__/msiTest.js.snap | 6 +-- .../oneClickInstallerTest.js.snap | 3 ++ .../__snapshots__/winPackagerTest.js.snap | 2 +- test/src/helpers/packTester.ts | 13 ++---- test/src/helpers/runTests.ts | 15 +++---- test/src/linux/linuxPackagerTest.ts | 23 +++++----- test/src/mac/macArchiveTest.ts | 1 + test/src/updater/differentialUpdateTest.ts | 39 ++++++++++------- yarn.lock | 19 ++------- 28 files changed, 132 insertions(+), 112 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f94273275b3..a99457e87ce 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ cache: - '%LOCALAPPDATA%\electron-builder\cache' environment: - TEST_FILES: ExtraBuildTest,BuildTest,extraMetadataTest,filesTest,globTest,nsisUpdaterTest,oneClickInstallerTest,installerTest,appxTest,msiTest + TEST_FILES: ExtraBuildTest,BuildTest,extraMetadataTest,filesTest,globTest,nsisUpdaterTest,oneClickInstallerTest,installerTest,appxTest,msiTest,protonTest install: - ps: Install-Product node 10 x64 diff --git a/package.json b/package.json index ee7152635a0..b821ecda02d 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "source-map-support": "^0.5.9", "stat-mode": "^0.2.2", "sumchecker": "^2.0.2", - "temp-file": "^3.2.0", + "temp-file": "^3.3.2", "tunnel-agent": "^0.6.0", "update-notifier": "^2.5.0", "yargs": "^12.0.2" diff --git a/packages/app-builder-lib/package.json b/packages/app-builder-lib/package.json index c7f137a8f3b..a5c7dddb941 100644 --- a/packages/app-builder-lib/package.json +++ b/packages/app-builder-lib/package.json @@ -63,7 +63,7 @@ "semver": "^5.6.0", "debug": "^4.1.0", "lazy-val": "^1.0.3", - "temp-file": "^3.2.0", + "temp-file": "^3.3.2", "ejs": "^2.6.1" }, "typings": "./out/index.d.ts" diff --git a/packages/app-builder-lib/src/macPackager.ts b/packages/app-builder-lib/src/macPackager.ts index 59556eeb993..4b887cbb1c8 100644 --- a/packages/app-builder-lib/src/macPackager.ts +++ b/packages/app-builder-lib/src/macPackager.ts @@ -192,6 +192,7 @@ export default class MacPackager extends PlatformPackager { throw new InvalidConfigurationError(`Cannot find valid "${certType}" identity to sign MAS installer, please see https://electron.build/code-signing`) } + // mas uploaded to AppStore, so, use "-" instead of space for name const artifactName = this.expandArtifactNamePattern(masOptions, "pkg") const artifactPath = path.join(outDir!, artifactName) await this.doFlat(appPath, artifactPath, masInstallerIdentity, keychainName) diff --git a/packages/app-builder-lib/src/platformPackager.ts b/packages/app-builder-lib/src/platformPackager.ts index b8259929257..ed1eaff211b 100644 --- a/packages/app-builder-lib/src/platformPackager.ts +++ b/packages/app-builder-lib/src/platformPackager.ts @@ -480,6 +480,11 @@ export abstract class PlatformPackager return this.computeArtifactName(pattern, ext, skipArchIfX64 && arch === Arch.x64 ? null : arch) } + expandArtifactBeautyNamePattern(targetSpecificOptions: TargetSpecificOptions | null | undefined, ext: string, arch?: Arch | null): string { + // tslint:disable-next-line:no-invalid-template-strings + return this.expandArtifactNamePattern(targetSpecificOptions, ext, arch, "${productName} ${version} ${arch}.${ext}", true) + } + private computeArtifactName(pattern: any, ext: string, arch: Arch | null | undefined) { let archName: string | null = arch == null ? null : Arch[arch] if (arch === Arch.x64) { diff --git a/packages/app-builder-lib/src/remoteBuilder/builder-cli.ts b/packages/app-builder-lib/src/remoteBuilder/builder-cli.ts index a39db2f0748..2e4808d98ae 100644 --- a/packages/app-builder-lib/src/remoteBuilder/builder-cli.ts +++ b/packages/app-builder-lib/src/remoteBuilder/builder-cli.ts @@ -8,8 +8,8 @@ if (process.env.BUILDER_REMOVE_STAGE_EVEN_IF_DEBUG == null) { } async function doBuild(data: BuildTask): Promise { - if (process.env.ELECTRON_BUILDER_TMP_DIR == null) { - throw new Error("Env ELECTRON_BUILDER_TMP_DIR must be set for builder process") + if (process.env.APP_BUILDER_TMP_DIR == null) { + throw new Error("Env APP_BUILDER_TMP_DIR must be set for builder process") } const projectDir = process.env.PROJECT_DIR @@ -86,13 +86,13 @@ async function doBuild(data: BuildTask): Promise { }, info.metadata, info.devMetadata, info.repositoryInfo) // writeJson must be not used because it adds unwanted \n as last file symbol - await writeFile(path.join(process.env.ELECTRON_BUILDER_TMP_DIR!!, "__build-result.json"), JSON.stringify(artifacts)) + await writeFile(path.join(process.env.APP_BUILDER_TMP_DIR!!, "__build-result.json"), JSON.stringify(artifacts)) } doBuild(JSON.parse(process.argv[2])) .catch(error => { process.exitCode = 0 - return writeFile(path.join(process.env.ELECTRON_BUILDER_TMP_DIR!!, "__build-result.json"), (error.stack || error).toString()) + return writeFile(path.join(process.env.APP_BUILDER_TMP_DIR!!, "__build-result.json"), (error.stack || error).toString()) }) interface TargetInfo { diff --git a/packages/app-builder-lib/src/targets/AppImageTarget.ts b/packages/app-builder-lib/src/targets/AppImageTarget.ts index faf7e464e83..9e307497593 100644 --- a/packages/app-builder-lib/src/targets/AppImageTarget.ts +++ b/packages/app-builder-lib/src/targets/AppImageTarget.ts @@ -32,7 +32,7 @@ export default class AppImageTarget extends Target { // https://github.com/electron-userland/electron-builder/issues/775 // https://github.com/electron-userland/electron-builder/issues/1726 // tslint:disable-next-line:no-invalid-template-strings - const artifactName = packager.expandArtifactNamePattern(options, "AppImage", arch, "${name}-${version}-${arch}.${ext}", false) + const artifactName = packager.expandArtifactBeautyNamePattern(options, "AppImage", arch) const artifactPath = path.join(this.outDir, artifactName) this.logBuilding("AppImage", artifactPath, arch) diff --git a/packages/app-builder-lib/src/targets/AppxTarget.ts b/packages/app-builder-lib/src/targets/AppxTarget.ts index 18d3d9f36de..87dd810cc60 100644 --- a/packages/app-builder-lib/src/targets/AppxTarget.ts +++ b/packages/app-builder-lib/src/targets/AppxTarget.ts @@ -36,7 +36,7 @@ export default class AppXTarget extends Target { // https://docs.microsoft.com/en-us/windows/uwp/packaging/create-app-package-with-makeappx-tool#mapping-files async build(appOutDir: string, arch: Arch): Promise { const packager = this.packager - const artifactName = packager.expandArtifactNamePattern(this.options, "appx", arch) + const artifactName = packager.expandArtifactBeautyNamePattern(this.options, "appx", arch) const artifactPath = path.join(this.outDir, artifactName) this.logBuilding("AppX", artifactPath, arch) diff --git a/packages/app-builder-lib/src/targets/MsiTarget.ts b/packages/app-builder-lib/src/targets/MsiTarget.ts index 06b3a76aaff..dced1cd678a 100644 --- a/packages/app-builder-lib/src/targets/MsiTarget.ts +++ b/packages/app-builder-lib/src/targets/MsiTarget.ts @@ -42,7 +42,7 @@ export default class MsiTarget extends Target { async build(appOutDir: string, arch: Arch) { const packager = this.packager - const artifactName = packager.expandArtifactNamePattern(this.options, "msi", arch) + const artifactName = packager.expandArtifactBeautyNamePattern(this.options, "msi", arch) const artifactPath = path.join(this.outDir, artifactName) this.logBuilding("MSI", artifactPath, arch) diff --git a/packages/app-builder-lib/src/targets/pkg.ts b/packages/app-builder-lib/src/targets/pkg.ts index 58d56251be2..ba310af5e2e 100644 --- a/packages/app-builder-lib/src/targets/pkg.ts +++ b/packages/app-builder-lib/src/targets/pkg.ts @@ -33,6 +33,7 @@ export class PkgTarget extends Target { const options = this.options const appInfo = packager.appInfo + // pkg doesn't like not ASCII symbols (Could not open package to list files: /Volumes/test/t-gIjdGK/test-project-0/dist/Test App ßW-1.1.0.pkg) const artifactName = packager.expandArtifactNamePattern(options, "pkg") const artifactPath = path.join(this.outDir, artifactName) diff --git a/packages/builder-util/package.json b/packages/builder-util/package.json index acfe5b3f916..85d4a1b87ec 100644 --- a/packages/builder-util/package.json +++ b/packages/builder-util/package.json @@ -12,7 +12,7 @@ ], "dependencies": { "app-builder-bin": "2.5.1", - "temp-file": "^3.2.0", + "temp-file": "^3.3.2", "fs-extra-p": "^7.0.0", "is-ci": "^1.2.1", "stat-mode": "^0.2.2", diff --git a/test/babel-jest.js b/test/babel-jest.js index 9a2848fed64..0734639be1f 100644 --- a/test/babel-jest.js +++ b/test/babel-jest.js @@ -1,5 +1,7 @@ "use strict" +const isCi = require("is-ci") + let babel const crypto = require("crypto") const fs = require("fs") @@ -31,7 +33,7 @@ function createTransformer(options) { .digest("hex") }, process(src, filename, config, transformOptions) { - if (process.env.BABEL_JEST_SKIP === "true" || require("is-ci")) { + if (process.env.BABEL_JEST_SKIP === "true" || isCi) { // precompiled on CI return src } diff --git a/test/out/__snapshots__/ExtraBuildTest.js.snap b/test/out/__snapshots__/ExtraBuildTest.js.snap index de811eb53fd..3606c26c571 100644 --- a/test/out/__snapshots__/ExtraBuildTest.js.snap +++ b/test/out/__snapshots__/ExtraBuildTest.js.snap @@ -5,7 +5,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.1.0-x86_64.AppImage", + "file": "Test App ßW 1.1.0.AppImage", + "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", diff --git a/test/out/__snapshots__/PublishManagerTest.js.snap b/test/out/__snapshots__/PublishManagerTest.js.snap index a916c8fc883..3aca84d5783 100644 --- a/test/out/__snapshots__/PublishManagerTest.js.snap +++ b/test/out/__snapshots__/PublishManagerTest.js.snap @@ -201,7 +201,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.1.0-x86_64.AppImage", + "file": "Test App ßW 1.1.0.AppImage", + "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", diff --git a/test/out/__snapshots__/configurationValidationTest.js.snap b/test/out/__snapshots__/configurationValidationTest.js.snap index 84ce28cf7e8..6fcf85c489a 100644 --- a/test/out/__snapshots__/configurationValidationTest.js.snap +++ b/test/out/__snapshots__/configurationValidationTest.js.snap @@ -5,7 +5,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.1.0-x86_64.AppImage", + "file": "Test App ßW 1.1.0.AppImage", + "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", diff --git a/test/out/__snapshots__/protonTest.js.snap b/test/out/__snapshots__/protonTest.js.snap index 80309dc2aa5..c952b108147 100644 --- a/test/out/__snapshots__/protonTest.js.snap +++ b/test/out/__snapshots__/protonTest.js.snap @@ -5,7 +5,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "notepad-1.0.0-x86_64.AppImage", + "file": "notepad 1.0.0.AppImage", + "safeArtifactName": "notepad-1.0.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", diff --git a/test/out/linux/__snapshots__/linuxPackagerTest.js.snap b/test/out/linux/__snapshots__/linuxPackagerTest.js.snap index 26ded5ccc39..700635dfb8f 100644 --- a/test/out/linux/__snapshots__/linuxPackagerTest.js.snap +++ b/test/out/linux/__snapshots__/linuxPackagerTest.js.snap @@ -36,7 +36,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.1.0-x86_64.AppImage", + "file": "Test App ßW 1.1.0.AppImage", + "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -52,7 +53,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.1.0-x86_64.AppImage", + "file": "Test App ßW 1.1.0.AppImage", + "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -67,10 +69,10 @@ Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", "size": "@size", - "url": "TestApp-1.1.0-x86_64.AppImage", + "url": "Test App ßW 1.1.0.AppImage", }, ], - "path": "TestApp-1.1.0-x86_64.AppImage", + "path": "Test App ßW 1.1.0.AppImage", "releaseDate": "@releaseDate", "sha512": "@sha512", "version": "1.1.0", @@ -85,7 +87,8 @@ Object { "linux": Array [ Object { "arch": "armv7l", - "file": "TestApp-1.1.0-armv7l.AppImage", + "file": "Test App ßW 1.1.0 armv7l.AppImage", + "safeArtifactName": "TestApp-1.1.0-armv7l.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -100,10 +103,10 @@ Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", "size": "@size", - "url": "TestApp-1.1.0-armv7l.AppImage", + "url": "Test App ßW 1.1.0 armv7l.AppImage", }, ], - "path": "TestApp-1.1.0-armv7l.AppImage", + "path": "Test App ßW 1.1.0 armv7l.AppImage", "releaseDate": "@releaseDate", "sha512": "@sha512", "version": "1.1.0", @@ -118,7 +121,8 @@ Object { "linux": Array [ Object { "arch": "ia32", - "file": "TestApp-1.1.0-i386.AppImage", + "file": "Test App ßW 1.1.0 i386.AppImage", + "safeArtifactName": "TestApp-1.1.0-i386.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -133,10 +137,10 @@ Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", "size": "@size", - "url": "TestApp-1.1.0-i386.AppImage", + "url": "Test App ßW 1.1.0 i386.AppImage", }, ], - "path": "TestApp-1.1.0-i386.AppImage", + "path": "Test App ßW 1.1.0 i386.AppImage", "releaseDate": "@releaseDate", "sha512": "@sha512", "version": "1.1.0", @@ -153,7 +157,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.1.0-x86_64.AppImage", + "file": "Test App ßW 1.1.0.AppImage", + "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -169,7 +174,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.1.0-x86_64.AppImage", + "file": "Test App ßW 1.1.0.AppImage", + "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -185,7 +191,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.1.0-x86_64.AppImage", + "file": "Test App ßW 1.1.0.AppImage", + "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -201,7 +208,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.1.0-x86_64.AppImage", + "file": "Test App ßW 1.1.0.AppImage", + "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -217,7 +225,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.1.0-x86_64.AppImage", + "file": "Test App ßW 1.1.0.AppImage", + "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -233,7 +242,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.1.0-x86_64.AppImage", + "file": "Test App ßW 1.1.0.AppImage", + "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", diff --git a/test/out/updater/__snapshots__/differentialUpdateTest.js.snap b/test/out/updater/__snapshots__/differentialUpdateTest.js.snap index f56d0a307ea..1857510d2eb 100644 --- a/test/out/updater/__snapshots__/differentialUpdateTest.js.snap +++ b/test/out/updater/__snapshots__/differentialUpdateTest.js.snap @@ -5,7 +5,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.0.0-x86_64.AppImage", + "file": "Test App ßW 1.0.0.AppImage", + "safeArtifactName": "TestApp-1.0.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -20,10 +21,10 @@ Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", "size": "@size", - "url": "TestApp-1.0.0-x86_64.AppImage", + "url": "Test App ßW 1.0.0.AppImage", }, ], - "path": "TestApp-1.0.0-x86_64.AppImage", + "path": "Test App ßW 1.0.0.AppImage", "releaseDate": "@releaseDate", "sha512": "@sha512", "version": "1.0.0", @@ -38,7 +39,8 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "TestApp-1.0.1-x86_64.AppImage", + "file": "Test App ßW 1.0.1.AppImage", + "safeArtifactName": "TestApp-1.0.1-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -53,10 +55,10 @@ Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", "size": "@size", - "url": "TestApp-1.0.1-x86_64.AppImage", + "url": "Test App ßW 1.0.1.AppImage", }, ], - "path": "TestApp-1.0.1-x86_64.AppImage", + "path": "Test App ßW 1.0.1.AppImage", "releaseDate": "@releaseDate", "sha512": "@sha512", "version": "1.0.1", @@ -93,7 +95,8 @@ Object { "linux": Array [ Object { "arch": "ia32", - "file": "TestApp-1.0.0-i386.AppImage", + "file": "Test App ßW 1.0.0 i386.AppImage", + "safeArtifactName": "TestApp-1.0.0-i386.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -108,10 +111,10 @@ Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", "size": "@size", - "url": "TestApp-1.0.0-i386.AppImage", + "url": "Test App ßW 1.0.0 i386.AppImage", }, ], - "path": "TestApp-1.0.0-i386.AppImage", + "path": "Test App ßW 1.0.0 i386.AppImage", "releaseDate": "@releaseDate", "sha512": "@sha512", "version": "1.0.0", @@ -126,7 +129,8 @@ Object { "linux": Array [ Object { "arch": "ia32", - "file": "TestApp-1.0.1-i386.AppImage", + "file": "Test App ßW 1.0.1 i386.AppImage", + "safeArtifactName": "TestApp-1.0.1-i386.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", @@ -141,10 +145,10 @@ Object { "blockMapSize": "@blockMapSize", "sha512": "@sha512", "size": "@size", - "url": "TestApp-1.0.1-i386.AppImage", + "url": "Test App ßW 1.0.1 i386.AppImage", }, ], - "path": "TestApp-1.0.1-i386.AppImage", + "path": "Test App ßW 1.0.1 i386.AppImage", "releaseDate": "@releaseDate", "sha512": "@sha512", "version": "1.0.1", diff --git a/test/out/windows/__snapshots__/appxTest.js.snap b/test/out/windows/__snapshots__/appxTest.js.snap index e6c04fdfa5e..147419abddf 100644 --- a/test/out/windows/__snapshots__/appxTest.js.snap +++ b/test/out/windows/__snapshots__/appxTest.js.snap @@ -5,7 +5,7 @@ Object { "win": Array [ Object { "arch": "x64", - "file": "Test App ßW-1.1.0.appx", + "file": "Test App ßW 1.1.0.appx", "safeArtifactName": "TestApp-1.1.0.appx", }, ], @@ -17,7 +17,7 @@ Object { "win": Array [ Object { "arch": "x64", - "file": "Test App ßW-1.1.0.appx", + "file": "Test App ßW 1.1.0.appx", "safeArtifactName": "TestApp-1.1.0.appx", }, ], @@ -41,12 +41,12 @@ Object { "win": Array [ Object { "arch": "ia32", - "file": "Test App ßW-1.1.0-ia32.appx", + "file": "Test App ßW 1.1.0 ia32.appx", "safeArtifactName": "TestApp-1.1.0.appx", }, Object { "arch": "x64", - "file": "Test App ßW-1.1.0.appx", + "file": "Test App ßW 1.1.0.appx", "safeArtifactName": "TestApp-1.1.0.appx", }, ], diff --git a/test/out/windows/__snapshots__/msiTest.js.snap b/test/out/windows/__snapshots__/msiTest.js.snap index 0e29838ce2f..91a8c3f872b 100644 --- a/test/out/windows/__snapshots__/msiTest.js.snap +++ b/test/out/windows/__snapshots__/msiTest.js.snap @@ -17,7 +17,7 @@ Object { "win": Array [ Object { "arch": "x64", - "file": "Test MSI-1.1.0.msi", + "file": "Test MSI 1.1.0.msi", "safeArtifactName": "TestApp-1.1.0.msi", }, ], @@ -29,7 +29,7 @@ Object { "win": Array [ Object { "arch": "x64", - "file": "Test MSI-1.1.0.msi", + "file": "Test MSI 1.1.0.msi", "safeArtifactName": "TestApp-1.1.0.msi", }, ], @@ -41,7 +41,7 @@ Object { "win": Array [ Object { "arch": "x64", - "file": "Test MSI Per User-1.1.0.msi", + "file": "Test MSI Per User 1.1.0.msi", "safeArtifactName": "TestApp-1.1.0.msi", }, ], diff --git a/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap b/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap index 5656b0e53fc..19062b5befb 100644 --- a/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap +++ b/test/out/windows/__snapshots__/oneClickInstallerTest.js.snap @@ -285,6 +285,7 @@ Object { "fileContent": Object { "files": Array [ Object { + "isAdminRightsRequired": true, "sha512": "@sha512", "size": "@size", "url": "TestApp Setup 1.1.0.exe", @@ -301,6 +302,7 @@ Object { "file": "TestApp Setup 1.1.0.exe", "safeArtifactName": "TestApp-Setup-1.1.0.exe", "updateInfo": Object { + "isAdminRightsRequired": true, "sha512": "@sha512", "size": "@size", }, @@ -309,6 +311,7 @@ Object { "file": "TestApp Setup 1.1.0.exe.blockmap", "safeArtifactName": "TestApp-Setup-1.1.0.exe.blockmap", "updateInfo": Object { + "isAdminRightsRequired": true, "sha512": "@sha512", "size": "@size", }, diff --git a/test/out/windows/__snapshots__/winPackagerTest.js.snap b/test/out/windows/__snapshots__/winPackagerTest.js.snap index d1949228690..745db162679 100644 --- a/test/out/windows/__snapshots__/winPackagerTest.js.snap +++ b/test/out/windows/__snapshots__/winPackagerTest.js.snap @@ -21,7 +21,7 @@ Object { "linux": Array [ Object { "arch": "x64", - "file": "Test App ßW-1.1.0-linux-x86_64.AppImage", + "file": "Test App ßW-1.1.0-linux.AppImage", "safeArtifactName": "TestApp-1.1.0-x86_64.AppImage", "updateInfo": Object { "blockMapSize": "@blockMapSize", diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index 18572f3d89c..dd2bd2743ab 100644 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -41,6 +41,8 @@ export interface AssertPackOptions { readonly isInstallDepsBefore?: boolean readonly publish?: PublishPolicy + + readonly tmpDir?: TmpDir } export interface PackedContext { @@ -93,7 +95,7 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO let projectDir = path.join(__dirname, "..", "..", "fixtures", fixtureName) // const isDoNotUseTempDir = platform === "darwin" const customTmpDir = process.env.TEST_APP_TMP_DIR - const tmpDir = new TmpDir("pack-tester") + const tmpDir = checkOptions.tmpDir || new TmpDir(`pack-tester: ${fixtureName}`) // non-macOS test uses the same dir as macOS test, but we cannot share node_modules (because tests executed in parallel) const dir = customTmpDir == null ? await tmpDir.createTempDir({prefix: "test-project"}) : path.resolve(customTmpDir) if (customTmpDir != null) { @@ -146,7 +148,7 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO tmpDir, }) } - })(), () => tmpDir.cleanup()) + })(), (): any => tmpDir === checkOptions.tmpDir ? null : tmpDir.cleanup()) } const fileCopier = new FileCopier() @@ -470,13 +472,6 @@ export function createMacTargetTest(target: Array, config?: Con }) } -export function convertUpdateInfo(info: any) { - if (info.releaseDate != null) { - info.releaseDate = "1970-01-01T00:00:00.000Z" - } - return info -} - export async function checkDirContents(dir: string) { expect((await walk(dir, file => !path.basename(file).startsWith("."))).map(it => it.substring(dir.length + 1))).toMatchSnapshot() } diff --git a/test/src/helpers/runTests.ts b/test/src/helpers/runTests.ts index fd8cb22637f..0dba0c304ec 100644 --- a/test/src/helpers/runTests.ts +++ b/test/src/helpers/runTests.ts @@ -1,5 +1,5 @@ import { createHash } from "crypto" -import { emptyDir, readJson, remove } from "fs-extra-p" +import { emptyDir, readJson, realpathSync, remove } from "fs-extra-p" import isCi from "is-ci" import { tmpdir } from "os" import * as path from "path" @@ -10,8 +10,8 @@ const rootDir = path.join(__dirname, "../../..") const util = require(`${rootDir}/packages/builder-util/out/util`) const isEmptyOrSpaces = util.isEmptyOrSpaces -const baseDir = process.env.ELECTRON_BUILDER_TMP_DIR || (process.platform === "darwin" && !require("is-ci") ? "/tmp" : tmpdir()) -const TEST_TMP_DIR = path.join(baseDir, `et-${createHash("md5").update(__dirname).digest("hex")}`) +const baseDir = process.env.APP_BUILDER_TMP_DIR || realpathSync(tmpdir()) +const APP_BUILDER_TMP_DIR = path.join(baseDir, `et-${createHash("md5").update(__dirname).digest("hex")}`) runTests() .catch(error => { @@ -23,13 +23,13 @@ async function runTests() { process.env.BABEL_JEST_SKIP = "true" if (process.env.CIRCLECI) { - await emptyDir(TEST_TMP_DIR) + await emptyDir(APP_BUILDER_TMP_DIR) } else { await Promise.all([ deleteOldElectronVersion(), downloadAllRequiredElectronVersions(), - emptyDir(TEST_TMP_DIR), + emptyDir(APP_BUILDER_TMP_DIR), ]) } @@ -76,11 +76,12 @@ async function runTests() { testPatterns.push("PublishManagerTest") testPatterns.push("assistedInstallerTest") testPatterns.push("filesTest") + testPatterns.push("protonTest") } console.log(`Test files for node ${circleNodeIndex}: ${testPatterns.join(", ")}`) } - process.env.TEST_TMP_DIR = TEST_TMP_DIR + process.env.APP_BUILDER_TMP_DIR = APP_BUILDER_TMP_DIR const rootDir = path.join(__dirname, "..", "..", "..") @@ -163,7 +164,7 @@ async function runTests() { process.exit(exitCode) } - await remove(TEST_TMP_DIR) + await remove(APP_BUILDER_TMP_DIR) process.exitCode = exitCode if (testResult.globalConfig.forceExit) { process.exit(exitCode) diff --git a/test/src/linux/linuxPackagerTest.ts b/test/src/linux/linuxPackagerTest.ts index 0c20e26fadb..7f4b3a8e3f1 100644 --- a/test/src/linux/linuxPackagerTest.ts +++ b/test/src/linux/linuxPackagerTest.ts @@ -1,19 +1,23 @@ import { Arch, build, Platform } from "electron-builder" import { copyFile, move, outputFile, remove, rename } from "fs-extra-p" import * as path from "path" +import { GenericServerOptions } from "builder-util-runtime" import { assertThat } from "../helpers/fileAssert" import { app, appThrows, copyTestAsset, modifyPackageJson } from "../helpers/packTester" import { ELECTRON_VERSION } from "../helpers/testConfig" const appImageTarget = Platform.LINUX.createTarget("appimage") +// test update info file name +const testPublishConfig: GenericServerOptions = { + provider: "generic", + url: "https://example.com/download", +} + test.ifNotWindows("AppImage", app({ targets: appImageTarget, config: { - publish: { - provider: "generic", - url: "https://example.com/downloads", - }, + publish: testPublishConfig, }, })) @@ -25,21 +29,14 @@ test.ifAll.ifNotWindows.ifNotCiMac("AppImage ia32", app({ // tslint:disable:no-invalid-template-strings output: "dist/${os}", }, - publish: { - provider: "generic", - url: "https://example.com/downloads" - }, + publish: testPublishConfig, }, })) test.ifAll.ifNotWindows.ifNotCiMac("AppImage arm, max compression", app({ targets: Platform.LINUX.createTarget("Appimage", Arch.armv7l), config: { - // test update info file name - publish: { - provider: "generic", - url: "https://example.com/downloads" - }, + publish: testPublishConfig, compression: "maximum", }, })) diff --git a/test/src/mac/macArchiveTest.ts b/test/src/mac/macArchiveTest.ts index 8d947e0fa2e..b1c5663f066 100644 --- a/test/src/mac/macArchiveTest.ts +++ b/test/src/mac/macArchiveTest.ts @@ -102,6 +102,7 @@ test.ifAll.ifMac("pkg scripts", app({ }, packed: async context => { const pkgPath = path.join(context.outDir, "Test App ßW-1.1.0.pkg") + console.log("CALL") const fileList = pathSorter(parseFileList(await exec("pkgutil", ["--payload-files", pkgPath]), false)) expect(fileList).toMatchSnapshot() diff --git a/test/src/updater/differentialUpdateTest.ts b/test/src/updater/differentialUpdateTest.ts index 2faf6502459..a88a56968ff 100644 --- a/test/src/updater/differentialUpdateTest.ts +++ b/test/src/updater/differentialUpdateTest.ts @@ -32,7 +32,7 @@ const testAppCacheDirName = "testapp-updater" test.ifAll.ifDevOrWinCi("web installer", async () => { let outDirs: Array = [] - async function buildApp(version: string) { + async function buildApp(version: string, tmpDir: TmpDir) { await assertPack("test-app-one", { targets: Platform.WINDOWS.createTarget(["nsis-web"], Arch.x64), config: { @@ -51,21 +51,21 @@ test.ifAll.ifDevOrWinCi("web installer", async () => { signedWin: true, packed: async context => { outDirs.push(context.outDir) - } + }, + tmpDir, }) } if (process.env.__SKIP_BUILD == null) { - await buildApp(OLD_VERSION_NUMBER) - const tmpDir = new TmpDir("differential-updater-test") try { + await buildApp(OLD_VERSION_NUMBER, tmpDir) // move dist temporarily out of project dir const oldDir = await tmpDir.getTempDir() await move(outDirs[0], oldDir) outDirs[0] = oldDir - await buildApp("1.0.1") + await buildApp("1.0.1", tmpDir) } catch (e) { await tmpDir.cleanup() @@ -157,10 +157,16 @@ async function testLinux(arch: Arch) { process.env.TEST_UPDATER_ARCH = Arch[arch] const outDirs: Array = [] - await doBuild(outDirs, Platform.LINUX.createTarget(["appimage"], arch)) + const tmpDir = new TmpDir("differential-updater-test") + try { + await doBuild(outDirs, Platform.LINUX.createTarget(["appimage"], arch), tmpDir) - process.env.APPIMAGE = path.join(outDirs[0], `TestApp-1.0.0-${arch === Arch.x64 ? "x86_64" : "i386"}.AppImage`) - await testBlockMap(outDirs[0], path.join(outDirs[1]), AppImageUpdater, `__appImage-${Arch[arch]}`, Platform.LINUX) + process.env.APPIMAGE = path.join(outDirs[0], `TestApp-1.0.0-${arch === Arch.x64 ? "x86_64" : "i386"}.AppImage`) + await testBlockMap(outDirs[0], path.join(outDirs[1]), AppImageUpdater, `__appImage-${Arch[arch]}`, Platform.LINUX) + } + finally { + await tmpDir.cleanup() + } } test.ifAll.ifDevOrLinuxCi("AppImage", () => testLinux(Arch.x64)) @@ -170,8 +176,9 @@ test.ifAll.ifDevOrLinuxCi("AppImage ia32", () => testLinux(Arch.ia32)) // ifAll.ifMac.ifNotCi todo test.skip("dmg", async () => { const outDirs: Array = [] + const tmpDir = new TmpDir("differential-updater-test") if (process.env.__SKIP_BUILD == null) { - await doBuild(outDirs, Platform.MAC.createTarget(), { + await doBuild(outDirs, Platform.MAC.createTarget(), tmpDir, { mac: { electronUpdaterCompatibility: ">=2.17.0", }, @@ -184,7 +191,7 @@ test.skip("dmg", async () => { await testBlockMap(outDirs[0], path.join(outDirs[1]), MacUpdater, "mac/Test App ßW.app", Platform.MAC) }) -async function buildApp(version: string, outDirs: Array, targets: Map>>, extraConfig?: Configuration | null) { +async function buildApp(version: string, outDirs: Array, targets: Map>>, tmpDir: TmpDir, extraConfig: Configuration | null | undefined) { await assertPack("test-app-one", { targets, config: { @@ -201,21 +208,21 @@ async function buildApp(version: string, outDirs: Array, targets: Map { - outDirs.push(context.outDir)} + outDirs.push(context.outDir) + }, + tmpDir, }) } -async function doBuild(outDirs: Array, targets: Map>>, extraConfig?: Configuration | null) { - await buildApp("1.0.0", outDirs, targets, extraConfig) - - const tmpDir = new TmpDir("differential-updater-test") +async function doBuild(outDirs: Array, targets: Map>>, tmpDir: TmpDir, extraConfig?: Configuration | null) { + await buildApp("1.0.0", outDirs, targets, tmpDir, extraConfig) try { // move dist temporarily out of project dir const oldDir = await tmpDir.getTempDir() await move(outDirs[0], oldDir) outDirs[0] = oldDir - await buildApp("1.0.1", outDirs, targets, extraConfig) + await buildApp("1.0.1", outDirs, targets, tmpDir, extraConfig) } catch (e) { await tmpDir.cleanup() diff --git a/yarn.lock b/yarn.lock index 1896ced1b0e..ddc41ffcb90 100644 --- a/yarn.lock +++ b/yarn.lock @@ -885,11 +885,6 @@ resolved "https://registry.yarnpkg.com/@types/ejs/-/ejs-2.6.0.tgz#56502bca6e2e1b4cf9351918ca76cdaa93fe3b6c" integrity sha512-1ISPltnwvcNU1VTxV0Zusv/nUViHO/S+TUIjiHlvXdmU6e9B/WpCWN6Ewz+fCB7sugdIe5lhsJbbZ6/6+dA1Gg== -"@types/electron-is-dev@^0.3.0": - version "0.3.0" - resolved "https://registry.yarnpkg.com/@types/electron-is-dev/-/electron-is-dev-0.3.0.tgz#28dc6aa4c9493869a8c5da29ebd586648f5ffb70" - integrity sha512-Y7ur72wnUrPACXLnw8RyO+vPMOPTB1zGm0yJBPZ750+jTk2mEpC4EgoRSBpjrQW21v6p39ZPk7tPDMxIVyDMcg== - "@types/ini@^1.3.29": version "1.3.29" resolved "https://registry.yarnpkg.com/@types/ini/-/ini-1.3.29.tgz#1325e981e047d40d13ce0359b821475b97741d2f" @@ -2253,11 +2248,6 @@ electron-builder-tslint-config@^1.1.0: resolved "https://registry.yarnpkg.com/electron-builder-tslint-config/-/electron-builder-tslint-config-1.1.0.tgz#5ef62fa3210d2265a3c6d259d7a1a1741ce1804b" integrity sha512-m/oAwS+NYB/b182bGY8C7uj1cDy8XXnHTl5CwD98dng7wE/nZGV2mJD9NyqbFmhJ1kF61wbsYDVx2KLIN5s5tg== -electron-is-dev@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/electron-is-dev/-/electron-is-dev-1.0.1.tgz#6e0a184736fe7aea77d18210b0b0f6a02402c4bc" - integrity sha512-iwM3EotA9HTXqMGpQRkR/kT8OZqBbdfHTnlwcxsjSLYqY8svvsq0MuujsWCn3/vtgRmDv/PC/gKUUpoZvi5C1w== - electron-osx-sign@0.4.11: version "0.4.11" resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.4.11.tgz#8377732fe7b207969f264b67582ee47029ce092f" @@ -5679,15 +5669,14 @@ tar@^4: safe-buffer "^5.1.2" yallist "^3.0.2" -temp-file@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/temp-file/-/temp-file-3.2.0.tgz#0d0e486739929d0821be5af71063c2595c5451df" - integrity sha512-4aGgEyfmCtU08cio1P51pfL3Zk6v1UGefc52CdbpVUCFtdScwFUfE/TKJZVp3sYCfiF6erKmgcKmcvXSLbgs6Q== +temp-file@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/temp-file/-/temp-file-3.3.2.tgz#69b6daf1bbe23231d0a5d03844e3d96f3f531aaa" + integrity sha512-FGKccAW0Mux9hC/2bdUIe4bJRv4OyVo4RpVcuplFird1V/YoplIFbnPZjfzbJSf/qNvRZIRB9/4n/RkI0GziuQ== dependencies: async-exit-hook "^2.0.1" bluebird-lst "^1.0.6" fs-extra-p "^7.0.0" - lazy-val "^1.0.3" temp-path@^1.0.0: version "1.0.0"