IF Commons GitHub

doctor

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-workspace-model FR-012

The checks of ergonex doctor as pure functions over facts a host layer probed (commons 0002-workspace-model FR-012, FR-014, FR-036, 0001-ergonex FR-014): the runtime and the tools, the portability of every path (Windows' 259 characters unless long paths are on), the file system of the root (FAT, exFAT, a network share, a Windows drive under WSL, each as found by a probe and never guessed from the path), and the hooks of each repository. Each check is ok, suggest, warn or error, each with what to do, and becomes a finding of the severity it names.

A message states what is wrong and what to do. A check that could not be made says so (suggest, with the reason) and is never a pass. The plaintext-token scan, signed commits and the tools and modules outside the catalog are the policy scans' (workspaces/scan/), which the command adds to these through its list of extra checks.

Source: commons/ergonex/src/doctor.ts

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

Checktypeno test imports it
type Check = {
  /** The rule, such as `ergonex/path-too-long`. */
  readonly id: string;
  readonly level: Level;
  /** What it is about: a path, a tool, a repository. */
  readonly subject: string;
  /** What is wrong and what to do about it, or, for `ok`, what was found. */
  readonly message: string;
};

One check and what it found.

classifyFsfunction
function classifyFs(type: string, wsl: boolean): FsKind

The kind of a file system by the type a probe reported (vfat, exfat, nfs, 9p), and whether the system is WSL.

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

findingsOffunction
function findingsOf(checks: readonly Check[], today: string): readonly Finding[]

The findings of a list of checks, each first seen today.

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

fsCheckfunction
function fsCheck(probe: FsProbe, home: string): Check

The check of the file system of the root.

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

FsKindtypeno test imports it
type FsKind = "ok" | "fat" | "exfat" | "network" | "wsl-windows-drive";

The kinds of file system the workspace warns about.

FsProbetypeno test imports it
type FsProbe =
  { readonly kind: "found"; readonly type: string; readonly wsl: boolean } | { readonly kind: "not-run"; readonly reason: string };

What a probe of the root's file system found, or why it was not made.

hookChecksfunction
function hookChecks(facts: readonly HookFacts[], wantedHooksPath: string): readonly Check[]

The checks of the hooks: a repository on disk whose local core.hooksPath is not the workspace's is a warning that says to run ergonex apply.

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

HookFactstypeno test imports it
type HookFacts = {
  readonly repo: RepoPath;
  /** The repository is on disk (its state is not `Missing`). */
  readonly present: boolean;
  /** The repository's local `core.hooksPath`, if it sets one. */
  readonly hooksPath: string | undefined;
};

What is known of a repository's hooks.

Leveltypeno test imports it
type Level = "ok" | "suggest" | "warn" | "error";

What a check came to: the four words of ergonex doctor.

LongPathstypeno test imports it
type LongPaths = "enabled" | "disabled" | "unknown";

What the long-path setting of Windows is.

MIN_NODE_MAJORconstno test imports it
const MIN_NODE_MAJOR: 26

The oldest Node ergonex runs on (Node 26 is the backup runtime).

PathFactstypeno test imports it
type PathFacts = {
  readonly home: string;
  readonly windows: boolean;
  readonly longPaths: LongPaths;
  /** Every path of the workspace the manifest and the templates name: repositories, worktrees, generated files. */
  readonly paths: readonly RepoPath[];
};

What the path checks are given.

pathChecksfunction
function pathChecks(f: PathFacts): readonly Check[]

The checks of path length (0002-workspace-model FR-012, FR-036): on Windows while long paths are off, a path longer than 259 characters is an error naming it and saying that ergonex setup can turn long paths on; and that long paths are not enabled is informational while no path exceeds the limit. Elsewhere the limit does not apply.

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

repoPathChecksfunction
function repoPathChecks(f: { readonly home: string; readonly windows: boolean; readonly repositories: readonly RepoPath[]; }): readonly Check[]

The checks of the length of each repository's own path (0002-workspace-model FR-048), on every system: over 150 characters is informational (it leaves little room for the files inside the repository), over 259 an error whether or not long paths are enabled. A repository whose path fits has no check of its own.

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

runtimeChecksfunction
function runtimeChecks(runtime: { readonly name: "bun" | "node"; readonly version: string; }, tools: readonly ToolProbe[]): readonly Check[]

The checks of the runtime and of the tools: git must be there; the runtime must be Bun, or Node 26 or later; the other runtime, where it is missing, is a suggestion.

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

severityOffunction
function severityOf(level: Level): Severity | undefined

The severity a level becomes; ok is none.

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

ToolProbetypeno test imports it
type ToolProbe = {
  readonly name: string;
  readonly version: string | undefined;
};

What is known of the version of a tool.

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