Skip to content

Commit

Permalink
fix: ${arch} missing from app-update.yml
Browse files Browse the repository at this point in the history
Close #1389
  • Loading branch information
develar committed Mar 25, 2017
1 parent 0f0de81 commit 77558e6
Show file tree
Hide file tree
Showing 28 changed files with 97 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ export default class SquirrelWindowsTarget extends Target {

await buildInstaller(<SquirrelOptions>distOptions, installerOutDir, setupFileName, packager, appOutDir)

packager.dispatchArtifactCreated(path.join(installerOutDir, setupFileName), this, `${appInfo.name}-Setup-${version}${archSuffix}.exe`)
packager.dispatchArtifactCreated(path.join(installerOutDir, setupFileName), this, arch, `${appInfo.name}-Setup-${version}${archSuffix}.exe`)

const packagePrefix = `${appInfo.name}-${convertVersion(version)}-`
packager.dispatchArtifactCreated(path.join(installerOutDir, `${packagePrefix}full.nupkg`), this)
packager.dispatchArtifactCreated(path.join(installerOutDir, `${packagePrefix}full.nupkg`), this, arch)
if (distOptions.remoteReleases != null) {
packager.dispatchArtifactCreated(path.join(installerOutDir, `${packagePrefix}delta.nupkg`), this)
packager.dispatchArtifactCreated(path.join(installerOutDir, `${packagePrefix}delta.nupkg`), this, arch)
}

packager.dispatchArtifactCreated(path.join(installerOutDir, "RELEASES"), this)
packager.dispatchArtifactCreated(path.join(installerOutDir, "RELEASES"), this, arch)
}

