Skip to content

Conversation

achingbrain
Copy link
Member

I've moved the replication/mirroring functionality out of this module into ipfs-registry-mirror because it was getting very unwieldy and was starting to lose focus - this is what's currently deployed at https://registry.js.ipfs.io

This PR fixes #50 by making the purpose of this module just to install your npm deps.

When invoked on the command line, this module now:

  1. Makes a request to https://replication.registry.js.ipfs.io to find out what the current CID of the npm index is
  2. Dials the replication master to ensure we can ipfs.files.cp the updated index
  3. Updates the local copy of the registry index
  4. Starts a web server to serve dependencies
  5. Spawns npm in the background configured to connect to us
  6. For every tarball/manifest request, if it exists in our copy of the index, uses the CID stored alongside it to fetch it using IPFS, if not proxies for the public npm registry but updates the local copy of the index with the CID of the newly downloaded module

Some notes:

  1. 1 & 2 will go away when js-ipfs can resolve remote IPNS names
  2. There seems to be a bug with ipfs.dag.get, in that it stops responding when invoked loads of times concurrently, but I need to dig in to this further. Until then this module is best used with the go daemon. E.g. in your project directory and with go-ipfs on your $PATH:
ipfs-npm --ipfs-type=go
  1. Requesting modules from localhost results in having http://localhost... in your package-lock.json file, might need to rewrite these post-install and replace them with https://registry.js.ipfs.io urls..

README.md Outdated
# npm on IPFS

![](/img/ip-npm-small.png)
![Alt text](./img/npm-on-ipfs.svg)
Copy link
Member

Choose a reason for hiding this comment

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

Too big

Copy link
Member Author

Choose a reason for hiding this comment

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

It is a bit big. Did you have a preferred size in mind?

Copy link
Member

Choose a reason for hiding this comment

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

see the js-ipfs repo for a good size

===========
# npm on IPFS

![](/img/ip-npm-small.png)
Copy link
Member

Choose a reason for hiding this comment

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

This image was great btw

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you prefer it to the new image? Since #55 was opened I thought you wanted it updating?

Copy link
Member

Choose a reason for hiding this comment

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

see the js-ipfs repo for a good size

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but the network of multiple npm registries is still super cool. Can we meet in the middle?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I'll put it back in :)

README.md Outdated
🔧 Please either update your npm config with 'npm config set registry http://localhost:50321'
🔧 or use the '--registry' flag, eg: 'npm install --registry=http://localhost:50321'
$ ipfs-npm
👿 Spawning a go-IPFS node
Copy link
Member

Choose a reason for hiding this comment

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

no default to JS anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

It defaults to an in-process js-ipfs node. The output here is from a testing run, I missed that it was with a go-ipfs node, will update.

README.md Outdated
🔧 or use the '--registry' flag, eg: 'npm install --registry=http://localhost:50321'
$ ipfs-npm
👿 Spawning a go-IPFS node
🗑️ Removing old registry if it exists
Copy link
Member

Choose a reason for hiding this comment

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

Removing or updating?

Copy link
Member Author

Choose a reason for hiding this comment

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

It removes the old one and replaces it with the latest from the replication master. Once it's finished it's first import run (might take a week or two), it should have everything you'd ever need. N.b. it's just the json package descriptions you're pulling down, not the tarballs.

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps say something as "replacing old registry index if it exists"

README.md Outdated
🗑️ Removing old registry if it exists
☎️ Dialing replication master /ip4/127.0.0.1/tcp/40020/ipfs/QmeXyYCLSivUn5Ju31jjPBYNKdncbzzEf6zdN2DyrdLAbe
📠 Copying registry index /ipfs/QmQmVsNFw3stJky7agrETeB9kZqkcvLSLRnFFMrhiR8zG1 to /commons-registry
👩‍🚀 Starting local webserver
Copy link
Member

Choose a reason for hiding this comment

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

perhaps say "local proxy"

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok

README.md Outdated
👿 Spawning a go-IPFS node
🗑️ Removing old registry if it exists
☎️ Dialing replication master /ip4/127.0.0.1/tcp/40020/ipfs/QmeXyYCLSivUn5Ju31jjPBYNKdncbzzEf6zdN2DyrdLAbe
📠 Copying registry index /ipfs/QmQmVsNFw3stJky7agrETeB9kZqkcvLSLRnFFMrhiR8zG1 to /commons-registry
Copy link
Member

Choose a reason for hiding this comment

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

Why not do npm-registry?

Copy link
Member Author

Choose a reason for hiding this comment

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

Throwback to #56. Will update.

Copy link
Member

Choose a reason for hiding this comment

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

this is just a folder name

README.md Outdated
🎁 Installing dependencies with /Users/alex/.nvm/versions/node/v10.8.0/bin/npm
🆕 New version of express detected undefined vs 3864-53d75cca2a8eae32408fce2fd43f4c87
📄 GET /express 200 993ms
🐨 npm http fetch GET 200 http://localhost:57314/express 1029ms
Copy link
Member

Choose a reason for hiding this comment

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

Why does it try to install express on setup?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't, this was output using ipfs-npm in a project that had express as a dependency.

README.md Outdated
📠 Copying registry index /ipfs/QmQmVsNFw3stJky7agrETeB9kZqkcvLSLRnFFMrhiR8zG1 to /commons-registry
👩‍🚀 Starting local webserver
👿 Spawning an in-process IPFS node
🗑️ Replacing old registry index if it exist
Copy link
Member

Choose a reason for hiding this comment

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

exists*

README.md Outdated
# npm on IPFS

![Alt text](./img/npm-on-ipfs.svg)
![npm on IPFS logo](./img/npm-on-ipfs.svg)
Copy link
Member

Choose a reason for hiding this comment

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

nicpick, can you make it centered. Just like libp2p https://github.com/libp2p/js-libp2p?

@codecov-io
Copy link

codecov-io commented Oct 25, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@6ea40aa). Click here to learn what that means.
The diff coverage is 81.06%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #70   +/-   ##
=========================================
  Coverage          ?   75.13%           
=========================================
  Files             ?        8           
  Lines             ?      185           
  Branches          ?        0           
=========================================
  Hits              ?      139           
  Misses            ?       46           
  Partials          ?        0
Impacted Files Coverage Δ
src/core/config.js 100% <100%> (ø)
src/cli/bin.js 100% <100%> (ø)
src/core/handlers/root.js 42.85% <33.33%> (ø)
src/core/start-ipfs.js 56.52% <56.52%> (ø)
src/core/index.js 82.75% <81.81%> (ø)
src/core/handlers/tarball.js 51.72% <83.33%> (ø)
src/core/handlers/manifest.js 66.66% <85.71%> (ø)
src/core/start-server.js 97.14% <97.14%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ea40aa...1fe471e. Read the comment docs.

@achingbrain achingbrain merged commit 1100ff6 into master Oct 25, 2018
@achingbrain achingbrain deleted the split-into-modules branch October 25, 2018 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ipfs-npm install command that is an alias to ipfs-npm && npm install --registry=http://localhost:50321
3 participants