Skip to content

Commit

Permalink
Compiles ES6+ (ethereum#3034)
Browse files Browse the repository at this point in the history
* Compiles es6+7

* Optionally skipping gulp tasks

* Rearranges deps

* Fixing menuItems bug

* Transpiles with Babel

* Runs dev with Babel

* Compiles modules directory
  • Loading branch information
wolovim authored and evertonfraga committed Sep 14, 2017
1 parent 3d9cc7a commit 093fae5
Show file tree
Hide file tree
Showing 12 changed files with 733 additions and 282 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2016-node5"]
}
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ Options are:

*Note: applicable only when combined with `--wallet`*

#### skipTasks

When building a binary, you can optionally skip some tasks — generally for testing purposes.

$ gulp --mac --skipTasks=bundling-interface,release-dist

#### Checksums

Spits out the MD5 checksums of distributables.
Expand All @@ -226,7 +232,7 @@ It expects installer/zip files to be in the generated folders e.g. `dist_mist/re

## Testing

Tests are ran using [Spectron](https://github.com/electron/spectron/), a webdriver.io runner built for Electron.
Tests are ran using [Spectron](https://github.com/electron/spectron/), a webdriver.io runner built for Electron.

First make sure to build Mist with:

Expand Down
17 changes: 15 additions & 2 deletions gulpTasks/building.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const del = require('del');
const exec = require('child_process').exec;
const fs = require('fs');
const gulp = require('gulp');
const babel = require('gulp-babel');
const options = require('../gulpfile.js').options;
const path = require('path');
const Q = require('bluebird');
Expand All @@ -28,9 +29,7 @@ gulp.task('copy-app-source-files', () => {
'node_modules/**/*',
'!node_modules/electron/',
'!node_modules/electron/**/*',
'./main.js',
'./clientBinaries.json',
'./modules/**',
'./tests/**/*.*',
'!./tests/wallet/*',
`./icons/${type}/*`,
Expand All @@ -44,6 +43,20 @@ gulp.task('copy-app-source-files', () => {
});


gulp.task('transpile-main', () => {
return gulp.src('./main.js')
.pipe(babel({ presets: ['es2016-node5'] }))
.pipe(gulp.dest(`./dist_${type}/app`));
});


gulp.task('transpile-modules', () => {
return gulp.src('./modules/**')
.pipe(babel({ presets: ['es2016-node5'] }))
.pipe(gulp.dest(`./dist_${type}/app/modules`));
});


gulp.task('copy-build-folder-files', () => {
return gulp.src([
`./icons/${type}/*`,
Expand Down
28 changes: 17 additions & 11 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ if (process.platform === 'darwin') {
// parse commandline arguments
const args = process.argv.slice(2);
const options = minimist(args, {
string: ['walletSource', 'test'],
string: ['walletSource', 'test', 'skipTasks'],
boolean: _.flatten(['wallet', platforms]),
default: {
wallet: false,
walletSource: 'master',
test: 'basic',
skipTasks: '',
},
});

Expand Down Expand Up @@ -66,18 +67,24 @@ gulp.task('default', ['buildQueue']);


gulp.task('buildQueue', (cb) => {
const tasks = [];
const skipTasks = options.skipTasks.split(',');
let tasks = [
'clean-dist',
'copy-app-source-files',
'transpile-main',
'transpile-modules',
'copy-build-folder-files',
'switch-production',
'bundling-interface',
'copy-i18n',
'build-dist',
'release-dist',
];

tasks.push('clean-dist');
tasks.push('copy-app-source-files');
tasks.push('copy-build-folder-files');
tasks.push('switch-production');
tasks.push('bundling-interface');
tasks.push('copy-i18n');
tasks.push('build-dist');
tasks.push('release-dist');
if (options.win) tasks.push('build-nsis');

tasks = _.difference(tasks, skipTasks);

runSeq.apply(null, _.flatten([tasks, cb]));
});

Expand All @@ -90,4 +97,3 @@ gulp.task('uploadQueue', (cb) => {

runSeq.apply(null, _.flatten([tasks, cb]));
});

18 changes: 18 additions & 0 deletions interface/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


babel-runtime@^6.18.0:
version "6.25.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.25.0.tgz#33b98eaa5d482bb01a8d1aa6b437ad2b01aec41c"
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.10.0"

core-js@^2.4.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.0.tgz#569c050918be6486b3837552028ae0466b717086"

regenerator-runtime@^0.10.0:
version "0.10.5"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658"
17 changes: 7 additions & 10 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,13 @@ app.on('before-quit', (event) => {
});

// delay quit, so the sockets can close
setTimeout(() => {
ethereumNode.stop()
.then(() => {
killedSocketsAndNodes = true;

return db.close();
})
.then(() => {
app.quit();
});
setTimeout(async () => {
await ethereumNode.stop()

killedSocketsAndNodes = true;
await db.close();

app.quit();
}, 500);
} else {
log.info('About to quit...');
Expand Down
7 changes: 4 additions & 3 deletions modules/ipc/methods/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ module.exports = class BaseProcessor {
* @param {Object|Array} payload payload
* @return {Promise}
*/
exec(conn, payload) {
async exec(conn, payload) {
this._log.trace('Execute request', payload);

return conn.socket.send(payload, {
const ret = await conn.socket.send(payload, {
fullResult: true,
})
.then(ret => ret.result);

return ret.result;
}


Expand Down
8 changes: 6 additions & 2 deletions modules/menuItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,17 @@ let menuTempl = function (webviews) {

// DEVELOP
const devToolsMenu = [];
let devtToolsSubMenu;
let curWindow;

// change for wallet
if (Settings.uiMode === 'mist') {
devtToolsSubMenu = [{
label: i18n.t('mist.applicationMenu.develop.devToolsMistUI'),
accelerator: 'Alt+CommandOrControl+I',
click() {
if (curWindow = BrowserWindow.getFocusedWindow()) {
curWindow = BrowserWindow.getFocusedWindow();
if (curWindow) {
curWindow.toggleDevTools();
}
},
Expand All @@ -383,7 +386,8 @@ let menuTempl = function (webviews) {
label: i18n.t('mist.applicationMenu.develop.devToolsWalletUI'),
accelerator: 'Alt+CommandOrControl+I',
click() {
if (curWindow = BrowserWindow.getFocusedWindow()) {
curWindow = BrowserWindow.getFocusedWindow();
if (curWindow) {
curWindow.toggleDevTools();
}
},
Expand Down
31 changes: 14 additions & 17 deletions modules/preloader/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@
@module preloader tests
*/

if(location.origin !== "file://") {
if (location.origin !== "file://") {
throw new Error('Wrong test file loaded');
return;
}


// load dapp preloader file
require('./dapps.js');
} else {
// load dapp preloader file
require('./dapps.js');

const electron = require('electron');
const ipcRenderer = electron.ipcRenderer;

const electron = require('electron');
const ipcRenderer = electron.ipcRenderer;
window.ipcProvider = require('../ipc/ipcProviderWrapper.js');
window.permissions = {};

window.ipcProvider = require('../ipc/ipcProviderWrapper.js');
window.permissions = {};

ipcRenderer.sendToHost('sendTestData');
ipcRenderer.on('uiAction_sendTestData', function(e, permissions, coinbase) {
window.permissions = permissions;
window.coinbase = coinbase;
});
ipcRenderer.sendToHost('sendTestData');
ipcRenderer.on('uiAction_sendTestData', function(e, permissions, coinbase) {
window.permissions = permissions;
window.coinbase = coinbase;
});
}
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"url": "https://github.com/ethereum/mist.git"
},
"scripts": {
"postinstall": "cd interface && yarn"
"postinstall": "cd interface && yarn",
"dev:electron": "electron -r babel-register main.js",
"dev:meteor": "cd interface && meteor --no-release-check"
},
"main": "main.js",
"dependencies": {
Expand All @@ -32,8 +34,8 @@
"oboe": "^2.1.3",
"os-timesync": "^1.0.7",
"semver": "^5.1.0",
"swarm-js": "^0.1.21",
"solc": "^0.4.15",
"swarm-js": "^0.1.21",
"typescript": "^2.2.2",
"underscore": "^1.8.3",
"underscore-deep-extend": "^1.1.5",
Expand All @@ -42,6 +44,8 @@
"yargs": "^7.0.2"
},
"devDependencies": {
"babel-preset-es2016-node5": "^1.1.2",
"babel-register": "^6.26.0",
"chai": "^3.5.0",
"co-mocha": "^1.2.0",
"del": "^2.2.2",
Expand All @@ -56,6 +60,7 @@
"geth-private": "^1.3.0",
"gh-release-assets": "^1.1.0",
"gulp": "^3.9.0",
"gulp-babel": "^7.0.0",
"gulp-spawn-mocha": "^3.3.0",
"json-structure-diff": "^0.0.2",
"minimist": "^1.2.0",
Expand Down
4 changes: 4 additions & 0 deletions tests/_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ const startGeth = function* () {
rpcport: 58545,
},
});
console.info('Geth starting...');
yield geth.start();
console.info('Geth started');
return geth;
};

Expand Down Expand Up @@ -131,7 +133,9 @@ exports.mocha = (_module, options) => {
chromeDriverLogPath: chromeLogFile,
});

console.info('App starting...');
yield this.app.start();
console.info('App started');
this.client = this.app.client;

/*
Expand Down
Loading

0 comments on commit 093fae5

Please sign in to comment.