async computeEffectiveDistOptions(): Promise<SquirrelOptions> {
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default class MacPackager extends PlatformPackager<MacOptions> {

const pkg = path.join(outDir!, this.expandArtifactNamePattern(masOptions, "pkg"))
await this.doFlat(appPath, pkg, masInstallerIdentity, keychainName)
this.dispatchArtifactCreated(pkg, null, `${this.appInfo.name}-${this.appInfo.version}.pkg`)
this.dispatchArtifactCreated(pkg, null, Arch.x64, `${this.appInfo.name}-${this.appInfo.version}.pkg`)
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/electron-builder/src/packagerApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export interface BuildInfo {
export interface ArtifactCreated {
readonly packager: PlatformPackager<any>
readonly target: Target | null
readonly arch: Arch | null

readonly file?: string
readonly data?: Buffer
Expand Down
6 changes: 2 additions & 4 deletions packages/electron-builder/src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,10 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
return this.info.prepackaged || path.join(outDir, `${this.platform.buildConfigurationKey}${getArchSuffix(arch)}${this.platform === Platform.MAC ? "" : "-unpacked"}`)
}

dispatchArtifactCreated(file: string, target: Target | null, safeArtifactName?: string) {
dispatchArtifactCreated(file: string, target: Target | null, arch: Arch | null, safeArtifactName?: string) {
this.info.dispatchArtifactCreated({
file: file,
safeArtifactName: safeArtifactName,
file, safeArtifactName, target, arch,
packager: this,
target: target,
})
}

Expand Down
30 changes: 16 additions & 14 deletions packages/electron-builder/src/publish/PublishManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BluebirdPromise from "bluebird-lst"
import { createHash } from "crypto"
import { Platform, PlatformSpecificBuildOptions, Target } from "electron-builder-core"
import { Arch, Platform, PlatformSpecificBuildOptions, Target } from "electron-builder-core"
import { CancellationToken } from "electron-builder-http/out/CancellationToken"
import { BintrayOptions, GenericServerOptions, GithubOptions, githubUrl, PublishConfiguration, PublishProvider, S3Options, s3Url, UpdateInfo, VersionInfo } from "electron-builder-http/out/publishOptions"
import { asArray, debug, isEmptyOrSpaces, isPullRequest, safeStringifyJson } from "electron-builder-util"
Expand Down Expand Up @@ -73,7 +73,7 @@ export class PublishManager implements PublishContext {
return
}

const publishConfigs = await getPublishConfigsForUpdateInfo(packager, await getPublishConfigs(packager, null))
const publishConfigs = await getPublishConfigsForUpdateInfo(packager, await getPublishConfigs(packager, null, event.arch), event.arch)
if (publishConfigs == null || publishConfigs.length === 0) {
return
}
Expand All @@ -96,7 +96,7 @@ export class PublishManager implements PublishContext {
private async artifactCreated(event: ArtifactCreated) {
const packager = event.packager
const target = event.target
const publishConfigs = event.publishConfig == null ? await getPublishConfigs(packager, target == null ? null : target.options) : [event.publishConfig]
const publishConfigs = event.publishConfig == null ? await getPublishConfigs(packager, target == null ? null : target.options, event.arch) : [event.publishConfig]

const eventFile = event.file
if (publishConfigs == null) {
Expand Down Expand Up @@ -184,7 +184,7 @@ export class PublishManager implements PublishContext {
}
}

export async function getPublishConfigsForUpdateInfo(packager: PlatformPackager<any>, publishConfigs: Array<PublishConfiguration> | null): Promise<Array<PublishConfiguration> | null> {
export async function getPublishConfigsForUpdateInfo(packager: PlatformPackager<any>, publishConfigs: Array<PublishConfiguration> | null, arch: Arch | null): Promise<Array<PublishConfiguration> | null> {
if (publishConfigs === null) {
return null
}
Expand All @@ -195,7 +195,7 @@ export async function getPublishConfigsForUpdateInfo(packager: PlatformPackager<
// default publish config is github, file should be generated regardless of publish state (user can test installer locally or manage the release process manually)
const repositoryInfo = await packager.info.repositoryInfo
if (repositoryInfo != null && repositoryInfo.type === "github") {
const resolvedPublishConfig = await getResolvedPublishConfig(packager, {provider: repositoryInfo.type}, false)
const resolvedPublishConfig = await getResolvedPublishConfig(packager, {provider: repositoryInfo.type}, arch, false)
if (resolvedPublishConfig != null) {
return [resolvedPublishConfig]
}
Expand All @@ -206,7 +206,7 @@ export async function getPublishConfigsForUpdateInfo(packager: PlatformPackager<

async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<PublishConfiguration>) {
const packager = event.packager
const publishConfigs = await getPublishConfigsForUpdateInfo(packager, _publishConfigs)
const publishConfigs = await getPublishConfigsForUpdateInfo(packager, _publishConfigs, event.arch)
if (publishConfigs == null || publishConfigs.length === 0) {
return
}
Expand Down Expand Up @@ -236,6 +236,7 @@ async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<Pu

packager.info.dispatchArtifactCreated({
file: updateInfoFile,
arch: null,
packager: packager,
target: null,
publishConfig: publishConfig,
Expand Down Expand Up @@ -273,13 +274,15 @@ async function writeWindowsUpdateInfo(event: ArtifactCreated, version: string, o
packager: packager,
target: null,
publishConfig: githubPublishConfig,
arch: null,
})
}

const genericPublishConfig = publishConfigs.find(it => it.provider === "generic" || it.provider === "s3")
if (genericPublishConfig != null) {
packager.info.dispatchArtifactCreated({
file: updateInfoFile,
arch: null,
packager: packager,
target: null,
publishConfig: genericPublishConfig,
Expand Down Expand Up @@ -347,7 +350,7 @@ export function computeDownloadUrl(publishConfig: PublishConfiguration, fileName
return `${baseUrl}/${encodeURI(fileName)}`
}

export async function getPublishConfigs(packager: PlatformPackager<any>, targetSpecificOptions: PlatformSpecificBuildOptions | null | undefined): Promise<Array<PublishConfiguration> | null> {
export async function getPublishConfigs(packager: PlatformPackager<any>, targetSpecificOptions: PlatformSpecificBuildOptions | null | undefined, arch: Arch | null): Promise<Array<PublishConfiguration> | null> {
let publishers

// check build.nsis (target)
Expand Down Expand Up @@ -385,7 +388,7 @@ export async function getPublishConfigs(packager: PlatformPackager<any>, targetS

if (serviceName != null) {
debug(`Detect ${serviceName} as publish provider`)
return [(await getResolvedPublishConfig(packager, {provider: serviceName}))!]
return [(await getResolvedPublishConfig(packager, {provider: serviceName}, arch))!]
}
}

Expand All @@ -394,7 +397,7 @@ export async function getPublishConfigs(packager: PlatformPackager<any>, targetS
}

debug(`Explicit publish provider: ${safeStringifyJson(publishers)}`)
return await (<Promise<Array<PublishConfiguration>>>BluebirdPromise.map(asArray(publishers), it => getResolvedPublishConfig(packager, typeof it === "string" ? {provider: it} : it)))
return await (<Promise<Array<PublishConfiguration>>>BluebirdPromise.map(asArray(publishers), it => getResolvedPublishConfig(packager, typeof it === "string" ? {provider: it} : it, arch)))
}

function sha256(file: string) {
Expand Down Expand Up @@ -423,22 +426,21 @@ function getCiTag() {
return tag != null && tag.length > 0 ? tag : null
}

function expandPublishConfig(options: any, packager: PlatformPackager<any>): void {
function expandPublishConfig(options: any, packager: PlatformPackager<any>, arch: Arch | null): void {
for (const name of Object.keys(options)) {
const value = options[name]
if (typeof value === "string") {
const expanded = packager.expandMacro(value, null)
const expanded = packager.expandMacro(value, arch)
if (expanded !== value) {
options[name] = expanded
}
}
}
}


async function getResolvedPublishConfig(packager: PlatformPackager<any>, options: PublishConfiguration, errorIfCannot: boolean = true): Promise<PublishConfiguration | null> {
async function getResolvedPublishConfig(packager: PlatformPackager<any>, options: PublishConfiguration, arch: Arch | null, errorIfCannot: boolean = true): Promise<PublishConfiguration | null> {
options = Object.assign(Object.create(null), options)
expandPublishConfig(options, packager)
expandPublishConfig(options, packager, arch)

const provider = options.provider
if (provider === "generic") {
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/ArchiveTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ export class ArchiveTarget extends Target {
await archive(packager.config.compression, format, outFile, appOutDir)
}

packager.dispatchArtifactCreated(outFile, this, isMac ? packager.generateName2(format, "mac", true) : packager.generateName(format, arch, true, packager.platform === Platform.WINDOWS ? "win" : null))
packager.dispatchArtifactCreated(outFile, this, Arch.x64, isMac ? packager.generateName2(format, "mac", true) : packager.generateName(format, arch, true, packager.platform === Platform.WINDOWS ? "win" : null))
}
}
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/WebInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class WebInstallerTarget extends NsisTarget {

let appPackageUrl = (<NsisWebOptions>options).appPackageUrl
if (appPackageUrl == null) {
const publishConfigs = await getPublishConfigsForUpdateInfo(packager, await getPublishConfigs(packager, this.options))
const publishConfigs = await getPublishConfigsForUpdateInfo(packager, await getPublishConfigs(packager, this.options, null), null)
if (publishConfigs == null || publishConfigs.length === 0) {
throw new Error("Cannot compute app package download URL")
}
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/appImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ export default class AppImageTarget extends Target {

await chmod(resultFile, "0755")

packager.dispatchArtifactCreated(resultFile, this)
packager.dispatchArtifactCreated(resultFile, this, arch)
}
}
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/appx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default class AppXTarget extends Target {
await spawn(path.join(vendorPath, "windows-10", arch === Arch.ia32 ? "ia32" : "x64", "makeappx.exe"), args)

await packager.sign(destination)
packager.dispatchArtifactCreated(destination, this, packager.generateName("appx", arch, true))
packager.dispatchArtifactCreated(destination, this, arch, packager.generateName("appx", arch, true))
}

private async writeManifest(templatePath: string, preAppx: string, safeName: string, arch: Arch, publisher: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/dmg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class DmgTarget extends Target {
await spawn("hdiutil", addVerboseIfNeed(["convert", tempDmg, "-ov", "-format", specification.format!, "-imagekey", `zlib-level=${process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL || "9"}`, "-o", artifactPath]))
await exec("hdiutil", addVerboseIfNeed(["internet-enable", "-no"]).concat(artifactPath))

this.packager.dispatchArtifactCreated(artifactPath, this, `${appInfo.name}-${appInfo.version}.dmg`)
this.packager.dispatchArtifactCreated(artifactPath, this, arch, `${appInfo.name}-${appInfo.version}.dmg`)
}

computeVolumeName(custom?: string | null): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/fpm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default class FpmTarget extends Target {

await exec(await fpmPath, args)

this.packager.dispatchArtifactCreated(destination, this)
this.packager.dispatchArtifactCreated(destination, this, arch)
}
}

Expand Down
6 changes: 2 additions & 4 deletions packages/electron-builder/src/targets/nsis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export default class NsisTarget extends Target {
warn('"electron-squirrel-startup" dependency is not required for NSIS')
}
}



async build(appOutDir: string, arch: Arch) {
this.archs.set(arch, appOutDir)
Expand Down Expand Up @@ -142,7 +140,7 @@ export default class NsisTarget extends Target {
defines[(arch === Arch.x64 ? "APP_64" : "APP_32") + "_NAME"] = path.basename(file)

if (this.isWebInstaller) {
packager.dispatchArtifactCreated(file, this)
packager.dispatchArtifactCreated(file, this, arch)
}
else {
filesToDelete.push(file)
Expand Down Expand Up @@ -176,7 +174,7 @@ export default class NsisTarget extends Target {
await this.executeMakensis(defines, commands, await this.computeFinalScript(script, true))
await packager.sign(installerPath)

packager.dispatchArtifactCreated(installerPath, this, this.generateGitHubInstallerName())
packager.dispatchArtifactCreated(installerPath, this, this.archs.size === 1 ? this.archs.keys().next().value : null, this.generateGitHubInstallerName())
}

protected generateGitHubInstallerName() {
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/pkg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class PkgTarget extends Target {
})
await BluebirdPromise.all([unlink(innerPackageFile), unlink(distInfo)])

packager.dispatchArtifactCreated(outFile, this, `${appInfo.name}-${appInfo.version}.pkg`)
packager.dispatchArtifactCreated(outFile, this, arch, `${appInfo.name}-${appInfo.version}.pkg`)
}

private async buildComponentPackage(appPath: string, outFile: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/targets/snap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ export default class SnapTarget extends Target {
stdio: ["ignore", "inherit", "pipe"],
})
}
packager.dispatchArtifactCreated(resultFile, this)
packager.dispatchArtifactCreated(resultFile, this, arch)
}
}
5 changes: 5 additions & 0 deletions test/out/__snapshots__/ExtraBuildTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`custom buildResources and output dirs: linux 1`] = `
Object {
"linux": Array [
Object {
"arch": 1,
"file": "TestApp-1.1.0-x86_64.AppImage",
},
],
Expand All @@ -20,6 +21,7 @@ exports[`custom buildResources and output dirs: win 1`] = `
Object {
"win": Array [
Object {
"arch": 1,
"file": "Test App ßW Setup 1.1.0.exe",
"safeArtifactName": "TestApp-Setup-1.1.0.exe",
},
Expand All @@ -31,6 +33,7 @@ exports[`override targets in the config - only arch 1`] = `
Object {
"win": Array [
Object {
"arch": 0,
"file": "Test App ßW Setup 1.1.0.exe",
"safeArtifactName": "TestApp-Setup-1.1.0.exe",
},
Expand Down Expand Up @@ -123,9 +126,11 @@ exports[`scheme validation extraFiles 1`] = `
Object {
"linux": Array [
Object {
"arch": 1,
"file": "TestApp-1.1.0-x86_64.AppImage",
},
Object {
"arch": 1,
"file": "TestApp-1.1.0-ia32.zip",
"safeArtifactName": "TestApp-1.1.0-ia32.zip",
},
Expand Down
3 changes: 3 additions & 0 deletions test/out/__snapshots__/filesTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ exports[`extraResources on Linux and Windows 2`] = `
Object {
"win": Array [
Object {
"arch": 1,
"file": "RELEASES",
},
Object {
"arch": 1,
"file": "Test App ßW Setup 1.1.0.exe",
"safeArtifactName": "TestApp-Setup-1.1.0.exe",
},
Object {
"arch": 1,
"file": "TestApp-1.1.0-full.nupkg",
},
],
Expand Down
2 changes: 2 additions & 0 deletions test/out/linux/__snapshots__/debTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`arm deb 1`] = `
Object {
"linux": Array [
Object {
"arch": 2,
"file": "TestApp_1.1.0_armv7l.deb",
},
],
Expand All @@ -26,6 +27,7 @@ exports[`deb 1`] = `
Object {
"linux": Array [
Object {
"arch": 1,
"file": "TestApp_1.1.0_amd64.deb",
},
],
Expand Down
7 changes: 7 additions & 0 deletions test/out/linux/__snapshots__/fpmTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ exports[`rpm and tar.gz 1`] = `
Object {
"linux": Array [
Object {
"arch": 1,
"file": "TestApp-1.1.0.rpm",
},
Object {
"arch": 1,
"file": "TestApp-1.1.0.tar.gz",
"safeArtifactName": "TestApp-1.1.0.tar.gz",
},
Expand All @@ -18,19 +20,24 @@ exports[`targets 1`] = `
Object {
"linux": Array [
Object {
"arch": 1,
"file": "TestApp-1.1.0.7z",
"safeArtifactName": "TestApp-1.1.0.7z",
},
Object {
"arch": 1,
"file": "TestApp-1.1.0.freebsd",
},
Object {
"arch": 1,
"file": "TestApp-1.1.0.pacman",
},
Object {
"arch": 1,
"file": "TestApp-1.1.0.sh",
},
Object {
"arch": 1,
"file": "TestApp-1.1.0.zip",
"safeArtifactName": "TestApp-1.1.0.zip",
},
Expand Down
Loading

0 comments on commit 77558e6

Please sign in to comment.