npmgen-core
The library behind npmgen.
It generates the npm publish tree that ships a prebuilt Rust binary.
The tree is a meta package plus one package per platform, wired through optionalDependencies and npm os/cpu filters.
The npmgen command-line tool is a thin wrapper over this crate.
Add it as a dependency:
cargo add npmgen-core
Two ways in
Acquiring the inputs and generating are separate concerns.
A Generator runs over a resolved Project; how you obtain that Project is up to you.
Load it from a crate manifest (uses cargo metadata and TOML):
use ;
let project = load?;
new.out.run?;
Or build it in memory, with no manifest, no cargo metadata, and no TOML parsing:
use ;
let project = builder
.git_url
.config
.workspace_root
.target_directory
.build;
new.out.run?;
Targets, payload, and foreign manifests live in Config, documented as [package.metadata.npmgen] in the main README.
Key types
Generatorconfigures and runs a generation over aProject.Projectis the resolved target crate; build it withProject::builderorProject::load.Configis the npmgen metadata;Targetis one resolved platform.BuildDriveris the build seam, withCargoDriveras the default.
License
MIT. See LICENSE.