support --dashboard option

This commit is contained in:
Iuri Matias 2016-10-29 22:30:41 -04:00
parent 655f56f893
commit 7bccb73f01
3 changed files with 28 additions and 11 deletions

View File

@ -65,6 +65,7 @@ Cmd.prototype.run = function() {
.option('-p, --port [port]', 'port to run the dev webserver (default: 8000)') .option('-p, --port [port]', 'port to run the dev webserver (default: 8000)')
.option('-b, --host [host]', 'host to run the dev webserver (default: localhost)') .option('-b, --host [host]', 'host to run the dev webserver (default: localhost)')
.option('--noserver', 'disable the development webserver') .option('--noserver', 'disable the development webserver')
.option('--nodashboard', 'simple mode, disables the dashboard')
.description('run dapp (default: development)') .description('run dapp (default: development)')
.action(function(env, options) { .action(function(env, options) {
self.Embark.initConfig(env || 'development', { self.Embark.initConfig(env || 'development', {
@ -74,7 +75,8 @@ Cmd.prototype.run = function() {
env: env || 'development', env: env || 'development',
serverPort: options.port, serverPort: options.port,
serverHost: options.host, serverHost: options.host,
runWebserver: !options.noserver runWebserver: !options.noserver,
useDashboard: !options.nodashboard
}); });
}); });
}; };

View File

@ -63,20 +63,34 @@ var Embark = {
var self = this; var self = this;
var env = options.env; var env = options.env;
async.waterfall([ async.waterfall([
function welcome(callback) {
if (!options.useDashboard) {
console.log('========================'.bold.green);
console.log('Welcome to Embark 2.1.2'.yellow.bold);
console.log('========================'.bold.green);
}
callback();
},
function startConsole(callback) { function startConsole(callback) {
Embark.console = new Console(); Embark.console = new Console();
callback(); callback();
}, },
function startMonitor(callback) { function startMonitor(callback) {
if (!options.useDashboard) {
return callback();
}
Embark.monitor = new Monitor({env: env, console: Embark.console}); Embark.monitor = new Monitor({env: env, console: Embark.console});
Embark.monitor.setStatus("Starting");
self.logger.logFunction = Embark.monitor.logEntry; self.logger.logFunction = Embark.monitor.logEntry;
self.logger.contractsState = Embark.monitor.setContracts; self.logger.contractsState = Embark.monitor.setContracts;
self.logger.availableServices = Embark.monitor.availableServices; self.logger.availableServices = Embark.monitor.availableServices;
self.logger.setStatus = Embark.monitor.setStatus.bind(Embark.monitor);
// TODO: do this after monitor is rendered // TODO: do this after monitor is rendered
callback(); callback();
}, },
function monitorServices(callback) { function monitorServices(callback) {
if (!options.useDashboard) {
return callback();
}
Embark.servicesMonitor = new ServicesMonitor({ Embark.servicesMonitor = new ServicesMonitor({
logger: Embark.logger, logger: Embark.logger,
config: Embark.config, config: Embark.config,
@ -92,7 +106,7 @@ var Embark = {
if (!options.runWebserver) { if (!options.runWebserver) {
return callback(); return callback();
} }
Embark.monitor.setStatus("Starting Server"); self.logger.setStatus("Starting Server");
var server = new Server({ var server = new Server({
logger: self.logger, logger: self.logger,
host: options.serverHost, host: options.serverHost,
@ -101,7 +115,7 @@ var Embark = {
server.start(callback); server.start(callback);
}, },
function watchFilesForChanges(callback) { function watchFilesForChanges(callback) {
Embark.monitor.setStatus("Watching for changes"); self.logger.setStatus("Watching for changes");
var watch = new Watch({logger: self.logger}); var watch = new Watch({logger: self.logger});
watch.start(); watch.start();
watch.on('redeploy', function() { watch.on('redeploy', function() {
@ -116,7 +130,7 @@ var Embark = {
callback(); callback();
} }
], function(err, result) { ], function(err, result) {
Embark.monitor.setStatus("Ready".green); self.logger.setStatus("Ready".green);
self.logger.trace("finished".underline); self.logger.trace("finished".underline);
}); });
}, },
@ -215,7 +229,7 @@ var Embark = {
buildDeployGenerate: function(done) { buildDeployGenerate: function(done) {
var self = this; var self = this;
Embark.monitor.setStatus("Deploying...".magenta.underline); self.logger.setStatus("Deploying...".magenta.underline);
async.waterfall([ async.waterfall([
function deployAndBuildContractsManager(callback) { function deployAndBuildContractsManager(callback) {
Embark.buildAndDeploy(function(err, contractsManager) { Embark.buildAndDeploy(function(err, contractsManager) {
@ -237,7 +251,7 @@ var Embark = {
callback(null, abiGenerator.generateABI({useEmbarkJS: true})); callback(null, abiGenerator.generateABI({useEmbarkJS: true}));
}, },
function buildPipeline(abi, callback) { function buildPipeline(abi, callback) {
Embark.monitor.setStatus("Building Assets"); self.logger.setStatus("Building Assets");
var pipeline = new Pipeline({ var pipeline = new Pipeline({
buildDir: self.config.buildDir, buildDir: self.config.buildDir,
contractsFiles: self.config.contractsFiles, contractsFiles: self.config.contractsFiles,
@ -251,9 +265,9 @@ var Embark = {
if (err) { if (err) {
self.logger.error("error deploying"); self.logger.error("error deploying");
self.logger.error(err.message); self.logger.error(err.message);
Embark.monitor.setStatus("Deployment Error".red); self.logger.setStatus("Deployment Error".red);
} else { } else {
Embark.monitor.setStatus("Ready".green); self.logger.setStatus("Ready".green);
} }
done(result); done(result);
}); });

View File

@ -4,8 +4,9 @@ var Logger = function(options) {
this.logLevels = ['error', 'warn', 'info', 'debug', 'trace']; this.logLevels = ['error', 'warn', 'info', 'debug', 'trace'];
this.logLevel = options.logLevel || 'info'; this.logLevel = options.logLevel || 'info';
this.logFunction = options.logFunction || console.log; this.logFunction = options.logFunction || console.log;
this.contractsState = options.contractsState || console.log; this.contractsState = options.contractsState || function() {};
this.availableServices = options.availableServices || console.log; this.availableServices = options.availableServices || function() {};
this.setStatus = options.setStatus || console.log;
}; };
Logger.prototype.error = function(txt) { Logger.prototype.error = function(txt) {