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

A buuunch of stuff #7

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
tmp
node_modules
go-ipfs
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Juan Batiz-Benet
Copyright (c) 2016 Juan Batiz-Benet

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
56 changes: 12 additions & 44 deletions README.md
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.
5 changes: 0 additions & 5 deletions bin/ipfs

This file was deleted.

20 changes: 0 additions & 20 deletions filesize.js

This file was deleted.

2 changes: 0 additions & 2 deletions index.js

This file was deleted.

75 changes: 0 additions & 75 deletions install.js

This file was deleted.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "go-ipfs",
"version": "0.3.11",
"description": "Install the latest go-ipfs binary",
"main": "index.js",
"main": "src/index.js",
"scripts": {
"install": "node install.js",
"install": "node src/bin.js",
"test": "tape test/*.js | tap-spec"
},
"bin": {
Expand All @@ -15,10 +15,13 @@
"url": "git+https://github.com/ipfs/npm-go-ipfs.git"
},
"dependencies": {
"extract-zip": "^1.0.3",
"go-platform": "^1.0.0",
"gunzip-maybe": "^1.3.1",
"mkdirp": "^0.5.0",
"nugget": "^1.2.0"
"nugget": "^1.2.0",
"request": "^2.70.0",
"tar-fs": "^1.12.0",
"tar.gz": "^1.0.3"
},
"keywords": [
"ipfs",
Expand Down
39 changes: 0 additions & 39 deletions publish.sh

This file was deleted.

2 changes: 2 additions & 0 deletions src/bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./')(function () {})
48 changes: 48 additions & 0 deletions src/index.js
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'
Copy link
Member

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.

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':
Copy link
Member

Choose a reason for hiding this comment

The 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)
}
}
}
18 changes: 8 additions & 10 deletions test/index.js
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')
})
})
})
56 changes: 0 additions & 56 deletions update.js

This file was deleted.