printEffects
uses tcmts.cli.style.dim, which uses node:util
A library's effects (#mplyds33), a line each; against what it reached before (was, an upgrade),
only what's new or gone.
import { EFFECT_WORDS } from "#codebase/tcmts/cli/libraries"; import type { libraryEffects } from "#codebase/tcmts/cli/libraries"; import { dim, red, yellow } from "#codebase/tcmts/cli/style"; import type { Effect } from "#codebase/tcmts/core/effects"; export function printEffects( now: ReturnType<typeof libraryEffects>, was?: ReturnType<typeof libraryEffects>, ) { const some = (xs: string[]) => `${xs.slice(0, 3).join(", ")}${xs.length > 3 ? ` (+${xs.length - 3})` : ""}`; const order = Object.keys(EFFECT_WORDS) as Effect[]; if (!was) { if (!now.reaches.size && !now.unknown.length) return console.log(dim(" reaches nothing outside itself")); for (const e of order) { const at = now.reaches.get(e); if (at) console.log(` ${yellow("reaches")} ${EFFECT_WORDS[e]}${dim(`: ${some(at)}`)}`); } } else { for (const e of order) { const at = now.reaches.get(e); if (at && !was.reaches.has(e)) console.log(`\n ${red("now reaches")} ${EFFECT_WORDS[e]}${dim(`: ${some(at)}`)}`); if (!at && was.reaches.has(e)) console.log(dim(`\n no longer reaches ${EFFECT_WORDS[e]}`)); } } const fresh = now.unknown.filter((p) => !was?.unknown.includes(p)); if (fresh.length) console.log( ` ${yellow("can't tell what")} ${some(fresh)} ${yellow("reach")}${dim(": not all of their code could be followed")}`, ); }
uses
- tcmts.cli.libraries.EFFECT_WORDS
- tcmts.cli.libraries.libraryEffects
- tcmts.cli.style.dim
- tcmts.cli.style.red
- tcmts.cli.style.yellow
- tcmts.core.effects.Effect