CalVer
npm i -D @unirelman/plugin-calverpnpm add -D @unirelman/plugin-calveryarn add -D @unirelman/plugin-calverbun add -d @unirelman/plugin-calverimport { createCalverPlugin } from "@unirelman/plugin-calver";
createCalverPlugin();Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
prereleaseChannels |
string[] |
[] |
Channels a scope goes through, in order: letters, digits, and hyphens. Required by calver pre, except to exit. |
fixed |
boolean | Record<string, string[]> |
false |
Groups of scopes that share a version. See Fixed versioning. |
granularity |
"day" | "month" |
"day" |
Period of a version. See Version format. |
Phases
Section titled “Phases”| Phase | Behavior |
|---|---|
parseCurrentVersion |
Parses each scope’s current version and fills meta.calver, plus meta.prerelease for prereleases. |
computeNextVersion |
Computes each scope’s next version from the current date and its prerelease state, following the rules. |
Version format
Section titled “Version format”| Granularity | Release | Prerelease |
|---|---|---|
day |
YYYY.MM.DD.MICRO, such as 2026.01.01.0 |
YYYY.MM.DD.MICRO-<channel>.<number>, such as 2026.01.01.0-alpha.1 |
month |
YYYY.MM.MICRO, such as 2026.01.0 |
YYYY.MM.MICRO-<channel>.<number>, such as 2026.01.0-alpha.1 |
The npm registry accepts SemVer versions only, so calendar-versioned packages stay private: see Use calendar versioning.
Next version rules
Section titled “Next version rules”The date is the day, or the month with the month granularity, of the version run, in UTC. Any change gives a next version, whatever its level, and every rule but “Exit, no changes” needs one. The examples use the day granularity; with month, “day” reads “month” (2026.01.3 → 2026.02.0 in a new month).
| Situation | Rule | Example (on 2026-01-02) |
|---|---|---|
| Release, another day | Today, micro 0. |
2026.01.01.3 → 2026.01.02.0 |
| Release, same day | Increment micro. | 2026.01.02.0 → 2026.01.02.1 |
| Enter a channel | Bump, then start the channel at 0. |
2026.01.01.3 → 2026.01.02.0-alpha.0 |
| Same channel, same day | Increment the number. | 2026.01.02.0-alpha.0 → 2026.01.02.0-alpha.1 |
| Prerelease from another day | Bump to today, restart at 0. |
2026.01.01.0-alpha.2 → 2026.01.02.0-alpha.0 |
| Next channel | Keep the base, restart at 0. |
2026.01.02.0-alpha.1 → 2026.01.02.0-beta.0 |
| Exit, no changes | Release the base. | 2026.01.01.0-beta.0 → 2026.01.01.0 |
| Exit, with changes | Apply the changes, then release. | 2026.01.01.0-beta.0 → 2026.01.02.0 |
Fixed versioning
Section titled “Fixed versioning”fixed groups scopes that share a version, such as { product: ["@example/core", "@example/cli"] }. The other scopes stay independent. true is one group named all with every scope of the registration.
computeNextVersion computes one next version per group, from the shared current version and the changes of every scope of the group, and gives it to every scope of the group, including the scopes without changes.
Commands
Section titled “Commands”calver pre
Section titled “calver pre”Puts a scope in prerelease mode, moves it to a later channel, or exits prerelease mode, in the prerelease state.
unirelman calver pre [--scope <scope> | --group <group>] [--channel <channel> | --exit]| Option | Description |
|---|---|
--scope |
Independent scope to change, outside every group. |
--group |
Group to change, by name. |
--channel |
Channel to enter, after the current one in prereleaseChannels. Prompted when missing. |
--exit |
Exit from prerelease mode: the next version releases the base version. |
A target, --scope or --group, is prompted when missing, and required by --channel and --exit. When the registration has a single target, such as the all group of fixed: true, the target is optional.
JSON document
Section titled “JSON document”With --json, the command prints this document, validated by prereleaseOutputSchema from @unirelman/helpers/prerelease:
{ "group": null, "scopes": ["@example/ui"], "channel": "beta", "previousChannel": "alpha"}| Field | Type | Description |
|---|---|---|
group |
string | null |
Group the command applies to, null for an independent scope. |
scopes |
string[] |
Scopes the command applies to. |
channel |
string | null |
Channel of the scopes after the command, null when they exit. |
previousChannel |
string | null |
Channel of the scopes before the command, null when they were in release mode. |
Prerelease state
Section titled “Prerelease state”{ "@example/ui": { "channel": "beta" }}Each scope listed is in prerelease mode on its channel. calver pre writes the file, and computeNextVersion reads it.
Version meta
Section titled “Version meta”Current versions carry meta.calver, the parsed version: { year, month, day, micro }, without day for the month granularity, plus { channel, increment } for a prerelease. The exported type guard checks it:
import { isCalverVersionMeta } from "@unirelman/plugin-calver";Errors
Section titled “Errors”| Error | Cause |
|---|---|
VersioningInvalidVersionError |
A current version has another format, or a date that does not exist. |
CalverFutureVersionError |
A current version is dated after today (UTC). |
GroupEmptyError |
A group has no scope. |
GroupUnknownScopeError |
A group lists a scope outside the registration. |
GroupDuplicateScopeError |
A scope is in two groups. |
VersioningFixedVersionMismatchError |
The scopes of a group have different current versions. |
VersioningMissingCurrentVersionError |
A scope or a group with changes has no current version. |
PrereleaseStateMismatchError |
The scopes of a group have different prerelease states. |
PrereleaseNoChannelsConfiguredError |
calver pre runs without --exit and with an empty prereleaseChannels. |
PrereleaseInvalidChannelNameError |
A channel in prereleaseChannels has a character other than a letter, a digit, or a hyphen. |
PrereleaseInvalidTargetChannelError |
The channel is outside prereleaseChannels, or before the current one. |
PrereleaseDowngradeChannelError |
A next version would move to an earlier channel. |
PrereleaseInvalidCurrentChannelError |
A current version is on a channel outside prereleaseChannels. |
PrereleaseInvalidChannelInStateError |
calver pre enters a channel while the state has a channel outside prereleaseChannels. |
PrereleaseInvalidScopeError |
--scope names a scope outside the independent scopes of the registration. |
PrereleaseInvalidGroupError |
--group names no group. |
PrereleaseOptionRequiredError |
--channel or --exit is given without a target. |
PrereleaseOptionsConflictError |
--channel and --exit, or --scope and --group, are given together. |