import { Result, TaggedErrorClass } from "better-result"; //#region src/args.d.ts /** * @module args * * CLI argument parsing. Converts raw `process.argv` strings into a typed * {@link ParsedArgs} object, handling boolean flags, short aliases, and * positional repo paths. */ /** * Represents the fully parsed CLI arguments. * * @property {string | undefined} browser - Override the auto-detected browser for opening PR URLs. * @property {string | undefined} configPath - Explicit path to a config file, overriding default search. * @property {boolean} dryRun - When `true`, prints what would happen without making changes. * @property {boolean} help - When `true`, prints usage information and exits. * @property {boolean} minor - When `true`, restricts dependency updates to the current minor range. * @property {boolean} noChangeset - When `true`, skips changeset file generation after updates. * @property {boolean} noWorkspaces - When `true`, skips workspace-aware update logic. * @property {string[]} positional - Remaining non-flag arguments, interpreted as repo paths. */ interface ParsedArgs { browser: string | undefined; configPath: string | undefined; dryRun: boolean; help: boolean; minor: boolean; noChangeset: boolean; noWorkspaces: boolean; positional: string[]; } //#endregion //#region src/errors.d.ts /** * Error thrown when a spawned child process exits with a non-zero code. * * @property {string} message - Human-readable error description. * @property {string} command - The full command string that was executed. * @property {string} stderr - Captured standard error output from the failed process. */ declare const CommandFailedError: TaggedErrorClass<"CommandFailedError", { message: string; command: string; stderr: string; }>; /** Instance type for {@link CommandFailedError}. */ type CommandFailedError = InstanceType; /** * Error thrown when user-supplied input (CLI flags, config values) fails validation. * * @property {string} message - Human-readable error description. */ declare const InvalidInputError: TaggedErrorClass<"InvalidInputError", { message: string; }>; /** Instance type for {@link InvalidInputError}. */ type InvalidInputError = InstanceType; //#endregion //#region src/config.d.ts /** * User configuration loaded from `repo-updater.config.json`. * * @property {string | undefined} browser - Preferred browser for opening PR URLs (auto-detected if omitted). * @property {string[]} repos - List of local filesystem paths to Git repositories to update. */ interface Config { browser?: string; repos: string[]; } //#endregion //#region src/runner.d.ts /** * Captures the output of a spawned child process. * * @property {string} stdout - Standard output captured as a string. * @property {string} stderr - Standard error captured as a string. */ interface ExecOutput { stderr: string; stdout: string; } /** * Describes the result of processing a single repository. * * @property {string} repo - The repository path that was processed. * @property {string | undefined} prUrl - The URL of the created pull request, if applicable. * @property {"pr-created" | "no-changes"} status - Whether a PR was created or no changes were detected. */ interface RepoResult { prUrl?: string; repo: string; status: "pr-created" | "no-changes"; } /** * Executes a command, automatically selecting Bun or Node.js based on the * current runtime. * * @param cmd - The command and arguments to execute. * @param cwd - The working directory for the command. * @returns `Ok` with the captured {@link ExecOutput}, or `Err` with a * {@link CommandFailedError} if the process exits non-zero. */ declare const exec: (cmd: string[], cwd: string) => Promise>; /** * Performs a full dependency update cycle on a single repository. * * Clones the target branch from the default branch, runs the package manager * update command, installs dependencies, commits changes, pushes, and creates * a pull request via `gh pr create`. Supports changeset generation and * workspace-aware updates when enabled. * * @param options - Repository path, date, flags, and optional overrides. * @param options.repo - Repository filesystem path. * @param options.date - Date string in `YYYY-MM-DD` format (used in branch name and PR title). * @param options.dryRun - When `true`, prints the steps without executing them. * @param options.minor - When `true`, restricts updates to the current minor range. * @param options.noChangeset - When `true`, skips changeset file generation. * @param options.noWorkspaces - When `true`, disables workspace detection. * @param execFn - Optional command executor (defaults to {@link exec}). * Useful for testing or custom runtime environments. * @returns `Ok` with the {@link RepoResult}, or `Err` with a * {@link CommandFailedError} if any step fails. On failure the branch * is cleaned up automatically. * * @example * ```ts * const result = await updateRepo({ * repo: "./my-repo", * date: "2026-03-30", * dryRun: false, * minor: true, * }); * if (result.isOk()) console.log("PR:", result.value.prUrl); * ``` */ declare const updateRepo: (options: { repo: string; date: string; dryRun: boolean; minor?: boolean; noChangeset?: boolean; noWorkspaces?: boolean; }, execFn?: typeof exec) => Promise>; //#endregion //#region src/index.d.ts /** * Prints CLI usage information and available flags to standard output. */ declare const printUsage: () => void; /** * Resolves the list of repository paths from CLI arguments and configuration. * * If positional arguments are provided, they are used directly. Otherwise, * falls back to the `repos` array from the configuration file. * * @param args - The parsed CLI arguments. * @returns An object with `repos` and optional `config`, or `null` if * no config was found and no positional arguments were given. */ declare const resolveRepos: (args: ParsedArgs) => { repos: string[]; config?: Config; } | null; /** * Processes a single repository for dependency updates. * * Handles both dry-run and live modes. In live mode, delegates to * {@link updateRepo} (or a custom `updateFn`). Collects PR URLs for * later display. * * @param repo - Filesystem path to the repository. * @param date - Date string for branch naming (from {@link getDate}). * @param dryRun - When `true`, only simulates the update. * @param updateFn - Optional custom update function (defaults to {@link updateRepo}). * @param minor - When `true`, restricts updates to the current minor range. * @param noChangeset - When `true`, skips changeset generation. * @param noWorkspaces - When `true`, skips workspace-aware updates. * @returns A result object with `repo`, `status`, and optional `prUrl`. */ declare const processRepo: (repo: string, date: string, dryRun: boolean, updateFn?: typeof updateRepo, minor?: boolean, noChangeset?: boolean, noWorkspaces?: boolean) => Promise<{ repo: string; status: "pr-created" | "no-changes" | "failed"; prUrl?: string; }>; /** * Opens a URL using Bun's native `Bun.spawn` (fire-and-forget, the * returned subprocess is not awaited). * * @param cmd - The browser command and arguments. */ declare const openURLBun: (cmd: string[]) => void; /** * Opens a URL using Bun's native `Bun.spawnSync`. * * @param cmd - The browser command and arguments. */ declare const openURLBunSync: (cmd: string[]) => number | null; /** * Opens a URL using Node.js `child_process.spawn` with `stdio: "ignore"`. * * @param cmd - The browser command and arguments. */ declare const openURLNodejs: (cmd: string[]) => Promise; /** * Function signature for executing shell commands. * * @param cmd - The command and arguments to execute. * @param cwd - The working directory for the command. * @returns A promise resolving to the command's captured output. */ type ExecFn = (cmd: string[], cwd: string) => Promise<{ stdout: string; stderr: string; exitCode: number; }>; /** * Detects the default browser for the current operating system. * * Uses platform-specific detection: reads `LSHandlerURLScheme` defaults on * macOS, queries the Windows registry for HTTP handler prog IDs on Windows, * and checks `xdg-settings` on Linux. * * @param platform - The OS platform (defaults to `process.platform`). * @param execFn - Optional command executor for testing. * @returns The detected browser command name, or `null` if detection fails. */ declare const detectBrowser: (platform?: string, execFn?: ExecFn) => Promise<{ browser: string; path?: string; } | null>; /** * Opens one or more URLs in the system browser. * * Builds platform-appropriate open commands (macOS `open`, Windows `start`, * Linux `xdg-open`) and executes them sequentially. * * @param urls - Array of URLs to open. * @param platform - The OS platform (defaults to `process.platform`). * @param execFn - Optional command executor for testing. * @param browserOverride - Override the auto-detected browser. */ declare const openURLs: (urls: string[], platform?: string, execFn?: ExecFn, browserOverride?: string) => Promise; /** * Main entry point for repo-updater. * * Parses CLI arguments, loads configuration, validates repositories, and * processes each repository for dependency updates. Supports interactive * browser selection, dry-run mode, and automatic PR URL opening. * * @param argv - Raw CLI arguments (defaults to `process.argv.slice(2)`). * @param updateFn - Optional custom update function for testing or programmatic use. * * @example * ```ts * // Run with default arguments * await main(); * * // Run with custom arguments and updater * await main(["--dry-run", "./my-repo"], myUpdateFn); * ``` */ declare const main: (argv?: string[], updateFn?: typeof updateRepo) => Promise; //#endregion export { ExecFn, detectBrowser, main, openURLBun, openURLBunSync, openURLNodejs, openURLs, printUsage, processRepo, resolveRepos };