From 8670d5a90ff7627b807cfc5caf97471672fff4ea Mon Sep 17 00:00:00 2001 From: develar Date: Mon, 16 Jan 2017 20:59:40 +0100 Subject: [PATCH] fix: generate latest-mac.json for github in the github directory --- docs/Auto Update.md | 2 + package.json | 1 - packages/electron-builder/src/asarUtil.ts | 3 +- packages/electron-builder/src/builder.ts | 12 +- packages/electron-builder/src/metadata.ts | 11 +- .../electron-builder/src/platformPackager.ts | 68 +----- .../src/publish/PublishManager.ts | 220 ++++++++++++------ packages/electron-builder/src/targets/nsis.ts | 73 +----- test/src/ArtifactPublisherTest.ts | 27 --- test/src/mac/macArchiveTest.ts | 6 +- test/src/windows/winPackagerTest.ts | 4 +- typings/asar.d.ts | 10 - yarn.lock | 8 +- 13 files changed, 184 insertions(+), 261 deletions(-) diff --git a/docs/Auto Update.md b/docs/Auto Update.md index 9eb65fec9c9..1bfeaaad724 100644 --- a/docs/Auto Update.md +++ b/docs/Auto Update.md @@ -2,6 +2,8 @@ See the [Publishing Artifacts](https://github.com/electron-userland/electron-bui Real project [example](https://github.com/develar/onshape-desktop-shell/blob/master/src/AppUpdater.ts). +Simplified auto-update is not supported for Squirrel.Windows. + ## Quick Setup Guide 1. Install `electron-auto-updater` as an app dependency. diff --git a/package.json b/package.json index 380db61ca30..7a3f3f336ad 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,6 @@ "test": "node ./test/out/helpers/runTests.js skipFpm skipSw skipArtifactPublisher", "test-all": "node ./test/vendor/yarn.js pretest && node ./test/out/helpers/runTests.js", "test-linux": "docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine /bin/bash -c \"node ./test/vendor/yarn.js && node ./test/vendor/yarn.js test\"", - "semantic-release": "semantic-release pre && npm publish && semantic-release post", "//": "Update wiki if docs changed. Update only if functionalily are generally available (latest release, not next)", "update-wiki": "git subtree split -b wiki --prefix docs/ && git push -f wiki wiki:master", "whitespace": "whitespace 'src/**/*.ts'", diff --git a/packages/electron-builder/src/asarUtil.ts b/packages/electron-builder/src/asarUtil.ts index d2ecd085538..d3b0c081362 100644 --- a/packages/electron-builder/src/asarUtil.ts +++ b/packages/electron-builder/src/asarUtil.ts @@ -1,4 +1,4 @@ -import { AsarFileInfo, listPackage, statFile, AsarOptions } from "asar-electron-builder" +import { AsarFileInfo, listPackage, statFile } from "asar-electron-builder" import { debug } from "electron-builder-util" import { readFile, Stats, createWriteStream, ensureDir, createReadStream, readJson, writeFile, readlink, stat } from "fs-extra-p" import BluebirdPromise from "bluebird-lst-c" @@ -6,6 +6,7 @@ import * as path from "path" import { log } from "electron-builder-util/out/log" import { deepAssign } from "electron-builder-util/out/deepAssign" import { walk, statOrNull, CONCURRENCY, MAX_FILE_REQUESTS, Filter, FileCopier } from "electron-builder-util/out/fs" +import { AsarOptions } from "./metadata" const isBinaryFile: any = BluebirdPromise.promisify(require("isbinaryfile")) const pickle = require ("chromium-pickle-js") diff --git a/packages/electron-builder/src/builder.ts b/packages/electron-builder/src/builder.ts index d058c99e2f2..497f9c7fe87 100644 --- a/packages/electron-builder/src/builder.ts +++ b/packages/electron-builder/src/builder.ts @@ -202,20 +202,16 @@ export async function build(rawOptions?: CliOptions): Promise> { } const packager = new Packager(options) - //noinspection JSMismatchedCollectionQueryUpdate - const artifactPaths: Array = [] + // because artifact event maybe dispatched several times for different publish providers + const artifactPaths = new Set() packager.artifactCreated(event => { if (event.file != null) { - artifactPaths.push(event.file) + artifactPaths.add(event.file) } }) const publishManager = new PublishManager(packager, options) - return await executeFinally(packager.build().then(() => artifactPaths), errorOccurred => { - if (publishManager == null) { - return BluebirdPromise.resolve(null) - } - + return await executeFinally(packager.build().then(() => Array.from(artifactPaths)), errorOccurred => { if (errorOccurred) { publishManager.cancelTasks() return BluebirdPromise.resolve(null) diff --git a/packages/electron-builder/src/metadata.ts b/packages/electron-builder/src/metadata.ts index 6e62a6a15d2..0ceef0847c0 100755 --- a/packages/electron-builder/src/metadata.ts +++ b/packages/electron-builder/src/metadata.ts @@ -1,4 +1,3 @@ -import { AsarOptions } from "asar-electron-builder" import { PlatformPackager } from "./platformPackager" import { MacOptions, DmgOptions, MasBuildOptions } from "./options/macOptions" import { Publish } from "electron-builder-http/out/publishOptions" @@ -6,6 +5,16 @@ import { WinBuildOptions, NsisOptions, SquirrelWindowsOptions, AppXOptions } fro import { LinuxBuildOptions, SnapOptions } from "./options/linuxOptions" import { Platform } from "electron-builder-core" +export interface AsarOptions { + dot?: boolean + + smartUnpack?: boolean + + ordering?: string | null + + extraMetadata?: any | null +} + /* ## Fields in the package.json diff --git a/packages/electron-builder/src/platformPackager.ts b/packages/electron-builder/src/platformPackager.ts index 879ef73b2fb..e5cc6f40a94 100644 --- a/packages/electron-builder/src/platformPackager.ts +++ b/packages/electron-builder/src/platformPackager.ts @@ -1,20 +1,17 @@ -import { PlatformSpecificBuildOptions, FileAssociation, Config } from "./metadata" +import { PlatformSpecificBuildOptions, FileAssociation, Config, AsarOptions } from "./metadata" import BluebirdPromise from "bluebird-lst-c" import * as path from "path" import { readdir, remove, rename } from "fs-extra-p" import { use, isEmptyOrSpaces, asArray, debug } from "electron-builder-util" -import { AsarOptions } from "asar-electron-builder" import { Minimatch } from "minimatch" import { checkFileInArchive, createAsarArchive } from "./asarUtil" import { warn, log } from "electron-builder-util/out/log" import { AppInfo } from "./appInfo" import { unpackElectron } from "./packager/dirPackager" import { FileMatchOptions, FileMatcher, FilePattern, deprecatedUserIgnoreFilter } from "./fileMatcher" -import { PublishConfiguration } from "electron-builder-http/out/publishOptions" import { deepAssign } from "electron-builder-util/out/deepAssign" import { statOrNull, unlinkIfExists, copyDir } from "electron-builder-util/out/fs" import { Arch, Target, getArchSuffix, Platform } from "electron-builder-core" -import { getResolvedPublishConfig } from "./publish/publisher" import { readInstalled } from "./readInstalled" import { PackagerOptions, BuildInfo } from "./packagerApi" @@ -336,7 +333,7 @@ export abstract class PlatformPackager return fileMatchers.length === 0 ? null : fileMatchers } - private getResourcesDir(appOutDir: string): string { + public getResourcesDir(appOutDir: string): string { return this.platform === Platform.MAC ? this.getMacOsResourcesDir(appOutDir) : path.join(appOutDir, "resources") } @@ -465,27 +462,6 @@ export abstract class PlatformPackager } return null } - - async computePublishConfigs(targetSpecificOptions: PlatformSpecificBuildOptions | null): Promise | null> { - let publishConfigs = getPublishConfigs(this, targetSpecificOptions) - if (publishConfigs == null) { - return 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.info.repositoryInfo - if (repositoryInfo != null && repositoryInfo.type === "github") { - publishConfigs = [{provider: "github"}] - } - else { - return null - } - } - - return await BluebirdPromise.map(publishConfigs, it => >getResolvedPublishConfig(this.info, it, true)) - } } // remove leading dot @@ -493,46 +469,6 @@ export function normalizeExt(ext: string) { return ext.startsWith(".") ? ext.substring(1) : ext } -export function getPublishConfigs(packager: PlatformPackager, targetSpecificOptions: PlatformSpecificBuildOptions | null | undefined): Array | null { - let publishers - - // check build.nsis (target) - if (targetSpecificOptions != null) { - publishers = targetSpecificOptions.publish - // if explicitly set to null - do not publish - if (publishers === null) { - return null - } - } - - // check build.win (platform) - if (publishers == null) { - publishers = packager.platformSpecificBuildOptions.publish - if (publishers === null) { - return null - } - } - - if (publishers == null) { - publishers = packager.config.publish - // triple equals - if explicitly set to null - if (publishers === null) { - return null - } - - if (publishers == null && !isEmptyOrSpaces(process.env.GH_TOKEN)) { - publishers = [{provider: "github"}] - } - // if both tokens are set — still publish to github (because default publisher is github) - if (publishers == null && !isEmptyOrSpaces(process.env.BT_TOKEN)) { - publishers = [{provider: "bintray"}] - } - } - - return asArray(publishers) - .map(it => typeof it === "string" ? {provider: it} : it) -} - async function dependencies(dir: string, result: Set): Promise { const pathToDep = await readInstalled(dir) for (const dep of pathToDep.values()) { diff --git a/packages/electron-builder/src/publish/PublishManager.ts b/packages/electron-builder/src/publish/PublishManager.ts index 29c10b18232..28b706214e6 100644 --- a/packages/electron-builder/src/publish/PublishManager.ts +++ b/packages/electron-builder/src/publish/PublishManager.ts @@ -1,29 +1,32 @@ import { Packager } from "../packager" -import { getPublishConfigs, PlatformPackager } from "../platformPackager" -import { debug, isEmptyOrSpaces } from "electron-builder-util" +import { PlatformPackager } from "../platformPackager" +import { debug, isEmptyOrSpaces, asArray} from "electron-builder-util" import { Publisher, PublishOptions, getResolvedPublishConfig } from "./publisher" import BluebirdPromise from "bluebird-lst-c" import { GitHubPublisher } from "./gitHubPublisher" -import { PublishConfiguration, GithubOptions, BintrayOptions, GenericServerOptions, VersionInfo } from "electron-builder-http/out/publishOptions" +import { PublishConfiguration, GithubOptions, BintrayOptions, GenericServerOptions, VersionInfo, UpdateInfo } from "electron-builder-http/out/publishOptions" import { log } from "electron-builder-util/out/log" import { BintrayPublisher } from "./BintrayPublisher" import { BuildInfo, ArtifactCreated } from "../packagerApi" import { Platform } from "electron-builder-core" import { safeDump } from "js-yaml" -import { writeFile, writeJson } from "fs-extra-p" +import { writeFile, outputJson, createReadStream } from "fs-extra-p" import * as path from "path" import { ArchiveTarget } from "../targets/ArchiveTarget" import { throwError } from "electron-builder-util/out/promise" import isCi from "is-ci" import * as url from "url" +import { PlatformSpecificBuildOptions } from "../metadata" +import { createHash } from "crypto" export class PublishManager { - private readonly nameToPublisher = new Map>() + private readonly nameToPublisher = new Map() readonly publishTasks: Array> = [] private readonly errors: Array = [] private isPublishOptionGuessed = false + private isPublish = false constructor(packager: Packager, private readonly publishOptions: PublishOptions) { if (publishOptions.publish === undefined) { @@ -45,11 +48,10 @@ export class PublishManager { } } - let isPublish = false if (publishOptions.publish != null && publishOptions.publish !== "never") { // todo if token set as option if (isAuthTokenSet()) { - isPublish = true + this.isPublish = true } else if (isCi) { log(`CI detected, publish is set to ${publishOptions.publish}, but neither GH_TOKEN nor BT_TOKEN is not set, so artifacts will be not published`) @@ -57,54 +59,53 @@ export class PublishManager { } packager.addAfterPackHandler(async event => { - if (event.electronPlatformName != "darwin") { + if (!(event.electronPlatformName == "darwin" || event.packager.platform === Platform.WINDOWS)) { return } const packager = event.packager - const publishConfigs = await getPublishConfigsForUpdateInfo(packager, getPublishConfigs(packager, null)) + const publishConfigs = await getPublishConfigsForUpdateInfo(packager, await getPublishConfigs(packager, null)) if (publishConfigs == null || publishConfigs.length === 0) { return } - await writeFile(path.join(packager.getMacOsResourcesDir(event.appOutDir), "app-update.yml"), safeDump(publishConfigs[0])) + await writeFile(path.join(packager.getResourcesDir(event.appOutDir), "app-update.yml"), safeDump(publishConfigs[0])) }) - packager.artifactCreated(event => { - const packager = event.packager - const target = event.target - const publishConfigs = event.publishConfig == null ? getPublishConfigs(packager, target == null ? null : (packager.config)[target.name]) : [event.publishConfig] + packager.artifactCreated(event => this.addTask(this.artifactCreated(event))) + } - if (isPublish) { - if (publishConfigs == null) { - debug(`${event.file} is not published: no publish configs`) - return - } + private async artifactCreated(event: ArtifactCreated) { + const packager = event.packager + const target = event.target + const publishConfigs = event.publishConfig == null ? await getPublishConfigs(packager, target == null ? null : (packager.config)[target.name]) : [event.publishConfig] + + if (publishConfigs == null) { + if (this.isPublish) { + debug(`${event.file} is not published: no publish configs`) + } + return + } - for (const publishConfig of publishConfigs) { - const publisher = this.getOrCreatePublisher(publishConfig, packager.info) - if (publisher != null) { - this.addTask(publisher - .then(it => { - if (it == null) { - return null - } - - if (event.file == null) { - return it.uploadData(event.data!, event.artifactName!) - } - else { - return it.upload(event.file!, event.artifactName) - } - })) + if (this.isPublish) { + for (const publishConfig of publishConfigs) { + const publisher = this.getOrCreatePublisher(publishConfig, packager.info) + if (publisher != null) { + if (event.file == null) { + this.addTask(publisher.uploadData(event.data!, event.artifactName!)) + } + else { + this.addTask(publisher.upload(event.file!, event.artifactName)) } } } + } - if (publishConfigs != null && packager.platform === Platform.MAC && target != null && target.name === "zip") { + if (target != null && event.file != null) { + if ((packager.platform === Platform.MAC && target.name === "zip") || (packager.platform === Platform.WINDOWS && target.name === "nsis")) { this.addTask(writeUpdateInfo(event, publishConfigs)) } - }) + } } private addTask(promise: Promise) { @@ -112,7 +113,7 @@ export class PublishManager { .catch(it => this.errors.push(it))) } - getOrCreatePublisher(publishConfig: PublishConfiguration, buildInfo: BuildInfo): Promise { + getOrCreatePublisher(publishConfig: PublishConfiguration, buildInfo: BuildInfo): Publisher | null { let publisher = this.nameToPublisher.get(publishConfig.provider) if (publisher == null) { publisher = createPublisher(buildInfo, publishConfig, this.publishOptions, this.isPublishOptionGuessed) @@ -178,50 +179,80 @@ async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Arrayevent.target).outDir - await writeMac(packager, (event.target).outDir, publishConfigs) -} - -async function writeMac(packager: PlatformPackager, outDir: string, publishConfigs: Array) { for (const publishConfig of publishConfigs) { - if (!(publishConfig.provider === "generic" || publishConfig.provider === "github")) { + const isGitHub = publishConfig.provider === "github" + if (!(publishConfig.provider === "generic" || isGitHub)) { continue } + const version = packager.appInfo.version const channel = (publishConfig).channel || "latest" - const updateInfoFile = path.join(outDir, `${channel}-mac.json`) - - await writeJson(updateInfoFile, { - version: packager.appInfo.version, - url: computeDownloadUrl(publishConfig, packager.generateName2("zip", "mac", true), packager.appInfo.version) - }, {spaces: 2}) - - packager.info.dispatchArtifactCreated({ - file: updateInfoFile, - packager: packager, - target: null, - }) + if (packager.platform === Platform.MAC) { + const updateInfoFile = isGitHub ? path.join(outDir, "github", `${channel}-mac.json`) : path.join(outDir, `${channel}-mac.json`) + await (outputJson)(updateInfoFile, { + version: version, + url: computeDownloadUrl(publishConfig, packager.generateName2("zip", "mac", isGitHub), version) + }, {spaces: 2}) + + packager.info.dispatchArtifactCreated({ + file: updateInfoFile, + packager: packager, + target: null, + publishConfig: publishConfig, + }) + } + else { + const githubArtifactName = `${packager.appInfo.name}-Setup-${version}.exe` + const sha2 = await sha256(event.file!) + const updateInfoFile = path.join(outDir, `${channel}.yml`) + await writeFile(updateInfoFile, safeDump({ + version: version, + githubArtifactName: githubArtifactName, + path: path.basename(event.file!), + sha2: sha2, + })) + + const githubPublishConfig = publishConfigs.find(it => it.provider === "github") + if (githubPublishConfig != null) { + // to preserve compatibility with old electron-auto-updater (< 0.10.0), we upload file with path specific for GitHub + packager.info.dispatchArtifactCreated({ + data: new Buffer(safeDump({ + version: version, + path: githubArtifactName, + sha2: sha2, + })), + artifactName: `${channel}.yml`, + packager: packager, + target: null, + publishConfig: githubPublishConfig, + }) + } - break + const genericPublishConfig = publishConfigs.find(it => it.provider === "generic") + if (genericPublishConfig != null) { + packager.info.dispatchArtifactCreated({ + file: updateInfoFile, + packager: packager, + target: null, + publishConfig: genericPublishConfig, + }) + } + break + } } } -// visible only for tests -// call only from this file or from tests -export async function createPublisher(buildInfo: BuildInfo, publishConfig: PublishConfiguration, options: PublishOptions, isPublishOptionGuessed: boolean = false): Promise { - const config = await getResolvedPublishConfig(buildInfo, publishConfig, isPublishOptionGuessed) - if (config == null) { - return null - } - +function createPublisher(buildInfo: BuildInfo, publishConfig: PublishConfiguration, options: PublishOptions, isPublishOptionGuessed: boolean = false): Publisher | null { const version = buildInfo.metadata.version! if (publishConfig.provider === "github") { - const githubInfo: GithubOptions = config + const githubInfo: GithubOptions = publishConfig log(`Creating Github Publisher — owner: ${githubInfo.owner}, project: ${githubInfo.repo}, version: ${version}`) return new GitHubPublisher(githubInfo, version, options, isPublishOptionGuessed) } if (publishConfig.provider === "bintray") { - const bintrayInfo: BintrayOptions = config + const bintrayInfo: BintrayOptions = publishConfig log(`Creating Bintray Publisher — user: ${bintrayInfo.user || bintrayInfo.owner}, owner: ${bintrayInfo.owner}, package: ${bintrayInfo.package}, repository: ${bintrayInfo.repo}, version: ${version}`) return new BintrayPublisher(bintrayInfo, version, options) } @@ -241,4 +272,61 @@ function computeDownloadUrl(publishConfig: PublishConfiguration, fileName: strin const gh = publishConfig return `https://github.com${`/${gh.owner}/${gh.repo}/releases`}/download/v${version}/${fileName}` } +} + +export function getPublishConfigs(packager: PlatformPackager, targetSpecificOptions: PlatformSpecificBuildOptions | null | undefined): Promise> | null { + let publishers + + // check build.nsis (target) + if (targetSpecificOptions != null) { + publishers = targetSpecificOptions.publish + // if explicitly set to null - do not publish + if (publishers === null) { + return null + } + } + + // check build.win (platform) + if (publishers == null) { + publishers = packager.platformSpecificBuildOptions.publish + if (publishers === null) { + return null + } + } + + if (publishers == null) { + publishers = packager.config.publish + // triple equals - if explicitly set to null + if (publishers === null) { + return null + } + + if (publishers == null && !isEmptyOrSpaces(process.env.GH_TOKEN)) { + publishers = [{provider: "github"}] + } + // if both tokens are set — still publish to github (because default publisher is github) + if (publishers == null && !isEmptyOrSpaces(process.env.BT_TOKEN)) { + publishers = [{provider: "bintray"}] + } + } + + //await getResolvedPublishConfig(packager.info, {provider: repositoryInfo.type}, false) + return BluebirdPromise.map(asArray(publishers), it => typeof it === "string" ? getResolvedPublishConfig(packager.info, {provider: it}, true) : it) +} + +function sha256(file: string) { + return new BluebirdPromise((resolve, reject) => { + const hash = createHash("sha256") + hash + .on("error", reject) + .setEncoding("hex") + + createReadStream(file) + .on("error", reject) + .on("end", () => { + hash.end() + resolve(hash.read()) + }) + .pipe(hash, {end: false}) + }) } \ No newline at end of file diff --git a/packages/electron-builder/src/targets/nsis.ts b/packages/electron-builder/src/targets/nsis.ts index 1876fd858a3..a49b09417aa 100644 --- a/packages/electron-builder/src/targets/nsis.ts +++ b/packages/electron-builder/src/targets/nsis.ts @@ -7,14 +7,10 @@ import { v5 as uuid5 } from "uuid-1345" import { normalizeExt } from "../platformPackager" import { archive } from "./archive" import { subTask, log, warn } from "electron-builder-util/out/log" -import { unlink, readFile, writeFile, createReadStream } from "fs-extra-p" +import { unlink, readFile } from "fs-extra-p" import { NsisOptions } from "../options/winOptions" -import { GenericServerOptions, UpdateInfo } from "electron-builder-http/out/publishOptions" -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/out/fs" const NSIS_VERSION = "3.0.4" //noinspection SpellCheckingInspection @@ -32,8 +28,6 @@ export default class NsisTarget extends Target { private readonly nsisTemplatesDir = path.join(__dirname, "..", "..", "templates", "nsis") - private readonly publishConfigs = this.packager.computePublishConfigs(this.options) - constructor(private packager: WinPackager, private outDir: string) { super("nsis") @@ -51,11 +45,6 @@ export default class NsisTarget extends Target { private async doBuild(appOutDir: string, arch: Arch) { log(`Packaging NSIS installer for arch ${Arch[arch]}`) - const publishConfigs = await this.publishConfigs - if (publishConfigs != null) { - await writeFile(path.join(appOutDir, "resources", "app-update.yml"), safeDump(publishConfigs[0])) - } - const packager = this.packager const archiveFile = path.join(this.outDir, `${packager.appInfo.name}-${packager.appInfo.version}-${Arch[arch]}.nsis.7z`) return await archive(packager.config.compression, "7z", archiveFile, appOutDir, true) @@ -221,48 +210,7 @@ export default class NsisTarget extends Target { await subTask(`Executing makensis — installer`, this.executeMakensis(defines, commands, true, script)) await packager.sign(installerPath) - const publishConfigs = await this.publishConfigs - const githubArtifactName = `${appInfo.name}-Setup-${version}.exe` - if (publishConfigs != null) { - for (const publishConfig of publishConfigs) { - if (!(publishConfig.provider === "generic" || publishConfig.provider === "github")) { - continue - } - - 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) { - // to preserve compatibility with old electron-auto-updater (< 0.10.0), we upload file with path specific for GitHub - packager.info.dispatchArtifactCreated({ - data: new Buffer(safeDump({ - version: version, - path: githubArtifactName, - sha2: sha2, - })), - artifactName: `${channel}.yml`, - packager: packager, - target: this, - publishConfig: githubPublishConfig, - }) - } - - break - } - } - else { - await unlinkIfExists(path.join(this.outDir, `latest.yml`)) - } - - packager.dispatchArtifactCreated(installerPath, this, githubArtifactName) + packager.dispatchArtifactCreated(installerPath, this, `${packager.appInfo.name}-Setup-${version}.exe`) } private async executeMakensis(defines: any, commands: any, isInstaller: boolean, originalScript: string) { @@ -352,21 +300,4 @@ export default class NsisTarget extends Target { childProcess.stdin.end(script) }) } -} - -function sha256(file: string) { - return new BluebirdPromise((resolve, reject) => { - const hash = createHash("sha256") - hash - .on("error", reject) - .setEncoding("hex") - - createReadStream(file) - .on("error", reject) - .on("end", () => { - hash.end() - resolve(hash.read()) - }) - .pipe(hash, {end: false}) - }) } \ No newline at end of file diff --git a/test/src/ArtifactPublisherTest.ts b/test/src/ArtifactPublisherTest.ts index e1114834577..3a9d1b1d6bc 100644 --- a/test/src/ArtifactPublisherTest.ts +++ b/test/src/ArtifactPublisherTest.ts @@ -1,12 +1,8 @@ import { GitHubPublisher } from "electron-builder/out/publish/gitHubPublisher" import { join } from "path" import { BintrayPublisher } from "electron-builder/out/publish/BintrayPublisher" -import { createPublisher } from "electron-builder/out/publish/PublishManager" import isCi from "is-ci" import { HttpError } from "electron-builder-http" -import BluebirdPromise from "bluebird-lst-c" -import { SourceRepositoryInfo } from "electron-builder" -import { GithubOptions } from "electron-builder-http/out/publishOptions" if (isCi && process.platform === "win32") { fit("Skip ArtifactPublisherTest suite on Windows CI", () => { @@ -116,27 +112,4 @@ testAndIgnoreApiRate("GitHub upload org", async () => { finally { await publisher.deleteRelease() } -}) - -it("create publisher", async () => { - const packager: any = { - metadata: { - version: "2.0.0", - repository: "develar/test" - }, - repositoryInfo: BluebirdPromise.resolve({type: "github", domain: "github.com", user: "develar", project: "test",}) - } - const publisher = await createPublisher(packager, {provider: "github", vPrefixedTagName: false, token: "__test__"}, {}) - expect(publisher).toMatchObject({ - info: { - provider: "github", - vPrefixedTagName: false, - owner: "develar", - repo: "test", - token: "__test__", - }, - token: "__test__", - "version": "2.0.0", - "tag": "2.0.0", - }) }) \ No newline at end of file diff --git a/test/src/mac/macArchiveTest.ts b/test/src/mac/macArchiveTest.ts index 64ee4564b7e..c4164789ed0 100644 --- a/test/src/mac/macArchiveTest.ts +++ b/test/src/mac/macArchiveTest.ts @@ -3,11 +3,9 @@ import { assertThat } from "../helpers/fileAssert" test.ifMac("invalid target", () => assertThat(createMacTargetTest(["ttt"])()).throws("Unknown target: ttt")) -test("only zip", createMacTargetTest(["zip"])) +test("only zip", createMacTargetTest(["zip"])); -if (process.env.CSC_KEY_PASSWORD != null) { - test.ifMac("pkg", createMacTargetTest(["pkg"])) -} +(process.env.CSC_KEY_PASSWORD == null ? test.skip : test.ifMac)("pkg", createMacTargetTest(["pkg"])) test("tar.gz", createMacTargetTest(["tar.gz"])) diff --git a/test/src/windows/winPackagerTest.ts b/test/src/windows/winPackagerTest.ts index 2efa1597685..5cf88e2e851 100755 --- a/test/src/windows/winPackagerTest.ts +++ b/test/src/windows/winPackagerTest.ts @@ -3,9 +3,9 @@ import { assertPack, platform, app, appThrows, CheckingWinPackager } from "../he import { writeFile, rename, unlink } from "fs-extra-p" import * as path from "path" -test.ifDevOrWinCi("beta version", app({ +test.ifWinCi("beta version", app({ targets: Platform.WINDOWS.createTarget(["squirrel", "nsis"]), - appMetadata: { + appMetadata: { version: "3.0.0-beta.2", } })) diff --git a/typings/asar.d.ts b/typings/asar.d.ts index 3f01aa5f4d8..2d8641a0b75 100644 --- a/typings/asar.d.ts +++ b/typings/asar.d.ts @@ -4,16 +4,6 @@ declare module "asar-electron-builder" { size: number } - interface AsarOptions { - dot?: boolean - - smartUnpack?: boolean - - ordering?: string | null - - extraMetadata?: any | null - } - export function listPackage(archive: string): Array // followLinks defaults to true diff --git a/yarn.lock b/yarn.lock index 4f0c8c2f679..a6830bd7e3b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2104,8 +2104,8 @@ oauth-sign@~0.8.1: resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" object-assign@^4.0.1, object-assign@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" object-keys@~0.4.0: version "0.4.0" @@ -2661,8 +2661,8 @@ supports-color@^2.0.0: resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" supports-color@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.1.2.tgz#72a262894d9d408b956ca05ff37b2ed8a6e2a2d5" + version "3.2.3" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" dependencies: has-flag "^1.0.0"