Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IPFS provider options to ipscend.json #110

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ ipscend
> Web Application publishing, simple and distributed with IPFS

## Usage
[![how2deploy](https://img.youtube.com/vi/_GE3t6XzfBk/0.jpg)](https://www.youtube.com/watch?v=_GE3t6XzfBk)


Install via npm

```
$ npm install ipscend --global
$ npm install alexstep/ipscend --global
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like to merge efforts? :)

```

Run the CLI to show the available commands
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ipscend",
"version": "0.4.3",
"version": "0.4.4",
"description": "Web Application publishing made simple and distributed with IPFS ",
"bin": {
"ipscend": "src/cli/bin.js",
Expand Down
6 changes: 6 additions & 0 deletions src/cli/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ module.exports = Command.extend({

function bootstrap () {
var config = {
provider:{
host: 'ipfs.infura.io',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Infura have R+W nodes always available?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diasdavid yes, infura has good uptime http://status.infura.io/2286441

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is default config, for users can install and use, they allways can change provider in ipscend.json

__host: 'localhost',
port: '5001',
opts: { protocol:'https' }
},
versions: []
}
console.log('This utility will walk you through creating a ipscend.json file.')
Expand Down
32 changes: 27 additions & 5 deletions src/cli/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ module.exports = Command.extend({

function publish () {
const config = require(configPath)
const ipfs = ipfsAPI('localhost', '5001')

let host = config.provider.host || 'ipfs.infura.io'
let port = config.provider.port || '5001'
let opts = config.provider.opts || { protocol:'https' }

const ipfs = ipfsAPI(host, port, opts)

ipfs.util.addFromFs(config.path, {
recursive: true,
Expand All @@ -30,16 +35,26 @@ module.exports = Command.extend({
return console.error('err', err)
}

console.log()
console.log('Uploaded files:')
console.log(res)

const hash = res[res.length - 2].hash
console.log()
console.log()
let hash = ''
for(let k in res){
if (res[k].path==config.path) {
hash = res[k].hash
}
}

const duplicate = config.versions.filter(function (v) {
return v.hash === hash
})[0]

if (duplicate) {
console.log('This version (' + duplicate.hash + ') has already been published on:', duplicate.timestamp)
console.log('You can access it by url http://ipfs.io/ipfs/' + duplicate.hash)
console.log()
return
}

Expand All @@ -50,8 +65,15 @@ module.exports = Command.extend({

console.log('Published', config.path, 'with the following hash:', version.hash)
console.log('You can access it through your local node or through a public IPFS gateway:')
console.log('http://localhost:8080/ipfs/' + version.hash)
console.log('http://ipfs.io/ipfs/' + version.hash)

if (config.provider.host=='localhost') {
console.log('http://'+config.provider.host+':8080/ipfs/' + version.hash)
}

console.log('https://ipfs.io/ipfs/' + version.hash)
console.log(' OR ')
console.log('https://ipfs.infura.io/ipfs/' + version.hash)
console.log()

config.versions.push(version)

Expand Down