From b4462a293db71af69889646d12ff024156db3923 Mon Sep 17 00:00:00 2001 From: develar Date: Sat, 25 Mar 2017 16:31:14 +0100 Subject: [PATCH] feat: electronCompile option to disable electron-compile integration --- .idea/dictionaries/develar.xml | 1 + docs/Auto Update.md | 6 +-- docs/Developer API.md | 32 +++++++------- docs/Options.md | 43 ++++++++++--------- docs/Publishing Artifacts.md | 17 +++++--- package.json | 2 +- .../electron-builder/src/fileTransformer.ts | 16 +++---- packages/electron-builder/src/metadata.ts | 5 +++ yarn.lock | 12 ++---- 9 files changed, 67 insertions(+), 67 deletions(-) diff --git a/.idea/dictionaries/develar.xml b/.idea/dictionaries/develar.xml index 6231757de33..f2f9b8cdb47 100644 --- a/.idea/dictionaries/develar.xml +++ b/.idea/dictionaries/develar.xml @@ -169,6 +169,7 @@ postinstall powerrequired powershell + precompilation preinstall prerelease productbuild diff --git a/docs/Auto Update.md b/docs/Auto Update.md index 0c18a89331c..bcd966bd02e 100644 --- a/docs/Auto Update.md +++ b/docs/Auto Update.md @@ -133,8 +133,8 @@ Emitted on progress. Only supported over Windows build, since `Squirrel.Mac` [do | Name | Type | | --- | --- | -| name| string | -| url| string | +| **name**| string | +| **url**| string | | sha2| string | | headers| Object | @@ -146,7 +146,7 @@ Emitted on progress. Only supported over Windows build, since `Squirrel.Mac` [do | Name | Type | | --- | --- | -| versionInfo| [VersionInfo](Publishing-Artifacts#VersionInfo) | +| **versionInfo**| [VersionInfo](Publishing-Artifacts#VersionInfo) | | fileInfo| [FileInfo](#FileInfo) | | downloadPromise| Promise<any> \| null | | cancellationToken| [CancellationToken](Developer-API#CancellationToken) | diff --git a/docs/Developer API.md b/docs/Developer API.md index e6c9ea6c228..409510b8fb8 100644 --- a/docs/Developer API.md +++ b/docs/Developer API.md @@ -2380,12 +2380,12 @@ | Name | Type | | --- | --- | -| path| string | +| **path**| string | | cert| string \| null | | name| string \| null | | password| string \| null | | site| string \| null | -| options| [WinBuildOptions](Options#WinBuildOptions) | +| **options**| [WinBuildOptions](Options#WinBuildOptions) | @@ -2862,7 +2862,7 @@ | Name | Type | | --- | --- | -| name| string | +| **name**| string | | email| string | @@ -2873,10 +2873,10 @@ | Name | Type | | --- | --- | -| appDir| string | -| electronVersion| string | -| platform| [Platform](#Platform) | -| arch| string | +| **appDir**| string | +| **electronVersion**| string | +| **platform**| [Platform](#Platform) | +| **arch**| string | @@ -2892,7 +2892,7 @@ On Windows works only if [nsis.perMachine](https://github.com/electron-userland/ | Name | Type | Description | | --- | --- | --- | -| ext| string \| Array<string> | The extension (minus the leading period). e.g. `png`. | +| **ext**| string \| Array<string> | The extension (minus the leading period). e.g. `png`. | | name| string \| null | The name. e.g. `PNG`. Defaults to `ext`. | | description| string \| null | *windows-only.* The description. | | icon| string \| null | The path to icon (`.icns` for MacOS and `.ico` for Windows), relative to `build` (build resources directory). Defaults to `${firstExt}.icns`/`${firstExt}.ico` (if several extensions specified, first is used) or to application icon. | @@ -2955,9 +2955,9 @@ Please note — on macOS [you need to register an `open-url` event handler](http | Name | Type | Description | | --- | --- | --- | -| name| string | The name. e.g. `IRC server URL`. | +| **name**| string | The name. e.g. `IRC server URL`. | | role = Editor| "Editor" \| "Viewer" \| "Shell" \| "None" | *macOS-only* The app’s role with respect to the type. | -| schemes| Array<string> | The schemes. e.g. `["irc", "ircs"]`. | +| **schemes**| Array<string> | The schemes. e.g. `["irc", "ircs"]`. | @@ -2967,7 +2967,7 @@ Please note — on macOS [you need to register an `open-url` event handler](http | Name | Type | | --- | --- | -| url| string | +| **url**| string | @@ -2990,7 +2990,7 @@ Please note — on macOS [you need to register an `open-url` event handler](http | Name | Type | Description | | --- | --- | --- | -| target| string | The target name. e.g. `snap`. | +| **target**| string | The target name. e.g. `snap`. | | arch| Array<"x64" \| "ia32" \| "armv7l"> \| string | The arch or list of archs. | @@ -3156,8 +3156,8 @@ Please note — on macOS [you need to register an `open-url` event handler](http | Name | Type | | --- | --- | -| name| string | -| package| string | +| **name**| string | +| **package**| string | @@ -3363,7 +3363,7 @@ Please note — on macOS [you need to register an `open-url` event handler](http | headers| [RequestHeaders](#RequestHeaders) \| null | | skipDirCreation| boolean | | sha2| string \| null | -| cancellationToken| [CancellationToken](#CancellationToken) | +| **cancellationToken**| [CancellationToken](#CancellationToken) | @@ -3844,7 +3844,7 @@ Please note — on macOS [you need to register an `open-url` event handler](http | Name | Type | | --- | --- | -| cancellationToken| [CancellationToken](#CancellationToken) | +| **cancellationToken**| [CancellationToken](#CancellationToken) | | progress| [MultiProgress](#MultiProgress) \| null | diff --git a/docs/Options.md b/docs/Options.md index 40917b3d788..750fb86687d 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -126,11 +126,11 @@ You can use [file macros](#file-macros) in the `from` and `to` fields as well. | Name | Type | | --- | --- | -| appOutDir| string | -| packager| [PlatformPackager](Developer-API#PlatformPackager)<any> | -| electronPlatformName| string | -| arch| [Arch](Developer-API#Arch) | -| targets| Array<[Target](Developer-API#Target)> | +| **appOutDir**| string | +| **packager**| [PlatformPackager](Developer-API#PlatformPackager)<any> | +| **electronPlatformName**| string | +| **arch**| [Arch](Developer-API#Arch) | +| **targets**| Array<[Target](Developer-API#Target)> | @@ -157,7 +157,7 @@ AppX Options | Name | Type | | --- | --- | -| packager| [PlatformPackager](Developer-API#PlatformPackager)<any> | +| **packager**| [PlatformPackager](Developer-API#PlatformPackager)<any> | | target| [Target](Developer-API#Target) \| null | | file| string | | data| Buffer | @@ -172,21 +172,21 @@ AppX Options | Name | Type | | --- | --- | -| options| [PackagerOptions](#PackagerOptions) | -| metadata| [Metadata](#Metadata) | -| devMetadata| [Metadata](#Metadata) | -| config| [Config](#Config) | -| projectDir| string | -| appDir| string | -| electronVersion| string | +| **options**| [PackagerOptions](#PackagerOptions) | +| **metadata**| [Metadata](#Metadata) | +| **devMetadata**| [Metadata](#Metadata) | +| **config**| [Config](#Config) | +| **projectDir**| string | +| **appDir**| string | +| **electronVersion**| string | | muonVersion| string \| null | -| isTwoPackageJsonProjectLayoutUsed| boolean | -| appInfo| [AppInfo](Developer-API#AppInfo) | -| tempDirManager| [TmpDir](Developer-API#TmpDir) | -| repositoryInfo| Promise< \| [SourceRepositoryInfo](Developer-API#SourceRepositoryInfo)> | -| isPrepackedAppAsar| boolean | +| **isTwoPackageJsonProjectLayoutUsed**| boolean | +| **appInfo**| [AppInfo](Developer-API#AppInfo) | +| **tempDirManager**| [TmpDir](Developer-API#TmpDir) | +| **repositoryInfo**| Promise< \| [SourceRepositoryInfo](Developer-API#SourceRepositoryInfo)> | +| **isPrepackedAppAsar**| boolean | | prepackaged| string \| null | -| cancellationToken| [CancellationToken](Developer-API#CancellationToken) | +| **cancellationToken**| [CancellationToken](Developer-API#CancellationToken) | @@ -201,8 +201,8 @@ AppX Options | Name | Type | | --- | --- | -| outDir| string | -| platformToTargets| Map<[Platform](Developer-API#Platform) \| Map<String \| [Target](Developer-API#Target)>> | +| **outDir**| string | +| **platformToTargets**| Map<[Platform](Developer-API#Platform) \| Map<String \| [Target](Developer-API#Target)>> | @@ -261,6 +261,7 @@ Configuration Options | muonVersion| string \| null | The version of muon you are packaging for. | | artifactName| string \| null | The [artifact file name pattern](https://github.com/electron-userland/electron-builder/wiki/Options#artifact-file-name-pattern). Defaults to `${productName}-${version}.${ext}` (some target can have another defaults, see corresponding options).

Currently supported only for `mas`, `pkg`, `dmg` and `nsis`. | | buildVersion| string \| null | The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`. If `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_NUMBER` or `bamboo.buildNumber` env defined, it will be used as a build version (`version.build_number`). | +| electronCompile| boolean | Whether to use [electron-compile](http://github.com/electron/electron-compile) to compile app. Defaults to `true` if `electron-compile` in the dependencies. And `false` if in the `devDependencies` or doesn't specified. | | mac| [MacOptions](#MacOptions) \| null | | | mas| [MasBuildOptions](#MasBuildOptions) \| null | | | dmg| [DmgOptions](#DmgOptions) \| null | | diff --git a/docs/Publishing Artifacts.md b/docs/Publishing Artifacts.md index 102bd72fe30..0c01caf0fbf 100644 --- a/docs/Publishing Artifacts.md +++ b/docs/Publishing Artifacts.md @@ -108,7 +108,7 @@ Generic (any HTTP(S) server) options. | Name | Type | Description | | --- | --- | --- | -| url| string | The base url. e.g. `https://bucket_name.s3.amazonaws.com`. You can use `${os}` (expanded to `mac`, `linux` or `win` according to target platform) and `${arch}` macros. | +| **url**| string | The base url. e.g. `https://bucket_name.s3.amazonaws.com`. You can use `${os}` (expanded to `mac`, `linux` or `win` according to target platform) and `${arch}` macros. | | channel = "latest"| string \| null | The channel. | @@ -116,6 +116,9 @@ Generic (any HTTP(S) server) options. ### `GithubOptions` ⇐ [PublishConfiguration](#PublishConfiguration) GitHub options. +GitHub [personal access token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) is required. You can generate by going to [https://github.com/settings/tokens/new](https://github.com/settings/tokens/new). The access token should have the repo scope/permission. +Define `GH_TOKEN` environment variable. + **Kind**: interface of [electron-builder-http/out/publishOptions](#module_electron-builder-http/out/publishOptions) **Extends**: [PublishConfiguration](#PublishConfiguration) **Properties** @@ -143,7 +146,7 @@ If `BT_TOKEN` is set and `GH_TOKEN` is not set — defaults to `[{provider: "bin | Name | Type | Description | | --- | --- | --- | -| provider| "github" \| "bintray" \| "s3" \| "generic" | The provider. | +| **provider**| "github" \| "bintray" \| "s3" \| "generic" | The provider. | | owner| string \| null | The owner. | | token| string \| null | | @@ -161,7 +164,7 @@ Define `AWS_SECRET_ACCESS_KEY` and `AWS_ACCESS_KEY_ID` [environment variables](h | Name | Type | Description | | --- | --- | --- | -| bucket| string | The bucket name. | +| **bucket**| string | The bucket name. | | path = "/"| string \| null | The directory path. | | region| string \| null | The region. Is determined and set automatically when publishing. | | channel = "latest"| string \| null | The channel. | @@ -184,12 +187,12 @@ Define `AWS_SECRET_ACCESS_KEY` and `AWS_ACCESS_KEY_ID` [environment variables](h | Name | Type | Description | | --- | --- | --- | -| path| string | | +| **path**| string | | | githubArtifactName| string \| null | | -| sha2| string | | +| **sha2**| string | | | releaseName| string \| null | The release name. | | releaseNotes| string \| null | The release notes. | -| releaseDate| string | The release date. | +| **releaseDate**| string | The release date. | @@ -199,7 +202,7 @@ Define `AWS_SECRET_ACCESS_KEY` and `AWS_ACCESS_KEY_ID` [environment variables](h | Name | Type | Description | | --- | --- | --- | -| version| string | The version. | +| **version**| string | The version. | diff --git a/package.json b/package.json index 6583c8733fd..5f9456ed4eb 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "sanitize-filename": "^1.6.1", "semver": "^5.3.0", "stat-mode": "^0.2.2", - "ts-jsdoc": "^1.2.0", + "ts-jsdoc": "^1.2.1", "tunnel-agent": "^0.6.0", "update-notifier": "^2.1.0", "uuid-1345": "^0.99.6", diff --git a/packages/electron-builder/src/fileTransformer.ts b/packages/electron-builder/src/fileTransformer.ts index b86870eada7..0d4809f1336 100644 --- a/packages/electron-builder/src/fileTransformer.ts +++ b/packages/electron-builder/src/fileTransformer.ts @@ -7,19 +7,13 @@ import * as path from "path" import { BuildInfo } from "./packagerApi" export function isElectronCompileUsed(info: BuildInfo): boolean { - const depList = [(info.metadata).devDependencies, info.metadata.dependencies] - if (info.isTwoPackageJsonProjectLayoutUsed) { - depList.push((info.devMetadata).devDependencies) - depList.push(info.devMetadata.dependencies) + if (info.config.electronCompile != null) { + return info.config.electronCompile } - for (const deps of depList) { - if (deps != null && "electron-compile" in deps) { - return true - } - } - - return false + // if in devDependencies - it means that babel is used for precompilation or for some reason user decided to not use electron-compile for production + const deps = info.metadata.dependencies + return deps != null && "electron-compile" in deps } export async function createTransformer(srcDir: string, extraMetadata: any): Promise { diff --git a/packages/electron-builder/src/metadata.ts b/packages/electron-builder/src/metadata.ts index 3de403416f6..70ecb37e193 100755 --- a/packages/electron-builder/src/metadata.ts +++ b/packages/electron-builder/src/metadata.ts @@ -197,6 +197,11 @@ export interface Config extends PlatformSpecificBuildOptions { */ readonly buildVersion?: string | null + /** + * Whether to use [electron-compile](http://github.com/electron/electron-compile) to compile app. Defaults to `true` if `electron-compile` in the dependencies. And `false` if in the `devDependencies` or doesn't specified. + */ + readonly electronCompile?: boolean + readonly mac?: MacOptions | null readonly mas?: MasBuildOptions | null readonly dmg?: DmgOptions | null diff --git a/yarn.lock b/yarn.lock index 6f98033890b..30837c2c978 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2255,7 +2255,7 @@ mime@^1.3.4: dependencies: brace-expansion "^1.0.0" -minimist@0.0.8: +minimist@0.0.8, minimist@~0.0.1: version "0.0.8" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" @@ -2263,10 +2263,6 @@ 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" -minimist@~0.0.1: - version "0.0.10" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" - mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" @@ -3169,9 +3165,9 @@ ts-babel@^3.0.0: fs-extra-p "^4.1.0" source-map-support "^0.4.14" -ts-jsdoc@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/ts-jsdoc/-/ts-jsdoc-1.2.0.tgz#7400db16493fe3292bf884122142bd02b755d085" +ts-jsdoc@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ts-jsdoc/-/ts-jsdoc-1.2.1.tgz#e2b05881c4f8cc4b0972586d01d7a91673d18745" dependencies: bluebird-lst "^1.0.2" chalk "^1.1.3"