printAttestations
uses tcmts.cli.style.red, which uses node:util
Attestations, said a line each: yanks and advisories first.
import type { FoundAttestation } from "#codebase/tcmts/cli/attest"; import { red, yellow } from "#codebase/tcmts/cli/style"; export function printAttestations(found: FoundAttestation[], who: (did: string) => string): void { const order = { yank: 0, advisory: 1, review: 2 } as const; for (const a of [...found].sort( (x, y) => order[x.kind] - order[y.kind] || y.createdAt.localeCompare(x.createdAt), )) { // (what someone else wrote, as text: no escape sequences for the terminal to act on) // eslint-disable-next-line no-control-regex const plain = (s: string) => s.replace(/[\u0000-\u0009\u000b-\u001f\u007f-\u009f]/g, ""); const first = plain(a.body.split("\n")[0]!); if (a.kind === "yank") console.log(red(` yanked by its author ${who(a.did)}: ${first}`)); else if (a.kind === "advisory") console.log( yellow( ` advisory (${plain(a.severity ?? "")}) from ${who(a.did)}: ${first}${a.fixedIn ? ` (fixed in ${plain(a.fixedIn)})` : ""}`, ), ); else console.log(` reviewed by ${who(a.did)}: ${first}`); } }