diff --git a/README.md b/README.md index 5b115a47080..a8206673a25 100755 --- a/README.md +++ b/README.md @@ -19,8 +19,6 @@ _Note: Platform specific `7zip-bin-*` packages are `optionalDependencies`, which Real project example — [onshape-desktop-shell](https://github.com/develar/onshape-desktop-shell). -Consider to use `nsis` target for Windows ([auto-update](https://github.com/electron-userland/electron-builder/issues/529) will be implemented this month) for new projects. - # Configuration See [options](https://github.com/electron-userland/electron-builder/wiki/Options) for a full reference but consider following the simple guide outlined below first. diff --git a/docs/Options.md b/docs/Options.md index c502342678b..e3ee8bee720 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -82,9 +82,9 @@ Don't customize paths to background and icon, — just follow conventions. | linux | See [.build.linux](#LinuxBuildOptions). | compression | The compression level, one of `store`, `normal`, `maximum` (default: `normal`). If you want to rapidly test build, `store` can reduce build time significantly. | afterPack | *programmatic API only* The function to be run after pack (but before pack into distributable format and sign). Promise must be returned. -| npmRebuild | *two package.json structure only* Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`. -| npmSkipBuildFromSource | *two package.json structure only* Whether to omit using [--build-from-source](https://github.com/mapbox/node-pre-gyp#options) flag when installing app native deps. Defaults to `false`. -| npmArgs | *two package.json structure only* Additional command line arguments to use when installing app native deps. Defaults to `null`. +| npmRebuild | Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`. +| npmSkipBuildFromSource | Whether to omit using [--build-from-source](https://github.com/mapbox/node-pre-gyp#options) flag when installing app native deps. Defaults to `false`. +| npmArgs | Additional command line arguments to use when installing app native deps. Defaults to `null`. | nodeGypRebuild | Whether to execute `node-gyp rebuild` before starting to package the app. Defaults to `false`. | electronDist | The path to custom Electron build (e.g. `~/electron/out/R`). Only macOS supported, file issue if need for Linux or Windows. | publish | See [.build.publish](#PublishConfiguration). @@ -255,9 +255,9 @@ Amazon S3 — `https` must be used, so, if you use direct Amazon S3 endpoints, f | --- | --- | iconUrl |

A URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features). Defaults to the Electron icon.

Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http.

| loadingGif |

