Skip to content

Commit 084fdbb

Browse files
committed
define the CLI API
1 parent b065329 commit 084fdbb

File tree

2 files changed

+42
-89
lines changed

2 files changed

+42
-89
lines changed

README.md

+36-84
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
registry-mirror
2-
===============
1+
npm on IPFS
2+
===========
3+
4+
> previously known as `registry-mirror`
35
46
![](/img/ip-npm-small.png)
57

@@ -10,122 +12,72 @@ registry-mirror
1012
![](https://img.shields.io/badge/coverage-76%25-yellow.svg?style=flat-square)
1113
<!-- 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) -->
1214

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

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

21-
# Quick setup (probably all that you need)
22-
23-
## Install IPFS dev0.4.0
24-
25-
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:
26-
27-
```bash
28-
$ go get -u github.com/ipfs/go-ipfs
29-
$ ipfs version
30-
ipfs version 0.4.0-dev
31-
```
32-
33-
## Run IPFS daemon
23+
# Installation
3424

3525
```bash
36-
$ ipfs daemon
37-
Initializing daemon...
38-
Swarm listening on /ip4/127.0.0.1/tcp/4001
39-
Swarm listening on /ip4/192.168.1.64/tcp/4001
40-
Swarm listening on /ip4/192.168.10.172/tcp/4001
41-
Swarm listening on /ip6/2001:8a0:7ac5:4201:4816:fd56:bea7:eaf3/tcp/4001
42-
Swarm listening on /ip6/2001:8a0:7ac5:4201:ae87:a3ff:fe19:def1/tcp/4001
43-
Swarm listening on /ip6/::1/tcp/4001
44-
API server listening on /ip4/127.0.0.1/tcp/5001
45-
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
46-
Daemon is ready
26+
> npm install ipfs-npm --global
4727
```
4828

49-
## Install registry-mirror
50-
51-
```bash
52-
$ npm i registry-mirror -g
53-
```
29+
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.
5430

5531
# Usage
5632

57-
Wait for the `Updated directory listing` log.
58-
59-
```bash
60-
$ registry-mirror daemon
61-
registry-mirror [info] using output directory /npm-registry/
62-
registry-mirror [info] listening on 127.0.0.1:50321
63-
registry-mirror [info] Cloning NPM OFF
64-
registry-mirror [info] Updated directory listing, good to go :)
65-
```
66-
67-
Port `50321` is default and can be set with `--port`.
68-
69-
## Configure npm
70-
71-
Set up your npm to use `registry-mirror` with the default port through:
72-
73-
```bash
74-
$ npm config set registry http://localhost:50321
75-
```
76-
77-
If you picked another `--port` you need to adjust accordingly.
78-
79-
Good to npm install away! :)
33+
> **WIP**
8034
81-
# Usage
35+
### Examples
8236

83-
## CLI
37+
### API
8438

85-
```bash
86-
$ registry-mirror
87-
Usage: registry-mirror COMMAND [OPTIONS]
39+
#### `ipnpm registry` commands
8840

89-
Available commands:
41+
##### `ipnpm registry clone` - Download and store the entire npm repository into IPFS
9042

91-
daemon Mirror npm registry
92-
ls Check modules available in the mirror
93-
npm publish Publish an IPNS record with your current npm list
94-
npm update Update your npm list of modules from IPNS
95-
```
43+
Downloads the entire npm registry from registry.npmjs.org and stores it on the IPFS node.
9644

97-
## Commands
45+
This command will try to find an IPFS node on the default (`IPFS_PATH`), if none is found, it will start one.
9846

99-
### daemon
47+
**options:**
48+
- `seq-number` - Select the mirror sequence number to start from. Defaults to last, if none, 0.
49+
- `ipfs` - Select an IPFS daemon by passing its API URL. e.g `ipnpm registry clone --ipfs=/ip4/127.0.0.1/tcp/5001`.
50+
- `log` - Sets the log level, default is `module`. Other options are: `[all, module]`. e.g `ipnpm registry clone --log=all`.
10051

