/** * Files indicating project root. */ declare const ROOT_MARKERS: readonly ["package.json", ".git"]; /** * Files indicating workspace/monorepo root. */ declare const WORKSPACE_MARKERS: readonly ["nx.json", "turbo.json", "lerna.json", "pnpm-workspace.yaml", "rush.json"]; /** * Find the project root from a starting path. * Project root is the nearest directory containing package.json * with source files. * * @param startPath - Starting path * @returns Project root path or null * * @example Finding project root * ```typescript * import { findProjectRoot } from '@hyperfrontend/project-scope' * * // Find project root from current directory * const root = findProjectRoot(process.cwd()) * if (root) { * console.log('Project root:', root) * } * * // Find root from a deeply nested file * const root2 = findProjectRoot('./libs/my-lib/src/utils/helper.ts') * ``` */ declare function findProjectRoot(startPath: string): string | null; /** * Find workspace root (monorepo root). * Searches up for workspace markers like nx.json, turbo.json, etc. * * @param startPath - Starting path * @returns Workspace root path or null * * @example Finding workspace root * ```typescript * import { findWorkspaceRoot } from '@hyperfrontend/project-scope' * * const root = findWorkspaceRoot('./libs/my-lib') * if (root) { * console.log('Monorepo root:', root) // e.g., '/home/user/my-monorepo' * } * ``` */ declare function findWorkspaceRoot(startPath: string): string | null; /** * Generic root finder - walk up looking for any marker file. * * @param startPath - Starting path * @param markers - Files to search for * @returns Root directory path or null * * @example Finding root by marker files * ```typescript * import { findRootDirectory } from '@hyperfrontend/project-scope' * * // Find monorepo root by looking for nx.json or lerna.json * const root = findRootDirectory('./libs/my-lib', ['nx.json', 'lerna.json']) * // => '/path/to/monorepo' * ``` */ declare function findRootDirectory(startPath: string, markers: readonly string[] | string[]): string | null; /** * Find nearest .git directory (repo root). * * @param startPath - Starting path * @returns Git root path or null * * @example Finding Git repository root * ```typescript * import { findGitRoot } from '@hyperfrontend/project-scope' * * const gitRoot = findGitRoot('./src/deep/nested/file.ts') * // => '/path/to/repository' * ``` */ declare function findGitRoot(startPath: string): string | null; export { ROOT_MARKERS, WORKSPACE_MARKERS, findGitRoot, findProjectRoot, findRootDirectory, findWorkspaceRoot };