Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | 1x 2x 2x 1x 4x 4x 4x 1x 4x 4x 4x 1x 1x 3x 2x 3x 3x 2x | import type { Args } from "../shared/cli.ts";
import { optionValue } from "../shared/domain/cli.ts";
import { ExpectedError } from "../shared/errors.ts";
import { out } from "../shared/adapters/io.ts";
import {
projectRoots,
readManifests,
readNuxtSources,
readPackages,
readTableSources,
readWorkflows,
} from "./adapters/files.ts";
import { assertCommit, manifestAt } from "./adapters/git.ts";
import { manifestBans } from "./domain/bans.ts";
import { contractFindings, validatePackage } from "./domain/contracts.ts";
import { blocking, type Finding } from "./domain/findings.ts";
import { oneSidedShared } from "./domain/sides.ts";
import { compareLayoutBlock, compareTagTables } from "./domain/tables.ts";
import { misnamedWorkflow } from "./domain/workflows.ts";
const versionOf = (manifest: unknown): string | undefined => {
const version = (manifest as { version?: unknown } | undefined)?.version;
return typeof version === "string" ? version : undefined;
};
const collect = (base: string | undefined): Finding[] => {
const { boundaries, readme } = readTableSources();
return [
...readManifests().flatMap(({ path, manifest }) =>
manifestBans({
path,
manifest,
baseVersion: base === undefined ? undefined : versionOf(manifestAt(base, path)),
}),
),
...readPackages().map(validatePackage).flatMap(contractFindings),
...readNuxtSources().flatMap(oneSidedShared),
...compareTagTables(boundaries, readme),
...compareLayoutBlock(readme, projectRoots()),
...readWorkflows().flatMap(misnamedWorkflow),
];
};
export const main = ({ flags }: Args): void => {
const baseFlag = optionValue(flags, "base");
const findings = collect(baseFlag === undefined ? undefined : assertCommit(baseFlag));
if (flags.has("json")) {
out.json(findings);
return;
}
for (const finding of findings) {
(finding.blocks ? out.error : out.warn)(`${finding.title}: ${finding.detail}`);
}
const failures = blocking(findings).length;
if (failures > 0) throw new ExpectedError(`invariants:check found ${failures} violation(s).`);
out.success(
findings.length === 0
? "Repo invariants hold."
: `Repo invariants hold; ${findings.length} docs warning(s) above.`,
);
};
|