/** * Files indicating NX workspace root. */ declare const NX_CONFIG_FILES: readonly ["nx.json", "workspace.json"]; /** * NX-specific project file. */ declare const NX_PROJECT_FILE = "project.json"; /** * NX workspace layout configuration. */ interface NxWorkspaceLayout { /** Applications directory (default: 'apps') */ appsDir: string; /** Libraries directory (default: 'libs') */ libsDir: string; } /** * nx.json configuration structure. */ interface NxJson { /** Default project */ defaultProject?: string; /** Workspace layout */ workspaceLayout?: Partial; /** Named inputs for caching */ namedInputs?: Record; /** Target defaults */ targetDefaults?: Record; /** NX Cloud access token */ nxCloudAccessToken?: string; /** Plugins configuration */ plugins?: unknown[]; /** Task runner options */ tasksRunnerOptions?: Record; /** Default base */ defaultBase?: string; /** Additional properties */ [key: string]: unknown; } /** * NX workspace information. */ interface NxWorkspaceInfo { /** Workspace root path */ root: string; /** NX version from package.json */ version: string | null; /** Parsed nx.json */ nxJson: NxJson; /** Whether this is an integrated repo (vs standalone) */ isIntegrated: boolean; /** Default project name */ defaultProject?: string; /** Workspace layout configuration */ workspaceLayout: NxWorkspaceLayout; } /** * Check if directory is an NX workspace root. * * @param path - Directory path to check * @returns True if the directory contains nx.json or workspace.json * * @example Checking for NX workspace * ```typescript * import { isNxWorkspace } from '@hyperfrontend/project-scope' * * if (isNxWorkspace('./my-project')) { * console.log('This is an NX monorepo') * } * ``` */ declare function isNxWorkspace(path: string): boolean; /** * Check if directory is an NX project. * * @param path - Directory path to check * @returns True if the directory contains project.json * * @example Checking for NX project * ```typescript * import { isNxProject } from '@hyperfrontend/project-scope' * * if (isNxProject('./libs/my-lib')) { * console.log('This is an NX project') * } * ``` */ declare function isNxProject(path: string): boolean; /** * Find NX workspace root from any path. * * @param startPath - Starting path to search from * @returns Workspace root path or null if not found * * @example Finding NX workspace root * ```typescript * import { findNxWorkspaceRoot } from '@hyperfrontend/project-scope' * * const root = findNxWorkspaceRoot('./libs/my-lib/src') * if (root) { * console.log('Workspace root:', root) // e.g., '/home/user/my-monorepo' * } * ``` */ declare function findNxWorkspaceRoot(startPath: string): string | null; /** * Get comprehensive NX workspace information. * * @param workspacePath - Workspace root path * @returns Workspace info or null if not an NX workspace * * @example Getting NX workspace information * ```typescript * import { getNxWorkspaceInfo } from '@hyperfrontend/project-scope' * * const info = getNxWorkspaceInfo('/path/to/monorepo') * if (info) { * console.log('NX version:', info.version) * console.log('Apps dir:', info.workspaceLayout.appsDir) * } * ``` */ declare function getNxWorkspaceInfo(workspacePath: string): NxWorkspaceInfo | null; /** * Object form of an entry in `targets[*].dependsOn`: a target name plus the * project(s) it should be looked up in. */ interface NxTargetDependency { /** Target name to depend on */ target: string; /** Project(s) containing the target */ projects: string | string[]; } /** * NX target configuration. */ interface NxTargetConfig { /** Executor to run */ executor?: string; /** Target outputs */ outputs?: string[]; /** Target options */ options?: Record; /** Target configurations */ configurations?: Record>; /** Default configuration */ defaultConfiguration?: string; /** Depends on other targets */ dependsOn?: Array; /** Target inputs for caching */ inputs?: unknown[]; } /** * NX project configuration from project.json. */ interface NxProjectConfig { /** Project name */ name?: string; /** Project root path (relative to workspace root) */ root?: string; /** Source root path */ sourceRoot?: string; /** Project type */ projectType?: 'application' | 'library'; /** Project tags for filtering */ tags?: string[]; /** Implicit dependencies */ implicitDependencies?: string[]; /** Named inputs for caching */ namedInputs?: Record; /** Build targets */ targets?: Record; /** Generator defaults */ generators?: Record; /** Additional properties */ [key: string]: unknown; } /** * Simplified project graph node. */ interface NxProjectGraphNode { /** Project name */ name: string; /** Project type */ type: string; /** Project configuration */ data: NxProjectConfig; } /** * Simplified project dependency. */ interface NxProjectDependency { /** Target project name */ target: string; /** Dependency type */ type: 'implicit' | 'explicit' | 'static'; } /** * Simplified project graph. */ interface NxProjectGraph { /** Project nodes */ nodes: Record; /** Project dependencies */ dependencies: Record; } /** * Read project.json for an NX project. * * @param projectPath - Project directory path * @returns Parsed project.json or null if not found * * @example Reading NX project.json * ```typescript * import { readProjectJson } from '@hyperfrontend/project-scope' * * const config = readProjectJson('./libs/my-lib') * if (config) { * console.log('Project:', config.name, 'Type:', config.projectType) * } * ``` */ declare function readProjectJson(projectPath: string): NxProjectConfig | null; /** * Get project configuration from project.json or package.json nx field. * * @param projectPath - Project directory path * @param workspacePath - Workspace root path (for relative path calculation) * @returns Project configuration or null if not found * * @example Getting project configuration * ```typescript * import { getProjectConfig } from '@hyperfrontend/project-scope' * * const config = getProjectConfig('./libs/my-lib', '/workspace') * // => { name: 'my-lib', root: 'libs/my-lib', projectType: 'library' } * ``` */ declare function getProjectConfig(projectPath: string, workspacePath: string): NxProjectConfig | null; /** * Discover all NX projects in workspace. * Supports both workspace.json (older format) and project.json (newer format). * * @param workspacePath - Workspace root path * @returns Map of project name to configuration * * @example Discovering all NX projects * ```typescript * import { discoverNxProjects } from '@hyperfrontend/project-scope' * * const projects = discoverNxProjects('/workspace') * for (const [name, config] of projects) { * console.log(`${name}: ${config.projectType} at ${config.root}`) * } * ``` */ declare function discoverNxProjects(workspacePath: string): Map; /** * Build a simple project graph from discovered projects. * * @param workspacePath - Workspace root path * @param projects - Existing configuration map to skip auto-discovery * @returns NxProjectGraph with nodes and dependencies * * @example Building a simple project graph * ```typescript * import { buildSimpleProjectGraph } from '@hyperfrontend/project-scope' * * const graph = buildSimpleProjectGraph('/workspace') * console.log('Projects:', Object.keys(graph.nodes)) * console.log('Dependencies:', graph.dependencies['my-app']) * ``` */ declare function buildSimpleProjectGraph(workspacePath: string, projects?: Map): NxProjectGraph; export { NX_CONFIG_FILES, NX_PROJECT_FILE, buildSimpleProjectGraph, discoverNxProjects, findNxWorkspaceRoot, getNxWorkspaceInfo, getProjectConfig, isNxProject, isNxWorkspace, readProjectJson }; export type { NxJson, NxProjectConfig, NxProjectDependency, NxProjectGraph, NxProjectGraphNode, NxTargetConfig, NxWorkspaceInfo, NxWorkspaceLayout };