Skip to content

Commit c53d92b

Browse files
committed
refactor deployments to upload command
1 parent 15b8d9b commit c53d92b

File tree

2 files changed

+21
-27
lines changed

2 files changed

+21
-27
lines changed

lib/cmd.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ Cmd.prototype.process = function(args) {
1414
this.blockchain();
1515
this.simulator();
1616
this.test();
17-
this.ipfs();
18-
this.swarm();
17+
this.upload();
1918
this.otherCommands();
2019
program.parse(args);
2120
};
@@ -138,24 +137,17 @@ Cmd.prototype.test = function() {
138137
});
139138
};
140139

141-
// TODO: replace both of this with a deploy/upload command
142-
Cmd.prototype.ipfs = function() {
140+
Cmd.prototype.upload = function() {
143141
var self = this;
144142
program
145-
.command('ipfs')
146-
.description('deploy to IPFS')
147-
.action(function() {
148-
self.Embark.ipfs();
149-
});
150-
};
151-
152-
Cmd.prototype.swarm = function() {
153-
var self = this;
154-
program
155-
.command('swarm')
156-
.description('deploy to SWARM')
157-
.action(function() {
158-
self.Embark.swarm();
143+
.command('upload [platform]')
144+
.description('upload your dapp to a decentralized storage. possible options: ipfs, swarm (e.g embark upload swarm)')
145+
.action(function(platform ,options) {
146+
// TODO: get env in cmd line as well
147+
self.Embark.initConfig('development', {
148+
embarkConfig: 'embark.json'
149+
});
150+
self.Embark.upload(platform);
159151
});
160152
};
161153

lib/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,17 +302,19 @@ var Embark = {
302302
},
303303

304304
// TODO: should deploy if it hasn't already
305-
ipfs: function() {
306-
var ipfs = new IPFS({buildDir: 'dist/'});
307-
ipfs.deploy();
305+
upload: function(platform) {
306+
if (platform === 'ipfs') {
307+
var ipfs = new IPFS({buildDir: 'dist/'});
308+
ipfs.deploy();
309+
} else if (platform === 'swarm') {
310+
var swarm = new Swarm({buildDir: 'dist/'});
311+
swarm.deploy();
312+
} else {
313+
console.log(("unknown platform: " + platform).red);
314+
console.log('try "embark upload ipfs" or "embark upload swarm"'.green);
315+
}
308316
},
309317

310-
// TODO: should deploy if it hasn't already
311-
swarm: function() {
312-
var swarm = new Swarm({buildDir: 'dist/'});
313-
swarm.deploy();
314-
}
315-
316318
};
317319

318320
module.exports = Embark;

0 commit comments

Comments
 (0)