Skip to content

Commit

Permalink
fix: restore --platform and --arch CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jun 9, 2016
1 parent 6d4ab11 commit 7f9e6e3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ MAS (Mac Application Store) specific options (in addition to `build.osx`).
| vendor | <a name="LinuxBuildOptions-vendor"></a>The vendor. Defaults to [author](#AppMetadata-author).
| compression | <a name="LinuxBuildOptions-compression"></a>*deb-only.* The compression type, one of `gz`, `bzip2`, `xz`. Defaults to `xz`.
| depends | <a name="LinuxBuildOptions-depends"></a>Package dependencies. Defaults to `["libappindicator1", "libnotify-bin"]`.
| target | <a name="LinuxBuildOptions-target"></a><p>Target package type: list of <code>default</code>, <code>deb</code>, <code>rpm</code>, <code>freebsd</code>, <code>pacman</code>, <code>p5p</code>, <code>apk</code>, <code>7z</code>, <code>zip</code>, <code>tar.xz</code>, <code>tar.lz</code>, <code>tar.gz</code>, <code>tar.bz2</code>. Defaults to <code>default</code> (<code>deb</code>).</p> <p>Only <code>deb</code> is tested. Feel free to file issues for <code>rpm</code> and other package formats.</p>
| target | <a name="LinuxBuildOptions-target"></a><p>Target package type: list of <code>deb</code>, <code>rpm</code>, <code>freebsd</code>, <code>pacman</code>, <code>p5p</code>, <code>apk</code>, <code>7z</code>, <code>zip</code>, <code>tar.xz</code>, <code>tar.lz</code>, <code>tar.gz</code>, <code>tar.bz2</code>. Defaults to <code>deb</code>.</p> <p>The most effective [xz](https://en.wikipedia.org/wiki/Xz) compression format used by default.</p> <p>Only <code>deb</code> is tested. Feel free to file issues for <code>rpm</code> and other package formats.</p>

<a name="MetadataDirectories"></a>
## `.directories`
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,5 @@
"test/out/*"
]
},
"typings": "./out/electron-builder.d.ts",
"publishConfig": {
"tag": "next"
}
"typings": "./out/electron-builder.d.ts"
}
2 changes: 1 addition & 1 deletion src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 2 additions & 5 deletions src/cliOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 2 additions & 0 deletions test/src/BuildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()}))
Expand Down

0 comments on commit 7f9e6e3

Please sign in to comment.