Skip to content

Commit

Permalink
define the CLI API
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Jun 28, 2016
1 parent b065329 commit 82640a4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 97 deletions.
113 changes: 21 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
registry-mirror
===============
npm on IPFS
===========

> previously known as `registry-mirror`
![](/img/ip-npm-small.png)

Expand All @@ -10,122 +12,49 @@ registry-mirror
![](https://img.shields.io/badge/coverage-76%25-yellow.svg?style=flat-square)
<!-- While 0.4.0 doesn't get released [![Build Status](https://img.shields.io/travis/diasdavid/registry-mirror/master.svg?style=flat-square)](https://travis-ci.org/diasdavid/registry-mirror) -->

> registry-mirror sets a mirror the the whole NPM registry, using IPFS for the discovery and transport of modules.
> **Install your modules through IPFS!!** This CLI utility enables you to clone the npm registry into IPFS and/or mirror the registry from IPFS.
# Resources

- [Demo video](https://vimeo.com/147968322)
- [Lengthy introduction in a blog post](http://blog.daviddias.me/2015/12/08/stellar-module-management)
- [Node.js Interactive Talk - Stellar Module Management](https://www.youtube.com/watch?v=-S-Tc7Gl8FM)

# Quick setup (probably all that you need)

## Install IPFS dev0.4.0

To install IPFS dev0.4.0, you will need go installed, to install go in your machine, go to https://golang.org/dl and then run:

```bash
$ go get -u github.com/ipfs/go-ipfs
$ ipfs version
ipfs version 0.4.0-dev
```

## Run IPFS daemon

```bash
$ ipfs daemon
Initializing daemon...
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.64/tcp/4001
Swarm listening on /ip4/192.168.10.172/tcp/4001
Swarm listening on /ip6/2001:8a0:7ac5:4201:4816:fd56:bea7:eaf3/tcp/4001
Swarm listening on /ip6/2001:8a0:7ac5:4201:ae87:a3ff:fe19:def1/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready
```

## Install registry-mirror

```bash
$ npm i registry-mirror -g
```

# Usage

Wait for the `Updated directory listing` log.

```bash
$ registry-mirror daemon
registry-mirror [info] using output directory /npm-registry/
registry-mirror [info] listening on 127.0.0.1:50321
registry-mirror [info] Cloning NPM OFF
registry-mirror [info] Updated directory listing, good to go :)
```

Port `50321` is default and can be set with `--port`.

## Configure npm

Set up your npm to use `registry-mirror` with the default port through:
# Installation

```bash
$ npm config set registry http://localhost:50321
> npm install ipfs-npm --global
```

If you picked another `--port` you need to adjust accordingly.

Good to npm install away! :)
This will make the `ipfs-npm` CLI tool available globally and an alias, `ipnpm`. We will use the alias for examples and API documentation, as it is shorter.

# Usage

## CLI

```bash
$ registry-mirror
Usage: registry-mirror COMMAND [OPTIONS]

Available commands:

daemon Mirror npm registry
ls Check modules available in the mirror
npm publish Publish an IPNS record with your current npm list
npm update Update your npm list of modules from IPNS
```

## Commands

### daemon

> starts the registry-mirror daemon
> **WIP**
`$ registry-mirror daemon`
### Examples

Options:
- `--clone` - Download the entire npm (Otherwise it just tries to read)
- `--port=<port>` Listen on the specified port
- `--host=<host>` Listen on the specified port
### API

### ls
#### `ipnpm registry` commands

> lists all the modules available on the IPFS accessible registry and their respective hashes
##### `ipnpm registry clone` - Download and store the entire npm repository into IPFS

`$ registry-mirror ls`
options
seq number
ipfs=

### npm update
##### `ipnpm registry index publish` - Publishes the current index we know as an IPNS name

> update your local registry cache
##### `ipnpm registry index fetch` - Fetches the latest known index from the IPFS network

`$ registry npm update`
#### `ipnpm daemon` - Starts an ipfs-npm daemon, so that we can point our npm cli to it

### npm publish
#### `ipnpm install <module>` - Similar to `npm install`, however it tries first to download the module from npm and then falls back into the regular registry

> publish the version of the cache you have from npm

`$ registry npm publish`

## Important
## Important: Getting 502 errors?

If you are on Mac OS X, make sure to increase the limit of files open (with `ulimit -Sn 4096`), otherwise the ipfs daemon will be sad and throw 502 replies.

Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "registry-mirror",
"name": "ipfs-npm",
"version": "0.6.3",
"description": "Set up a NPM registry mirror, using your favourite storage, IPFS! :D",
"main": "src/index.js",
"bin": {
"registry-mirror": "src/cli/bin.js"
"ipfs-npm": "src/cli/bin.js",
"ipnpm": "src/cli/bin.js"
},
"scripts": {
"test": "mocha tests/test-*/index.js",
Expand All @@ -17,17 +18,17 @@
],
"repository": {
"type": "git",
"url": "git+https://github.com/diasdavid/registry-mirror.git"
"url": "git+https://github.com/diasdavid/ipfs-npm.git"
},
"keywords": [
"IPFS"
],
"author": "David Dias <daviddias@ipfs.io>",
"license": "MIT",
"bugs": {
"url": "https://github.com/diasdavid/registry-mirror/issues"
"url": "https://github.com/diasdavid/ipfs-npm/issues"
},
"homepage": "https://github.com/diasdavid/registry-mirror#readme",
"homepage": "https://github.com/diasdavid/ipfs-npm#readme",
"dependencies": {
"async": "^1.5.2",
"debug": "^2.2.0",
Expand Down

0 comments on commit 82640a4

Please sign in to comment.