Skip to content

Commit

Permalink
feat(mac): upgrade osslsigncode, do not require wine
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jun 20, 2017
1 parent 5f6bbae commit d68fc64
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 60 deletions.
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ language: node_js
matrix:
include:
- os: osx
#env: TEST_FILES=BuildTest,extraMetadataTest,globTest,filesTest,ignoreTest,linux.*,windows.*
env: TEST_FILES=oneClickInstallerTest.*
env: TEST_FILES=BuildTest,extraMetadataTest,globTest,filesTest,ignoreTest,linux.*,windows.*
# env: TEST_FILES=oneClickInstallerTest.*
node_js: "8"

# - os: osx
# env: TEST_FILES=mac.*
# node_js: "8"
- os: osx
env: TEST_FILES=mac.*
node_js: "8"

# - os: osx
# env: TEST_FILES=mac.* NODE_VERSION=6
- os: osx
env: TEST_FILES=mac.*
node_js: "6"

cache:
yarn: true
directories:
- node_modules
- $HOME/Library/Caches/electron
- $HOME/Library/Caches/electron-builder
- /tmp/jest-electron-builder-tests

install:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ _Note: Platform specific `7zip-bin-*` packages are `optionalDependencies`, which
```
Then you can run `npm run dist` (to package in a distributable format (e.g. dmg, windows installer, deb package)) or `npm run pack` (only generates the package directory without really packaging it. This is useful for testing purposes).

To ensure your native dependencies are always matched electron version, simply add `"postinstall": "install-app-deps"` to your `package.json`.
To ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps"` to your `package.json`.

5. If you have native addons of your own that are part of the application (not as a dependency), add `"nodeGypRebuild": true` to the `build` section of your development `package.json`.
:bulb: Don't [use](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241214075) [npm](http://electron.atom.io/docs/tutorial/using-native-node-modules/#using-npm) (neither `.npmrc`) for configuring electron headers. Use [node-gyp-rebuild](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241488783) bin instead.
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder-util/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { statOrNull } from "./fs"
import { log, warn } from "./log"

export { TmpDir } from "./tmp"
export { log, warn, task } from "./log"
export { log, warn, task, subTask } from "./log"

