Skip to content

feat(cli): add package manager utility commands#280

Merged
fengmk2 merged 1 commit intomainfrom
10-31-feat_cli_add_package_manager_utility_commands
Nov 21, 2025
Merged

feat(cli): add package manager utility commands#280
fengmk2 merged 1 commit intomainfrom
10-31-feat_cli_add_package_manager_utility_commands

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Oct 31, 2025

TL;DR

Added a new vite pm command group that provides unified access to package manager utilities across pnpm, npm, and yarn.

What changed?

  • Added a new vite pm command group with several subcommands:
    • prune: Remove unnecessary packages
    • pack: Create a tarball of the package
    • list/ls: List installed packages
    • view: View package information from registry
    • publish: Publish package to registry
    • owner: Manage package owners
    • cache: Manage package cache
    • config: Manage package manager configuration
  • Implemented command resolution for each package manager type (pnpm, npm, yarn)
  • Added appropriate command mappings to handle differences between package managers
  • Included version-specific handling for yarn@1 vs yarn@2+
  • Added deprecation warnings for unsupported commands (e.g., npm prune)
  • Created unit tests for the prune command

How to test?

Test the new commands with different package managers:

# Cache management
vite pm cache dir
vite pm cache clean

# List packages
vite pm list --depth 0
vite pm list --json

# View package info
vite pm view react
vite pm view react version

# Configuration
vite pm config get registry
vite pm config set registry https://registry.npmjs.org

# Package operations
vite pm pack --dry-run
vite pm publish --dry-run

Why make this change?

This change provides a unified interface to package manager utilities, which:

  1. Reduces cognitive load by providing consistent commands across different package managers
  2. Improves developer experience when working across projects with different package managers
  3. Makes scripts more portable by abstracting package manager differences
  4. Complements existing vite+ commands for package management (install, add, remove, update)
  5. Follows the same pattern as other package managers like Bun that provide a unified PM interface

Copy link
Copy Markdown
Member Author

fengmk2 commented Oct 31, 2025

@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch 3 times, most recently from 9cedb9c to 7bc67f9 Compare November 1, 2025 07:39
@fengmk2 fengmk2 changed the base branch from main to graphite-base/280 November 2, 2025 09:21
@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch from 7bc67f9 to b2a7e69 Compare November 2, 2025 09:21
@fengmk2 fengmk2 changed the base branch from graphite-base/280 to 11-02-chore_cli_add_tool_json-sort_command November 2, 2025 09:21
@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch from b2a7e69 to cff898a Compare November 2, 2025 10:11
@fengmk2 fengmk2 force-pushed the 11-02-chore_cli_add_tool_json-sort_command branch from af8244b to d3abd34 Compare November 2, 2025 10:12
@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch 2 times, most recently from f4aae74 to e3f5c66 Compare November 2, 2025 11:07
@fengmk2 fengmk2 marked this pull request as ready for review November 2, 2025 11:07
@fengmk2 fengmk2 self-assigned this Nov 2, 2025
@fengmk2 fengmk2 force-pushed the 11-02-chore_cli_add_tool_json-sort_command branch from d3abd34 to bc8bf05 Compare November 2, 2025 15:14
@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch 3 times, most recently from a9fa64e to 923d5fb Compare November 3, 2025 03:35
@fengmk2 fengmk2 changed the base branch from 11-02-chore_cli_add_tool_json-sort_command to graphite-base/280 November 3, 2025 13:01
@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch from 923d5fb to cc95199 Compare November 3, 2025 13:01
@graphite-app graphite-app bot changed the base branch from graphite-base/280 to main November 3, 2025 13:01
@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch from cc95199 to f1a0a92 Compare November 3, 2025 13:02
Copilot AI review requested due to automatic review settings November 3, 2025 16:07
@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch from f1a0a92 to fa7f229 Compare November 3, 2025 16:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a vite pm command group that provides unified access to package manager utilities (like cache management, package publishing, configuration, etc.) across different package managers (pnpm, npm, yarn). The implementation includes:

  • An RFC document detailing the design and implementation
  • Test utility updates to handle new output patterns from package manager commands
  • Comprehensive snapshot tests for various pm subcommands across different package managers

Reviewed Changes

Copilot reviewed 176 out of 176 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
rfcs/pm-command-group.md Complete RFC documenting the new vite pm command group with detailed subcommand mappings and examples
packages/tools/src/utils.ts Enhanced test utilities to normalize variable output (sizes, hashes, registry URLs, speeds) in snapshot tests
packages/tools/src/tests/utils.spec.ts Added tests for new output normalization patterns
packages/tools/src/tests/snapshots/utils.spec.ts.snap Snapshot expectations for utility test cases
packages/global/snap-tests/command-/ Extensive snapshot test files for pm subcommands (view, publish, prune, pack, list, owner, config, cache) across pnpm10, npm10, yarn1, and yarn4
packages/global/snap-tests/command--with-workspace/ Workspace-specific snapshot tests for pm commands
packages/global/snap-tests/command-why-/ Updated snapshots removing "Running:" debug output lines
packages/global/snap-tests/command-update-/ Updated snapshots removing "Running:" debug output lines
packages/global/snap-tests/command-/ Multiple other command snapshot updates removing "Running:" output

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch from fa7f229 to 5514ec2 Compare November 3, 2025 16:13
@graphite-app graphite-app bot changed the base branch from graphite-base/280 to main November 4, 2025 13:59
@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch 2 times, most recently from c1cf227 to 5316503 Compare November 7, 2025 09:57
Copilot AI review requested due to automatic review settings November 7, 2025 09:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 176 out of 176 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch from 5316503 to ed04c6c Compare November 10, 2025 02:49
@fengmk2 fengmk2 marked this pull request as draft November 10, 2025 03:48
@fengmk2 fengmk2 changed the base branch from main to graphite-base/280 November 10, 2025 11:39
@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch from ed04c6c to 27599d8 Compare November 10, 2025 11:39
@fengmk2 fengmk2 changed the base branch from graphite-base/280 to 11-10-fix_run_command_support_windows November 10, 2025 11:39
@graphite-app graphite-app bot changed the base branch from 11-10-fix_run_command_support_windows to main November 10, 2025 11:40
@fengmk2 fengmk2 marked this pull request as ready for review November 10, 2025 11:55
Copilot AI review requested due to automatic review settings November 10, 2025 11:55
@fengmk2 fengmk2 changed the base branch from main to graphite-base/280 November 10, 2025 11:55
@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch from 27599d8 to 3fda230 Compare November 10, 2025 11:56
@fengmk2 fengmk2 changed the base branch from graphite-base/280 to 11-10-fix_run_command_support_windows November 10, 2025 11:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 176 out of 176 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member Author

fengmk2 commented Nov 10, 2025

@branchseer It also ran on Windows, you can take a look

@fengmk2 fengmk2 changed the base branch from 11-10-fix_run_command_support_windows to graphite-base/280 November 10, 2025 14:13
@fengmk2 fengmk2 changed the base branch from graphite-base/280 to main November 10, 2025 14:14
@fengmk2 fengmk2 force-pushed the 10-31-feat_cli_add_package_manager_utility_commands branch 2 times, most recently from f24c99a to d539372 Compare November 10, 2025 14:15
@fengmk2 fengmk2 changed the base branch from main to graphite-base/280 November 19, 2025 02:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 134 out of 134 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@Brooooooklyn Brooooooklyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's combine it and improve it as we move forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants