Expand description
Pure-Rust utilities for the npm registry and web assets.
Building blocks for fetching browser/JS dependencies at build time without Node or npm:
registry— talk to an npm registry: build tarball URLs, fetch a package’s metadata, and resolve the newest version matching a semver range.download— fetch bytes over HTTP (with a retry) and build GitHub archive URLs.extract— unpack.tar.gzand.ziparchives into a destination directory, selecting all files, an explicit file map, or a predicate, with path-traversal protection.cache— content-hash markers, a cross-process build lock, and directory helpers for skip-if-unchanged download caches.package_json— read pinned dependency versions from apackage.json.
use npm_utils::{download, extract, registry::Registry};
let reg = Registry::npm();
let lit = reg.resolve("lit", &"^3".parse()?)?;
let tgz = download::fetch(&lit.tarball_url)?;
extract::tar_gz(&tgz, "dist/lit".as_ref(), Some("package/"), extract::Select::All)?;Modules§
- cache
- Skip-if-unchanged cache helpers: content-hash markers, a cross-process build lock, and directory utilities.
- download
- HTTP download helpers.
- extract
- Archive extraction with path-traversal protection.
- package_
json - Minimal
package.jsonreader for consumers that pin dependency versions there (rather than resolving against the registry). - registry
- npm registry interaction: tarball URLs, package metadata, and version resolution against a semver range.