diff --git a/lib/cmd.js b/lib/cmd.js index 2977d69e..5df6eb61 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -177,11 +177,10 @@ class Cmd { .command('graph [environment]') .description('generates documentation based on the smart contracts configured') .action(function (env, options) { - embark.initConfig(env || 'development', { - embarkConfig: 'embark.json', - interceptLogs: false + embark.graph({ + env: env || 'development', + logfile: options.logfile }); - embark.graph(); }); } diff --git a/lib/contracts/deploy_manager.js b/lib/contracts/deploy_manager.js index 0562574e..edcd49e7 100644 --- a/lib/contracts/deploy_manager.js +++ b/lib/contracts/deploy_manager.js @@ -17,6 +17,7 @@ class DeployManager { this.gasLimit = false; this.fatalErrors = false; this.deployOnlyOnConfig = false; + this.onlyCompile = options.onlyCompile !== undefined ? options.onlyCompile : false; } deployContracts(done) { @@ -33,6 +34,13 @@ class DeployManager { self.contractsManager.deployOnlyOnConfig = self.deployOnlyOnConfig; // temporary, should refactor 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) { if (!self.web3) { return callback(Error("no web3 instance found")); diff --git a/lib/core/engine.js b/lib/core/engine.js index 53ee6203..4d3bb00e 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -153,7 +153,8 @@ class Engine { logger: this.logger, plugins: this.plugins, events: this.events, - contractsManager: this.contractsManager + contractsManager: this.contractsManager, + onlyCompile: options.onlyCompile }); this.events.on('file-event', function (fileType, _path) { diff --git a/lib/index.js b/lib/index.js index 14a78911..21bc71f4 100644 --- a/lib/index.js +++ b/lib/index.js @@ -185,11 +185,70 @@ class Embark { return new Test(options); } - graph() { - const GraphGenerator = new require('./cmds/graph.js'); - console.log(this.config); - let graphGen = new GraphGenerator(this.config); - graphGen.generate(); + graph(options) { + + + + 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() {