Skip to content

Commit

Permalink
fix: generate latest-mac.json for github in the github directory
Browse files Browse the repository at this point in the history
develar committed Jan 16, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent df7d316 commit 8670d5a
Showing 13 changed files with 184 additions and 261 deletions.
2 changes: 2 additions & 0 deletions docs/Auto Update.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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'",
3 changes: 2 additions & 1 deletion packages/electron-builder/src/asarUtil.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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"
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")
12 changes: 4 additions & 8 deletions packages/electron-builder/src/builder.ts
Original file line number Diff line number Diff line change
@@ -202,20 +202,16 @@ export async function build(rawOptions?: CliOptions): Promise<Array<string>> {
}

const packager = new Packager(options)
//noinspection JSMismatchedCollectionQueryUpdate
const artifactPaths: Array<string> = []
// because artifact event maybe dispatched several times for different publish providers
const artifactPaths = new Set<string>()
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)
11 changes: 10 additions & 1 deletion packages/electron-builder/src/metadata.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
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"
import { WinBuildOptions, NsisOptions, SquirrelWindowsOptions, AppXOptions } from "./options/winOptions"
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
68 changes: 2 additions & 66 deletions packages/electron-builder/src/platformPackager.ts
Original file line number Diff line number Diff line change
@@ -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<DC extends PlatformSpecificBuildOptions>
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,74 +462,13 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
}
return null
}

async computePublishConfigs(targetSpecificOptions: PlatformSpecificBuildOptions | null): Promise<Array<PublishConfiguration> | 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 => <Promise<PublishConfiguration>>getResolvedPublishConfig(this.info, it, true))
}
}

// remove leading dot
export function normalizeExt(ext: string) {
return ext.startsWith(".") ? ext.substring(1) : ext
}

export function getPublishConfigs(packager: PlatformPackager<any>, targetSpecificOptions: PlatformSpecificBuildOptions | null | undefined): Array<PublishConfiguration> | 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<PublishConfiguration | string>(publishers)
.map(it => typeof it === "string" ? {provider: <any>it} : it)
}

async function dependencies(dir: string, result: Set<string>): Promise<void> {
const pathToDep = await readInstalled(dir)
for (const dep of pathToDep.values()) {
220 changes: 154 additions & 66 deletions packages/electron-builder/src/publish/PublishManager.ts
Original file line number Diff line number Diff line change
@@ -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<string, Promise<Publisher>>()
private readonly nameToPublisher = new Map<string, Publisher | null>()

readonly publishTasks: Array<Promise<any>> = []
private readonly errors: Array<Error> = []

private isPublishOptionGuessed = false
private isPublish = false

constructor(packager: Packager, private readonly publishOptions: PublishOptions) {
if (publishOptions.publish === undefined) {
@@ -45,74 +48,72 @@ 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`)
}
}

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 : (<any>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 : (<any>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<any>) {
this.publishTasks.push(promise
.catch(it => this.errors.push(it)))
}

getOrCreatePublisher(publishConfig: PublishConfiguration, buildInfo: BuildInfo): Promise<Publisher | null> {
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: Array<Pu
if (publishConfigs == null || publishConfigs.length === 0) {
return
}
const outDir = (<ArchiveTarget>event.target).outDir

await writeMac(packager, (<ArchiveTarget>event.target).outDir, publishConfigs)
}

async function writeMac(packager: PlatformPackager<any>, outDir: string, publishConfigs: Array<PublishConfiguration>) {
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 = (<GenericServerOptions>publishConfig).channel || "latest"
const updateInfoFile = path.join(outDir, `${channel}-mac.json`)

await writeJson(updateInfoFile, <VersionInfo>{
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 (<any>outputJson)(updateInfoFile, <VersionInfo>{
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(<UpdateInfo>{
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(<UpdateInfo>{
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<Publisher | null> {
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 = <GithubOptions>publishConfig
return `https://github.com${`/${gh.owner}/${gh.repo}/releases`}/download/v${version}/${fileName}`
}
}

export function getPublishConfigs(packager: PlatformPackager<any>, targetSpecificOptions: PlatformSpecificBuildOptions | null | undefined): Promise<Array<PublishConfiguration>> | 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: <any>it}, true) : it)
}

function sha256(file: string) {
return new BluebirdPromise<string>((resolve, reject) => {
const hash = createHash("sha256")
hash
.on("error", reject)
.setEncoding("hex")

createReadStream(file)
.on("error", reject)
.on("end", () => {
hash.end()
resolve(<string>hash.read())
})
.pipe(hash, {end: false})
})
}
73 changes: 2 additions & 71 deletions packages/electron-builder/src/targets/nsis.ts
Original file line number Diff line number Diff line change
@@ -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 = (<GenericServerOptions>publishConfig).channel || "latest"
const updateInfoFile = path.join(this.outDir, `${channel}.yml`)
await writeFile(updateInfoFile, safeDump(<UpdateInfo>{
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(<UpdateInfo>{
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<string>((resolve, reject) => {
const hash = createHash("sha256")
hash
.on("error", reject)
.setEncoding("hex")

createReadStream(file)
.on("error", reject)
.on("end", () => {
hash.end()
resolve(<string>hash.read())
})
.pipe(hash, {end: false})
})
}
27 changes: 0 additions & 27 deletions test/src/ArtifactPublisherTest.ts
Original file line number Diff line number Diff line change
@@ -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(<SourceRepositoryInfo>{type: "github", domain: "github.com", user: "develar", project: "test",})
}
const publisher = await createPublisher(packager, <GithubOptions>{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",
})
})
6 changes: 2 additions & 4 deletions test/src/mac/macArchiveTest.ts
Original file line number Diff line number Diff line change
@@ -3,11 +3,9 @@ import { assertThat } from "../helpers/fileAssert"

test.ifMac("invalid target", () => assertThat(createMacTargetTest([<any>"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"]))

4 changes: 2 additions & 2 deletions test/src/windows/winPackagerTest.ts
Original file line number Diff line number Diff line change
@@ -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: <any>{
appMetadata: {
version: "3.0.0-beta.2",
}
}))
10 changes: 0 additions & 10 deletions typings/asar.d.ts
Original file line number Diff line number Diff line change
@@ -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<string>

// followLinks defaults to true
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 8670d5a

Please sign in to comment.