Changed logic of deploy manager to be able to only compile the code and not deploy it

This commit is contained in:
Richard Ramos 2018-03-22 15:09:01 -04:00
parent 9e469cc83e
commit d7b33a309b
4 changed files with 77 additions and 10 deletions

View File

@ -177,11 +177,10 @@ class Cmd {
.command('graph [environment]') .command('graph [environment]')
.description('generates documentation based on the smart contracts configured') .description('generates documentation based on the smart contracts configured')
.action(function (env, options) { .action(function (env, options) {
embark.initConfig(env || 'development', { embark.graph({
embarkConfig: 'embark.json', env: env || 'development',
interceptLogs: false logfile: options.logfile
}); });
embark.graph();
}); });
} }

View File

@ -17,6 +17,7 @@ class DeployManager {
this.gasLimit = false; this.gasLimit = false;
this.fatalErrors = false; this.fatalErrors = false;
this.deployOnlyOnConfig = false; this.deployOnlyOnConfig = false;
this.onlyCompile = options.onlyCompile !== undefined ? options.onlyCompile : false;
} }
deployContracts(done) { deployContracts(done) {
@ -33,6 +34,13 @@ class DeployManager {
self.contractsManager.deployOnlyOnConfig = self.deployOnlyOnConfig; // temporary, should refactor self.contractsManager.deployOnlyOnConfig = self.deployOnlyOnConfig; // temporary, should refactor
self.contractsManager.build(callback); self.contractsManager.build(callback);
}, },
function checkCompileOnly(contractsManager, callback){
if(self.onlyCompile){
self.events.emit('contractsDeployed', contractsManager);
return done();
}
return callback(contractsManager, null);
},
function checkWeb3IsConnected(contractsManager, callback) { function checkWeb3IsConnected(contractsManager, callback) {
if (!self.web3) { if (!self.web3) {
return callback(Error("no web3 instance found")); return callback(Error("no web3 instance found"));

View File

@ -153,7 +153,8 @@ class Engine {
logger: this.logger, logger: this.logger,
plugins: this.plugins, plugins: this.plugins,
events: this.events, events: this.events,
contractsManager: this.contractsManager contractsManager: this.contractsManager,
onlyCompile: options.onlyCompile
}); });
this.events.on('file-event', function (fileType, _path) { this.events.on('file-event', function (fileType, _path) {

View File

@ -185,11 +185,70 @@ class Embark {
return new Test(options); return new Test(options);
} }
graph() { graph(options) {
const GraphGenerator = new require('./cmds/graph.js');
console.log(this.config);
let graphGen = new GraphGenerator(this.config);
graphGen.generate(); let self = this;
options.onlyCompile = true;
let engine = new Engine({
env: options.env,
version: this.version,
embarkConfig: options.embarkConfig || 'embark.json',
logfile: options.logfile
});
engine.init();
async.parallel([
function (callback) {
let pluginList = engine.plugins.listPlugins();
if (pluginList.length > 0) {
engine.logger.info("loaded plugins: " + pluginList.join(", "));
}
engine.startMonitor();
engine.startService("libraryManager");
engine.startService("pipeline");
engine.startService("codeGenerator");
engine.startService("deployment", {onlyCompile: true});
engine.deployManager.deployContracts(function (err) {
callback(err);
});
}
], function (err, _result) {
if (err) {
engine.logger.error(err.message);
engine.logger.info(err.stack);
} else {
const GraphGenerator = require('./cmds/graph.js');
let graphGen = new GraphGenerator(engine.config);
graphGen.generate();
engine.logger.info("Done".underline);
process.exit();
}
});
} }
reset() { reset() {