From 86be5d7b5c8ef0633895132d80e99a56f333c1c5 Mon Sep 17 00:00:00 2001 From: develar Date: Mon, 26 Jun 2017 19:17:03 +0200 Subject: [PATCH] feat: do not force build from sources by default Close #1703 --- .idea/dictionaries/develar.xml | 2 + docs/Multi Platform Build.md | 3 +- docs/Options.md | 3 +- packages/electron-builder/src/metadata.ts | 7 +- packages/electron-builder/src/packager.ts | 14 ++-- packages/electron-builder/src/util/config.ts | 5 ++ packages/electron-builder/src/util/yarn.ts | 4 +- yarn.lock | 76 ++++++++++++-------- 8 files changed, 71 insertions(+), 43 deletions(-) diff --git a/.idea/dictionaries/develar.xml b/.idea/dictionaries/develar.xml index c5b7607aade..4b78cdbe5c0 100644 --- a/.idea/dictionaries/develar.xml +++ b/.idea/dictionaries/develar.xml @@ -52,12 +52,14 @@ debian debuggability depcheck + deps devdir devel develar devmode difflet digester + dirname disturl docdash docstrap diff --git a/docs/Multi Platform Build.md b/docs/Multi Platform Build.md index 5c0339de1eb..2c77cd93e4d 100644 --- a/docs/Multi Platform Build.md +++ b/docs/Multi Platform Build.md @@ -1,8 +1,7 @@ Don't expect that you can build app for all platforms on one platform. * If your app has native dependencies, it can be compiled only on the target platform. -[prebuild](https://www.npmjs.com/package/prebuild) is a solution, but most node modules [don't provide](https://github.com/atom/node-keytar/issues/27) prebuilt binaries. - By default build from sources is forced, set [npmSkipBuildFromSource](https://github.com/electron-userland/electron-builder/wiki/Options#Config-npmSkipBuildFromSource) to `true` to use prebuild binaries (if available). +[prebuild](https://www.npmjs.com/package/prebuild) is a solution, but most node modules [don't provide](https://github.com/atom/node-keytar/issues/27) prebuilt binaries. * macOS Code Signing works only on macOS. [Cannot be fixed](http://stackoverflow.com/a/12156576). Don't think that mentioned issues are major, you should use build servers — e.g. [AppVeyor](http://www.appveyor.com/) to build Windows app and [Travis](https://travis-ci.org) to build MacOS/Linux apps. diff --git a/docs/Options.md b/docs/Options.md index 8fb8132b90d..e185838a6fd 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -179,7 +179,8 @@ Configuration Options * `nodeGypRebuild` = `false` Boolean - Whether to execute `node-gyp rebuild` before starting to package the app. * `npmArgs` Array<String> | String - Additional command line arguments to use when installing app native deps. * `npmRebuild` = `true` Boolean - Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies (`npm rebuild`) before starting to package the app. -* `npmSkipBuildFromSource` = `false` Boolean - Whether to omit using [--build-from-source](https://github.com/mapbox/node-pre-gyp#options) flag when installing app native deps. +* `buildDependenciesFromSource` = `false` Boolean - Whether to build the application native dependencies from source. +* `npmSkipBuildFromSource` Boolean - Deprecated: {tag.description} * `publish` String | [GithubOptions](Publishing-Artifacts#GithubOptions) | [S3Options](Publishing-Artifacts#S3Options) | [GenericServerOptions](Publishing-Artifacts#GenericServerOptions) | [BintrayOptions](Publishing-Artifacts#BintrayOptions) | Array - The [publish configuration](https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts#publish-options). Order is important — first item will be used as a default auto-update server. If `GH_TOKEN` is set — defaults to `[{provider: "github"}]`. diff --git a/packages/electron-builder/src/metadata.ts b/packages/electron-builder/src/metadata.ts index 3259bdf49d2..f9bad4c5bab 100644 --- a/packages/electron-builder/src/metadata.ts +++ b/packages/electron-builder/src/metadata.ts @@ -225,9 +225,14 @@ export interface Config extends PlatformSpecificBuildOptions { readonly npmRebuild?: boolean /** - * Whether to omit using [--build-from-source](https://github.com/mapbox/node-pre-gyp#options) flag when installing app native deps. + * Whether to build the application native dependencies from source. * @default false */ + buildDependenciesFromSource?: boolean + + /** + * @deprecated Please use npmBuildFromSource. + */ readonly npmSkipBuildFromSource?: boolean /** diff --git a/packages/electron-builder/src/packager.ts b/packages/electron-builder/src/packager.ts index b1173fe35ea..c586f1be9ce 100644 --- a/packages/electron-builder/src/packager.ts +++ b/packages/electron-builder/src/packager.ts @@ -283,20 +283,20 @@ export class Packager implements BuildInfo { } const frameworkInfo = {version: this.config.muonVersion || this.config.electronVersion!, useCustomDist: this.config.muonVersion == null} - const options = this.config - if (options.nodeGypRebuild === true) { + const config = this.config + if (config.nodeGypRebuild === true) { log(`Executing node-gyp rebuild for arch ${Arch[arch]}`) await exec(process.platform === "win32" ? "node-gyp.cmd" : "node-gyp", ["rebuild"], { env: getGypEnv(frameworkInfo, platform.nodeName, Arch[arch], true), }) } - if (options.npmRebuild === false) { + if (config.npmRebuild === false) { log("Skip app dependencies rebuild because npmRebuild is set to false") return } - const beforeBuild = options.beforeBuild + const beforeBuild = config.beforeBuild if (beforeBuild != null) { const performDependenciesInstallOrRebuild = await beforeBuild({ appDir: this.appDir, @@ -307,11 +307,11 @@ export class Packager implements BuildInfo { if (!performDependenciesInstallOrRebuild) return } - if (options.npmSkipBuildFromSource !== true && platform.nodeName !== process.platform) { - log("Skip app dependencies rebuild because platform is different") + if (config.buildDependenciesFromSource === true && platform.nodeName !== process.platform) { + log("Skip app dependencies rebuild because platform is different and buildDependenciesFromSource is set to true") } else { - await installOrRebuild(options, this.appDir, frameworkInfo, platform.nodeName, Arch[arch]) + await installOrRebuild(config, this.appDir, frameworkInfo, platform.nodeName, Arch[arch]) } } diff --git a/packages/electron-builder/src/util/config.ts b/packages/electron-builder/src/util/config.ts index a56a448c3df..4eba269c22c 100644 --- a/packages/electron-builder/src/util/config.ts +++ b/packages/electron-builder/src/util/config.ts @@ -168,6 +168,11 @@ export async function validateConfig(config: Config) { } } + // noinspection JSDeprecatedSymbols + if (config.npmSkipBuildFromSource === false) { + config.buildDependenciesFromSource = false + } + if (validatorPromise == null) { validatorPromise = createConfigValidator() } diff --git a/packages/electron-builder/src/util/yarn.ts b/packages/electron-builder/src/util/yarn.ts index a67696d3f39..626da0fde26 100644 --- a/packages/electron-builder/src/util/yarn.ts +++ b/packages/electron-builder/src/util/yarn.ts @@ -10,10 +10,10 @@ import { readInstalled } from "./packageDependencies" export async function installOrRebuild(config: Config, appDir: string, frameworkInfo: DesktopFrameworkInfo, platform: string, arch: string, forceInstall: boolean = false) { const args = asArray(config.npmArgs) if (forceInstall || !(await exists(path.join(appDir, "node_modules")))) { - await installDependencies(appDir, frameworkInfo, platform, arch, args, !config.npmSkipBuildFromSource) + await installDependencies(appDir, frameworkInfo, platform, arch, args, config.buildDependenciesFromSource === true) } else { - await rebuild(appDir, frameworkInfo, platform, arch, args, !config.npmSkipBuildFromSource) + await rebuild(appDir, frameworkInfo, platform, arch, args, config.buildDependenciesFromSource === true) } } diff --git a/yarn.lock b/yarn.lock index 0cc6a0a3f35..1e8b7a62a75 100644 --- a/yarn.lock +++ b/yarn.lock @@ -35,8 +35,8 @@ resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.5.31.tgz#54aeb8bcaaf94a7b1a64311bc318dbfe601a593a" "@types/node@*": - version "8.0.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.2.tgz#8ab9456efb87d57f11d04f313d3da1041948fb4d" + version "8.0.3" + resolved "https://registry.yarnpkg.com/@types/node/-/node-8.0.3.tgz#fca61c26f83e5f453166114f57d53a47feb36d45" "@types/source-map-support@^0.4.0": version "0.4.0" @@ -130,6 +130,10 @@ ansi-regex@^2.0.0, ansi-regex@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" +ansi-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" + ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" @@ -209,6 +213,12 @@ array-back@^1.0.2, array-back@^1.0.3, array-back@^1.0.4: dependencies: typical "^2.6.0" +array-back@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/array-back/-/array-back-2.0.0.tgz#6877471d51ecc9c9bfa6136fb6c7d5fe69748022" + dependencies: + typical "^2.6.1" + array-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93" @@ -252,8 +262,8 @@ async@^1.4.0: resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" async@^2.0.0, async@^2.1.4: - version "2.4.1" - resolved "https://registry.yarnpkg.com/async/-/async-2.4.1.tgz#62a56b279c98a11d0987096a01cc3eeb8eb7bbd7" + version "2.5.0" + resolved "https://registry.yarnpkg.com/async/-/async-2.5.0.tgz#843190fd6b7357a0b9e1c956edddd5ec8462b54d" dependencies: lodash "^4.14.0" @@ -520,7 +530,7 @@ babel-types@^6.18.0, babel-types@^6.24.1, babel-types@^6.25.0: lodash "^4.2.0" to-fast-properties "^1.0.1" -babylon@^6.1.21, babylon@^6.13.0, babylon@^6.17.2: +babylon@^6.1.21, babylon@^6.17.2, babylon@^6.17.4: version "6.17.4" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.4.tgz#3e8b7402b88d22c3423e137a1577883b15ff869a" @@ -528,14 +538,10 @@ balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" -base64-js@1.2.0: +base64-js@1.2.0, base64-js@^1.0.2: version "1.2.0" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.0.tgz#a39992d723584811982be5e290bb6a53d86700f1" -base64-js@^1.0.2: - version "1.2.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.2.1.tgz#a91947da1f4a516ea38e5b4ec0ec3773675e0886" - bcrypt-pbkdf@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" @@ -1693,14 +1699,14 @@ isstream@~0.1.2: resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" istanbul-api@^1.1.1: - version "1.1.9" - resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.1.9.tgz#2827920d380d4286d857d57a2968a841db8a7ec8" + version "1.1.10" + resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.1.10.tgz#f27e5e7125c8de13f6a80661af78f512e5439b2b" dependencies: async "^2.1.4" fileset "^2.0.2" istanbul-lib-coverage "^1.1.1" istanbul-lib-hook "^1.0.7" - istanbul-lib-instrument "^1.7.2" + istanbul-lib-instrument "^1.7.3" istanbul-lib-report "^1.1.1" istanbul-lib-source-maps "^1.2.1" istanbul-reports "^1.1.1" @@ -1718,15 +1724,15 @@ istanbul-lib-hook@^1.0.7: dependencies: append-transform "^0.4.0" -istanbul-lib-instrument@^1.4.2, istanbul-lib-instrument@^1.7.2: - version "1.7.2" - resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.2.tgz#6014b03d3470fb77638d5802508c255c06312e56" +istanbul-lib-instrument@^1.4.2, istanbul-lib-instrument@^1.7.2, istanbul-lib-instrument@^1.7.3: + version "1.7.3" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.7.3.tgz#925b239163eabdd68cc4048f52c2fa4f899ecfa7" dependencies: babel-generator "^6.18.0" babel-template "^6.16.0" babel-traverse "^6.18.0" babel-types "^6.18.0" - babylon "^6.13.0" + babylon "^6.17.4" istanbul-lib-coverage "^1.1.1" semver "^5.3.0" @@ -2344,7 +2350,7 @@ minimist@^1.1.0, minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" -mkdirp2@^1.0.2: +mkdirp2@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/mkdirp2/-/mkdirp2-1.0.3.tgz#cc8dd8265f1f06e2d8f5b10b6e52f4e050bed21b" @@ -2850,7 +2856,7 @@ repeating@^2.0.0: dependencies: is-finite "^1.0.0" -req-then@^0.6.1: +req-then@^0.6.2: version "0.6.2" resolved "https://registry.yarnpkg.com/req-then/-/req-then-0.6.2.tgz#7f9e6ebbcab327adc9280aa92b3698d3fc1c5b0d" dependencies: @@ -3102,11 +3108,11 @@ string-width@^1.0.1, string-width@^1.0.2: strip-ansi "^3.0.0" string-width@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.0.0.tgz#635c5436cc72a6e0c387ceca278d4e2eec52687e" + version "2.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.0.tgz#030664561fc146c9423ec7d978fe2457437fe6d0" dependencies: is-fullwidth-code-point "^2.0.0" - strip-ansi "^3.0.0" + strip-ansi "^4.0.0" string.prototype.codepointat@^0.2.0: version "0.2.0" @@ -3132,6 +3138,12 @@ strip-ansi@^3.0.0, strip-ansi@^3.0.1: dependencies: ansi-regex "^2.0.0" +strip-ansi@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" + dependencies: + ansi-regex "^3.0.0" + strip-bom@3.0.0, strip-bom@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" @@ -3459,15 +3471,15 @@ url@0.10.3: querystring "0.2.0" usage-stats@^0.9.0: - version "0.9.1" - resolved "https://registry.yarnpkg.com/usage-stats/-/usage-stats-0.9.1.tgz#3b34997dbef1e151f48a118a93a5c595e1d4269a" + version "0.9.3" + resolved "https://registry.yarnpkg.com/usage-stats/-/usage-stats-0.9.3.tgz#6c906491becb9b4e8659f2e0d27f337fcf8f087e" dependencies: - array-back "^1.0.4" + array-back "^2.0.0" home-path "^1.0.5" - mkdirp2 "^1.0.2" - req-then "^0.6.1" - typical "^2.6.0" - uuid "^3.0.1" + mkdirp2 "^1.0.3" + req-then "^0.6.2" + typical "^2.6.1" + uuid "^3.1.0" utf8-byte-length@^1.0.1: version "1.0.4" @@ -3483,7 +3495,7 @@ uuid-1345@^0.99.6: dependencies: macaddress "^0.2.7" -uuid@3.0.1, uuid@^3.0.0, uuid@^3.0.1: +uuid@3.0.1, uuid@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" @@ -3491,6 +3503,10 @@ uuid@^2.0.1: version "2.0.3" resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.3.tgz#67e2e863797215530dff318e5bf9dcebfd47b21a" +uuid@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" + validate-npm-package-license@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc"