Skip to content

Commit

Permalink
feat: Surround [version]-[revision] with underscores rather than dash…
Browse files Browse the repository at this point in the history
…es in filenames

BREAKING CHANGES: Debian binary package naming convention is [name]_[version]-[revision]_[arch].deb

Closes #803
  • Loading branch information
develar committed Nov 15, 2016
1 parent 5f2a1c6 commit 1057499
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class Packager implements BuildInfo {

this.appInfo = new AppInfo(this.metadata, this.devMetadata)
const cleanupTasks: Array<() => Promise<any>> = []
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<any>>): Promise<Map<Platform, Map<String, Target>>> {
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
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())
}

Expand Down Expand Up @@ -435,7 +436,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
await this.checkFileInPackage(resourcesDir, "package.json", "Application", isAsar)
}

protected async archiveApp(format: string, appOutDir: string, outFile: string): Promise<any> {
protected archiveApp(format: string, appOutDir: string, outFile: string): Promise<any> {
const isMac = this.platform === Platform.MAC
return archiveApp(this.devMetadata.build.compression, format, outFile, isMac ? path.join(appOutDir, `${this.appInfo.productFilename}.app`) : appOutDir, isMac)
}
Expand Down Expand Up @@ -465,7 +466,8 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>

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) {
Expand Down
6 changes: 3 additions & 3 deletions src/targets/LinuxTargetHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export class LinuxTargetHelper {
private async computeDesktopIcons(): Promise<Array<Array<string>>> {
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)))
}
}

Expand Down Expand Up @@ -97,7 +97,7 @@ export class LinuxTargetHelper {
private async createFromIcns(tempDir: string): Promise<Array<Array<string>>> {
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") {
Expand Down
9 changes: 5 additions & 4 deletions src/targets/fpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>([afterInstallFilePath, afterRemoveFilePath])
//noinspection ES6MissingAwait
return await BluebirdPromise.all<string>([
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<any> {
Expand Down
2 changes: 1 addition & 1 deletion src/winPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {
}

//noinspection JSMethodCanBeStatic
protected async doSign(options: SignOptions): Promise<any> {
protected doSign(options: SignOptions): Promise<any> {
return sign(options)
}

Expand Down
6 changes: 3 additions & 3 deletions test/src/helpers/fileAssert.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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`)
}
Expand Down
6 changes: 3 additions & 3 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down Expand Up @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions test/src/nsisUpdaterTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand All @@ -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)
})
Expand Down Expand Up @@ -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)
})
Expand Down

0 comments on commit 1057499

Please sign in to comment.