ipfs-inactive / package-managers

[ARCHIVED] 📦 IPFS Package Managers Task Force
MIT License
99 stars 11 forks source link

ruby bundler ipfs plugin #4

Open andrew opened 5 years ago

andrew commented 5 years ago

It looks like it's possible to add IPFS support to bundler, the rubygems dependency manager, via a plugin system, specifically a "source" plugin: https://bundler.io/v2.0/guides/bundler_plugins.html

There's already three built-in sources: rubygems, git and path, so it's not a big jump to be able to make an ipfs source.

There's a few different ways to approach using it. A simple one would be just declaring the cids as named dependencies, then you'd be able to do the following in your Gemfile:

gem 'keystone', ipfs: 'QmYLKZodZBg41enHjp8qBwPLAUmi6QkrgZqoWQW3R4wJS3'

which would download the equivalent contents of https://rubygems.org/downloads/keystone-0.0.32.gem and put it in the correct path for rubygems to find it when you call require 'keystone' in your ruby code.

Another neat thing the extension enables you to do is add your own metadata to Gemfile.lock, for example the git source adds:

GIT
  remote: https://github.com/attr-encrypted/attr_encrypted
  revision: 11df93aef14c661dd0c03169d382a0412f93124e
  specs:
    attr_encrypted (3.1.0)
      encryptor (~> 3.0.0)

So we could add a similar IPFS section with mappings for package names to CIDs, perhaps with a http url fallback.

You can also make plugins for bundler commands, one that springs to mind is a command to download one or more gems from rubygems.org and add them to IPFS and then record the CID in the Gemfile.lock, effectively enabling people to bootstrap the process, adding their applications dependencies to IPFS and recording them without us needing to spin up a whole registry mirror online.

There's no IPFS implementation in ruby yet but there do appear to be some http clients that can talk to go-ipfs.

andrew commented 5 years ago

Talking of rubygems, Ruby Together, the org that funds most bundler and rubygems development are open to proposals for pieces of work to fund, https://rubytogether.org/projects, might be worth proposing something like this?

More details in their recent blog post: https://rubytogether.org/news/2018-12-19-announcing-project-proposals