IF Commons GitHub

logical/sync

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-repoctl-sync FR-002

repoctl sync (commons repoctl 0003-repoctl-sync FR-002 to FR-004): every generator in the order of its table, rerunning only the ones whose own check says their files are stale, and proving each rewrite by checking it again; with the mode check nothing is written, and each generator that is stale is named with the command that fixes it. A generator's status is read as its programs end: 0 its files are what it makes, 1 they are not (or a source of it is wrong, which its own lines say), anything else it could not run.

import { classify } from "./sync.ts";
classify({ code: 0, stdout: "", stderr: "" }); // "fresh"
classify({ code: 1, stdout: "", stderr: "README.md is not what the manifests make" }); // "stale"

Source: commons/repoctl/src/logical/sync.ts

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

logical.Outcometypeno test imports it
type Outcome =
  | { readonly kind: "fresh"; readonly id: StepId }
  | { readonly kind: "regenerated"; readonly id: StepId }
  | { readonly kind: "stale"; readonly id: StepId; readonly fix: string; readonly detail: readonly string[] }
  | { readonly kind: "failed"; readonly id: StepId; readonly fix: string; readonly detail: readonly string[] };

What a generator did in a run of sync.

logical.Modetypeno test imports it
type Mode = "write" | "check";

Whether sync writes, or only checks.

logical.SyncReporttypeno test imports it
type SyncReport = { readonly mode: Mode; readonly outcomes: readonly Outcome[] };

The run of sync: its mode and what each generator did, in the order they ran.

logical.classifyfunctionno test imports it
function classify(run: Run): "failed" | "fresh" | "stale"

What a generator's check says of its files, from how it ended.

logical.runSyncfunctionno test imports it
function runSync(w: Pick<World, "process" | "repo">, mode: Mode, order: readonly Generator[], only?: readonly StepId[]): Promise<SyncReport>

Runs sync over the generators, which are given in the order to run them. only limits it to some of them.

logical.findingsOfSyncfunctionno test imports it
function findingsOfSync(report: SyncReport): readonly Finding[]

The findings of a run: a generator that is stale (in the mode check) and one that could not be made.

Outcometypeno test imports it
type Outcome =
  | { readonly kind: "fresh"; readonly id: StepId }
  | { readonly kind: "regenerated"; readonly id: StepId }
  | { readonly kind: "stale"; readonly id: StepId; readonly fix: string; readonly detail: readonly string[] }
  | { readonly kind: "failed"; readonly id: StepId; readonly fix: string; readonly detail: readonly string[] };

What a generator did in a run of sync.

Modetypeno test imports it
type Mode = "write" | "check";

Whether sync writes, or only checks.

SyncReporttypeno test imports it
type SyncReport = { readonly mode: Mode; readonly outcomes: readonly Outcome[] };

The run of sync: its mode and what each generator did, in the order they ran.

classifyfunction
function classify(run: Run): "failed" | "fresh" | "stale"

What a generator's check says of its files, from how it ended.

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

runSyncfunction
function runSync(w: Pick<World, "process" | "repo">, mode: Mode, order: readonly Generator[], only?: readonly StepId[]): Promise<SyncReport>

Runs sync over the generators, which are given in the order to run them. only limits it to some of them.

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

findingsOfSyncfunction
function findingsOfSync(report: SyncReport): readonly Finding[]

The findings of a run: a generator that is stale (in the mode check) and one that could not be made.

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

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