diff --git a/cmd/cmd_controller.js b/cmd/cmd_controller.js index cb43769b..80ff90eb 100644 --- a/cmd/cmd_controller.js +++ b/cmd/cmd_controller.js @@ -31,7 +31,7 @@ class EmbarkController { } blockchain(env, client) { - this.context = [constants.contexts.blockchain]; + this.context = [constants.contexts.blockchain]; return require('../lib/modules/blockchain_process/blockchain.js')(this.config.blockchainConfig, client, env, null, null, this.logger, this.events, true).run(); } @@ -438,50 +438,73 @@ class EmbarkController { } scaffold(options) { - this.context = options.context || [constants.contexts.scaffold]; - options.onlyCompile = true; const Engine = require('../lib/core/engine.js'); const engine = new Engine({ env: options.env, + client: options.client, + locale: options.locale, version: this.version, - embarkConfig: options.embarkConfig || 'embark.json', + embarkConfig: 'embark.json', + interceptLogs: false, logFile: options.logFile, - context: this.context + logLevel: options.logLevel, + events: options.events, + logger: options.logger, + config: options.config, + plugins: options.plugins, + context: this.context, + webpackConfigName: options.webpackConfigName }); - async.waterfall([ - function (callback) { + function initEngine(callback) { engine.init({}, callback); }, - function (callback) { + function startServices(callback) { + engine.startService("scaffolding"); + callback(); + }, + function generateContract(callback) { + engine.events.request('scaffolding:generate:contract', options, function(err, file) { + // Add contract file to the manager + engine.events.request('config:contractsFiles:add', file); + callback(); + }); + }, + function initEngineServices(callback) { let pluginList = engine.plugins.listPlugins(); if (pluginList.length > 0) { engine.logger.info(__("loaded plugins") + ": " + pluginList.join(", ")); } - engine.startService("processManager"); - engine.startService("serviceMonitor"); engine.startService("libraryManager"); - engine.startService("pipeline"); - engine.startService("deployment", {onlyCompile: true}); + engine.startService("codeRunner"); engine.startService("web3"); - engine.startService("scaffolding"); + engine.startService("deployment", {onlyCompile: true}); - engine.events.request('deploy:contracts', callback); - } - ], (err) => { - if (err) { - engine.logger.error(err.message); - engine.logger.info(err.stack); - } else { - engine.events.request("scaffolding:generate", options, () => { - engine.logger.info(__("finished generating the UI").underline); - process.exit(); + callback(); + }, + function deploy(callback) { + engine.events.request('deploy:contracts', function(err) { + callback(err); + }); + }, + function generateUI(callback) { + engine.events.request("scaffolding:generate:ui", options, () => { + callback(); }); } + ], function(err) { + if (err) { + engine.logger.error(__("Error generating the UI: ")); + engine.logger.error(err.message || err); + process.exit(1); + } + engine.logger.info(__("finished generating the UI").underline); + engine.logger.info(__("To see the result, execute {{cmd}} and go to /{{contract}}.html", {cmd: 'embark run'.underline, contract: options.contract})); + process.exit(); }); }