Skip to content

feat: implement native recursive version command#10879

Merged
zkochan merged 2 commits intopnpm:mainfrom
kairosci:feature/native-version-command
Mar 22, 2026
Merged

feat: implement native recursive version command#10879
zkochan merged 2 commits intopnpm:mainfrom
kairosci:feature/native-version-command

Conversation

@kairosci
Copy link
Copy Markdown
Contributor

@kairosci kairosci commented Mar 5, 2026

Description

Implement version natively in pnpm to support workspaces and workspace: protocols correctly.

Changes

  • Implemented version command in @pnpm/plugin-commands-script-runners.
  • Registered version command in pnpm CLI.
  • Removed hardcoded passthrough to npm version in pnpm CLI.
  • Added support for --recursive versioning.

Checklist

Copilot AI review requested due to automatic review settings March 5, 2026 21:39
@kairosci kairosci requested a review from zkochan as a code owner March 5, 2026 21:39
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

Implements a native pnpm version command (including pnpm -r version) so version bumps run with pnpm’s workspace context instead of being passed through to npm version (which breaks on workspace: protocol deps).

Changes:

  • Register version as a pnpm command via @pnpm/plugin-commands-script-runners and stop passing version through to npm.
  • Update CLI arg parsing to treat version similarly to run/dlx for passthrough-style args.
  • Add regression tests and a small repro workspace fixture for the workspace:^ dependency case.

Reviewed changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
repro-workspace-version-issue/pnpm-workspace.yaml Adds a minimal workspace manifest for the repro fixture.
repro-workspace-version-issue/pnpm-lock.yaml Adds a minimal lockfile capturing workspace:^ dependency usage.
repro-workspace-version-issue/package.json Adds root package.json for the repro fixture.
repro-workspace-version-issue/packages/pkg-a/package.json Adds pkg-a fixture package.
repro-workspace-version-issue/packages/pkg-b/package.json Adds pkg-b fixture package depending on pkg-a via workspace:^.
pnpm/test/version.test.ts Adds an integration test asserting pnpm -r version minor succeeds with workspace: deps.
pnpm/src/pnpm.ts Removes version from the npm pass-through command list.
pnpm/src/parseCliArgs.ts Treats version as an escaped-args command at the pnpm CLI wrapper level.
pnpm/src/cmd/index.ts Registers the new version command from script-runners.
pnpm-lock.yaml Adds @pnpm/run-npm workspace dependency (for the new command).
exec/plugin-commands-script-runners/tsconfig.json Adds TS project reference for run-npm.
exec/plugin-commands-script-runners/package.json Adds @pnpm/run-npm dependency.
exec/plugin-commands-script-runners/src/index.ts Exports the new version command module.
exec/plugin-commands-script-runners/src/version.ts New implementation of the version command (recursive + non-recursive).
exec/plugin-commands-script-runners/test/version.test.ts Unit test ensuring version delegates to runNpm with correct args/options.
cli/parse-cli-args/src/index.ts Treats version like run/dlx for special escaping behavior.
Files not reviewed (2)
  • pnpm-lock.yaml: Language not supported
  • repro-workspace-version-issue/pnpm-lock.yaml: Language not supported

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

@kairosci kairosci marked this pull request as draft March 5, 2026 21:51
@kairosci kairosci force-pushed the feature/native-version-command branch 3 times, most recently from 556cede to 3cb39a1 Compare March 5, 2026 22:07
@kairosci kairosci marked this pull request as ready for review March 5, 2026 22:11
@kairosci kairosci marked this pull request as draft March 9, 2026 17:29
@kairosci kairosci force-pushed the feature/native-version-command branch 6 times, most recently from ff6a339 to 1a54dca Compare March 17, 2026 11:06
@saudademjj
Copy link
Copy Markdown

I pulled this PR locally and fixed the failing import-sort errors in a follow-up branch on my fork:

  • branch: saudademjj:codex/fix-pr-10879-version-command
  • commit: 395729fb1

Validated locally with:

  • pnpm run lint
  • pnpm --filter @pnpm/plugin-commands-script-runners run _test -- --runTestsByPath test/version.test.ts --runInBand
  • pnpm --filter pnpm run _test -- --runTestsByPath test/version.test.ts --runInBand

If helpful, feel free to cherry-pick 395729fb1.

@saudademjj
Copy link
Copy Markdown

Follow-up fix for the remaining review feedback is available on saudademjj:codex/fix-pr-10879-version-command at commit 1d659a5c5.

Addressed in this update:

  • pnpm version --help now goes through pnpm's help path, while arguments after a real version argument still pass through to npm.
  • pnpm help version now works in the bundled CLI by using the standard render-help import.
  • version now advertises the CLI options it actually supports (npm-path, sort, recursive, reverse).
  • Removed the misleading concurrency wrapper around synchronous runNpm() calls and execute recursive version bumps sequentially.

Validated locally:

  • pnpm run compile-only
  • pnpm --filter @pnpm/parse-cli-args run _test -- --runTestsByPath test/index.ts --runInBand
  • pnpm --filter @pnpm/plugin-commands-script-runners run _test -- --runTestsByPath test/version.test.ts --runInBand
  • pnpm --filter pnpm run _test -- --runTestsByPath test/version.test.ts --runInBand
  • ./node_modules/.bin/eslint cli/parse-cli-args/src/index.ts cli/parse-cli-args/test/index.ts exec/plugin-commands-script-runners/src/version.ts exec/plugin-commands-script-runners/test/version.test.ts pnpm/test/version.test.ts

@kairosci kairosci force-pushed the feature/native-version-command branch 2 times, most recently from 34eae5d to 22b47ab Compare March 17, 2026 13:08
@kairosci kairosci closed this Mar 17, 2026
@kairosci kairosci force-pushed the feature/native-version-command branch from 4f9d668 to f47ef4b Compare March 17, 2026 17:42
@kairosci kairosci reopened this Mar 17, 2026
@kairosci kairosci force-pushed the feature/native-version-command branch 6 times, most recently from ee2a254 to 252a7c6 Compare March 17, 2026 21:30
@kairosci kairosci marked this pull request as ready for review March 17, 2026 22:04
@kairosci kairosci force-pushed the feature/native-version-command branch 2 times, most recently from 2da4634 to e0ee9dc Compare March 18, 2026 15:39
@kairosci
Copy link
Copy Markdown
Contributor Author

@gluxon @zkochan PTAL, thank you!

@zkochan zkochan added this to the v11.0 milestone Mar 22, 2026
@zkochan zkochan force-pushed the feature/native-version-command branch from 38450fa to b67ea5c Compare March 22, 2026 11:22
kairosci and others added 2 commits March 22, 2026 12:24
- Fix changeset package name to @pnpm/releasing.commands
- Use writeProjectManifest instead of writeJsonFile to preserve formatting
- Remove dead updateWorkspaceDependencies placeholder function
- Remove unused imports (path, ProjectManifest, writeJsonFile)
- Add expect.assertions(1) to prevent silent test pass on no-throw

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zkochan zkochan force-pushed the feature/native-version-command branch from b67ea5c to 2f7e7fd Compare March 22, 2026 11:26
@zkochan zkochan enabled auto-merge (squash) March 22, 2026 11:29
@zkochan zkochan merged commit d5be835 into pnpm:main Mar 22, 2026
8 checks passed
@kairosci kairosci deleted the feature/native-version-command branch March 22, 2026 12:02
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.

pnpm version -ws leads to npm error Unsupported URL Type "workspace:": workspace:^

4 participants