diff --git a/.idea/rc-producer.yml b/.idea/rc-producer.yml index a54d8d6e78a..811b203e328 100644 --- a/.idea/rc-producer.yml +++ b/.idea/rc-producer.yml @@ -7,7 +7,7 @@ - <<: *defaults - lineRegExp: '^\s*(?:test|it)(?:\.\w+)?\("([^"'']+)' + lineRegExp: '^\s*(?:test|it|testAndIgnoreApiRate)(?:\.\w+)?\("([^"'']+)' scriptArgs: ["-i", "--env", "jest-environment-node-debug", "-t", "${0regExp}", *filePattern] rcName: "${fileNameWithoutExt}.${0}" env: diff --git a/.travis.yml b/.travis.yml index 3d0325aa83a..a3697c2d51f 100755 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,8 @@ language: c cache: directories: - node_modules + - packages/electron-builder/node_modules + - packages/electron-builder-util/node_modules - $HOME/.electron - /tmp/jest-electron-builder-tests diff --git a/appveyor.yml b/appveyor.yml index b5e2cc20789..7cd7587a246 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,6 +3,8 @@ platform: cache: - node_modules + - packages/electron-builder/node_modules + - packages/electron-builder-util/node_modules - '%USERPROFILE%\.electron' environment: diff --git a/packages/electron-auto-updater/src/GitHubProvider.ts b/packages/electron-auto-updater/src/GitHubProvider.ts index 7bf93c91b53..6f44e0677e4 100644 --- a/packages/electron-auto-updater/src/GitHubProvider.ts +++ b/packages/electron-auto-updater/src/GitHubProvider.ts @@ -51,7 +51,7 @@ export class GitHubProvider implements Provider { async getUpdateFile(versionInfo: UpdateInfo): Promise { const basePath = this.getBasePath() // space is not supported on GitHub - const name = path.posix.basename(versionInfo.path).replace(/ /g, "-") + const name = versionInfo.githubArtifactName || path.posix.basename(versionInfo.path).replace(/ /g, "-") return { name: name, url: `https://github.com${basePath}/download/v${versionInfo.version}/${name}`, diff --git a/packages/electron-builder-http/src/publishOptions.ts b/packages/electron-builder-http/src/publishOptions.ts index a1b2a401351..f7cdb91ec81 100644 --- a/packages/electron-builder-http/src/publishOptions.ts +++ b/packages/electron-builder-http/src/publishOptions.ts @@ -49,6 +49,7 @@ export interface VersionInfo { export interface UpdateInfo extends VersionInfo { readonly path: string + readonly githubArtifactName?: string | null readonly sha2: string } diff --git a/packages/electron-builder/src/builder.ts b/packages/electron-builder/src/builder.ts index c2a0057aab9..01a1a8c208a 100644 --- a/packages/electron-builder/src/builder.ts +++ b/packages/electron-builder/src/builder.ts @@ -291,13 +291,7 @@ function publishManager(packager: Packager, publishTasks: Array>it.uploadData(event.data!, event.artifactName!)) - } - else { - return publishTasks.push(>it.upload(event.file!, event.artifactName)) - } + return publishTasks.push(>it.upload(event.file, event.artifactName)) }) } } diff --git a/packages/electron-builder/src/platformPackager.ts b/packages/electron-builder/src/platformPackager.ts index b1e2c5e3e0d..c3b3c7cc385 100644 --- a/packages/electron-builder/src/platformPackager.ts +++ b/packages/electron-builder/src/platformPackager.ts @@ -541,8 +541,7 @@ export interface RepositoryInfo { export interface ArtifactCreated { readonly packager: PlatformPackager - readonly file?: string - readonly data?: Buffer + readonly file: string readonly artifactName?: string @@ -586,6 +585,7 @@ export function getPublishConfigs(packager: PlatformPackager, platformSpeci if (publishers == null) { publishers = packager.config.publish + // triple equals - if explicitly set to null if (publishers === null) { return null } diff --git a/packages/electron-builder/src/targets/nsis.ts b/packages/electron-builder/src/targets/nsis.ts index 446a5ecabc9..410caf069f5 100644 --- a/packages/electron-builder/src/targets/nsis.ts +++ b/packages/electron-builder/src/targets/nsis.ts @@ -14,6 +14,7 @@ import { safeDump } from "js-yaml" import { createHash } from "crypto" import { Target, Arch } from "electron-builder-core" import sanitizeFileName from "sanitize-filename" +import { unlinkIfExists } from "../../../electron-builder-util/src/fs" const NSIS_VERSION = "3.0.4" //noinspection SpellCheckingInspection @@ -42,14 +43,25 @@ export default class NsisTarget extends Target { } } - private computePublishConfigs(): Promise | null> { - const publishConfigs = getPublishConfigs(this.packager, this.options) - if (publishConfigs != null && publishConfigs.length > 0) { - return BluebirdPromise.map(publishConfigs, it => getResolvedPublishConfig(this.packager.info, it, true)) + private async computePublishConfigs(): Promise | null> { + let publishConfigs = getPublishConfigs(this.packager, this.options) + if (publishConfigs == null) { + return null } - else { - return BluebirdPromise.resolve(null) + + if (publishConfigs.length === 0) { + // https://github.com/electron-userland/electron-builder/issues/925#issuecomment-261732378 + // 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 this.packager.getRepositoryInfo() + if (repositoryInfo != null && repositoryInfo.type === "github") { + publishConfigs = [{provider: "github"}] + } + else { + return null + } } + + return await BluebirdPromise.map(publishConfigs, it => >getResolvedPublishConfig(this.packager.info, it, true)) } build(appOutDir: string, arch: Arch) { @@ -226,36 +238,36 @@ export default class NsisTarget extends Target { const publishConfigs = await this.publishConfigs const githubArtifactName = `${appInfo.name}-Setup-${version}.exe` if (publishConfigs != null) { - let sha2: string | null = null for (const publishConfig of publishConfigs) { - if (publishConfig.provider === "generic" || publishConfig.provider === "github") { - if (sha2 == null) { - sha2 = await sha256(installerPath) - } + if (!(publishConfig.provider === "generic" || publishConfig.provider === "github")) { + continue + } - const channel = (publishConfig).channel || "latest" - if (publishConfig.provider === "generic") { - await writeFile(path.join(this.outDir, `${channel}.yml`), safeDump({ - version: version, - path: installerFilename, - sha2: sha2, - })) - } - else { - packager.info.eventEmitter.emit("artifactCreated", { - data: new Buffer(safeDump({ - version: version, - path: githubArtifactName, - sha2: sha2, - })), - artifactName: `${channel}.yml`, - packager: packager, - publishConfig: publishConfig, - }) - } + const sha2 = await sha256(installerPath) + const channel = (publishConfig).channel || "latest" + const updateInfoFile = path.join(this.outDir, `${channel}.yml`) + await writeFile(updateInfoFile, safeDump({ + version: version, + githubArtifactName: githubArtifactName, + path: installerFilename, + sha2: sha2, + })) + + const githubPublishConfig = publishConfigs.find(it => it.provider === "github") + if (githubPublishConfig != null) { + packager.info.eventEmitter.emit("artifactCreated", { + file: updateInfoFile, + packager: packager, + publishConfig: githubPublishConfig, + }) } + + break } } + else { + await unlinkIfExists(path.join(this.outDir, `latest.yml`)) + } packager.dispatchArtifactCreated(installerPath, githubArtifactName) } diff --git a/packages/electron-builder/src/winPackager.ts b/packages/electron-builder/src/winPackager.ts index 599fd629707..8ecdecef08e 100644 --- a/packages/electron-builder/src/winPackager.ts +++ b/packages/electron-builder/src/winPackager.ts @@ -78,10 +78,18 @@ export class WinPackager extends PlatformPackager { switch (name) { case "nsis": return require("./targets/nsis").default + case "squirrel": - return require("electron-builder-squirrel-windows").default + try { + return require("electron-builder-squirrel-windows").default + } + catch (e) { + throw new Error(`Since electron-builder 11, module electron-builder-squirrel-windows must be installed in addition to build Squirrel.Windows: ${e.stack || e}`) + } + case "appx": return require("./targets/appx").default + default: return null }