/** * GitHub Repository Cloning * * Handles fetching and cloning GitHub repositories during init. * Cloning runs in background (non-blocking) via job manager. * * Provides parity with ADO multi-repo cloning: * - Fetches repos from GitHub org via API * - Filters by user-selected pattern (all/glob/regex) * - Creates background clone jobs * - Tracks progress via sw:jobs * * @module cli/helpers/init/github-repo-cloning */ import { type ClonePatternResult } from '../selection-strategy.js'; /** * GitHub repository selection (from init flow) */ export interface GitHubRepoSelection { /** GitHub organization or owner */ org: string; /** Personal Access Token */ pat: string; } /** * Repository info from GitHub API * * @see https://docs.github.com/en/rest/repos/repos#list-repositories-for-the-authenticated-user */ interface GitHubRepository { id: number; name: string; full_name: string; clone_url: string; html_url: string; owner: { login: string; }; /** Whether the repository is archived (read-only, may be stale) */ archived: boolean; /** Whether the repository is a fork of another repo */ fork: boolean; /** Whether the repository is private */ private: boolean; /** Visibility: public, private, or internal (GitHub Enterprise) */ visibility?: string; } /** * Rate limit info from GitHub API headers */ interface RateLimitInfo { remaining: number; limit: number; reset: Date; } /** * Fetch result with repos and rate limit info */ interface FetchResult { repos: GitHubRepository[]; rateLimit?: RateLimitInfo; partial: boolean; error?: string; } /** * Fetch repositories from GitHub organization with pagination and rate limit handling * * @param org - GitHub organization or owner * @param pat - Personal Access Token * @param maxRepos - Maximum repos to fetch (default 1000, configurable via REPO_FETCH_LIMITS) * @returns Fetch result with repos and metadata */ export declare function fetchGitHubRepos(org: string, pat: string, maxRepos?: number): Promise; /** * Result of GitHub repo cloning trigger */ export interface GitHubCloningResult { /** Job ID for tracking background clone */ jobId?: string; /** List of repo names being cloned (for 1:1 project mapping) */ clonedRepos: string[]; } /** * Build clone URL based on user's URL format preference * * @param owner - Repository owner (org or user) * @param repo - Repository name * @param pat - Personal Access Token (only used for HTTPS) * @param gitUrlFormat - User's preference: 'ssh' or 'https' * @returns Clone URL in the requested format */ export declare function buildGitHubCloneUrl(owner: string, repo: string, pat: string, gitUrlFormat?: 'ssh' | 'https'): string; /** * Trigger GitHub repository cloning during init * * This function: * 1. Fetches repository list from GitHub organization * 2. Filters repositories by clone pattern (glob/regex) * 3. Creates a background job for cloning * 4. Starts cloning asynchronously (non-blocking) * * @param projectPath - Target directory for cloning * @param githubRepoSelection - GitHub org and PAT * @param clonePattern - Clone pattern configuration * @param gitUrlFormat - Git URL format preference ('ssh' or 'https') - v1.0.10+ * @param excludeRepos - Repo names to exclude from cloning (e.g., umbrella repo already cloned at root) * @returns Cloning result with job ID and list of repos being cloned (v1.0.9) */ export declare function triggerGitHubRepoCloning(projectPath: string, githubRepoSelection: GitHubRepoSelection, clonePattern: ClonePatternResult, gitUrlFormat?: 'ssh' | 'https', excludeRepos?: string[]): Promise; /** * Options for cloning a single GitHub repository */ export interface SingleRepoCloneOptions { /** Raw repo identifier (any format: owner/repo, URL, SSH) */ repoIdentifier: string; /** Project root path */ projectPath: string; /** GitHub PAT (optional for SSH) */ pat?: string; /** Dry-run mode — validate only, don't clone */ dryRun?: boolean; } /** * Result of a single repo clone operation */ export interface SingleRepoCloneResult { /** Whether the clone job was launched */ cloned: boolean; /** Job ID if clone was launched */ jobId?: string; /** Whether repo was already cloned locally */ alreadyCloned?: boolean; /** Parsed owner */ owner?: string; /** Parsed repo name */ repo?: string; /** Error message if failed */ error?: string; } /** * Clone a single GitHub repository into the umbrella workspace. * * Validates the repo exists, checks for local duplicates, then * launches a background clone job via existing infrastructure. * * @param options - Clone options including repo identifier and project path * @returns Result with clone status, job ID, or error */ export declare function cloneSingleGitHubRepo(options: SingleRepoCloneOptions): Promise; export {}; //# sourceMappingURL=github-repo-cloning.d.ts.map