Skip to main content

NpmConfig

Struct NpmConfig 

Source
pub struct NpmConfig {
Show 43 fields pub id: Option<String>, pub ids: Option<Vec<String>>, pub targets: Option<Vec<String>>, pub mode: NpmMode, pub scope: Option<String>, pub platform_name_template: Option<String>, pub skip_metapackage: Option<StringOrBool>, pub metapackage: Option<String>, pub bin: Option<String>, pub bins: Option<BTreeMap<String, String>>, pub platform_bin_dir: Option<String>, pub shim_env: Option<BTreeMap<String, String>>, pub libc_aware: bool, pub name: Option<String>, pub description: Option<String>, pub homepage: Option<String>, pub keywords: Option<Vec<String>>, pub license: Option<String>, pub author: Option<String>, pub engines: Option<BTreeMap<String, String>>, pub files: Option<Vec<String>>, pub provenance: Option<bool>, pub repository_url: Option<String>, pub bugs: Option<String>, pub man: Option<Vec<String>>, pub contributors: Option<Vec<String>>, pub access: Option<String>, pub tag: Option<String>, pub format: Option<String>, pub url_template: Option<String>, pub binary_version: Option<String>, pub amd64_variant: Option<Amd64Variant>, pub arm_variant: Option<String>, pub extra_files: Option<Vec<String>>, pub templated_extra_files: Option<Vec<NpmTemplatedExtraFile>>, pub extra: Option<HashMap<String, Value>>, pub registry: Option<String>, pub token: Option<String>, pub auth: NpmAuthMode, pub skip: Option<StringOrBool>, pub required: Option<bool>, pub if_condition: Option<String>, pub retain_on_rollback: Option<bool>,
}
Expand description

NPM package registry publisher configuration.

In the default optional-deps mode anodizer emits one thin npm package per built platform (with os/cpu/libc selectors derived from the target triple) plus a metapackage whose optionalDependencies lists every platform package; npm’s native resolution installs only the one matching the host. In postinstall mode a single package carries a postinstall script that downloads the matching release archive at npm install time. Each npms[] entry produces one publish.

Fields§

§id: Option<String>

Unique identifier for selecting this entry from the CLI (--id=...).

§ids: Option<Vec<String>>

Crate-name filter: only include artifacts whose owning crate_name is in this list. Orthogonal to targets: (both filters apply).

§targets: Option<Vec<String>>

Target-triple allowlist: restrict the per-platform packages to a subset of the built targets. When unset (the default), every built target that maps to an npm triple becomes a package. When set, only artifacts whose target triple appears in this list are turned into packages; the rest are silently skipped (deliberately out of scope — unlike a target with no npm os/cpu mapping, which is warned about). Orthogonal to ids:: both filters apply (an artifact must pass the ids filter AND, when this is set, be listed here). A listed triple that no selected build produces is a config error, and an explicit empty list (targets: []) is rejected — omit the field to publish every built target. Example: targets: [x86_64-unknown-linux-gnu, aarch64-apple-darwin].

§mode: NpmMode

Binary-distribution strategy. optional-deps (default) emits npm’s native per-platform packages; postinstall emits a download shim.

§scope: Option<String>

npm scope for the per-platform packages emitted in optional-deps mode (e.g. @biomejs). The per-platform packages are named <scope>/<bin>-<os>-<cpu>[-<libc>]. Required for optional-deps mode unless platform_name_template is set (a template can produce unscoped names); ignored in postinstall mode.

§platform_name_template: Option<String>

Override the per-platform package naming in optional-deps mode.

The rendered template is the FULL package name for each platform, replacing the default <scope>/<bin>-<os>-<cpu>[-<libc>]. Beyond the standard release context, four platform vars are available per package: NpmOs (npm’s os selector: linux/darwin/win32), NpmCpu (x64/arm64/ia32/…), NpmLibc (glibc/musl, empty off-linux), plus anodizer’s own Os/Arch target mapping (os windows, not win32). Example: "git-cliff-{{ Os }}-{{ NpmCpu }}" yields git-cliff-linux-x64, git-cliff-darwin-arm64, git-cliff-windows-x64. A rendered name without a leading @ is prefixed with scope when one is set; with this template set, scope is optional and unscoped names are allowed. If the template renders the same name for two platforms (e.g. it omits NpmLibc while libc_aware is true), the publisher fails with a config error naming the colliding packages. The npm os/cpu/libc selector fields inside each package.json always use the npm tokens regardless of this template. Ignored (hard error) in postinstall mode.

§skip_metapackage: Option<StringOrBool>

