From 7f9e6e3644297aeddb02ce2861c8e540657e7656 Mon Sep 17 00:00:00 2001 From: develar Date: Tue, 7 Jun 2016 08:14:19 +0200 Subject: [PATCH] fix: restore `--platform` and `--arch` CLI --- README.md | 30 ++++++++++++++++-------------- docs/Options.md | 2 +- package.json | 5 +---- src/builder.ts | 2 +- src/cliOptions.ts | 7 ++----- src/metadata.ts | 4 +++- test/src/BuildTest.ts | 2 ++ 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 1aa2dddb647..cc37e863fec 100755 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ # electron-builder [![npm version](https://img.shields.io/npm/v/electron-builder.svg)](https://npmjs.org/package/electron-builder) -Complete solution to build ready for distribution and "auto update" installers of your app for OS X, Windows and Linux. +Complete solution to package and build ready for distribution and "auto update" Electron app for OS X, Windows and Linux. -* [Native application dependencies](http://electron.atom.io/docs/latest/tutorial/using-native-node-modules/) compilation (only if [two-package.json project structure](#two-packagejson-structure) used). -* [Auto Update](#auto-update) ready application packaging. +* NPM packages management: + * [Native application dependencies](http://electron.atom.io/docs/latest/tutorial/using-native-node-modules/) compilation (only if [two-package.json project structure](#two-packagejson-structure) used). + * Development dependencies are never included. You don't need to ignore it explicitly. * [Code Signing](https://github.com/electron-userland/electron-builder/wiki/Code-Signing) on a CI server or development machine. +* [Auto Update](#auto-update) ready application packaging. * [Build version management](#build-version-management). +* Numerous target formats: + * All platforms: `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`. + * [OS X](https://github.com/electron-userland/electron-builder/wiki/Options#OsXBuildOptions-target): `dmg`, `mas`. + * [Linux](https://github.com/electron-userland/electron-builder/wiki/Options#LinuxBuildOptions-target): `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`. + * Windows: Squirrel.Windows. NSIS will be supported soon. * [Publishing artifacts to GitHub Releases](https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts). [electron-packager](https://github.com/electron-userland/electron-packager) and @@ -14,26 +21,22 @@ Real project example — [onshape-desktop-shell](https://github.com/develar/onsh # Two package.json structure -We strongly recommend to use **two** package.json files (it is not required, you can build project with any structure). +We recommend to use two package.json files (it is not required, you can build project with any structure). 1. For development - In the root of the project. - Here you declare dependencies for your development environment and build scripts. + In the root of the project. Here you declare dependencies for your development environment and build scripts. 2. For your application In the `app` directory. *Only this directory is distributed with real application.* -Why the two package.json structure is ideal and how it solves a lot of issues -([#39](https://github.com/electron-userland/electron-builder/issues/39), -[#182](https://github.com/electron-userland/electron-builder/issues/182), -[#230](https://github.com/electron-userland/electron-builder/issues/230))? +Why? -1. Native npm modules (those written in C, not JavaScript) need to be compiled, and here we have two different compilation targets for them. Those used in application need to be compiled against electron runtime, and all `devDependencies` need to be compiled against your locally installed node.js. Thanks to having two files this is trivial. -2. When you package the app for distribution there is no need to add up to size of the app with your `devDependencies`. Here those are always not included (because reside outside the `app` directory). +1. Native npm modules (those written in C, not JavaScript) need to be compiled, and here we have two different compilation targets for them. Those used in application need to be compiled against electron runtime, and all `devDependencies` need to be compiled against your locally installed node.js. Thanks to having two files this is trivial (see [#39](https://github.com/electron-userland/electron-builder/issues/39)). +2. No need to specify which [files](https://github.com/electron-userland/electron-builder/wiki/Options#BuildMetadata-files) to include in the app (because development files reside outside the `app` directory). -Please see [#379](https://github.com/electron-userland/electron-builder/issues/379#issuecomment-218503881) and [#326](https://github.com/electron-userland/electron-builder/issues/326#issuecomment-211124807). +Please see [Loading App Dependencies Manually](https://github.com/electron-userland/electron-builder/wiki/Loading-App-Dependencies-Manually) and [#379](https://github.com/electron-userland/electron-builder/issues/379#issuecomment-218503881). # Configuration @@ -81,7 +84,6 @@ Please note — packaged into an asar archive [by default](https://github.com/el * `-mac.zip`: required for Squirrel.Mac. * `.exe` and `-ia32.exe`: Windows installer, required for Windows user to initial install. Please note — [your app must handle Squirrel.Windows events](https://github.com/electronjs/windows-installer#handling-squirrel-events). See [real example](https://github.com/develar/onshape-desktop-shell/blob/master/src/WinSquirrelStartupEventHandler.ts). * `.full-nupkg`: required for Squirrel.Windows. -* `-amd64.deb` and `-i386.deb`: Linux Debian package. Please note — by default the most effective [xz](https://en.wikipedia.org/wiki/Xz) compression format used. For auto updating to work, you must implement and configure Electron's [`autoUpdater`](http://electron.atom.io/docs/latest/api/auto-updater/) module ([example](https://github.com/develar/onshape-desktop-shell/blob/master/src/AppUpdater.ts)). You also need to deploy your releases to a server. diff --git a/docs/Options.md b/docs/Options.md index c79669d28e4..f0e20cfc8eb 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -109,7 +109,7 @@ MAS (Mac Application Store) specific options (in addition to `build.osx`). | vendor | The vendor. Defaults to [author](#AppMetadata-author). | compression | *deb-only.* The compression type, one of `gz`, `bzip2`, `xz`. Defaults to `xz`. | depends | Package dependencies. Defaults to `["libappindicator1", "libnotify-bin"]`. -| target |

