Skip to content

feat(npm): look packages up in the registries .npmrc names - #162

Merged
sweepies merged 6 commits into
mainfrom
feat/npm-registries
Nov 3, 2026
Merged

sweepies merged 6 commits into
mainfrom
feat/npm-registries

Conversation

@sweepies

@sweepies sweepies commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Phase 3 of #157, npm. A dependency can now come from a registry of its own. The registry is a separate field on the dependency, not part of package, so rules, the dashboard and the report keep the plain package name.

Where the registry comes from

  • npm .npmrc: the nearest one at or above each package.json, using registry= and @scope:registry=. Lines with ${VAR} and anything that isn't an https URL are ignored. packageManager stays on the public registry, because Corepack doesn't read .npmrc.
  • Yarn Berry's .yarnrc.yml: npmRegistryServer and npmScopes, which win over .npmrc in the same directory.
  • Extractors: a new registry template. An empty or unmatched capture means the public registry. Config validation checks the template's captures.
  • npm's own public registry counts as no registry.

Plumbing

  • Dependency: patchula_manager::Dependency.registry.
  • Engine: the lookup and catalog cache key become {enabled}:{source}:{registry}, so two packages with the same name from different registries are separate lookups.
  • Datasource: Client::lookup(source, registry, package). Only npm takes a registry for now, and only an https one; any other source with a registry is an error. credentialed takes the registry too, so the public API rule from feat(lookup): authenticate to private registries from operator settings #160 covers these lookups.
  • Credentials: they still come only from operator registries entries covering the URL. A repository that names a registry brings none.
  • Advisories and release notes: a package from its own registry gets no OSV advisories and no release notes, since the public package with that name is a different package. Without this, a private @acme/ui would pick up advisories and release notes from whatever is published publicly as @acme/ui.

Breaking

The report schema moves to version 5, adding registry to a dependency. Readers reject unknown fields, so a new field means a new version.

Docs

  • The sources guide gets a "Package registries" section.
  • Updated: the npm section of the managers guide, the custom extractors section of the configuration guide, the report reference, and a compatibility row for registryUrls/.npmrc.

Testing

mise run test:unit, mise run lint and mise run docs:build pass on the dev VM. New tests cover:

  • .npmrc and .yarnrc.yml scopes, the nearest-file rule, ignoring ${VAR} and http://, and Corepack
  • the extractor registry template
  • an npm lookup against its own registry with an entry's credentials
  • refusing a registry for other sources
  • the report v5 field

Next: PyPI, Cargo, NuGet, RubyGems/Composer and Go/Terraform, one PR each, using the same registry field. Helm and Maven move onto it in a later cleanup PR.

View guided diff Turn on auto-fix

A dependency gains a `registry`: the https URL to look it up in when it
is not its source's public one. npm reads it from the nearest `.npmrc`
(`registry=`, `@scope:registry=`) or Yarn Berry's `.yarnrc.yml`
(`npmRegistryServer`, `npmScopes`), and extractors take a `registry`
template. The registry is part of the lookup and catalog keys, and
credentials come only from operator entries covering its URL.

A package from its own registry gets no OSV advisories and no release
notes, since the public package of that name is a different package.

BREAKING CHANGE: the report schema is version 5, adding a dependency's
`registry`.

Refs #157
@deepsource-io

deepsource-io Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in 79883f9...81d9dd4 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Rust Nov 3, 2026 7:29a.m. Review ↗
JavaScript Nov 3, 2026 7:29a.m. Review ↗
Shell Nov 3, 2026 7:29a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@context7

context7 Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Docs7 for sweepies/count-patchula

Result Status Action
Deployment ➖ Not used —
Content review ➖ Did not run. This site has no agent runs available this month. Wait for the monthly reset or check your Docs7 plan. —

Commit 81d9dd4

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula e5a0603 Commit Preview URL

Branch Preview URL
Nov 03 2026, 07:18 AM

…ot use

From an independent review of this PR:
- A registry value the Count cannot read from (`${VAR}`, plain http) is
  kept as written, so that lookup fails instead of falling back to the
  public package of the name. Extractors do the same instead of failing
  the whole extraction, and only npm extractors take a registry.
- `.npmrc`/`.yarnrc.yml` files that name no registry no longer hide one
  further up; scope and default settings each come from the nearest file
  that sets them.
- Yarn's registry.yarnpkg.com, and any path on a public registry host,
  count as public npm.
- Packages only a lockfile records get their registry too, so OSV is not
  asked about the public package of their name.
- Same-named packages from different registries get separate branches.
- Escaped npm names are refused, and `credentialed` resolves mirrors.
From a second review:
- `.npmrc` and `.yarnrc.yml` are fetched whenever npm or Bun is enabled,
  so a `files` selection or `exclude` cannot send scoped packages to the
  public registry.
- npm extractors without a `registry` template follow `.npmrc`.
- Branch prefixes use the whole registry URL, so two registries on one
  host do not share a branch.
- An empty `registry=` or `npmRegistryServer` sets nothing.
From the third and fourth review rounds:
- The extraction cache key moves to v12, so extractions cached without
  registries are not reused.
- npm regex extractors read `.npmrc` even when only the regex manager
  is enabled.
- A plain-http public npm or Yarn registry counts as public.
- A request without credentials never gains an entry's on a redirect.
- Plan matching and dashboard keys include the registry, unchanged for
  public packages.
- Lockfile tools see each `.npmrc` cut down to its registry lines, and a
  `${VAR}` registry stays in `.yarnrc.yml`, so a private scope never
  resolves to the public package of its name.
A package is now one `PackageId { source, registry, name }` wherever the
Count identifies it: datasource lookups, credential checks and release
notes, the engine's lookup and catalog keys, the server's public view and
the PR writer's notes cache. The compiler now finds every place that has
to account for a package's registry. `PackageId::is_public` is the single
rule for what may be read by name from public services, used by
advisories and release notes.

The catalog age cache (v3) and lookup hints (v4) get new keys, since their
stored shapes changed.
@sweepies
sweepies merged commit bee8e4e into main Nov 3, 2026
15 checks passed
@sweepies
sweepies deleted the feat/npm-registries branch November 3, 2026 07:41
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.

1 participant