OPERATIONSconstconst OPERATIONS: readonly ["Install", "QueryInstalled", "QueryVersion", "Refresh"]The operations of a manager that a dialect uses.
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"); // falseOPERATIONSconstconst OPERATIONS: readonly ["Install", "QueryInstalled", "QueryVersion", "Refresh"]The operations of a manager that a dialect uses.
Operationtypeno test imports ittype 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";CommandSpectypetype 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.
Versioningtypetype 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.
isSafeNamefunctionfunction isSafeName(name: string): booleanA 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.
isSafeVersionfunctionfunction isSafeVersion(version: string): booleanA version safe to put in a command.