From de58321ba24be38c7a0ad82d951d3f51d735b5d8 Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Mon, 18 Mar 2019 13:54:30 -0700 Subject: [PATCH 01/15] Remove callback support --- package.json | 1 - src/installer.js | 12 ++---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index d28bde5..29672bc 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,6 @@ "glob": "^7.1.3", "glob-promise": "^3.4.0", "lodash": "^4.17.11", - "nodeify": "^1.0.1", "parse-author": "^2.0.0", "which": "^1.3.1", "yargs": "^13.2.2" diff --git a/src/installer.js b/src/installer.js index e29ae25..5ea8eb1 100644 --- a/src/installer.js +++ b/src/installer.js @@ -4,7 +4,6 @@ const common = require('electron-installer-common') const debug = require('debug') const fs = require('fs-extra') const glob = require('glob-promise') -const nodeify = require('nodeify') const parseAuthor = require('parse-author') const path = require('path') @@ -233,18 +232,13 @@ class SquirrelInstaller extends common.ElectronInstaller { /* ************************************************************************** */ -module.exports = (data, callback) => { +module.exports = data => { data.rename = data.rename || defaultRename data.logger = data.logger || defaultLogger - if (callback) { - console.warn('The node-style callback is deprecated. In a future major version, it will be' + - 'removed in favor of a Promise-based async style.') - } - const installer = new SquirrelInstaller(data) - const promise = installer.generateDefaults() + return installer.generateDefaults() .then(() => installer.generateOptions()) .then(() => data.logger(`Creating package with options\n${JSON.stringify(installer.options, null, 2)}`)) .then(() => installer.createStagingDir()) @@ -260,8 +254,6 @@ module.exports = (data, callback) => { data.logger(common.errorMessage('creating package', err)) throw err }) - - return nodeify(promise, callback) } module.exports.Installer = SquirrelInstaller From 85920099f83dcfac70d92fcb0b483a08b6c470ea Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Mon, 18 Mar 2019 13:55:11 -0700 Subject: [PATCH 02/15] Improve imports in tests --- test/helpers/describe_cli.js | 4 +--- test/helpers/describe_installer.js | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/test/helpers/describe_cli.js b/test/helpers/describe_cli.js index 56e7e16..7e46689 100644 --- a/test/helpers/describe_cli.js +++ b/test/helpers/describe_cli.js @@ -4,9 +4,7 @@ const chai = require('chai') const fs = require('fs-extra') const { spawn } = require('electron-installer-common') const tmp = require('tmp-promise') -const access = require('./access_helper').access -const testAccess = require('./access_helper').testAccess -const accessAll = require('./access_helper').accessAll +const { access, testAccess, accessAll } = require('./access_helper') function printLogs (logs) { if (process.env.DEBUG === 'electron-installer-windows') { diff --git a/test/helpers/describe_installer.js b/test/helpers/describe_installer.js index a346796..ff599c6 100644 --- a/test/helpers/describe_installer.js +++ b/test/helpers/describe_installer.js @@ -4,9 +4,7 @@ const chai = require('chai') const fs = require('fs-extra') const path = require('path') const tmp = require('tmp-promise') -const access = require('./access_helper').access -const testAccess = require('./access_helper').testAccess -const accessAll = require('./access_helper').accessAll +const { access, testAccess, accessAll } = require('./access_helper') const installer = require('../..') From 7188b991c89f3fa4a524f03b78eca36ed1966604 Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Mon, 18 Mar 2019 13:59:08 -0700 Subject: [PATCH 03/15] Remove node 6 support --- .travis.yml | 1 - appveyor.yml | 4 ---- package.json | 2 +- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 263a982..86843c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ addons: env: - DEBUG="electron-installer-windows" NODE_VERSION="10" - DEBUG="electron-installer-windows" NODE_VERSION="8" - - DEBUG="electron-installer-windows" NODE_VERSION="6" branches: only: diff --git a/appveyor.yml b/appveyor.yml index f83fe2b..a9fdc21 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,10 +15,6 @@ environment: nodejs_version: '8' - platform: x64 nodejs_version: '8' - - platform: x86 - nodejs_version: '6' - - platform: x64 - nodejs_version: '6' branches: only: diff --git a/package.json b/package.json index 29672bc..55f601b 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "test": "npm run lint && npm run spec" }, "engines": { - "node": ">=6.0.0" + "node": ">=8.0.0" }, "dependencies": { "debug": "^4.1.0", From 9afc19922ebdc4d20fcec99068c44a8556396b5e Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Mon, 18 Mar 2019 13:59:22 -0700 Subject: [PATCH 04/15] Update README --- README.md | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7ad575f..0701fc7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ This tool relies on the awesome [Squirrel.Windows](https://github.com/Squirrel/S ## Requirements -This tool requires Node 6 or greater. +This tool requires Node 8 or greater. I'd recommend building your packages on your target platform, but if you have to run this on Mac OS X or Linux, you will need to install `mono` and `wine` through your package manager. @@ -172,20 +172,12 @@ installer(options) process.exit(1) }) ``` -Alternatively, it is possible to use the callback pattern: -```javascript -installer(options, (err) => { - if (err) { - console.error(err, err.stack) - process.exit(1) - } - - console.log(`Successfully created package at ${options.dest}`) -}) -``` You'll end up with the package at `dist/installers/app-0.0.1-setup.exe`. +_Note: As of 2.0.0, the Node-style callback pattern is no longer available. You can use [`nodeify`](https://npm.im/nodeify) if this is required for your use case._ + + ### Options Even though you can pass most of these options through the command-line interface, it may be easier to create a configuration file: From f7f19645f50350cdd0e6a0b908e3fdcdf01077aa Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Mon, 13 May 2019 12:49:09 -0700 Subject: [PATCH 05/15] Update dependencies --- package.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 55f601b..521a66e 100644 --- a/package.json +++ b/package.json @@ -30,9 +30,9 @@ }, "dependencies": { "debug": "^4.1.0", - "electron-installer-common": "^0.6.1", - "fs-extra": "^7.0.1", - "glob": "^7.1.3", + "electron-installer-common": "^0.6.3", + "fs-extra": "^8.0.1", + "glob": "^7.1.4", "glob-promise": "^3.4.0", "lodash": "^4.17.11", "parse-author": "^2.0.0", @@ -41,16 +41,16 @@ }, "devDependencies": { "chai": "^4.2.0", - "eslint": "^5.9.0", + "eslint": "^5.16.0", "eslint-config-standard": "^12.0.0", - "eslint-plugin-import": "^2.14.0", - "eslint-plugin-node": "^8.0.0", - "eslint-plugin-promise": "^4.0.1", + "eslint-plugin-import": "^2.17.2", + "eslint-plugin-node": "^9.0.1", + "eslint-plugin-promise": "^4.1.1", "eslint-plugin-standard": "^4.0.0", - "finalhandler": "^1.1.1", - "mocha": "^6.1.2", + "finalhandler": "^1.1.2", + "mocha": "^6.1.4", "promise-retry": "^1.1.1", - "serve-static": "^1.13.2", - "tmp-promise": "^1.0.5" + "serve-static": "^1.14.1", + "tmp-promise": "^2.0.0" } } From b8cabeb936f82f57de6f7c2238ae363ea078582a Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Mon, 13 May 2019 13:28:12 -0700 Subject: [PATCH 06/15] Replace nodify with util.callbackify --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0701fc7..50e0c6f 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ installer(options) You'll end up with the package at `dist/installers/app-0.0.1-setup.exe`. -_Note: As of 2.0.0, the Node-style callback pattern is no longer available. You can use [`nodeify`](https://npm.im/nodeify) if this is required for your use case._ +_Note: As of 2.0.0, the Node-style callback pattern is no longer available. You can use [`util.callbackify`](https://nodejs.org/dist/latest-v8.x/docs/api/util.html#util_util_callbackify_original) if this is required for your use case._ ### Options From c34e0c3006adca58e2a7fdb0909169b2c89b0bdc Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Tue, 14 May 2019 12:47:12 -0700 Subject: [PATCH 07/15] Remove glob-promise dependency --- package.json | 1 - src/installer.js | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 521a66e..fbdfc9b 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,6 @@ "electron-installer-common": "^0.6.3", "fs-extra": "^8.0.1", "glob": "^7.1.4", - "glob-promise": "^3.4.0", "lodash": "^4.17.11", "parse-author": "^2.0.0", "which": "^1.3.1", diff --git a/src/installer.js b/src/installer.js index 5ea8eb1..ee75f86 100644 --- a/src/installer.js +++ b/src/installer.js @@ -3,9 +3,10 @@ const common = require('electron-installer-common') const debug = require('debug') const fs = require('fs-extra') -const glob = require('glob-promise') const parseAuthor = require('parse-author') const path = require('path') +const { promisify } = require('util') +const glob = promisify(require('glob')) const spawn = require('./spawn') From fec8df87a26f1ac1789f870a0f9c81dba90c3ba7 Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Fri, 24 May 2019 15:12:06 -0700 Subject: [PATCH 08/15] feat: use Node 8 syntax --- .travis.yml | 2 + README.md | 9 ++- package.json | 2 +- src/installer.js | 114 +++++++++++++---------------- src/spawn.js | 2 +- test/cli.js | 4 +- test/helpers/access_helper.js | 34 ++++++--- test/helpers/describe_cli.js | 21 +++--- test/helpers/describe_installer.js | 27 ++++--- test/installer.js | 4 +- 10 files changed, 114 insertions(+), 105 deletions(-) diff --git a/.travis.yml b/.travis.yml index 86843c0..1ee7ab9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,8 @@ branches: - master - /^v\d+\.\d+\.\d+/ +cache: npm + before_install: nvm install $NODE_VERSION install: npm install script: npm test diff --git a/README.md b/README.md index 50e0c6f..34e4abd 100644 --- a/README.md +++ b/README.md @@ -165,12 +165,13 @@ const options = { console.log('Creating package (this may take a while)') -installer(options) - .then(() => console.log(`Successfully created package at ${options.dest}`)) - .catch(err => { +try { + await installer(options) + console.log(`Successfully created package at ${options.dest}`) +} catch(err) { console.error(err, err.stack) process.exit(1) - }) +} ``` You'll end up with the package at `dist/installers/app-0.0.1-setup.exe`. diff --git a/package.json b/package.json index fbdfc9b..6d6a7b0 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "dependencies": { "debug": "^4.1.0", - "electron-installer-common": "^0.6.3", + "electron-installer-common": "electron-userland/electron-installer-common", "fs-extra": "^8.0.1", "glob": "^7.1.4", "lodash": "^4.17.11", diff --git a/src/installer.js b/src/installer.js index ee75f86..c2e3508 100644 --- a/src/installer.js +++ b/src/installer.js @@ -52,16 +52,15 @@ class SquirrelInstaller extends common.ElectronInstaller { /** * Copy the application into the package. */ - copyApplication () { - return super.copyApplication() - .then(() => this.copySquirrelUpdater()) + async copyApplication () { + await super.copyApplication() + return this.copySquirrelUpdater() } copySquirrelUpdater () { const updateSrc = path.join(this.vendorDir, 'squirrel', 'Squirrel.exe') const updateDest = path.join(this.stagingAppDir, 'Update.exe') - return fs.copy(updateSrc, updateDest) - .catch(common.wrapError('copying Squirrel updater')) + return common.wrapError('copying Squirrel updater', async () => fs.copy(updateSrc, updateDest)) } /** @@ -81,8 +80,7 @@ class SquirrelInstaller extends common.ElectronInstaller { '-NoDefaultExcludes' ] - return spawn(cmd, args, this.options.logger) - .catch(common.wrapError('creating package with NuGet')) + return common.wrapError('creating package with NuGet', async () => spawn(cmd, args, this.options.logger)) } /** @@ -94,8 +92,7 @@ class SquirrelInstaller extends common.ElectronInstaller { const src = path.resolve(__dirname, '../resources/spec.ejs') this.options.logger(`Creating spec file at ${this.specPath}`) - return this.createTemplatedFile(src, this.specPath) - .catch(common.wrapError('creating spec file')) + return common.wrapError('creating spec file', async () => this.createTemplatedFile(src, this.specPath)) } /** @@ -105,48 +102,43 @@ class SquirrelInstaller extends common.ElectronInstaller { const packagePattern = path.join(this.stagingDir, 'nuget', '*.nupkg') this.options.logger(`Finding package with pattern ${packagePattern}`) - return glob(packagePattern) - .then(files => files[0]) - .catch(common.wrapError('finding package with pattern')) + return common.wrapError('finding package with pattern', async () => (await glob(packagePattern))[0]) } /** * Get the hash of default options for the installer. Some come from the info * read from `package.json`, and some are hardcoded. */ - generateDefaults () { - return common.readMetadata(this.userSupplied) - .then(pkg => { - pkg = pkg || {} + async generateDefaults () { + const pkg = (await common.readMetadata(this.userSupplied)) || {} - const authors = pkg.author ? [typeof pkg.author === 'string' ? parseAuthor(pkg.author).name : pkg.author.name] : undefined + const authors = pkg.author ? [typeof pkg.author === 'string' ? parseAuthor(pkg.author).name : pkg.author.name] : undefined - this.defaults = Object.assign(common.getDefaultsFromPackageJSON(pkg), { - version: pkg.version || '0.0.0', + this.defaults = Object.assign(common.getDefaultsFromPackageJSON(pkg), { + version: pkg.version || '0.0.0', - copyright: pkg.copyright || (authors && `Copyright \u00A9 ${new Date().getFullYear()} ${authors.join(', ')}`), - authors: authors, - owners: authors, + copyright: pkg.copyright || (authors && `Copyright \u00A9 ${new Date().getFullYear()} ${authors.join(', ')}`), + authors: authors, + owners: authors, - exe: pkg.name ? `${pkg.name}.exe` : 'electron.exe', - icon: path.resolve(__dirname, '../resources/icon.ico'), - animation: path.resolve(__dirname, '../resources/animation.gif'), + exe: pkg.name ? `${pkg.name}.exe` : 'electron.exe', + icon: path.resolve(__dirname, '../resources/icon.ico'), + animation: path.resolve(__dirname, '../resources/animation.gif'), - iconUrl: undefined, + iconUrl: undefined, - tags: [], + tags: [], - certificateFile: undefined, - certificatePassword: undefined, - signWithParams: undefined, + certificateFile: undefined, + certificatePassword: undefined, + signWithParams: undefined, - remoteReleases: undefined, + remoteReleases: undefined, - noMsi: false - }) + noMsi: false + }) - return this.defaults - }) + return this.defaults } /** @@ -164,12 +156,14 @@ class SquirrelInstaller extends common.ElectronInstaller { if (!this.options.authors) { throw new Error(`No Authors provided. Please set an author in the app's package.json or provide it in the this.options.`) } + + return this.options } /** * Releasify everything using `squirrel`. */ - releasifyPackage () { + async releasifyPackage () { this.options.logger(`Releasifying package at ${this.stagingDir}`) const cmd = path.join(this.vendorDir, 'squirrel', process.platform === 'win32' ? 'Squirrel.com' : 'Squirrel-Mono.exe') @@ -200,17 +194,17 @@ class SquirrelInstaller extends common.ElectronInstaller { args.push('--no-msi') } - return this.findPackage() - .then(pkg => { - args.unshift('--releasify', pkg) - return spawn(cmd, args, this.options.logger) - }).catch(common.wrapError('releasifying package')) + return common.wrapError('releasifying package', async () => { + const pkg = await this.findPackage() + args.unshift('--releasify', pkg) + return spawn(cmd, args, this.options.logger) + }) } /** * Sync remote releases. */ - syncRemoteReleases () { + async syncRemoteReleases () { if (!this.options.remoteReleases) { return } @@ -225,36 +219,32 @@ class SquirrelInstaller extends common.ElectronInstaller { this.squirrelDir ] - return fs.ensureDir(this.squirrelDir, '0755') - .then(() => spawn(cmd, args, this.options.logger)) - .catch(common.wrapError('syncing remote releases')) + return common.wrapError('syncing remote releases', async () => { + await fs.ensureDir(this.squirrelDir, '0755') + return spawn(cmd, args, this.options.logger) + }) } } /* ************************************************************************** */ -module.exports = data => { +module.exports = async data => { data.rename = data.rename || defaultRename data.logger = data.logger || defaultLogger const installer = new SquirrelInstaller(data) - return installer.generateDefaults() - .then(() => installer.generateOptions()) - .then(() => data.logger(`Creating package with options\n${JSON.stringify(installer.options, null, 2)}`)) - .then(() => installer.createStagingDir()) - .then(() => installer.createContents()) - .then(() => installer.createPackage()) - .then(() => installer.syncRemoteReleases()) - .then(() => installer.releasifyPackage()) - .then(() => installer.movePackage()) - .then(() => { - data.logger(`Successfully created package at ${installer.options.dest}`) - return installer.options - }).catch(err => { - data.logger(common.errorMessage('creating package', err)) - throw err - }) + await installer.generateDefaults() + await installer.generateOptions() + data.logger(`Creating package with options\n${JSON.stringify(installer.options, null, 2)}`) + await installer.createStagingDir() + await installer.createContents() + await installer.createPackage() + await installer.syncRemoteReleases() + await installer.releasifyPackage() + await installer.movePackage() + data.logger(`Successfully created package at ${installer.options.dest}`) + return installer.options } module.exports.Installer = SquirrelInstaller diff --git a/src/spawn.js b/src/spawn.js index d320473..5c7dc1f 100644 --- a/src/spawn.js +++ b/src/spawn.js @@ -23,7 +23,7 @@ function updateExecutableMissingException (err, updateError) { } } -module.exports = function (cmd, args, logger) { +module.exports = async function (cmd, args, logger) { if (process.platform !== 'win32') { args.unshift(cmd) cmd = 'mono' diff --git a/test/cli.js b/test/cli.js index ca34b58..c54f14f 100644 --- a/test/cli.js +++ b/test/cli.js @@ -26,9 +26,9 @@ describe('cli', function () { describe('with a releases server', function (test) { const server = new Server('test/fixtures/releases/', 3000) - before(() => server.runServer()) + before(async () => server.runServer()) - after(() => server.closeServer()) + after(async () => server.closeServer()) describeCLI('with an app with asar with the same remote release', true, { remoteReleases: 'http://localhost:3000/foo/' diff --git a/test/helpers/access_helper.js b/test/helpers/access_helper.js index cf71a6f..64d1424 100644 --- a/test/helpers/access_helper.js +++ b/test/helpers/access_helper.js @@ -5,24 +5,34 @@ const path = require('path') const retry = require('promise-retry') // `fs.access` which retries three times. -module.exports.testAccess = (path) => retry((retry, number) => { - return fs.access(path) - .then(() => 'done accessing') - .catch(retry) -}, { retries: 3, minTimeout: 500 }) +async function testAccess (path) { + return retry((retry, number) => { + return fs.access(path) + .catch(retry) + }, { + retries: 3, + minTimeout: 500 + }) +} -module.exports.access = (desc, dir, filename) => { - it(desc, () => module.exports.testAccess(path.join(dir, filename))) +function access (desc, dir, filename) { + it(desc, async () => testAccess(path.join(dir, filename))) } -module.exports.accessAll = (appName, dir, cli) => { +function accessAll (appName, dir, cli) { let test cli ? test = 'setup' : test = 'installer' - module.exports.access('generates a `RELEASES` manifest', dir, 'RELEASES') - module.exports.access('generates a `.nupkg` package', dir, `${appName}-0.0.1-full.nupkg`) - module.exports.access('generates a `.exe` package', dir, `${appName}-0.0.1-${test}.exe`) + access('generates a `RELEASES` manifest', dir, 'RELEASES') + access('generates a `.nupkg` package', dir, `${appName}-0.0.1-full.nupkg`) + access('generates a `.exe` package', dir, `${appName}-0.0.1-${test}.exe`) if (process.platform === 'win32') { - module.exports.access('generates a `.msi` package', dir, `${appName}-0.0.1-${test}.msi`) + access('generates a `.msi` package', dir, `${appName}-0.0.1-${test}.msi`) } } + +module.exports = { + testAccess, + access, + accessAll +} diff --git a/test/helpers/describe_cli.js b/test/helpers/describe_cli.js index 7e46689..528ce98 100644 --- a/test/helpers/describe_cli.js +++ b/test/helpers/describe_cli.js @@ -38,22 +38,23 @@ module.exports = function (desc, asar, options) { if (options.remoteReleases) args.push('--remoteReleases', options.remoteReleases) describe(desc, test => { - before((done) => { - spawn('./src/cli.js', args, null, null) - .then(logs => printLogs(logs)) - .then(() => done()) + before(async () => { + const logs = await spawn('./src/cli.js', args, null, null) + printLogs(logs) }) - after(() => fs.remove(options.dest)) + after(async () => fs.remove(options.dest)) accessAll(appName, options.dest, true) if (options.remoteReleases && asar) { - it('does not generate a delta `.nupkg` package', () => { - return testAccess(`${options.dest}/${appName}-0.0.1-delta.nupkg'`) - .then(() => { - throw new Error('delta `.nupkg` was created') - }).catch(error => chai.expect(error.message).to.have.string('no such file or directory')) + it('does not generate a delta `.nupkg` package', async () => { + try { + await testAccess(`${options.dest}/${appName}-0.0.1-delta.nupkg'`) + throw new Error('delta `.nupkg` was created') + } catch (error) { + chai.expect(error.message).to.have.string('no such file or directory') + } }) } diff --git a/test/helpers/describe_installer.js b/test/helpers/describe_installer.js index ff599c6..163a1e1 100644 --- a/test/helpers/describe_installer.js +++ b/test/helpers/describe_installer.js @@ -12,18 +12,20 @@ module.exports = function describeInstaller (desc, asar, testOptions) { const [appName, options] = installerOptions(asar, testOptions) describe(desc, test => { - before(() => installer(options)) + before(async () => installer(options)) - after(() => fs.remove(options.dest)) + after(async () => fs.remove(options.dest)) accessAll(appName, options.dest, false) if (testOptions.remoteReleases && asar) { - it('does not generate a delta `.nupkg` package', () => { - return testAccess(`${options.dest}/${appName}-0.0.1-delta.nupkg`) - .then(() => { - throw new Error('delta `.nupkg` was created') - }).catch(error => chai.expect(error.message).to.have.string('no such file or directory')) + it('does not generate a delta `.nupkg` package', async () => { + try { + await testAccess(`${options.dest}/${appName}-0.0.1-delta.nupkg`) + throw new Error('delta `.nupkg` was created') + } catch (error) { + chai.expect(error.message).to.have.string('no such file or directory') + } }) } @@ -38,12 +40,15 @@ module.exports.describeInstallerWithException = function describeInstallerWithEx options.src = testOptions.src describe(desc, test => { - it('throws an error', () => { - return installer(options) - .catch(error => chai.expect(error.message).to.match(errorRegex)) + it('throws an error', async () => { + try { + await installer(options) + } catch (error) { + chai.expect(error.message).to.match(errorRegex) + } }) - after(() => fs.remove(options.dest)) + after(async () => fs.remove(options.dest)) }) } diff --git a/test/installer.js b/test/installer.js index b468578..d184c94 100644 --- a/test/installer.js +++ b/test/installer.js @@ -57,9 +57,9 @@ describe('module', function () { describe('with a releases server', function (test) { const server = new Server('test/fixtures/releases/', 3000) - before(() => server.runServer()) + before(async () => server.runServer()) - after(() => server.closeServer()) + after(async () => server.closeServer()) describeInstaller('with an app with asar with the same remote release', true, { productDescription: 'Just a test.', From ec8ed10de7498930dde591aac23b37ae61d62177 Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Fri, 24 May 2019 15:27:48 -0700 Subject: [PATCH 09/15] Better syntax highlighting on README --- README.md | 26 +++++++++++++------------- example/README.md | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 34e4abd..ba920bf 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,13 @@ You won't get an `.msi` installer though, only `.nupkg` and `.exe` installers. T For use from command-line: -``` +```shell $ npm install -g electron-installer-windows ``` For use in npm scripts or programmatically: -``` +```shell $ npm install --save-dev electron-installer-windows ``` @@ -58,7 +58,7 @@ Say your Electron app lives in `path/to/app` and has a structure like this: You now run `electron-packager` to build the app for Windows: -``` +```shell $ electron-packager . app --platform win32 --arch x64 --out dist/ ``` @@ -97,13 +97,13 @@ How do you turn that into a Windows package that your users can install? If you want to run `electron-installer-windows` straight from the command-line, install the package globally: -``` +```shell $ npm install -g electron-installer-windows ``` And point it to your built app: -``` +```shell $ electron-installer-windows --src dist/app-win32-x64/ --dest dist/installers/ ``` @@ -113,13 +113,13 @@ You'll end up with the package at `dist/installers/app-0.0.1-setup.exe`. If you want to run `electron-installer-windows` through npm, install the package locally: -``` +```shell $ npm install --save-dev electron-installer-windows ``` Edit the `scripts` section of your `package.json`: -```javascript +```json { "name": "app", "description": "An awesome app!", @@ -139,7 +139,7 @@ Edit the `scripts` section of your `package.json`: And run the script: -``` +```shell $ npm run setup ``` @@ -149,7 +149,7 @@ You'll end up with the package at `dist/installers/app-0.0.1-setup.exe`. Install the package locally: -``` +```shell $ npm install --save-dev electron-installer-windows ``` @@ -183,7 +183,7 @@ _Note: As of 2.0.0, the Node-style callback pattern is no longer available. You Even though you can pass most of these options through the command-line interface, it may be easier to create a configuration file: -```javascript +```json { "dest": "dist/installers/", "icon": "resources/Icon.ico", @@ -195,7 +195,7 @@ Even though you can pass most of these options through the command-line interfac And pass that instead with the `config` option: -``` +```shell $ electron-installer-windows --src dist/app-win32-x64/ --config config.json ``` @@ -344,14 +344,14 @@ Internet Explorer's SmartScreen Filter and antivirus programs may flag your pack To generate the certificate, open the *Developer Command Prompt for Visual Studio* and execute the following: -``` +```shell $ makecert -sv my_private_key.pvk -n "CN=MyTestCertificate" my_test_certificate.cer -b 01/01/2016 -e 01/01/2026 -r $ pvk2pfx -pvk my_private_key.pvk -spc my_test_certificate.cer -pfx my_signing_key.pfx -po my_password ``` Now we can tell `electron-installer-windows` to sign the packages that it generates with that certificate: -``` +```shell $ electron-installer-windows --src dist/app-win32-x64/ --dest dist/installers/ --certificateFile my_signing_key.pfx --certificatePassword my_password ``` diff --git a/example/README.md b/example/README.md index 79940ae..fc10acd 100644 --- a/example/README.md +++ b/example/README.md @@ -2,7 +2,7 @@ From this directory, run the following commands to build the Windows packages for the app: -``` +```shell $ npm install $ npm run build ``` From 47b743812c882dd80f8b78bf8a9e7976647c33a3 Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Sun, 26 May 2019 13:16:57 -0700 Subject: [PATCH 10/15] Use latest release of electron-installer-common --- .eslintrc.json | 5 ++++- package.json | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index e3578aa..024f6d9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,3 +1,6 @@ { - "extends": "standard" + "extends": [ + "standard", + "plugin:promise/recommended" + ] } diff --git a/package.json b/package.json index 6d6a7b0..1c7361d 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "dependencies": { "debug": "^4.1.0", - "electron-installer-common": "electron-userland/electron-installer-common", + "electron-installer-common": "^0.7.0", "fs-extra": "^8.0.1", "glob": "^7.1.4", "lodash": "^4.17.11", @@ -42,7 +42,7 @@ "chai": "^4.2.0", "eslint": "^5.16.0", "eslint-config-standard": "^12.0.0", - "eslint-plugin-import": "^2.17.2", + "eslint-plugin-import": "^2.17.3", "eslint-plugin-node": "^9.0.1", "eslint-plugin-promise": "^4.1.1", "eslint-plugin-standard": "^4.0.0", From 6030fb931c6b4a0a421e81b81ddee4df03ff0276 Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Sun, 26 May 2019 13:22:56 -0700 Subject: [PATCH 11/15] Better await code example --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ba920bf..d7c5d02 100644 --- a/README.md +++ b/README.md @@ -163,15 +163,17 @@ const options = { dest: 'dist/installers/' } -console.log('Creating package (this may take a while)') - -try { - await installer(options) - console.log(`Successfully created package at ${options.dest}`) -} catch(err) { +async function main (options) { + console.log('Creating package (this may take a while)') + try { + await installer(options) + console.log(`Successfully created package at ${options.dest}`) + } catch (err) { console.error(err, err.stack) process.exit(1) + } } +main(options) ``` You'll end up with the package at `dist/installers/app-0.0.1-setup.exe`. From 251fa499d178c0d8c3e487b10f798776f405bf71 Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Thu, 30 May 2019 22:25:46 -0700 Subject: [PATCH 12/15] Update dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1c7361d..42f8cf8 100644 --- a/package.json +++ b/package.json @@ -29,27 +29,27 @@ "node": ">=8.0.0" }, "dependencies": { - "debug": "^4.1.0", + "debug": "^4.1.1", "electron-installer-common": "^0.7.0", "fs-extra": "^8.0.1", "glob": "^7.1.4", "lodash": "^4.17.11", "parse-author": "^2.0.0", "which": "^1.3.1", - "yargs": "^13.2.2" + "yargs": "^13.2.4" }, "devDependencies": { "chai": "^4.2.0", "eslint": "^5.16.0", "eslint-config-standard": "^12.0.0", "eslint-plugin-import": "^2.17.3", - "eslint-plugin-node": "^9.0.1", + "eslint-plugin-node": "^9.1.0", "eslint-plugin-promise": "^4.1.1", "eslint-plugin-standard": "^4.0.0", "finalhandler": "^1.1.2", "mocha": "^6.1.4", "promise-retry": "^1.1.1", "serve-static": "^1.14.1", - "tmp-promise": "^2.0.0" + "tmp-promise": "^2.0.1" } } From f38603de805f287378712a508a249d05d6f35c11 Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Thu, 30 May 2019 22:26:16 -0700 Subject: [PATCH 13/15] Make code more readable --- src/installer.js | 5 ++++- test/helpers/describe_cli.js | 9 ++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/installer.js b/src/installer.js index c2e3508..6eb2da4 100644 --- a/src/installer.js +++ b/src/installer.js @@ -102,7 +102,10 @@ class SquirrelInstaller extends common.ElectronInstaller { const packagePattern = path.join(this.stagingDir, 'nuget', '*.nupkg') this.options.logger(`Finding package with pattern ${packagePattern}`) - return common.wrapError('finding package with pattern', async () => (await glob(packagePattern))[0]) + return common.wrapError('finding package with pattern', async () => { + const files = await glob(packagePattern) + return files[0] + }) } /** diff --git a/test/helpers/describe_cli.js b/test/helpers/describe_cli.js index 528ce98..81e4bfe 100644 --- a/test/helpers/describe_cli.js +++ b/test/helpers/describe_cli.js @@ -4,7 +4,7 @@ const chai = require('chai') const fs = require('fs-extra') const { spawn } = require('electron-installer-common') const tmp = require('tmp-promise') -const { access, testAccess, accessAll } = require('./access_helper') +const { access, accessAll } = require('./access_helper') function printLogs (logs) { if (process.env.DEBUG === 'electron-installer-windows') { @@ -49,12 +49,7 @@ module.exports = function (desc, asar, options) { if (options.remoteReleases && asar) { it('does not generate a delta `.nupkg` package', async () => { - try { - await testAccess(`${options.dest}/${appName}-0.0.1-delta.nupkg'`) - throw new Error('delta `.nupkg` was created') - } catch (error) { - chai.expect(error.message).to.have.string('no such file or directory') - } + return chai.expect(await fs.pathExists(`${options.dest}/${appName}-0.0.1-delta.nupkg'`)).to.be.false }) } From db691a7e001443c6415622fae788e0d105baa8ed Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Thu, 30 May 2019 23:42:39 -0700 Subject: [PATCH 14/15] Add node 12 to tests --- .travis.yml | 1 + appveyor.yml | 18 ++++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1ee7ab9..d6a55b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ addons: - wine env: + - DEBUG="electron-installer-windows" NODE_VERSION="12" - DEBUG="electron-installer-windows" NODE_VERSION="10" - DEBUG="electron-installer-windows" NODE_VERSION="8" diff --git a/appveyor.yml b/appveyor.yml index a9fdc21..dc71845 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,23 +5,21 @@ init: environment: DEBUG: 'electron-installer-windows' - matrix: - - platform: x86 - nodejs_version: '10' - - platform: x64 - nodejs_version: '10' - - platform: x86 - nodejs_version: '8' - - platform: x64 - nodejs_version: '8' + - nodejs_version: "12" + - nodejs_version: "10" + - nodejs_version: "8" + +platform: + - x86 + - x64 branches: only: - master install: - - ps: Install-Product node $env:nodejs_version + - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:PLATFORM - npm install build: off From 8fde3a62dbb77ef8702363268ae2be3af6a94365 Mon Sep 17 00:00:00 2001 From: Felipe Castillo Date: Sat, 1 Jun 2019 11:55:26 -0700 Subject: [PATCH 15/15] Test only against the oldest and newest node LTS versions --- .travis.yml | 1 - appveyor.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d6a55b6..a622061 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ addons: env: - DEBUG="electron-installer-windows" NODE_VERSION="12" - - DEBUG="electron-installer-windows" NODE_VERSION="10" - DEBUG="electron-installer-windows" NODE_VERSION="8" branches: diff --git a/appveyor.yml b/appveyor.yml index dc71845..078bb16 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,6 @@ environment: DEBUG: 'electron-installer-windows' matrix: - nodejs_version: "12" - - nodejs_version: "10" - nodejs_version: "8" platform: