Repository navigation
fix(pacquet/login): honor the scope setting - #13255
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe PR adds ChangesLogin scope configuration
Estimated code review effort: 3 (Moderate) | ~25 minutes Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Micro-Benchmark ResultsLinux |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13255 +/- ##
==========================================
- Coverage 88.00% 87.99% -0.01%
==========================================
Files 567 567
Lines 97930 97944 +14
==========================================
+ Hits 86179 86188 +9
- Misses 11751 11756 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time). Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.55215781054,
"stddev": 0.17612920259938342,
"median": 2.5520133337399997,
"user": 1.53286652,
"system": 1.28250666,
"min": 2.3514363427399996,
"max": 2.79122496874,
"times": [
2.37877353974,
2.79122496874,
2.73193613774,
2.58023430574,
2.3725760237399998,
2.3788206047399996,
2.6435258237399997,
2.52379236174,
2.76925799674,
2.3514363427399996
]
},
{
"command": "pacquet@main",
"mean": 2.5428749746399997,
"stddev": 0.17523416760932536,
"median": 2.5774627787399997,
"user": 1.48781352,
"system": 1.2506303600000002,
"min": 2.33167413674,
"max": 2.7697836047399997,
"times": [
2.6831862527399997,
2.4986401467399997,
2.7297166917399998,
2.34906488674,
2.39300656074,
2.33167413674,
2.66441176174,
2.35298029374,
2.65628541074,
2.7697836047399997
]
},
{
"command": "pnpr@HEAD",
"mean": 1.54280673484,
"stddev": 0.13764062762037202,
"median": 1.53752108624,
"user": 1.07152552,
"system": 1.10513086,
"min": 1.36749567174,
"max": 1.73719221674,
"times": [
1.67838792174,
1.71163869674,
1.4168715947400001,
1.36893593574,
1.60213100074,
1.47037213774,
1.52788839474,
1.36749567174,
1.73719221674,
1.54715377774
]
},
{
"command": "pnpr@main",
"mean": 1.4941659864399999,
"stddev": 0.16524723722909315,
"median": 1.42313247224,
"user": 1.06345432,
"system": 1.11341976,
"min": 1.34788400674,
"max": 1.7804863347400002,
"times": [
1.44893390074,
1.36137613574,
1.35940046274,
1.60815817774,
1.55277394774,
1.35026224474,
1.34788400674,
1.7804863347400002,
1.73505360974,
1.3973310437400002
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25549964624,
"stddev": 0.00901143500022442,
"median": 0.25740869174000003,
"user": 0.19753632,
"system": 0.53522994,
"min": 0.24046002074000003,
"max": 0.26653477774,
"times": [
0.24355467274000003,
0.25002732474,
0.24046002074000003,
0.25492767074,
0.25101904774,
0.26396234274,
0.26653477774,
0.26407022774,
0.25988971274,
0.26055066474
]
},
{
"command": "pacquet@main",
"mean": 0.25202029053999997,
"stddev": 0.008147456691853919,
"median": 0.25042774674,
"user": 0.19598001999999998,
"system": 0.5288582399999999,
"min": 0.24370708974000002,
"max": 0.26983626974,
"times": [
0.25172437274,
0.24640879574000002,
0.25771232274,
0.24370708974000002,
0.24619040574000003,
0.24374845874000003,
0.24913112074000002,
0.26983626974,
0.25406850574,
0.25767556374
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27677608504,
"stddev": 0.006458116723845182,
"median": 0.27776409924,
"user": 0.21162282000000002,
"system": 0.5505070400000001,
"min": 0.26359878074,
"max": 0.28498976874,
"times": [
0.27689985974,
0.27877776874,
0.27697025274,
0.26785835474,
0.27855794574,
0.28498976874,
0.28167955974,
0.28161897774,
0.27680958174,
0.26359878074
]
},
{
"command": "pnpr@main",
"mean": 0.27056017974,
"stddev": 0.00875583872953946,
"median": 0.27080804474,
"user": 0.21934952000000002,
"system": 0.52228074,
"min": 0.25528640374,
"max": 0.28323073474,
"times": [
0.28323073474,
0.25528640374,
0.26161146774,
0.27230427674,
0.26820696874,
0.26982434074,
0.26470562074,
0.27179174874,
0.27634646874,
0.28229376674
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.5960352562,
"stddev": 0.018541925952571422,
"median": 2.5993716940000002,
"user": 1.4812404799999999,
"system": 1.30332554,
"min": 2.5651212525,
"max": 2.6266660825,
"times": [
2.5651212525,
2.5769821645,
2.6028990735,
2.6078316725,
2.5749944985,
2.6266660825,
2.5980250735,
2.6007183145,
2.6094416295,
2.5976728005
]
},
{
"command": "pacquet@main",
"mean": 2.6027207636,
"stddev": 0.013985401210611684,
"median": 2.6013025775000003,
"user": 1.45401018,
"system": 1.3148280399999996,
"min": 2.5821044925,
"max": 2.6249603015,
"times": [
2.6161687635,
2.6144229015000002,
2.6024568525,
2.6103368725,
2.5955637575,
2.6001483025,
2.5821044925,
2.5979188385,
2.5831265535,
2.6249603015
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6430977042000001,
"stddev": 0.17468257832571282,
"median": 1.6618527090000002,
"user": 1.01475888,
"system": 1.1774469399999998,
"min": 1.4292006595,
"max": 1.8450192565,
"times": [
1.4324039605,
1.4766367985,
1.7577446275000002,
1.7995060405,
1.5091243295,
1.7951844665,
1.5659607905000001,
1.8201961125000001,
1.8450192565,
1.4292006595
]
},
{
"command": "pnpr@main",
"mean": 1.6262138785000002,
"stddev": 0.15054234682569936,
"median": 1.574375996,
"user": 1.01619758,
"system": 1.14692364,
"min": 1.4257649405000001,
"max": 1.8259450195000002,
"times": [
1.7692709835,
1.4487461305,
1.7406715735,
1.5364148315000001,
1.4257649405000001,
1.5828532465,
1.8224582145000001,
1.8259450195000002,
1.5658987455000002,
1.5441150995
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.3975198489800001,
"stddev": 0.008173071718091946,
"median": 0.40008509868000003,
"user": 0.5151196599999999,
"system": 0.70509328,
"min": 0.38095850518,
"max": 0.40919381918000003,
"times": [
0.40109623518000004,
0.40919381918000003,
0.39028627118000003,
0.40227023218,
0.39311793518,
0.39907396218,
0.40446471718,
0.40142313918,
0.39331367318,
0.38095850518
]
},
{
"command": "pacquet@main",
"mean": 0.38969643958000005,
"stddev": 0.004965070573609055,
"median": 0.38837964168000005,
"user": 0.51341286,
"system": 0.6768614800000001,
"min": 0.38400967118,
"max": 0.39946601918,
"times": [
0.38641793918,
0.38400967118,
0.38557090618,
0.39024483318000003,
0.39352182418000003,
0.38651445018,
0.39946601918,
0.39203852718000004,
0.38536238418,
0.39381784118
]
},
{
"command": "pnpr@HEAD",
"mean": 0.31183747528000005,
"stddev": 0.008596797270425538,
"median": 0.31017269068,
"user": 0.19802666,
"system": 0.54599078,
"min": 0.29784987818,
"max": 0.32553060918,
"times": [
0.31404572718,
0.32553060918,
0.30260473718,
0.31657837818,
0.30995317318,
0.30854127718,
0.31039220818,
0.32387356418,
0.30900520018,
0.29784987818
]
},
{
"command": "pnpr@main",
"mean": 0.30899704848,
"stddev": 0.00415777843955624,
"median": 0.30738036618,
"user": 0.21485566,
"system": 0.53312818,
"min": 0.30482416918,
"max": 0.31701434818,
"times": [
0.30707869918,
0.30768203318,
0.31004977418,
0.30482416918,
0.30670445518,
0.31059225518,
0.30542133418,
0.31701434818,
0.30564414218,
0.31495927418
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.7262353632200003,
"stddev": 0.005409608620912543,
"median": 1.7247617655200003,
"user": 0.7144493000000001,
"system": 0.76148542,
"min": 1.72064941302,
"max": 1.7357384510200002,
"times": [
1.7232385710200002,
1.7264580840200001,
1.7248125100200002,
1.7357384510200002,
1.7283101060200001,
1.72064941302,
1.72219775402,
1.73521755102,
1.72471102102,
1.7210201710200002
]
},
{
"command": "pacquet@main",
"mean": 1.72331242262,
"stddev": 0.006284313618793279,
"median": 1.7232193315200002,
"user": 0.7147540000000001,
"system": 0.7476182200000001,
"min": 1.71771535602,
"max": 1.73877985902,
"times": [
1.7248796590200002,
1.7248447030200003,
1.7240044520200002,
1.7183786330200002,
1.71864066602,
1.71771535602,
1.72543766902,
1.7224342110200002,
1.71800901802,
1.73877985902
]
},
{
"command": "pnpr@HEAD",
"mean": 0.3026724017200001,
"stddev": 0.007540843488788096,
"median": 0.30076905052,
"user": 0.1952022,
"system": 0.52212452,
"min": 0.29211043302,
"max": 0.31555937902000003,
"times": [
0.31349018802,
0.29211043302,
0.29342021602,
0.30116950902,
0.30507276802000005,
0.30036859202000005,
0.30017281402,
0.30023608302000004,
0.31555937902000003,
0.30512403502
]
},
{
"command": "pnpr@main",
"mean": 0.30483430192000005,
"stddev": 0.005979318125468603,
"median": 0.30484943352000005,
"user": 0.1919397,
"system": 0.54475592,
"min": 0.29413812502000003,
"max": 0.31343206802,
"times": [
0.31170507102,
0.30726021202000003,
0.30358053202,
0.29769037602000004,
0.29413812502000003,
0.30391483102000005,
0.30578403602000004,
0.30897622902000005,
0.30186153902,
0.31343206802
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.18022059539000002,
"stddev": 0.003886637289081546,
"median": 0.18062515964000003,
"user": 0.1620077025,
"system": 0.0756894375,
"min": 0.17374517164,
"max": 0.18654421064,
"times": [
0.17750865764,
0.18508679964000002,
0.18195455964,
0.17374517164,
0.18503639364000002,
0.18654421064,
0.17479103864,
0.17996896564,
0.17615512364000002,
0.17840796964,
0.18029545964000002,
0.17559801564000002,
0.18266317064,
0.18185391064,
0.18095485964000002,
0.18296521964
]
},
{
"command": "pacquet@main",
"mean": 0.17200898017846156,
"stddev": 0.01303026208943278,
"median": 0.16946495164,
"user": 0.16010313999999998,
"system": 0.06130669230769232,
"min": 0.16426688764,
"max": 0.21400836764,
"times": [
0.21400836764,
0.17409197364,
0.17083643164,
0.16495751564,
0.16465260264,
0.16722205464,
0.16500230964,
0.16946495164,
0.16426688764,
0.16707456664,
0.17196851064000002,
0.17102708964000002,
0.17154348064
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08737067054909091,
"stddev": 0.0017532765668433728,
"median": 0.08744784564000001,
"user": 0.021359382424242426,
"system": 0.008770393939393937,
"min": 0.08431230964,
"max": 0.09037825664,
"times": [
0.08604667064,
0.08763684164,
0.08575407164,
0.08846910664,
0.08572860364,
0.08763966764,
0.08756412464,
0.08684730664000001,
0.08617636564,
0.08709143664,
0.08716187864000001,
0.08744784564000001,
0.09003595364,
0.08563771264,
0.09037825664,
0.09018704864,
0.08909440264,
0.08448177864,
0.08956123064,
0.08431230964,
0.08908376264000001,
0.08695506964000001,
0.08740431264000001,
0.08896308864000001,
0.08472024864000001,
0.08799515764,
0.08931966864,
0.08518589364000001,
0.08946435064000001,
0.08494610364,
0.08580269364000001,
0.08839179364000001,
0.08774737164
]
},
{
"command": "pnpr@main",
"mean": 0.08725329485212122,
"stddev": 0.001706476303969266,
"median": 0.08746967064000001,
"user": 0.021510685454545455,
"system": 0.008418060606060604,
"min": 0.08332035564000001,
"max": 0.09058966764000001,
"times": [
0.08539327364,
0.08917268264,
0.08787178564,
0.08505936664000001,
0.09057418764,
0.08332035564000001,
0.08809381364,
0.08766975564,
0.08834579764,
0.08781968764,
0.08689844564,
0.08634650764,
0.08903392164,
0.08797415764000001,
0.08576651564,
0.08843882264,
0.08505900564,
0.08779690464,
0.08747980864,
0.08584383264,
0.08684918364000001,
0.09017024864,
0.08534100564000001,
0.08672686364,
0.09058966764000001,
0.08514991764,
0.08886214864,
0.08550103764,
0.08746967064000001,
0.08667108764,
0.08645180464,
0.08854613464000001,
0.08707133064
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.88843465412,
"stddev": 0.17739333160407733,
"median": 0.94362186812,
"user": 0.8139812088888889,
"system": 0.20975981555555556,
"min": 0.5464053521200001,
"max": 1.09134492212,
"times": [
0.69478631312,
0.9925558011200001,
0.79618394912,
0.9268325311200001,
0.94362186812,
1.05858873612,
0.9455924141200001,
0.5464053521200001,
1.09134492212
]
},
{
"command": "pacquet@main",
"mean": 0.8044327570088889,
"stddev": 0.10248228472125374,
"median": 0.8327194141200001,
"user": 0.747595431111111,
"system": 0.17031581555555556,
"min": 0.58062765612,
"max": 0.9397212721200001,
"times": [
0.71476258412,
0.8628961691200001,
0.9397212721200001,
0.8327194141200001,
0.84059611012,
0.58062765612,
0.8433785721200001,
0.82695861912,
0.79823441612
]
},
{
"command": "pnpm@HEAD",
"mean": 2.893384379675556,
"stddev": 0.05870344150390176,
"median": 2.90587769512,
"user": 4.424940431111111,
"system": 0.25405514888888886,
"min": 2.77366203012,
"max": 2.9559881741200003,
"times": [
2.95316701012,
2.83488762312,
2.77366203012,
2.91712097112,
2.8846087911200002,
2.90587769512,
2.9559881741200003,
2.88389807312,
2.9312490491200003
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.501153640620001,
"stddev": 0.1386927113304073,
"median": 4.43411187792,
"user": 1.7039418599999998,
"system": 1.35391854,
"min": 4.40408662292,
"max": 4.80339828592,
"times": [
4.42938374692,
4.43652528792,
4.40408662292,
4.42176643992,
4.4294210969200005,
4.47069060592,
4.80339828592,
4.43169846792,
4.47143085892,
4.713134992920001
]
},
{
"command": "pacquet@main",
"mean": 4.5755941920200005,
"stddev": 0.16562233350283528,
"median": 4.498271834920001,
"user": 1.66872866,
"system": 1.3735740400000003,
"min": 4.40432292692,
"max": 4.86794784092,
"times": [
4.4805999319200005,
4.515943737920001,
4.40432292692,
4.45614939992,
4.86794784092,
4.47254703692,
4.66581201792,
4.67704573392,
4.41530278592,
4.8002705079200005
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5533193075200002,
"stddev": 0.13009443549577712,
"median": 3.5181367524200002,
"user": 1.1605046599999997,
"system": 1.23859934,
"min": 3.45993932892,
"max": 3.85530797092,
"times": [
3.5579405469200003,
3.71051072792,
3.4610539139200003,
3.52305974092,
3.4661765679200003,
3.85530797092,
3.46293077292,
3.5197912539200003,
3.45993932892,
3.51648225092
]
},
{
"command": "pnpr@main",
"mean": 3.5900814146200006,
"stddev": 0.13277188357407252,
"median": 3.56616672192,
"user": 1.20400606,
"system": 1.2075874399999997,
"min": 3.43333518292,
"max": 3.77764769392,
"times": [
3.47103999192,
3.5680044569200002,
3.56432898692,
3.7575593029200003,
3.50339576492,
3.57464839992,
3.43333518292,
3.77764769392,
3.7758987049200003,
3.47495566092
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13255 |
| 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,429.20 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 292.11 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 297.85 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.31 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,367.50 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,459.94 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 263.60 ms |
pnpm login / pnpm adduser only read the --scope command-line flag; the scope rc option in .npmrc and pnpm-workspace.yaml was ignored, unlike the TypeScript pnpm CLI, which already treats scope as an rc option. This closes a pacquet-only parity gap in the auth.ini contract; no TypeScript change is required. Add a scope field to Config, populated from the scope key in .npmrc (via NpmrcAuth) and pnpm-workspace.yaml (via WorkspaceSettings), mirroring how registry is resolved. The login CLI adapter now falls back to the resolved config.scope when --scope is absent, with the flag still taking precedence. Fixes #12893 Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01V8DMrvmeGcZWqJsA3v4co3
d50cd7f to
67618f8
Compare
Complete the scope rc-option mirror of registry: scope was resolved from .npmrc and pnpm-workspace.yaml but not from the PNPM_CONFIG_SCOPE environment variable, because WorkspaceSettings::from_pnpm_config_env (a hand-maintained macro list) had no scope entry. registry is env-readable via PNPM_CONFIG_REGISTRY, so scope must be too for parity. Add the string_field!(scope, "SCOPE") env line and a matching env-overlay test, and note the env source in the changeset. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01V8DMrvmeGcZWqJsA3v4co3
Brings in the native ci / clean-install command and the update --latest catalog / node-gyp holdback from main. No files overlap with this branch's scope changes, so the merge is conflict-free.
Brings in the GitHub Actions env-file persistence fix, the update --latest resolver-decides-writes fix, and the opt-in GitHub Actions checks for outdated / update. Only workspace_yaml.rs overlaps this branch's scope changes, and git auto-merged it cleanly (main reworded the distant UpdateSettings / UpdateConfig github_actions docs, far from the scope field).
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@pnpm/crates/cli/src/cli_args/login/tests.rs`:
- Around line 89-120: Add a fixture-backed integration test that exercises the
actual login write path, covering config/environment-derived scope versus an
explicit --scope override. Assert that the resulting npmrc contains the scoped
authentication token and matching `@scope`:registry mapping, and verify both
precedence cases rather than only inspecting LoginOptions.scope.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 01a4896c-be46-4935-be69-d11562cf73f5
📒 Files selected for processing (11)
.changeset/pacquet-login-scope-from-npmrc.mdpnpm/crates/cli/src/cli_args/login.rspnpm/crates/cli/src/cli_args/login/tests.rspnpm/crates/config/src/env_overlay.rspnpm/crates/config/src/env_overlay/tests.rspnpm/crates/config/src/lib.rspnpm/crates/config/src/npmrc_auth.rspnpm/crates/config/src/npmrc_auth/tests.rspnpm/crates/config/src/workspace_yaml.rspnpm/crates/config/src/workspace_yaml/tests.rspnpm/crates/package-manager/src/install_package_from_registry/tests.rs
Brings in 125 commits, including the pnpm 12 beta lane move, the web-login-without-a-TTY feature, the unscoped .npmrc setting pinning, and the resolver/dedupe parity work. Git auto-merged every overlapping file (login tests, npmrc_auth, workspace_yaml, env_overlay, lib.rs) with no conflicts; this branch's scope wiring is unchanged.
… scope The adapter tests proved only that a config-derived scope reaches LoginOptions.scope; the auth.ini write path was covered separately in pacquet-auth-commands, which feeds LoginOptions.scope directly. Nothing spanned both halves, so a future refactor decoupling login_options from login could regress the feature with every test still green. Add two execute-level tests that start from Config.scope and assert the persisted auth.ini: a config-only scope writes the scoped _authToken plus the @scope:registry mapping (and nothing unscoped), and --scope beats a configured scope all the way to disk. Both were verified to fail when the config fallback is dropped or its precedence inverted. The auth.ini write is captured by extending login_host_fake! with an opt-in auth_ini_writes helper, mirroring login_fake! in pacquet-auth-commands. Raised by CodeRabbit on #13255 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V8DMrvmeGcZWqJsA3v4co3
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (4): Last reviewed commit: "docs(pacquet/config): de-duplicate the s..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
Fixes a pacquet-only parity gap where pnpm login / pnpm adduser ignored the scope rc option (from .npmrc, pnpm-workspace.yaml, and PNPM_CONFIG_SCOPE), causing scoped auth tokens and @scope:registry mappings to be persisted incorrectly compared to the TypeScript CLI.
Changes:
- Add
Config.scopeto pacquet-config and plumb it through the existing config layering (npmrc, workspace yaml, env overlay). - Make the login CLI adapter fall back to
config.scopewhen--scopeis not provided (with the flag still taking precedence). - Add/extend tests to cover scope parsing and end-to-end
auth.inipersistence for config-sourced scope, plus a changeset for the Rust-side fix.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm/crates/package-manager/src/install_package_from_registry/tests.rs | Updates test config construction for the new Config.scope field. |
| pnpm/crates/config/src/workspace_yaml/tests.rs | Adds coverage for parsing/applying scope from pnpm-workspace.yaml and precedence vs .npmrc. |
| pnpm/crates/config/src/workspace_yaml.rs | Adds WorkspaceSettings.scope, env substitution support, and applies it onto Config. |
| pnpm/crates/config/src/npmrc_auth/tests.rs | Adds coverage for reading scope= from .npmrc and applying it to Config. |
| pnpm/crates/config/src/npmrc_auth.rs | Extends .npmrc parsing and layering to include top-level scope= (similar to registry=). |
| pnpm/crates/config/src/lib.rs | Introduces Config.scope as a resolved default scope for login/adduser. |
| pnpm/crates/config/src/env_overlay/tests.rs | Adds coverage for parsing scope from PNPM_CONFIG_SCOPE. |
| pnpm/crates/config/src/env_overlay.rs | Adds scope to the env overlay fields (PNPM_CONFIG_SCOPE). |
| pnpm/crates/cli/src/cli_args/login/tests.rs | Adds unit + end-to-end tests ensuring config-sourced scope affects persisted auth.ini the same as --scope. |
| pnpm/crates/cli/src/cli_args/login.rs | Uses config.scope as the fallback when --scope is absent. |
| .changeset/pacquet-login-scope-from-npmrc.md | Adds a patch changeset documenting the pacquet behavior change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
pnpm does not honor `scope` from an .npmrc: readAndFilterNpmrc keeps only auth/registry keys (isNpmrcReadableKey), and scope is in neither NPM_AUTH_SETTINGS nor NETWORK_INI_KEYS, so a `scope=` line there is dropped before it reaches the merged config. Parsing it in pacquet was therefore a divergence, not the parity fix it was framed as. Drop the .npmrc parsing (npmrc_auth.rs returns to its previous state) and pin the behavior with a test asserting a `scope=` line is ignored. The sources pnpm does honor stay: pnpm-workspace.yaml and the global config.yaml via WorkspaceSettings, PNPM_CONFIG_SCOPE via the env overlay, and --scope on the command line, which still wins. Verified against the TypeScript reader: loadNpmrcFiles.ts:454 gates .npmrc keys on isNpmrcReadableKey; addSettingsFromWorkspaceManifestToConfig assigns any camelCase yaml key; parseEnvVars accepts a PNPM_CONFIG_* key whose schema resolves in `types`, which includes scope via npmConfigTypes. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V8DMrvmeGcZWqJsA3v4co3
The scope tests all sat at the unit level — WorkspaceSettings::apply_to, from_pnpm_config_env, NpmrcAuth::apply_to, login_options — so nothing exercised the assembled Config::current pipeline. That is the layer where a setting can be silently swallowed by a filter, which is exactly what .npmrc does to scope, so it is the layer worth pinning. Add two tests alongside the existing registry-from-yaml one: a pnpm-workspace.yaml scope reaches Config::current (and beats an .npmrc scope), and an .npmrc scope on its own never does. Verified non-vacuous by removing the yaml apply, which fails the first and correctly leaves the second passing. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V8DMrvmeGcZWqJsA3v4co3
Brings in 42 commits, including the pnpm 11.19.0 / pacquet 12.0.0-beta.2 releases, the resolver and peer-hoisting performance work, and the napi readConfig additions. Git merged every overlapping file without a textual conflict, but one change needed a semantic fixup: #13277 argument-gates `web_auth_fake!`, so the two scope tests added on this branch had to name the helpers they use (`FakeHost`, `RecordingReporter`, `set_fetch`) instead of calling the macro bare. Without it the crate would still merge cleanly and then fail to compile.
LoginOptions::scope still documented itself as "the --scope value", which stopped being true once the adapter began falling back to the resolved setting; a reader consulting the contract would conclude the setting is not honored. normalize_scope's doc had the same flag-only framing. The tests had three weaknesses. Nothing pinned that scope must survive clear_workspace_only_fields, so adding it to that list — a long roster of plausible-looking workspace-only knobs — would have silently removed the global config.yaml source with every test still green; a guard now covers it, verified by adding scope to the list and watching it fail. The Config::current test claimed yaml beat an .npmrc scope, a contest .npmrc cannot enter, so it is renamed to what it actually proves and the .npmrc half is left to the test that covers it non-vacuously. And the npmrc test's doc re-listed the scope sources for a third time. Also add the compile_error! fallback arm that login_host_fake!'s own doc implies by claiming to mirror login_fake!, so a mistyped helper reports the valid names instead of "no rules expected this token". Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V8DMrvmeGcZWqJsA3v4co3
pnpm turns a --config.<key>=<value> token into a plain cli option: normalizeOptions strips the `config.` prefix, so --config.scope=@org reaches config.scope the same way --scope does. pacquet strips those tokens out of argv itself and only re-applies a curated set, which already included registry but not scope — so the sibling settings behaved differently after this branch taught login to read the scope setting. Add scope to ConfigOverrides alongside registry. Verified the test fails when the new `set` arm is dropped. Also state the callee contract on LoginOptions::scope instead of narrating where the value came from, which the adapter already shows and which left the field describing its resolution while its `registry` sibling described its contract, and note the .npmrc exclusion in the changeset since that is where npm users would expect `scope=` to work. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01V8DMrvmeGcZWqJsA3v4co3
…ypeScript An empty `PNPM_CONFIG_SCOPE=` must override a scope set by a lower-priority layer (`pnpm-workspace.yaml`, global `config.yaml`) so `pnpm login` records an unscoped token — the way the TypeScript CLI's env pass does, since it skips only an absent variable, never an empty one. Reading `scope` through `read_env` dropped the empty value and let the lower layer's scope leak through, diverging from the TypeScript CLI in the on-disk `auth.ini`. Route `scope` through `read_env_allow_empty`, joining `savePrefix` as the exception where `""` is observably different from unset, and cover the case with a test.
KSXGitHub
left a comment
There was a problem hiding this comment.
Claude Code,
Below are many different reviews. Each may belong to different categories.
I wish that you do not collapse all the unrelated tasks into a single commit.
You shall analyze the reviews. You shall make groups of related reviews.
Each group of related reviews correspond to a task and a git commit.
A git commit should have its purpose clear and focused.
If there would be multiple groups of related reviews, then I expect multiple commits.
The second paragraph of the `login_host_fake!` doc comment restated what the macro's `auth_ini_writes` argument already conveys and duplicated the rationale that lives on `login_fake!` in `pacquet-auth-commands`. Per pnpm/CLAUDE.md, a test's documentation should not re-narrate what the code says; drop it and keep the one-line contract.
Bind the fake `-/v1/login` handshake body to a `body` local before building the mock, instead of inlining the `serde_json::json!(...).to_string()` expression in the `with_body(...)` call. With the argument now short, rustfmt reflows the builder chain onto one line; the calls and their order are unchanged.
Format the fake `-/v1/login` handshake body as a multi-line `serde_json::json!` object instead of a single long line.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/config/src/workspace_yaml.rs (1)
531-535: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep unrelated
saveExactbehavior out of this scope-only PR.The PR objective is login
scoperesolution. These changes add separate workspace and environment configuration behavior. Revert them unless this PR intentionally includessaveExact. If retained, add matching parity tests and a changeset that names the affected Rust package.
pnpm/crates/config/src/workspace_yaml.rs#L531-L535: remove the newWorkspaceSettings.save_exactfield, or document and test the feature as part of this PR.pnpm/crates/config/src/workspace_yaml.rs#L1046-L1046: removesave_exactfrom the workspace application list, or complete its configuration contract.pnpm/crates/config/src/env_overlay.rs#L271-L271: removeSAVE_EXACTparsing, or add complete end-to-end coverage and release documentation.As per path instructions, keep the change limited to the scope feature and describe each user-visible Rust behavior in the matching changeset.
🤖 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/config/src/workspace_yaml.rs` around lines 531 - 535, Remove the unrelated saveExact configuration changes: delete WorkspaceSettings.save_exact in pnpm/crates/config/src/workspace_yaml.rs:531-535, remove save_exact from the workspace application list in pnpm/crates/config/src/workspace_yaml.rs:1046-1046, and remove SAVE_EXACT parsing in pnpm/crates/config/src/env_overlay.rs:271-271. Keep this PR limited to login scope resolution.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/config/src/workspace_yaml.rs`:
- Around line 531-535: Remove the unrelated saveExact configuration changes:
delete WorkspaceSettings.save_exact in
pnpm/crates/config/src/workspace_yaml.rs:531-535, remove save_exact from the
workspace application list in
pnpm/crates/config/src/workspace_yaml.rs:1046-1046, and remove SAVE_EXACT
parsing in pnpm/crates/config/src/env_overlay.rs:271-271. Keep this PR limited
to login scope resolution.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: a332dce5-33d3-4fbb-9339-f7c3b9fbd0bc
📒 Files selected for processing (12)
.changeset/pacquet-login-scope-setting.mdpnpm/crates/auth-commands/src/login.rspnpm/crates/cli/src/cli_args/login/tests.rspnpm/crates/cli/src/config_overrides.rspnpm/crates/cli/src/config_overrides/tests.rspnpm/crates/config/src/env_overlay.rspnpm/crates/config/src/env_overlay/tests.rspnpm/crates/config/src/lib.rspnpm/crates/config/src/npmrc_auth/tests.rspnpm/crates/config/src/tests.rspnpm/crates/config/src/workspace_yaml.rspnpm/crates/config/src/workspace_yaml/tests.rs
🚧 Files skipped from review as they are similar to previous changes (4)
- .changeset/pacquet-login-scope-setting.md
- pnpm/crates/config/src/env_overlay/tests.rs
- pnpm/crates/config/src/lib.rs
- pnpm/crates/config/src/workspace_yaml/tests.rs
…mment
The reworded doc comment dropped the subject from one sentence, leaving a
fragment ("For nearly every setting that is indistinguishable from leaving
it unset, which is why read_env drops it"). Restore "an empty value is" so
the sentence reads as intended.
The call-site comment restated the empty-value clobber/parity rationale already documented on read_env_allow_empty, which it references. Per the comment policy, keep the shared "why" in one place: trim the call site to its local point (scope breaks the string_field! pattern to keep an empty value) and defer to the referenced doc.
The pending changeset from #13255 still advertised `pnpm-workspace.yaml` as a source for the login `scope`, which this branch removes. Both intents are consumed by the same release, so the notes would have announced the setting and its removal side by side.
Summary
pacquet's
pnpm login/pnpm adduserhonoredscopeonly as the--scopecommand-line flag, ignoring the setting when it came from configuration. The TypeScript pnpm CLI resolvesscopethrough the config chain, so pacquet was missing three sources:pnpm-workspace.yaml, the globalconfig.yaml, and thePNPM_CONFIG_SCOPEenvironment variable. This adds them.pacquet-config'sConfiggains ascopefield, populated frompnpm-workspace.yamland the globalconfig.yaml(viaWorkspaceSettings) and fromPNPM_CONFIG_SCOPE(viaWorkspaceSettings::from_pnpm_config_env). The login adapter falls back to it when--scopeis absent; the flag still wins when both are set. A resolved scope keys the granted token (//registry/:@scope:_authToken) and records the@scope:registrymapping, matching the TypeScript CLI..npmrcis deliberately not one of the sources. pnpm keeps only auth/registry keys when reading an.npmrc—readAndFilterNpmrcgates onisNpmrcReadableKey, andscopeis in neitherNPM_AUTH_SETTINGSnorNETWORK_INI_KEYS— so ascope=line there is dropped before it reaches the merged config. A test pins that pacquet ignores it too, so the two stacks stay identical on the point.Fixes #12893.
Note that the linked issue is inaccurate on one detail: it describes the gap as pacquet not reading
scopefrom.npmrc, but the TypeScript CLI does not read it from there either. The real gap was the config-file and environment sources, which is what this PR closes.Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting. (The TypeScript CLI already resolvesscopefrom these sources; only the Rust port needed the fix.)pnpm changeset) if this PR changes any published package. Keep it short and written for pnpm users — it becomes a release note.Summary by CodeRabbit
New Features
pnpm loginandpnpm addusernow resolve package scope from workspace or global configuration, environment settings, or CLI options.--scopevalues take precedence over configured defaults.Bug Fixes
.npmrcare ignored consistently.