Skip to content

fix(pacquet/cli): patch --version literal during release build#11812

Merged
zkochan merged 1 commit into
mainfrom
pacquet-cli-version-autopatch
May 21, 2026
Merged

fix(pacquet/cli): patch --version literal during release build#11812
zkochan merged 1 commit into
mainfrom
pacquet-cli-version-autopatch

Conversation

@zkochan

@zkochan zkochan commented May 21, 2026

Copy link
Copy Markdown
Member

Summary

  • pacquet --version reports a hardcoded clap attribute literal in pacquet/crates/cli/src/cli_args.rs. It wasn't bumped for the 0.2.2 release, so the published 0.2.2 binary still reports 0.2.1. Bump the literal to 0.2.2.
  • Add a step to the release workflow (.github/workflows/pacquet-release-to-npm.yml) that rewrites the attribute from inputs.version before cross build, so future releases stay correct without anyone having to remember.

The substitution is a portable perl -i -pe (matching macOS / Linux / Windows-bash matrix legs); a trailing grep -F fails the job loudly if the regex stops matching after a future refactor of the attribute. The same inputs.version semver check that already gates the publish job now also runs at the top of the matched build step, so an invalid version fails early instead of after six parallel builds.

Test plan

  • Manually verify the perl substitution by running it locally against cli_args.rs with a 0.2.3-rc.1-style value (done; substitution lands and grep -F succeeds).
  • Next release dispatch: confirm the build matrix log shows the injected version and that the published pacquet --version matches inputs.version.

Written by an agent (Claude Code, claude-opus-4-7).

Summary by CodeRabbit

  • Chores
    • Updated CLI version to 0.2.2
    • Enhanced release automation for version management

Review Change Stack

The `pacquet --version` string is a hardcoded clap attribute in
`cli_args.rs`. It didn't get bumped for the 0.2.2 release, so the
published binary still reports 0.2.1. Bump the literal to 0.2.2 and
add a release-workflow step that rewrites the attribute from
`inputs.version` before `cross build`, so future releases stay
correct automatically. A trailing `grep -F` fails the job loudly if
the regex stops matching after a future refactor of the attribute.
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 976b986b-d420-4724-a0e3-cd2138227369

📥 Commits

Reviewing files that changed from the base of the PR and between 0dd1ec4 and c780e94.

📒 Files selected for processing (2)
  • .github/workflows/pacquet-release-to-npm.yml
  • pacquet/crates/cli/src/cli_args.rs
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Run benchmark on ubuntu-latest
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Lint and Test (macos-latest)
  • GitHub Check: Lint and Test (ubuntu-latest)
  • GitHub Check: Lint and Test (windows-latest)
  • GitHub Check: Dylint
  • GitHub Check: Code Coverage
  • GitHub Check: Doc
  • GitHub Check: Run benchmark on ubuntu-latest
  • GitHub Check: Compile & Lint
🧰 Additional context used
📓 Path-based instructions (1)
pacquet/**/*.rs

📄 CodeRabbit inference engine (pacquet/AGENTS.md)

pacquet/**/*.rs: When porting a function that fires pnpm:<channel> events through globalLogger, logger.debug(), or streamParser.write(), mirror the call site, payload, and ordering so the reporter parses pacquet's NDJSON the same way it parses pnpm's.
Declare a newtype wrapper for branded string types. Do not collapse the brand into a plain String or &str.
If upstream always validates before construction, validate in pacquet's wrapper too. The wrapper must construct only via TryFrom<String> and/or FromStr. Do not provide an infallible public constructor.
If upstream never validates, just brand for type-safety. Expose an infallible From<String> (and From<&str> when convenient).
If upstream occasionally constructs without validation, expose from_str_unchecked as an escape hatch alongside the validating constructor.
Match upstream serde behavior for branded types that cross JSON, YAML, or INI boundaries. Use #[serde(try_from = "String")] for deserialization and #[serde(into = "String")] for serialization.
Use #[derive(derive_more::From)] and #[derive(derive_more::Into)] for mechanical conversion impls. Fall back to manual impl only when conversion needs custom logic.
String-literal unions should become enums, not newtype wrappers. Model closed sets of valid string values as enums.
Template literal types should be treated as branded strings with validation discipline from rules 2-5.
Choose owned vs. borrowed parameters to minimize copies. Widen to the most encompassing type (&Path over &PathBuf, &str over &String) when it doesn't force extra copies.
Prefer Arc::clone(&x) / Rc::clone(&x) over x.clone() for reference-counted types, so the cost is visible at the call site.
Follow Rust API Guidelines for naming conventions.
Do not use star imports inside module bodies. Write use super::{Foo, bar} instead of use super::*;. Two forms stay allowed: external-crate preludes like use rayon::prelude::*; and root-of-module re-...