The path to a .gif file to display during install. build/install-spinner.gif will be used if exists (it is a recommended way to set) (otherwise [default](https://github.com/electron/windows-installer/blob/master/resources/install-spinner.gif)).

-| msi | *Squirrel.Windows-only.* Whether to create an MSI installer. Defaults to `false` (MSI is not created). -| remoteReleases | *Squirrel.Windows-only.* A URL to your existing updates. Or `true` to automatically set to your GitHub repository. If given, these will be downloaded to create delta updates. -| remoteToken | *Squirrel.Windows-only.* Authentication token for remote updates +| msi | Whether to create an MSI installer. Defaults to `false` (MSI is not created). +| remoteReleases | A URL to your existing updates. Or `true` to automatically set to your GitHub repository. If given, these will be downloaded to create delta updates. +| remoteToken | Authentication token for remote updates | useAppIdAsId | Use `appId` to identify package instead of `name`. @@ -267,7 +267,7 @@ Windows specific build options. | Name | Description | --- | --- -| target | Target package type: list of `nsis`, `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `squirrel`. +| target | Target package type: list of `nsis`, `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `nsis`. | signingHashAlgorithms | Array of signing algorithms used. Defaults to `['sha1', 'sha256']` | icon | The path to application icon. Defaults to `build/icon.ico` (consider using this convention instead of complicating your configuration). | legalTrademarks | The trademarks and registered trademarks. diff --git a/package.json b/package.json index be7779dfee5..7942f001709 100644 --- a/package.json +++ b/package.json @@ -131,7 +131,12 @@ "transform-es2015-spread", "transform-es2015-destructuring", "array-includes", - "transform-inline-imports-commonjs" + [ + "transform-inline-imports-commonjs", + { + "excludeModules": "path" + } + ] ] }, "ava": { diff --git a/src/metadata.ts b/src/metadata.ts index a0618cd489a..c0f42a924ff 100755 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -195,17 +195,17 @@ export interface BuildMetadata { readonly afterPack?: (context: AfterPackContext) => Promise | null /* - *two package.json structure only* Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`. + Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`. */ readonly npmRebuild?: boolean /* - *two package.json structure only* Whether to omit using [--build-from-source](https://github.com/mapbox/node-pre-gyp#options) flag when installing app native deps. Defaults to `false`. + Whether to omit using [--build-from-source](https://github.com/mapbox/node-pre-gyp#options) flag when installing app native deps. Defaults to `false`. */ readonly npmSkipBuildFromSource?: boolean /* - *two package.json structure only* Additional command line arguments to use when installing app native deps. Defaults to `null`. + Additional command line arguments to use when installing app native deps. Defaults to `null`. */ readonly npmArgs?: Array | string | null diff --git a/src/options/winOptions.ts b/src/options/winOptions.ts index 9f4170b7ee0..cc896b6b66f 100644 --- a/src/options/winOptions.ts +++ b/src/options/winOptions.ts @@ -7,7 +7,7 @@ import { PlatformSpecificBuildOptions } from "../metadata" */ export interface WinBuildOptions extends PlatformSpecificBuildOptions { /* - Target package type: list of `nsis`, `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `squirrel`. + Target package type: list of `nsis`, `squirrel`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `nsis`. */ readonly target?: Array | null @@ -143,17 +143,17 @@ export interface SquirrelWindowsOptions extends WinBuildOptions { readonly loadingGif?: string | null /* - *Squirrel.Windows-only.* Whether to create an MSI installer. Defaults to `false` (MSI is not created). + Whether to create an MSI installer. Defaults to `false` (MSI is not created). */ readonly msi?: boolean /* - *Squirrel.Windows-only.* A URL to your existing updates. Or `true` to automatically set to your GitHub repository. If given, these will be downloaded to create delta updates. + A URL to your existing updates. Or `true` to automatically set to your GitHub repository. If given, these will be downloaded to create delta updates. */ readonly remoteReleases?: string | boolean | null /* - *Squirrel.Windows-only.* Authentication token for remote updates + Authentication token for remote updates */ readonly remoteToken?: string | null diff --git a/src/platformPackager.ts b/src/platformPackager.ts index fbd96cdad8f..26d55360b0f 100644 --- a/src/platformPackager.ts +++ b/src/platformPackager.ts @@ -9,7 +9,7 @@ import { AsarOptions } from "asar-electron-builder" import { archiveApp } from "./targets/archive" import { Minimatch } from "minimatch" import { checkFileInArchive, createAsarArchive } from "./asarUtil" -import { warn, log, task } from "./util/log" +import { warn, log } from "./util/log" import { AppInfo } from "./appInfo" import { copyFiltered } from "./util/filter" import { pack } from "./packager/dirPackager" @@ -182,7 +182,8 @@ export abstract class PlatformPackager const resourcesPath = this.platform === Platform.MAC ? path.join(appOutDir, "Electron.app", "Contents", "Resources") : path.join(appOutDir, "resources") - const p = pack(this, appOutDir, platformName, Arch[arch], this.info.electronVersion, async() => { + log(`Packaging for ${platformName} ${Arch[arch]} using electron ${this.info.electronVersion} to ${path.relative(this.projectDir, appOutDir)}`) + await pack(this, appOutDir, platformName, Arch[arch], this.info.electronVersion, async () => { const ignoreFiles = new Set([path.resolve(this.info.appDir, outDir), path.resolve(this.info.appDir, this.buildResourcesDir)]) // prune dev or not listed dependencies await dependencies(this.info.appDir, true, ignoreFiles) @@ -244,7 +245,6 @@ export abstract class PlatformPackager promises.push(this.postInitApp(appOutDir)) await BluebirdPromise.all(promises) }) - await task(`Packaging for platform ${platformName} ${Arch[arch]} using electron ${this.info.electronVersion} to ${path.relative(this.projectDir, appOutDir)}`, p) await this.doCopyExtraFiles(extraResourceMatchers) await this.doCopyExtraFiles(extraFileMatchers) diff --git a/src/targets/nsis.ts b/src/targets/nsis.ts index 77cf05ce674..052acf9790a 100644 --- a/src/targets/nsis.ts +++ b/src/targets/nsis.ts @@ -5,12 +5,9 @@ import * as path from "path" import BluebirdPromise from "bluebird-lst-c" import { getBinFromBintray } from "../util/binDownload" import { v5 as uuid5 } from "uuid-1345" -import { - normalizeExt, TargetEx, getPublishConfigs, getResolvedPublishConfig, - ArtifactCreated -} from "../platformPackager" +import { normalizeExt, TargetEx, getPublishConfigs, getResolvedPublishConfig, ArtifactCreated } from "../platformPackager" import { archiveApp } from "./archive" -import { subTask, task, log } from "../util/log" +import { subTask, log } from "../util/log" import { unlink, readFile, writeFile, createReadStream } from "fs-extra-p" import { SemVer } from "semver" import { NsisOptions } from "../options/winOptions" @@ -56,6 +53,8 @@ export default class NsisTarget extends TargetEx { } 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])) @@ -66,9 +65,14 @@ export default class NsisTarget extends TargetEx { return await archiveApp(packager.devMetadata.build.compression, "7z", archiveFile, appOutDir, false, true) } - finishBuild(): Promise { - return task("Building NSIS installer", this.buildInstaller() - .then(() => BluebirdPromise.map(this.archs.values(), it => unlink(it)))) + async finishBuild(): Promise { + log("Building NSIS installer") + try { + await this.buildInstaller() + } + finally { + await BluebirdPromise.map(this.archs.values(), it => unlink(it)) + } } private async buildInstaller(): Promise { diff --git a/src/targets/squirrelWindows.ts b/src/targets/squirrelWindows.ts index b48fa4564a7..fd83737b7f9 100644 --- a/src/targets/squirrelWindows.ts +++ b/src/targets/squirrelWindows.ts @@ -20,6 +20,8 @@ export default class SquirrelWindowsTarget extends TargetEx { } async build(appOutDir: string, arch: Arch) { + log(`Building Squirrel.Windows for arch ${Arch[arch]}`) + if (arch === Arch.ia32) { warn("For windows consider only distributing 64-bit or use nsis target, see https://github.com/electron-userland/electron-builder/issues/359#issuecomment-214851130") } diff --git a/src/winPackager.ts b/src/winPackager.ts index dfabcceb97b..0fd1b6477ac 100644 --- a/src/winPackager.ts +++ b/src/winPackager.ts @@ -3,7 +3,7 @@ import BluebirdPromise from "bluebird-lst-c" import { PlatformPackager, BuildInfo, Target, TargetEx } from "./platformPackager" import { Platform, Arch } from "./metadata" import * as path from "path" -import { log, task } from "./util/log" +import { log } from "./util/log" import { exec, use } from "./util/util" import { open, close, read } from "fs-extra-p" import { sign, SignOptions, getSignVendorPath } from "./windowsCodeSign" @@ -73,13 +73,13 @@ export class WinPackager extends PlatformPackager { continue } - if (name === DEFAULT_TARGET || name === "squirrel") { + if (name === "squirrel") { mapper("squirrel", () => { const targetClass: typeof SquirrelWindowsTarget = require("./targets/squirrelWindows").default return new targetClass(this) }) } - else if (name === "nsis") { + else if (name === DEFAULT_TARGET || name === "nsis") { mapper(name, outDir => { const targetClass: typeof NsisTarget = require("./targets/nsis").default return new targetClass(this, outDir) @@ -181,7 +181,7 @@ export class WinPackager extends PlatformPackager { protected packageInDistributableFormat(outDir: string, appOutDir: string, arch: Arch, targets: Array, promises: Array>): void { for (let target of targets) { if (target instanceof TargetEx) { - promises.push(task(`Building ${target.name} ${Arch[arch]}`, target.build(appOutDir, arch))) + promises.push(target.build(appOutDir, arch)) } else { const format = target.name diff --git a/test/src/globTest.ts b/test/src/globTest.ts index e5bbadd9e68..82bc8036261 100644 --- a/test/src/globTest.ts +++ b/test/src/globTest.ts @@ -190,7 +190,7 @@ test("extraResources", async () => { //noinspection SpellCheckingInspection await assertPack("test-app", { // to check NuGet package - targets: platform.createTarget(platform === Platform.WINDOWS ? null : DIR_TARGET), + targets: platform.createTarget(platform === Platform.WINDOWS ? "squirrel" : DIR_TARGET), }, { projectDirCreated: projectDir => { return BluebirdPromise.all([ diff --git a/test/src/winPackagerTest.ts b/test/src/winPackagerTest.ts index ba9ba433227..b57e3936b32 100755 --- a/test/src/winPackagerTest.ts +++ b/test/src/winPackagerTest.ts @@ -10,11 +10,11 @@ import { SignOptions } from "out/windowsCodeSign" import SquirrelWindowsTarget from "out/targets/squirrelWindows" import { Target } from "out/platformPackager" -test.ifNotCiOsx("win", app({targets: Platform.WINDOWS.createTarget(["default", "zip"])}, {signed: true})) +test.ifNotCiOsx("win", app({targets: Platform.WINDOWS.createTarget(["squirrel", "zip"])}, {signed: true})) // very slow test.skip("delta and msi", app({ - targets: Platform.WINDOWS.createTarget(null, Arch.ia32), + targets: Platform.WINDOWS.createTarget("squirrel", Arch.ia32), devMetadata: { build: { squirrelWindows: { @@ -39,8 +39,7 @@ test.ifDevOrWinCi("beta version", app({ } })) -test.ifNotCiOsx("msi as string", t => t.throws(assertPack("test-app-one", platform(Platform.WINDOWS), - { +test.ifNotCiOsx("msi as string", t => t.throws(assertPack("test-app-one", {targets: Platform.WINDOWS.createTarget("squirrel")}, { projectDirCreated: it => modifyPackageJson(it, data => { data.build.win = { msi: "false", @@ -54,7 +53,7 @@ test("detect install-spinner, certificateFile/password", () => { let loadingGifPath: string = null return assertPack("test-app-one", { - targets: Platform.WINDOWS.createTarget(), + targets: Platform.WINDOWS.createTarget("squirrel"), platformPackagerFactory: (packager, platform, cleanupTasks) => platformPackager = new CheckingWinPackager(packager), devMetadata: { build: { @@ -75,11 +74,10 @@ test("detect install-spinner, certificateFile/password", () => { } })]) }, - packed: () => { + packed: async () => { assertThat(platformPackager.effectiveDistOptions.loadingGif).isEqualTo(loadingGifPath) assertThat(platformPackager.signOptions.cert).isEqualTo("secretFile") assertThat(platformPackager.signOptions.password).isEqualTo("pass") - return BluebirdPromise.resolve(null) }, }) }) @@ -95,7 +93,7 @@ test.ifNotCiOsx("icon not an image", t => t.throws(assertPack("test-app-one", pl test.ifOsx("custom icon", () => { let platformPackager: CheckingWinPackager = null return assertPack("test-app-one", { - targets: Platform.WINDOWS.createTarget(), + targets: Platform.WINDOWS.createTarget("squirrel"), platformPackagerFactory: (packager, platform, cleanupTasks) => platformPackager = new CheckingWinPackager(packager) }, { projectDirCreated: projectDir => BluebirdPromise.all([ @@ -108,7 +106,6 @@ test.ifOsx("custom icon", () => { ]), packed: async context => { assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(context.projectDir, "customIcon.ico")) - return BluebirdPromise.resolve() }, }) })