In optional-deps mode, emit and publish ONLY the per-platform packages — no metapackage (no optionalDependencies aggregate, no bin shim). Accepts bool or template string, like skip. For projects whose base npm package is hand-written (e.g. a TypeScript library owning the name) while anodizer owns the per-platform binary packages it lists under its own optionalDependencies. Hard error in postinstall mode (there is no metapackage to skip) — but only when it evaluates truthy: skip_metapackage: false (or a template rendering falsey/empty) is inert. Example bool form: skip_metapackage: true. Example templated form: skip_metapackage: "{{ if .Env.EXTERNAL_METAPACKAGE }}true{{ end }}" — skip only when the base package is published elsewhere.

§metapackage: Option<String>

Metapackage name for optional-deps mode (e.g. biome). This is the package users npm install; it lists every per-platform package under optionalDependencies and ships the bin shim. Falls back to name (or the crate name) when unset.

§bin: Option<String>

Command name installed by the metapackage’s bin map (optional-deps mode). Falls back to the metapackage basename when unset. Shorthand for a single-command package; superseded by bins when both are set.

§bins: Option<BTreeMap<String, String>>

Multiple commands installed by one package, as a map of command name → binary filename to resolve inside the selected per-platform package (optional-deps) or the extracted bin/ directory (postinstall). The package that ships hurl + hurlfmt, for example, sets bins: { hurl: hurl, hurlfmt: hurlfmt } to emit both commands. Each command gets its own launcher shim (<command>.js) and its own entry in the package’s bin map. When set, this supersedes the single-command bin: shorthand; when unset, a single command is emitted from bin:.

§platform_bin_dir: Option<String>

Per-platform binary subdirectory inside each optional-deps package (e.g. bin). When set, the platform binary lands at <platform_bin_dir>/<binary> rather than the package root, the metapackage shim resolves it at that path, and the package’s files allowlist covers it. Required by external shims that hard-code a nested resolve path — for example git-cliff’s own wrapper resolves git-cliff-<os>-<arch>/bin/git-cliff, so a skip_metapackage layout must place the binary under bin/. When unset (the default), the binary lands at the package root (<binary>). Ignored in postinstall mode.

§shim_env: Option<BTreeMap<String, String>>

Environment variables injected into the child process the generated launcher shim spawns (both the optional-deps metapackage shim and the postinstall launcher). Each entry is merged over the inherited process.env before the native binary is exec’d, so a wrapper can set a runtime variable its binary expects (e.g. { BIOME_BINARY_SOURCE: npm }). When unset, the shim spawns with the inherited environment unchanged.

§libc_aware: bool

In optional-deps mode, emit separate per-platform packages for linux musl vs glibc (distinguished by the npm libc selector). When false, a single linux package per cpu is emitted with no libc selector. Default true — musl and glibc binaries are not interchangeable, so collapsing them risks installing the wrong one.

§name: Option<String>

NPM package name (the metapackage / postinstall package). May be scoped (@org/foo) or unscoped (foo). Falls back to the crate name when unset.

§description: Option<String>

Templated package description. Falls back to the project-level metadata.description when unset.

§homepage: Option<String>

Templated homepage URL. Falls back to metadata.homepage when unset.

§keywords: Option<Vec<String>>

NPM keywords list.

§license: Option<String>

Templated SPDX license identifier (e.g. MIT, Apache-2.0). Falls back to metadata.license when unset.

§author: Option<String>

Templated author field for package.json. Falls back to the project’s metadata.maintainers[0], and then to the crate’s Cargo.toml [package].authors[0], when unset.

§engines: Option<BTreeMap<String, String>>

npm engines constraint map written verbatim into package.json (e.g. { node: ">=18" }). When unset, anodizer emits a sensible default of { node: ">=18" } — the floor every leading native-CLI wrapper (esbuild, biome, swc) declares. Set to an empty map to suppress the field entirely.

§files: Option<Vec<String>>

Explicit npm files allowlist written into package.json. When unset, anodizer derives it from what each package actually ships (the per-platform binary, the metapackage shim.js, or the postinstall launcher/script) plus any extra_files basenames. Set to an empty list to suppress the field (npm then falls back to its implicit inclusion rules).

§provenance: Option<bool>

npm publishConfig.provenance flag. When unset, anodizer emits true — the npm supply-chain norm that biome and swc both set, pairing with anodizer’s signing story. Set to false to disable.

§repository_url: Option<String>

