mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-16 23:57:11 +00:00
Merge pull request #264 from toadkicker/eventing
integration testing fixes
This commit is contained in:
commit
f5cfcae3dd
27
lib/cmd.js
27
lib/cmd.js
@ -3,11 +3,12 @@ let colors = require('colors');
|
|||||||
let shelljs = require('shelljs');
|
let shelljs = require('shelljs');
|
||||||
let promptly = require('promptly');
|
let promptly = require('promptly');
|
||||||
let path = require('path');
|
let path = require('path');
|
||||||
let Embark = require('../lib/index');
|
const Embark = require('../lib/index');
|
||||||
|
let embark = new Embark;
|
||||||
|
|
||||||
class Cmd {
|
class Cmd {
|
||||||
constructor() {
|
constructor() {
|
||||||
program.version(Embark.version);
|
program.version(embark.version);
|
||||||
}
|
}
|
||||||
|
|
||||||
process(args) {
|
process(args) {
|
||||||
@ -56,11 +57,11 @@ class Cmd {
|
|||||||
err.retry();
|
err.retry();
|
||||||
} else {
|
} else {
|
||||||
//slightly different assignment of name since it comes from child prompt
|
//slightly different assignment of name since it comes from child prompt
|
||||||
Embark.generateTemplate('boilerplate', './', inputvalue);
|
embark.generateTemplate('boilerplate', './', inputvalue);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Embark.generateTemplate('boilerplate', './', name);
|
embark.generateTemplate('boilerplate', './', name);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -71,7 +72,7 @@ class Cmd {
|
|||||||
.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 () {
|
||||||
Embark.generateTemplate('demo', './', 'embark_demo');
|
embark.generateTemplate('demo', './', 'embark_demo');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +81,7 @@ class Cmd {
|
|||||||
.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) {
|
||||||
Embark.build({env: env || 'development'});
|
embark.build({env: env || 'development'});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ class Cmd {
|
|||||||
.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) {
|
||||||
Embark.run({
|
embark.run({
|
||||||
env: env || 'development',
|
env: env || 'development',
|
||||||
serverPort: options.port,
|
serverPort: options.port,
|
||||||
serverHost: options.host,
|
serverHost: options.host,
|
||||||
@ -110,11 +111,11 @@ class Cmd {
|
|||||||
.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) {
|
||||||
Embark.initConfig(env || 'development', {
|
embark.initConfig(env || 'development', {
|
||||||
embarkConfig: 'embark.json',
|
embarkConfig: 'embark.json',
|
||||||
interceptLogs: false
|
interceptLogs: false
|
||||||
});
|
});
|
||||||
Embark.blockchain(env || 'development', options.client || 'geth');
|
embark.blockchain(env || 'development', options.client || 'geth');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,11 +127,11 @@ class Cmd {
|
|||||||
.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) {
|
||||||
Embark.initConfig(env || 'development', {
|
embark.initConfig(env || 'development', {
|
||||||
embarkConfig: 'embark.json',
|
embarkConfig: 'embark.json',
|
||||||
interceptLogs: false
|
interceptLogs: false
|
||||||
});
|
});
|
||||||
Embark.simulator({port: options.port, host: options.host});
|
embark.simulator({port: options.port, host: options.host});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,10 +150,10 @@ class Cmd {
|
|||||||
.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
|
||||||
Embark.initConfig(env || 'development', {
|
embark.initConfig(env || 'development', {
|
||||||
embarkConfig: 'embark.json', interceptLogs: false
|
embarkConfig: 'embark.json', interceptLogs: false
|
||||||
});
|
});
|
||||||
Embark.upload(platform);
|
embark.upload(platform);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ let GethCommands = require('./geth_commands.js');
|
|||||||
|
|
||||||
let BlockchainClient = function(blockchainConfig, client, env) {
|
let BlockchainClient = function(blockchainConfig, client, env) {
|
||||||
if (client === 'geth') {
|
if (client === 'geth') {
|
||||||
return new Blockchain({blockchainConfig: blockchainConfig, client: GethCommands, env: env});
|
return new Blockchain({blockchainConfig: blockchainConfig, client: new GethCommands(), env: env});
|
||||||
} else {
|
} else {
|
||||||
throw new Error('unknown client');
|
throw new Error('unknown client');
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ class Blockchain {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static runCommand(cmd) {
|
runCommand(cmd) {
|
||||||
console.log(("running: " + cmd.underline).green);
|
console.log(("running: " + cmd.underline).green);
|
||||||
return shelljs.exec(cmd);
|
return shelljs.exec(cmd);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,8 @@ let async = require('async');
|
|||||||
// TODO: make all of this async
|
// TODO: make all of this async
|
||||||
class GethCommands {
|
class GethCommands {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.config = options.config;
|
this.config = options && options.hasOwnProperty('config') ? options.config : {};
|
||||||
this.env = options.env || 'development';
|
this.env = options && options.hasOwnProperty('env') ? options.env : 'development';
|
||||||
this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
|
this.name = "Go-Ethereum (https://github.com/ethereum/go-ethereum)";
|
||||||
this.geth_bin = this.config.geth_bin || "geth";
|
this.geth_bin = this.config.geth_bin || "geth";
|
||||||
}
|
}
|
||||||
@ -141,7 +141,12 @@ class GethCommands {
|
|||||||
callback(null, '--rpcapi "' + rpc_api.join(',') + '"');
|
callback(null, '--rpcapi "' + rpc_api.join(',') + '"');
|
||||||
},
|
},
|
||||||
function accountToUnlock(callback) {
|
function accountToUnlock(callback) {
|
||||||
let accountAddress = config.account.address || address;
|
let accountAddress = "";
|
||||||
|
if(config.hasOwnProperty('address') && config.account.hasOwnProperty('address')) {
|
||||||
|
accountAddress = config.account.address;
|
||||||
|
} else {
|
||||||
|
accountAddress = address;
|
||||||
|
}
|
||||||
if (accountAddress) {
|
if (accountAddress) {
|
||||||
return callback(null, "--unlock=" + accountAddress);
|
return callback(null, "--unlock=" + accountAddress);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ class Plugins extends EventEmitter {
|
|||||||
//TODO: put an observer on this.plugins and call loadPlugin when a new item is added
|
//TODO: put an observer on this.plugins and call loadPlugin when a new item is added
|
||||||
this.config = {};
|
this.config = {};
|
||||||
|
|
||||||
const loadPlugins = this.load;
|
|
||||||
for (let opt in options) {
|
for (let opt in options) {
|
||||||
if (options.hasOwnProperty(opt)) {
|
if (options.hasOwnProperty(opt)) {
|
||||||
this.config[opt] = options[opt];
|
this.config[opt] = options[opt];
|
||||||
@ -44,10 +43,18 @@ class Plugins extends EventEmitter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadPlugins () {
|
||||||
|
return this.load();
|
||||||
|
}
|
||||||
|
|
||||||
listPlugins() {
|
listPlugins() {
|
||||||
return this.config.plugins.join(', ');
|
return this.config.plugins.join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPluginsFor(pluginType, plugins) {
|
||||||
|
return getPluginsFor(pluginType, plugins);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Plugins;
|
module.exports = Plugins;
|
371
lib/index.js
371
lib/index.js
@ -4,204 +4,197 @@ let async = require('async');
|
|||||||
|
|
||||||
let colors = require('colors');
|
let colors = require('colors');
|
||||||
|
|
||||||
|
let Engine = require('./core/engine.js');
|
||||||
|
|
||||||
let IPFS = require('./upload/ipfs.js');
|
let IPFS = require('./upload/ipfs.js');
|
||||||
let Swarm = require('./upload/swarm.js');
|
let Swarm = require('./upload/swarm.js');
|
||||||
|
|
||||||
let EventEmitter = require('events').EventEmitter;
|
let version = require('../package.json').version;
|
||||||
let Config = require('./core/config');
|
|
||||||
/**
|
|
||||||
* Initialize a new `Embark` instance.
|
|
||||||
*
|
|
||||||
* @return {Embark}
|
|
||||||
* @api public
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Embark {
|
const EventEmitter = require('events').EventEmitter;
|
||||||
constructor(options) {
|
|
||||||
this.version = require('../package.json').version;
|
|
||||||
|
|
||||||
this.env = options.environment || options.env || "development";
|
class Embark extends EventEmitter {
|
||||||
|
|
||||||
this.config = new Config({env: this.env, logger: this.logger, events: this.events});
|
constructor (options) {
|
||||||
|
super();
|
||||||
|
this.version = version;
|
||||||
|
this.options = options || {};
|
||||||
|
}
|
||||||
|
|
||||||
|
initConfig(env, options) {
|
||||||
|
let Events = require('./core/events.js');
|
||||||
|
let Logger = require('./core/logger.js');
|
||||||
|
let Config = require('./core/config.js');
|
||||||
|
|
||||||
|
this.events = new Events();
|
||||||
|
this.logger = new Logger({logLevel: 'debug'});
|
||||||
|
|
||||||
|
this.config = new Config({env: env, logger: this.logger, events: this.events});
|
||||||
this.config.loadConfigFiles(options);
|
this.config.loadConfigFiles(options);
|
||||||
this.plugins = this.config.plugins;
|
this.plugins = this.config.plugins;
|
||||||
|
|
||||||
this.blockchain = function (env, client) {
|
|
||||||
return require('./cmds/blockchain/blockchain.js')(Embark.prototype.config.blockchainConfig, client, env).run();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.simulator = function (options) {
|
|
||||||
let Simulator = require('./cmds/simulator.js');
|
|
||||||
let simulator = new Simulator({blockchainConfig: Embark.prototype.config.blockchainConfig});
|
|
||||||
simulator.run(options);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.generateTemplate = function (templateName, destinationFolder, name) {
|
|
||||||
let TemplateGenerator = require('./cmds/template_generator.js');
|
|
||||||
let templateGenerator = new TemplateGenerator(templateName);
|
|
||||||
templateGenerator.generate(destinationFolder, name);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.run = function (options) {
|
|
||||||
let Dashboard = require('./dashboard/dashboard.js');
|
|
||||||
let Engine = require('./core/engine');
|
|
||||||
let engine = new Engine({
|
|
||||||
env: options.env,
|
|
||||||
embarkConfig: options.embarkConfig || 'embark.json'
|
|
||||||
});
|
|
||||||
|
|
||||||
engine.init();
|
|
||||||
|
|
||||||
if (!options.useDashboard) {
|
|
||||||
console.log('========================'.bold.green);
|
|
||||||
console.log(('Welcome to Embark ' + Embark.version).yellow.bold);
|
|
||||||
console.log('========================'.bold.green);
|
|
||||||
}
|
|
||||||
|
|
||||||
async.parallel([
|
|
||||||
function startDashboard(callback) {
|
|
||||||
if (!options.useDashboard) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
|
|
||||||
let dashboard = new Dashboard({
|
|
||||||
logger: engine.logger,
|
|
||||||
plugins: engine.plugins,
|
|
||||||
version: engine.version,
|
|
||||||
env: engine.env
|
|
||||||
});
|
|
||||||
dashboard.start(function () {
|
|
||||||
Embark.on('abi-vanila', function (abi) {
|
|
||||||
dashboard.console.runCode(abi);
|
|
||||||
});
|
|
||||||
|
|
||||||
engine.logger.info('dashboard start');
|
|
||||||
Embark.on('servicesState', function (servicesState) {
|
|
||||||
dashboard.monitor.availableServices(servicesState);
|
|
||||||
});
|
|
||||||
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function (callback) {
|
|
||||||
let pluginList = engine.plugins.listPlugins();
|
|
||||||
if (pluginList.length > 0) {
|
|
||||||
engine.logger.info("loaded plugins: " + pluginList.join(", "));
|
|
||||||
}
|
|
||||||
|
|
||||||
engine.startMonitor();
|
|
||||||
engine.startService("web3");
|
|
||||||
engine.startService("pipeline");
|
|
||||||
engine.startService("abi");
|
|
||||||
engine.startService("deployment");
|
|
||||||
engine.startService("ipfs");
|
|
||||||
|
|
||||||
Embark.on('check:backOnline:Ethereum', function () {
|
|
||||||
engine.logger.info('Ethereum node detected..');
|
|
||||||
engine.config.reloadConfig();
|
|
||||||
engine.deployManager.deployContracts(function () {
|
|
||||||
engine.logger.info('Deployment Done');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
engine.deployManager.deployContracts(function (err) {
|
|
||||||
engine.startService("fileWatcher");
|
|
||||||
if (options.runWebserver) {
|
|
||||||
engine.startService("webServer", {
|
|
||||||
host: options.serverHost,
|
|
||||||
port: options.serverPort
|
|
||||||
});
|
|
||||||
}
|
|
||||||
callback(err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
], function (err, result) {
|
|
||||||
if (err) {
|
|
||||||
engine.logger.error(err.message);
|
|
||||||
engine.logger.info(err.stack);
|
|
||||||
} else {
|
|
||||||
engine.logger.setStatus("Ready".green);
|
|
||||||
engine.logger.info("Looking for documentation? you can find it at ".cyan + "http://embark.readthedocs.io/".green.underline);
|
|
||||||
engine.logger.info("Ready".underline);
|
|
||||||
engine.events.emit('firstDeploymentDone');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.build = function (options) {
|
|
||||||
let Engine = require('./core/engine');
|
|
||||||
|
|
||||||
let engine = new Engine({
|
|
||||||
env: options.env,
|
|
||||||
embarkConfig: 'embark.json',
|
|
||||||
interceptLogs: false
|
|
||||||
});
|
|
||||||
engine.init();
|
|
||||||
|
|
||||||
async.waterfall([
|
|
||||||
function startServices(callback) {
|
|
||||||
let pluginList = engine.plugins.listPlugins();
|
|
||||||
if (pluginList.length > 0) {
|
|
||||||
engine.logger.info("loaded plugins: " + pluginList.join(", "));
|
|
||||||
}
|
|
||||||
|
|
||||||
engine.startService("web3");
|
|
||||||
engine.startService("pipeline");
|
|
||||||
engine.startService("abi");
|
|
||||||
engine.startService("deployment");
|
|
||||||
callback();
|
|
||||||
},
|
|
||||||
function deploy(callback) {
|
|
||||||
engine.deployManager.deployContracts(function (err) {
|
|
||||||
callback(err);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
], function (err, result) {
|
|
||||||
if (err) {
|
|
||||||
engine.logger.error(err.message);
|
|
||||||
engine.logger.debug(err.stack);
|
|
||||||
} else {
|
|
||||||
engine.logger.info("finished building".underline);
|
|
||||||
}
|
|
||||||
// needed due to child processes
|
|
||||||
process.exit();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.initTests = function () {
|
|
||||||
let Test = require('./core/test.js');
|
|
||||||
return new Test(options);
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: should deploy if it hasn't already
|
|
||||||
this.upload = function (platform) {
|
|
||||||
if (platform === 'ipfs') {
|
|
||||||
let ipfs = new IPFS({
|
|
||||||
buildDir: 'dist/',
|
|
||||||
plugins: Embark.prototype.plugins,
|
|
||||||
storageConfig: Embark.prototype.config.storageConfig
|
|
||||||
});
|
|
||||||
ipfs.deploy();
|
|
||||||
} else if (platform === 'swarm') {
|
|
||||||
let swarm = new Swarm({
|
|
||||||
buildDir: 'dist/',
|
|
||||||
plugins: Embark.prototype.plugins,
|
|
||||||
storageConfig: Embark.prototype.config.storageConfig
|
|
||||||
});
|
|
||||||
swarm.deploy();
|
|
||||||
} else {
|
|
||||||
console.log(("unknown platform: " + platform).red);
|
|
||||||
console.log('try "embark upload ipfs" or "embark upload swarm"'.green);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!(this instanceof Embark)) {
|
|
||||||
return new Embark();
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockchain(env, client) {
|
||||||
|
return require('./cmds/blockchain/blockchain.js')(this.config.blockchainConfig, client, env).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
simulator(options) {
|
||||||
|
let Simulator = require('./cmds/simulator.js');
|
||||||
|
let simulator = new Simulator({blockchainConfig: this.config.blockchainConfig});
|
||||||
|
simulator.run(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
generateTemplate(templateName, destinationFolder, name) {
|
||||||
|
let TemplateGenerator = require('./cmds/template_generator.js');
|
||||||
|
let templateGenerator = new TemplateGenerator(templateName);
|
||||||
|
templateGenerator.generate(destinationFolder, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
run(options) {
|
||||||
|
let Dashboard = require('./dashboard/dashboard.js');
|
||||||
|
|
||||||
|
let env = options.env;
|
||||||
|
|
||||||
|
let engine = new Engine({
|
||||||
|
env: options.env,
|
||||||
|
embarkConfig: options.embarkConfig || 'embark.json'
|
||||||
|
});
|
||||||
|
engine.init();
|
||||||
|
|
||||||
|
if (!options.useDashboard) {
|
||||||
|
console.log('========================'.bold.green);
|
||||||
|
console.log(('Welcome to Embark ' + Embark.version).yellow.bold);
|
||||||
|
console.log('========================'.bold.green);
|
||||||
|
}
|
||||||
|
|
||||||
|
async.parallel([
|
||||||
|
function startDashboard(callback) {
|
||||||
|
if (!options.useDashboard) {
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
let dashboard = new Dashboard({
|
||||||
|
logger: engine.logger,
|
||||||
|
plugins: engine.plugins,
|
||||||
|
version: engine.version,
|
||||||
|
env: engine.env
|
||||||
|
});
|
||||||
|
dashboard.start(function () {
|
||||||
|
engine.events.on('abi-vanila', function (abi) {
|
||||||
|
dashboard.console.runCode(abi);
|
||||||
|
});
|
||||||
|
|
||||||
|
engine.logger.info('dashboard start');
|
||||||
|
engine.events.on('servicesState', function (servicesState) {
|
||||||
|
dashboard.monitor.availableServices(servicesState);
|
||||||
|
});
|
||||||
|
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function (callback) {
|
||||||
|
let pluginList = engine.plugins.listPlugins();
|
||||||
|
if (pluginList.length > 0) {
|
||||||
|
engine.logger.info("loaded plugins: " + pluginList.join(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
engine.startMonitor();
|
||||||
|
engine.startService("web3");
|
||||||
|
engine.startService("pipeline");
|
||||||
|
engine.startService("abi");
|
||||||
|
engine.startService("deployment");
|
||||||
|
engine.startService("ipfs");
|
||||||
|
|
||||||
|
engine.events.on('check:backOnline:Ethereum', function () {
|
||||||
|
engine.logger.info('Ethereum node detected..');
|
||||||
|
engine.config.reloadConfig();
|
||||||
|
engine.deployManager.deployContracts(function () {
|
||||||
|
engine.logger.info('Deployment Done');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
engine.deployManager.deployContracts(function (err) {
|
||||||
|
engine.startService("fileWatcher");
|
||||||
|
if (options.runWebserver) {
|
||||||
|
engine.startService("webServer", {
|
||||||
|
host: options.serverHost,
|
||||||
|
port: options.serverPort
|
||||||
|
});
|
||||||
|
}
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
], function (err, result) {
|
||||||
|
if (err) {
|
||||||
|
engine.logger.error(err.message);
|
||||||
|
engine.logger.info(err.stack);
|
||||||
|
} else {
|
||||||
|
engine.logger.setStatus("Ready".green);
|
||||||
|
engine.logger.info("Looking for documentation? you can find it at ".cyan + "http://embark.readthedocs.io/".green.underline);
|
||||||
|
engine.logger.info("Ready".underline);
|
||||||
|
engine.events.emit('firstDeploymentDone');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
build(options) {
|
||||||
|
|
||||||
|
let engine = new Engine({
|
||||||
|
env: options.env,
|
||||||
|
embarkConfig: 'embark.json',
|
||||||
|
interceptLogs: false
|
||||||
|
});
|
||||||
|
engine.init();
|
||||||
|
|
||||||
|
async.waterfall([
|
||||||
|
function startServices(callback) {
|
||||||
|
let pluginList = engine.plugins.listPlugins();
|
||||||
|
if (pluginList.length > 0) {
|
||||||
|
engine.logger.info("loaded plugins: " + pluginList.join(", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
engine.startService("web3");
|
||||||
|
engine.startService("pipeline");
|
||||||
|
engine.startService("abi");
|
||||||
|
engine.startService("deployment");
|
||||||
|
callback();
|
||||||
|
},
|
||||||
|
function deploy(callback) {
|
||||||
|
engine.deployManager.deployContracts(function (err) {
|
||||||
|
callback(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
], function (err, result) {
|
||||||
|
if (err) {
|
||||||
|
engine.logger.error(err.message);
|
||||||
|
engine.logger.debug(err.stack);
|
||||||
|
} else {
|
||||||
|
engine.logger.info("finished building".underline);
|
||||||
|
}
|
||||||
|
// needed due to child processes
|
||||||
|
process.exit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initTests(options) {
|
||||||
|
let Test = require('./core/test.js');
|
||||||
|
return new Test(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: should deploy if it hasn't already
|
||||||
|
upload(platform) {
|
||||||
|
if (platform === 'ipfs') {
|
||||||
|
let ipfs = new IPFS({buildDir: 'dist/', plugins: this.plugins, storageConfig: this.config.storageConfig});
|
||||||
|
ipfs.deploy();
|
||||||
|
} else if (platform === 'swarm') {
|
||||||
|
let swarm = new Swarm({buildDir: 'dist/', plugins: this.plugins, storageConfig: this.config.storageConfig});
|
||||||
|
swarm.deploy();
|
||||||
|
} else {
|
||||||
|
console.log(("unknown platform: " + platform).red);
|
||||||
|
console.log('try "embark upload ipfs" or "embark upload swarm"'.green);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Embark.prototype = Object.create(EventEmitter.prototype);
|
|
||||||
|
|
||||||
module.exports = Embark;
|
module.exports = Embark;
|
||||||
|
@ -11,7 +11,7 @@ describe('embark.Blockchain', function () {
|
|||||||
//let client = new Client();
|
//let client = new Client();
|
||||||
|
|
||||||
describe('with empty config', function () {
|
describe('with empty config', function () {
|
||||||
it('should have a default config', function () {
|
it('should have a default config', function (done) {
|
||||||
let config = {
|
let config = {
|
||||||
networkType: 'custom',
|
networkType: 'custom',
|
||||||
genesisBlock: false,
|
genesisBlock: false,
|
||||||
@ -35,11 +35,12 @@ describe('embark.Blockchain', function () {
|
|||||||
let blockchain = new Blockchain(config, 'geth');
|
let blockchain = new Blockchain(config, 'geth');
|
||||||
|
|
||||||
assert.deepEqual(blockchain.config, config);
|
assert.deepEqual(blockchain.config, config);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('with config', function () {
|
describe('with config', function () {
|
||||||
it('should take config params', function () {
|
it('should take config params', function (done) {
|
||||||
let config = {
|
let config = {
|
||||||
networkType: 'livenet',
|
networkType: 'livenet',
|
||||||
genesisBlock: 'foo/bar/genesis.json',
|
genesisBlock: 'foo/bar/genesis.json',
|
||||||
@ -63,6 +64,7 @@ describe('embark.Blockchain', function () {
|
|||||||
let blockchain = new Blockchain(config, 'geth');
|
let blockchain = new Blockchain(config, 'geth');
|
||||||
|
|
||||||
assert.deepEqual(blockchain.config, config);
|
assert.deepEqual(blockchain.config, config);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user