ipfs-shipyard / npm-on-ipfs

:package: Install npm modules through IPFS!
MIT License
467 stars 40 forks source link

Dont spawn node for local operations like npm ls #95

Closed olizilla closed 5 years ago

olizilla commented 5 years ago

Things like npm ls and npm -v shouldn't trigger a spawn n dial.

$ npm ls cids
πŸ‘Ώ Spawning an in-process IPFS node using repo at /Users/oli/.jsipfs
Swarm listening on /ip4/127.0.0.1/tcp/54572/ipfs/QmPKLo7oNb6SiXUTd4fKxvnZFQXWxKzBggD9WsoFg9M4Na
πŸ—‚οΈ  Loading registry index from https://registry.js.ipfs.io
☎️  Dialling registry mirror /ip4/35.178.192.119/tcp/10000/ipfs/Qmf8FJm6bQaLEuMyMU2wVq6BwfiUwtCNd3vz3hLMXHQA9z,/dns4/registry.js.ipfs.io/tcp/10000/ipfs/Qmf8FJm6bQaLEuMyMU2wVq6BwfiUwtCNd3vz3hLMXHQA9z
πŸ“±οΈ Connected to registry
πŸ‘©β€πŸš€ Starting local proxy
πŸš€ Server running on port 54595
🎁 Installing dependencies with /usr/local/bin/npm
ipld-explorer-components@1.2.0 /Users/oli/Code/ipfs-shipyard/ipld-explorer-components
β”œβ”€β”€ cids@0.6.0 
#Β trimmed
🎁 /usr/local/bin/npm exited with code 0
πŸ” Updating package-lock.json
achingbrain commented 5 years ago

Fair point, we should probably spin a node up on-demand when the first registry request is received instead of at start-up.

hacdias commented 5 years ago

Would it be better to whitelist some commands or to open an IPFS connection when the server gets the first request? Commands like login will make a request to the server hence trigger connecting to the daemon although they don't need it. Or is there any other way to detect real registry connections?

achingbrain commented 5 years ago

Sure, I meant spin up a node when a request is received that would involve IPFS-related operations like transferring a file or resolving a packument, etc - there are a bunch of endpoints we create that are just forwarded on to npm (e.g. login, detecting vulnerabilities, etc) - they would stay as they are.

olizilla commented 5 years ago

@achingbrain do you have a preffered solution here, or should we freestyle it? Can you drop any specific thoughts you have here so @fsdiogo can take a look.

olizilla commented 5 years ago

of note this issue is very related https://github.com/ipfs-shipyard/npm-on-ipfs/issues/96