ToolNametypetype ToolName = Brand<string, "toolchain tool name">;The name of a tool.
The names of Toolchain: a tool name and a version, each made only by the function that validates it, and the order of two versions. A version is one exact version of a tool, never latest and never a range: what is pinned is one thing.
import { compareVersions, parseVersion } from "./ids.ts";
parseVersion("1.10.0").kind; // "ok"
parseVersion("^1.2.3").kind; // "err"
compareVersions("1.10.0", "1.9.9") > 0; // trueToolNametypetype ToolName = Brand<string, "toolchain tool name">;The name of a tool.
Versiontypeno test imports ittype Version = Brand<string, "toolchain version">;One exact version of a tool: dotted numbers with an optional suffix.
parseToolNamefunctionfunction parseToolName(text: string): Result<ToolName, string>A tool name from text: lower case words joined by hyphens, starting with a letter, at most 60 characters.
parseVersionfunctionfunction parseVersion(text: string): Result<Version, string>A version from text: one to four numbers joined by dots, with an optional suffix after a hyphen or a plus sign; latest, an empty text and a range are refused.
compareVersionsfunctionfunction compareVersions(a: string, b: string): numberThe order of two versions: negative where a is the earlier, positive where it is the later, 0 where they are the same. A version with a pre-release suffix comes before the same numbers without one.
PinIdtypeno test imports ittype PinId = Brand<string, "toolchain pin id">;The name of a pin of the packaging ontology (bun, rustup-init): a program's pinned download, whose version and checksums the ontology holds.
ManagerIdtypeno test imports ittype ManagerId = Brand<string, "toolchain manager id">;The identity of a package manager of the packaging ontology (manager-apt).
parsePinIdfunctionfunction parsePinId(text: string): Result<PinId, string>A pin id from text: lower case words joined by hyphens, starting with a letter, as the packaging ontology names a pin.
parseManagerIdfunctionfunction parseManagerId(text: string): Result<ManagerId, string>A manager id from text: manager- and lower case words joined by hyphens, as the packaging ontology names a package manager.