listLibraries
uses tcmts.cli.style.dim, which uses node:util
tcm lib: the libraries this branch holds, each with what it is, where it comes from, and what its author and the
people the codebase trusts say of it (yanks, advisories, reviews).
import { attestationsFor, attesterNames, printAttestations } from "#codebase/tcmts/cli/attest"; import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { announcer, EFFECT_WORDS, librariesIn, libraryEffects, libraryLabel, mountedAsAdded, mountedRows, } from "#codebase/tcmts/cli/libraries"; import { bold, dim } from "#codebase/tcmts/cli/style"; import type { Effect } from "#codebase/tcmts/core/effects"; export async function listLibraries(cb: Codebase) { const libraries = librariesIn(cb.store); if (!libraries.length) return console.log( dim( "no libraries; add one with `tcm lib add @<handle>/<package>`, or `tcm lib add <source> <package>[@<version>]`", ), ); for (const l of libraries) { const changed = mountedAsAdded(cb.store, l) ? "" : ` ${dim("(its names aren't the namespace it was added as)")}`; const { reaches, unknown } = libraryEffects(cb, mountedRows(cb.store, l)); const effects = (Object.keys(EFFECT_WORDS) as Effect[]) .filter((e) => reaches.has(e)) .map((e) => EFFECT_WORDS[e]); const said = effects.length ? `reaches ${effects.join(", ")}` : "reaches nothing outside itself"; console.log( `${bold(l.path)} ${libraryLabel(l)} ${dim(`${l.did ? `by ${announcer(l)}, ` : ""}from ${l.sources.join(", ")} · ${said}${unknown.length ? ` (can't tell for ${unknown.join(", ")})` : ""}`)}${changed}`, ); // (what its author and the people this codebase trusts say of it) printAttestations(await attestationsFor(cb, [l.namespace], l.did), attesterNames(cb, l)); } }
uses
- tcmts.cli.attest.attestationsFor
- tcmts.cli.attest.attesterNames
- tcmts.cli.attest.printAttestations
- tcmts.cli.codebase.Codebase
- tcmts.cli.libraries.EFFECT_WORDS
- tcmts.cli.libraries.announcer
- tcmts.cli.libraries.librariesIn
- tcmts.cli.libraries.libraryEffects
- tcmts.cli.libraries.libraryLabel
- tcmts.cli.libraries.mountedAsAdded
- tcmts.cli.libraries.mountedRows
- tcmts.cli.style.bold
- tcmts.cli.style.dim
- tcmts.core.effects.Effect