#156326148 Build contracts and dapp before upload.

This commit is contained in:
Eric Mastro 2018-04-12 20:46:04 +10:00 committed by emizzle
parent f9b7f5c034
commit 6b7af4b647
2 changed files with 63 additions and 11 deletions

View File

@ -170,13 +170,15 @@ class Cmd {
upload() { upload() {
program program
.command('upload [platform] [environment]') .command('upload [platform] [environment]')
.option('--logfile [logfile]', 'filename to output logs (default: none)')
.description('upload your dapp to a decentralized storage (e.g embark upload ipfs)') .description('upload your dapp to a decentralized storage (e.g embark upload ipfs)')
.action(function (platform, env, _options) { .action(function (platform, env, _options) {
// TODO: get env in cmd line as well let environment = env || 'development';
embark.initConfig(env || 'development', { embark.initConfig(environment, {
embarkConfig: 'embark.json', interceptLogs: false embarkConfig: 'embark.json', interceptLogs: false
}); });
embark.upload(platform); _options.env = environment;
embark.upload(platform, _options);
}); });
} }

View File

@ -247,11 +247,18 @@ class Embark {
} }
// TODO: should deploy if it hasn't already // TODO: should deploy if it hasn't already
upload(platform) { upload(platform, options) {
let options = {
buildDir: 'dist/', options.buildDir = 'dist/';
storageConfig: this.config.storageConfig options.storageConfig = this.config.storageConfig;
};
let engine = new Engine({
env: options.env,
version: this.version,
embarkConfig: options.embarkConfig || 'embark.json',
logfile: options.logfile
});
engine.init();
this.plugins.loadInternalPlugin('ipfs', options); this.plugins.loadInternalPlugin('ipfs', options);
this.plugins.loadInternalPlugin('swarm', options); this.plugins.loadInternalPlugin('swarm', options);
@ -265,11 +272,54 @@ class Embark {
} }
if (cmdPlugin) { if (cmdPlugin) {
async.waterfall([
function buildDapp(callback){
engine.logger.debug('building dapp...');
engine.startMonitor();
engine.startService("libraryManager");
engine.startService("web3");
engine.startService("pipeline");
engine.startService("codeGenerator");
engine.startService("deployment");
engine.startService("ipfs");
engine.events.on('outputDone', function () {
engine.logger.debug('deploying...');
cmdPlugin.uploadCmds[0].cb(); cmdPlugin.uploadCmds[0].cb();
} else { callback();
console.log(("unknown platform: " + platform).red); });
console.log('try "embark upload ipfs" or "embark upload swarm"'.green);
// build the contracts
engine.contractsManager.build(function(){
// trigger code generation and dapp webpack
engine.events.emit('asset-changed', engine.contractsManager);
});
},
function upload(callback){
callback();
} }
], function (err, _result) {
if (err) {
engine.logger.error(err.message);
engine.logger.debug(err.stack);
} else {
engine.logger.info("finished building dapp and deploying to " + platform.underline);
}
// needed due to child processes
process.exit();
});
} else {
engine.logger.error(("unknown platform: " + platform));
engine.logger.info('try "embark upload ipfs" or "embark upload swarm"'.green);
}
} }
runTests(file) { runTests(file) {