feat(cli): Add tttk check validator
Statically validate a directory of tttk documents and report structured diagnostics with file/line positions, exit codes, and --json output. Checks cover code-block roles, unresolved content references, tag blocks, element names, links, anchors, and assets. Runs over the same content registry as the app.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import type { CheckCommandHandler } from "../types.js";
|
||||
import { formatHuman, formatJson } from "../validate/diagnostics.js";
|
||||
import { runCheck } from "../validate/index.js";
|
||||
|
||||
export const checkCommand: CheckCommandHandler = async (dir, options) => {
|
||||
let report;
|
||||
try {
|
||||
report = runCheck(dir);
|
||||
} catch (error) {
|
||||
console.error(error instanceof Error ? error.message : String(error));
|
||||
process.exitCode = 2;
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(
|
||||
options.json ? formatJson(report) : formatHuman(report, options.quiet),
|
||||
);
|
||||
|
||||
const failed =
|
||||
report.summary.errors > 0 ||
|
||||
(options.strict && report.summary.warnings > 0);
|
||||
if (failed) process.exitCode = 1;
|
||||
};
|
||||
Reference in New Issue
Block a user