suiteLibraries
uses node:path
The tcm libraries the package at namespace ships (libraries in its manifest), packed as tcm pack packs them,
for its command run from this codebase (as suites run it, not from a package): a directory holding their
codebase.sqlite, made once for those releases, which the command finds by TCM_SHIPPED_LIBRARIES. Undefined if it ships
none.
import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { packagesIn } from "#codebase/tcmts/cli/manifests"; import { packLibraries } from "#codebase/tcmts/cli/pack"; import { createHash } from "node:crypto"; import fs from "node:fs"; import path from "node:path"; export function suiteLibraries(cb: Codebase, namespace: string): string | undefined { let pkg; try { pkg = packagesIn(cb, cb.store.names(undefined, true)).find((p) => p.namespace === namespace); } catch { return undefined; } const libraries = pkg?.manifest.libraries ?? []; if (!libraries.length) return undefined; const releases = libraries.map((l) => { const r = cb.store.releases(l)[0]; return r ? `${l}@${r.version} ${r.causal}` : l; }); const dir = path.join( cb.lay.cacheDir, "libraries", createHash("sha256").update(releases.join("\n")).digest("hex").slice(0, 16), ); if (!fs.existsSync(path.join(dir, "codebase.sqlite"))) packLibraries(cb, libraries, dir); return dir; }