Skip to content

Import an npm registry's packages into a hosted npm repository #643

Description

@schmitch

Forge serves npm hosted repositories (#41), but an import copies only NuGet and Docker. This builds on #642, which makes the import read its source through the format's own protocol, and adds an npm source. The format crate's upstream client already reads packuments for proxy repositories.

Source: an npm registry

The source is a registry URL, for Nexus <nexus>/repository/<name>/.

  • Names: npm's protocol has no listing, so the import tries these in turn:
    • GET /-/v1/search, paged with from/size (at most 250 a page). Nexus serves it on hosted repositories since 3.7. Whether it lists every package with an empty text, or needs one search per scope, has to be tried; Nexus 3.88 moved its search to SQL.
    • GET /-/all, the legacy listing. Nexus still answers it for hosted repositories.
    • The package names or scopes the import names itself.
  • Versions: from the packument (GET /<name>, or @scope%2fname for a scoped package). It lists every version with dist.tarball, dist.integrity (SHA-512) and dist.shasum, each version's publish time in time, and deprecated.
  • Copy:
    • The tarball is downloaded and verified against dist.integrity, then written through the hosted write path.
    • A version Forge already holds with the same integrity is skipped without a download.
    • Tarball URLs are built from the import's URL, not taken from dist.tarball. Like Nexus' downloadUrl today, dist.tarball carries the source's configured base URL, which may name a host Forge does not reach the source on.
  • dist-tags and deprecations: latest, next and the rest are set once their versions are in Forge, and deprecated messages come along. A dist-tag that Forge already points at another version follows on_conflict.

Acceptance criteria

  • e2e against a real Nexus 3 npm hosted repository: scoped and unscoped packages, prereleases, dist-tags and a deprecated version arrive, and npm install from Forge works afterwards.
  • e2e against a second registry: Verdaccio (mirror.gcr.io/verdaccio/verdaccio) or another Forge.
  • Publish times come from time, and a re-run copies only what is new.
  • The web UI offers the import on npm hosted repositories, and the docs describe the npm source. Changelog fragment: feature.

Activity

  1. added this to the 2.2.0 milestone on Oct 28, 2026
  2. added
    enhancement
    on Oct 28, 2026
  3. added theissue type on Oct 28, 2026
  4. self-assigned this
    on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions