PR feedback
This commit is contained in:
parent
581b0c9f42
commit
31cb79bf5b
|
@ -99,7 +99,8 @@ class EmbarkController {
|
|||
version: engine.version,
|
||||
events: engine.events,
|
||||
logger: engine.logger,
|
||||
ipc: engine.ipc
|
||||
ipc: engine.ipc,
|
||||
config: engine.config
|
||||
}).startConsole();
|
||||
return callback();
|
||||
}
|
||||
|
@ -110,7 +111,8 @@ class EmbarkController {
|
|||
plugins: engine.plugins,
|
||||
version: self.version,
|
||||
env: engine.env,
|
||||
ipc: engine.ipc
|
||||
ipc: engine.ipc,
|
||||
config: engine.config
|
||||
});
|
||||
dashboard.start(function () {
|
||||
engine.logger.info(__('dashboard start'));
|
||||
|
@ -260,6 +262,16 @@ class EmbarkController {
|
|||
webpackConfigName: options.webpackConfigName
|
||||
});
|
||||
engine.init();
|
||||
const repl = new REPL({
|
||||
env: engine.env,
|
||||
plugins: engine.plugins,
|
||||
version: engine.version,
|
||||
events: engine.events,
|
||||
logger: engine.logger,
|
||||
ipc: engine.ipc,
|
||||
config: engine.config
|
||||
});
|
||||
repl.startConsole();
|
||||
async.waterfall([
|
||||
function startServices(callback) {
|
||||
let pluginList = engine.plugins.listPlugins();
|
||||
|
@ -333,14 +345,6 @@ class EmbarkController {
|
|||
});
|
||||
},
|
||||
function startREPL(callback) {
|
||||
let repl = new REPL({
|
||||
env: engine.env,
|
||||
plugins: engine.plugins,
|
||||
version: engine.version,
|
||||
events: engine.events,
|
||||
logger: engine.logger,
|
||||
ipc: engine.ipc
|
||||
});
|
||||
repl.start(callback);
|
||||
}
|
||||
], function (err, _result) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
let utils = require('../../lib/utils/utils.js');
|
||||
|
||||
const EmbarkJS = require('embarkjs');
|
||||
const IpfsApi = require('ipfs-api');
|
||||
const Web3 = require('web3');
|
||||
class Console {
|
||||
constructor(options) {
|
||||
this.events = options.events;
|
||||
|
@ -7,10 +9,13 @@ class Console {
|
|||
this.version = options.version;
|
||||
this.logger = options.logger;
|
||||
this.ipc = options.ipc;
|
||||
this.config = options.config;
|
||||
|
||||
if (this.ipc.isServer()) {
|
||||
this.ipc.on('console:executeCmd', this.executeCmd.bind(this));
|
||||
}
|
||||
|
||||
this.registerEmbarkJs();
|
||||
}
|
||||
|
||||
processEmbarkCmd (cmd) {
|
||||
|
@ -65,6 +70,46 @@ class Console {
|
|||
callback(e);
|
||||
}
|
||||
}
|
||||
|
||||
registerEmbarkJs() {
|
||||
this.events.on('runcode:ready', () => {
|
||||
this.events.emit('runcode:register', 'IpfsApi', IpfsApi, false);
|
||||
this.events.emit('runcode:register', 'Web3', Web3, false);
|
||||
this.events.emit('runcode:register', 'EmbarkJS', EmbarkJS, false);
|
||||
});
|
||||
|
||||
this.events.on('code-generator-ready', () => {
|
||||
if (this.ipc.connected) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.events.request('code-generator:embarkjs:provider-code', (code) => {
|
||||
const func = () => {};
|
||||
this.events.request('runcode:eval', code, func, true);
|
||||
this.events.request('runcode:eval', this.getInitProviderCode(), func, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getInitProviderCode() {
|
||||
const codeTypes = {
|
||||
'communication': this.config.communicationConfig || {},
|
||||
'names': this.config.namesystemConfig || {},
|
||||
'storage': this.config.storageConfig || {}
|
||||
};
|
||||
|
||||
return this.plugins.getPluginsFor('initConsoleCode').reduce((acc, plugin) => {
|
||||
Object.keys(codeTypes).forEach(codeTypeName => {
|
||||
(plugin.embarkjs_init_console_code[codeTypeName] || []).forEach(initCode => {
|
||||
let [block, shouldInit] = initCode;
|
||||
if (shouldInit.call(plugin, codeTypes[codeTypeName])) {
|
||||
acc += block;
|
||||
}
|
||||
});
|
||||
});
|
||||
return acc;
|
||||
}, '');
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Console;
|
||||
|
|
|
@ -12,6 +12,7 @@ class Dashboard {
|
|||
this.version = options.version;
|
||||
this.env = options.env;
|
||||
this.ipc = options.ipc;
|
||||
this.config = options.config;
|
||||
|
||||
this.events.on('firstDeploymentDone', this.checkWindowSize.bind(this));
|
||||
this.events.on('outputDone', this.checkWindowSize.bind(this));
|
||||
|
@ -35,7 +36,8 @@ class Dashboard {
|
|||
plugins: self.plugins,
|
||||
version: self.version,
|
||||
ipc: self.ipc,
|
||||
logger: self.logger
|
||||
logger: self.logger,
|
||||
config: self.config
|
||||
});
|
||||
callback();
|
||||
},
|
||||
|
|
|
@ -11,6 +11,7 @@ class REPL {
|
|||
this.events = options.events;
|
||||
this.version = options.version;
|
||||
this.ipc = options.ipc;
|
||||
this.config = options.config;
|
||||
}
|
||||
|
||||
startConsole(){
|
||||
|
@ -19,7 +20,8 @@ class REPL {
|
|||
plugins: this.plugins,
|
||||
version: this.version,
|
||||
ipc: this.ipc,
|
||||
logger: this.logger
|
||||
logger: this.logger,
|
||||
config: this.config
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
const RunCode = require('./runCode.js');
|
||||
const EmbarkJS = require('embarkjs');
|
||||
const IpfsApi = require('ipfs-api');
|
||||
const Web3 = require('web3');
|
||||
|
||||
class CodeRunner {
|
||||
constructor(options) {
|
||||
|
@ -16,7 +13,7 @@ class CodeRunner {
|
|||
this.IpcClientListen();
|
||||
this.registerEvents();
|
||||
this.registerCommands();
|
||||
this.registerEmbarkJs();
|
||||
this.events.emit('runcode:ready');
|
||||
}
|
||||
|
||||
registerIpcEvents() {
|
||||
|
@ -55,23 +52,6 @@ class CodeRunner {
|
|||
this.events.setCommandHandler('runcode:eval', this.evalCode.bind(this));
|
||||
}
|
||||
|
||||
registerEmbarkJs() {
|
||||
this.registerVar('IpfsApi', IpfsApi, false);
|
||||
this.registerVar('Web3', Web3, false);
|
||||
this.registerVar('EmbarkJS', EmbarkJS, false);
|
||||
|
||||
if (this.ipc.connected) {
|
||||
return;
|
||||
}
|
||||
this.events.on('code-generator-ready', () => {
|
||||
this.events.request('code-generator:embarkjs:provider-code', (code) => {
|
||||
const func = () => {};
|
||||
this.evalCode(code, func, true);
|
||||
this.evalCode(this.getInitProviderCode(), func, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
registerVar(varName, code, toRecord = true) {
|
||||
if (this.ipc.isServer() && toRecord) {
|
||||
this.commands.push({varName, code});
|
||||
|
@ -81,9 +61,7 @@ class CodeRunner {
|
|||
}
|
||||
|
||||
evalCode(code, cb, forConsoleOnly = false) {
|
||||
if (!cb) {
|
||||
cb = function() {};
|
||||
}
|
||||
cb = cb || function() {};
|
||||
const awaitIdx = code.indexOf('await');
|
||||
if (awaitIdx > -1) {
|
||||
if (awaitIdx < 2) {
|
||||
|
@ -109,27 +87,6 @@ class CodeRunner {
|
|||
|
||||
cb(null, result);
|
||||
}
|
||||
|
||||
getInitProviderCode() {
|
||||
const codeTypes = {
|
||||
'communication': this.config.communicationConfig || {},
|
||||
'names': this.config.namesystemConfig || {},
|
||||
'storage': this.config.storageConfig || {}
|
||||
};
|
||||
|
||||
return this.plugins.getPluginsFor('initConsoleCode').reduce((acc, plugin) => {
|
||||
Object.keys(codeTypes).forEach(codeTypeName => {
|
||||
(plugin.embarkjs_init_console_code[codeTypeName] || []).forEach(initCode => {
|
||||
let [block, shouldInit] = initCode;
|
||||
if (shouldInit.call(plugin, codeTypes[codeTypeName])) {
|
||||
acc += block;
|
||||
}
|
||||
});
|
||||
});
|
||||
return acc;
|
||||
}, '');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CodeRunner;
|
||||
|
|
|
@ -146,7 +146,7 @@ class ENS extends React.Component {
|
|||
</FormGroup>
|
||||
</Form>
|
||||
|
||||
<h3>Register subdomain for eth</h3>
|
||||
<h3>Register subdomain</h3>
|
||||
<Form inline onKeyDown={(e) => this.checkEnter(e, this.registerSubDomain)}>
|
||||
<FormGroup>
|
||||
{this.state.responseRegister &&
|
||||
|
|
Loading…
Reference in New Issue