Templated repository URL. Emitted as repository.url in package.json with type: git. Falls back to the crate’s Cargo.toml [package].repository when unset. Named repository_url to avoid colliding with the {owner, name, token, ...} repository: block every git-based publisher uses; the legacy repository: spelling is accepted via serde alias for back-compat.

§bugs: Option<String>

Templated bug tracker URL. Emitted as bugs.url in package.json.

§man: Option<Vec<String>>

npm man page list, emitted verbatim into package.json as man (a path or array of paths to troff-formatted man pages npm installs).

§contributors: Option<Vec<String>>

npm contributors list, emitted verbatim into package.json as contributors (each entry a name or Name <email> (url) string).

§access: Option<String>

NPM access level for scoped packages. Accepts "public" / "restricted". Scoped packages on npmjs.org default to restricted unless this is set to public.

§tag: Option<String>

NPM dist-tag for the publish (default latest). Templated.

§format: Option<String>

Archive format the postinstall script downloads (tgz, tar.gz, tar, zip, binary). Default tgz. Only consulted in postinstall mode.

§url_template: Option<String>

Override the download URL emitted into the postinstall script (templated). When unset, anodizer derives the URL from the release context. Only consulted in postinstall mode.

§binary_version: Option<String>

Version of the native binary the postinstall script downloads, when it differs from the published npm package version. Feeds the {{ Version }} var of the derived (or url_template) download URL, so the npm package can be re-published at a new version while still fetching a pinned binary release. Falls back to the release version when unset. Only consulted in postinstall mode.

§amd64_variant: Option<Amd64Variant>

amd64 microarchitecture variant filter (v1 / v2 / v3 / v4). When set, an amd64 artifact is included only when its amd64_variant metadata matches (artifacts without the metadata always pass). Steers which tuned build lands in each platform package. Typed as Amd64Variant, so any value outside v1..v4 is rejected at parse time. Default v1, mirroring the homebrew/winget/krew/nix/aur peers.

§arm_variant: Option<String>

ARM version filter (e.g. 6, 7). When set, a 32-bit ARM artifact is included only when its arm_variant metadata matches (artifacts without the metadata always pass). Mirrors the homebrew/winget/krew/nix/aur peers; defaults to 6 when unset.

§extra_files: Option<Vec<String>>

Additional files to include in the published package alongside the generated metadata. Default ["README*", "LICENSE*"] (applied at the Default pass).

§templated_extra_files: Option<Vec<NpmTemplatedExtraFile>>

Template-rendered file mappings (src may be a glob; rendered contents written to dst).

§extra: Option<HashMap<String, Value>>

Free-form root-level package.json fields. Shallow-merged into the generated package.json (config keys win over generated ones). Useful for mcpName, funding, or other npm metadata fields anodizer does not surface as first-class options.

§registry: Option<String>

Override the registry endpoint (default https://registry.npmjs.org).

§token: Option<String>

Auth token for the registry. Falls back to the NPM_TOKEN env var when unset. Stored in .npmrc as //<registry>/:_authToken=... at publish time and never passed via argv.

§auth: NpmAuthMode

Credential-selection strategy: auto (default) decides per package by probing the registry for the package’s existence; token always uses the token; oidc always uses Trusted Publishing with no token fallback. See NpmAuthMode. Absent in existing configs resolves to auto.

§skip: Option<StringOrBool>

Skip this publisher. Accepts bool or template string. Accepts the legacy disable: spelling via serde alias for back-compat.

§required: Option<bool>

Override whether this publisher failing should fail the overall release.

Default: true — NPM is a Manager-group publisher (one-way 72-hour unpublish window), so a failed publish aborts by default to avoid surprising the operator with a half-released version. Set to false to log failures but continue.

§if_condition: Option<String>

Template-conditional gate: when the rendered result is falsy ("false" / "0" / "no" / empty), the NPM publisher entry is skipped. Render failure hard-errors.

§retain_on_rollback: Option<bool>

When true, a triggered rollback leaves this publisher’s work in place rather than attempting to undo it. Default false.

Trait Implementations§

Source§

impl Clone for NpmConfig

Source§

fn clone(&self) -> NpmConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NpmConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for NpmConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for NpmConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for NpmConfig

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PublisherGateOverrides for NpmConfig

Source§

fn required_override(&self) -> Option<bool>

Config-level required: override. None keeps the publisher’s built-in default; Some(true) anywhere escalates the release gate.
Source§

fn retain_on_rollback_override(&self) -> Option<bool>

Config-level retain_on_rollback: override. Some(true) anywhere opts the publisher’s successful work out of rollback.
Source§

impl Serialize for NpmConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more