Skip to content

feat: pnpm logout#11213

Merged
zkochan merged 10 commits intomainfrom
claude/implement-pnpm-logout-3Rvdf
Apr 7, 2026
Merged

feat: pnpm logout#11213
zkochan merged 10 commits intomainfrom
claude/implement-pnpm-logout-3Rvdf

Conversation

@KSXGitHub
Copy link
Copy Markdown
Contributor

This PR implements the pnpm logout command, allowing users to log out of npm registries by revoking their authentication tokens both on the registry and locally.

https://claude.ai/code/session_016fw5sdGFtBiB9QapMKEuXa

@KSXGitHub KSXGitHub changed the title Implement pnpm logout command for registry authentication feat: pnpm logout Apr 6, 2026
KSXGitHub

This comment was marked as resolved.

KSXGitHub

This comment was marked as resolved.

@KSXGitHub KSXGitHub marked this pull request as ready for review April 7, 2026 06:59
@KSXGitHub KSXGitHub requested a review from zkochan as a code owner April 7, 2026 06:59
Copilot AI review requested due to automatic review settings April 7, 2026 06:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds first-class support for pnpm logout, wiring it into the CLI and implementing the underlying auth token revocation + local credential cleanup logic in @pnpm/auth.commands.

Changes:

  • Register a new logout command in the pnpm CLI (and remove it from the “not implemented” list).
  • Implement logout command logic in @pnpm/auth.commands, including registry token revocation and auth.ini cleanup.
  • Add unit tests and a changeset for the new command.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pnpm/src/cmd/notImplemented.ts Removes logout from the not-implemented command set.
pnpm/src/cmd/index.ts Adds logout to the CLI command registry.
auth/commands/src/logout.ts Implements pnpm logout command behavior (revoke + local config updates).
auth/commands/src/login.ts Tightens LoginFetchOptions.method type.
auth/commands/src/index.ts Exports the new logout command module.
auth/commands/test/logout.test.ts Adds unit test coverage for logout scenarios.
.changeset/implement-pnpm-logout.md Declares minor releases for pnpm and @pnpm/auth.commands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KSXGitHub KSXGitHub marked this pull request as draft April 7, 2026 07:06
@KSXGitHub KSXGitHub marked this pull request as ready for review April 7, 2026 07:14
@KSXGitHub KSXGitHub requested a review from Copilot April 7, 2026 07:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KSXGitHub KSXGitHub marked this pull request as draft April 7, 2026 07:25
@KSXGitHub KSXGitHub marked this pull request as ready for review April 7, 2026 07:27
@KSXGitHub KSXGitHub requested a review from Copilot April 7, 2026 07:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

claude and others added 10 commits April 7, 2026 10:29
Adds a new `pnpm logout` command that logs users out of npm registries.
The command revokes the authentication token on the registry via
DELETE /-/user/token/{token}, then removes it from the local auth.ini
config file. Token revocation is best-effort: local cleanup always
proceeds even if the registry is unreachable or doesn't support
revocation.

Uses the same dependency injection pattern as `pnpm login` for
comprehensive testability.

https://claude.ai/code/session_016fw5sdGFtBiB9QapMKEuXa
- Rename revokeToken to tryRevokeToken for self-documenting code
- Extract token removal into removeTokenFromAuthIni function
- Remove redundant comments that restate function names
- Fix toHaveProperty to use array syntax for keys containing dots
  (avoids Jest property path parsing pitfall)
- Add globalWarn when token is found in authConfig but not in auth.ini,
  informing the user it must be removed manually from .npmrc
- Add tests for the .npmrc-only warning case

https://claude.ai/code/session_016fw5sdGFtBiB9QapMKEuXa
Use path.join in test expectations for the warning message path,
since path.join produces backslashes on Windows.

https://claude.ai/code/session_016fw5sdGFtBiB9QapMKEuXa
Replace manual fetchedUrls arrays with jest.fn() mocks and use
toHaveBeenCalledWith for cleaner, more idiomatic assertions.

https://claude.ai/code/session_016fw5sdGFtBiB9QapMKEuXa
- Rename mockFetch to fetch for shorthand property syntax
- Use platform-aware configDir in warning tests instead of
  path.join on Unix-style paths

https://claude.ai/code/session_016fw5sdGFtBiB9QapMKEuXa
Single-statement return-with-braces arrow function converted to
expression-body form.

https://claude.ai/code/session_016fw5sdGFtBiB9QapMKEuXa
- Send Authorization: Bearer header in the DELETE token revocation
  request, otherwise the registry returns 401 and the token is not
  actually revoked
- Make tryRevokeToken return a boolean indicating whether the token
  was actually revoked, and use it to choose the right warning when
  the token is not in auth.ini
- Drop the misleading "(token removed locally)" suffix from the
  registry-failure log messages, since the local removal may not
  happen
- Extract getRegistryConfigKey and safeReadIniFile from login.ts and
  logout.ts into a shared module to prevent the two commands from
  drifting apart over time
- Add tests asserting the Authorization header is sent and that the
  warning correctly distinguishes between revoked and not-revoked
  cases

https://claude.ai/code/session_016fw5sdGFtBiB9QapMKEuXa
When the registry rejects the token revocation AND the token is not
in auth.ini, neither side effect of logout actually happened — the
user is still authenticated locally and on the registry. Throwing
an ERR_PNPM_LOGOUT_FAILED error in this case avoids the misleading
"Logged out of ..." success message and gives a non-zero exit code.

https://claude.ai/code/session_016fw5sdGFtBiB9QapMKEuXa
@zkochan zkochan force-pushed the claude/implement-pnpm-logout-3Rvdf branch from 5b89d28 to 2fd86ee Compare April 7, 2026 08:29
@zkochan zkochan merged commit 16cfde6 into main Apr 7, 2026
12 checks passed
@zkochan zkochan deleted the claude/implement-pnpm-logout-3Rvdf branch April 7, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants