magus v0.4.2 is out. See what's new
¶ View generated markdown
2 min read

semver

Semantic version parsing and comparison (SemVer 2.0.0).

Naming convention: import the module under its bare name (import "semver"), reach members with a backslash, and call methods in camelCase: semver\someMethod.

Methods

compare

Order two semver strings: -1 when a sorts before b, 0 when they are equal, 1 when a sorts after. Use satisfies() to test a relation or a range.

Signature: semver\compare(a, b) -> int - source

Parameter Type Optional Description
a string
b string

Returns: int

isValid

Whether v parses as a semantic version. Use it instead of calling parse purely to see whether it raises.

Signature: semver\isValid(v) -> bool - source

Parameter Type Optional Description
v string

Returns: bool

canonical

Canonical "vX.Y.Z" form of v, filling in missing components and discarding build metadata; errors on invalid input.

Signature: semver\canonical(v) -> string - source

Parameter Type Optional Description
v string

Returns: string

major

The major prefix of v as a string: major("1.2.3") is "v1". This is the cache token a spell's VersionKey{upTo = "major"} produces; parse().major is the same number as an int.

Signature: semver\major(v) -> string - source

Parameter Type Optional Description
v string

Returns: string

majorMinor

The major.minor prefix of v as a string: majorMinor("1.2.3") is "v1.2". This is the cache token a spell's VersionKey{upTo = "minor"} produces.

Signature: semver\majorMinor(v) -> string - source

Parameter Type Optional Description
v string

Returns: string

satisfies

Whether v meets constraint, the full range syntax magus.yaml required_version uses: ">= 1.2, < 2.0", "^1.2.3", "~1.2". compare() tests one relation; this tests a range.

Signature: semver\satisfies(v, constraint) -> bool - source

Parameter Type Optional Description
v string
constraint string

Returns: bool

parse

Parse a semver string into {major, minor, patch, prerelease, metadata, original}; errors on invalid input.

Signature: semver\parse(v) -> SemverVersion - source

Parameter Type Optional Description
v string

Returns: map[string]any

next

Candidate next versions after v: {major, minor, patch}, each "vX.Y.Z" - the result of bumping the major, minor, or patch component. Errors on invalid input.

Signature: semver\next(v) -> SemverNext - source

Parameter Type Optional Description
v string

Returns: map[string]any

generatedreference/buzz/semvermodulestdlibmagusfile
Last updated (4f8cc295)
Earlier changes on this page (7)

Full history ↗ · Blame source ↗

Glossary

Magusfile

The magusfile.buzz that declares a project's targets (as export funs) and binds its spells. See targets.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). See operations.

Spell

A language/runtime adapter (e.g. go, md) that maps generic targets onto a toolchain's real commands. See spells.

Module

A magus stdlib namespace a magusfile imports for host capabilities: filesystem, exec, vcs, and more. See the module reference.

Buzz

The language magusfiles are written in (the .buzz engine). See engines.

Cache

The content-addressed store magus consults before running a target, so unchanged work is skipped. See cache.

Lease

One row of the lease ledger: a piece of work an orchestrating agent handed out, with its goal, the checkpoint it was cut against, and the paths it owns or must not touch. The ledger records; the agent guard is what reads those facts back when grading a write. See doctrine.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.