#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() {
program
.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)')
.action(function (platform, env, _options) {
// TODO: get env in cmd line as well
embark.initConfig(env || 'development', {
let environment = env || 'development';
embark.initConfig(environment, {
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
upload(platform) {
let options = {
buildDir: 'dist/',
storageConfig: this.config.storageConfig
};
upload(platform, options) {
options.buildDir = 'dist/';
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('swarm', options);
@ -265,11 +272,54 @@ class Embark {
}
if (cmdPlugin) {
cmdPlugin.uploadCmds[0].cb();
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();
callback();
});
// 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 {
console.log(("unknown platform: " + platform).red);
console.log('try "embark upload ipfs" or "embark upload swarm"'.green);
engine.logger.error(("unknown platform: " + platform));
engine.logger.info('try "embark upload ipfs" or "embark upload swarm"'.green);
}
}
runTests(file) {