/** * Configuration pattern information. */ interface ConfigPatternInfo { /** File patterns to match */ patterns: string[]; /** Primary format (optional - auto-detected from file extension if not provided) */ format?: 'json' | 'jsonc' | 'yaml' | 'js' | 'ts' | 'ini' | 'dotenv' | 'text'; /** Human-readable description */ description: string; /** Whether config can extend others */ canExtend?: boolean; /** Whether file may contain secrets */ sensitive?: boolean; } /** * Configuration type identifier. */ type ConfigType = 'package.json' | 'package-lock.json' | 'pnpm-lock.yaml' | 'yarn.lock' | '.npmrc' | 'tsconfig' | 'nx' | 'project.json' | 'workspace.json' | 'turbo' | 'lerna' | 'webpack' | 'rollup' | 'vite' | 'esbuild' | 'babel' | 'swc' | 'jest' | 'vitest' | 'cypress' | 'playwright' | 'next' | 'angular' | 'nuxt' | 'svelte' | 'astro' | 'eslint' | 'prettier' | 'env' | '.gitignore' | '.gitattributes'; /** * Known configuration file patterns organized by type. */ declare const CONFIG_PATTERNS: Record; /** * Get patterns for specific config types. * * @param types - Array of config types to get patterns for * @returns Array of file patterns * * @example Retrieving config patterns by type * ```typescript * import { getConfigPatternsByType } from '@hyperfrontend/project-scope' * * const patterns = getConfigPatternsByType(['typescript', 'eslint']) * // => ['tsconfig.json', 'tsconfig.*.json', '.eslintrc', '.eslintrc.js', ...] * ``` */ declare function getConfigPatternsByType(types: ConfigType[]): string[]; /** * Detected configuration file. */ interface DetectedConfig { /** Config type */ type: ConfigType; /** File path (relative to root) */ path: string; /** Pattern that matched */ matchedPattern: string; /** Pattern info */ info: ConfigPatternInfo; } /** * Options for config detection. */ interface DetectConfigOptions { /** Maximum depth for recursive search */ maxDepth?: number; /** Include hidden directories */ includeHidden?: boolean; /** Skip cache lookup (force fresh detection) */ skipCache?: boolean; } /** * Detect all configuration files in a directory. * * Results are cached for 30 seconds per project path and options * to avoid redundant file system operations on repeated calls. * * @param rootPath - Project root directory * @param types - Optional array of config types to check (defaults to all) * @param options - Detection options * @returns Array of detected configuration files * * @example Detecting configuration files * ```typescript * import { detectConfigs } from '@hyperfrontend/project-scope' * * // Detect all config files * const configs = detectConfigs('./my-project') * for (const config of configs) { * console.log(`${config.type}: ${config.path}`) * } * // Output: * // typescript: tsconfig.json * // eslint: eslint.config.js * // jest: jest.config.ts * * // Detect specific config types only * const tsConfigs = detectConfigs('./my-project', ['typescript', 'eslint']) * ``` */ declare function detectConfigs(rootPath: string, types?: ConfigType[], options?: DetectConfigOptions): DetectedConfig[]; /** * Clear the config detection cache. * * Useful for testing or when the project files have changed. * * @example Clearing the config detection cache * ```typescript * import { clearConfigDetectionCache } from '@hyperfrontend/project-scope' * * // Reset cache after modifying config files * clearConfigDetectionCache() * ``` */ declare function clearConfigDetectionCache(): void; /** * Find a specific configuration file. * * @param rootPath - Project root directory * @param type - Config type to find * @returns Full path to config file or null if not found * * @example Finding a specific config file * ```typescript * import { findConfigFile } from '@hyperfrontend/project-scope' * * const tsConfig = findConfigFile('/project', 'typescript') * // => '/project/tsconfig.json' * * const eslint = findConfigFile('/project', 'eslint') * // => '/project/.eslintrc.js' or null if not found * ``` */ declare function findConfigFile(rootPath: string, type: ConfigType): string | null; /** * Result of parsing a configuration file. */ interface ParsedConfig { /** Config type */ type: ConfigType | 'unknown'; /** Source file path */ path: string; /** File format */ format: string; /** Parsed data (for JSON/YAML formats) */ data?: Record; /** Raw content (for text formats or JS/TS configs) */ raw?: string; /** Extended config paths (if any) */ extends?: string[]; } /** * Parse JSON configuration file. * * @param filePath - Path to the JSON configuration file * @param content - Raw file content to parse * @param type - Category of configuration (e.g., typescript, eslint) * @param format - Whether to strip comments (jsonc) or parse strictly (json) * @returns Configuration object with parsed data and extends references * * @example Parsing JSON configuration * ```typescript * import { parseJsonConfig } from '@hyperfrontend/project-scope' * * const config = parseJsonConfig( * 'tsconfig.json', * '{ "extends": "./base.json", "compilerOptions": {} }', * 'typescript' * ) * // => { type: 'typescript', path: 'tsconfig.json', data: {...}, extends: ['./base.json'] } * ``` */ declare function parseJsonConfig(filePath: string, content: string, type?: ConfigType, format?: 'json' | 'jsonc'): ParsedConfig; /** * Parse YAML configuration file. * * @param filePath - Path to the YAML configuration file * @param content - Raw file content to parse * @param type - Category of configuration (e.g., github-actions, docker-compose) * @returns Configuration object with parsed YAML data * * @example Parsing YAML configuration * ```typescript * import { parseYamlConfig } from '@hyperfrontend/project-scope' * * const config = parseYamlConfig('.github/workflows/ci.yml', yamlContent, 'github-actions') * // => { type: 'github-actions', path: '...', format: 'yaml', data: {...} } * ``` */ declare function parseYamlConfig(filePath: string, content: string, type?: ConfigType): ParsedConfig; /** * Parse configuration file. * * @param filePath - Path to config file * @param type - Optional config type (auto-detected if not provided) * @returns Parsed configuration * * @example Parsing a configuration file * ```typescript * import { parseConfig } from '@hyperfrontend/project-scope' * * const tsConfig = parseConfig('/project/tsconfig.json') * const eslintConfig = parseConfig('/project/.eslintrc.yml', 'eslint') * ``` */ declare function parseConfig(filePath: string, type?: ConfigType): ParsedConfig; export { CONFIG_PATTERNS, clearConfigDetectionCache, detectConfigs, findConfigFile, getConfigPatternsByType, parseConfig, parseJsonConfig, parseYamlConfig }; export type { ConfigPatternInfo, ConfigType, DetectConfigOptions, DetectedConfig, ParsedConfig };