Files:

  • pacquet/crates/cli/src/cli_args.rs
🧠 Learnings (2)
📚 Learning: 2026-05-20T19:40:55.051Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11774
File: pacquet/crates/resolving-deps-resolver/src/resolve_peers.rs:0-0
Timestamp: 2026-05-20T19:40:55.051Z
Learning: In the pacquet Rust code, ensure the semver implementation uses the `node-semver` crate (not `nodejs-semver`). `node-semver`’s public API does not include a `satisfies_with_prerelease`-style method; prerelease-tolerant matching should be implemented inline by first calling `Range::satisfies`, and when it rejects a prerelease version, retry matching against a stripped `MAJOR.MINOR.PATCH` base of the prerelease version.

Applied to files:

  • pacquet/crates/cli/src/cli_args.rs
📚 Learning: 2026-05-20T23:07:58.444Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11784
File: pacquet/crates/resolving-deps-resolver/src/hoist_peers.rs:120-133
Timestamp: 2026-05-20T23:07:58.444Z
Learning: When reviewing code in this pacquet Rust port, follow the upstream pnpm compatibility rule: only match pnpm’s behavior exactly. Do not propose review changes that intentionally deviate from pnpm’s documented/observed behavior, even if pnpm appears buggy. If you identify a real bug in pnpm behavior, the review should prioritize fixing it upstream in pnpm first, and avoid implementing a pnpm-behavior workaround here unless the same fix has already landed upstream.

Applied to files:

  • pacquet/crates/cli/src/cli_args.rs
🔇 Additional comments (2)
pacquet/crates/cli/src/cli_args.rs (1)

24-24: LGTM!

.github/workflows/pacquet-release-to-npm.yml (1)

75-95: LGTM!


📝 Walkthrough

Walkthrough

This PR automates version injection for pacquet CLI releases. The workflow now validates a manually provided semver version and patches the CLI clap version attribute during the build step, ensuring the compiled binary reports the intended release version without manual source edits.

Changes

Release Version Management

Layer / File(s) Summary
CLI version baseline update
pacquet/crates/cli/src/cli_args.rs
Clap-reported CLI version incremented from 0.2.1 to 0.2.2 in the CliArgs version attribute.
Workflow version validation and injection
.github/workflows/pacquet-release-to-npm.yml
Build job validates inputs.version against semver regex, then uses perl to patch cli_args.rs with the provided version and verifies the injection with grep.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • pnpm/pnpm#11652: Both PRs modify .github/workflows/pacquet-release-to-npm.yml to semver-validate the manually provided inputs.version and inject that version into build/package artifacts at runtime, so the workflow logic changes are directly overlapping.

Poem

🐰 A version bump and workflow flow,
Perl patches as the pipelines go,
Semver checks keep it just right,
Automation makes releases bright,
No more edits—the machines write!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: patching the --version literal during the release build process, which is the core objective of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pacquet-cli-version-autopatch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
tarball/download_dependency    1.00      7.7±0.31ms   566.7 KB/sec    1.03      7.9±0.50ms   552.1 KB/sec

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.47%. Comparing base (0dd1ec4) to head (c780e94).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #11812   +/-   ##
=======================================
  Coverage   87.47%   87.47%           
