Repository navigation
feat(pacquet): logout - #12568
feat(pacquet): logout#12568
logout#12568Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a new logout command, raw auth-token capture in config, flat Changespnpm logout implementation
Shared URL sanitization
Sequence Diagram(s)sequenceDiagram
participant LogoutArgsRun as LogoutArgs::run
participant LogoutFn as pacquet_auth_commands::logout
participant Host
participant Registry
participant IniSettings
participant FsWrite
LogoutArgsRun->>LogoutFn: LogoutOptions + ThrottledClient
LogoutFn->>Host: revoke(http_client, revoke_url, token, retry)
Host->>Registry: DELETE /-/user/token/:encoded_token
Registry-->>Host: RevokeOutcome
LogoutFn->>IniSettings: parse(auth.ini)
LogoutFn->>IniSettings: remove(token_key)
LogoutFn->>FsWrite: write(auth.ini, serialize())
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
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 |
Micro-Benchmark ResultsLinux |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
pacquet/crates/auth-commands/src/logout/tests.rs (1)
97-498: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winAdd a regression test for
WriteAuthInipropagation.The suite covers read failures and logout-failed branches, but it does not force
FsWrite::writeto fail and assertLogoutError::WriteAuthIni. Adding that case would lock down the remaining filesystem error path.As per coding guidelines, REVIEW_GUIDE.md requires regression coverage for logout behavior and error paths.
🤖 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 `@pacquet/crates/auth-commands/src/logout/tests.rs` around lines 97 - 498, Add a regression test following the pattern of the existing `propagates_non_non_not_found_read_errors` test that covers the `WriteAuthIni` error path. Create a new test function that configures the sys_fake to fail when writing to auth.ini (by making the write operation return an appropriate error), calls the logout function with valid setup that would normally succeed but the write fails, and asserts that the error returned is `LogoutError::WriteAuthIni` with the expected error details included. This will complete the filesystem error path coverage alongside the existing read error handling tests.Source: Coding guidelines
pacquet/crates/cli/src/cli_args/logout.rs (1)
26-30: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winRoute this user-facing error through
pacquet-diagnosticsinstead of an inlinemiette!diagnostic.Line 27 creates a command-specific ad-hoc diagnostic in the CLI layer. Please define/use the error in
pacquet-diagnosticsand return that typed diagnostic here to keep user-facing error contracts centralized and consistent.
As per coding guidelines, "User-facing errors go throughmiettevia thepacquet-diagnosticscrate."🤖 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 `@pacquet/crates/cli/src/cli_args/logout.rs` around lines 26 - 30, The inline miette! diagnostic for the missing config directory case in the logout function needs to be refactored to use the pacquet-diagnostics crate instead. Define a new error type in pacquet-diagnostics that represents the ERR_PNPM_NO_CONFIG_DIR error condition (or use an existing one if available), then replace the inline miette! call in the logout.rs file with a return statement that constructs and returns the typed diagnostic from pacquet-diagnostics, ensuring the error handling is centralized and maintains consistency with the coding guidelines.Source: Coding guidelines
pacquet/crates/auth-commands/src/lib.rs (1)
6-7: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick winReorder module declarations to match pacquet style.
pub moddeclarations should come before privatemoddeclarations in this crate style.Suggested change
-mod ini; pub mod logout; +mod ini;As per coding guidelines,
pacquet/CODE_STYLE_GUIDE.mdrequires module declarations ordered as “pub mod declarations first, then pub use, then private imports.”🤖 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 `@pacquet/crates/auth-commands/src/lib.rs` around lines 6 - 7, The module declarations in the lib.rs file are in the wrong order. According to the pacquet code style guide, public module declarations must appear before private module declarations. Reorder the modules so that the pub mod logout declaration comes before the private mod ini declaration. This ensures consistency with the crate's coding standards where public exports are declared first, followed by private modules.Source: Coding guidelines
🤖 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 `@pacquet/crates/auth-commands/src/lib.rs`:
- Around line 6-7: The module declarations in the lib.rs file are in the wrong
order. According to the pacquet code style guide, public module declarations
must appear before private module declarations. Reorder the modules so that the
pub mod logout declaration comes before the private mod ini declaration. This
ensures consistency with the crate's coding standards where public exports are
declared first, followed by private modules.
In `@pacquet/crates/auth-commands/src/logout/tests.rs`:
- Around line 97-498: Add a regression test following the pattern of the
existing `propagates_non_non_not_found_read_errors` test that covers the
`WriteAuthIni` error path. Create a new test function that configures the
sys_fake to fail when writing to auth.ini (by making the write operation return
an appropriate error), calls the logout function with valid setup that would
normally succeed but the write fails, and asserts that the error returned is
`LogoutError::WriteAuthIni` with the expected error details included. This will
complete the filesystem error path coverage alongside the existing read error
handling tests.
In `@pacquet/crates/cli/src/cli_args/logout.rs`:
- Around line 26-30: The inline miette! diagnostic for the missing config
directory case in the logout function needs to be refactored to use the
pacquet-diagnostics crate instead. Define a new error type in
pacquet-diagnostics that represents the ERR_PNPM_NO_CONFIG_DIR error condition
(or use an existing one if available), then replace the inline miette! call in
the logout.rs file with a return statement that constructs and returns the typed
diagnostic from pacquet-diagnostics, ensuring the error handling is centralized
and maintains consistency with the coding guidelines.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2721fc2e-b17a-43cc-a5c6-f4c3bd28b035
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (14)
Cargo.tomlpacquet/crates/auth-commands/Cargo.tomlpacquet/crates/auth-commands/src/ini.rspacquet/crates/auth-commands/src/ini/tests.rspacquet/crates/auth-commands/src/lib.rspacquet/crates/auth-commands/src/logout.rspacquet/crates/auth-commands/src/logout/tests.rspacquet/crates/cli/Cargo.tomlpacquet/crates/cli/src/cli_args.rspacquet/crates/cli/src/cli_args/logout.rspacquet/crates/config/src/lib.rspacquet/crates/config/src/npmrc_auth.rspacquet/crates/package-manager/src/install_package_from_registry/tests.rspacquet/plans/TEST_PORTING.md
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12568 +/- ##
==========================================
+ Coverage 85.43% 85.48% +0.05%
==========================================
Files 389 393 +4
Lines 59609 59808 +199
==========================================
+ Hits 50926 51126 +200
+ Misses 8683 8682 -1 ☔ 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": 4.93419951198,
"stddev": 0.20215944347118048,
"median": 4.93228464308,
"user": 4.0254628199999996,
"system": 3.4441065800000006,
"min": 4.69561297758,
"max": 5.22709868858,
"times": [
5.06717674758,
5.21026869758,
5.22709868858,
5.04264677058,
4.99254407858,
4.87202520758,
4.74178225958,
4.69561297758,
4.79452399058,
4.69831570158
]
},
{
"command": "pacquet@main",
"mean": 4.82165444318,
"stddev": 0.10821570846252558,
"median": 4.79288627608,
"user": 4.01838242,
"system": 3.4531013799999997,
"min": 4.70316536858,
"max": 5.01462754358,
"times": [
4.81781717258,
4.73724851758,
4.71076308458,
4.94804117458,
4.91256202758,
4.74386497658,
4.76795537958,
4.86049918658,
5.01462754358,
4.70316536858
]
},
{
"command": "pnpr@HEAD",
"mean": 2.97760096688,
"stddev": 0.14765604706646057,
"median": 2.91367736458,
"user": 2.8243810199999997,
"system": 2.965850180000001,
"min": 2.82540720058,
"max": 3.21652359358,
"times": [
2.91861742358,
2.90873730558,
3.11978775458,
2.88680786758,
3.21652359358,
3.20595128558,
2.97064239758,
2.82540720058,
2.85025726158,
2.87327757858
]
},
{
"command": "pnpr@main",
"mean": 2.9591867933800002,
"stddev": 0.13422576977379158,
"median": 2.90645168258,
"user": 2.81431732,
"system": 2.9564990799999995,
"min": 2.84271099058,
"max": 3.23947680358,
"times": [
2.93619488658,
3.04371701558,
2.91004733558,
2.84271099058,
3.23947680358,
2.86767434258,
3.12775428358,
2.87769457758,
2.84374166858,
2.90285602958
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.65778637332,
"stddev": 0.008596813545181133,
"median": 0.65802797682,
"user": 0.39706357999999997,
"system": 1.32985756,
"min": 0.64242545732,
"max": 0.67150799932,
"times": [
0.6562368603200001,
0.66425899732,
0.65096848632,
0.65012631732,
0.64242545732,
0.67150799932,
0.66432983032,
0.66362715432,
0.65456353732,
0.65981909332
]
},
{
"command": "pacquet@main",
"mean": 0.66275453802,
"stddev": 0.037823005188098405,
"median": 0.6548271933200001,
"user": 0.38493787999999995,
"system": 1.33576966,
"min": 0.6318032583200001,
"max": 0.76477722532,
"times": [
0.65323190532,
0.64935972332,
0.6318032583200001,
0.64147603832,
0.66679351032,
0.63671026332,
0.76477722532,
0.65848799532,
0.66848297932,
0.65642248132
]
},
{
"command": "pnpr@HEAD",
"mean": 0.7223569788199999,
"stddev": 0.04900157754412094,
"median": 0.7123677418200001,
"user": 0.42341858,
"system": 1.3632205599999998,
"min": 0.68168218432,
"max": 0.85305253332,
"times": [
0.71973933632,
0.68168218432,
0.69645732132,
0.6897226763200001,
0.72322593832,
0.73547469132,
0.69671069832,
0.72250826132,
0.85305253332,
0.70499614732
]
},
{
"command": "pnpr@main",
"mean": 0.7380941039199999,
"stddev": 0.06420900511204328,
"median": 0.71367044782,
"user": 0.40785007999999995,
"system": 1.37508736,
"min": 0.69296428932,
"max": 0.8755518143200001,
"times": [
0.69782688632,
0.72365555332,
0.69377678732,
0.71848087232,
0.70886002332,
0.8755518143200001,
0.72601231032,
0.70592103732,
0.69296428932,
0.83789146532
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.844236959020001,
"stddev": 0.05921390295455596,
"median": 4.83892492162,
"user": 3.9652902599999997,
"system": 3.3687090999999993,
"min": 4.76744550012,
"max": 4.93710301912,
"times": [
4.93710301912,
4.90115745012,
4.79122889912,
4.846605691120001,
4.8053733671200005,
4.83124415212,
4.8578924721200005,
4.78511872212,
4.9192003171200005,
4.76744550012
]
},
{
"command": "pacquet@main",
"mean": 4.73315357862,
"stddev": 0.04121377531381851,
"median": 4.71904182812,
"user": 3.90894766,
"system": 3.3015186,
"min": 4.68644046012,
"max": 4.79727153512,
"times": [
4.79593588912,
4.77618812312,
4.68644046012,
4.7197786741200005,
4.72760319512,
4.71830498212,
4.69920286512,
4.69917731912,
4.79727153512,
4.71163274312
]
},
{
"command": "pnpr@HEAD",
"mean": 3.2178253732199993,
"stddev": 0.1425488871507281,
"median": 3.18810807112,
"user": 2.90043796,
"system": 3.0833321999999996,
"min": 3.03295803912,
"max": 3.4383302361199997,
"times": [
3.1143536131199996,
3.08891008812,
3.08974030412,
3.20380557212,
3.03295803912,
3.3539225021199996,
3.2930451221199997,
3.3907776851199998,
3.4383302361199997,
3.17241057012
]
},
{
"command": "pnpr@main",
"mean": 3.23069325732,
"stddev": 0.16038745458191497,
"median": 3.21774973662,
"user": 2.90246916,
"system": 3.0965808999999997,
"min": 3.02433864512,
"max": 3.62110364212,
"times": [
3.2294062601199998,
3.2306348471199997,
3.3023252741199998,
3.1746474381199996,
3.62110364212,
3.20609321312,
3.06981194912,
3.25318819512,
3.02433864512,
3.19538310912
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.3620381751,
"stddev": 0.009994552628022128,
"median": 1.3633336024,
"user": 1.3007016399999998,
"system": 1.70793844,
"min": 1.3430128609,
"max": 1.3768337259,
"times": [
1.3633813709,
1.3585233539000001,
1.3430128609,
1.3675466119000002,
1.3632858339,
1.3685490939,
1.3585716979,
1.3768337259,
1.3706319369,
1.3500452649
]
},
{
"command": "pacquet@main",
"mean": 1.3686609003,
"stddev": 0.016831106973282366,
"median": 1.3673465394000002,
"user": 1.3222692399999998,
"system": 1.70244134,
"min": 1.3491973129000001,
"max": 1.4082791449,
"times": [
1.3771206199000001,
1.4082791449,
1.3641810239,
1.3726808789,
1.3724916049,
1.3661226469,
1.3685704319,
1.3491973129000001,
1.3494375399,
1.3585277989
]
},
{
"command": "pnpr@HEAD",
"mean": 1.4610220851,
"stddev": 0.07216512991376386,
"median": 1.4385797904,
"user": 0.56362874,
"system": 1.59192224,
"min": 1.4221953069,
"max": 1.6639496349,
"times": [
1.4509993059000001,
1.6639496349,
1.4282838639,
1.4221953069,
1.4352677049,
1.4453398429,
1.4314220629,
1.4418918759,
1.4591044769000001,
1.4317667759000001
]
},
{
"command": "pnpr@main",
"mean": 1.4366768639,
"stddev": 0.024171778523134048,
"median": 1.4438008369,
"user": 0.5766929399999999,
"system": 1.5504397399999998,
"min": 1.3981837289,
"max": 1.4761100129,
"times": [
1.4761100129,
1.4208644189000001,
1.4419398129,
1.4498331279,
1.4024666629,
1.4288423389,
1.3981837289,
1.4456618609,
1.4548248749000001,
1.4480417999000001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.0494062026999997,
"stddev": 0.04862003580951334,
"median": 3.0371227259999998,
"user": 1.7732939399999996,
"system": 1.9704771399999998,
"min": 3.001225081,
"max": 3.134519496,
"times": [
3.006899649,
3.040473009,
3.112757655,
3.047490391,
3.033772443,
3.097979085,
3.001225081,
3.134519496,
3.011989423,
3.006955795
]
},
{
"command": "pacquet@main",
"mean": 3.0398382069,
"stddev": 0.04740799736199791,
"median": 3.0270353425,
"user": 1.7674377399999996,
"system": 1.97728084,
"min": 2.98907327,
"max": 3.138654822,
"times": [
3.030161526,
3.032346975,
3.015911154,
3.023909159,
2.996254473,
3.0167363,
3.049254505,
3.138654822,
2.98907327,
3.106079885
]
},
{
"command": "pnpr@HEAD",
"mean": 1.4531124328999998,
"stddev": 0.02650562326663806,
"median": 1.4417822285000002,
"user": 0.57517434,
"system": 1.57055834,
"min": 1.424611968,
"max": 1.507418483,
"times": [
1.474254967,
1.48475814,
1.445018208,
1.507418483,
1.424611968,
1.436925127,
1.438546249,
1.445387982,
1.437798702,
1.4364045029999999
]
},
{
"command": "pnpr@main",
"mean": 1.4293075433999998,
"stddev": 0.045762039460993095,
"median": 1.414463779,
"user": 0.5644218400000002,
"system": 1.5392365399999999,
"min": 1.3887011550000001,
"max": 1.553228785,
"times": [
1.432027544,
1.553228785,
1.441889004,
1.416248458,
1.417353758,
1.408681377,
1.4126791,
1.3887011550000001,
1.411601326,
1.410664927
]
}
]
} |
|
| Branch | pr/12568 |
| Testbed | pacquet |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result milliseconds (ms) (Result Δ%) | Upper Boundary milliseconds (ms) (Limit %) |
|---|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 4,844.24 ms(+1.76%)Baseline: 4,760.61 ms | 5,712.73 ms (84.80%) |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot 🚷 view threshold | 3,049.41 ms(+0.10%)Baseline: 3,046.48 ms | 3,655.78 ms (83.41%) |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 1,362.04 ms(+0.25%)Baseline: 1,358.63 ms | 1,630.35 ms (83.54%) |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 4,934.20 ms(+1.96%)Baseline: 4,839.27 ms | 5,807.13 ms (84.97%) |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 657.79 ms(+0.28%)Baseline: 655.96 ms | 787.15 ms (83.57%) |
|
| Branch | pr/12568 |
| 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 | 3,217.83 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 1,453.11 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 1,461.02 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,977.60 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 722.36 ms |
58c83dd to
1b0f9d8
Compare
Code Review by Qodo
1.
|
|
Code review by qodo was updated up to the latest commit 1b0f9d8 |
|
Code review by qodo was updated up to the latest commit b9ea70d |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@pacquet/crates/auth-commands/src/logout/tests.rs`:
- Around line 713-729: The logout success/warn test only checks credential
redaction, so it misses control-character sanitization regressions. Update the
test around logout::<Sys, Rep> to include a registry string with terminal
escape/control characters and assert the returned success message and
warns(&EVENTS) output strip them while still preserving the host, using the
existing logout flow and warning capture logic.
- Around line 739-762: The unreachable-endpoint test in Host::revoke is flaky
because it relies on 127.0.0.1:1 being closed; replace that assumption with a
deterministic setup by binding a TcpListener on localhost to reserve an
ephemeral port, dropping it, then building revoke_url from that released port so
the retry path always hits ECONNREFUSED. Keep the existing assertions around
RevokeOutcome::Unreachable and the warning log/token redaction in the same test.
🪄 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: dc957ac9-b29e-44cb-85ec-1194bf1b8826
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (8)
pacquet/crates/auth-commands/Cargo.tomlpacquet/crates/auth-commands/src/logout.rspacquet/crates/auth-commands/src/logout/tests.rspacquet/crates/cli/src/cli_args/ping.rspacquet/crates/network/src/auth.rspacquet/crates/network/src/auth/tests.rspacquet/crates/network/src/lib.rspacquet/crates/network/src/retry.rs
🚧 Files skipped from review as they are similar to previous changes (2)
- pacquet/crates/auth-commands/Cargo.toml
- pacquet/crates/auth-commands/src/logout.rs
|
Code review by qodo was updated up to the latest commit b9ea70d |
|
Code review by qodo was updated up to the latest commit 076e2c9 |
|
Code review by qodo was updated up to the latest commit 076e2c9 |
Port the `pnpm logout` command (`@pnpm/auth.commands`, `pnpm11/auth/commands/src/logout.ts`) into a new `pacquet-auth-commands` crate, wired into the CLI as `pacquet logout`. The command revokes the registry auth token on the server and removes it from `auth.ini`, warning when the token lives in `.npmrc` (which pnpm does not own) and failing only when the revocation is rejected and there is no local token left to remove. Upstream injects its side effects (`fetch`, `readIniFile`, `writeIniFile`, `globalInfo`, `globalWarn`) through a `LogoutContext` object of functions. This port uses pacquet's capability-trait seam instead: `FsReadToString`, `FsWrite`, and `RevokeToken` are `Sys`-bound capabilities with no `&self` receiver (production provider `Host`, test fakes are unit structs), and the two `global*` channels are emitted through the `R: Reporter` seam. All 13 upstream tests translate to unit tests of the ported function. `Config` previously baked auth credentials into ready-to-send `Authorization` headers and discarded the raw token. Expose `Config::auth_tokens_by_uri` (raw `_authToken` per nerf-darted registry URI) and `Config::config_dir` so the command can read the token back to revoke it and locate `auth.ini`. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01TkqTxuagHe8nJrJveucDpy
…rror path The Dylint CI job (perfectionist) rejected the logout port: - `single-letter-generic`: rename the `R` reporter generic to `Reporter` (bound `self::Reporter`) in `logout`, the `global` helper, and `LogoutArgs::run`, matching the existing `<Reporter: self::Reporter>` convention used across the cli, package-manager, and env-installer crates. - `macro-trailing-comma`: add the missing trailing comma to the multi-line `format!` and to the two multi-line `sys_fake!` invocations. Also address review feedback: - Order module declarations `pub mod` before private `mod` per `CODE_STYLE_GUIDE.md`. - Add `propagates_auth_ini_write_errors`, locking down the `WriteAuthIni` branch (a hand-written fake whose `FsWrite::write` fails, since `sys_fake!`'s write always succeeds). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01TkqTxuagHe8nJrJveucDpy
The unit suite exercises `logout` through the `Sys`/`Reporter` DI seam, which swaps in fakes for the filesystem and network — so the production `Host` provider and the CLI adapter had no test coverage. Add real-fixture tests for those paths, per the "prefer real fixtures" rule in the pacquet guide: - `auth-commands` `logout/tests.rs`: three `Host` tests driving the real filesystem (`tempfile::TempDir`) and a real `DELETE` over the HTTP stack (`mockito`) — revoke-success, registry-rejects, and unreachable. - `cli/tests/logout.rs`: spawn the `pacquet logout` binary against a `mockito` registry with a temp `XDG_CONFIG_HOME`/`auth.ini`, covering `LogoutArgs::run` and the reporter dispatch end-to-end, plus the not-logged-in error exit. - `config` `npmrc_auth` test: assert the default-registry `_authToken` lands in `Config::auth_tokens_by_uri`. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01TkqTxuagHe8nJrJveucDpy
Two defensive branches stayed uncovered after the integration tests because the full pipelines never reach them: - `NpmrcAuth::build_auth_headers`'s default-credentials branch keys an unrescoped default token to the registry URI, but `Config::current` (and the `apply_to` test helper) rescope default creds onto a per-URI key first. Add a direct `build_auth_headers` unit test that exercises the branch. - `LogoutArgs::run`'s missing-config-dir guard can't be hit through the binary (a home dir always resolves), so add a unit test that calls `run` with a `Config` whose `config_dir` is `None` and asserts the error. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01TkqTxuagHe8nJrJveucDpy
The logout doc comments linked upstream `@pnpm/auth.commands` via branch URLs (blob/main, tree/main), which drift as main moves. Pin them to the commit that currently holds pnpm11/auth/commands, per the pacquet AGENTS rule requiring commit-SHA permalinks over branch links.
Replace the ad-hoc `miette::miette!(code = ...)` in the logout CLI adapter with a `LogoutCliError::NoConfigDir` typed diagnostic, matching the codebase convention of a local `#[derive(Diagnostic)]` enum carrying the `ERR_PNPM_NO_CONFIG_DIR` code (as in completion.rs / config.rs) rather than a string-coded inline error.
Fix a broken sentence in the logout module doc, and drop three host_* test doc comments that only restated the test name, per the comment styleguide (a test doc comment should add the non-obvious why, not re-narrate what the name and assertions already say).
…tials Two security fixes for `pacquet logout`, both flagged on the PR. The revoke URL carries the auth token in its path (npm's DELETE -/user/token/<token> API). `send_with_retry` logs the URL it is handed and the reqwest error (which embeds the request URL), so a retryable failure with fetch-retries > 0 wrote the token to the retry logs. `Host::revoke` now passes the token-free URL prefix for routing/logging, and `send_with_retry` strips the URL from the logged error via `Error::without_url`. `logout` also printed the registry URL verbatim in its success line, warnings, and errors. A registry from an untrusted `.npmrc` / `--registry` can embed `user:pass@` credentials or terminal escape sequences, so it is now redacted and control-stripped before display, matching `pacquet ping`. The shared `redact_and_sanitize` helper moves to `pacquet-network` so `ping` and `logout` share one implementation. Adds regression tests, including a tracing-capture test asserting the token never reaches the retry logs.
`pnpm logout` rewrote auth.ini with `std::fs::write` (truncate-then-write): non-atomic, so a crash or I/O error mid-write could corrupt the credential file and drop other tokens, and symlink-following, so a symlinked auth.ini could redirect the overwrite to another path. Extract the atomic, symlink-safe, mode-preserving write the `pnpm config` ini writer already performed into a shared `pacquet_fs::write_atomic`, and use it from both that writer and logout's `Host::write`. Mirrors pnpm's write-ini-file.
Cover control-character sanitization on logout's success/warning output (not only credential redaction), and make the connection-refused tests deterministic by binding then dropping an ephemeral local port instead of assuming a fixed low port is closed.
076e2c9 to
d119959
Compare
|
Code review by qodo was updated up to the latest commit d119959 |
1 similar comment
|
Code review by qodo was updated up to the latest commit d119959 |
Summary
Ports
pnpm logoutto pacquet (the Rust port). Part of the Rust Roadmap (pnpm/pnpm#11633).pnpm logoutrevokes the registry auth token on the server (DELETE -/user/token/<token>) and removes it fromauth.ini. It warns when the token actually lives in.npmrcor another source pnpm doesn't own (revoked on the registry, but must be removed manually), and fails only when the registry rejects the revocation and there is no local token left to remove.Implemented as a new
pacquet-auth-commandscrate plus apacquet logout [--registry <url>]CLI command. Behavior, flags, error codes (ERR_PNPM_NOT_LOGGED_IN,ERR_PNPM_LOGOUT_FAILED), and messages mirror the TypeScript@pnpm/auth.commandsimplementation.Dependency injection. Upstream injects its side effects (
fetch,readIniFile,writeIniFile,globalInfo,globalWarn) through aLogoutContextobject of functions. This port uses pacquet's documented capability-trait seam instead:FsReadToString/FsWrite/RevokeTokenareSys-bound capabilities with no&selfreceiver (production providerHost; test fakes are unit structs), and the twoglobal*channels go through theReporterseam.Config. Adds
Config::auth_tokens_by_uri(raw_authTokenper nerf-darted registry URI) andConfig::config_dir.Configpreviously baked credentials into ready-to-sendAuthorizationheaders and discarded the raw token;logoutneeds the raw token to build the revoke URL/header, and the config dir to locateauth.ini.Tests
pnpm11/auth/commands/test/logout.test.tsported as DI unit tests. (pnpm11/pnpm/test/has nologoutend-to-end test to port — the only upstreamlogoutcoverage is that unit file.)Hostprovider viatempfile::TempDir+mockito(revoke-success / registry-rejects / unreachable).pacquet logoutagainst a mocked registry, covering the CLI adapter (LogoutArgs::run) and dispatch end-to-end.auth_tokens_by_uripopulation for default credentials, and the missing-config-dir guard.Parity / changeset
pacquet-only (Rust) change — the TypeScript
pnpm logoutalready exists upstream, so there is nothing to mirror on the TS side, and no changeset is needed (changesets cover published TS packages only).Squash Commit Body
Checklist
pacquet/port — the TypeScriptpnpm logoutalready exists upstream; this PR is the matching pacquet port.Hostprovider +pacquet logoutbinary), and coverage-closing unit tests.pacquet/plans/TEST_PORTING.md; no user-facing docs change (the command mirrors the already-documentedpnpm logout).Written by an agent (Claude Code).
Summary by CodeRabbit
logoutCLI command to sign out from an npm registry.auth.iniupdates.auth.iniis missing or the token isn’t present locally, with clearer warnings and consistent error reporting (including unreachable/non-OK registries).auth.inicleanup, redaction, and atomic write behavior.