From fe70b6517edec8db0c6f84fa1715a82028507104 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Fri, 11 Dec 2015 19:43:35 +0100 Subject: [PATCH] wip ipfsd-ctl usage impl --- gulpfile.js | 37 ++++++++++++++++++++++++++++++++----- package.json | 1 + 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 3b43d95..3ab9bd8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,7 @@ var webpack = require('webpack-stream') var clean = require('gulp-clean') var connect = require('gulp-connect') var ghPages = require('gulp-gh-pages') +var ipfsd = require('ipfsd-ctl') var config = { files: { @@ -15,6 +16,12 @@ var config = { dest: 'webapp/dist/' } +var server = { + root: config.dest, + port: 9090, + livereload: true +} + gulp.task('watch',['clean'],function(){ var cfg = require('./webpack.config.js') cfg.watch = true @@ -36,11 +43,7 @@ gulp.task('clean',function(){ }) gulp.task('server',function(){ - connect.server({ - root: config.dest, - port: 9090, - livereload: true - }) + connect.server(server) }) gulp.task('gh-pages',[ 'build' ],function(){ @@ -48,6 +51,30 @@ gulp.task('gh-pages',[ 'build' ],function(){ .pipe(ghPages()) }) +gulp.task('ipfs', function(done){ + console.log(server.port) + //'API.HTTPHeaders.Access-Control-Allow-Origin': '*' + var opt = { + 'Addresses.API': '/ip4/127.0.0.1/tcp/5001', + 'API': { + 'HTTPHeaders': { + 'Access-Control-Allow-Origin': [ + '*' + ] + } + } + } + console.log(opt) + ipfsd.disposableApi(opt,(err, ipfs) => { + ipfs.id(function (err, id) { + if(err) return console.log('Failed to start IPFS:',err) + console.log('Started IPFS Daemon') + //done() + }) + }) +}) + gulp.task('serve', [ 'watch', 'server' ]) +gulp.task('serve-with-ipfs', [ 'serve', 'ipfs' ]) gulp.task('default', [ 'build' ]) diff --git a/package.json b/package.json index 2ba274b..369afec 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "html-loader": "^0.4.0", "html-webpack-plugin": "~1.7.0", "ipfs-api": "2.9.13", + "ipfsd-ctl": "^0.6.3", "json-loader": "~0.5.4", "lodash.sortedindex": "~3.1.1", "markdown-loader": "^0.1.7",