From 05121df3037cde5c66e06c259a119ec220370265 Mon Sep 17 00:00:00 2001 From: develar Date: Thu, 12 May 2016 20:45:36 +0200 Subject: [PATCH] fix: Cannot upload prerelease version Closes #395 --- .idea/dictionaries/develar.xml | 1 + package.json | 2 +- src/winPackager.ts | 8 +++++--- test/src/BuildTest.ts | 1 - test/src/helpers/packTester.ts | 8 ++++++-- test/src/winPackagerTest.ts | 19 +++++++++++++++++++ 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/.idea/dictionaries/develar.xml b/.idea/dictionaries/develar.xml index d639071fe8f..a62216d6c60 100644 --- a/.idea/dictionaries/develar.xml +++ b/.idea/dictionaries/develar.xml @@ -26,6 +26,7 @@ mkdirp nokeys nomacver + noninteractive nsis nuget nupkg diff --git a/package.json b/package.json index 3661c1f8744..ac4f01b1122 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "deep-assign": "^2.0.0", "electron-osx-sign-tf": "0.4.0-beta.0", "electron-packager-tf": "^7.0.2-beta.0", - "electron-winstaller-fixed": "~2.7.0", + "electron-winstaller-fixed": "~2.7.1", "fs-extra-p": "^1.0.1", "globby": "^4.0.0", "hosted-git-info": "^2.1.4", diff --git a/src/winPackager.ts b/src/winPackager.ts index c378639a7aa..611b134ea8d 100644 --- a/src/winPackager.ts +++ b/src/winPackager.ts @@ -161,13 +161,15 @@ export class WinPackager extends PlatformPackager { async packageInDistributableFormat(outDir: string, appOutDir: string, arch: string, packOptions: ElectronPackagerOptions): Promise { const installerOutDir = computeDistOut(outDir, arch) - await require("electron-winstaller-fixed").createWindowsInstaller(await this.computeEffectiveDistOptions(appOutDir, installerOutDir, packOptions)) + const winstaller = require("electron-winstaller-fixed") + await winstaller.createWindowsInstaller(await this.computeEffectiveDistOptions(appOutDir, installerOutDir, packOptions)) const version = this.metadata.version const archSuffix = arch === "x64" ? "" : ("-" + arch) const releasesFile = path.join(installerOutDir, "RELEASES") - const nupkgPathOriginal = this.metadata.name + "-" + version + "-full.nupkg" - const nupkgPathWithArch = this.metadata.name + "-" + version + archSuffix + "-full.nupkg" + const nupkgVersion = winstaller.convertVersion(version) + const nupkgPathOriginal = `${this.metadata.name}-${nupkgVersion}-full.nupkg` + const nupkgPathWithArch = `${this.metadata.name}-${nupkgVersion}${archSuffix}-full.nupkg` async function changeFileNameInTheReleasesFile(): Promise { const data = (await readFile(releasesFile, "utf8")).replace(new RegExp(" " + nupkgPathOriginal + " ", "g"), " " + nupkgPathWithArch + " ") diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts index 6042c4eace5..991404c2306 100755 --- a/test/src/BuildTest.ts +++ b/test/src/BuildTest.ts @@ -166,7 +166,6 @@ test("copy extra resource", async () => { "lib/net45/bar/x64.txt", "lib/net45/foo/nameWithoutDot", "lib/net45/platformSpecific", - "lib/net45/win/", "lib/net45/win/x64.txt" )) : null, }) diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index d33e147689b..3b82980a6a5 100755 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -27,6 +27,7 @@ interface AssertPackOptions { readonly tempDirCreated?: (projectDir: string) => Promise readonly packed?: (projectDir: string) => Promise readonly expectedContents?: Array + readonly expectedArtifacts?: Array } export async function assertPack(fixtureName: string, packagerOptions: PackagerOptions, checkOptions?: AssertPackOptions): Promise { @@ -210,13 +211,16 @@ async function checkWindowsResult(packager: Packager, packagerOptions: PackagerO `TestApp-1.1.0${archSuffix}-full.nupkg`, ] } - const archSuffix = (packagerOptions.arch || process.arch) === "x64" ? "" : "-ia32" - const expected = archSuffix == "" ? getWinExpected(archSuffix) : getWinExpected(archSuffix).concat(getWinExpected("")) + const expected = checkOptions == null || checkOptions.expectedArtifacts == null ? (archSuffix == "" ? getWinExpected(archSuffix) : getWinExpected(archSuffix).concat(getWinExpected(""))) : checkOptions.expectedArtifacts const filenames = artifacts.map(it => path.basename(it.file)) assertThat(filenames.slice().sort()).deepEqual(expected.slice().sort()) + if (checkOptions != null && checkOptions.expectedArtifacts != null) { + return + } + let i = filenames.indexOf("RELEASES-ia32") if (i !== -1) { assertThat((await readFile(artifacts[i].file, "utf8")).indexOf("ia32")).not.equal(-1) diff --git a/test/src/winPackagerTest.ts b/test/src/winPackagerTest.ts index 270f682d85e..c92ca8b7bb0 100755 --- a/test/src/winPackagerTest.ts +++ b/test/src/winPackagerTest.ts @@ -22,6 +22,25 @@ test.ifNotCiOsx("win", () => assertPack("test-app-one", platform(Platform.WINDOW } )) +test.ifNotCiOsx("win f", () => { + const metadata: any = { + version: "3.0.0-beta.2" + } + + return assertPack("test-app-one", { + platform: [Platform.WINDOWS], + cscLink: null, + cscInstallerLink: null, + devMetadata: metadata + }, { + expectedArtifacts: [ + "RELEASES", + "TestApp Setup 3.0.0-beta.2.exe", + "TestApp-3.0.0-beta2-full.nupkg" + ] + }) +}) + test.ifNotCiOsx("noMsi as string", t => t.throws(assertPack("test-app-one", platform(Platform.WINDOWS), { tempDirCreated: it => modifyPackageJson(it, data => {