mirror of https://github.com/jiahaog/Nativefier
Upgrade dependencies and default to latest Electron 1.7.9 (PR #483)
* Update deps except eslint * Update eslint and lint:fix (WIP, needs manual fixing for remaining 44 problems) * Manually fix remaining eslint errors * Document deprecation of `version-string` as of electron-packager 9.0.0 * Upgrade to Electron 1.7.9 (chrome-58, node-7.9.0, v8-5.8) * npm: Disable generation of package-lock.json and gitignore it --Trying this, package-lock is a pain in PRs. May not be a good idea (obviously we lose deps pinning), will revert if necessary.-- * npm tasks: add dev-up-win for Windows developers, and e2e for end-to-end tests. Update docs. * Move normalizeUrl test to a jest unit test, makes no sense to be in the mocha e2e tests * Switch from babel-preset-es2015 to babel-preset-env, with target.node=4.0. Seem like it's today's most convenient way to support the latest ES and let babel transpile to what makes sense for our currently minimal node version
This commit is contained in:
parent
78bedc62ac
commit
6fb3b92eb8
|
@ -7,5 +7,7 @@ plugins:
|
||||||
rules:
|
rules:
|
||||||
# TODO: Remove this when we have shifted away from the async package
|
# TODO: Remove this when we have shifted away from the async package
|
||||||
no-shadow: 'warn'
|
no-shadow: 'warn'
|
||||||
|
# Remove no-console when we have moved to a proper logging lib with logging levels
|
||||||
|
no-console: 'off'
|
||||||
# Gulpfiles and tests use dev dependencies
|
# Gulpfiles and tests use dev dependencies
|
||||||
import/no-extraneous-dependencies: ['error', { devDependencies: ['gulpfile.babel.js', 'gulp/**/**.js', 'test/**/**.js']}]
|
import/no-extraneous-dependencies: ['error', { devDependencies: ['gulpfile.babel.js', 'gulp/**/**.js', 'test/**/**.js']}]
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# Node.js
|
# Node.js
|
||||||
|
package-lock.json
|
||||||
|
|
||||||
# ignore compiled lib files
|
# ignore compiled lib files
|
||||||
lib/*
|
lib/*
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
package-lock=false
|
|
@ -1,113 +0,0 @@
|
||||||
{
|
|
||||||
"name": "nativefier-placeholder",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"lockfileVersion": 1,
|
|
||||||
"requires": true,
|
|
||||||
"dependencies": {
|
|
||||||
"electron-dl": {
|
|
||||||
"version": "1.8.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/electron-dl/-/electron-dl-1.8.0.tgz",
|
|
||||||
"integrity": "sha1-VmUtpVqv2kpwB09jE/33+UHsdSo=",
|
|
||||||
"requires": {
|
|
||||||
"pupa": "1.0.0",
|
|
||||||
"unused-filename": "0.1.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"pupa": {
|
|
||||||
"version": "1.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/pupa/-/pupa-1.0.0.tgz",
|
|
||||||
"integrity": "sha1-mpVopa9+ZXuEYqbp1TKHQ1YM7/Y="
|
|
||||||
},
|
|
||||||
"unused-filename": {
|
|
||||||
"version": "0.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/unused-filename/-/unused-filename-0.1.0.tgz",
|
|
||||||
"integrity": "sha1-5fM7yeSmP4f2TTwR0xl53vXS5/s=",
|
|
||||||
"requires": {
|
|
||||||
"modify-filename": "1.1.0",
|
|
||||||
"path-exists": "3.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"modify-filename": {
|
|
||||||
"version": "1.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/modify-filename/-/modify-filename-1.1.0.tgz",
|
|
||||||
"integrity": "sha1-mi3sg4Bvuy2XXyK+7IWcoms5OqE="
|
|
||||||
},
|
|
||||||
"path-exists": {
|
|
||||||
"version": "3.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz",
|
|
||||||
"integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"electron-window-state": {
|
|
||||||
"version": "4.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/electron-window-state/-/electron-window-state-4.1.1.tgz",
|
|
||||||
"integrity": "sha1-azT9wxs4UU3+yLfI97XUrdtnYy0=",
|
|
||||||
"requires": {
|
|
||||||
"deep-equal": "1.0.1",
|
|
||||||
"jsonfile": "2.4.0",
|
|
||||||
"mkdirp": "0.5.1"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"deep-equal": {
|
|
||||||
"version": "1.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz",
|
|
||||||
"integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU="
|
|
||||||
},
|
|
||||||
"jsonfile": {
|
|
||||||
"version": "2.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz",
|
|
||||||
"integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=",
|
|
||||||
"requires": {
|
|
||||||
"graceful-fs": "4.1.11"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"graceful-fs": {
|
|
||||||
"version": "4.1.11",
|
|
||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
|
||||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"mkdirp": {
|
|
||||||
"version": "0.5.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
|
||||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
|
||||||
"requires": {
|
|
||||||
"minimist": "0.0.8"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"minimist": {
|
|
||||||
"version": "0.0.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
|
||||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"source-map-support": {
|
|
||||||
"version": "0.4.14",
|
|
||||||
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.14.tgz",
|
|
||||||
"integrity": "sha1-nURjdyWYuGJxtPUj9sH04Cp9au8=",
|
|
||||||
"requires": {
|
|
||||||
"source-map": "0.5.6"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"source-map": {
|
|
||||||
"version": "0.5.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz",
|
|
||||||
"integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"wurl": {
|
|
||||||
"version": "2.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/wurl/-/wurl-2.1.0.tgz",
|
|
||||||
"integrity": "sha1-ciS9DmYuUTUiHSWdjWAUHC0T0xA="
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,10 +4,10 @@
|
||||||
"description": "Placeholder for the nativefier cli to override with a target url",
|
"description": "Placeholder for the nativefier cli to override with a target url",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"electron-dl": "^1.1.0",
|
"electron-dl": "^1.10.0",
|
||||||
"electron-window-state": "^4.1.0",
|
"electron-window-state": "^4.1.1",
|
||||||
"source-map-support": "^0.4.0",
|
"source-map-support": "^0.5.0",
|
||||||
"wurl": "^2.1.0"
|
"wurl": "^2.5.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -6,7 +6,9 @@ import helpers from './../../helpers/helpers';
|
||||||
import createMenu from './../menu/menu';
|
import createMenu from './../menu/menu';
|
||||||
import initContextMenu from './../contextMenu/contextMenu';
|
import initContextMenu from './../contextMenu/contextMenu';
|
||||||
|
|
||||||
const { isOSX, linkIsInternal, getCssToInject, shouldInjectCss } = helpers;
|
const {
|
||||||
|
isOSX, linkIsInternal, getCssToInject, shouldInjectCss,
|
||||||
|
} = helpers;
|
||||||
|
|
||||||
const ZOOM_INTERVAL = 0.1;
|
const ZOOM_INTERVAL = 0.1;
|
||||||
|
|
||||||
|
@ -125,7 +127,7 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
|
||||||
if (response !== 0) {
|
if (response !== 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const session = mainWindow.webContents.session;
|
const { session } = mainWindow.webContents;
|
||||||
session.clearStorageData(() => {
|
session.clearStorageData(() => {
|
||||||
session.clearCache(() => {
|
session.clearCache(() => {
|
||||||
mainWindow.loadURL(options.targetUrl);
|
mainWindow.loadURL(options.targetUrl);
|
||||||
|
|
|
@ -13,23 +13,25 @@ import { Menu, shell, clipboard } from 'electron';
|
||||||
* @param clearAppData
|
* @param clearAppData
|
||||||
* @param disableDevTools
|
* @param disableDevTools
|
||||||
*/
|
*/
|
||||||
function createMenu({ nativefierVersion,
|
function createMenu({
|
||||||
appQuit,
|
nativefierVersion,
|
||||||
zoomIn,
|
appQuit,
|
||||||
zoomOut,
|
zoomIn,
|
||||||
zoomReset,
|
zoomOut,
|
||||||
zoomBuildTimeValue,
|
zoomReset,
|
||||||
goBack,
|
zoomBuildTimeValue,
|
||||||
goForward,
|
goBack,
|
||||||
getCurrentUrl,
|
goForward,
|
||||||
clearAppData,
|
getCurrentUrl,
|
||||||
disableDevTools }) {
|
clearAppData,
|
||||||
|
disableDevTools,
|
||||||
|
}) {
|
||||||
if (Menu.getApplicationMenu()) {
|
if (Menu.getApplicationMenu()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const zoomResetLabel = (zoomBuildTimeValue === 1.0) ?
|
const zoomResetLabel = (zoomBuildTimeValue === 1.0) ?
|
||||||
'Reset Zoom' :
|
'Reset Zoom' :
|
||||||
`Reset Zoom (to ${zoomBuildTimeValue * 100}%, set at build time)`;
|
`Reset Zoom (to ${zoomBuildTimeValue * 100}%, set at build time)`;
|
||||||
|
|
||||||
const template = [
|
const template = [
|
||||||
{
|
{
|
||||||
|
@ -221,8 +223,8 @@ function createMenu({ nativefierVersion,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (disableDevTools) {
|
if (disableDevTools) {
|
||||||
// remove last item (dev tools) from menu > view
|
// remove last item (dev tools) from menu > view
|
||||||
const submenu = template[1].submenu;
|
const { submenu } = template[1];
|
||||||
submenu.splice(submenu.length - 1, 1);
|
submenu.splice(submenu.length - 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +274,7 @@ function createMenu({ nativefierVersion,
|
||||||
label: 'Bring All to Front',
|
label: 'Bring All to Front',
|
||||||
role: 'front',
|
role: 'front',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const menu = Menu.buildFromTemplate(template);
|
const menu = Menu.buildFromTemplate(template);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
const { app, Tray, Menu, ipcMain } = require('electron');
|
const {
|
||||||
|
app, Tray, Menu, ipcMain,
|
||||||
|
} = require('electron');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -72,7 +72,7 @@ app.on('window-all-closed', () => {
|
||||||
|
|
||||||
app.on('activate', (event, hasVisibleWindows) => {
|
app.on('activate', (event, hasVisibleWindows) => {
|
||||||
if (isOSX()) {
|
if (isOSX()) {
|
||||||
// this is called when the dock is clicked
|
// this is called when the dock is clicked
|
||||||
if (!hasVisibleWindows) {
|
if (!hasVisibleWindows) {
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ app.on('ready', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('login', (event, webContents, request, authInfo, callback) => {
|
app.on('login', (event, webContents, request, authInfo, callback) => {
|
||||||
// for http authentication
|
// for http authentication
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (appArgs.basicAuthUsername !== null && appArgs.basicAuthPassword !== null) {
|
if (appArgs.basicAuthUsername !== null && appArgs.basicAuthPassword !== null) {
|
||||||
|
|
|
@ -498,7 +498,7 @@ nativefier(options, function(error, appPath) {
|
||||||
|
|
||||||
#### [version-string]
|
#### [version-string]
|
||||||
|
|
||||||
*Object* (**deprecated** and will be removed in a future major version (of `electron-packager`), please use the
|
*Object* (**deprecated** as removed in `electron-packager` 9.0.0, please use the
|
||||||
[`win32metadata`](#win32metadata) parameter instead)
|
[`win32metadata`](#win32metadata) parameter instead)
|
||||||
|
|
||||||
#### [win32metadata]
|
#### [win32metadata]
|
||||||
|
|
|
@ -2,41 +2,39 @@
|
||||||
|
|
||||||
## Environment Setup
|
## Environment Setup
|
||||||
|
|
||||||
First clone the project
|
First, clone the project
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/jiahaog/nativefier.git
|
git clone https://github.com/jiahaog/nativefier.git
|
||||||
cd nativefier
|
cd nativefier
|
||||||
```
|
```
|
||||||
|
|
||||||
Install dependencies
|
Install dependencies and build:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# OSX and Linux
|
# macOS and Linux
|
||||||
npm run dev-up
|
npm run dev-up
|
||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
npm install
|
npm run dev-up-win
|
||||||
cd app
|
|
||||||
npm install
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Don't forget to compile source files:
|
If dependencies are installed and you just want to re-build,
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
You can set up symlinks so that you can run `nativefier` for your local changes
|
You can set up a symbolic link so that running `nativefier` invokes your development version including your changes:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm link
|
npm link
|
||||||
```
|
```
|
||||||
|
|
||||||
After doing so, you can then run Nativefier with your test parameters
|
After doing so (and not forgetting to build with `npm run build`), you can run Nativefier with your test parameters:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nativefier <...>
|
nativefier <--your-awesome-new-flag>
|
||||||
```
|
```
|
||||||
|
|
||||||
Or you can automatically watch the files for changes with:
|
Or you can automatically watch the files for changes with:
|
||||||
|
@ -48,5 +46,12 @@ npm run watch
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# To run all tests (unit, end-to-end),
|
||||||
npm test
|
npm test
|
||||||
|
|
||||||
|
# To run only unit tests,
|
||||||
|
npm run jest
|
||||||
|
|
||||||
|
# To run only end-to-end tests,
|
||||||
|
npm run e2e
|
||||||
```
|
```
|
||||||
|
|
|
@ -5,5 +5,5 @@ import PATHS from './../helpers/src-paths';
|
||||||
const webpackConfig = require('./../../webpack.config.js');
|
const webpackConfig = require('./../../webpack.config.js');
|
||||||
|
|
||||||
gulp.task('build-app', ['build-static'], () => gulp.src(PATHS.APP_MAIN_JS)
|
gulp.task('build-app', ['build-static'], () => gulp.src(PATHS.APP_MAIN_JS)
|
||||||
.pipe(webpack(webpackConfig))
|
.pipe(webpack(webpackConfig))
|
||||||
.pipe(gulp.dest(PATHS.APP_DEST)));
|
.pipe(gulp.dest(PATHS.APP_DEST)));
|
||||||
|
|
|
@ -5,7 +5,7 @@ import helpers from './../helpers/gulp-helpers';
|
||||||
const { buildES6 } = helpers;
|
const { buildES6 } = helpers;
|
||||||
|
|
||||||
gulp.task('build-static-not-js', () => gulp.src([PATHS.APP_STATIC_ALL, '!**/*.js'])
|
gulp.task('build-static-not-js', () => gulp.src([PATHS.APP_STATIC_ALL, '!**/*.js'])
|
||||||
.pipe(gulp.dest(PATHS.APP_STATIC_DEST)));
|
.pipe(gulp.dest(PATHS.APP_STATIC_DEST)));
|
||||||
|
|
||||||
gulp.task('build-static-js', done => buildES6(PATHS.APP_STATIC_JS, PATHS.APP_STATIC_DEST, done));
|
gulp.task('build-static-js', done => buildES6(PATHS.APP_STATIC_JS, PATHS.APP_STATIC_DEST, done));
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@ function shellExec(cmd, silent, callback) {
|
||||||
|
|
||||||
function buildES6(src, dest, callback) {
|
function buildES6(src, dest, callback) {
|
||||||
return gulp.src(src)
|
return gulp.src(src)
|
||||||
.pipe(sourcemaps.init())
|
.pipe(sourcemaps.init())
|
||||||
.pipe(babel())
|
.pipe(babel())
|
||||||
.on('error', callback)
|
.on('error', callback)
|
||||||
.pipe(sourcemaps.write('.'))
|
.pipe(sourcemaps.write('.'))
|
||||||
.pipe(gulp.dest(dest));
|
.pipe(gulp.dest(dest));
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -2,15 +2,15 @@ import gulp from 'gulp';
|
||||||
import PATHS from './helpers/src-paths';
|
import PATHS from './helpers/src-paths';
|
||||||
|
|
||||||
gulp.task('watch', ['build'], () => {
|
gulp.task('watch', ['build'], () => {
|
||||||
const handleError = function (error) {
|
const handleError = function watch(error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
};
|
};
|
||||||
gulp.watch(PATHS.APP_ALL, ['build-app'])
|
gulp.watch(PATHS.APP_ALL, ['build-app'])
|
||||||
.on('error', handleError);
|
.on('error', handleError);
|
||||||
|
|
||||||
gulp.watch(PATHS.CLI_SRC_JS, ['build-cli'])
|
gulp.watch(PATHS.CLI_SRC_JS, ['build-cli'])
|
||||||
.on('error', handleError);
|
.on('error', handleError);
|
||||||
|
|
||||||
gulp.watch(PATHS.TEST_SRC_JS, ['build-tests'])
|
gulp.watch(PATHS.TEST_SRC_JS, ['build-tests'])
|
||||||
.on('error', handleError);
|
.on('error', handleError);
|
||||||
});
|
});
|
||||||
|
|
77
package.json
77
package.json
|
@ -12,8 +12,10 @@
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev-up": "npm install && (cd ./app && npm install) && npm run build",
|
"dev-up": "npm install && (cd ./app && npm install) && npm run build",
|
||||||
|
"dev-up-win": "npm install & cd app & npm install & cd .. & npm run build",
|
||||||
"test": "jest && gulp test",
|
"test": "jest && gulp test",
|
||||||
"jest": "jest",
|
"jest": "jest",
|
||||||
|
"e2e": "gulp test",
|
||||||
"tdd": "gulp tdd",
|
"tdd": "gulp tdd",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint:fix": "eslint . --fix",
|
"lint:fix": "eslint . --fix",
|
||||||
|
@ -39,54 +41,61 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/jiahaog/nativefier#readme",
|
"homepage": "https://github.com/jiahaog/nativefier#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^2.3.0",
|
"async": "^2.6.0",
|
||||||
"axios": "^0.16.1",
|
"axios": "^0.17.1",
|
||||||
"babel-polyfill": "^6.7.2",
|
"babel-polyfill": "^6.26.0",
|
||||||
"cheerio": "^0.22.0",
|
"cheerio": "^1.0.0-rc.2",
|
||||||
"commander": "^2.9.0",
|
"commander": "^2.11.0",
|
||||||
"electron-packager": "^8.6.0",
|
"electron-packager": "^9.1.0",
|
||||||
"gitcloud": "^0.1.0",
|
"gitcloud": "^0.1.0",
|
||||||
"hasbin": "^1.2.0",
|
"hasbin": "^1.2.3",
|
||||||
"lodash": "^4.0.0",
|
"lodash": "^4.17.4",
|
||||||
"loglevel": "^1.4.0",
|
"loglevel": "^1.5.1",
|
||||||
"ncp": "^2.0.0",
|
"ncp": "^2.0.0",
|
||||||
"page-icon": "^0.3.0",
|
"page-icon": "^0.3.0",
|
||||||
"progress": "^2.0.0",
|
"progress": "^2.0.0",
|
||||||
"sanitize-filename": "^1.5.3",
|
"sanitize-filename": "^1.6.1",
|
||||||
"shelljs": "^0.7.0",
|
"shelljs": "^0.7.8",
|
||||||
"source-map-support": "^0.4.0",
|
"source-map-support": "^0.5.0",
|
||||||
"tmp": "0.0.31",
|
"tmp": "0.0.33",
|
||||||
"validator": "^7.0.0"
|
"validator": "^9.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-core": "^6.4.5",
|
"babel-core": "^6.26.0",
|
||||||
"babel-jest": "^19.0.0",
|
"babel-jest": "^21.2.0",
|
||||||
"babel-loader": "^6.2.1",
|
"babel-loader": "^7.1.2",
|
||||||
"babel-preset-es2015": "^6.6.0",
|
"babel-preset-env": "^1.6.1",
|
||||||
"babel-register": "^6.6.0",
|
"babel-register": "^6.26.0",
|
||||||
"chai": "^3.4.1",
|
"chai": "^4.1.2",
|
||||||
"del": "^2.2.0",
|
"del": "^3.0.0",
|
||||||
"eslint": "^3.19.0",
|
"eslint": "^4.11.0",
|
||||||
"eslint-config-airbnb-base": "^11.1.3",
|
"eslint-config-airbnb-base": "^12.1.0",
|
||||||
"eslint-plugin-import": "^2.2.0",
|
"eslint-plugin-import": "^2.8.0",
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.1",
|
||||||
"gulp-babel": "^6.1.1",
|
"gulp-babel": "^7.0.0",
|
||||||
"gulp-istanbul": "^1.1.1",
|
"gulp-istanbul": "^1.1.2",
|
||||||
"gulp-mocha": "^4.3.0",
|
"gulp-mocha": "^4.3.1",
|
||||||
"gulp-sourcemaps": "^2.6.0",
|
"gulp-sourcemaps": "^2.6.1",
|
||||||
"isparta": "^4.0.0",
|
"isparta": "^4.0.0",
|
||||||
"jest": "^20.0.3",
|
"jest": "^21.2.1",
|
||||||
"regenerator-runtime": "^0.10.5",
|
"regenerator-runtime": "^0.11.0",
|
||||||
"require-dir": "^0.3.2",
|
"require-dir": "^0.3.2",
|
||||||
"run-sequence": "^1.1.5",
|
"run-sequence": "^2.2.0",
|
||||||
"webpack-stream": "^3.1.0"
|
"webpack-stream": "^4.0.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 4.0"
|
"node": ">= 4.0"
|
||||||
},
|
},
|
||||||
"babel": {
|
"babel": {
|
||||||
"presets": [
|
"presets": [
|
||||||
"es2015"
|
[
|
||||||
|
"env",
|
||||||
|
{
|
||||||
|
"targets": {
|
||||||
|
"node": "4.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
|
|
|
@ -60,7 +60,7 @@ function maybeCopyScripts(srcs, dest) {
|
||||||
}
|
}
|
||||||
const promises = srcs.map(src => new Promise((resolve, reject) => {
|
const promises = srcs.map(src => new Promise((resolve, reject) => {
|
||||||
if (!fs.existsSync(src)) {
|
if (!fs.existsSync(src)) {
|
||||||
reject('Error copying injection files: file not found');
|
reject(new Error('Error copying injection files: file not found'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ function maybeCopyScripts(srcs, dest) {
|
||||||
|
|
||||||
copy(src, path.join(dest, 'inject', destFileName), (error) => {
|
copy(src, path.join(dest, 'inject', destFileName), (error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(`Error Copying injection files: ${error}`);
|
reject(new Error(`Error Copying injection files: ${error}`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -95,7 +95,7 @@ function maybeCopyScripts(srcs, dest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeAppName(appName, url) {
|
function normalizeAppName(appName, url) {
|
||||||
// use a simple 3 byte random string to prevent collision
|
// use a simple 3 byte random string to prevent collision
|
||||||
const hash = crypto.createHash('md5');
|
const hash = crypto.createHash('md5');
|
||||||
hash.update(url);
|
hash.update(url);
|
||||||
const postFixHash = hash.digest('hex').substring(0, 6);
|
const postFixHash = hash.digest('hex').substring(0, 6);
|
||||||
|
@ -130,8 +130,8 @@ function buildApp(src, dest, options, callback) {
|
||||||
fs.writeFileSync(path.join(dest, '/nativefier.json'), JSON.stringify(appArgs));
|
fs.writeFileSync(path.join(dest, '/nativefier.json'), JSON.stringify(appArgs));
|
||||||
|
|
||||||
maybeCopyScripts(options.inject, dest)
|
maybeCopyScripts(options.inject, dest)
|
||||||
.catch((error) => {
|
.catch((err) => {
|
||||||
console.warn(error);
|
console.warn(err);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
changeAppPackageJsonName(dest, appArgs.name, appArgs.targetUrl);
|
changeAppPackageJsonName(dest, appArgs.name, appArgs.targetUrl);
|
||||||
|
|
|
@ -13,7 +13,7 @@ import PackagerConsole from './../helpers/packagerConsole';
|
||||||
import buildApp from './buildApp';
|
import buildApp from './buildApp';
|
||||||
|
|
||||||
const copy = ncp.ncp;
|
const copy = ncp.ncp;
|
||||||
const isWindows = helpers.isWindows;
|
const { isWindows } = helpers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the app path array to determine if the packaging was completed successfully
|
* Checks the app path array to determine if the packaging was completed successfully
|
||||||
|
@ -153,7 +153,6 @@ function buildMain(inpOptions, callback) {
|
||||||
const options = Object.assign({}, inpOptions);
|
const options = Object.assign({}, inpOptions);
|
||||||
|
|
||||||
// pre process app
|
// pre process app
|
||||||
|
|
||||||
const tmpObj = tmp.dirSync({ unsafeCleanup: true });
|
const tmpObj = tmp.dirSync({ unsafeCleanup: true });
|
||||||
const tmpPath = tmpObj.name;
|
const tmpPath = tmpObj.name;
|
||||||
|
|
||||||
|
@ -163,37 +162,37 @@ function buildMain(inpOptions, callback) {
|
||||||
const progress = new DishonestProgress(5);
|
const progress = new DishonestProgress(5);
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
(callback) => {
|
(cb) => {
|
||||||
progress.tick('inferring');
|
progress.tick('inferring');
|
||||||
optionsFactory(options)
|
optionsFactory(options)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
callback(null, result);
|
cb(null, result);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
callback(error);
|
cb(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
(options, callback) => {
|
(opts, cb) => {
|
||||||
progress.tick('copying');
|
progress.tick('copying');
|
||||||
buildApp(options.dir, tmpPath, options, (error) => {
|
buildApp(opts.dir, tmpPath, opts, (error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
callback(error);
|
cb(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Change the reference file for the Electron app to be the temporary path
|
// Change the reference file for the Electron app to be the temporary path
|
||||||
const newOptions = Object.assign({}, options, { dir: tmpPath });
|
const newOptions = Object.assign({}, opts, { dir: tmpPath });
|
||||||
callback(null, newOptions);
|
cb(null, newOptions);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
(options, callback) => {
|
(opts, cb) => {
|
||||||
progress.tick('icons');
|
progress.tick('icons');
|
||||||
iconBuild(options, (error, optionsWithIcon) => {
|
iconBuild(opts, (error, optionsWithIcon) => {
|
||||||
callback(null, optionsWithIcon);
|
cb(null, optionsWithIcon);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
(options, callback) => {
|
(opts, cb) => {
|
||||||
progress.tick('packaging');
|
progress.tick('packaging');
|
||||||
// maybe skip passing icon parameter to electron packager
|
// maybe skip passing icon parameter to electron packager
|
||||||
let packageOptions = maybeNoIconOption(options);
|
let packageOptions = maybeNoIconOption(opts);
|
||||||
// maybe skip passing other parameters to electron packager
|
// maybe skip passing other parameters to electron packager
|
||||||
packageOptions = maybeNoAppCopyrightOption(packageOptions);
|
packageOptions = maybeNoAppCopyrightOption(packageOptions);
|
||||||
packageOptions = maybeNoAppVersionOption(packageOptions);
|
packageOptions = maybeNoAppVersionOption(packageOptions);
|
||||||
|
@ -208,20 +207,20 @@ function buildMain(inpOptions, callback) {
|
||||||
packagerConsole.restore();
|
packagerConsole.restore();
|
||||||
|
|
||||||
// pass options which still contains the icon to waterfall
|
// pass options which still contains the icon to waterfall
|
||||||
callback(error, options, appPathArray);
|
cb(error, opts, appPathArray);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
(options, appPathArray, callback) => {
|
(opts, appPathArray, cb) => {
|
||||||
progress.tick('finalizing');
|
progress.tick('finalizing');
|
||||||
// somehow appPathArray is a 1 element array
|
// somehow appPathArray is a 1 element array
|
||||||
const appPath = getAppPath(appPathArray);
|
const appPath = getAppPath(appPathArray);
|
||||||
if (!appPath) {
|
if (!appPath) {
|
||||||
callback();
|
cb();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
maybeCopyIcons(options, appPath, (error) => {
|
maybeCopyIcons(opts, appPath, (error) => {
|
||||||
callback(error, appPath);
|
cb(error, appPath);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
], (error, appPath) => {
|
], (error, appPath) => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
export const DEFAULT_APP_NAME = 'APP';
|
export const DEFAULT_APP_NAME = 'APP';
|
||||||
export const ELECTRON_VERSION = '1.6.6';
|
export const ELECTRON_VERSION = '1.7.9';
|
||||||
export const PLACEHOLDER_APP_DIR = path.join(__dirname, './../', 'app');
|
export const PLACEHOLDER_APP_DIR = path.join(__dirname, './../', 'app');
|
||||||
|
|
|
@ -3,7 +3,7 @@ import path from 'path';
|
||||||
import tmp from 'tmp';
|
import tmp from 'tmp';
|
||||||
import helpers from './helpers';
|
import helpers from './helpers';
|
||||||
|
|
||||||
const isOSX = helpers.isOSX;
|
const { isOSX } = helpers;
|
||||||
tmp.setGracefulCleanup();
|
tmp.setGracefulCleanup();
|
||||||
|
|
||||||
const PNG_TO_ICNS_BIN_PATH = path.join(__dirname, '../..', 'bin/convertToIcns');
|
const PNG_TO_ICNS_BIN_PATH = path.join(__dirname, '../..', 'bin/convertToIcns');
|
||||||
|
|
|
@ -12,10 +12,9 @@ function isWindows() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadFile(fileUrl) {
|
function downloadFile(fileUrl) {
|
||||||
return axios.get(
|
return axios.get(fileUrl, {
|
||||||
fileUrl, {
|
responseType: 'arraybuffer',
|
||||||
responseType: 'arraybuffer',
|
})
|
||||||
})
|
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -23,12 +23,13 @@ const SCRIPT_PATHS = {
|
||||||
function iconShellHelper(shellScriptPath, icoSrc, dest) {
|
function iconShellHelper(shellScriptPath, icoSrc, dest) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (isWindows()) {
|
if (isWindows()) {
|
||||||
reject('OSX or Linux is required');
|
reject(new Error('OSX or Linux is required'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.exec(`${shellScriptPath} ${icoSrc} ${dest}`, { silent: true }, (exitCode, stdOut, stdError) => {
|
shell.exec(`${shellScriptPath} ${icoSrc} ${dest}`, { silent: true }, (exitCode, stdOut, stdError) => {
|
||||||
if (exitCode) {
|
if (exitCode) {
|
||||||
|
// eslint-disable-next-line prefer-promise-reject-errors
|
||||||
reject({
|
reject({
|
||||||
stdOut,
|
stdOut,
|
||||||
stdError,
|
stdError,
|
||||||
|
@ -66,7 +67,7 @@ function convertToIco(icoSrc) {
|
||||||
|
|
||||||
function convertToIcns(icoSrc) {
|
function convertToIcns(icoSrc) {
|
||||||
if (!isOSX()) {
|
if (!isOSX()) {
|
||||||
return new Promise((resolve, reject) => reject('OSX is required to convert to a .icns icon'));
|
return new Promise((resolve, reject) => reject(new Error('OSX is required to convert to a .icns icon')));
|
||||||
}
|
}
|
||||||
return iconShellHelper(SCRIPT_PATHS.convertToIcns, icoSrc, `${getTmpDirPath()}/icon.icns`);
|
return iconShellHelper(SCRIPT_PATHS.convertToIcns, icoSrc, `${getTmpDirPath()}/icon.icns`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// TODO: remove this file and use quiet mode of new version of electron packager
|
// TODO: remove this file and use quiet mode of new version of electron packager
|
||||||
class PackagerConsole {
|
class PackagerConsole {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.logs = [];
|
this.logs = [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import _ from 'lodash';
|
||||||
import log from 'loglevel';
|
import log from 'loglevel';
|
||||||
|
|
||||||
const ELECTRON_VERSIONS_URL = 'https://atom.io/download/atom-shell/index.json';
|
const ELECTRON_VERSIONS_URL = 'https://atom.io/download/atom-shell/index.json';
|
||||||
const DEFAULT_CHROME_VERSION = '56.0.2924.87';
|
const DEFAULT_CHROME_VERSION = '58.0.3029.110';
|
||||||
|
|
||||||
function getChromeVersionForElectronVersion(electronVersion, url = ELECTRON_VERSIONS_URL) {
|
function getChromeVersionForElectronVersion(electronVersion, url = ELECTRON_VERSIONS_URL) {
|
||||||
return axios.get(url, { timeout: 5000 })
|
return axios.get(url, { timeout: 5000 })
|
||||||
|
@ -12,9 +12,11 @@ function getChromeVersionForElectronVersion(electronVersion, url = ELECTRON_VERS
|
||||||
throw new Error(`Bad request: Status code ${response.status}`);
|
throw new Error(`Bad request: Status code ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = response.data;
|
const { data } = response;
|
||||||
const electronVersionToChromeVersion = _.zipObject(data.map(d => d.version),
|
const electronVersionToChromeVersion = _.zipObject(
|
||||||
data.map(d => d.chrome));
|
data.map(d => d.version),
|
||||||
|
data.map(d => d.chrome),
|
||||||
|
);
|
||||||
|
|
||||||
if (!(electronVersion in electronVersionToChromeVersion)) {
|
if (!(electronVersion in electronVersionToChromeVersion)) {
|
||||||
throw new Error(`Electron version '${electronVersion}' not found in retrieved version list!`);
|
throw new Error(`Electron version '${electronVersion}' not found in retrieved version list!`);
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe('when the icon parameter is not passed', () => {
|
||||||
|
|
||||||
describe('when inferIcon resolves with an error', () => {
|
describe('when inferIcon resolves with an error', () => {
|
||||||
test('it should handle the error', () => {
|
test('it should handle the error', () => {
|
||||||
inferIcon.mockImplementationOnce(() => Promise.reject('some error'));
|
inferIcon.mockImplementationOnce(() => Promise.reject(new Error('some error')));
|
||||||
const params = { targetUrl: 'some url', platform: 'mac' };
|
const params = { targetUrl: 'some url', platform: 'mac' };
|
||||||
|
|
||||||
return icon(params).then((result) => {
|
return icon(params).then((result) => {
|
||||||
|
|
|
@ -75,7 +75,7 @@ describe('handling inferTitle results', () => {
|
||||||
|
|
||||||
describe('when inferTitle resolves with an error', () => {
|
describe('when inferTitle resolves with an error', () => {
|
||||||
test('it should return the default app name', () => {
|
test('it should return the default app name', () => {
|
||||||
inferTitle.mockImplementationOnce(() => Promise.reject('some error'));
|
inferTitle.mockImplementationOnce(() => Promise.reject(new Error('some error')));
|
||||||
|
|
||||||
return name(params).then((result) => {
|
return name(params).then((result) => {
|
||||||
expect(result).toBe(DEFAULT_APP_NAME);
|
expect(result).toBe(DEFAULT_APP_NAME);
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import normalizeUrl from './normalizeUrl';
|
||||||
|
|
||||||
|
test("a proper URL shouldn't be mangled", () => {
|
||||||
|
expect(normalizeUrl('http://www.google.com')).toEqual('http://www.google.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('missing protocol should default to http', () => {
|
||||||
|
expect(normalizeUrl('www.google.com')).toEqual('http://www.google.com');
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a proper URL shouldn't be mangled", () => {
|
||||||
|
expect(() => { normalizeUrl('http://ssddfoo bar'); }).toThrow('Your Url: "http://ssddfoo bar" is invalid!');
|
||||||
|
});
|
|
@ -7,7 +7,7 @@ import os from 'os';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import convertToIcns from './../../lib/helpers/convertToIcns';
|
import convertToIcns from './../../lib/helpers/convertToIcns';
|
||||||
|
|
||||||
const assert = chai.assert;
|
const { assert } = chai;
|
||||||
|
|
||||||
// Prerequisite for test: to use OSX with sips, iconutil and imagemagick convert
|
// Prerequisite for test: to use OSX with sips, iconutil and imagemagick convert
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import nativefier from './../../lib/index';
|
||||||
|
|
||||||
const PLATFORMS = ['darwin', 'linux'];
|
const PLATFORMS = ['darwin', 'linux'];
|
||||||
tmp.setGracefulCleanup();
|
tmp.setGracefulCleanup();
|
||||||
const assert = chai.assert;
|
const { assert } = chai;
|
||||||
|
|
||||||
function checkApp(appPath, inputOptions, callback) {
|
function checkApp(appPath, inputOptions, callback) {
|
||||||
try {
|
try {
|
||||||
|
@ -32,16 +32,16 @@ function checkApp(appPath, inputOptions, callback) {
|
||||||
const nativefierConfig = JSON.parse(fs.readFileSync(nativefierConfigPath));
|
const nativefierConfig = JSON.parse(fs.readFileSync(nativefierConfigPath));
|
||||||
|
|
||||||
assert.strictEqual(inputOptions.targetUrl, nativefierConfig.targetUrl, 'Packaged app must have the same targetUrl as the input parameters');
|
assert.strictEqual(inputOptions.targetUrl, nativefierConfig.targetUrl, 'Packaged app must have the same targetUrl as the input parameters');
|
||||||
// app name is not consistent for linux
|
// app name is not consistent for linux
|
||||||
// assert.strictEqual(inputOptions.appName, nativefierConfig.name,
|
// assert.strictEqual(inputOptions.appName, nativefierConfig.name,
|
||||||
// 'Packaged app must have the same name as the input parameters');
|
// 'Packaged app must have the same name as the input parameters');
|
||||||
callback();
|
callback();
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
callback(exception);
|
callback(exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Nativefier Module', function () {
|
describe('Nativefier Module', function testNativefierModule() {
|
||||||
this.timeout(240000);
|
this.timeout(240000);
|
||||||
it('Can build an app from a target url', (done) => {
|
it('Can build an app from a target url', (done) => {
|
||||||
async.eachSeries(PLATFORMS, (platform, callback) => {
|
async.eachSeries(PLATFORMS, (platform, callback) => {
|
||||||
|
@ -63,8 +63,8 @@ describe('Nativefier Module', function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkApp(appPath, options, (error) => {
|
checkApp(appPath, options, (err) => {
|
||||||
callback(error);
|
callback(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import chai from 'chai';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import inferUserAgent from './../../lib/infer/inferUserAgent';
|
import inferUserAgent from './../../lib/infer/inferUserAgent';
|
||||||
|
|
||||||
const assert = chai.assert;
|
const { assert } = chai;
|
||||||
|
|
||||||
const TEST_RESULT = {
|
const TEST_RESULT = {
|
||||||
darwin: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36',
|
darwin: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36',
|
||||||
|
@ -12,36 +12,36 @@ const TEST_RESULT = {
|
||||||
|
|
||||||
function testPlatform(platform) {
|
function testPlatform(platform) {
|
||||||
return inferUserAgent('0.37.1', platform)
|
return inferUserAgent('0.37.1', platform)
|
||||||
.then((userAgent) => {
|
.then((userAgent) => {
|
||||||
assert.equal(userAgent, TEST_RESULT[platform], 'Correct user agent should be inferred');
|
assert.equal(userAgent, TEST_RESULT[platform], 'Correct user agent should be inferred');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Infer User Agent', function () {
|
describe('Infer User Agent', function testInferUserAgent() {
|
||||||
this.timeout(15000);
|
this.timeout(15000);
|
||||||
it('Can infer userAgent for all platforms', (done) => {
|
it('Can infer userAgent for all platforms', (done) => {
|
||||||
const testPromises = _.keys(TEST_RESULT).map(platform => testPlatform(platform));
|
const testPromises = _.keys(TEST_RESULT).map(platform => testPlatform(platform));
|
||||||
Promise
|
Promise
|
||||||
.all(testPromises)
|
.all(testPromises)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
done(error);
|
done(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Connection error will still get a user agent', (done) => {
|
it('Connection error will still get a user agent', (done) => {
|
||||||
const TIMEOUT_URL = 'http://www.google.com:81/';
|
const TIMEOUT_URL = 'http://www.google.com:81/';
|
||||||
inferUserAgent('1.6.7', 'darwin', TIMEOUT_URL)
|
inferUserAgent('1.6.7', 'darwin', TIMEOUT_URL)
|
||||||
.then((userAgent) => {
|
.then((userAgent) => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
userAgent,
|
userAgent,
|
||||||
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
|
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36',
|
||||||
'Expect default user agent on connection error',
|
'Expect default user agent on connection error',
|
||||||
);
|
);
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(done);
|
.catch(done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
import chai from 'chai';
|
|
||||||
import normalizeUrl from '../../../src/options/normalizeUrl';
|
|
||||||
|
|
||||||
const assert = chai.assert;
|
|
||||||
const expect = chai.expect;
|
|
||||||
|
|
||||||
describe('Normalize URL', () => {
|
|
||||||
describe('given a valid URL without a protocol', () => {
|
|
||||||
it('should allow the url', () => {
|
|
||||||
assert.equal(normalizeUrl('http://www.google.com'), 'http://www.google.com');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('given a valid URL without a protocol', () => {
|
|
||||||
it('should allow the url and prepend the HTTP protocol', () => {
|
|
||||||
assert.equal(normalizeUrl('www.google.com'), 'http://www.google.com');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('given an invalid URL', () => {
|
|
||||||
it('should throw an exception', () => {
|
|
||||||
expect(() => normalizeUrl('http://ssddfoo bar')).to.throw('Your Url: "http://ssddfoo bar" is invalid!');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -17,7 +17,7 @@ module.exports = {
|
||||||
externals: nodeModules,
|
externals: nodeModules,
|
||||||
module: {
|
module: {
|
||||||
loaders: [
|
loaders: [
|
||||||
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
|
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
|
|
Loading…
Reference in New Issue