rolesIn

tcmts.cli.roles.rolesIn · #nyotug22 · term · runs on the server

uses tcmts.cli.roles.manifestsIn, which uses tcmts.cli.config.configValue, which uses node:path

The roles the codebase's packages give their definitions (roles in a manifest), its libraries' included: each definition's hash, and its role. A version of a library's that a codebase holds is known by its hash wherever it's used from.

import type { Evaluating } from "#codebase/tcmts/cli/config";
import { manifestsIn } from "#codebase/tcmts/cli/roles";
import type { Role } from "#codebase/tcmts/cli/roles";
import type { NameRow } from "#codebase/tcmts/store";

export function rolesIn(cb: Evaluating, rows: NameRow[] = cb.store.names()): Map<string, Role> {
  const hashOf = new Map(rows.filter((r) => r.kind !== "type").map((r) => [r.path, r.hash]));
  const out = new Map<string, Role>();
  for (const { namespace, manifest } of manifestsIn(cb, rows))
    for (const [name, role] of Object.entries(manifest.roles ?? {})) {
      const h = hashOf.get(namespace ? `${namespace}.${name}` : name);
      if (h) out.set(h, role);
    }
  return out;
}

uses

used by