dependency_graph.ts view source
{ readonly PROD: "prod"; readonly PEER: "peer"; readonly DEV: "dev"; } import {DEPENDENCY_TYPE} from '@fuzdev/fuz_repos/dependency_graph.js'; Dependency graph data structure and algorithms for multi-repo publishing.
Provides the DependencyGraph class, built from local repos, with topological sort
(via @fuzdev/fuz_util/sort.ts), cycle detection by dependency type, and
wildcard-range analysis.
For the publishing order and the analysis workflow, see graph_validation.ts.
7 declarations
dependency_graph.ts view source
{ readonly PROD: "prod"; readonly PEER: "peer"; readonly DEV: "dev"; } import {DEPENDENCY_TYPE} from '@fuzdev/fuz_repos/dependency_graph.js'; dependency_graph.ts view source
DependencyAnalysis import type {DependencyAnalysis} from '@fuzdev/fuz_repos/dependency_graph.js'; Cycles and wildcard dependencies found by DependencyGraph.analyze.
production_cyclestype string[][]
dev_cyclestype string[][]
wildcard_depstype { pkg: string; dep: string; version: string; }[]
dependency_graph.ts view source
import {DependencyGraph} from '@fuzdev/fuz_repos/dependency_graph.js'; nodestype Map<string, DependencyNode>
edgestype Map<string, Set<string>>
constructorBuilds the graph from local repos.
Two passes: first creates nodes, then builds edges (dependents). Prioritizes prod/peer deps over dev deps when the same package appears in multiple dependency types (the stronger constraint wins).
type new (repos: LocalRepo[]): DependencyGraph
reposLocalRepo[]get_nodetype (name: string): DependencyNode | undefined
namestringDependencyNode | undefinedtopological_sortComputes topological sort order for dependency graph.
Delegates to @fuzdev/fuz_util/sort.ts for the sorting algorithm.
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)
throws
Error - if circular dependencies detected in included dependency typesdetect_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)
analyzeReports cycles by type and wildcard (*) dependency ranges.
Tolerates cycles: it reports them rather than throwing.
type (): DependencyAnalysis
toJSONtype (): DependencyGraphJson
dependency_graph.ts view source
DependencyGraphJson import type {DependencyGraphJson} from '@fuzdev/fuz_repos/dependency_graph.js'; nodestype { name: string; version: string; dependencies: { name: string; spec: DependencySpec; }[]; dependents: string[]; }[]
edgestype { from: string; to: string; }[]
dependency_graph.ts view source
DependencyNode import type {DependencyNode} from '@fuzdev/fuz_repos/dependency_graph.js'; nametype string
versiontype string
dependenciestype Map<string, DependencySpec>
dependentstype Set<string>
dependency_graph.ts view source
DependencySpec import type {DependencySpec} from '@fuzdev/fuz_repos/dependency_graph.js'; typetype DependencyType
versiontype string
dependency_graph.ts view source
DependencyType type "prod" | "peer" | "dev"
import type {DependencyType} from '@fuzdev/fuz_repos/dependency_graph.js';