withRecord
uses Buffer
rows, with the record at record holding entries (none: no record).
import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { fileDefinition } from "#codebase/tcmts/cli/files"; import { recordText } from "#codebase/tcmts/cli/libraries"; import type { LibraryEntry } from "#codebase/tcmts/cli/libraries"; import type { NameRow } from "#codebase/tcmts/store"; export function withRecord( cb: Codebase, rows: NameRow[], record: string, entries: Record<string, LibraryEntry>, ): NameRow[] { const kept = rows.filter((r) => r.path !== record); if (!Object.keys(entries).length) return kept; const { def } = fileDefinition(cb, record, "json", Buffer.from(recordText(entries))); cb.putDefs([def]); return [...kept, { path: record, hash: def.hash, kind: "file" }]; }
uses
- tcmts.cli.codebase.Codebase
- tcmts.cli.files.fileDefinition
- tcmts.cli.libraries.LibraryEntry
- tcmts.cli.libraries.recordText
- tcmts.store.NameRow