Skip to content

Commit

Permalink
fix: Cannot upload prerelease version
Browse files Browse the repository at this point in the history
Closes #395
  • Loading branch information
develar committed May 12, 2016
1 parent 6977557 commit 05121df
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/develar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions src/winPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,15 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {

async packageInDistributableFormat(outDir: string, appOutDir: string, arch: string, packOptions: ElectronPackagerOptions): Promise<any> {
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<void> {
const data = (await readFile(releasesFile, "utf8")).replace(new RegExp(" " + nupkgPathOriginal + " ", "g"), " " + nupkgPathWithArch + " ")
Expand Down
1 change: 0 additions & 1 deletion test/src/BuildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down
8 changes: 6 additions & 2 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface AssertPackOptions {
readonly tempDirCreated?: (projectDir: string) => Promise<any>
readonly packed?: (projectDir: string) => Promise<any>
readonly expectedContents?: Array<string>
readonly expectedArtifacts?: Array<string>
}

export async function assertPack(fixtureName: string, packagerOptions: PackagerOptions, checkOptions?: AssertPackOptions): Promise<void> {
Expand Down Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions test/src/winPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 05121df

Please sign in to comment.