Skip to content

Commit

Permalink
chore: upgrade to Node 6 (#293)
Browse files Browse the repository at this point in the history
* Update fs-extra to 7.0.0 and remove obsolete fs wrappers
* Update ava and babel
* Replace bluebird with pify
* Require the correct Node version in package.json
  • Loading branch information
Brad Carter authored and MarshallOfSound committed Feb 28, 2019
1 parent 6210bab commit 5403c71
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 90 deletions.
22 changes: 8 additions & 14 deletions .travis.yml
@@ -1,24 +1,18 @@
language: node_js
node_js: "6"
cache: npm

node_js:
- "4.1"
dist: xenial
addons:
apt:
packages:
- wine
- mono-devel

branches:
only:
- master

cache:
directories:
- node_modules

before_install:
- sudo add-apt-repository ppa:ubuntu-wine/ppa -y
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
- echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
- echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
- sudo apt-get -qq update
- sudo apt-get -qq install wine mono-devel -y

notifications:
email:
on_success: never
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -9,7 +9,7 @@ init:

environment:
matrix:
- nodejs_version: 4.3.2
- nodejs_version: 6

install:
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
Expand Down
37 changes: 15 additions & 22 deletions package.json
Expand Up @@ -17,39 +17,32 @@
},
"dependencies": {
"asar": "^1.0.0",
"bluebird": "^3.3.4",
"debug": "^2.2.0",
"fs-extra": "^2.1.2",
"fs-extra": "^7.0.1",
"lodash.template": "^4.2.2",
"pify": "^4.0.1",
"temp": "^0.8.3"
},
"devDependencies": {
"ava": "^0.13.0",
"babel-cli": "^6.6.5",
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.3",
"@babel/plugin-transform-async-to-generator": "^7.2.0",
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.3.1",
"@babel/register": "^7.0.0",
"ava": "^1.2.1",
"babel-eslint": "^6.0.2",
"babel-plugin-transform-async-to-module-method": "^6.7.0",
"babel-plugin-transform-runtime": "^6.6.0",
"babel-preset-es2015-node4": "^2.0.3",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.7.2",
"eslint": "^2.4.0"
},
"engines": {
"node": ">=0.4.0"
"node": ">=6.0.0"
},
"babel": {
"presets": [
"stage-0",
"es2015-node4"
"@babel/preset-env"
],
"plugins": [
[
"transform-async-to-module-method",
{
"module": "bluebird",
"method": "coroutine"
}
]
"@babel/plugin-transform-async-to-generator"
]
},
"ava": {
Expand All @@ -58,8 +51,8 @@
],
"failFast": true,
"require": [
"babel-register"
],
"babel": "inherit"
"@babel/register",
"@babel/polyfill"
]
}
}
2 changes: 1 addition & 1 deletion spec/convert-version-spec.js
@@ -1,5 +1,5 @@
import test from 'ava';
import {convertVersion} from '../src/index';
import { convertVersion } from '../src/index';

