Workiva / dpx

Apache License 2.0
1 stars 0 forks source link

Should dpx check for a local version of the requested package? #19

Open evanweible-wf opened 2 months ago

evanweible-wf commented 2 months ago

Some projects use executables from packages by installing them locally as a dev_dependency. For example:

# pubspec.yaml
dev_dependencies:
  dependency_validator: ^4.0.0
> dart run dependency_validator

This has some benefits over the use of a globally activated dependency, as it allows the consuming project to specify the version of the tool to use.

If we look at the JS ecosystem, npx handles this by first checking for a local version of the requested package and using it if found, or falling back to installing it globally. This makes it possible for devs to use a command like npx prettier . --write to format their code without needing to care about whether the project they're working uses a specific version of prettier or not. If it does, npx prettier will use that locally installed version of prettier, otherwise it'll just use the latest version of prettier.

If we supported the same pattern, then Dart developers could, for example, always run dependency validation with dpx dependency_validator. If the package they're working on specifies dependency_validator in their dev_dependencies, dpx will use that version, otherwise it will install it globally and use that.