Skip to content

Comments

feat(pm): utoo auth cmd#2604

Merged
elrrrrrrr merged 3 commits intonextfrom
feat/pm-auth-npmrc
Feb 22, 2026
Merged

feat(pm): utoo auth cmd#2604
elrrrrrrr merged 3 commits intonextfrom
feat/pm-auth-npmrc

Conversation

@elrrrrrrr
Copy link
Contributor

  • ut login
  • ut whoami
  • ut logout
image

- Add util/auth.rs for resolving registry authentication tokens
- Add util/npmrc.rs for parsing .npmrc configuration files
- Add service/auth.rs for web-based and legacy npm login flows
- Add config delete method for logout support

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @elrrrrrrr, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the utoo package manager by integrating comprehensive authentication capabilities. It introduces three new commands: login for secure web-based authentication, whoami to display the currently logged-in user, and logout to invalidate and remove authentication tokens. These changes provide users with essential tools to manage their registry access directly through the CLI, leveraging a new, modular authentication service.

Highlights

  • New Authentication Commands: Introduced ut login, ut whoami, and ut logout commands to manage user authentication with npm registries.
  • Web-based Login Flow: Implemented a web-based authentication flow for ut login that opens a browser for user interaction and polls for token completion.
  • Token Management: Added functionality to resolve, require, save, and delete authentication tokens, stored per registry in the user's configuration.
  • New Authentication Service: Created a dedicated auth service module to encapsulate all authentication-related logic, improving modularity.
  • Dependency Updates: Added new dependencies is-docker, is-wsl, and open to support opening URLs in a browser for the web login flow.
Changelog
  • Cargo.lock
    • Added new package is-docker version 0.2.0.
    • Added new package is-wsl version 0.4.0.
    • Added new package open version 5.3.3.
  • crates/pm/Cargo.toml
    • Added open crate as a dependency with version 5.
  • crates/pm/src/cmd/login.rs
    • Added new file implementing the login command, handling web-based authentication and token saving.
  • crates/pm/src/cmd/logout.rs
    • Added new file implementing the logout command, responsible for invalidating tokens and removing them from local configuration.
  • crates/pm/src/cmd/mod.rs
    • Exported new modules login, logout, and whoami.
  • crates/pm/src/cmd/whoami.rs
    • Added new file implementing the whoami command, which fetches and displays the authenticated username.
  • crates/pm/src/constants.rs
    • Defined constants for LOGIN_NAME, LOGIN_ALIAS, LOGIN_ABOUT.
    • Defined constants for WHOAMI_NAME, WHOAMI_ALIAS, WHOAMI_ABOUT.
    • Defined constants for LOGOUT_NAME, LOGOUT_ALIAS, LOGOUT_ABOUT.
  • crates/pm/src/main.rs
    • Imported new command constants for login, logout, and whoami.
    • Added Login, Whoami, and Logout variants to the Commands enum.
    • Integrated login, whoami, and logout command handling into the main asynchronous function.
  • crates/pm/src/service/auth.rs
    • Added new file containing the core authentication service, including functions for registry_api, registry_host, token_key, resolve_token, require_token, web_login, whoami, logout, and save_token.
  • crates/pm/src/service/config.rs
    • Updated the ConfigService command list to include login, logout, and whoami.
  • crates/pm/src/service/mod.rs
    • Exported the new auth module.
  • crates/pm/src/util/config_file.rs
    • Added a delete method to the Config struct for removing configuration keys.
    • Added unit tests for the delete functionality in Config.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces authentication commands (login, logout, whoami) to the utoo package manager. The implementation is comprehensive, covering web-based login flows, token management, and CLI integration. However, I've identified a critical compilation error in the authentication service due to an incorrect method call on a Result type. Additionally, there's an opportunity to improve user experience by handling a potential error when opening the browser, and a test case that doesn't correctly test the new functionality it's supposed to cover. Addressing these points will significantly improve the robustness and quality of this new feature.

@elrrrrrrr elrrrrrrr requested a review from killagu February 22, 2026 07:44
@elrrrrrrr elrrrrrrr added the A-Pkg Manager Area: Package Manager label Feb 22, 2026
@elrrrrrrr elrrrrrrr marked this pull request as ready for review February 22, 2026 07:44
Copy link
Contributor

@killagu killagu left a comment

Choose a reason for hiding this comment

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

LGTM

@killagu
Copy link
Contributor

killagu commented Feb 22, 2026

PR 有点大,未来可以拆的更小一点?

@elrrrrrrr elrrrrrrr merged commit 87da31c into next Feb 22, 2026
19 checks passed
@elrrrrrrr elrrrrrrr deleted the feat/pm-auth-npmrc branch February 22, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Pkg Manager Area: Package Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants