From 10574994e126b488aecef78171c5e503c517c321 Mon Sep 17 00:00:00 2001 From: develar Date: Tue, 15 Nov 2016 09:58:43 +0100 Subject: [PATCH] feat: Surround [version]-[revision] with underscores rather than dashes in filenames BREAKING CHANGES: Debian binary package naming convention is [name]_[version]-[revision]_[arch].deb Closes #803 --- src/packager.ts | 4 ++-- src/platformPackager.ts | 6 ++++-- src/targets/LinuxTargetHelper.ts | 6 +++--- src/targets/fpm.ts | 9 +++++---- src/winPackager.ts | 2 +- test/src/helpers/fileAssert.ts | 6 +++--- test/src/helpers/packTester.ts | 6 +++--- test/src/nsisUpdaterTest.ts | 6 +++--- 8 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/packager.ts b/src/packager.ts index ef60118f474..16fee034dfa 100644 --- a/src/packager.ts +++ b/src/packager.ts @@ -97,7 +97,7 @@ export class Packager implements BuildInfo { this.appInfo = new AppInfo(this.metadata, this.devMetadata) const cleanupTasks: Array<() => Promise> = [] - return executeFinally(this.doBuild(cleanupTasks), () => all(cleanupTasks.map(it => it()).concat(this.tempDirManager.cleanup()))) + return await executeFinally(this.doBuild(cleanupTasks), () => all(cleanupTasks.map(it => it()).concat(this.tempDirManager.cleanup()))) } private async doBuild(cleanupTasks: Array<() => Promise>): Promise>> { @@ -126,7 +126,7 @@ export class Packager implements BuildInfo { if (checkWine && wineCheck != null) { checkWine = false - checkWineVersion(wineCheck) + await checkWineVersion(wineCheck) } await helper.pack(outDir, arch, createTargets(nameToTarget, targets, outDir, helper, cleanupTasks), distTasks) diff --git a/src/platformPackager.ts b/src/platformPackager.ts index db5951fa454..bb0c847bce9 100644 --- a/src/platformPackager.ts +++ b/src/platformPackager.ts @@ -249,6 +249,7 @@ export abstract class PlatformPackager else { const unpackPattern = this.getFileMatchers("asarUnpack", appDir, path.join(resourcesPath, "app"), false, fileMatchOptions, platformSpecificBuildOptions) const fileMatcher = unpackPattern == null ? null : unpackPattern[0] + //noinspection ES6MissingAwait promise = createAsarArchive(appDir, resourcesPath, asarOptions, filter, fileMatcher == null ? null : fileMatcher.createFilter()) } @@ -435,7 +436,7 @@ export abstract class PlatformPackager await this.checkFileInPackage(resourcesDir, "package.json", "Application", isAsar) } - protected async archiveApp(format: string, appOutDir: string, outFile: string): Promise { + protected archiveApp(format: string, appOutDir: string, outFile: string): Promise { const isMac = this.platform === Platform.MAC return archiveApp(this.devMetadata.build.compression, format, outFile, isMac ? path.join(appOutDir, `${this.appInfo.productFilename}.app`) : appOutDir, isMac) } @@ -465,7 +466,8 @@ export abstract class PlatformPackager generateName2(ext: string | null, classifier: string | n, deployment: boolean): string { const dotExt = ext == null ? "" : `.${ext}` - return `${deployment ? this.appInfo.name : this.appInfo.productFilename}-${this.appInfo.version}${classifier == null ? "" : `-${classifier}`}${dotExt}` + const separator = ext === "deb" ? "_" : "-" + return `${deployment ? this.appInfo.name : this.appInfo.productFilename}${separator}${this.appInfo.version}${classifier == null ? "" : `${separator}${classifier}`}${dotExt}` } async getDefaultIcon(ext: string) { diff --git a/src/targets/LinuxTargetHelper.ts b/src/targets/LinuxTargetHelper.ts index b20ddd836e9..3605ad1864c 100644 --- a/src/targets/LinuxTargetHelper.ts +++ b/src/targets/LinuxTargetHelper.ts @@ -20,10 +20,10 @@ export class LinuxTargetHelper { private async computeDesktopIcons(): Promise>> { const resourceList = await this.packager.resourceList if (resourceList.includes("icons")) { - return this.iconsFromDir(path.join(this.packager.buildResourcesDir, "icons")) + return await this.iconsFromDir(path.join(this.packager.buildResourcesDir, "icons")) } else { - return this.createFromIcns(await this.packager.getTempFile("electron-builder-linux.iconset").then(it => ensureDir(it).thenReturn(it))) + return await this.createFromIcns(await this.packager.getTempFile("electron-builder-linux.iconset").then(it => ensureDir(it).thenReturn(it))) } } @@ -97,7 +97,7 @@ export class LinuxTargetHelper { private async createFromIcns(tempDir: string): Promise>> { const iconPath = await this.getIcns() if (iconPath == null) { - return this.iconsFromDir(path.join(__dirname, "..", "..", "templates", "linux", "electron-icons")) + return await this.iconsFromDir(path.join(__dirname, "..", "..", "templates", "linux", "electron-icons")) } if (process.platform === "darwin") { diff --git a/src/targets/fpm.ts b/src/targets/fpm.ts index 86054f29a21..f900bdbe347 100644 --- a/src/targets/fpm.ts +++ b/src/targets/fpm.ts @@ -57,10 +57,11 @@ export default class FpmTarget extends TargetEx { return path.resolve(packager.projectDir, value) } - const afterInstallFilePath = writeConfigFile(packager.info.tempDirManager, getResource(packager.platformSpecificBuildOptions.afterInstall, "after-install.tpl"), templateOptions) - const afterRemoveFilePath = writeConfigFile(packager.info.tempDirManager, getResource(packager.platformSpecificBuildOptions.afterRemove, "after-remove.tpl"), templateOptions) - - return await BluebirdPromise.all([afterInstallFilePath, afterRemoveFilePath]) + //noinspection ES6MissingAwait + return await BluebirdPromise.all([ + writeConfigFile(packager.info.tempDirManager, getResource(packager.platformSpecificBuildOptions.afterInstall, "after-install.tpl"), templateOptions), + writeConfigFile(packager.info.tempDirManager, getResource(packager.platformSpecificBuildOptions.afterRemove, "after-remove.tpl"), templateOptions) + ]) } async build(appOutDir: string, arch: Arch): Promise { diff --git a/src/winPackager.ts b/src/winPackager.ts index 0fd1b6477ac..83f3dd52f8a 100644 --- a/src/winPackager.ts +++ b/src/winPackager.ts @@ -140,7 +140,7 @@ export class WinPackager extends PlatformPackager { } //noinspection JSMethodCanBeStatic - protected async doSign(options: SignOptions): Promise { + protected doSign(options: SignOptions): Promise { return sign(options) } diff --git a/test/src/helpers/fileAssert.ts b/test/src/helpers/fileAssert.ts index 7339def6ef8..a1a4dc88d75 100644 --- a/test/src/helpers/fileAssert.ts +++ b/test/src/helpers/fileAssert.ts @@ -1,4 +1,4 @@ -import { stat } from "fs-extra-p" +import { stat, Stats } from "fs-extra-p" import * as json8 from "json8" import { green, red, gray } from "chalk" import { diffJson } from "diff" @@ -65,14 +65,14 @@ class Assertions { } async isFile() { - const info = await stat(this.actual) + const info: Stats = await stat(this.actual) if (!info.isFile()) { throw new Error(`Path ${this.actual} is not a file`) } } async isDirectory() { - const info = await stat(this.actual) + const info: Stats = await stat(this.actual) if (!info.isDirectory()) { throw new Error(`Path ${this.actual} is not a directory`) } diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index f05548ea613..6735ea53739 100755 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -192,7 +192,7 @@ async function checkLinuxResult(outDir: string, packager: Packager, checkOptions result.push(`${appInfo.name}-${appInfo.version}-${arch === Arch.x64 ? "x86_64" : Arch[arch]}.AppImage`) } else if (target === "deb") { - result.push(`${appInfo.name}-${appInfo.version}-${arch === Arch.x64 ? "amd64" : Arch[arch]}.deb`) + result.push(`${appInfo.name}_${appInfo.version}_${arch === Arch.x64 ? "amd64" : Arch[arch]}.deb`) } else { result.push(`TestApp-${appInfo.version}.${target}`) @@ -220,10 +220,10 @@ async function checkLinuxResult(outDir: string, packager: Packager, checkOptions } })) - const packageFile = `${outDir}/TestApp-${appInfo.version}-${arch === Arch.ia32 ? "ia32" : (arch === Arch.x64 ? "amd64" : "armv7l")}.deb` + const packageFile = `${outDir}/TestApp_${appInfo.version}_${arch === Arch.ia32 ? "ia32" : (arch === Arch.x64 ? "amd64" : "armv7l")}.deb` assertThat(await getContents(packageFile)).isEqualTo(expectedContents) if (arch === Arch.ia32) { - assertThat(await getContents(`${outDir}/TestApp-${appInfo.version}-i386.deb`)).isEqualTo(expectedContents) + assertThat(await getContents(`${outDir}/TestApp_${appInfo.version}_i386.deb`)).isEqualTo(expectedContents) } assertThat(parseDebControl(await exec("dpkg", ["--info", packageFile]))).hasProperties({ diff --git a/test/src/nsisUpdaterTest.ts b/test/src/nsisUpdaterTest.ts index b29efc8ba71..3703112224b 100644 --- a/test/src/nsisUpdaterTest.ts +++ b/test/src/nsisUpdaterTest.ts @@ -65,7 +65,7 @@ test("file url", async () => { assertThat(updateCheckResult.fileInfo).hasProperties({ url: "https://dl.bintray.com/actperepo/generic/TestApp Setup 1.1.0.exe" }) - assertThat(path.join(await updateCheckResult.downloadPromise)).isFile() + await assertThat(path.join(await updateCheckResult.downloadPromise)).isFile() assertThat(actualEvents).isEqualTo(expectedEvents) }) @@ -92,7 +92,7 @@ test("file url generic", async () => { assertThat(updateCheckResult.fileInfo).hasProperties({ url: "https://develar.s3.amazonaws.com/test/TestApp Setup 1.1.0.exe" }) - assertThat(path.join(await updateCheckResult.downloadPromise)).isFile() + await assertThat(path.join(await updateCheckResult.downloadPromise)).isFile() assertThat(actualEvents).isEqualTo(expectedEvents) }) @@ -120,7 +120,7 @@ test("file url github", async () => { assertThat(updateCheckResult.fileInfo).hasProperties({ url: "https://github.com/develar/__test_nsis_release/releases/download/v1.1.0/TestApp-Setup-1.1.0.exe" }) - assertThat(path.join(await updateCheckResult.downloadPromise)).isFile() + await assertThat(path.join(await updateCheckResult.downloadPromise)).isFile() assertThat(actualEvents).isEqualTo(expectedEvents) })