import { cancel, isCancel, log as clackLog, note as clackNote, spinner as clackSpinner, tasks as clackTasks } from "@clack/prompts"; import { CAC, Command } from "cac"; //#region src/cli-kit/errors.d.ts /** * Errors and error formatting shared by all Pagesmith CLIs. * * `CliError` is preferred over plain `Error` when you want to control the * process exit code or attach a follow-up "hint" line for the user. `formatCliError` * walks the `cause` chain so deeply-wrapped errors still surface readable lines. */ declare class CliError extends Error { readonly exitCode: number; readonly hint?: string; constructor(message: string, options?: { exitCode?: number; hint?: string; cause?: unknown; }); } declare function formatCliError(error: unknown): string; declare function exitCodeFor(error: unknown): number; //#endregion //#region src/cli-kit/modes.d.ts /** * Interactive vs non-interactive mode resolution shared by all Pagesmith CLIs. * * Precedence (highest first): * 1. `--yes` / `--non-interactive` flags force non-interactive mode. * 2. `--interactive` flag forces interactive mode (errors when no TTY is * attached so the user does not get a silently-hung prompt). * 3. Environment auto-detection: `CI`, `PAGESMITH_NON_INTERACTIVE`, and * whether `process.stdin`/`process.stdout` are TTYs. * * Every Pagesmith CLI honors the same env vars and flag spelling so CI/CD * pipelines have one knob to flip. */ type InteractivityFlags = { yes?: boolean; nonInteractive?: boolean; interactive?: boolean; }; type InteractivityResolution = { interactive: boolean; /** Human-readable reason to print/log when running non-interactively. */ reason: string; }; declare function isNonInteractiveEnv(): boolean; declare function isInteractive(): boolean; declare function resolveInteractive(flags?: InteractivityFlags): InteractivityResolution; type AssertValueOptions = { /** Human label for the value (e.g. `"project name"`). */label: string; /** Flag the user can pass on the CLI to satisfy this requirement. */ flag: string; /** Optional config key the user can set (e.g. `"name"` or `"cli.core.template"`). */ configKey?: string; /** Optional environment variable that can also satisfy the requirement. */ envVar?: string; }; /** * Throws a `CliError` when a required value is missing in non-interactive mode. * Passes the value through unchanged in the success path so callers can use it * inline: `const name = assertValue(args.name, { ... })`. */ declare function assertValue(value: T | undefined | null, opts: AssertValueOptions): T; //#endregion //#region src/cli-kit/prompts.d.ts declare function intro(message: string): void; declare function outro(message: string): void; type TextPromptOptions = { message: string; placeholder?: string; defaultValue?: string; validate?: (value: string | undefined) => string | Error | undefined; }; declare function promptText(options: TextPromptOptions): Promise; type ConfirmPromptOptions = { message: string; initialValue?: boolean; }; declare function promptConfirm(options: ConfirmPromptOptions): Promise; type SelectOption = { value: T; label?: string; hint?: string; }; type SelectPromptOptions = { message: string; options: Array>; initialValue?: T; }; declare function promptSelect(options: SelectPromptOptions): Promise; type MultiselectPromptOptions = { message: string; options: Array>; initialValues?: T[]; required?: boolean; }; declare function promptMultiselect(options: MultiselectPromptOptions): Promise; /** * Sequential prompt group. The provided record is passed straight through to * clack's `group()`; we only keep the cancel-handling policy consistent by * intercepting cancel results in the typed wrappers above. */ declare const group: (prompts: import("@clack/prompts").PromptGroup, opts?: import("@clack/prompts").PromptGroupOptions) => Promise<{ [P in keyof import("@clack/prompts").PromptGroupAwaitedReturn]: import("@clack/prompts").PromptGroupAwaitedReturn[P] }>; //#endregion //#region src/cli-kit/parse.d.ts type DefineCliOptions = { /** Binary name shown in help (e.g. `"pagesmith-docs"`). */name: string; /** Package version printed by `--version`. */ version: string; /** * Optional descriptive line appended before help. Most CLIs leave this * blank because cac's auto-generated help is already verbose. */ description?: string; }; type RunCliOptions = { /** argv slice to parse. Defaults to `process.argv.slice(2)`. */argv?: string[]; /** * When `true`, do not call `process.exit`; instead let any thrown error * bubble out so callers can handle it (used by tests). */ rethrow?: boolean; }; type CliInstance = { cli: CAC; /** Register `--config ` and the standard interactivity flags on a command. */ withInteractivityFlags(command: Command): Command; withConfigFlag(command: Command): Command; /** Parse argv and dispatch to the registered handlers. */ run(options?: RunCliOptions): Promise; }; /** * Adds the standard `--yes`, `--non-interactive`/`--no-interactive`, and * `--interactive` flags to a cac command. Centralizing the spelling here keeps * every Pagesmith CLI in lockstep — see `cli-kit/modes.ts` for how they're * resolved. */ declare function withInteractivityFlags(command: Command): Command; declare function withConfigFlag(command: Command): Command; declare function defineCli(options: DefineCliOptions): CliInstance; //#endregion //#region src/cli-kit/load-config.d.ts /** * Unified Pagesmith config loader. * * Resolves and reads `pagesmith.config.{ts,mts,js,mjs,json5,json}` (in that * order of preference). Each Pagesmith CLI uses this to: * - Locate a config without forcing the user to pass `--config`. * - Seed prompt defaults during interactive flows. * - Pass a normalized config path/object to the underlying preset/resolver. * * The loader returns a loose `Record` so the calling package * can narrow with its own zod schema (`DocsConfigSchema`, `SiteUserConfigSchema`, * etc.) — keeping cli-kit free of package-specific shapes. */ type PagesmithConfigFormat = "ts" | "mts" | "js" | "mjs" | "json5" | "json"; declare const PAGESMITH_CONFIG_BASENAMES: readonly ["pagesmith.config.ts", "pagesmith.config.mts", "pagesmith.config.mjs", "pagesmith.config.js", "pagesmith.config.json5", "pagesmith.config.json"]; type PagesmithConfigFile = { /** Absolute path to the resolved config file, or `undefined` if none was found. */configPath?: string; /** File extension without the leading dot. */ format?: PagesmithConfigFormat; /** Raw config object, or `undefined` if no config file was found. */ config?: Record; }; type FindConfigOptions = { /** Base directory used to resolve relative paths. Defaults to `process.cwd()`. */cwd?: string; /** * Explicit user-supplied path (e.g. `--config ./my.config.ts`). When set, * this is the only candidate considered. */ explicitPath?: string; }; declare function findPagesmithConfig(options?: FindConfigOptions): { configPath?: string; format?: PagesmithConfigFormat; }; declare function readPagesmithConfig(configPath: string, format?: PagesmithConfigFormat): Promise>; /** * Find and load the closest Pagesmith config. Returns an empty object when no * config is found so callers can treat the result as "use defaults". When the * config file exists but cannot be parsed/imported, throws a `CliError` with a * helpful hint. */ declare function loadPagesmithConfig(options?: FindConfigOptions): Promise; //#endregion //#region src/cli-kit/version.d.ts /** * Helper to read a CLI's version string from its sibling `package.json`. * Used by every Pagesmith CLI's `bin.ts` to wire up `cac.version()`. */ /** * Read the `version` field from a package.json located relative to the calling * module. Pass `import.meta.dirname` from the caller as the `dirname` argument. * * @param dirname Directory of the calling module (typically `import.meta.dirname`). * @param relativePath Relative path from `dirname` to the package.json (default: `'../../package.json'`). */ declare function readPackageVersion(dirname: string, relativePath?: string): string; //#endregion export { type AssertValueOptions, CliError, type CliInstance, type ConfirmPromptOptions, type DefineCliOptions, type FindConfigOptions, type InteractivityFlags, type InteractivityResolution, type MultiselectPromptOptions, PAGESMITH_CONFIG_BASENAMES, type PagesmithConfigFile, type PagesmithConfigFormat, type RunCliOptions, type SelectOption, type SelectPromptOptions, type TextPromptOptions, assertValue, cancel, defineCli, exitCodeFor, findPagesmithConfig, formatCliError, group, intro, isCancel, isInteractive, isNonInteractiveEnv, loadPagesmithConfig, clackLog as log, clackNote as note, outro, promptConfirm, promptMultiselect, promptSelect, promptText, readPackageVersion, readPagesmithConfig, resolveInteractive, clackSpinner as spinner, clackTasks as tasks, withConfigFlag, withInteractivityFlags }; //# sourceMappingURL=index.d.mts.map