version_bump/plugins/npm

The npm publish plugin (plugin name “npm”).

Mirrors @semantic-release/npm. It manages a package.json and the npm registry across three hooks:

The only PURE function is set_version, which performs the package.json version rewrite as a string transformation so it can be unit-tested without any IO. It is exported for that reason.

Values

pub fn plugin() -> plugin.Plugin

Build the npm plugin: implements verify_conditions, prepare, and publish.

pub fn set_version(
  package_json: String,
  version: String,
) -> Result(String, error.ReleaseError)

Replace the top-level "version" field in a package.json document with version, leaving the rest of the document byte-for-byte intact.

PURE: a string transformation, no IO. Returns a PluginError when no "version" field is present so callers can surface a clear message rather than silently producing a package.json without a version.

The match targets the first "version": "..." pair, which in a well-formed package.json is the top-level package version. Only the quoted value is rewritten; surrounding whitespace and formatting are preserved.

Search Document