dependency_graph.ts view source
{ readonly PROD: "prod"; readonly PEER: "peer"; readonly DEV: "dev"; } Dependency graph data structure and algorithms for multi-repo publishing.
Provides DependencyGraph class with topological sort and cycle detection. For validation workflow and publishing order computation, see graph_validation.ts.
7 declarations
dependency_graph.ts view source
{ readonly PROD: "prod"; readonly PEER: "peer"; readonly DEV: "dev"; } dependency_graph.ts view source
nodestype Map<string, DependencyNode>
edgestype Map<string, Set<string>>
constructortype new (): DependencyGraph
init_from_repostype (repos: LocalRepo[]): void
reposLocalRepo[]voidget_nodetype (name: string): DependencyNode | undefined
namestringDependencyNode | undefinedget_dependentstype (name: string): Set<string>
namestringSet<string>get_dependenciestype (name: string): Map<string, DependencySpec>
namestringMap<string, DependencySpec>topological_sortComputes topological sort order for dependency graph.
Uses Kahn's algorithm with alphabetical ordering within tiers for deterministic results. Throws if cycles detected.
type (exclude_dev?: boolean): string[]
exclude_devif true, excludes dev dependencies to break cycles. Publishing uses exclude_dev=true to handle circular dev deps.
booleanfalsestring[]array of package names in dependency order (dependencies before dependents)
if - circular dependencies detected in included dependency typesdetect_cyclestype (): string[][]
string[][]detect_cycles_by_typeDetects circular dependencies, categorized by severity.
Production/peer cycles prevent publishing (impossible to order packages). Dev cycles are normal (test utils, shared configs) and safely ignored.
Uses DFS traversal with recursion stack to identify back edges. Deduplicates cycles using sorted cycle keys.
type (): { production_cycles: string[][]; dev_cycles: string[][]; }
{ production_cycles: string[][]; dev_cycles: string[][]; }object with production_cycles (errors) and dev_cycles (info)
toJSONtype (): DependencyGraphJson
dependency_graph.ts view source
Builder for creating and analyzing dependency graphs.
build_from_reposConstructs dependency graph from local repos.
Two-pass algorithm: first creates nodes, then builds edges (dependents). Prioritizes prod/peer deps over dev deps when same package appears in multiple dependency types (stronger constraint wins).
type (repos: LocalRepo[]): DependencyGraph
reposLocalRepo[]fully initialized dependency graph with all nodes and edges
compute_publishing_orderComputes publishing order using topological sort with dev deps excluded.
Excludes dev dependencies to break circular dev dependency cycles while preserving production/peer dependency ordering. This allows patterns like shared test utilities that depend on each other for development.
type (graph: DependencyGraph): string[]
graphstring[]package names in safe publishing order (dependencies before dependents)
if - production/peer cycles detected (cannot be resolved by exclusion)analyzetype (graph: DependencyGraph): { production_cycles: string[][]; dev_cycles: string[][]; wildcard_deps: { pkg: string; dep: string; version: string; }[]; missing_peers: { pkg: string; dep: string; }[]; }
graph{ production_cycles: string[][]; dev_cycles: string[][]; wildcard_deps: { pkg: string; dep: string; version: string; }[]; missing_peers: { pkg: string; dep: string; }[]; }dependency_graph.ts view source
DependencyGraphJson nodesArray<{
name: string;
version: string;
dependencies: Array<{name: string; spec: DependencySpec}>;
dependents: Array<string>;
publishable: boolean;
}>edgesArray<{from: string; to: string}>dependency_graph.ts view source
DependencyNode namestringversionstringrepodependenciesMap<string, DependencySpec>dependentsSet<string>publishablebooleandependency_graph.ts view source
DependencySpec typeversionstringresolvedstringdependency_graph.ts view source
DependencyType