=======================================
  Files         202      202           
  Lines       23704    23704           
=======================================
  Hits        20735    20735           
  Misses       2969     2969           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Scenario: Frozen Lockfile

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.462 ± 0.057 2.378 2.531 1.02 ± 0.03
pacquet@main 2.416 ± 0.060 2.353 2.555 1.00
pnpm 4.927 ± 0.039 4.863 4.996 2.04 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4623472442999996,
      "stddev": 0.05693212216118505,
      "median": 2.4612821928999997,
      "user": 2.74035124,
      "system": 3.7955662400000003,
      "min": 2.3781981049,
      "max": 2.5312554489,
      "times": [
        2.5121219809,
        2.5312554489,
        2.4125988039,
        2.3898779539,
        2.4645570868999997,
        2.3781981049,
        2.4580072989,
        2.5296735739,
        2.5077110979,
        2.4394710929
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.4156959388,
      "stddev": 0.060074574006443,
      "median": 2.4028696254,
      "user": 2.7709589399999994,
      "system": 3.7745668399999994,
      "min": 2.3528810319,
      "max": 2.5545166389,
      "times": [
        2.3936644939,
        2.4121327009,
        2.3528810319,
        2.3823691089,
        2.5545166389,
        2.4093833409,
        2.4830053479,
        2.4010319849,
        2.3632674739,
        2.4047072659
      ]
    },
    {
      "command": "pnpm",
      "mean": 4.927063482300001,
      "stddev": 0.03887862590865631,
      "median": 4.9278037359,
      "user": 8.338695140000002,
      "system": 4.322487539999999,
      "min": 4.8630045689,
      "max": 4.996393059900001,
      "times": [
        4.9501187709000005,
        4.8630045689,
        4.933007459900001,
        4.960582677900001,
        4.9241397539000005,
        4.9314677179,
        4.914547805900001,
        4.996393059900001,
        4.8741071819,
        4.923265825900001
      ]
    }
  ]
}

Scenario: Frozen Lockfile (Hot Cache)

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 695.3 ± 47.6 666.4 822.9 1.00 ± 0.09
pacquet@main 692.7 ± 40.7 654.3 784.6 1.00
pnpm 2621.9 ± 123.1 2487.9 2901.8 3.79 ± 0.28
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.69531208356,
      "stddev": 0.04760048689515899,
      "median": 0.67857499126,
      "user": 0.3881392,
      "system": 1.55811656,
      "min": 0.66638772426,
      "max": 0.82290018026,
      "times": [
        0.82290018026,
        0.67094635626,
        0.67798582826,
        0.6676102592600001,
        0.71935072126,
        0.69154352826,
        0.68874787226,
        0.66848421126,
        0.67916415426,
        0.66638772426
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6926755337599999,
      "stddev": 0.04072978448966641,
      "median": 0.6778802242599999,
      "user": 0.38956329999999995,
      "system": 1.5656124599999999,
      "min": 0.65426460526,
      "max": 0.7846380322600001,
      "times": [
        0.72335206726,
        0.7846380322600001,
        0.66431414826,
        0.65426460526,
        0.67283151326,
        0.66243394126,
        0.70823527526,
        0.71462427026,
        0.68292893526,
        0.65913254926
      ]
    },
    {
      "command": "pnpm",
      "mean": 2.6218551658600004,
      "stddev": 0.12312314229710096,
      "median": 2.5902588047600004,
      "user": 3.2771828,
      "system": 2.2619941599999995,
      "min": 2.4878528062600003,
      "max": 2.90180992426,
      "times": [
        2.6628088452600003,
        2.53251104826,
        2.4878528062600003,
        2.67428121926,
        2.5205748952600002,
        2.5437069342600003,
        2.7144883762600003,
        2.6096494862600004,
        2.5708681232600004,
        2.90180992426
      ]
    }
  ]
}

@zkochan zkochan merged commit f279d77 into main May 21, 2026
28 checks passed
@zkochan zkochan deleted the pacquet-cli-version-autopatch branch May 21, 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.

2 participants