IF Commons GitHub

governance/ids

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-toolchain-governance FR-001

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; // true

Source: commons/toolchain/src/governance/ids.ts

6 of 9 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

ToolNametype
type ToolName = Brand<string, "toolchain tool name">;

The name of a tool.

Imported by 8 tests of the run (8 passed, 0 failed): the library's results

Versiontypeno test imports it
type Version = Brand<string, "toolchain version">;

One exact version of a tool: dotted numbers with an optional suffix.

parseToolNamefunction
function 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.

Imported by 9 tests of the run (9 passed, 0 failed): the library's results

parseVersionfunction
function 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.

Imported by 9 tests of the run (9 passed, 0 failed): the library's results

compareVersionsfunction
function compareVersions(a: string, b: string): number

The 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.

Imported by 9 tests of the run (9 passed, 0 failed): the library's results

PinIdtypeno test imports it
type 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 it
type ManagerId = Brand<string, "toolchain manager id">;

The identity of a package manager of the packaging ontology (manager-apt).

parsePinIdfunction
function 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.

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

parseManagerIdfunction
function 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.

Imported by 17 tests of the run (17 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.