proto icon indicating copy to clipboard operation
proto copied to clipboard

Support asdf plugins through a proto WASM plugin

Open milesj opened this issue 1 year ago • 9 comments

There has been multiple requests now to support (piggy-back) off of asdf, since it has a ton of plugins and support for many tools. Unfortunately, building this into proto core simply isn't feasible without rewriting it from scratch, and at that point, it's really not worth it. The other issue is that asdf is Unix only, so that means no Windows support.

However! I had a thought the other day, why not support every asdf plugin through a single proto WASM plugin, similar to how our TOML plugins work (they are WASM under the hood). For example, say you wanted to use the scala asdf plugin, it may look something like the following in proto:

# .prototools
scala = "latest"

[plugins]
scala = "https://path/to/asdf/plugin.wasm"

Easy right? But what if the proto identifier doesn't match up with the asdf plugin name? Well, just override it with configuration. For example, using the nodejs asdf plugin.

# .prototools
node = "latest"

[plugins]
node = "https://path/to/asdf/plugin.wasm"

[tools.node]
asdf-plugin = "nodejs"

We can also take this further by supporting the git repository directly.

# .prototools
[tools.node]
asdf-repository = "https://github.com/asdf-vm/asdf-nodejs.git"

Caveats

With all this being said, I have no idea if this will actually work, or if the asdf plugin APIs will match up to the proto plugin APIs. It's definitely something that needs to be prototyped to ensure it's feasible.

Requirements

  • Plugin should be written in Rust and use our APIs/PDKs:
    • https://moonrepo.dev/docs/guides/wasm-plugins
    • https://moonrepo.dev/docs/proto/wasm-plugin
  • PRs submitted to https://github.com/moonrepo/asdf-plugin
  • Does not need to support Windows
  • Must work without asdf existing in the environment
  • Should ideally support all asdf plugins
  • Should detect versions from .tool-versions - https://asdf-vm.com/manage/configuration.html#tool-versions
  • Should support ASDF_* env vars - https://asdf-vm.com/plugins/create.html#environment-variables-overview

Implementation

How this is implemented may require a lot of discussion, which can be had on Discord.

With that said, we can outline a few things:

  • How we download/install asdf plugins should probably mirror what asdf itself does.
    • Stored at ~/.asdf - https://asdf-vm.com/manage/configuration.html#asdf-data-dir
  • API reference - https://asdf-vm.com/plugins/create.html#required-scripts

milesj avatar Jul 08 '24 22:07 milesj

/bounty $500

milesj avatar Jul 08 '24 22:07 milesj

If this turns out to not be feasible, I'll send over a tip for the work done so far.

milesj avatar Jul 08 '24 22:07 milesj

/attempt #539

Algora profile Completed bounties Tech Active attempts Options
@scshiv29-dev 2 bounties from 2 projects
Java, Python,
TypeScript & more
Cancel attempt

scshiv29-dev avatar Jul 08 '24 23:07 scshiv29-dev

I am into it @milesj

/attempt #539

Algora profile Completed bounties Tech Active attempts Options
@varshith257    3 moonrepo bounties
+ 1 bounty from 1 project
TypeScript, Go
Cancel attempt

varshith257 avatar Jul 09 '24 02:07 varshith257

@milesj can others give it a try?? Asking since it's assigned.

abhishek818 avatar Jul 09 '24 04:07 abhishek818

@abhishek818 Maybe you can give an attempt after my attempt is done. I will let you know

varshith257 avatar Jul 09 '24 04:07 varshith257

Go for it

milesj avatar Jul 09 '24 05:07 milesj

Moving this to https://github.com/moonrepo/tools

milesj avatar Aug 18 '24 23:08 milesj