From 1995afab17e9aa7507e15b24e80ff859bfefa428 Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Sat, 19 Mar 2016 20:29:36 +0800 Subject: [PATCH 01/16] added --help and --version cli parameters --- main.js | 13 +++++++++++++ package.json | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 04c90a23f..559445a3a 100644 --- a/main.js +++ b/main.js @@ -10,6 +10,19 @@ const ipc = electron.ipcMain; const dialog = require('dialog'); const packageJson = require('./package.json'); +// CLI options +const argv = require('yargs') + .usage('Usage: $0 [options]') + .describe('version', 'Display app version') + .help('h') + .alias('h', 'help') + .argv; + +if (argv.version) { + console.log(packageJson.version); + process.exit(0); +} + // GLOBAL Variables global.path = { diff --git a/package.json b/package.json index 00f720b9e..2d359e6c0 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "numeral": "^1.5.3", "solc": "^0.2.1-1", "underscore": "^1.8.3", - "web3": "^0.15.1" + "web3": "^0.15.1", + "yargs": "^4.3.1" }, "devDependencies": { "del": "^1.2.1", From 68e8dfcd71c6dfa5a7d4954814cf45807cb9fa91 Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Sat, 19 Mar 2016 21:01:20 +0800 Subject: [PATCH 02/16] get it working properly with built Electron app --- README.md | 2 +- main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7b50202c1..ebb6e8d83 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Requires electron version 0.35.2 To run mist in development you need [Node.js NPM](https://nodejs.org) and [Meteor](https://www.meteor.com/install) and electron installed: $ curl https://install.meteor.com/ | sh - $ npm install -g electron-prebuilt + $ npm install -g electron-prebuilt@0.36.9 ### Installation diff --git a/main.js b/main.js index 559445a3a..00eb6a82d 100644 --- a/main.js +++ b/main.js @@ -16,7 +16,7 @@ const argv = require('yargs') .describe('version', 'Display app version') .help('h') .alias('h', 'help') - .argv; + .parse(process.argv.slice(1)); if (argv.version) { console.log(packageJson.version); From fdf1a33070cde0894830028edb01a7ca18c6f9aa Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Sat, 19 Mar 2016 22:48:33 +0800 Subject: [PATCH 03/16] Add app mode CLI parameter. --- README.md | 4 ++-- main.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ebb6e8d83..b9d4c6ef6 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ In the original window you can then start Mist with: ### Run the Wallet -Switch the `global.mode` to `"wallet"` in the `main.js`. +Add `--model wallet` to the Mist command-line. Start the wallet app for development, *in a separate terminal window:* @@ -84,7 +84,7 @@ Start the wallet app for development, *in a separate terminal window:* In the original window you can then start Mist with: $ cd mist - $ electron . + $ electron . --mode wallet ### Using Mist with a privatenet diff --git a/main.js b/main.js index 00eb6a82d..e5a730305 100644 --- a/main.js +++ b/main.js @@ -14,6 +14,8 @@ const packageJson = require('./package.json'); const argv = require('yargs') .usage('Usage: $0 [options]') .describe('version', 'Display app version') + .describe('mode', 'App mode: wallet, mist (default)') + .alias('m', 'mode') .help('h') .alias('h', 'help') .parse(process.argv.slice(1)); @@ -34,7 +36,7 @@ global.path = { global.appName = 'Mist'; global.production = false; -global.mode = 'mist'; +global.mode = ('wallet' === argv.mode ? 'wallet' : 'mist'); global.version = packageJson.version; global.license = packageJson.license; From aea61e97879e225d1ecad059e0582ae0197be26b Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Wed, 30 Mar 2016 13:52:23 +0800 Subject: [PATCH 04/16] added --gethpath and --ethpath, added caching for path resolver --- main.js | 4 ++++ modules/getNodePath.js | 51 +++++++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/main.js b/main.js index 9e1faf1dc..cf8548fe8 100644 --- a/main.js +++ b/main.js @@ -38,6 +38,10 @@ global.appName = 'Mist'; global.production = false; global.mode = ('wallet' === argv.mode ? 'wallet' : 'mist'); +global.paths = { + geth: argv.gethpath, + eth: argv.ethpath, +}; global.version = packageJson.version; global.license = packageJson.license; diff --git a/modules/getNodePath.js b/modules/getNodePath.js index 1c63b4764..2a5a0316b 100644 --- a/modules/getNodePath.js +++ b/modules/getNodePath.js @@ -1,3 +1,5 @@ +"use strict"; + /** Gets the right Node path @@ -7,28 +9,45 @@ Gets the right Node path const path = require('path'); const binaryPath = path.resolve(__dirname + '/../nodes'); +// cache +const resolvedPaths = {}; + + module.exports = function(type) { + if (resolvedPaths[type]) { + return resolvedPaths[type]; + } + + let ret = ''; + + // global override? + if (global.paths && global.paths[type]) { + resolvedPaths[type] = global.paths[type]; + } else { + var binPath = (global.production) + ? binaryPath.replace('nodes','node') + '/'+ type +'/'+ type + : binaryPath + '/'+ type +'/'+ process.platform +'-'+ process.arch + '/'+ type; + + if(global.production) { + binPath = binPath.replace('app.asar/','').replace('app.asar\\',''); + + if(process.platform === 'darwin') { + binPath = path.resolve(binPath.replace('/node/', '/../Frameworks/node/')); + } + } - var binPath = (global.production) - ? binaryPath.replace('nodes','node') + '/'+ type +'/'+ type - : binaryPath + '/'+ type +'/'+ process.platform +'-'+ process.arch + '/'+ type; - if(global.production) { - binPath = binPath.replace('app.asar/','').replace('app.asar\\',''); - - if(process.platform === 'darwin') { - binPath = path.resolve(binPath.replace('/node/', '/../Frameworks/node/')); + if(process.platform === 'win32') { + binPath = binPath.replace(/\/+/,'\\'); + binPath += '.exe'; } + + resolvedPaths[type] = binPath; } + console.log(`Resolved path for ${type}: ${resolvedPaths[type]}`); - if(process.platform === 'win32') { - binPath = binPath.replace(/\/+/,'\\'); - binPath += '.exe'; - } + return resolvedPaths[type]; +}; - // if(process.platform === 'linux') - // binPath = type; // simply try to run a global binary - return binPath; -}; \ No newline at end of file From 9d9b90c441c00c8cfc25d1e61559971c76ce5511 Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Thu, 31 Mar 2016 12:53:14 +0800 Subject: [PATCH 05/16] update electron version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7b7a0119d..5c5675497 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Requires electron version 0.37.2 To run mist in development you need [Node.js NPM](https://nodejs.org) and [Meteor](https://www.meteor.com/install) and electron installed: $ curl https://install.meteor.com/ | sh - $ npm install -g electron-prebuilt@0.36.9 + $ npm install -g electron-prebuilt@0.37.2 ### Installation From 09a6a9aeab6c95567faeef33368d25f7116712e5 Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Thu, 31 Mar 2016 22:18:28 +0800 Subject: [PATCH 06/16] readme: fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c5675497..527cec972 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ In the original window you can then start Mist with: ### Run the Wallet -Add `--model wallet` to the Mist command-line. +Add `--mode wallet` to the Mist command-line. Start the wallet app for development, *in a separate terminal window:* From 842f24767489fe3717d44ca9a6a4a7cdd244d58d Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Thu, 31 Mar 2016 22:22:03 +0800 Subject: [PATCH 07/16] main: added help for gethpath and ethpath cli options --- main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.js b/main.js index cf8548fe8..5f67a46a8 100644 --- a/main.js +++ b/main.js @@ -16,6 +16,8 @@ const argv = require('yargs') .usage('Usage: $0 [options]') .describe('version', 'Display app version') .describe('mode', 'App mode: wallet, mist (default)') + .describe('gethpath', 'Path to geth executable to use instead of default') + .describe('ethpath', 'Path to eth executable to use instead of default') .alias('m', 'mode') .help('h') .alias('h', 'help') From c3e9694a5bbc8fc621ee0d44a34404cb6384e4da Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Tue, 5 Apr 2016 22:45:02 +0800 Subject: [PATCH 08/16] added ignore-gpu-blacklist flag --- main.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.js b/main.js index 5f67a46a8..9b475ec4f 100644 --- a/main.js +++ b/main.js @@ -18,6 +18,7 @@ const argv = require('yargs') .describe('mode', 'App mode: wallet, mist (default)') .describe('gethpath', 'Path to geth executable to use instead of default') .describe('ethpath', 'Path to eth executable to use instead of default') + .describe('ignore-gpu-blacklist', 'Ignores GPU blacklist (needed for some Linux installations)') .alias('m', 'mode') .help('h') .alias('h', 'help') @@ -28,6 +29,9 @@ if (argv.version) { process.exit(0); } +if (argv.ignoreGpuBlacklist) { + app.commandLine.appendSwitch('ignore-gpu-blacklist', 'true'); +} // GLOBAL Variables global.path = { @@ -45,6 +49,7 @@ global.paths = { eth: argv.ethpath, }; + global.version = packageJson.version; global.license = packageJson.license; From 5b198564daf842f58a94f10c415a8d4e2a38475c Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Sat, 19 Mar 2016 20:29:36 +0800 Subject: [PATCH 09/16] added --help and --version cli parameters --- main.js | 13 +++++++++++++ package.json | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 24fb0215d..468962f50 100644 --- a/main.js +++ b/main.js @@ -12,6 +12,19 @@ const dialog = require('dialog'); const packageJson = require('./package.json'); const i18n = require('./modules/i18n.js'); +// CLI options +const argv = require('yargs') + .usage('Usage: $0 [options]') + .describe('version', 'Display app version') + .help('h') + .alias('h', 'help') + .argv; + +if (argv.version) { + console.log(packageJson.version); + process.exit(0); +} + // GLOBAL Variables global.path = { diff --git a/package.json b/package.json index ba4143120..267931066 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "os-timesync": "^1.0.3", "solc": "^0.3.1-1", "underscore": "^1.8.3", - "web3": "^0.15.1" + "web3": "^0.15.1", + "yargs": "^4.3.1" }, "devDependencies": { "del": "^1.2.1", From 9f1382316906435eab1153798e9218abe3ba7efb Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Sat, 19 Mar 2016 21:01:20 +0800 Subject: [PATCH 10/16] get it working properly with built Electron app --- README.md | 2 +- main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d439c0367..7deaf4fbb 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Requires electron version 0.37.2 To run mist in development you need [Node.js NPM](https://nodejs.org) and [Meteor](https://www.meteor.com/install) and electron installed: $ curl https://install.meteor.com/ | sh - $ npm install -g electron-prebuilt + $ npm install -g electron-prebuilt@0.36.9 ### Installation diff --git a/main.js b/main.js index 468962f50..aa3dae210 100644 --- a/main.js +++ b/main.js @@ -18,7 +18,7 @@ const argv = require('yargs') .describe('version', 'Display app version') .help('h') .alias('h', 'help') - .argv; + .parse(process.argv.slice(1)); if (argv.version) { console.log(packageJson.version); From 25027266603c3b42eca4def016b4fa782edd2a25 Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Sat, 19 Mar 2016 22:48:33 +0800 Subject: [PATCH 11/16] Add app mode CLI parameter. --- README.md | 4 ++-- main.js | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7deaf4fbb..7b7a0119d 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ In the original window you can then start Mist with: ### Run the Wallet -Switch the `global.mode` to `"wallet"` in the `main.js`. +Add `--model wallet` to the Mist command-line. Start the wallet app for development, *in a separate terminal window:* @@ -84,7 +84,7 @@ Start the wallet app for development, *in a separate terminal window:* In the original window you can then start Mist with: $ cd mist - $ electron . + $ electron . --mode wallet ### Using Mist with a privatenet diff --git a/main.js b/main.js index aa3dae210..f377937d4 100644 --- a/main.js +++ b/main.js @@ -16,6 +16,8 @@ const i18n = require('./modules/i18n.js'); const argv = require('yargs') .usage('Usage: $0 [options]') .describe('version', 'Display app version') + .describe('mode', 'App mode: wallet, mist (default)') + .alias('m', 'mode') .help('h') .alias('h', 'help') .parse(process.argv.slice(1)); @@ -36,7 +38,7 @@ global.path = { global.appName = 'Mist'; global.production = false; -global.mode = 'mist'; +global.mode = ('wallet' === argv.mode ? 'wallet' : 'mist'); global.version = packageJson.version; global.license = packageJson.license; From a39fcf34fb591c78ecbf2ca34d7e87dcf8723ffd Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Wed, 30 Mar 2016 13:52:23 +0800 Subject: [PATCH 12/16] added --gethpath and --ethpath, added caching for path resolver --- main.js | 4 ++++ modules/getNodePath.js | 51 +++++++++++++++++++++++++++++------------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/main.js b/main.js index f377937d4..dc57ca235 100644 --- a/main.js +++ b/main.js @@ -39,6 +39,10 @@ global.appName = 'Mist'; global.production = false; global.mode = ('wallet' === argv.mode ? 'wallet' : 'mist'); +global.paths = { + geth: argv.gethpath, + eth: argv.ethpath, +}; global.version = packageJson.version; global.license = packageJson.license; diff --git a/modules/getNodePath.js b/modules/getNodePath.js index 1c63b4764..2a5a0316b 100644 --- a/modules/getNodePath.js +++ b/modules/getNodePath.js @@ -1,3 +1,5 @@ +"use strict"; + /** Gets the right Node path @@ -7,28 +9,45 @@ Gets the right Node path const path = require('path'); const binaryPath = path.resolve(__dirname + '/../nodes'); +// cache +const resolvedPaths = {}; + + module.exports = function(type) { + if (resolvedPaths[type]) { + return resolvedPaths[type]; + } + + let ret = ''; + + // global override? + if (global.paths && global.paths[type]) { + resolvedPaths[type] = global.paths[type]; + } else { + var binPath = (global.production) + ? binaryPath.replace('nodes','node') + '/'+ type +'/'+ type + : binaryPath + '/'+ type +'/'+ process.platform +'-'+ process.arch + '/'+ type; + + if(global.production) { + binPath = binPath.replace('app.asar/','').replace('app.asar\\',''); + + if(process.platform === 'darwin') { + binPath = path.resolve(binPath.replace('/node/', '/../Frameworks/node/')); + } + } - var binPath = (global.production) - ? binaryPath.replace('nodes','node') + '/'+ type +'/'+ type - : binaryPath + '/'+ type +'/'+ process.platform +'-'+ process.arch + '/'+ type; - if(global.production) { - binPath = binPath.replace('app.asar/','').replace('app.asar\\',''); - - if(process.platform === 'darwin') { - binPath = path.resolve(binPath.replace('/node/', '/../Frameworks/node/')); + if(process.platform === 'win32') { + binPath = binPath.replace(/\/+/,'\\'); + binPath += '.exe'; } + + resolvedPaths[type] = binPath; } + console.log(`Resolved path for ${type}: ${resolvedPaths[type]}`); - if(process.platform === 'win32') { - binPath = binPath.replace(/\/+/,'\\'); - binPath += '.exe'; - } + return resolvedPaths[type]; +}; - // if(process.platform === 'linux') - // binPath = type; // simply try to run a global binary - return binPath; -}; \ No newline at end of file From 3c96d9619c76382f2fba75ea080edb5a75bd47fa Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Thu, 31 Mar 2016 12:53:14 +0800 Subject: [PATCH 13/16] update electron version in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7b7a0119d..5c5675497 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Requires electron version 0.37.2 To run mist in development you need [Node.js NPM](https://nodejs.org) and [Meteor](https://www.meteor.com/install) and electron installed: $ curl https://install.meteor.com/ | sh - $ npm install -g electron-prebuilt@0.36.9 + $ npm install -g electron-prebuilt@0.37.2 ### Installation From a010dcc7c3ebee1f7779788f58f6b6626ce025a3 Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Thu, 31 Mar 2016 22:18:28 +0800 Subject: [PATCH 14/16] readme: fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c5675497..527cec972 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ In the original window you can then start Mist with: ### Run the Wallet -Add `--model wallet` to the Mist command-line. +Add `--mode wallet` to the Mist command-line. Start the wallet app for development, *in a separate terminal window:* From 9cd38588a3aa3b83e4f62c258ab63449ac7f906f Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Thu, 31 Mar 2016 22:22:03 +0800 Subject: [PATCH 15/16] main: added help for gethpath and ethpath cli options --- main.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main.js b/main.js index dc57ca235..5f17613b2 100644 --- a/main.js +++ b/main.js @@ -17,6 +17,8 @@ const argv = require('yargs') .usage('Usage: $0 [options]') .describe('version', 'Display app version') .describe('mode', 'App mode: wallet, mist (default)') + .describe('gethpath', 'Path to geth executable to use instead of default') + .describe('ethpath', 'Path to eth executable to use instead of default') .alias('m', 'mode') .help('h') .alias('h', 'help') From 22f8899a0fe016861d31a7f2e51d450d3b62796f Mon Sep 17 00:00:00 2001 From: Ramesh Nair Date: Tue, 5 Apr 2016 22:45:02 +0800 Subject: [PATCH 16/16] added ignore-gpu-blacklist flag --- main.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.js b/main.js index 5f17613b2..ce7943207 100644 --- a/main.js +++ b/main.js @@ -19,6 +19,7 @@ const argv = require('yargs') .describe('mode', 'App mode: wallet, mist (default)') .describe('gethpath', 'Path to geth executable to use instead of default') .describe('ethpath', 'Path to eth executable to use instead of default') + .describe('ignore-gpu-blacklist', 'Ignores GPU blacklist (needed for some Linux installations)') .alias('m', 'mode') .help('h') .alias('h', 'help') @@ -29,6 +30,9 @@ if (argv.version) { process.exit(0); } +if (argv.ignoreGpuBlacklist) { + app.commandLine.appendSwitch('ignore-gpu-blacklist', 'true'); +} // GLOBAL Variables global.path = { @@ -46,6 +50,7 @@ global.paths = { eth: argv.ethpath, }; + global.version = packageJson.version; global.license = packageJson.license;