pub struct Registry {
pub base_url: String,
}Expand description
An npm-compatible registry. Defaults to the public registry.
Fields§
§base_url: StringImplementations§
Source§impl Registry
impl Registry
Sourcepub fn with_base_url(base_url: impl Into<String>) -> Self
pub fn with_base_url(base_url: impl Into<String>) -> Self
A registry at a custom base URL (e.g. a private mirror).
Sourcepub fn tarball_url(&self, name: &str, version: &str) -> String
pub fn tarball_url(&self, name: &str, version: &str) -> String
Conventional tarball URL for an exact version. Handles scoped names:
@scope/pkg → <base>/@scope/pkg/-/pkg-<version>.tgz.
Sourcepub fn packument(&self, name: &str) -> Result<Value, Box<dyn Error>>
pub fn packument(&self, name: &str) -> Result<Value, Box<dyn Error>>
Fetch the package metadata document (“packument”).
Sourcepub fn resolve(
&self,
name: &str,
req: &VersionReq,
) -> Result<Resolved, Box<dyn Error>>
pub fn resolve( &self, name: &str, req: &VersionReq, ) -> Result<Resolved, Box<dyn Error>>
Resolve the newest published version of name matching req.
Sourcepub fn resolve_tree(
&self,
roots: &[(String, VersionReq)],
) -> Result<Vec<Resolved>, Box<dyn Error>>
pub fn resolve_tree( &self, roots: &[(String, VersionReq)], ) -> Result<Vec<Resolved>, Box<dyn Error>>
Resolve the transitive dependency graph of roots into a flat set — one
version per package name (the npm v3+ node_modules layout). Each package’s
dependencies are read straight from the registry metadata (no tarball
extraction), every child resolved to its newest matching version, and the set
de-duplicated by name. Cyclic graphs terminate (a name is resolved once).
Returns the packages sorted by name.
MVP limitation: a single version per package name. Two incompatible requirements on the same package — a genuine conflict npm would resolve by nesting — is reported as an error rather than silently mis-resolved.