IF Commons GitHub

governance/commands

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-package-managers-governance FR-001, 0002-package-managers-governance FR-002, 0002-package-managers-governance FR-003

What a package manager is to this library, as data: the operations of it that a dialect uses, the command of one operation as a template of words the packaging ontology states, how a manager writes an exact version, and the form a package name and a version must have to be put in a command. None of it runs anything.

import { isSafeName } from "./commands.ts";
isSafeName("xz-utils"); // true
isSafeName("-rf"); // false

Source: commons/package-managers/src/governance/commands.ts

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

OPERATIONSconst
const OPERATIONS: readonly ["Install", "QueryInstalled", "QueryVersion", "Refresh"]

The operations of a manager that a dialect uses.

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

Operationtypeno test imports it
type Operation = (typeof OPERATIONS)[number];

One operation of a package manager that a dialect uses: install a package, ask whether one is installed, ask its version, or refresh the index.

import type { Operation } from "./commands.ts";
const op: Operation = "QueryVersion";
CommandSpectype
type CommandSpec = { readonly manager: string; readonly executable: string; /** A `NAME=value` the command runs wi… (586 characters)
type CommandSpec = {
  readonly manager: string;
  readonly executable: string;
  /** A `NAME=value` the command runs with, where the manager needs one. */
  readonly environment?: string;
  readonly needsAdministrator: boolean;
  /** The words of the command, with `{packages}` or `{package}` where the names go. */
  readonly template: string;
  /** The form that asks nothing of a person; the template where there is none. */
  readonly nonInteractive?: string;
  /** Whether the ontology carries a date and a place it was tried (`pm:verifiedOn`). */
  readonly verified: boolean;
};

One command of a manager, as the packaging ontology states it.

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

Versioningtype
type Versioning =
  | { readonly kind: "joined"; readonly joiner: "=" | "@" }
  | { readonly kind: "flags"; readonly packageFlags: readonly string[]; readonly exactFlags: readonly string[]; readonly versionFlag: string }
  | { readonly kind: "none"; readonly reason: string };

How a manager writes an exact version: joined to the name (pkg=1.2, pkg@1.2), as flags after the name (--id pkg --exact --version 1.2), or not at all.

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

isSafeNamefunction
function isSafeName(name: string): boolean

A package name safe to put in a command: it starts with a letter or a digit, never a dash, so that it cannot be taken for an option.

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

isSafeVersionfunction
function isSafeVersion(version: string): boolean

A version safe to put in a command.

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

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