101-
> starts the registry-mirror daemon
52+
##### `ipnpm registry index publish` - Publishes the current index we know as an IPNS name
10253

103-
`$ registry-mirror daemon`
54+
This command will try to find an IPFS node on the default (`IPFS_PATH`), if none is found, it will start one.
10455

105-
Options:
106-
- `--clone` - Download the entire npm (Otherwise it just tries to read)
107-
- `--port=<port>` Listen on the specified port
108-
- `--host=<host>` Listen on the specified port
56+
**options:**
57+
- `ipfs` - Select an IPFS daemon by passing its API URL. e.g `ipnpm registry clone --ipfs=/ip4/127.0.0.1/tcp/5001`.
10958

110-
### ls
59+
##### `ipnpm registry index fetch` - Fetches the latest known index from the IPFS network
11160

112-
> lists all the modules available on the IPFS accessible registry and their respective hashes
61+
This command will try to find an IPFS node on the default (`IPFS_PATH`), if none is found, it will start one.
11362

114-
`$ registry-mirror ls`
63+
**options:**
64+
- `ipfs` - Select an IPFS daemon by passing its API URL. e.g `ipnpm registry clone --ipfs=/ip4/127.0.0.1/tcp/5001`.
11565

116-
### npm update
66+
#### `ipnpm daemon` - Starts an ipfs-npm daemon, so that we can point our npm cli to it
11767

118-
> update your local registry cache
68+
This command will try to find an IPFS node on the default (`IPFS_PATH`), if none is found, it will start one.
11969

120-
`$ registry npm update`
70+
**options:**
71+
- `ipfs` - Select an IPFS daemon by passing its API URL. e.g `ipnpm registry clone --ipfs=/ip4/127.0.0.1/tcp/5001`.
12172

122-
### npm publish
73+
#### `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
12374

124-
> publish the version of the cache you have from npm
75+
This command will try to find an IPFS node on the default (`IPFS_PATH`), if none is found, it will start one.
12576

126-
`$ registry npm publish`
77+
**options:**
78+
- `ipfs` - Select an IPFS daemon by passing its API URL. e.g `ipnpm registry clone --ipfs=/ip4/127.0.0.1/tcp/5001`.
12779

128-
## Important
80+
## Important: Getting 502 errors?
12981

13082
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.
13183

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2-
"name": "registry-mirror",
2+
"name": "ipfs-npm",
33
"version": "0.6.3",
44
"description": "Set up a NPM registry mirror, using your favourite storage, IPFS! :D",
55
"main": "src/index.js",
66
"bin": {
7-
"registry-mirror": "src/cli/bin.js"
7+
"ipfs-npm": "src/cli/bin.js",
8+
"ipnpm": "src/cli/bin.js"
89
},
910
"scripts": {
1011
"test": "mocha tests/test-*/index.js",
@@ -17,17 +18,17 @@
1718
],
1819
"repository": {
1920
"type": "git",
20-
"url": "git+https://github.com/diasdavid/registry-mirror.git"
21+
"url": "git+https://github.com/diasdavid/ipfs-npm.git"
2122
},
2223
"keywords": [
2324
"IPFS"
2425
],
2526
"author": "David Dias <[email protected]>",
2627
"license": "MIT",
2728
"bugs": {
28-
"url": "https://github.com/diasdavid/registry-mirror/issues"
29+
"url": "https://github.com/diasdavid/ipfs-npm/issues"
2930
},
30-
"homepage": "https://github.com/diasdavid/registry-mirror#readme",
31+
"homepage": "https://github.com/diasdavid/ipfs-npm#readme",
3132
"dependencies": {
3233
"async": "^1.5.2",
3334
"debug": "^2.2.0",

0 commit comments

Comments
 (0)