Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

## Unreleased

### Added

* Add `download` parameter (#320)

### Changed

* **Dropped support for running on Node < 4.0.** (#319)

### Fixed

* `strict-ssl` (and by extension, `download.strictSSL`) defaults to `true`, as documented (#320)

### Deprecated

* `cache` is deprecated in favor of `download.cache` (#320)
* `strict-ssl` is deprecated in favor of `download.strictSSL` (#320)

## [6.0.2] - 2016-04-09

### Changed
Expand Down
15 changes: 14 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
#!/usr/bin/env node
var fs = require('fs')
var args = require('minimist')(process.argv.slice(2), {boolean: ['prune', 'asar', 'all', 'overwrite', 'strict-ssl']})
var args = require('minimist')(process.argv.slice(2), {
boolean: [
'prune',
'asar',
'all',
'overwrite',
'strict-ssl',
'download.strictSSL'
],
default: {
'strict-ssl': true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually fixes a bug with strict-ssl 😢

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably use the alias feature of minimist, so the two values are always in sync. Otherwise, the other default might overwrite the user setting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, wow. Good catch. This means that users using electron-packager v6 from the command line will accept invalid ssl certificates.

This is bad enough that I would recommend running npm deprecate on all older versions so users know to upgrade.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably use the alias feature of minimist, so the two values are always in sync. Otherwise, the other default might overwrite the user setting.

Hmm. I'll have to look into that, thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All versions or just 6.x?

'download.strictSSL': true
}
})
var packager = require('./')
var path = require('path')
var usage = fs.readFileSync(path.join(__dirname, 'usage.txt')).toString()
Expand Down
30 changes: 30 additions & 0 deletions common.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ function generateFinalPath (opts) {
return path.join(opts.out || process.cwd(), generateFinalBasename(opts))
}

function subOptionWarning (properties, option_name, parameter, value) {
if (properties.hasOwnProperty(parameter)) {
console.warn(`WARNING: ${option_name}.${parameter} will be inferred from the main options`)
}
properties[parameter] = value
}

function userIgnoreFilter (opts) {
var ignore = opts.ignore || []
var ignoreFunc = null
Expand Down Expand Up @@ -84,6 +91,29 @@ module.exports = {
return platform === 'darwin' || platform === 'mas'
},

subOptionWarning: subOptionWarning,

createDownloadOpts: function createDownloadOpts (opts, platform, arch) {
if (opts.hasOwnProperty('cache')) {
console.warn('The cache parameter is deprecated, use download.cache instead')
}

if (opts.hasOwnProperty('strict-ssl')) {
console.warn('The strict-ssl parameter is deprecated, use download.strictSSL instead')
}

var downloadOpts = Object.assign({
cache: opts.cache,
strictSSL: opts['strict-ssl']
}, opts.download)

subOptionWarning(downloadOpts, 'download', 'platform', platform)
subOptionWarning(downloadOpts, 'download', 'arch', arch)
subOptionWarning(downloadOpts, 'download', 'version', opts.version)

return downloadOpts
},

generateFinalBasename: generateFinalBasename,
generateFinalPath: generateFinalPath,

Expand Down
18 changes: 16 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,23 @@ The build version of the application. Maps to the `FileVersion` metadata propert

##### `cache`

*String* (default: `$HOME/.electron`)
*String* (default: `$HOME/.electron`) (**deprecated** and will be removed in a future major version,
please use the [`download.cache`](#download) parameter instead)

The directory where prebuilt, pre-packaged Electron downloads are cached.

##### `download`

*Object*

If present, passes custom options to [`electron-download`](https://www.npmjs.com/package/electron-download)
(see the link for more detailed option descriptions and the defaults). Supported parameters include,
but are not limited to:
- `cache` (*String*): The directory where prebuilt, pre-packaged Electron downloads are cached.
- `mirror` (*String*): The URL to override the default Electron download location.
- `strictSSL` (*Boolean* - default: `true`): Whether SSL certificates are required to be valid when
downloading Electron.

##### `icon`

*String*
Expand Down Expand Up @@ -138,7 +151,8 @@ Runs [`npm prune --production`](https://docs.npmjs.com/cli/prune) before startin

##### `strict-ssl`

*Boolean* (**default: `true`**)
*Boolean* (**default: `true`**) (**deprecated** and will be removed in a future major version,
please use the [`download.strictSSL`](#download) parameter instead)

Whether SSL certificates are required to be valid when downloading Electron.

Expand Down
8 changes: 1 addition & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,7 @@ function createSeries (opts, archs, platforms) {
platforms.forEach(function (platform) {
// Electron does not have 32-bit releases for Mac OS X, so skip that combination
if (common.isPlatformMac(platform) && arch === 'ia32') return
combinations.push({
platform: platform,
arch: arch,
version: opts.version,
cache: opts.cache,
strictSSL: opts['strict-ssl']
})
combinations.push(common.createDownloadOpts(opts, platform, arch))
})
})

Expand Down
17 changes: 3 additions & 14 deletions mac.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,15 @@ function filterCFBundleIdentifier (identifier) {
return identifier.replace(/ /g, '-').replace(/[^a-zA-Z0-9.-]/g, '')
}

function signOptsWarning (name) {
console.warn(`WARNING: osx-sign.${name} will be inferred from main options`)
}

function createSignOpts (properties, platform, app) {
// use default sign opts if osx-sign is true, otherwise clone osx-sign object
var signOpts = properties === true ? {identity: null} : Object.assign({}, properties)

// osx-sign options are handed off to sign module, but
// with a few additions from main options
// with a few additions from the main options
// user may think they can pass platform or app, but they will be ignored
if (signOpts.platform) {
signOptsWarning('platform')
}
signOpts.platform = platform

if (signOpts.app) {
signOptsWarning('app')
}
signOpts.app = app
common.subOptionWarning(signOpts, 'osx-sign', 'platform', platform)
common.subOptionWarning(signOpts, 'osx-sign', 'app', app)

if (signOpts.binaries) {
console.warn('WARNING: osx-sign.binaries signing will fail. Sign manually, or with electron-osx-sign.')
Expand Down
43 changes: 43 additions & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,49 @@ function createIgnoreImplicitOutDirTest (opts) {
}
}

test('download argument test: download.cache overwrites cache', function (t) {
var opts = {
cache: 'should not exist',
download: {
cache: 'should exist'
},
version: '0.36.0'
}

var downloadOpts = common.createDownloadOpts(opts, 'linux', 'x64')
t.same(downloadOpts, {arch: 'x64', platform: 'linux', version: '0.36.0', cache: opts.download.cache, strictSSL: undefined})
t.end()
})

test('download argument test: download.strictSSL overwrites strict-ssl', function (t) {
var opts = {
download: {
strictSSL: false
},
'strict-ssl': true,
version: '0.36.0'
}

var downloadOpts = common.createDownloadOpts(opts, 'linux', 'x64')
t.same(downloadOpts, {arch: 'x64', platform: 'linux', version: '0.36.0', cache: undefined, strictSSL: opts.download.strictSSL})
t.end()
})

test('download argument test: download.{arch,platform,version} does not overwrite {arch,platform,version}', function (t) {
var opts = {
download: {
arch: 'ia32',
platform: 'win32',
version: '0.30.0'
},
version: '0.36.0'
}

var downloadOpts = common.createDownloadOpts(opts, 'linux', 'x64')
t.same(downloadOpts, {arch: 'x64', platform: 'linux', version: '0.36.0', cache: undefined, strictSSL: undefined})
t.end()
})

util.testAllPlatforms('infer test', createInferTest)
util.testAllPlatforms('defaults test', createDefaultsTest)
util.testAllPlatforms('default_app.asar removal test', createDefaultAppAsarTest)
Expand Down
9 changes: 9 additions & 0 deletions usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,22 @@ asar-unpack-dir unpacks the dir to app.asar.unpacked directory whose names ma
For example, `--asar-unpack-dir=sub_dir` will unpack the directory `/<sourcedir>/sub_dir`.
build-version build version to set for the app
cache directory of cached Electron downloads. Defaults to '$HOME/.electron'
(Deprecated, use --download.cache instead)
download a list of sub-options to pass to electron-download. They are specified via dot
notation, e.g., --download.cache=/tmp/cache
Properties supported:
- cache: directory of cached Electron downloads. Defaults to '$HOME/.electron'
- mirror: alternate URL to download Electron zips
- strictSSL: whether SSL certs are required to be valid when downloading
Electron. Defaults to true, use --download.strictSSL=false to disable checks.
icon the icon file to use as the icon for the app. Note: Format depends on platform.
ignore do not copy files into app whose filenames regex .match this string
out the dir to put the app into at the end. defaults to current working dir
overwrite if output directory for a platform already exists, replaces it rather than skipping it
prune runs `npm prune --production` on the app
strict-ssl whether SSL certificates are required to be valid when downloading Electron.
It defaults to true, use --strict-ssl=false to disable checks.
(Deprecated, use --download.strictSSL instead)
tmpdir temp directory. Defaults to system temp directory, use --tmpdir=false to disable use of a temporary directory.
version the version of Electron that is being packaged, see https://github.com/electron/electron/releases

Expand Down