Skip to content

Commit

Permalink
Upgrade dependencies and default to latest Electron 1.7.9 (PR nativef…
Browse files Browse the repository at this point in the history
…ier#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
  • Loading branch information
ronjouch authored Nov 14, 2017
1 parent 78bedc6 commit 6fb3b92
Show file tree
Hide file tree
Showing 33 changed files with 190 additions and 290 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ plugins:
rules:
# TODO: Remove this when we have shifted away from the async package
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
import/no-extraneous-dependencies: ['error', { devDependencies: ['gulpfile.babel.js', 'gulp/**/**.js', 'test/**/**.js']}]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.DS_Store

# Node.js
package-lock.json

# ignore compiled lib files
lib/*
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
1 change: 1 addition & 0 deletions app/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
113 changes: 0 additions & 113 deletions app/package-lock.json

This file was deleted.

8 changes: 4 additions & 4 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"description": "Placeholder for the nativefier cli to override with a target url",
"main": "lib/main.js",
"dependencies": {
"electron-dl": "^1.1.0",
"electron-window-state": "^4.1.0",
"source-map-support": "^0.4.0",
"wurl": "^2.1.0"
"electron-dl": "^1.10.0",
"electron-window-state": "^4.1.1",
"source-map-support": "^0.5.0",
"wurl": "^2.5.2"
},
"devDependencies": {},
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions app/src/components/mainWindow/mainWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import helpers from './../../helpers/helpers';
import createMenu from './../menu/menu';
import initContextMenu from './../contextMenu/contextMenu';

const { isOSX, linkIsInternal, getCssToInject, shouldInjectCss } = helpers;
const {
isOSX, linkIsInternal, getCssToInject, shouldInjectCss,
} = helpers;

const ZOOM_INTERVAL = 0.1;

Expand Down Expand Up @@ -125,7 +127,7 @@ function createMainWindow(inpOptions, onAppQuit, setDockBadge) {
if (response !== 0) {
return;
}
const session = mainWindow.webContents.session;
const { session } = mainWindow.webContents;
session.clearStorageData(() => {
session.clearCache(() => {
mainWindow.loadURL(options.targetUrl);
Expand Down
34 changes: 18 additions & 16 deletions app/src/components/menu/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,25 @@ import { Menu, shell, clipboard } from 'electron';
* @param clearAppData
* @param disableDevTools
*/
function createMenu({ nativefierVersion,
appQuit,
zoomIn,
zoomOut,
zoomReset,
zoomBuildTimeValue,
goBack,
goForward,
getCurrentUrl,
clearAppData,
disableDevTools }) {
function createMenu({
nativefierVersion,
appQuit,
zoomIn,
zoomOut,
zoomReset,
zoomBuildTimeValue,
goBack,
goForward,
getCurrentUrl,
clearAppData,
disableDevTools,
}) {
if (Menu.getApplicationMenu()) {
return;
}
const zoomResetLabel = (zoomBuildTimeValue === 1.0) ?
'Reset Zoom' :
`Reset Zoom (to ${zoomBuildTimeValue * 100}%, set at build time)`;
'Reset Zoom' :
`Reset Zoom (to ${zoomBuildTimeValue * 100}%, set at build time)`;

const template = [
{
Expand Down Expand Up @@ -221,8 +223,8 @@ function createMenu({ nativefierVersion,
];

if (disableDevTools) {
// remove last item (dev tools) from menu > view
const submenu = template[1].submenu;
// remove last item (dev tools) from menu > view
const { submenu } = template[1];
submenu.splice(submenu.length - 1, 1);
}

Expand Down Expand Up @@ -272,7 +274,7 @@ function createMenu({ nativefierVersion,
label: 'Bring All to Front',
role: 'front',
},
);
);
}

const menu = Menu.buildFromTemplate(template);
Expand Down
4 changes: 3 additions & 1 deletion app/src/components/trayIcon/trayIcon.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import path from 'path';

const { app, Tray, Menu, ipcMain } = require('electron');
const {
app, Tray, Menu, ipcMain,
} = require('electron');

/**
*
Expand Down
4 changes: 2 additions & 2 deletions app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ app.on('window-all-closed', () => {

app.on('activate', (event, hasVisibleWindows) => {
if (isOSX()) {
// this is called when the dock is clicked
// this is called when the dock is clicked
if (!hasVisibleWindows) {
mainWindow.show();
}
Expand Down Expand Up @@ -108,7 +108,7 @@ app.on('ready', () => {
});

app.on('login', (event, webContents, request, authInfo, callback) => {
// for http authentication
// for http authentication
event.preventDefault();

if (appArgs.basicAuthUsername !== null && appArgs.basicAuthPassword !== null) {
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ nativefier(options, function(error, appPath) {

#### [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]
Expand Down
25 changes: 15 additions & 10 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,39 @@

## Environment Setup

First clone the project
First, clone the project

```bash
git clone https://github.com/jiahaog/nativefier.git
cd nativefier
```

Install dependencies
Install dependencies and build:

```bash
# OSX and Linux
# macOS and Linux
npm run dev-up

# Windows
npm install
cd app
npm install
npm run dev-up-win
```

Don't forget to compile source files:
If dependencies are installed and you just want to re-build,

```bash
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
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
nativefier <...>
nativefier <--your-awesome-new-flag>
```

Or you can automatically watch the files for changes with:
Expand All @@ -48,5 +46,12 @@ npm run watch
## Tests

```bash
# To run all tests (unit, end-to-end),
npm test

# To run only unit tests,
npm run jest

# To run only end-to-end tests,
npm run e2e
```
4 changes: 2 additions & 2 deletions gulp/build/build-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import PATHS from './../helpers/src-paths';
const webpackConfig = require('./../../webpack.config.js');

gulp.task('build-app', ['build-static'], () => gulp.src(PATHS.APP_MAIN_JS)
.pipe(webpack(webpackConfig))
.pipe(gulp.dest(PATHS.APP_DEST)));
.pipe(webpack(webpackConfig))
.pipe(gulp.dest(PATHS.APP_DEST)));
2 changes: 1 addition & 1 deletion gulp/build/build-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import helpers from './../helpers/gulp-helpers';
const { buildES6 } = helpers;

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));

Expand Down
10 changes: 5 additions & 5 deletions gulp/helpers/gulp-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ function shellExec(cmd, silent, callback) {

function buildES6(src, dest, callback) {
return gulp.src(src)
.pipe(sourcemaps.init())
.pipe(babel())
.on('error', callback)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dest));
.pipe(sourcemaps.init())
.pipe(babel())
.on('error', callback)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dest));
}

export default {
Expand Down
8 changes: 4 additions & 4 deletions gulp/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import gulp from 'gulp';
import PATHS from './helpers/src-paths';

gulp.task('watch', ['build'], () => {
const handleError = function (error) {
const handleError = function watch(error) {
console.error(error);
};
gulp.watch(PATHS.APP_ALL, ['build-app'])
.on('error', handleError);
.on('error', handleError);

gulp.watch(PATHS.CLI_SRC_JS, ['build-cli'])
.on('error', handleError);
.on('error', handleError);

gulp.watch(PATHS.TEST_SRC_JS, ['build-tests'])
.on('error', handleError);
.on('error', handleError);
});
Loading

0 comments on commit 6fb3b92

Please sign in to comment.