manifestTargets
What a package's manifest names by strings, as it writes them, each with the name it means: its commands, exports,
apps, end-to-end tests and package.json (definitions and namespaces, relative to its namespace), the files it ships
(kept in the codebase), and the libraries it gives apps (their packages' manifests, among packages). Only what's
in rows.
import { packageFileName } from "#codebase/tcmts/share"; import type { PackageInfo } from "#codebase/tcmts/share"; import type { NameRow } from "#codebase/tcmts/store"; export function manifestTargets( pkg: PackageInfo, rows: NameRow[], packages: PackageInfo[], ): Map<string, string> { const targets = new Map<string, string>(); const has = (n: string) => rows.some((r) => r.path === n || r.path.startsWith(`${n}.`)); const written = (n: string) => pkg.namespace && n.startsWith(`${pkg.namespace}.`) ? n.slice(pkg.namespace.length + 1) : n; const names = [ ...Object.values(pkg.bin), ...Object.values(pkg.exports).flat(), ...Object.values(pkg.apps), ...Object.values(pkg.suites).flat(), ...(pkg.packageJson ? [pkg.packageJson] : []), ]; for (const n of names) if (has(n)) targets.set(written(n), n); for (const f of pkg.files) { const n = packageFileName(rows, pkg.namespace, f); if (n) targets.set(f, n); } for (const l of pkg.libraries) { const p = packages.find((x) => x.name === l); if (p) targets.set(l, p.manifestPath); } return targets; }