From f1ecd4d543109e69818d28d2677491b332536fbb Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 11 Aug 2016 16:00:31 -0700 Subject: [PATCH 01/13] Default app/build version to package.json version --- index.js | 11 +++++++++-- mac.js | 2 +- test/fixtures/basic/package.json | 1 + test/mac.js | 31 +++++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 51d05729..bf450bb6 100644 --- a/index.js +++ b/index.js @@ -48,10 +48,11 @@ function validateList (list, supported, name) { return list } -function getNameAndVersion (opts, dir, cb) { +function getMetadata (opts, dir, cb) { var props = [] if (!opts.name) props.push(['productName', 'name']) if (!opts.version) props.push(['dependencies.electron', 'devDependencies.electron']) + if (!opts['app-version'] || !opts['build-version']) props.push('version') // Name and version provided, no need to infer if (props.length === 0) return cb(null) @@ -77,6 +78,12 @@ function inferNameAndVersionFromInstalled (packageName, opts, result, cb) { debug('Inferring application name from productName or name in package.json') opts.name = result.values.productName } + + if (result.values.version) { + debug('Inferring packageVersion from version in package.json') + opts.packageVersion = result.values.version + } + if (result.values[`dependencies.${packageName}`]) { resolve(packageName, { basedir: path.dirname(result.source[`dependencies.${packageName}`].src) @@ -223,7 +230,7 @@ module.exports = function packager (opts, cb) { debug(`Target Platforms: ${platforms.join(', ')}`) debug(`Target Architectures: ${archs.join(', ')}`) - getNameAndVersion(opts, path.resolve(process.cwd(), opts.dir) || process.cwd(), function (err) { + getMetadata(opts, path.resolve(process.cwd(), opts.dir) || process.cwd(), function (err) { if (err) { err.message = 'Unable to determine application name or Electron version. ' + 'Please specify an application name and Electron version.\n\n' + diff --git a/mac.js b/mac.js index 1e00552b..ca4e1e8d 100644 --- a/mac.js +++ b/mac.js @@ -30,7 +30,7 @@ class MacApp { } get appVersion () { - return this.opts['app-version'] + return this.opts['app-version'] || this.opts.packageVersion } get buildVersion () { diff --git a/test/fixtures/basic/package.json b/test/fixtures/basic/package.json index 942e4d9a..5fe25727 100644 --- a/test/fixtures/basic/package.json +++ b/test/fixtures/basic/package.json @@ -1,5 +1,6 @@ { "main": "main.js", + "version": "4.99.101", "productName": "MainJS", "dependencies": { "run-series": "^1.1.1" diff --git a/test/mac.js b/test/mac.js index 7283ac10..e71b0917 100644 --- a/test/mac.js +++ b/test/mac.js @@ -189,6 +189,33 @@ function createAppVersionTest (baseOpts, appVersion, buildVersion) { } } +function createAppVersionInferenceTest (baseOpts) { + return function (t) { + t.timeoutAfter(config.timeout) + + var plistPath + + waterfall([ + function (cb) { + packager(baseOpts, cb) + }, function (paths, cb) { + plistPath = path.join(paths[0], baseOpts.name + '.app', 'Contents', 'Info.plist') + fs.stat(plistPath, cb) + }, function (stats, cb) { + t.true(stats.isFile(), 'The expected Info.plist file should exist') + fs.readFile(plistPath, 'utf8', cb) + }, function (file, cb) { + var obj = plist.parse(file) + t.equal(obj.CFBundleVersion, '4.99.101', 'CFBundleVersion should reflect package.json version') + t.equal(obj.CFBundleShortVersionString, '4.99.101', 'CFBundleShortVersionString should reflect package.json version') + cb() + } + ], function (err) { + t.end(err) + }) + } +} + function createAppCategoryTypeTest (baseOpts, appCategoryType) { return function (t) { t.timeoutAfter(config.timeout) @@ -602,6 +629,10 @@ module.exports = function (baseOpts) { test('app and build version test', createAppVersionTest(baseOpts, '1.1.0', '1.1.0.1234')) util.teardown() + util.setup() + test('infer app version from package.json test', createAppVersionInferenceTest(baseOpts)) + util.teardown() + util.setup() test('app version test', createAppVersionTest(baseOpts, '1.1.0')) util.teardown() From cb33caa8daf45ea5e5b63439efd4376258b28f1f Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 11 Aug 2016 16:21:11 -0700 Subject: [PATCH 02/13] Keep dependency props at end of array --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index bf450bb6..c01aaa45 100644 --- a/index.js +++ b/index.js @@ -51,8 +51,8 @@ function validateList (list, supported, name) { function getMetadata (opts, dir, cb) { var props = [] if (!opts.name) props.push(['productName', 'name']) - if (!opts.version) props.push(['dependencies.electron', 'devDependencies.electron']) if (!opts['app-version'] || !opts['build-version']) props.push('version') + if (!opts.version) props.push(['dependencies.electron', 'devDependencies.electron']) // Name and version provided, no need to infer if (props.length === 0) return cb(null) From 1724a7580828469e77dee4fb900cd7f84b9ca0bf Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 11 Aug 2016 16:35:04 -0700 Subject: [PATCH 03/13] Remove unneeded build version check --- index.js | 6 +++--- mac.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index c01aaa45..a3135ed4 100644 --- a/index.js +++ b/index.js @@ -51,7 +51,7 @@ function validateList (list, supported, name) { function getMetadata (opts, dir, cb) { var props = [] if (!opts.name) props.push(['productName', 'name']) - if (!opts['app-version'] || !opts['build-version']) props.push('version') + if (!opts['app-version']) props.push('version') if (!opts.version) props.push(['dependencies.electron', 'devDependencies.electron']) // Name and version provided, no need to infer @@ -80,8 +80,8 @@ function inferNameAndVersionFromInstalled (packageName, opts, result, cb) { } if (result.values.version) { - debug('Inferring packageVersion from version in package.json') - opts.packageVersion = result.values.version + debug('Inferring app-version from version in package.json') + opts['app-version'] = result.values.version } if (result.values[`dependencies.${packageName}`]) { diff --git a/mac.js b/mac.js index ca4e1e8d..1e00552b 100644 --- a/mac.js +++ b/mac.js @@ -30,7 +30,7 @@ class MacApp { } get appVersion () { - return this.opts['app-version'] || this.opts.packageVersion + return this.opts['app-version'] } get buildVersion () { From a302279f8522369ea9169d96db80bb5debb90b01 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Thu, 11 Aug 2016 16:37:43 -0700 Subject: [PATCH 04/13] Add the good news --- NEWS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS.md b/NEWS.md index 7d4f18cc..6f2bb477 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,10 @@ ## Unreleased +### Added + +* The `package.json` `version` property is the default app version if `--app-version` is unspecified. + ### Fixed * [CLI] ensure --out has either a string or null value (#442) From db793fcbf988d2d444a0e492ad58af141e7735c6 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 11 Aug 2016 17:26:36 -0700 Subject: [PATCH 05/13] Add PR number to news --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 6f2bb477..5d8c7aa5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ ### Added -* The `package.json` `version` property is the default app version if `--app-version` is unspecified. +* The `package.json` `version` property is the default app version if `--app-version` is unspecified (#449) ### Fixed From a8a9f6945cafd62c127352175910aa3260b43fa1 Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Thu, 11 Aug 2016 21:44:43 -0700 Subject: [PATCH 06/13] Update docs --- docs/api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api.md b/docs/api.md index 30f9561e..cdbc5742 100644 --- a/docs/api.md +++ b/docs/api.md @@ -85,7 +85,7 @@ The human-readable copyright line for the app. Maps to the `LegalCopyright` meta *String* -The release version of the application. Maps to the `ProductVersion` metadata property on Windows, and `CFBundleShortVersionString` on OS X. +The release version of the application. By default the `version` property in the `package.json` is used but it can be overridden with this argument. If neither are provided, the version of Electron will be used. Maps to the `ProductVersion` metadata property on Windows, and `CFBundleShortVersionString` on OS X. ##### `asar` From d301bc80cc5072bda9460ad56f60a4360f0db99a Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Fri, 12 Aug 2016 15:36:34 -0700 Subject: [PATCH 07/13] brew install wine on travis macs --- test/ci/before_install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/ci/before_install.sh b/test/ci/before_install.sh index d71bed76..cb67cc9d 100755 --- a/test/ci/before_install.sh +++ b/test/ci/before_install.sh @@ -24,5 +24,6 @@ case "$TRAVIS_OS_NAME" in -in codesign.csr -out codesign.cer openssl pkcs12 -export -in codesign.cer -inkey codesign.key -out codesign.p12 -password pass:12345 security import codesign.p12 -k ~/Library/Keychains/login.keychain -P 12345 -T /usr/bin/codesign + brew install wine ;; esac From 4b697d8ec7e2c464e6f82c484153e71df0be771e Mon Sep 17 00:00:00 2001 From: Jessica Lord Date: Tue, 16 Aug 2016 14:51:11 -0700 Subject: [PATCH 08/13] Use wine package from npm --- test/ci/before_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ci/before_install.sh b/test/ci/before_install.sh index cb67cc9d..67b9aadb 100755 --- a/test/ci/before_install.sh +++ b/test/ci/before_install.sh @@ -24,6 +24,6 @@ case "$TRAVIS_OS_NAME" in -in codesign.csr -out codesign.cer openssl pkcs12 -export -in codesign.cer -inkey codesign.key -out codesign.p12 -password pass:12345 security import codesign.p12 -k ~/Library/Keychains/login.keychain -P 12345 -T /usr/bin/codesign - brew install wine + npm install wine-darwin@1.9.16 ;; esac From 685a8fe3ce1c63457f502eca3f9944aad8c7e240 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 16 Aug 2016 15:43:22 -0700 Subject: [PATCH 09/13] Upgrade wine-darwin version --- test/ci/before_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ci/before_install.sh b/test/ci/before_install.sh index 67b9aadb..ad371240 100755 --- a/test/ci/before_install.sh +++ b/test/ci/before_install.sh @@ -24,6 +24,6 @@ case "$TRAVIS_OS_NAME" in -in codesign.csr -out codesign.cer openssl pkcs12 -export -in codesign.cer -inkey codesign.key -out codesign.p12 -password pass:12345 security import codesign.p12 -k ~/Library/Keychains/login.keychain -P 12345 -T /usr/bin/codesign - npm install wine-darwin@1.9.16 + npm install wine-darwin@1.9.17-0 ;; esac From f52d168b2791ead49cece18b4968424f756f806b Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Aug 2016 10:14:57 -0700 Subject: [PATCH 10/13] git ignore npm-debug.log --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2212de3c..8b704b2a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ node_modules test/work .DS_Store .nyc_output +npm-debug.log From dccc0086a778ac1f6b930e6482b6c7235d045aab Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Aug 2016 10:46:38 -0700 Subject: [PATCH 11/13] Upgrade and configure wine on Travis --- .travis.yml | 4 +++- test/ci/before_install.sh | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a3e899e0..ad6a28ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,4 +23,6 @@ branches: env: global: # coveralls token - secure: hG3cs8/tOGTa8IPewVuahcp1f8gwsk/rX7ReUBPag6cdZdJpkbjzxp8R97mhhCrFOP/fvX8zAbCelXvvhME/mjZTFgzSNHLBL/SJreHP5m2B1yxXkroiQFu1qwewvzzKmfcs5W1CD8J8WbJuBk9zozDQG9c1OxTaK87tBGh1xik= + - secure: hG3cs8/tOGTa8IPewVuahcp1f8gwsk/rX7ReUBPag6cdZdJpkbjzxp8R97mhhCrFOP/fvX8zAbCelXvvhME/mjZTFgzSNHLBL/SJreHP5m2B1yxXkroiQFu1qwewvzzKmfcs5W1CD8J8WbJuBk9zozDQG9c1OxTaK87tBGh1xik= + # prevent wine popup dialogs about installing additional packages + - WINEDLLOVERRIDES="mscoree,mshtml=" diff --git a/test/ci/before_install.sh b/test/ci/before_install.sh index ad371240..fd184739 100755 --- a/test/ci/before_install.sh +++ b/test/ci/before_install.sh @@ -24,6 +24,8 @@ case "$TRAVIS_OS_NAME" in -in codesign.csr -out codesign.cer openssl pkcs12 -export -in codesign.cer -inkey codesign.key -out codesign.p12 -password pass:12345 security import codesign.p12 -k ~/Library/Keychains/login.keychain -P 12345 -T /usr/bin/codesign - npm install wine-darwin@1.9.17-0 + npm install wine-darwin@1.9.17-1 + # Setup ~/.wine by running a command + wine hostname ;; esac From 998de30f78606b73a0c3639d17b74a27c88625f0 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 17 Aug 2016 10:55:13 -0700 Subject: [PATCH 12/13] Use relative path to wine --- test/ci/before_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ci/before_install.sh b/test/ci/before_install.sh index fd184739..93c5570b 100755 --- a/test/ci/before_install.sh +++ b/test/ci/before_install.sh @@ -26,6 +26,6 @@ case "$TRAVIS_OS_NAME" in security import codesign.p12 -k ~/Library/Keychains/login.keychain -P 12345 -T /usr/bin/codesign npm install wine-darwin@1.9.17-1 # Setup ~/.wine by running a command - wine hostname + ./node_modules/.bin/wine hostname ;; esac From a5633e0dd4cbd37264b17b16204072a4ab4b182e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 18 Aug 2016 15:02:29 -0700 Subject: [PATCH 13/13] Suppress Wine fixme: log messages --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ad6a28ae..e950735b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,3 +26,4 @@ env: - secure: hG3cs8/tOGTa8IPewVuahcp1f8gwsk/rX7ReUBPag6cdZdJpkbjzxp8R97mhhCrFOP/fvX8zAbCelXvvhME/mjZTFgzSNHLBL/SJreHP5m2B1yxXkroiQFu1qwewvzzKmfcs5W1CD8J8WbJuBk9zozDQG9c1OxTaK87tBGh1xik= # prevent wine popup dialogs about installing additional packages - WINEDLLOVERRIDES="mscoree,mshtml=" + - WINEDEBUG="-all"