librariesOf
The libraries some names hold (a branch's, or a past namespace's), from the records among them, each read with
textOf: outermost only.
import { parseRecord, RECORD, within } from "#codebase/tcmts/cli/libraries"; import type { Library } from "#codebase/tcmts/cli/libraries"; import type { NameRow } from "#codebase/tcmts/store"; export function librariesOf( rows: Pick<NameRow, "path" | "hash" | "kind">[], textOf: (hash: string) => string, ): Library[] { const all: Library[] = []; for (const r of rows) { if (r.kind !== "file" || r.path.slice(r.path.lastIndexOf(".") + 1) !== RECORD) continue; const ns = r.path.includes(".") ? r.path.slice(0, r.path.lastIndexOf(".")) : ""; for (const [name, e] of Object.entries(parseRecord(textOf(r.hash)))) all.push({ ...e, path: ns ? `${ns}.${name}` : name, record: r.path }); } return all.filter((l) => !all.some((o) => o !== l && within(l.path, o.path))); }
uses
- tcmts.cli.libraries.Library
- tcmts.cli.libraries.RECORD
- tcmts.cli.libraries.parseRecord
- tcmts.cli.libraries.within
- tcmts.store.NameRow