Skip to content

Repository files navigation

vfox-pub

A mise backend plugin for Dart packages from pub.dev.

The plugin installs a package with dart pub global activate into a separate directory for each version. Then it puts the package executables on your PATH.

Install

mise plugin install pub https://github.com/hleinone/vfox-pub

Use

mise use pub:protoc_plugin@22.3.0

This adds the tool to your mise.toml:

[tools]
"pub:protoc_plugin" = "22.3.0"

Other commands:

mise ls-remote pub:protoc_plugin
mise install pub:melos@latest
mise exec pub:melos -- melos --version

Requirements

  • The dart executable must be on PATH when a tool is installed and when it runs. Install Dart with mise (mise use dart@latest or mise use flutter@latest) or in another way.
  • Network access to pub.dev.

How it works

  1. BackendListVersions reads https://pub.dev/api/packages/<name>. It returns all versions that are not retracted.
  2. BackendInstall reads the executables of that version from the same pub.dev response. It runs dart pub global activate --no-executables <name> <version> with PUB_CACHE set to <install directory>/pub-cache. Each version has its own pub cache. Then it writes a wrapper for each executable into <install directory>/bin and compiles the executable to a kernel snapshot in <install directory>/snapshots with dart compile kernel.
  3. The wrapper runs dart --packages=<package config> <snapshot>, so package URIs resolve at run time. After a Dart SDK upgrade the snapshot is stale, and the wrapper compiles it again before it runs the tool. Compiler output goes to stderr, so the tool's stdout stays clean. This matters for protoc plugins, which speak protobuf on stdout. pub's own launchers and dart pub global run are not used at run time: pub prints status text to stdout while it rebuilds a snapshot, rewrites its launchers, does not quote paths in them, and writes them in the system code page.
  4. BackendExecEnv adds <install directory>/bin to PATH.

Each installed version downloads its own copy of the package dependencies.

Platforms

Linux, macOS and Windows. On Windows, pub writes .bat launchers and the plugin writes .bat wrappers. CI runs the end-to-end test on all three platforms.

Limitations

  • Only pub.dev is supported. Private pub servers are not supported yet.
  • On Windows, mise itself does not load Lua plugins from a directory whose path has non-ASCII characters. Set MISE_DATA_DIR to an ASCII path in that case. Install paths with non-ASCII characters work.

Develop

mise install       # stylua, lua-language-server, actionlint
mise run format
mise run lint
mise run test      # links this directory as the pub plugin and installs protoc_plugin
mise run ci        # lint and test

mise run test replaces a plugin named pub on your machine with a link to this directory. On Windows, run the test from Git Bash with bash mise-tasks/test, because mise runs file tasks through cmd there.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages