Npm
@simple-release/npm describes projects managed with npm: NpmProject for a single package and NpmWorkspacesProject for an npm workspaces monorepo. Publishing runs npm publish.
pnpm add @simple-release/npmnpm i @simple-release/npmyarn add @simple-release/npmSingle package:
{ "project": "@simple-release/npm#NpmProject"}Workspaces monorepo — NpmWorkspacesProject reads the workspaces list from the package.json in the project root:
{ "project": ["@simple-release/npm#NpmWorkspacesProject", { "mode": "fixed" }]}Options
Section titled “Options”NpmProject
Section titled “NpmProject”| Option | Description |
|---|---|
path | Path to the package.json manifest file. Defaults to 'package.json'. |
changelogFile | Path to the changelog file. Defaults to 'CHANGELOG.md'. |
compose | Function to compose the main manifest with secondary manifests where the version should also be updated. Optional. |
NpmWorkspacesProject
Section titled “NpmWorkspacesProject”| Option | Description |
|---|---|
mode | Versioning mode. Required. independent — each package has its own version; fixed — all packages share the same version. |
root | Path to the monorepo root. Defaults to the current working directory. |
changelogFile | Path to the changelog file. Defaults to 'CHANGELOG.md'. |
compose | Same as for NpmProject, called for each manifest in the monorepo. Optional. |
scope | Function to format the scope name from the package name. By default the scope part of the package name is dropped: @scope/pkg-name → pkg-name. |
tagPrefix | Function to format the tag prefix from the scope name. Defaults to pkg-name@ in independent mode and an empty string in fixed mode. |
In monorepos, commits are attributed to packages by the commit scope — fix(pkg-name): ... bumps pkg-name. The scope must match the package name without the npm scope (or whatever your scope function returns).
In fixed mode, only packages with changes get the new version. When it is breaking for one of them — a major bump, a minor bump of a 0.x version or a patch bump of a 0.0.x version, including a major prerelease and its graduation — the packages without changes are bumped too, so all packages are released together. Set the force bump option to false to turn it off, or to true to always bump all packages. npm publishes version ranges of workspace dependencies as written, so update them along with breaking releases.
publish
Section titled “publish”Options of the publish step for both classes:
| Option | Description |
|---|---|
skip | Skip publishing. |
access | Access level for the package. |
tag | npm dist-tag — a string or a function of the version and prerelease components. When not set, prereleases get their prerelease identifier and maintenance releases of previous majors get release-N.x, so they never overwrite latest. |
otp | One-time password for publishing. |
env | Environment variables to set before publishing. Defaults to process.env. |