test('makes semver versions into valid NuGet versions', t => {
t.is(convertVersion('1'), '1');
Expand Down
17 changes: 9 additions & 8 deletions spec/installer-spec.js
@@ -1,6 +1,7 @@
import test from 'ava';
import path from 'path';
import { createTempDir, fileExists, unlink, readDir } from '../src/fs-utils';
import { createTempDir } from '../src/temp-utils';
import fs from 'fs-extra';
import { createWindowsInstaller } from '../src/index.js';

const log = require('debug')('electron-windows-installer:spec');
Expand All @@ -10,8 +11,8 @@ const appDirectory = path.join(__dirname, 'fixtures/app');
test.beforeEach(async () => {
const updateExePath = path.join(appDirectory, 'Update.exe');

if (await fileExists(updateExePath)) {
await unlink(updateExePath);
if (await fs.pathExists(updateExePath)) {
await fs.unlink(updateExePath);
}
});

Expand All @@ -26,15 +27,15 @@ test('creates a nuget package and installer', async t => {
await createWindowsInstaller(options);

log(`Verifying assertions on ${outputDirectory}`);
log(JSON.stringify(await readDir(outputDirectory)));
log(JSON.stringify(await fs.readdir(outputDirectory)));

t.true(await fileExists(path.join(outputDirectory, 'myapp-1.0.0-full.nupkg')));
t.true(await fileExists(path.join(outputDirectory, 'MyAppSetup.exe')));
t.true(await fs.pathExists(path.join(outputDirectory, 'myapp-1.0.0-full.nupkg')));
t.true(await fs.pathExists(path.join(outputDirectory, 'MyAppSetup.exe')));

if (process.platform === 'win32') {
t.true(await fileExists(path.join(outputDirectory, 'MyAppSetup.msi')));
t.true(await fs.pathExists(path.join(outputDirectory, 'MyAppSetup.msi')));
}

log('Verifying Update.exe');
t.true(await fileExists(path.join(appDirectory, 'Update.exe')));
t.true(await fs.pathExists(path.join(appDirectory, 'Update.exe')));
});
30 changes: 0 additions & 30 deletions src/fs-utils.js

This file was deleted.

26 changes: 13 additions & 13 deletions src/index.js
Expand Up @@ -2,8 +2,8 @@ import template from 'lodash.template';
import spawn from './spawn-promise';
import asar from 'asar';
import path from 'path';
import * as fsUtils from './fs-utils';

import { createTempDir } from './temp-utils';
import fs from 'fs-extra';
const log = require('debug')('electron-windows-installer:main');

export function convertVersion(version) {
Expand Down Expand Up @@ -40,7 +40,7 @@ export async function createWindowsInstaller(options) {
const vendorUpdate = path.join(vendorPath, 'Update.exe');
const appUpdate = path.join(appDirectory, 'Update.exe');

await fsUtils.copy(vendorUpdate, appUpdate);
await fs.copy(vendorUpdate, appUpdate);
if (options.setupIcon && (options.skipUpdateIcon !== true)) {
let cmd = path.join(vendorPath, 'rcedit.exe');
let args = [
Expand All @@ -59,7 +59,7 @@ export async function createWindowsInstaller(options) {
const defaultLoadingGif = path.join(__dirname, '..', 'resources', 'install-spinner.gif');
loadingGif = loadingGif ? path.resolve(loadingGif) : defaultLoadingGif;

let {certificateFile, certificatePassword, remoteReleases, signWithParams, remoteToken} = options;
let { certificateFile, certificatePassword, remoteReleases, signWithParams, remoteToken } = options;

const metadata = {
description: '',
Expand All @@ -71,10 +71,10 @@ export async function createWindowsInstaller(options) {
const asarFile = path.join(appResources, 'app.asar');
let appMetadata;

if (await fsUtils.fileExists(asarFile)) {
if (await fs.pathExists(asarFile)) {
appMetadata = JSON.parse(asar.extractFile(asarFile, 'package.json'));
} else {
appMetadata = JSON.parse(await fsUtils.readFile(path.join(appResources, 'app', 'package.json'), 'utf8'));
appMetadata = await fs.readJSON(path.join(appResources, 'app', 'package.json'), 'utf8');
}

Object.assign(metadata, {
Expand All @@ -86,7 +86,7 @@ export async function createWindowsInstaller(options) {
Object.assign(metadata, options);

if (!metadata.authors) {
if (typeof(metadata.author) === 'string') {
if (typeof (metadata.author) === 'string') {
metadata.authors = metadata.author;
} else {
metadata.authors = (metadata.author || {}).name || '';
Expand All @@ -98,18 +98,18 @@ export async function createWindowsInstaller(options) {
metadata.copyright = metadata.copyright ||
`Copyright © ${new Date().getFullYear()} ${metadata.authors || metadata.owners}`;

let templateData = await fsUtils.readFile(path.join(__dirname, '..', 'template.nuspectemplate'), 'utf8');
let templateData = await fs.readFile(path.join(__dirname, '..', 'template.nuspectemplate'), 'utf8');
if (path.sep === '/') {
templateData = templateData.replace(/\\/g, '/');
}
const nuspecContent = template(templateData)(metadata);

log(`Created NuSpec file:\n${nuspecContent}`);

const nugetOutput = await fsUtils.createTempDir('si-');
const nugetOutput = await createTempDir('si-');
const targetNuspecPath = path.join(nugetOutput, metadata.name + '.nuspec');

await fsUtils.writeFile(targetNuspecPath, nuspecContent);
await fs.writeFile(targetNuspecPath, nuspecContent);

let cmd = path.join(vendorPath, 'nuget.exe');
let args = [
Expand Down Expand Up @@ -186,15 +186,15 @@ export async function createWindowsInstaller(options) {
const setupPath = path.join(outputDirectory, options.setupExe || `${metadata.productName}Setup.exe`);
const unfixedSetupPath = path.join(outputDirectory, 'Setup.exe');
log(`Renaming ${unfixedSetupPath} => ${setupPath}`);
await fsUtils.rename(unfixedSetupPath, setupPath);
await fs.rename(unfixedSetupPath, setupPath);
}

if (metadata.productName || options.setupMsi) {
const msiPath = path.join(outputDirectory, options.setupMsi || `${metadata.productName}Setup.msi`);
const unfixedMsiPath = path.join(outputDirectory, 'Setup.msi');
if (await fsUtils.fileExists(unfixedMsiPath)) {
if (await fs.pathExists(unfixedMsiPath)) {
log(`Renaming ${unfixedMsiPath} => ${msiPath}`);
await fsUtils.rename(unfixedMsiPath, msiPath);
await fs.rename(unfixedMsiPath, msiPath);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/spawn-promise.js
@@ -1,5 +1,4 @@
import { spawn as spawnOg } from 'child_process';
import { Promise } from 'bluebird';

const d = require('debug')('electron-windows-installer:spawn');

Expand Down
9 changes: 9 additions & 0 deletions src/temp-utils.js
@@ -0,0 +1,9 @@
import pify from 'pify';
import temp from 'temp';
temp.track();

const createTempDir = pify(temp.mkdir);

export {
createTempDir
};

0 comments on commit 5403c71

Please sign in to comment.