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

FUTURE: initial support for .npmrc file #23560

Merged
merged 57 commits into from
May 23, 2024

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented Apr 25, 2024

This commit adds initial support for ".npmrc" files.

Currently we only discover ".npmrc" files next to "package.json" files
and discovering these files in user home dir is left for a follow up.

This pass supports "_authToken" and "_auth" configuration
for providing authentication.

LSP support has been left for a follow up PR.

Towards #16105

bartlomieju added a commit that referenced this pull request Apr 26, 2024
Factored out from #23560 to make it
easier to review.
cli/http_util.rs Outdated
Comment on lines 361 to 365
let mut builder = self.get_no_redirect(new_url.clone())?;
if let Some((header_name, header_value)) = maybe_header.as_ref() {
builder = builder.header(header_name, header_value);
}
let new_response = builder.send().await?;
Copy link
Member

Choose a reason for hiding this comment

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

You should only serve auth tokens after a redirect if the original and redirected URL have the same origin.

bartlomieju added a commit that referenced this pull request Apr 26, 2024
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.

Nice! Looks really good. Just a few comments.

.unwrap();
let mut relative_url = registry_root_dir.make_relative(specifier)?;
if relative_url.starts_with("../") {
return None;
Copy link
Member

Choose a reason for hiding this comment

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

I think we could make this more optimal by storing root_url_to_safe_local_dirname for each registry url in the constructor, then here getting the relative path from the self.root_dir_url, then check the first component for a match, then continue below

cli/npm/managed/resolvers/mod.rs Show resolved Hide resolved
cli/standalone/mod.rs Show resolved Hide resolved
cli/standalone/mod.rs Show resolved Hide resolved
Copy link
Member Author

@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.

It appears --reload flag is not working correctly if .npmrc is present and custom registries are used.

This is a blocker to landing this PR. Opened #23953 to address in a follow up

@bartlomieju bartlomieju changed the title FUTURE: basic support for .npmrc file FUTURE: initial support for .npmrc file May 22, 2024
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!

@bartlomieju bartlomieju merged commit 959739f into denoland:main May 23, 2024
17 checks passed
@bartlomieju bartlomieju deleted the npm_private_registry branch May 23, 2024 21:26
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.

3 participants