/** * Git Detection Utilities * * Shared utilities for detecting git configuration (main branch, remote origin). * Used by both init and doctor commands. */ /** * Find git repository root by walking up directory tree * * Searches for .git directory starting from startDir and walking up * to the root directory. Similar to how findConfigPath() works. * * This allows doctor and other commands to work correctly from any subdirectory * within a project, not just from the repository root. * * @param startDir Directory to start searching from (defaults to process.cwd()) * @returns Path to git repository root or null if not found * * @example * ```typescript * // From /repo/packages/cli * const gitRoot = findGitRoot(); * // Returns: /repo * * // From /not-a-repo * const gitRoot = findGitRoot(); * // Returns: null * ``` */ export declare function findGitRoot(startDir?: string): string | null; /** * Result of git configuration detection */ export interface DetectedGitConfig { /** The detected or default main branch name (e.g., 'main', 'master', 'develop') */ mainBranch: string; /** The detected or default remote origin name (e.g., 'origin', 'upstream') */ remoteOrigin: string; /** Whether git configuration was successfully detected (false means defaults were used) */ detected: boolean; } export declare function detectGitConfig(): DetectedGitConfig; /** * Resolve path relative to git repository root * * DRY helper for commands that need to find files at git root. * Automatically handles git root detection and path joining. * * @param relativePath - Path relative to git root (e.g., '.github/workflows/validate.yml') * @param startDir - Directory to start searching from (defaults to process.cwd()) * @returns Absolute path or null if not in git repository * * @example * ```typescript * const workflowPath = resolveProjectPath('.github/workflows/validate.yml'); * if (workflowPath && existsSync(workflowPath)) { * // File exists at git root * } * ``` */ export declare function resolveProjectPath(relativePath: string, startDir?: string): string | null; /** * Check if file exists relative to git repository root * * DRY helper that combines git root detection with file existence check. * Useful for commands that need to verify files exist at project root. * * @param relativePath - Path relative to git root * @param startDir - Directory to start searching from (defaults to process.cwd()) * @returns true if file exists, false otherwise (including not in git repo) * * @example * ```typescript * if (projectFileExists('.github/workflows/validate.yml')) { * // Workflow file exists at git root * } * ``` */ export declare function projectFileExists(relativePath: string, startDir?: string): boolean; /** * Read file relative to git repository root * * DRY helper that combines git root detection with file reading. * Useful for commands that need to read config/workflow files at project root. * * @param relativePath - Path relative to git root * @param encoding - File encoding (defaults to 'utf8') * @param startDir - Directory to start searching from (defaults to process.cwd()) * @returns File contents or null if not found or not in git repository * * @example * ```typescript * const workflowContent = readProjectFile('.github/workflows/validate.yml'); * if (workflowContent) { * // Process workflow file * } * ``` */ export declare function readProjectFile(relativePath: string, encoding?: BufferEncoding, startDir?: string): string | null; //# sourceMappingURL=git-detection.d.ts.map