cargo-component icon indicating copy to clipboard operation
cargo-component copied to clipboard

Implement `wit pull`

Open lann opened this issue 3 months ago • 11 comments

This implements a wit pull subcommand which can be used to update local e.g. wit/deps/*.wit from a registry.

$ wit pull wasi:io --create-dirs
   Resolving package wasi:io
  Downloaded release wasi:[email protected]
       Wrote package wasi:[email protected] to 'wit/deps/[email protected]'

$ head -n1 wit/deps/[email protected]
package wasi:[email protected];

$ wit pull wasi:http
   Resolving package wasi:http
  Downloaded release wasi:[email protected]
       Wrote package wasi:[email protected] to 'wit/deps/[email protected]'
       Wrote package wasi:[email protected] to 'wit/deps/[email protected]'
       Wrote package wasi:[email protected] to 'wit/deps/[email protected]'
       Wrote package wasi:[email protected] to 'wit/deps/[email protected]'

There are two modes of operation:

  • When given specific name(s) it will pull those registry package(s) and unpack all (not existing) WIT packages into wit/deps/<namespace>-<name>@<version>.wit
  • When given no name(s) it will check the packages under wit/ for missing dependencies and attempt to pull them like above

Both of these can operate whether or not wit_parser::Resolve::push_dir can currently parse the wit/ directory. If it can parse, the existing dependency checks will just be more accurate (capturing e.g. wit/deps/some-package.wasm). This ought to be more consistent but really needs some refactoring in wit-parser first.

lann avatar Mar 22 '24 18:03 lann