refactor(pm-cli): consolidate package manager infrastructure#2140
Draft
forehalo wants to merge 1 commit into
Draft
refactor(pm-cli): consolidate package manager infrastructure#2140forehalo wants to merge 1 commit into
forehalo wants to merge 1 commit into
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This refactor makes typed command arguments the source of truth for package-manager compatibility.
#[pm_args]reads field-levelnot_supported(...)metadata, including manager and version conditionsbefore:
after:
Given the detected package manager and its version, the generated diagnosis step automatically:
This removes repeated compatibility checks from every npm, pnpm, Yarn, and Bun resolver. Normal
clap::Argsandclap::Subcommandderives remain explicit. Hard errors, fallback commands, and manager-specific translations stay in the resolver.Architecture and benefits
The production path is now:
typed clap arguments -> #[pm_args] diagnosis -> manager-specific Resolve<Args> -> Resolution -> runnerPackageManagerCommandsurface.vite_pm_cli; the redundantvite_installcrate is removed.Adding a command
XxxArgsclap struct, or anXxxCommandnested subcommand enum, and add#[pm_args].not_supported(...)rules.Resolve<Args>for npm, pnpm, Yarn, and Bun. Build argv withCommandBuilder; share lowering helpers where command shapes match and branch only where manager behavior differs.PackageManagerCommandorPmCommand, then select its project/manager policy.Validation
just checkcargo test -p vite_pm_cli— 701 passed, 2 ignored-D warningscargo fmt --all -- --checkandgit diff --check