This repository was archived by the owner on May 14, 2026. It is now read-only.
refactor(npmrc): collapse WorkspaceSettings::apply_to with macro#406
Merged
Conversation
Most field assignments in apply_to follow the same shape — `if let
Some(v) = self.X { npmrc.X = v; }` — and the path-resolved fields share
a second shape. Introduce a small function-local macro with two arms
(direct assignment, base-dir resolution) so the boilerplate is written
once. The two genuinely unique cases (`store_dir` wraps in `StoreDir`,
`registry` appends a trailing slash) stay inline.
No behaviour change.
Each invocation now takes a single field, so the macro arms no longer need `$(...)*`. Call sites are one `apply!(name);` per field, which reads more straightforwardly than a comma-separated list inside braces.
This reverts commit 76d78cd.
Micro-Benchmark ResultsLinux |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #406 +/- ##
==========================================
+ Coverage 82.39% 82.46% +0.07%
==========================================
Files 65 65
Lines 3731 3672 -59
==========================================
- Hits 3074 3028 -46
+ Misses 657 644 -13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Inlining the path-resolved fields after dropping the macro arm accidentally lost `virtual_store_dir`, so setting it in `pnpm-workspace.yaml` was silently ignored. Add the missing block alongside `modules_dir`.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors WorkspaceSettings::apply_to in the npmrc workspace YAML loader to reduce repetitive per-field if let Some(...) assignments by introducing a small local macro for direct field copies, while keeping special-case handling for path resolution and registry normalization.
Changes:
- Introduced a local
apply!macro to apply manyOption<T>fields ontoNpmrcvia direct assignment when set. - Kept explicit handling for path-valued fields (
modules_dir,virtual_store_dir,store_dir) and forregistry’s trailing-slash normalization. - Reordered the application flow so the bulk direct assignments happen in one consolidated block.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Integrated-Benchmark Report (Linux)Scenario: Frozen Lockfile
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.5973824391,
"stddev": 0.2857749802816158,
"median": 2.5328784101,
"user": 2.3888941,
"system": 3.4230714200000003,
"min": 2.3793476316,
"max": 3.3801460076,
"times": [
2.4387035716,
2.6324762326,
2.5301845845999997,
2.4622160626,
2.4520468626,
2.3793476316,
2.5889391566,
3.3801460076,
2.5355722356,
2.5741920456
]
},
{
"command": "pacquet@main",
"mean": 2.4080703563999997,
"stddev": 0.07703835571946402,
"median": 2.3877372071,
"user": 2.3566448,
"system": 3.3519410199999995,
"min": 2.2924023376,
"max": 2.5355936216,
"times": [
2.3757100896,
2.3500886415999998,
2.5262296296,
2.5355936216,
2.4287058176,
2.3993763646,
2.2924023376,
2.3760980496,
2.3553211575999997,
2.4411778546
]
},
{
"command": "pnpm",
"mean": 6.2201405867999995,
"stddev": 0.07668746224546355,
"median": 6.2211889476,
"user": 9.039660000000001,
"system": 4.521090320000001,
"min": 6.0704302096,
"max": 6.3638860886,
"times": [
6.1880836956,
6.1739024246,
6.3638860886,
6.2270899025999995,
6.2206718925999995,
6.0704302096,
6.2982680926,
6.2024365336,
6.2349310256,
6.2217060025999995
]
}
]
}Scenario: Frozen Lockfile (Hot Cache)
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.7146434838400001,
"stddev": 0.03763542110664967,
"median": 0.7094533765400002,
"user": 0.25158939999999996,
"system": 1.3603226999999998,
"min": 0.6680517735400001,
"max": 0.8080795475400001,
"times": [
0.8080795475400001,
0.7070401895400001,
0.6680517735400001,
0.7119527015400001,
0.7071889885400001,
0.7336075375400001,
0.7117177645400001,
0.69023424454,
0.7208242095400001,
0.68773788154
]
},
{
"command": "pacquet@main",
"mean": 0.7597708161400001,
"stddev": 0.039236278339127094,
"median": 0.7579173755400002,
"user": 0.25202319999999995,
"system": 1.3801342999999997,
"min": 0.70338907654,
"max": 0.8123845205400001,
"times": [
0.8118740955400001,
0.8012849035400001,
0.8123845205400001,
0.7592656025400001,
0.7565691485400001,
0.7375036395400001,
0.7474400405400001,
0.7067653385400001,
0.7612317955400001,
0.70338907654
]
},
{
"command": "pnpm",
"mean": 2.58453596764,
"stddev": 0.07425506148794057,
"median": 2.58256484254,
"user": 3.1902081999999994,
"system": 2.2287887000000004,
"min": 2.4511977805400003,
"max": 2.69474663754,
"times": [
2.69474663754,
2.5749855575400002,
2.5645543625400005,
2.59943316854,
2.4511977805400003,
2.5901441275400003,
2.50922954854,
2.6099567565400004,
2.55746595454,
2.6936457825400004
]
}
]
} |
zkochan
approved these changes
May 8, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 by CodeRabbit