add versions command

This commit is contained in:
Iuri Matias 2017-07-06 19:50:36 -04:00
parent 232f6fc88b
commit 414c875082
4 changed files with 23 additions and 9 deletions

View File

@ -3,6 +3,7 @@ var File = require('./file.js');
var Plugins = require('./plugins.js');
var utils = require('../utils/utils.js');
var Npm = require('../pipeline/npm.js');
let currentWeb3Version = require('../../package.json').dependencies.web3.replace("^","");
// TODO: add wrapper for fs so it can also work in the browser
// can work with both read and save
@ -250,7 +251,7 @@ Config.prototype.loadFiles = function(files) {
if (self.blockchainConfig.enabled || self.communicationConfig.provider === 'whisper' || self.communicationConfig.available_providers.indexOf('whisper') >= 0) {
let web3Version = self.contractsConfig.versions["web3.js"];
if (web3Version) {
if (web3Version && web3Version != currentWeb3Version) {
//if (false) {
//readFiles.push(new File({filename: 'web3-' + web3Version + '.js', type: 'custom', resolver: function(callback) {
readFiles.push(new File({filename: 'web3.js', type: 'custom', resolver: function(callback) {

View File

@ -5,15 +5,11 @@ class Console {
constructor(options) {
this.plugins = options.plugins;
this.version = options.version;
this.contractsConfig = options.contractsConfig;
}
runCode(code) {
try {
RunCode.doEval(code); // jshint ignore:line
} catch(e) {
console.log(code);
console.debug(e);
}
}
processEmbarkCmd (cmd) {
@ -22,6 +18,7 @@ class Console {
'Welcome to Embark ' + this.version,
'',
'possible commands are:',
'versions - display versions in use for libraries and tools like web3 and solc',
// TODO: only if the blockchain is actually active!
// will need to pass te current embark state here
'web3 - instantiated web3.js object configured to the current environment',
@ -30,6 +27,20 @@ class Console {
'The web3 object and the interfaces for the deployed contracts and their methods are also available'
];
return helpText.join('\n');
} else if (cmd === 'versions') {
//let currentSolcVersion = require('../../package.json').dependencies.solc;
let solcVersionInConfig = this.contractsConfig.versions.solc;
//let web3Version = require('../../package.json').dependencies["web3.js"].replace("^","");
let web3VersionInConfig = this.contractsConfig.versions["web3.js"];
let text = [
'versions in use:',
'solc: ' + solcVersionInConfig,
'web3.js: ' + web3VersionInConfig
]
return text.join('\n');
} else if (cmd === 'quit') {
utils.exit();
}

View File

@ -9,6 +9,7 @@ class Dashboard {
this.plugins = options.plugins;
this.version = options.version;
this.env = options.env;
this.contractsConfig = options.contractsConfig;
}
start(done) {
@ -17,7 +18,7 @@ class Dashboard {
async.waterfall([
function startConsole(callback) {
console = new Console({plugins: self.plugins, version: self.version});
console = new Console({plugins: self.plugins, version: self.version, contractsConfig: self.contractsConfig});
callback();
},
function startMonitor(callback) {

View File

@ -76,7 +76,8 @@ class Embark {
logger: engine.logger,
plugins: engine.plugins,
version: self.version,
env: engine.env
env: engine.env,
contractsConfig: engine.config.contractsConfig
});
dashboard.start(function () {
engine.events.on('code-generator-ready', function () {