codeMapNow
uses tcmts.share.roleNow, which uses tcmts.cli.pages.roleOf, which uses tcmts.cli.roles.codebaseRoles, which uses tcmts.cli.roles.rolesIn, which uses tcmts.cli.roles.manifestsIn, which uses tcmts.cli.config.configValue, which uses node:path
The branch's CodeMap as of its head, of everything or of what's under a namespace (a codebase the registry
mirrors, say, from its root): made once (in slices, so the pages asked for meanwhile aren't held up)
and kept until the head moves.
import { isManifestPath } from "#codebase/tcmts/cli/manifests"; import { codeMapOf, inSlices, manifestTargets, namesNow, packageInfoOf, projectNow, roleNow, } from "#codebase/tcmts/share"; import type { CodeMap, Share } from "#codebase/tcmts/share"; export function codeMapNow(s: Pick<Share, "cb" | "cache">, under = ""): Promise<CodeMap> { return s.cache.atHead(s.cb, `code map ${under}`, async () => { const all = namesNow(s); const rows = under ? all.filter((r) => r.path.startsWith(`${under}.`)) : all; // (placing a definition places what it uses: in slices, as the front page does) await inSlices(rows.map((r) => () => roleNow(s, r))); const placement = s.cache.placement(s.cb); // (a manifest references what its strings name, as its page links them, and its namespace, which is its package: // every manifest, a library's too; not its tests, as the graph leaves tests out) const root = under || projectNow(s).root; const manifests = rows .filter((r) => isManifestPath(r.path) && r.kind !== "type") .flatMap((r) => packageInfoOf(s.cb, r) ?? []); const alsoUses = manifests.flatMap((p) => { const tests = new Set(Object.values(p.suites).flat()); const named = [...manifestTargets(p, rows, manifests).values()].filter((t) => !tests.has(t)); return [...(p.namespace ? [p.namespace] : []), ...named].map((t): [string, string] => [ p.manifestPath, t, ]); }); const making = codeMapOf( rows, (h) => s.cb.store.namedDependents(h), (h) => placement.placeOf(h).place, root, alsoUses, ); let made: CodeMap | undefined; await inSlices( (function* () { while (!made) { yield () => { const next = making.next(); if (next.done) made = next.value; }; } })(), ); return made!; }); }
uses
- tcmts.cli.manifests.isManifestPath
- tcmts.share.CodeMap
- tcmts.share.Share
- tcmts.share.codeMapOf
- tcmts.share.inSlices
- tcmts.share.manifestTargets
- tcmts.share.namesNow
- tcmts.share.packageInfoOf
- tcmts.share.projectNow
- tcmts.share.roleNow