mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-18 16:46:38 +00:00
Dropped 'this' in Cmd and set internal var Embar to self execute
This commit is contained in:
parent
835899cf6e
commit
dc9084b8a6
37
lib/cmd.js
37
lib/cmd.js
@ -1,10 +1,9 @@
|
|||||||
var program = require('commander');
|
var program = require('commander');
|
||||||
var colors = require('colors');
|
var colors = require('colors');
|
||||||
var shelljs = require('shelljs');
|
var shelljs = require('shelljs');
|
||||||
var Embark = require('../lib/index');
|
var Embark = require('../lib/index')();
|
||||||
|
|
||||||
var Cmd = function() {
|
var Cmd = function() {
|
||||||
this.Embark = Embark;
|
|
||||||
program.version(Embark.version);
|
program.version(Embark.version);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -28,7 +27,7 @@ Cmd.prototype.process = function(args) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Cmd.prototype.newApp = function() {
|
Cmd.prototype.newApp = function() {
|
||||||
var self = this;
|
|
||||||
program
|
program
|
||||||
.command('new [name]')
|
.command('new [name]')
|
||||||
.description('new application')
|
.description('new application')
|
||||||
@ -40,32 +39,32 @@ Cmd.prototype.newApp = function() {
|
|||||||
console.log("e.g embark new --help for more information".green);
|
console.log("e.g embark new --help for more information".green);
|
||||||
process.exit(9);
|
process.exit(9);
|
||||||
}
|
}
|
||||||
self.Embark.generateTemplate('boilerplate', './', name);
|
Embark.generateTemplate('boilerplate', './', name);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Cmd.prototype.demo = function() {
|
Cmd.prototype.demo = function() {
|
||||||
var self = this;
|
|
||||||
program
|
program
|
||||||
.command('demo')
|
.command('demo')
|
||||||
.description('create a working dapp with a SimpleStorage contract')
|
.description('create a working dapp with a SimpleStorage contract')
|
||||||
.action(function() {
|
.action(function() {
|
||||||
self.Embark.generateTemplate('demo', './', 'embark_demo');
|
Embark.generateTemplate('demo', './', 'embark_demo');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Cmd.prototype.build = function() {
|
Cmd.prototype.build = function() {
|
||||||
var self = this;
|
|
||||||
program
|
program
|
||||||
.command('build [environment]')
|
.command('build [environment]')
|
||||||
.description('deploy and build dapp at dist/ (default: development)')
|
.description('deploy and build dapp at dist/ (default: development)')
|
||||||
.action(function(env, options) {
|
.action(function(env, options) {
|
||||||
self.Embark.build({env: env || 'development'});
|
Embark.build({env: env || 'development'});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Cmd.prototype.run = function() {
|
Cmd.prototype.run = function() {
|
||||||
var self = this;
|
|
||||||
program
|
program
|
||||||
.command('run [environment]')
|
.command('run [environment]')
|
||||||
.option('-p, --port [port]', 'port to run the dev webserver (default: 8000)')
|
.option('-p, --port [port]', 'port to run the dev webserver (default: 8000)')
|
||||||
@ -75,7 +74,7 @@ Cmd.prototype.run = function() {
|
|||||||
.option('--no-color', 'no colors in case it\'s needed for compatbility purposes')
|
.option('--no-color', 'no colors in case it\'s needed for compatbility purposes')
|
||||||
.description('run dapp (default: development)')
|
.description('run dapp (default: development)')
|
||||||
.action(function(env, options) {
|
.action(function(env, options) {
|
||||||
self.Embark.run({
|
Embark.run({
|
||||||
env: env || 'development',
|
env: env || 'development',
|
||||||
serverPort: options.port,
|
serverPort: options.port,
|
||||||
serverHost: options.host,
|
serverHost: options.host,
|
||||||
@ -86,22 +85,22 @@ Cmd.prototype.run = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Cmd.prototype.blockchain = function() {
|
Cmd.prototype.blockchain = function() {
|
||||||
var self = this;
|
|
||||||
program
|
program
|
||||||
.command('blockchain [environment]')
|
.command('blockchain [environment]')
|
||||||
.option('-c, --client [client]', 'Use a specific ethereum client or simulator (supported: geth, parity, ethersim, testrpc')
|
.option('-c, --client [client]', 'Use a specific ethereum client or simulator (supported: geth, parity, ethersim, testrpc')
|
||||||
.description('run blockchain server (default: development)')
|
.description('run blockchain server (default: development)')
|
||||||
.action(function(env ,options) {
|
.action(function(env ,options) {
|
||||||
self.Embark.initConfig(env || 'development', {
|
Embark.initConfig(env || 'development', {
|
||||||
embarkConfig: 'embark.json',
|
embarkConfig: 'embark.json',
|
||||||
interceptLogs: false
|
interceptLogs: false
|
||||||
});
|
});
|
||||||
self.Embark.blockchain(env || 'development', options.client || 'geth');
|
Embark.blockchain(env || 'development', options.client || 'geth');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Cmd.prototype.simulator = function() {
|
Cmd.prototype.simulator = function() {
|
||||||
var self = this;
|
|
||||||
program
|
program
|
||||||
.command('simulator [environment]')
|
.command('simulator [environment]')
|
||||||
.description('run a fast ethereum rpc simulator')
|
.description('run a fast ethereum rpc simulator')
|
||||||
@ -109,11 +108,11 @@ Cmd.prototype.simulator = function() {
|
|||||||
.option('-p, --port [port]', 'port to run the rpc simulator (default: 8000)')
|
.option('-p, --port [port]', 'port to run the rpc simulator (default: 8000)')
|
||||||
.option('-h, --host [host]', 'host to run the rpc simulator (default: localhost)')
|
.option('-h, --host [host]', 'host to run the rpc simulator (default: localhost)')
|
||||||
.action(function(env, options) {
|
.action(function(env, options) {
|
||||||
self.Embark.initConfig(env || 'development', {
|
Embark.initConfig(env || 'development', {
|
||||||
embarkConfig: 'embark.json',
|
embarkConfig: 'embark.json',
|
||||||
interceptLogs: false
|
interceptLogs: false
|
||||||
});
|
});
|
||||||
self.Embark.simulator({port: options.port, host: options.host});
|
Embark.simulator({port: options.port, host: options.host});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -127,16 +126,16 @@ Cmd.prototype.test = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Cmd.prototype.upload = function() {
|
Cmd.prototype.upload = function() {
|
||||||
var self = this;
|
|
||||||
program
|
program
|
||||||
.command('upload [platform] [environment]')
|
.command('upload [platform] [environment]')
|
||||||
.description('upload your dapp to a decentralized storage. possible options: ipfs, swarm (e.g embark upload swarm)')
|
.description('upload your dapp to a decentralized storage. possible options: ipfs, swarm (e.g embark upload swarm)')
|
||||||
.action(function(platform, env, options) {
|
.action(function(platform, env, options) {
|
||||||
// TODO: get env in cmd line as well
|
// TODO: get env in cmd line as well
|
||||||
self.Embark.initConfig(env || 'development', {
|
Embark.initConfig(env || 'development', {
|
||||||
embarkConfig: 'embark.json', interceptLogs: false
|
embarkConfig: 'embark.json', interceptLogs: false
|
||||||
});
|
});
|
||||||
self.Embark.upload(platform);
|
Embark.upload(platform);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user