import { DependencyGraph } from '../../models'; /** * Circular dependency information. */ interface CircularDependency { /** Ordered list of files in cycle */ cycle: string[]; /** Cycle length */ length: number; } /** * Project dependencies categorized. */ interface ProjectDependencies { /** Production dependencies */ runtime: string[]; /** Development dependencies */ development: string[]; /** Peer dependencies */ peer: string[]; /** Optional dependencies */ optional: string[]; /** Total count */ total: number; } /** * Options for dependency graph building. */ interface BuildGraphOptions { /** Maximum depth to traverse */ maxDepth?: number; /** Include node_modules imports */ includeExternal?: boolean; /** File extensions to analyze */ extensions?: string[]; } /** * Build dependency graph from source files. * * Analyzes imports/exports in source files to build a graph of * internal dependencies. * * @param projectPath - Absolute path to project root * @param options - Configuration for graph building * @returns Dependency graph with nodes, roots, and leaves * * @example Building a dependency graph * ```typescript * import { buildDependencyGraph } from '@hyperfrontend/project-scope' * * const graph = buildDependencyGraph('./my-lib') * console.log('Root files:', graph.roots) // Files not imported by anything * console.log('Leaf files:', graph.leaves) // Files that don't import anything * console.log('Total nodes:', graph.nodes.size) * * // Examine a specific node's dependencies * const node = graph.nodes.get('src/utils/helper.ts') * console.log('Depends on:', node?.dependencies) * console.log('Used by:', node?.dependents) * ``` */ declare function buildDependencyGraph(projectPath: string, options?: BuildGraphOptions): DependencyGraph; /** * Find circular dependencies in graph using DFS. * * @param graph - Dependency graph * @returns Array of circular dependencies found * * @example Finding circular dependencies * ```typescript * import { buildDependencyGraph, findCircularDependencies } from '@hyperfrontend/project-scope' * * const graph = buildDependencyGraph('/workspace') * const cycles = findCircularDependencies(graph) * cycles.forEach(c => console.log(`Cycle: ${c.cycle.join(' -> ')}`)) * ``` */ declare function findCircularDependencies(graph: DependencyGraph): CircularDependency[]; /** * Collect all dependencies from package.json grouped by category. * * @param projectPath - Project directory * @returns Dependencies grouped by runtime, dev, peer, and optional * * @example Getting project dependencies * ```typescript * import { getProjectDependencies } from '@hyperfrontend/project-scope' * * const deps = getProjectDependencies('/path/to/project') * console.log('Runtime:', deps.runtime) // ['express', 'lodash'] * console.log('Dev:', deps.development) // ['jest', 'typescript'] * console.log('Total:', deps.total) // 15 * ``` */ declare function getProjectDependencies(projectPath: string): ProjectDependencies; export { buildDependencyGraph, findCircularDependencies, getProjectDependencies }; export type { BuildGraphOptions, CircularDependency, ProjectDependencies };