Repository navigation
fix(add): support multiple package selectors - #12995
Conversation
📝 WalkthroughWalkthrough
ChangesMulti-package add flow
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant AddArgs
participant PackageManagerAdd
participant WorkspaceManifest
participant Install
CLI->>AddArgs: parse multiple selectors
AddArgs->>PackageManagerAdd: pass package_names
PackageManagerAdd->>WorkspaceManifest: write dependencies and catalogs
PackageManagerAdd->>Install: install resolved dependency groups
Install-->>CLI: complete batched add
Possibly related issues
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12995 +/- ##
==========================================
+ Coverage 85.63% 85.65% +0.02%
==========================================
Files 500 500
Lines 80138 80233 +95
==========================================
+ Hits 68624 68723 +99
+ Misses 11514 11510 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.8501645611,
"stddev": 0.14839380548000689,
"median": 2.9099849013000005,
"user": 2.60239626,
"system": 2.0167037199999998,
"min": 2.5428662778000004,
"max": 3.0136688058,
"times": [
2.8811699568000004,
2.6748804148,
2.7419080498,
2.5428662778000004,
2.9315181878000005,
2.9395743058000003,
2.8884516148,
3.0136688058,
2.9441037928000005,
2.9435042048000004
]
},
{
"command": "pacquet@main",
"mean": 2.7268249313000004,
"stddev": 0.12975165644140998,
"median": 2.6924129533000003,
"user": 2.64384086,
"system": 2.0245931199999996,
"min": 2.5739491748000005,
"max": 2.9250707578000004,
"times": [
2.7017523308,
2.6322105908,
2.5857926858,
2.9250707578000004,
2.6372530918000003,
2.7695943838000003,
2.5739491748000005,
2.8595078838000005,
2.9000448378000003,
2.6830735758000004
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5952526607000002,
"stddev": 0.17558965607236107,
"median": 1.5758904843000001,
"user": 1.6533293599999996,
"system": 1.6064664199999998,
"min": 1.3988484858,
"max": 1.8409763728,
"times": [
1.8409763728,
1.7555788178,
1.8085344908,
1.4263755838,
1.5688917098000001,
1.5828892588,
1.7275745328,
1.4174704718,
1.4253868828,
1.3988484858
]
},
{
"command": "pnpr@main",
"mean": 1.617947332,
"stddev": 0.1722240167869847,
"median": 1.6001720287999999,
"user": 1.6720412599999996,
"system": 1.53905922,
"min": 1.4277770567999999,
"max": 1.9149929808,
"times": [
1.4692157478,
1.7583710388,
1.4368369508,
1.4935884528,
1.4968125838,
1.9149929808,
1.7162246018,
1.4277770567999999,
1.7035314738,
1.7621224328
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.24916001148000003,
"stddev": 0.022706150195343916,
"median": 0.24770862588000003,
"user": 0.23143788,
"system": 0.6629506599999999,
"min": 0.22179496438000001,
"max": 0.29122166738,
"times": [
0.22179496438000001,
0.22700256638000002,
0.22314151438000002,
0.24615853838,
0.25478424837999997,
0.24925871338000002,
0.24599456138,
0.25331320438,
0.29122166738,
0.27893013637999997
]
},
{
"command": "pacquet@main",
"mean": 0.23199604358,
"stddev": 0.02449214127182562,
"median": 0.22615432088000004,
"user": 0.19644898000000002,
"system": 0.6513330599999999,
"min": 0.20295558738000002,
"max": 0.27737915537999996,
"times": [
0.21611174338000003,
0.21481050138000002,
0.20295558738000002,
0.20971843538,
0.22702982838000002,
0.22527881338000003,
0.23323831438,
0.27737915537999996,
0.26560960138,
0.24782845538
]
},
{
"command": "pnpr@HEAD",
"mean": 0.25318840018,
"stddev": 0.019936238918184804,
"median": 0.25219599588,
"user": 0.22389958000000004,
"system": 0.6295308599999999,
"min": 0.23053495038000002,
"max": 0.29427223537999997,
"times": [
0.23169115238000001,
0.23750378638000003,
0.23882044038000003,
0.29427223537999997,
0.25506569738,
0.24932629438,
0.26048870938,
0.26835156237999996,
0.26582917338,
0.23053495038000002
]
},
{
"command": "pnpr@main",
"mean": 0.28233484597999997,
"stddev": 0.02290014450954656,
"median": 0.27726068787999997,
"user": 0.26183888,
"system": 0.6733907599999999,
"min": 0.25084370938,
"max": 0.32590478738,
"times": [
0.29322686838,
0.25084370938,
0.29032050938,
0.25966845237999997,
0.27052390038,
0.28018436937999996,
0.27433700637999997,
0.30956592637999997,
0.32590478738,
0.26877293038
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.8394211649,
"stddev": 0.03197016247411597,
"median": 2.8419584027000004,
"user": 2.2689563799999997,
"system": 1.7167278,
"min": 2.7904880522,
"max": 2.8998075772000003,
"times": [
2.8493158992,
2.8467578202,
2.8998075772000003,
2.8711697932,
2.8472222132000002,
2.8302350862,
2.7904880522,
2.8371589852000003,
2.8001778402,
2.8218783822
]
},
{
"command": "pacquet@main",
"mean": 2.8756136393000005,
"stddev": 0.04365742769137125,
"median": 2.8770433147000003,
"user": 2.4996284799999997,
"system": 1.7919832,
"min": 2.8056908362,
"max": 2.9326013412000003,
"times": [
2.8709498142000003,
2.8056908362,
2.8651377152000004,
2.8831368152000003,
2.9244996522,
2.9326013412000003,
2.9070750662,
2.8137931492000003,
2.9051335582,
2.8481184452
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6350228294,
"stddev": 0.12800207534515065,
"median": 1.6425686262,
"user": 1.61147088,
"system": 1.5478576,
"min": 1.4598223552,
"max": 1.8781209572000002,
"times": [
1.7117414342000001,
1.5543037342000001,
1.4598223552,
1.8781209572000002,
1.7254522952000002,
1.6452908982,
1.5581497282,
1.6398463542000001,
1.4730575772,
1.7044429602000002
]
},
{
"command": "pnpr@main",
"mean": 1.7688067380999999,
"stddev": 0.19340923880989375,
"median": 1.8378369527,
"user": 1.58069608,
"system": 1.540982,
"min": 1.4715721472,
"max": 1.9742189342,
"times": [
1.9502878302000002,
1.9742189342,
1.9467407872,
1.8543632132,
1.5925787232000002,
1.9026125622000003,
1.4963054482000002,
1.4715721472,
1.6780770432,
1.8213106922000002
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6607440654600001,
"stddev": 0.012384619683788779,
"median": 0.6592902218600001,
"user": 0.84506464,
"system": 0.8121112199999999,
"min": 0.6403781848600001,
"max": 0.67590831086,
"times": [
0.67590831086,
0.6720464968600001,
0.6559883878600001,
0.67125468986,
0.6519843808600001,
0.6743483068600001,
0.6403781848600001,
0.6469514528600001,
0.66233818986,
0.6562422538600001
]
},
{
"command": "pacquet@main",
"mean": 0.6918114880600001,
"stddev": 0.039167059600144286,
"median": 0.69782556486,
"user": 0.9024287400000001,
"system": 0.86904662,
"min": 0.6393874358600001,
"max": 0.75399272786,
"times": [
0.6393874358600001,
0.6511427118600001,
0.66165257986,
0.6504172218600001,
0.6938445318600001,
0.7147283548600001,
0.75399272786,
0.7273133008600001,
0.7018065978600001,
0.7238294178600001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.28755043976,
"stddev": 0.013740851020363393,
"median": 0.28681853236,
"user": 0.23455524,
"system": 0.60360552,
"min": 0.26513130886,
"max": 0.31130692586,
"times": [
0.29900660086,
0.29677909886,
0.28435316686,
0.28290139386,
0.26922122086,
0.28928389786,
0.26513130886,
0.29335221886,
0.31130692586,
0.28416856486
]
},
{
"command": "pnpr@main",
"mean": 0.31134151645999997,
"stddev": 0.01366971298923503,
"median": 0.30731132435999997,
"user": 0.24828333999999996,
"system": 0.65118042,
"min": 0.29764572386,
"max": 0.33547148986,
"times": [
0.30980698486,
0.30481566386,
0.30065784286,
0.29764572386,
0.31245000586,
0.30460860086,
0.33547148986,
0.33465703886,
0.31435345786,
0.29894835586
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.9207235294,
"stddev": 0.048898908845778084,
"median": 1.9092788607000002,
"user": 1.0691165200000001,
"system": 0.8477987199999999,
"min": 1.8530003862000002,
"max": 2.0135149992,
"times": [
2.0135149992,
1.9020850072000002,
1.8530003862000002,
1.8856667582000002,
1.9156971762000001,
1.9398136312,
1.8750687852,
1.9810410052,
1.9028605452,
1.9384870002
]
},
{
"command": "pacquet@main",
"mean": 1.8609754872000004,
"stddev": 0.023758484275104238,
"median": 1.8567468807000003,
"user": 0.99708732,
"system": 0.79195862,
"min": 1.8294598142,
"max": 1.8994421332000002,
"times": [
1.8589180222000001,
1.8778642342000003,
1.8752404242,
1.8444768872000001,
1.8294598142,
1.8394017712000001,
1.8994421332000002,
1.8906854062,
1.8396904402000003,
1.8545757392000002
]
},
{
"command": "pnpr@HEAD",
"mean": 0.26873541509999993,
"stddev": 0.01018548134920109,
"median": 0.2680435007,
"user": 0.18948671999999997,
"system": 0.54515172,
"min": 0.2562445922,
"max": 0.2901289292,
"times": [
0.2587591312,
0.27495245220000003,
0.27109724820000003,
0.2637353862,
0.2690945212,
0.25958863320000003,
0.2669924802,
0.27676077720000003,
0.2901289292,
0.2562445922
]
},
{
"command": "pnpr@main",
"mean": 0.2573308808,
"stddev": 0.01562288417269523,
"median": 0.2577002537,
"user": 0.19600402,
"system": 0.53583582,
"min": 0.2310427442,
"max": 0.2795372912,
"times": [
0.2310427442,
0.2390324402,
0.2590355122,
0.2691029832,
0.2795372912,
0.2563649952,
0.2493606632,
0.2714528582,
0.2707083632,
0.2476709572
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.35016852006000004,
"stddev": 0.008775905507127589,
"median": 0.35138950726,
"user": 0.33846273999999993,
"system": 0.08294458000000002,
"min": 0.33342819426000003,
"max": 0.35974739226,
"times": [
0.33995855926,
0.34564391226,
0.35927516826,
0.33342819426000003,
0.35198691826,
0.34716634526,
0.35079209626,
0.35442515726,
0.35974739226,
0.35926145726000003
]
},
{
"command": "pacquet@main",
"mean": 0.43884483646000005,
"stddev": 0.08400049500515559,
"median": 0.44207565276000005,
"user": 0.42107313999999996,
"system": 0.10682867999999998,
"min": 0.34269639826000003,
"max": 0.57660492726,
"times": [
0.38166123326,
0.42820656926,
0.45594473626000004,
0.45909284726,
0.49116007026,
0.57660492726,
0.5521308192600001,
0.34848298226,
0.34269639826000003,
0.35246778126
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08759564819939394,
"stddev": 0.0028619841535162164,
"median": 0.08715458826000001,
"user": 0.01787132484848485,
"system": 0.013219022424242425,
"min": 0.08273523326000001,
"max": 0.09271298026000001,
"times": [
0.08503138426000001,
0.08820975326000001,
0.08715458826000001,
0.08406327726000001,
0.08321241526,
0.08865930126,
0.09167828826,
0.08862243226000001,
0.08273523326000001,
0.08534773726000001,
0.08750148926000001,
0.08667566426000001,
0.08954973926000001,
0.08492714726,
0.08495814726,
0.08645265726000001,
0.08281686626000001,
0.08469960526,
0.09130625926000001,
0.08936427926000001,
0.08678078626,
0.08699371126000001,
0.08987856526000002,
0.09103170926000001,
0.09271298026000001,
0.08622908926,
0.08645760326000002,
0.09025755926000001,
0.08983046126000001,
0.08546859626000002,
0.09210873626,
0.09241161226000001,
0.08752871526000001
]
},
{
"command": "pnpr@main",
"mean": 0.08873393022969699,
"stddev": 0.0033673260761261257,
"median": 0.08972648726000002,
"user": 0.019446052121212122,
"system": 0.013034089696969698,
"min": 0.08293570126000001,
"max": 0.09504747326000001,
"times": [
0.08402655526000001,
0.09213903526000002,
0.08385933926000001,
0.08654554626000001,
0.08293570126000001,
0.08575268826000002,
0.09165345226,
0.08747728126000001,
0.08864722426,
0.09504747326000001,
0.08879042226000002,
0.08513060126000001,
0.09082262426000001,
0.08497363426000001,
0.09026724726,
0.09025885026000001,
0.09117517126,
0.09023338726,
0.08296481526,
0.08403191726,
0.09407550826000001,
0.09186634826000001,
0.08421484626,
0.09256396726,
0.08972648726000002,
0.08760806726,
0.08982265326000001,
0.09065570626000001,
0.09157914926,
0.08852481226000002,
0.09260563926000001,
0.09058778326000001,
0.08765576226
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.608291044,
"stddev": 0.1423430511641906,
"median": 4.5581302754,
"user": 2.15521472,
"system": 1.60432772,
"min": 4.4523633989,
"max": 4.8813933959,
"times": [
4.8813933959,
4.4523633989,
4.6653834729,
4.6744117769,
4.7921699149000005,
4.4752446989,
4.4948929069000005,
4.5725108599,
4.530790323900001,
4.5437496909
]
},
{
"command": "pacquet@main",
"mean": 4.5973768101,
"stddev": 0.1672592802780101,
"median": 4.534758093400001,
"user": 2.31860642,
"system": 1.7187776200000002,
"min": 4.4374500399,
"max": 4.9506938679,
"times": [
4.6138356089000006,
4.5764379659,
4.5371447029,
4.9506938679,
4.5166839429,
4.840741915900001,
4.511172843900001,
4.457235728900001,
4.4374500399,
4.5323714839
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5918256452999997,
"stddev": 0.08042838824962363,
"median": 3.5788688569,
"user": 1.73321702,
"system": 1.6191804199999997,
"min": 3.4968057149,
"max": 3.7372048879,
"times": [
3.7372048879,
3.5383670448999998,
3.4968057149,
3.7098017038999997,
3.5067487369,
3.5542475379,
3.6034901758999998,
3.6127100668999996,
3.6090142519,
3.5498663319
]
},
{
"command": "pnpr@main",
"mean": 3.6764129110999995,
"stddev": 0.1713236736463684,
"median": 3.6017008054,
"user": 1.99744442,
"system": 1.7894986199999998,
"min": 3.5538123359,
"max": 4.049588146900001,
"times": [
3.5909691739,
3.5831338529,
3.6022241469,
3.6011774639,
3.6280602009,
3.5538123359,
3.5811750359,
3.6339505369,
3.9400382169,
4.049588146900001
]
}
]
} |
|
| Branch | pr/12995 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,635.02 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 268.74 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 287.55 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 87.60 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,595.25 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,591.83 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 253.19 ms |
38b2004 to
6722caa
Compare
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Confidence Score: 5/5Safe to merge; the change is well-scoped and the pre-validation-before-init ordering is a correctness improvement over the prior behavior. The refactoring is clean — validation happens before any filesystem side-effects, manifest updates are batched, and the workspace-manifest writer reads/writes the YAML file at most once per command. All three install paths (regular, global, config) are consistently updated and covered by new integration tests. No files require special attention. Reviews (3): Last reviewed commit: "refactor(cli): tighten the multi-selecto..." | Re-trigger Greptile |
6722caa to
98a5e81
Compare
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Route `add --config` on the parsed selector map itself instead of re-checking the `--config` flag and unwrapping the map, so the flag and the map cannot drift into a panic. Record why the parse has to precede `State::init`: it scaffolds a `package.json`, so a selector rejected afterwards would strand a half-created project. Drop `set_config_dependency`, which lost its last production caller when `add --config` moved to the batched writer, and let the single-entry test helper call the batched writer directly. Assert the batched write's exact file contents rather than per-fragment containment, matching the sibling tests and pinning the sorted block order the fragment assertions hid. Restore the dlx rationale on `add_package`'s doc comment.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/workspace-manifest-writer/src/lib.rs (1)
137-139: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMove implementation rationale to regular comments.
As per path instructions for
pnpm/CODE_STYLE_GUIDE.md, doc comments (///) should be used strictly for API contracts, while implementation rationale must go in regular comments (//). The explanation of howpnpm add --configuses this function and handles the lockfile is implementation rationale.♻️ Proposed refactor
-/// and writing the file at most once. Used by `pnpm add --config`; the -/// resolved integrity is recorded separately in the env lockfile, so only -/// the clean specifier is written here. +/// and writing the file at most once. +// Used by `pnpm add --config`; the resolved integrity is recorded separately +// in the env lockfile, so only the clean specifier is written here.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm/crates/workspace-manifest-writer/src/lib.rs` around lines 137 - 139, Convert the implementation-rationale documentation immediately above the relevant workspace manifest writer function to regular comments using // instead of ///. Preserve the explanation about pnpm add --config, single-write behavior, and separate integrity recording, while leaving any API-contract documentation unchanged.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pnpm/crates/workspace-manifest-writer/src/lib.rs`:
- Around line 137-139: Convert the implementation-rationale documentation
immediately above the relevant workspace manifest writer function to regular
comments using // instead of ///. Preserve the explanation about pnpm add
--config, single-write behavior, and separate integrity recording, while leaving
any API-contract documentation unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 827d1224-3a87-466a-bde8-4366e64edf0a
📒 Files selected for processing (3)
pnpm/crates/cli/src/cli_args/add.rspnpm/crates/workspace-manifest-writer/src/lib.rspnpm/crates/workspace-manifest-writer/src/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- pnpm/crates/workspace-manifest-writer/src/tests.rs
- pnpm/crates/cli/src/cli_args/add.rs
|
Code review by qodo was updated up to the latest commit d4d7d5c |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
… from Add list_dependency_groups existed only because the dependency-group list used to be consumed more than once. pnpm#12995 collapsed that to a single collect-and-reuse, so the Fn() -> DependencyGroupList closure indirection no longer buys anything: take dependency_groups directly instead. Threads the same simplification through add_package/add_packages and their five call sites (add, global, dlx, runtime, self_update/install_pnpm), each of which drops a trivial closure/std::iter::once wrapper for a plain value or array literal. Pure internal refactor: no user-visible behavior change, so no changeset and no TypeScript counterpart. Closes pnpm#13088 Co-Authored-By: Claude Sonnet 5 <[email protected]>
… from Add (#13107) refactor(add): drop the vestigial Fn() -> DependencyGroupList generic from Add list_dependency_groups existed only because the dependency-group list used to be consumed more than once. #12995 collapsed that to a single collect-and-reuse, so the Fn() -> DependencyGroupList closure indirection no longer buys anything: take dependency_groups directly instead. Threads the same simplification through add_package/add_packages and their five call sites (add, global, dlx, runtime, self_update/install_pnpm), each of which drops a trivial closure/std::iter::once wrapper for a plain value or array literal. Pure internal refactor: no user-visible behavior change, so no changeset and no TypeScript counterpart. Closes #13088
Summary
Pacquet's
addcommand now accepts every package selector supplied in one invocation for regular, global, and configuration-dependency installs.The command validates the complete selector list before initializing installation state, batches manifest updates, and performs one install/save operation. The workspace manifest writer now also supports applying multiple configuration-dependency updates atomically.
The TypeScript CLI already supports multiple package selectors, so this change brings the Rust CLI to parity. No TypeScript changes are required.
Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Codex, GPT-5).
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit
pacquet addnow accepts multiple package selectors in a single command and installs them together.-g) support batched additions for all selected packages.pacquet add --configcan record multiple config dependencies in one run, updating the workspace manifest and related lockfile artifacts.