refactor deployments to upload command

This commit is contained in:
Iuri Matias 2017-01-07 20:37:48 -05:00
parent 15b8d9b33e
commit c53d92baa5
2 changed files with 21 additions and 27 deletions

View File

@ -14,8 +14,7 @@ Cmd.prototype.process = function(args) {
this.blockchain(); this.blockchain();
this.simulator(); this.simulator();
this.test(); this.test();
this.ipfs(); this.upload();
this.swarm();
this.otherCommands(); this.otherCommands();
program.parse(args); program.parse(args);
}; };
@ -138,24 +137,17 @@ Cmd.prototype.test = function() {
}); });
}; };
// TODO: replace both of this with a deploy/upload command Cmd.prototype.upload = function() {
Cmd.prototype.ipfs = function() {
var self = this; var self = this;
program program
.command('ipfs') .command('upload [platform]')
.description('deploy to IPFS') .description('upload your dapp to a decentralized storage. possible options: ipfs, swarm (e.g embark upload swarm)')
.action(function() { .action(function(platform ,options) {
self.Embark.ipfs(); // TODO: get env in cmd line as well
}); self.Embark.initConfig('development', {
}; embarkConfig: 'embark.json'
});
Cmd.prototype.swarm = function() { self.Embark.upload(platform);
var self = this;
program
.command('swarm')
.description('deploy to SWARM')
.action(function() {
self.Embark.swarm();
}); });
}; };

View File

@ -302,17 +302,19 @@ var Embark = {
}, },
// TODO: should deploy if it hasn't already // TODO: should deploy if it hasn't already
ipfs: function() { upload: function(platform) {
var ipfs = new IPFS({buildDir: 'dist/'}); if (platform === 'ipfs') {
ipfs.deploy(); var ipfs = new IPFS({buildDir: 'dist/'});
ipfs.deploy();
} else if (platform === 'swarm') {
var swarm = new Swarm({buildDir: 'dist/'});
swarm.deploy();
} else {
console.log(("unknown platform: " + platform).red);
console.log('try "embark upload ipfs" or "embark upload swarm"'.green);
}
}, },
// TODO: should deploy if it hasn't already
swarm: function() {
var swarm = new Swarm({buildDir: 'dist/'});
swarm.deploy();
}
}; };
module.exports = Embark; module.exports = Embark;