-
Notifications
You must be signed in to change notification settings - Fork 30
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
A buuunch of stuff #7
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
tmp | ||
node_modules | ||
go-ipfs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,24 @@ | ||
# install go-ipfs from npm | ||
Install go-ipfs from npm as a dependency of your project | ||
======================================================== | ||
|
||
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) [![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) [![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) [![Dependency Status](https://david-dm.org/ipfs/npm-go-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/npm-go-ipfs) | ||
|
||
Install the latest [go-ipfs](https://github.com/ipfs/go-ipfs/) binary. | ||
|
||
``` | ||
npm install -g go-ipfs | ||
``` | ||
|
||
Installs from [https://gobuilder.me/github.com/ipfs/go-ipfs/cmd/ipfs](https://gobuilder.me/github.com/ipfs/go-ipfs/cmd/ipfs). | ||
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) | ||
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) | ||
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) | ||
[![Dependency Status](https://david-dm.org/ipfs/npm-go-ipfs.svg?style=flat-square)](https://david-dm.org/ipfs/npm-go-ipfs) | ||
|
||
> Install the latest [go-ipfs](https://github.com/ipfs/go-ipfs/) binary from [http://dist.ipfs.io](http://dist.ipfs.io) | ||
|
||
## Usage | ||
# Installation | ||
|
||
```sh | ||
> npm install -g go-ipfs | ||
> ipfs version | ||
ipfs version 0.3.11 | ||
|
||
> npm install go-ipfs | ||
> node_modules/.bin/ipfs | ||
ipfs version 0.3.11 | ||
``` | ||
npm install go-ipfs --save | ||
``` | ||
|
||
See [IPFS getting-started](http://ipfs.io/docs/getting-started). If anything goes wrong, try using: [http://ipfs.io/docs/install](http://ipfs.io/docs/install). | ||
|
||
Warning: this module uses the _latest_ version of ipfs. If there is a strong need to vendor an older version, let us know. We care about versions very much :( but for a number of reasons, this is easier for us all right now. | ||
|
||
Note: this module uses the _latest_ version of ipfs. If there is a strong need to vendor an older version, let us know. We care about versions very much, but for a number of reasons, this is easier for us all right now. | ||
|
||
## Development | ||
|
||
**Warning**: the file `bin/ipfs` is a placeholder, when downloading stuff, it gets replaced. so if you run `node install.js` it will then be dirty in the git repo. **Do not commit this file**, as then you would be commiting a big binary and publishing it to npm. (**TODO: add a pre-commit or pre-publish hook that warns about this**) | ||
|
||
### Publish a new version | ||
|
||
You should be able to just run `./publish.sh` for example: | ||
|
||
```sh | ||
> ./publish.sh | ||
usage ./publish.sh <version> | ||
publish a version of go-ipfs to npm | ||
|
||
> ./publish.sh 0.3.11 | ||
``` | ||
|
||
This will: | ||
|
||
- check the version is indeed a tag in https://github.com/ipfs/go-ipfs | ||
- check the size of `bin/ipfs` is right (must be the checked in file) | ||
- update the version numbers in `package.json` and `README.md` | ||
- `git commit` the changes | ||
- push to https://github.com/ipfs/npm-go-ipfs | ||
- publish to `go-ipfs@$version` to https://npmjs.com/package/go-ipfs | ||
|
||
Open an issue in the repo if you run into trouble. | ||
**Warning**: The binary gets put in the `go-ipfs` folder inside the module folder. |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env node | ||
require('./')(function () {}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
var path = require('path') | ||
var goenv = require('go-platform') | ||
var version = require('./../package.json').version | ||
var request = require('request') | ||
var gunzip = require('gunzip-maybe') | ||
var tarFS = require('tar-fs') | ||
|
||
module.exports = function (callback) { | ||
checkPlatform(goenv) // make sure we can do this. | ||
|
||
// hacky hack hack to work around unpublishability | ||
version = version.replace(/-[0-9]+/, '') | ||
|
||
var filename = 'ipfs_v' + version + '_' + goenv.GOOS + '-' + goenv.GOARCH + '.tar.gz' | ||
var url = 'http://dist.ipfs.io/go-ipfs/v' + version + '/go-' + filename | ||
|
||
var installPath = path.resolve(__dirname, '..') | ||
|
||
request | ||
.get(url) | ||
.pipe(gunzip()) | ||
.pipe( | ||
tarFS | ||
.extract(installPath) | ||
.on('finish', callback) | ||
) | ||
|
||
function checkPlatform (goenv) { | ||
switch (goenv.GOOS) { | ||
case 'darwin': | ||
case 'linux': | ||
case 'freebsd': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. windows builds exist now. |
||
break | ||
default: | ||
throw new Error('no binary available for os:' + goenv.GOOS) | ||
} | ||
|
||
switch (goenv.GOARCH) { | ||
case 'amd64': | ||
case '386': | ||
case 'arm': | ||
break | ||
|
||
default: | ||
throw new Error('no binary available for arch: ' + goenv.GOARCH) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,14 @@ | ||
var test = require('tape') | ||
var fs = require('fs') | ||
var cp = require('child_process') | ||
var ipfs = require('../') | ||
var download = require('../src') | ||
var path = require('path') | ||
|
||
test('ensure ipfs bin path exists', function(t) { | ||
t.plan(4) | ||
fs.stat(ipfs, function(err, stats) { | ||
t.error(err, 'ipfs bin should stat witout error') | ||
cp.exec([ipfs,'version'].join(' '), function(err, stdout, stderr) { | ||
t.error(err, 'ipfs runs without error') | ||
t.true(stdout.indexOf('ipfs version') >= 0, 'ipfs version retreived') | ||
t.false(stderr, 'no stderr output') | ||
test('Ensure ipfs gets downloaded', function (t) { | ||
t.plan(2) | ||
download(function () { | ||
fs.stat(path.resolve(__dirname, '../go-ipfs'), function (err, stats) { | ||
t.error(err, 'ipfs bin should stat without error') | ||
t.ok(stats, 'ipfs was downloaded') | ||
}) | ||
}) | ||
}) |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't work for windows. go-ipfs uses
.zip
for windows.