Target package type: list of default, deb, rpm, freebsd, pacman, p5p, apk, 7z, zip, tar.xz, tar.lz, tar.gz, tar.bz2. Defaults to default (deb).

Only deb is tested. Feel free to file issues for rpm and other package formats.

+| target |

Target package type: list of deb, rpm, freebsd, pacman, p5p, apk, 7z, zip, tar.xz, tar.lz, tar.gz, tar.bz2. Defaults to deb.

The most effective [xz](https://en.wikipedia.org/wiki/Xz) compression format used by default.

Only deb is tested. Feel free to file issues for rpm and other package formats.

## `.directories` diff --git a/package.json b/package.json index 7c458049527..b6ab0dd12a2 100644 --- a/package.json +++ b/package.json @@ -128,8 +128,5 @@ "test/out/*" ] }, - "typings": "./out/electron-builder.d.ts", - "publishConfig": { - "tag": "next" - } + "typings": "./out/electron-builder.d.ts" } diff --git a/src/builder.ts b/src/builder.ts index d5397d28476..db1f52b7c08 100644 --- a/src/builder.ts +++ b/src/builder.ts @@ -128,7 +128,7 @@ export function normalizeOptions(args: CliOptions): BuildOptions { } if (targets.size === 0) { - if (args.platform == null) { + if (args.platform == null && args.arch == null) { processTargets(Platform.current(), []) } else { diff --git a/src/cliOptions.ts b/src/cliOptions.ts index 8c2337cf1a1..e82d0995c03 100644 --- a/src/cliOptions.ts +++ b/src/cliOptions.ts @@ -27,20 +27,17 @@ export function createYargs(): any { describe: "Build for ia32", type: "boolean", }) - // .option("target", { - // alias: "t", - // describe: "Target package types", - // choices: commonTargets, - // }) .option("publish", { alias: "p", describe: `Publish artifacts (to GitHub Releases), see ${underline("https://goo.gl/WMlr4n")}`, choices: ["onTag", "onTagOrDraft", "always", "never"], }) .option("platform", { + describe: "The target platform (preferred to use --osx, --win or --linux)", choices: ["osx", "win", "linux", "darwin", "win32", "all"], }) .option("arch", { + describe: "The target arch (preferred to use --x64 or --ia32)", choices: ["ia32", "x64", "all"], }) .strict() diff --git a/src/metadata.ts b/src/metadata.ts index 06c7fa912a3..a28d808cefa 100755 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -337,7 +337,9 @@ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions { readonly depends?: string[] | null /* - Target package type: list of `default`, `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`. Defaults to `default` (`deb`). + Target package type: list of `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`. Defaults to `deb`. + + The most effective [xz](https://en.wikipedia.org/wiki/Xz) compression format used by default. Only `deb` is tested. Feel free to file issues for `rpm` and other package formats. */ diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts index 70d40db3a92..4ae8e2110c2 100755 --- a/test/src/BuildTest.ts +++ b/test/src/BuildTest.ts @@ -26,7 +26,9 @@ test("cli", () => { return normalizeOptions(yargs.parse(input.split(" "))) } + assertThat(parse("--platform osx")).isEqualTo(expected({targets: Platform.OSX.createTarget()})) assertThat(parse("--osx")).isEqualTo(expected({targets: Platform.OSX.createTarget()})) + assertThat(parse("--arch x64")).isEqualTo(expected({targets: Platform.current().createTarget(null, Arch.x64)})) assertThat(parse("--ia32 --x64")).isEqualTo(expected({targets: Platform.current().createTarget(null, Arch.x64, Arch.ia32)})) assertThat(parse("--linux")).isEqualTo(expected({targets: Platform.LINUX.createTarget()})) assertThat(parse("--win")).isEqualTo(expected({targets: Platform.WINDOWS.createTarget()}))