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
  • Loading branch information
develar committed Jan 16, 2017
1 parent df7d316 commit 8670d5a
Show file tree
Hide file tree
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
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand Down
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")
Expand Down
12 changes: 4 additions & 8 deletions packages/electron-builder/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
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
Expand Down
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"

Expand Down Expand Up @@ -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")
}

Expand Down Expand Up @@ -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()) {
Expand Down
Loading

0 comments on commit 8670d5a

Please sign in to comment.