Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
Fix Mist/Wallet app bundling (#721)
Browse files Browse the repository at this point in the history
* fix Mist/Wallet app bundling

* update electron-packager to 7.0.2
  • Loading branch information
hiddentao authored and Alex Van de Sande committed Jun 1, 2016
1 parent 1aaedac commit 521326e
Show file tree
Hide file tree
Showing 12 changed files with 194 additions and 169 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ interface_build/
interface/public/i18n/
dist_wallet/
dist_mist/
config.json
11 changes: 0 additions & 11 deletions config.js

This file was deleted.

13 changes: 7 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,18 @@ gulp.task('copy-files', ['clean:dist'], function() {
'!./interface/**/*.*',
'!./geth',
'!./geth.exe',
'!./main.js',
'!./Wallet-README.txt'
], { base: './' })
.pipe(gulp.dest('./dist_'+ type +'/app'));
});

gulp.task('switch-production', ['clean:dist'], function() {
return gulp.src(['./main.js'])
.pipe(replace('global.production = false;', 'global.production = true;'))
.pipe(replace('global.mode = (argv.mode ? argv.mode : \'mist\');', 'global.mode = (argv.mode ? argv.mode : \''+ type +'\');'))
.pipe(gulp.dest('./dist_'+ type +'/app'));
gulp.task('switch-production', ['clean:dist', 'copy-files'], function(cb) {
fs.writeFileSync(__dirname+'/dist_'+ type +'/app/config.json', JSON.stringify({
production: true,
mode: type,
}));

cb();
});


Expand Down
31 changes: 14 additions & 17 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,22 @@ const i18n = require('./modules/i18n.js');
const logger = require('./modules/utils/logger');
const Sockets = require('./modules/sockets');
const Windows = require('./modules/windows');
const cliArgs = require('./modules/utils/cliArgs');

const Settings = require('./modules/settings');
Settings.init();


if (Settings.cli.version) {
console.log(Settings.appVersion);

if (cliArgs.version) {
console.log(packageJson.version);
process.exit(0);
}

if (cliArgs.ignoreGpuBlacklist) {
if (Settings.cli.ignoreGpuBlacklist) {
app.commandLine.appendSwitch('ignore-gpu-blacklist', 'true');
}


// logging setup
logger.setup(cliArgs);
const log = logger.create('main');

// GLOBAL Variables
Expand All @@ -44,23 +45,19 @@ global.path = {
USERDATA: app.getPath('userData') // Application Aupport/Mist
};

global.appName = 'Mist';

global.dirname = __dirname;

global.version = packageJson.version;
global.version = Settings.appVersion;
global.license = Settings.appLicense;

global.production = false;
global.production = Settings.inProductionMode;
log.info(`Running in production mode: ${global.production}`);

global.mode = (cliArgs.mode ? cliArgs.mode : 'mist');
global.mode = Settings.uiMode;

Settings.set('gethPath', cliArgs.gethpath);
Settings.set('ethPath', cliArgs.ethpath);
Settings.set('ipcPath', cliArgs.ipcpath);
Settings.set('nodeOptions', cliArgs.nodeOptions);
global.appName = 'mist' === global.mode ? 'Mist' : 'Ethereum Wallet';

global.version = packageJson.version;
global.license = packageJson.license;


require('./modules/ipcCommunicator.js');
Expand Down Expand Up @@ -104,7 +101,7 @@ if(global.mode === 'wallet') {
? 'file://' + __dirname + '/interface/index.html'
: 'http://localhost:3000';

if (cliArgs.resetTabs) {
if (Settings.cli.resetTabs) {
url += '?reset-tabs=true'
}

Expand Down
2 changes: 1 addition & 1 deletion modules/ethereumNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ class EthereumNode extends EventEmitter {
pw = null;
}

let nodeOptions = Settings.get('nodeOptions');
let nodeOptions = Settings.nodeOptions;

if (nodeOptions && nodeOptions.length) {
log.debug('Custom node options', nodeOptions);
Expand Down
2 changes: 1 addition & 1 deletion modules/getNodePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = function(type) {
let ret = '';

// global override?
let globallySetType = Settings.get(`${type}Path`);
let globallySetType = Settings[`${type}Path`];

if (globallySetType) {
resolvedPaths[type] = globallySetType;
Expand Down
2 changes: 1 addition & 1 deletion modules/ipc/getIpcPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Settings = require('../settings');


module.exports = function() {
var ipcPath = Settings.get('ipcPath');
var ipcPath = Settings.ipcPath;
if (ipcPath) {
return ipcPath;
}
Expand Down
13 changes: 6 additions & 7 deletions modules/menuItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const BrowserWindow = electron.BrowserWindow;
const MenuItem = electron.MenuItem;
const Menu = electron.Menu;
const shell = electron.shell;
const config = require('../config.js');
const log = require('./utils/logger').create('menuItems');
const ipc = electron.ipcMain;
const ethereumNode = require('./ethereumNode.js');
Expand Down Expand Up @@ -50,10 +49,10 @@ var menuTempl = function(webviews) {

// APP
menu.push({
label: i18n.t('mist.applicationMenu.app.label', {app: config.name}),
label: i18n.t('mist.applicationMenu.app.label', {app: global.appName}),
submenu: [
{
label: i18n.t('mist.applicationMenu.app.about', {app: config.name}),
label: i18n.t('mist.applicationMenu.app.about', {app: global.appName}),
click: function(){
Windows.createPopup('about', {
electronOptions: {
Expand Down Expand Up @@ -81,24 +80,24 @@ var menuTempl = function(webviews) {
type: 'separator'
},
{
label: i18n.t('mist.applicationMenu.app.hide', {app: config.name}),
label: i18n.t('mist.applicationMenu.app.hide', {app: global.appName}),
accelerator: 'Command+H',
role: 'hide'
},
{
label: i18n.t('mist.applicationMenu.app.hideOthers', {app: config.name}),
label: i18n.t('mist.applicationMenu.app.hideOthers', {app: global.appName}),
accelerator: 'Command+Alt+H',
role: 'hideothers'
},
{
label: i18n.t('mist.applicationMenu.app.showAll', {app: config.name}),
label: i18n.t('mist.applicationMenu.app.showAll', {app: global.appName}),
role: 'unhide'
},
{
type: 'separator'
},
{
label: i18n.t('mist.applicationMenu.app.quit', {app: config.name}),
label: i18n.t('mist.applicationMenu.app.quit', {app: global.appName}),
accelerator: 'CommandOrControl+Q',
click: function(){
app.quit();
Expand Down
1 change: 0 additions & 1 deletion modules/mistAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

const electron = require('electron');
const packageJson = require('./../package.json');
const config = require('./../config');
const remote = electron.remote;

module.exports = function(isWallet) {
Expand Down
173 changes: 162 additions & 11 deletions modules/settings.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,172 @@
const log = require('./utils/logger').create('Settings');
const logger = require('./utils/logger');
const packageJson = require('../package.json');


var _settings = {};
// try loading in config file
let defaultConfig = {
mode: 'mist',
production: false,
};
try {
_.extend(defaultConfig, require('../config.json'));
} catch (err) {
}


exports.get = function(key) {
var value = _settings[key];

log.trace('get', key, value);
const argv = require('yargs')
.usage('Usage: $0 [Mist options] -- [Node options]')
.option({
mode: {
alias: 'm',
demand: false,
default: defaultConfig.mode,
describe: 'App UI mode: wallet, mist.',
requiresArg: true,
nargs: 1,
type: 'string',
group: 'Mist options:',
},
ipcpath: {
demand: false,
describe: 'Path to node IPC socket file (this will automatically get passed as an option to Geth).',
requiresArg: true,
nargs: 1,
type: 'string',
group: 'Mist options:',
},
gethpath: {
demand: false,
describe: 'Path to Geth executable to use instead of default.',
requiresArg: true,
nargs: 1,
type: 'string',
group: 'Mist options:',
},
ethpath: {
demand: false,
describe: 'Path to Eth executable to use instead of default.',
requiresArg: true,
nargs: 1,
type: 'string',
group: 'Mist options:',
},
'ignore-gpu-blacklist': {
demand: false,
describe: 'Ignores GPU blacklist (needed for some Linux installations).',
requiresArg: false,
nargs: 0,
type: 'boolean',
group: 'Mist options:',
},
'reset-tabs': {
demand: false,
describe: 'Reset Mist tabs to their default settings.',
requiresArg: false,
nargs: 0,
type: 'boolean',
group: 'Mist options:',
},
logfile: {
demand: false,
describe: 'Logs will be written to this file in addition to the console.',
requiresArg: true,
nargs: 1,
type: 'string',
group: 'Mist options:',
},
loglevel: {
demand: false,
default: 'info',
describe: 'Minimum logging threshold: trace (all logs), debug, info, warn, error.',
requiresArg: true,
nargs: 1,
type: 'string',
group: 'Mist options:',
},
version: {
alias: 'v',
demand: false,
requiresArg: false,
nargs: 0,
describe: 'Display Mist version.',
group: 'Mist options:',
type: 'boolean',
},
'': {
describe: 'All options will be passed onto the node (e.g. Geth).',
group: 'Node options:',
}
})
.help('h')
.alias('h', 'help')
.parse(process.argv.slice(1));

return value;
};

argv.nodeOptions = [];

exports.set = function(key, value) {
log.trace('set', key, value);
for (let optIdx in argv._) {
if ('-' === argv._[optIdx].charAt(0)) {
argv.nodeOptions = argv._.slice(optIdx);

_settings[key] = value;
};
break;
}
}

// some options are shared
if (argv.ipcpath) {
argv.nodeOptions.push('--ipcpcath', argv.ipcpath);
}



var log = null;


class Settings {
init () {
logger.setup(argv);

this._log = logger.create('Settings');
}

get cli () {
return argv;
}

get appVersion () {
return packageJson.version;
}

get appLicense () {
return packageJson.license;
}

get uiMode () {
return argv.mode;
}

get inProductionMode () {
return defaultConfig.production;
}

get gethPath () {
return argv.gethpath;
}

get ethPath () {
return argv.ethpath;
}

get ipcPath () {
return argv.ipcpath;
}

get nodeOptions () {
return argv.nodeOptions;
}


}

module.exports = new Settings();
Loading

0 comments on commit 521326e

Please sign in to comment.