export const debug = _debug("electron-builder")
export const debug7z = _debug("electron-builder:7z")
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as path from "path"
import updateNotifier from "update-notifier"
import yargs from "yargs"
import { build, configureBuildCommand } from "../builder"
import { getElectronVersion, loadConfig } from "../util/config"
import { getConfig, getElectronVersion } from "../util/config"
import { getGypEnv } from "../util/yarn"
import { createSelfSignedCert } from "./create-self-signed-cert"
import { configureInstallAppDepsCommand, installAppDeps } from "./install-app-deps"
Expand Down Expand Up @@ -64,7 +64,7 @@ function checkIsOutdated() {

async function rebuildAppNativeCode(args: any) {
const projectDir = process.cwd()
const config = await loadConfig(projectDir)
const config = await getConfig(projectDir, null, null, null)
log(`Execute node-gyp rebuild for ${args.platform}:${args.arch}`)
// this script must be used only for electron
await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], {
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/src/cli/install-app-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BluebirdPromise from "bluebird-lst"
import { computeDefaultAppDirectory, log, use, warn } from "electron-builder-util"
import { printErrorAndExit } from "electron-builder-util/out/promise"
import yargs from "yargs"
import { getElectronVersion, loadConfig } from "../util/config"
import { getConfig, getElectronVersion } from "../util/config"
import { installOrRebuild } from "../util/yarn"

declare const PACKAGE_VERSION: string
Expand Down Expand Up @@ -39,7 +39,7 @@ export async function installAppDeps(args: any) {
}

const projectDir = process.cwd()
const config = (await loadConfig(projectDir)) || {}
const config = (await getConfig(projectDir, null, null, null)) || {}
const muonVersion = config.muonVersion
const results = await BluebirdPromise.all<string>([
computeDefaultAppDirectory(projectDir, use(config.directories, it => it!.app)),
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { AfterPackContext, Config, Metadata } from "./metadata"
import { ArtifactCreated, BuildInfo, PackagerOptions } from "./packagerApi"
import { PlatformPackager } from "./platformPackager"
import { computeArchToTargetNamesMap, createTargets, NoOpTarget } from "./targets/targetFactory"
import { computeFinalConfig, getElectronVersion, validateConfig } from "./util/config"
import { getConfig, getElectronVersion, validateConfig } from "./util/config"
import { checkMetadata, readPackageJson } from "./util/packageMetadata"
import { getRepositoryInfo } from "./util/repositoryInfo"
import { getGypEnv, installOrRebuild } from "./util/yarn"
Expand Down Expand Up @@ -122,7 +122,7 @@ export class Packager implements BuildInfo {
this.devMetadata = await orNullIfFileNotExist(readPackageJson(devPackageFile))

const devMetadata = this.devMetadata
const config = await computeFinalConfig(projectDir, configPath, devMetadata, configFromOptions)
const config = await getConfig(projectDir, configPath, devMetadata, configFromOptions)
if (debug.enabled) {
debug(`Effective config: ${safeStringifyJson(config)}`)
}
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
@@ -1,4 +1,4 @@
import { log } from "electron-builder-util/out/log"
import { log } from "electron-builder-util"
import * as path from "path"
import { Arch, Platform, Target } from "../core"
import { PlatformPackager } from "../platformPackager"
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/targets/dmg.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import BluebirdPromise from "bluebird-lst"
import { debug, exec, isEmptyOrSpaces, spawn } from "electron-builder-util"
import { debug, exec, isEmptyOrSpaces, log, spawn, warn } from "electron-builder-util"
import { deepAssign } from "electron-builder-util/out/deepAssign"
import { copyFile, exists, statOrNull } from "electron-builder-util/out/fs"
import { log, warn } from "electron-builder-util/out/log"
import { executeFinally } from "electron-builder-util/out/promise"
import { outputFile, readFile, remove, unlink } from "fs-extra-p"
import * as path from "path"
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/targets/fpm.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import BluebirdPromise from "bluebird-lst"
import { debug, exec, smarten, TmpDir, use } from "electron-builder-util"
import { debug, exec, log, smarten, TmpDir, use, warn } from "electron-builder-util"
import { getBin } from "electron-builder-util/out/binDownload"
import { unlinkIfExists } from "electron-builder-util/out/fs"
import { log, warn } from "electron-builder-util/out/log"
import { ensureDir, outputFile, readFile } from "fs-extra-p"
import * as path from "path"
import { Arch, Target, toLinuxArchString } from "../core"
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/targets/nsis.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import BluebirdPromise from "bluebird-lst"
import _debug from "debug"
import { asArray, debug, doSpawn, getPlatformIconFileName, handleProcess, isEmptyOrSpaces, use } from "electron-builder-util"
import { asArray, debug, doSpawn, getPlatformIconFileName, handleProcess, isEmptyOrSpaces, log, subTask, use, warn } from "electron-builder-util"
import { getBinFromGithub } from "electron-builder-util/out/binDownload"
import { copyFile } from "electron-builder-util/out/fs"
import { log, subTask, warn } from "electron-builder-util/out/log"
import { asyncAll } from "electron-builder-util/out/promise"
import { outputFile, readFile, unlink } from "fs-extra-p"
import { safeLoad } from "js-yaml"
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/targets/snap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { replaceDefault, spawn } from "electron-builder-util"
import { log, replaceDefault, spawn } from "electron-builder-util"
import { copyFile } from "electron-builder-util/out/fs"
import { log } from "electron-builder-util/out/log"
import { emptyDir, outputFile } from "fs-extra-p"
import { safeDump } from "js-yaml"
import { homedir } from "os"
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/util/asarUtil.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BluebirdPromise from "bluebird-lst"
import { debug } from "electron-builder-util"
import { debug, log } from "electron-builder-util"
import { CONCURRENCY, FileCopier, FileTransformer, Filter, MAX_FILE_REQUESTS, statOrNull, walk } from "electron-builder-util/out/fs"
import { log } from "electron-builder-util/out/log"
import { createReadStream, createWriteStream, ensureDir, readFile, readlink, stat, Stats, writeFile } from "fs-extra-p"
import * as path from "path"
import { AsarFilesystem, Node, readAsar } from "../asar"
Expand Down
35 changes: 13 additions & 22 deletions packages/electron-builder/src/util/config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Ajv from "ajv"
import { CancellationToken } from "electron-builder-http"
import { debug } from "electron-builder-util"
import { debug, log, warn } from "electron-builder-util"
import { deepAssign } from "electron-builder-util/out/deepAssign"
import { statOrNull } from "electron-builder-util/out/fs"
import { log, warn } from "electron-builder-util/out/log"
import { httpExecutor } from "electron-builder-util/out/nodeHttpExecutor"
import { orNullIfFileNotExist } from "electron-builder-util/out/promise"
import { readFile, readJson } from "fs-extra-p"
Expand All @@ -16,12 +14,11 @@ import AdditionalPropertiesParams = ajv.AdditionalPropertiesParams
import ErrorObject = ajv.ErrorObject
import TypeParams = ajv.TypeParams

function getConfigFromPackageData(metadata: any) {
return metadata.build
function getConfigFromPackageData(metadata: any | null) {
return metadata == null ? null : metadata.build
}

/** @internal */
export async function doLoadConfig(configFile: string, projectDir: string): Promise<Config> {
async function doLoadConfig(configFile: string, projectDir: string): Promise<Config> {
const data = await readFile(configFile, "utf8")
let result
if (configFile.endsWith(".json5") || configFile.endsWith(".json")) {
Expand All @@ -39,30 +36,24 @@ export async function doLoadConfig(configFile: string, projectDir: string): Prom
return result
}

/** @internal */
export async function loadConfig(projectDir: string, packageMetadata?: any): Promise<Config | null> {
for (const configFile of ["electron-builder.yml", "electron-builder.yaml", "electron-builder.json", "electron-builder.json5", "electron-builder.toml"]) {
const data = await orNullIfFileNotExist(doLoadConfig(path.join(projectDir, configFile), projectDir))
if (data != null) {
return data
}
}

const data = getConfigFromPackageData(packageMetadata || (await orNullIfFileNotExist(readJson(path.join(projectDir, "package.json")))))
async function loadConfig(projectDir: string, packageMetadata?: any): Promise<Config | null> {
let data = getConfigFromPackageData(packageMetadata || (await orNullIfFileNotExist(readJson(path.join(projectDir, "package.json")))))
if (data != null) {
return data
}

if ((await statOrNull(path.join(projectDir, "app.asar"))) != null) {
// prepacked, do not throw error, just ignore
return null
for (const configFile of ["electron-builder.yml", "electron-builder.yaml", "electron-builder.json", "electron-builder.json5", "electron-builder.toml"]) {
data = await orNullIfFileNotExist(doLoadConfig(path.join(projectDir, configFile), projectDir))
if (data != null) {
return data
}
}

throw new Error(`Cannot find package.json in the ${projectDir}`)
return null
}

/** @internal */
export async function computeFinalConfig(projectDir: string, configPath: string | null, packageMetadata: any | null, configFromOptions: Config | null | undefined): Promise<Config> {
export async function getConfig(projectDir: string, configPath: string | null, packageMetadata: any | null, configFromOptions: Config | null | undefined): Promise<Config> {
let fileOrPackageConfig
if (configPath == null) {
fileOrPackageConfig = packageMetadata == null ? null : await loadConfig(projectDir, packageMetadata)
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/util/packageMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function checkMetadata(metadata: Metadata, devMetadata: any | null, appPa

const devDependencies = (<any>metadata).devDependencies
if (devDependencies != null && "electron-rebuild" in devDependencies) {
log("electron-rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies")
log('electron-rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies\n\nTo ensure your native dependencies are always matched electron version, simply add script `"postinstall": "electron-builder install-app-deps" to your `package.json`')
}

if (errors.length > 0) {
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-builder/src/util/yarn.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import BluebirdPromise from "bluebird-lst"
import { asArray, spawn } from "electron-builder-util"
import { asArray, log, spawn, warn } from "electron-builder-util"
import { exists } from "electron-builder-util/out/fs"
import { log, warn } from "electron-builder-util/out/log"
import { homedir } from "os"
import * as path from "path"
import { Config } from "../metadata"
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-publish/src/BintrayPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import BluebirdPromise from "bluebird-lst"
import { configureRequestOptions, HttpError } from "electron-builder-http"
import { BintrayClient, Version } from "electron-builder-http/out/bintray"
import { BintrayOptions } from "electron-builder-http/out/publishOptions"
import { debug, isEmptyOrSpaces } from "electron-builder-util"
import { log } from "electron-builder-util/out/log"
import { debug, isEmptyOrSpaces, log } from "electron-builder-util"
import { httpExecutor } from "electron-builder-util/out/nodeHttpExecutor"
import { ClientRequest } from "http"
import { HttpPublisher, PublishContext, PublishOptions } from "./publisher"
Expand Down
3 changes: 1 addition & 2 deletions packages/electron-publish/src/gitHubPublisher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import BluebirdPromise from "bluebird-lst"
import { configureRequestOptions, HttpError } from "electron-builder-http"
import { GithubOptions } from "electron-builder-http/out/publishOptions"
import { debug, isEmptyOrSpaces } from "electron-builder-util"
import { log, warn } from "electron-builder-util/out/log"
import { debug, isEmptyOrSpaces, log, warn } from "electron-builder-util"
import { httpExecutor } from "electron-builder-util/out/nodeHttpExecutor"
import { ClientRequest } from "http"
import mime from "mime"
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-publish/src/publisher.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { green } from "chalk"
import { CancellationToken, ProgressCallbackTransform } from "electron-builder-http"
import { log } from "electron-builder-util/out/log"
import { log } from "electron-builder-util"
import { createReadStream, stat, Stats } from "fs-extra-p"
import { ClientRequest } from "http"
import { basename } from "path"
Expand Down
1 change: 0 additions & 1 deletion test/out/mac/__snapshots__/macArchiveTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ Object {
"versStr": "1.1.0",
},
Object {
"customLocation": "/Applications",
"id": "org.electron-builder.testApp",
"pkg-ref": Object {
"id": "org.electron-builder.testApp",
Expand Down
3 changes: 1 addition & 2 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import DecompressZip from "decompress-zip"
import { Arch, ArtifactCreated, DIR_TARGET, getArchSuffix, MacOsTargetName, Packager, PackagerOptions, Platform, Target } from "electron-builder"
import { CancellationToken } from "electron-builder-http"
import { convertVersion } from "electron-builder-squirrel-windows/out/squirrelPack"
import { addValue, exec, getTempName, spawn } from "electron-builder-util"
import { addValue, exec, getTempName, log, spawn, warn } from "electron-builder-util"
import { copyDir, FileCopier } from "electron-builder-util/out/fs"
import { log, warn } from "electron-builder-util/out/log"
import { PublishManager } from "electron-builder/out/publish/PublishManager"
import { computeArchToTargetNamesMap } from "electron-builder/out/targets/targetFactory"
import { getLinuxToolsPath } from "electron-builder/out/util/bundledTool"
Expand Down

0 comments on commit d68fc64

Please sign in to comment.