Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): support username and _password in .npmrc file #24793

Merged
merged 8 commits into from
Aug 14, 2024

Conversation

iuioiua
Copy link
Contributor

@iuioiua iuioiua commented Jul 30, 2024

Closes #23950

@iuioiua iuioiua added ci-draft Run the CI on draft PRs. and removed ci-draft Run the CI on draft PRs. labels Jul 30, 2024
@iuioiua iuioiua marked this pull request as ready for review July 30, 2024 10:34
@bartlomieju
Copy link
Member

Erroring when only username or _password is defined can be handled in a follow-up PR.

I think we should do it in this PR

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

Actually we should verify what npm CLI does in such case.

@iuioiua
Copy link
Contributor Author

iuioiua commented Aug 10, 2024

npm throws when username or _password isn't provided without the other (ref). I've added this behavior in now.

@bartlomieju bartlomieju added this to the 1.46 milestone Aug 11, 2024
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, nice work!

Comment on lines +32 to +33
if (username.is_some() && password.is_none())
|| (username.is_none() && password.is_some())
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick, but you can probably compat this and the next conditional by using a match like so:

match (username, password) {
  (Some(username), Some(password)) => {...},
  (Some(_) , None_ => {...},
  (None, Some(_) => {...},
  _ => {}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll revisit this once when we add the certfile and keyfile fields.

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

LGTM too.

cli/npm/managed/cache/registry_info.rs Outdated Show resolved Hide resolved
@iuioiua iuioiua merged commit f89b531 into denoland:main Aug 14, 2024
17 checks passed
@iuioiua iuioiua deleted the npmrc-username-password branch August 14, 2024 16:53
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.

.npmrc: support username and _password auth configuration
3 participants