2016-10-02 21:04:22 +00:00
|
|
|
var colors = require('colors');
|
2015-06-28 02:20:07 +00:00
|
|
|
|
2016-10-02 21:04:22 +00:00
|
|
|
var IPFS = function(options) {
|
|
|
|
this.options = options;
|
|
|
|
this.buildDir = options.buildDir || 'dist/';
|
|
|
|
};
|
|
|
|
|
|
|
|
IPFS.prototype.deploy = function() {
|
|
|
|
var ipfs_bin = exec('which ipfs').output.split("\n")[0];
|
2015-06-28 02:20:07 +00:00
|
|
|
|
2016-01-11 14:54:02 +00:00
|
|
|
if (ipfs_bin==='ipfs not found'){
|
2016-10-02 21:04:22 +00:00
|
|
|
console.log('=== WARNING: IPFS not in an executable path. Guessing ~/go/bin/ipfs for path'.yellow);
|
2016-01-11 14:54:02 +00:00
|
|
|
ipfs_bin = "~/go/bin/ipfs";
|
|
|
|
}
|
|
|
|
|
2016-10-02 21:04:22 +00:00
|
|
|
var cmd = ipfs_bin + " add -r " + build_dir;
|
|
|
|
console.log(("=== adding " + cmd + " to ipfs").green);
|
2015-06-28 02:20:07 +00:00
|
|
|
|
2016-10-02 21:04:22 +00:00
|
|
|
var result = exec(cmd);
|
|
|
|
var rows = result.output.split("\n");
|
|
|
|
var dir_row = rows[rows.length - 2];
|
|
|
|
var dir_hash = dir_row.split(" ")[1];
|
2015-06-28 02:20:07 +00:00
|
|
|
|
2016-10-02 21:04:22 +00:00
|
|
|
console.log(("=== DApp available at http://localhost:8080/ipfs/" + dir_hash + "/").green);
|
|
|
|
console.log(("=== DApp available at http://gateway.ipfs.io/ipfs/" + dir_hash + "/").green);
|
|
|
|
};
|
2015-06-28 02:20:07 +00:00
|
|
|
|
2016-10-02 21:04:22 +00:00
|
|
|
module.exports = IPFS;
|
2016-10-02 20:58:52 +00:00
|
|
|
|