refactor deployments to upload command
This commit is contained in:
parent
15b8d9b33e
commit
c53d92baa5
28
lib/cmd.js
28
lib/cmd.js
|
@ -14,8 +14,7 @@ Cmd.prototype.process = function(args) {
|
|||
this.blockchain();
|
||||
this.simulator();
|
||||
this.test();
|
||||
this.ipfs();
|
||||
this.swarm();
|
||||
this.upload();
|
||||
this.otherCommands();
|
||||
program.parse(args);
|
||||
};
|
||||
|
@ -138,24 +137,17 @@ Cmd.prototype.test = function() {
|
|||
});
|
||||
};
|
||||
|
||||
// TODO: replace both of this with a deploy/upload command
|
||||
Cmd.prototype.ipfs = function() {
|
||||
Cmd.prototype.upload = function() {
|
||||
var self = this;
|
||||
program
|
||||
.command('ipfs')
|
||||
.description('deploy to IPFS')
|
||||
.action(function() {
|
||||
self.Embark.ipfs();
|
||||
});
|
||||
};
|
||||
|
||||
Cmd.prototype.swarm = function() {
|
||||
var self = this;
|
||||
program
|
||||
.command('swarm')
|
||||
.description('deploy to SWARM')
|
||||
.action(function() {
|
||||
self.Embark.swarm();
|
||||
.command('upload [platform]')
|
||||
.description('upload your dapp to a decentralized storage. possible options: ipfs, swarm (e.g embark upload swarm)')
|
||||
.action(function(platform ,options) {
|
||||
// TODO: get env in cmd line as well
|
||||
self.Embark.initConfig('development', {
|
||||
embarkConfig: 'embark.json'
|
||||
});
|
||||
self.Embark.upload(platform);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
20
lib/index.js
20
lib/index.js
|
@ -302,17 +302,19 @@ var Embark = {
|
|||
},
|
||||
|
||||
// TODO: should deploy if it hasn't already
|
||||
ipfs: function() {
|
||||
var ipfs = new IPFS({buildDir: 'dist/'});
|
||||
ipfs.deploy();
|
||||
upload: function(platform) {
|
||||
if (platform === 'ipfs') {
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue