import { l as HostCredentials, o as CredentialHost, r as ViteHubCliContext, s as CredentialSource, t as ViteHubCliCommand, u as HostCredentialsDescription } from "../provision-bhi-xnCG.js"; //#region ../internal/dist/config-edit.d.ts //#region src/config-edit.d.ts type JsonValue = null | boolean | number | string | readonly JsonValue[] | { readonly [key: string]: JsonValue; }; type ConfigForm = "vite-call" | "nuxt-module-tuple" | "nuxt-config-key"; type ManualReason = "parse-error" | "no-vitehub" | "multiple-vitehub" | "dynamic-options" | "spread" | "computed-key"; type ConfigValue = { kind: "literal"; value: JsonValue; } | { kind: "expression"; source: string; line: number; }; interface ViteHubConfigSite { form: ConfigForm; /** Byte range of the options object. Absent when the call or tuple has no options. */ options?: { start: number; end: number; }; keys: Readonly>; /** True when a spread can supply keys that are not in `keys`. */ spread: boolean; /** Top-level Nuxt options used to locate server discovery directories. */ nuxt?: { keys: Readonly>; spread: boolean; }; } type LocateResult = { ok: true; site: ViteHubConfigSite; } | { ok: false; reason: ManualReason; line?: number; }; //#endregion //#region ../internal/dist/deployment.d.ts //#region src/deployment.d.ts /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */ type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel"; type DeploymentService = "blob" | "browser" | "queue" | "rateLimit" | "realtime" | "sandbox"; //#endregion //#region ../internal/dist/features.d.ts //#region src/features.d.ts /** * The feature keys of `vitehub({...})`. `vitehub add ` and `vitehub status` read this list before the owner * package of a feature is installed, so the catalog is plain data with no owner imports. */ declare const featureIds: readonly ["agent", "auth", "blob", "browser", "cache", "channels", "comments", "connections", "console", "database", "email", "env", "i18n", "kv", "mcp", "observability", "queue", "rateLimit", "realtime", "sandboxTask", "schedule", "workflow", "workspace"]; type FeatureId = (typeof featureIds)[number]; /** `dev` stores default Node development support. Use `featureSupport()` with the configured host for development lookups. */ declare const featureHosts: readonly ["dev", "cloudflare", "vercel", "netlify", "deno", "node"]; type FeatureHost = (typeof featureHosts)[number]; interface NativeHostSupport { level: "native"; /** The default driver that ViteHub selects, such as `cloudflare`. */ driver: string; /** Short name for tables, such as `R2`. */ display: string; guarantee: "native" | "single-host" | "process-local"; detail: string; /** The first override whose environment variable has a non-empty, trimmed value replaces the default. */ envOverrides?: readonly { env: string; support: Omit; }[]; } /** * How a host supports a feature when the app enables it in `vitehub({...})`. * - `native`: ViteHub selects a driver for the host. Credentials can still be needed. * - `explicit`: the app must set `option` to choose a driver. * - `unsupported`: `vitehub({...})` cannot provide the feature on this host. */ type HostSupport = NativeHostSupport | { level: "explicit"; display: string; /** The option path that selects a driver, such as `blob.driver`. */ option: `${FeatureId}.${string}`; detail: string; } | { level: "unsupported"; detail: string; }; /** A feature that this feature turns on, unless the app sets the other feature to `false`. */ interface FeatureImplication { feature: FeatureId; } /** The starter Definition file that `vitehub add --name ` creates. */ interface FeatureStarter { /** The folder of the Definitions, relative to the project root, such as `server/queues`. */ dir: string; /** The path of the Definition `name`, relative to the project root. */ file: (name: string) => string; /** The source of a minimal Definition named `name`. */ template: (name: string) => string; /** * Earlier versions of `template`. `vitehub remove` deletes a file only when it equals the current or an earlier * starter, so keep the old template here when you change one. */ previousTemplates?: readonly ((name: string) => string)[]; /** * Other files, relative to the project root, that already define the Definition `name` or that the owner rejects * next to it. The starter is not written when one exists. */ conflicts: (name: string) => readonly string[]; } interface FeatureDefinition { id: TId; title: string; /** One sentence for pickers and docs. */ summary: string; docs: `/docs/${string}`; /** Whether the feature is unconditionally on when the app does not set its key. */ enabledByDefault: boolean; /** * Files and folders in the configured server directories (default `server/`) that turn on a feature whose key is * unset. A key of `false` keeps the feature off. */ enabledByDiscovery?: readonly string[]; /** Packages that the app installs for this feature, in `pnpm add` order. */ packages: readonly string[]; /** Additional packages selected by literal provider options. */ providerPackages?: Readonly>>>; requiredOptions?: readonly { option: `${TId}.${string}`; detail: string; }[]; /** Development dependencies that the app installs for this feature. */ devPackages: readonly string[]; implies: readonly FeatureImplication[]; /** The Deployment Plan service that this feature reads, when it has one. */ service?: DeploymentService; hosts: Readonly>; /** The starter Definition, for features with Definition files. */ definition?: FeatureStarter; /** Hosts that use `hosts.dev` during development instead of their deployment entry. Node always uses `hosts.dev`. */ developmentOverrides?: readonly ViteHubHost[]; } //#endregion //#region src/setup/project.d.ts type SetupFramework = "vite" | "nuxt" | "none"; type SetupPackageManager = "pnpm" | "npm" | "yarn" | "bun"; interface SetupProject { root: string; framework: SetupFramework; packageManager: SetupPackageManager; /** Where `packageManager` comes from. `default` means npm, because nothing named one. */ packageManagerSource: "manifest" | "lockfile" | "user-agent" | "default"; /** The config file name in `root`, such as `vite.config.ts`. */ configFile?: string; /** Where `vitehub()` options are in `configFile`. `undefined` when there is no config file. */ config: LocateResult | undefined; /** The text of `configFile` that `config` was read from. */ configSource?: string; /** True when the target manifest declares `name` for production, or for development when `dev` is true. */ declared: (name: string, dev: boolean) => boolean; /** Static discovery directories; undefined when Nuxt directories or layers need evaluation. */ serverDirs?: readonly string[]; /** True when `name` is resolvable from the project or present in an ancestor's node_modules. */ installed: (name: string) => boolean; } /** * Reads the project in `root` without loading its config: the config file is parsed, never run. * Throws `SETUP_NOT_A_PROJECT` when `root` has no package.json and no Vite or Nuxt config. */ export declare function readSetupProject(root: string, env: NodeJS.ProcessEnv): Promise; //#endregion //#region src/setup/status.d.ts interface SetupFeatureStatus { id: FeatureId; enabled: "on" | "off" | "unknown"; /** `config` when the config sets the key, `default` when it does not, `implied` when another feature turns it on. */ reason: "config" | "default" | "implied"; support: HostSupport | { level: "unknown"; detail: string; }; /** Packages and development packages of an enabled feature that are not installed. */ missingPackages: readonly string[]; /** The next step, such as the install command of `missingPackages`. */ fix?: string; } interface SetupStatus { schemaVersion: 1; root: string; framework: SetupProject["framework"]; config: { file: string; form: ConfigForm; } | { file?: string; manual: ManualReason; line?: number; }; host: { name: ViteHubHost | "unknown"; source: "config" | "env" | "default"; }; packageManager: SetupPackageManager; features: readonly SetupFeatureStatus[]; } /** What the project enables, on which host, and what each enabled feature still needs. Reads the config without running it. */ export declare function setupStatus(project: SetupProject, env: NodeJS.ProcessEnv, withoutDefinitions?: ReadonlySet): SetupStatus; //#endregion //#region src/setup/add.d.ts interface SetupAddArgs { features: FeatureId[]; json: boolean; dryRun: boolean; yes: boolean; install: boolean; name?: string; /** `--option` values, by feature. */ options: Partial>>; help: boolean; } interface SetupChange { /** Relative to the project root. */ path: string; /** `delete` is a file that `vitehub remove` deletes; its `after` is empty. */ kind: "create" | "patch" | "delete"; before?: string; after: string; /** A unified diff from `before` to `after`. */ diff: string; } interface SetupAddPlan { /** `planned` for a dry run or a plan that waits for `--yes`, `applied` when done, `unchanged` when there is nothing to do. */ status: "planned" | "applied" | "unchanged"; root: string; host: SetupStatus["host"]; features: readonly FeatureId[]; changes: readonly SetupChange[]; install: { packages: readonly string[]; devPackages: readonly string[]; command?: string; }; /** Features that the added features turn on. Only supplied provider options need an explicit config key. */ implied: readonly FeatureId[]; nextSteps: readonly string[]; } /** Reads the arguments. Throws `CLI_R0003` for an unknown flag, feature, or option. */ export declare function readAddArgs(args: readonly string[]): SetupAddArgs; /** `--option` values by feature. */ type SetupOptions = Partial>>; /** Builds the command that `rerun` reports: the request with `extra` options and `extraFeatures` added. */ type SetupRerun = (args: SetupAddArgs, extra?: SetupOptions, extraFeatures?: readonly FeatureId[]) => string; /** A `vitehub add` plan with the file contents that applying it writes. */ interface SetupAddPlanned { plan: SetupAddPlan; configFile?: { path: string; before: string; after: string; }; restartRequired: boolean; files: { path: string; content: string; }[]; install: { prod: string[]; dev: string[]; }; } /** Plans `vitehub add` without writing anything. Throws `SetupFailure` when the change needs input or is not possible. */ export declare function planSetupAdd(project: SetupProject, args: SetupAddArgs, env: NodeJS.ProcessEnv, rerun?: SetupRerun): Promise; /** Applies a `vitehub add` plan: installs the packages, writes the starter Definitions, and writes the config last. */ export declare function applySetupAdd(project: SetupProject, planned: SetupAddPlanned, args: Pick, context: Pick): Promise; export declare const addCommand: ViteHubCliCommand; //#endregion //#region src/setup/catalog.d.ts interface SetupCatalog { schemaVersion: 1; hosts: readonly FeatureHost[]; features: readonly FeatureDefinition[]; } /** Every feature of `vitehub({...})` and how each host supports it. Needs no project. */ export declare function setupCatalog(): SetupCatalog; //#endregion //#region src/setup/commands.d.ts /** The setup commands. They run before the CLI loads the project config. */ export declare const setupCommands: readonly ViteHubCliCommand[]; //#endregion //#region src/setup/console-auth.d.ts /** The hosted Console. `--console` and `VITEHUB_CONSOLE_URL` name a self-hosted one. */ export declare const defaultConsoleUrl = "https://console.vitehub.dev"; /** An API key for CI. It wins over the saved key, and `vitehub logout` does not remove it. */ export declare const consoleTokenVariable = "VITEHUB_CONSOLE_TOKEN"; export declare const consoleUrlVariable = "VITEHUB_CONSOLE_URL"; /** What `vitehub login` keeps for one Console. The file is readable only by its owner. */ interface ConsoleCredential { token: string; keyId: string; user: { id: string; name: string; email: string; }; team: { id: string; name: string; }; /** Milliseconds since 1970. */ expiresAt: number; } /** `$XDG_CONFIG_HOME/vitehub/credentials.json`, else `~/.config/vitehub/credentials.json`. */ export declare function consoleCredentialsFile(env: NodeJS.ProcessEnv): string; /** The origin of a Console URL. Plain `http` is accepted only for a Console on this machine. */ export declare function consoleOrigin(value: string): string; /** * The key that a command sends to a Console, and where it came from: `VITEHUB_CONSOLE_TOKEN`, else the key that * `vitehub login` saved for the Console. Without `console`, the Console is `VITEHUB_CONSOLE_URL`, else the only saved * Console, else console.vitehub.dev. `undefined` when there is no key. */ export declare function readConsoleCredential(env: NodeJS.ProcessEnv, console?: string): Promise<{ origin: string; token: string; source: "env" | "file"; saved?: ConsoleCredential; } | undefined>; export declare const loginCommand: ViteHubCliCommand; export declare const whoamiCommand: ViteHubCliCommand; export declare const logoutCommand: ViteHubCliCommand; //#endregion //#region src/setup/envelope.d.ts /** Exit codes of the setup commands. */ export declare const setupExitCodes: { readonly done: 0; readonly error: 1; readonly inputNeeded: 2; readonly conflict: 3; readonly stalePlan: 4; }; interface SetupError { code: string; message: string; why: string; fix?: string; docs?: string; } /** One accepted value of a missing input. Accounts carry an id and a name; plain values are strings. */ type SetupChoice = string | { id: string; name?: string; }; /** An input that a setup command needs, such as an account id, with the values it accepts when there are few. */ interface SetupMissing { field: string; choices?: readonly SetupChoice[]; } interface SetupFailureDetails { missing?: readonly SetupMissing[]; /** A command that would succeed, with `` for values that the caller must choose. */ rerun?: string; /** More fields of the JSON document, such as the plan. */ data?: object; } /** A setup diagnostic with its exit code and the input that is missing. `writeSetupError` reports it. */ type SetupFailure = Error & { readonly details: SetupFailureDetails; readonly exitCode: number; }; //#endregion //#region src/setup/link.d.ts /** The link file, relative to the project root. It is gitignored and never holds a secret. */ export declare const SETUP_LINK_FILE = ".vitehub/link.json"; type SetupLinkHost = CredentialHost; interface SetupLinkAccount { id: string; name?: string; } /** One host target of `.vitehub/link.json`. */ interface SetupLinkTarget { /** Can be absent for an unverified Deno link. */ account?: SetupLinkAccount; project: { id?: string; name: string; }; /** True when the host API confirmed that the project exists. */ verified: boolean; linkedAt: string; } /** A host target with its host, as deploy and the other commands use it. */ interface SetupLink extends SetupLinkTarget { host: SetupLinkHost; } /** The content of `.vitehub/link.json`: one target for each linked host, and the host that deploys without `--host`. */ interface SetupLinkFile { schemaVersion: 2; default?: SetupLinkHost; targets: Partial>; } /** The parsed link file. `targets` is empty when the project has no link. */ interface SetupLinks { default?: SetupLinkHost; targets: SetupLink[]; } /** The link fields that `vitehub status` reports. */ type SetupLinkSummary = Pick; interface SetupLinkOptions { host?: string; project?: string; account?: string; create: boolean; /** Make this host the default target. The first linked host is always the default. */ default?: boolean; } interface SetupLinkResult { file: string; link: SetupLink; /** The host that `vitehub deploy` uses without `--host`. `null` with several hosts and no default. */ default: SetupLinkHost | null; /** Every linked host, this one included. */ hosts: SetupLinkHost[]; /** True when `--create` created the project on the host. */ created: boolean; /** Where the credentials came from. `null` when the host needs none for a link (Deno). */ credentials: { source: CredentialSource; } | null; /** `added` when the command appended `.vitehub` to `.gitignore`. `no-gitignore` when the project has no `.gitignore`. */ gitignore: "added" | "present" | "no-gitignore"; } /** Looks up the project on the host, creates it with `create`, and writes `.vitehub/link.json`. */ export declare function linkSetupProject(project: SetupProject, options: SetupLinkOptions, context: ViteHubCliContext): Promise; /** * Removes the target of `host`, or the whole link file without `host`. When the default target goes and one target * stays, that one becomes the default. Returns false when there was nothing to remove. */ export declare function unlinkSetupProject(root: string, host?: SetupLinkHost): Promise; /** * Reads the targets of `.vitehub/link.json`. A missing or unreadable file has no target. A file of schema version 1 * holds one host link, so it reads as one target that is also the default. The next write saves it as version 2. */ export declare function readSetupLinks(root: string): Promise; /** The result of picking a target: the target, none, or several without a default. */ type SetupLinkSelection = { link: SetupLink | undefined; } | { ambiguous: SetupLinkHost[]; }; /** Picks the target of `host`. Without `host`: the default target, else the only target. */ export declare function selectSetupLink(links: SetupLinks, host?: SetupLinkHost): SetupLinkSelection; /** What `vitehub status` adds to the feature status. */ interface SetupLinkStatus { /** The target that `vitehub deploy` uses without `--host`. With several targets and no default, the target of the config host, else `null`. */ link: SetupLinkSummary | null; /** Every linked host target. */ targets: SetupLinkSummary[]; /** The host that `vitehub deploy` uses without `--host`. */ default: SetupLinkHost | null; /** For the `link` host, else the config host. Never includes the token. `null` on a host without credentials (Node). */ credentials: HostCredentialsDescription | null; } /** The link file and the credentials that `vitehub status` reads. `credentials` holds the token and never goes in output. */ interface SetupLinkState { status: SetupLinkStatus; link: SetupLink | undefined; credentials: HostCredentials | undefined; } /** Reads the link and credentials, skipping CLI discovery offline and sharing the online host deadline. */ export declare function readSetupLinkState(project: SetupProject, host: string, context: ViteHubCliContext, options?: { offline?: boolean; signal?: AbortSignal; }): Promise; /** The link and the credential status for `vitehub status`. The credentials never include the token. */ export declare function readSetupLinkStatus(project: SetupProject, host: string, context: ViteHubCliContext): Promise; //#endregion //#region src/setup/deploy/host.d.ts /** The hosts that `vitehub deploy` deploys to. */ type DeployHost = "cloudflare" | "vercel" | "netlify" | "deno"; /** The git commit of the deployed source. A folder without git has none. */ interface DeployCommit { sha: string; dirty: boolean; } /** Where a deployment came from, when the host says. */ type HostDeploymentSource = "cli" | "git" | "dashboard" | "api" | "unknown"; /** One deployment as the host lists it. */ interface HostDeployment { id: string; /** The URL of this deployment. Absent when the host gives it no own URL. */ url?: string; createdAt: string; state: "ready" | "building" | "error" | "canceled" | "unknown"; target: "production" | "preview"; /** True for the deployment that receives production traffic. */ live: boolean; /** The Worker version of a Cloudflare deployment. */ version?: string; /** * The deployed commit. `from: "vitehub"` is the marker of `vitehub deploy`. `from: "host"` is the commit of a Git * integration build, which builds a clean checkout. */ commit?: DeployCommit & { from: "vitehub" | "host"; }; source: HostDeploymentSource; } //#endregion //#region src/setup/deploy/after.d.ts /** One path of `deploy.check`, as the deployed app answered it. */ interface DeployCheckResult { path: string; url: string; ok: boolean; /** The last HTTP status. Missing when no request got an answer. */ status?: number; /** Why the last request got no answer, such as a timeout. */ error?: string; } /** How to put the previous production deployment back, when a check fails. */ interface DeployRollback { /** The deployment that received production traffic before this deploy. Missing on a first deploy or when it is not known. */ previous?: { deploymentId: string; version?: string; }; /** The command that rolls production back to `previous`. Missing when the host has no rollback command. */ command?: string; /** What to do when there is no command, or why `previous` is not known. */ note?: string; } /** What `vitehub deploy --json` prints for the IndexNow submission. */ type DeployIndexNowOutput = { submitted: number; status: number; } | { error: string; status?: number; }; //#endregion //#region src/setup/deploy/checkouts.d.ts /** What `pushWorkspaces()` returns for one checkout folder, the same as `vitehub push --json`. */ interface CheckoutPushResult { workspace: string; ref: string; /** The new head. Undefined when nothing changed locally. */ revision?: string; pushed: string[]; /** The pulls before the build and the push, in order. */ pull: { workspace: string; ref: string; from: string | null; head: string | null; files: Array<{ path: string; action: string; note?: string; }>; }; /** The pull after the first push to a new ref that inherits files from another ref. */ after?: CheckoutPushResult["pull"]; } interface CheckoutPushError { code: string; message: string; fix?: string; } /** `checkouts` of `vitehub deploy --json`: the push results and the files to commit, or the error of the push. */ type DeployCheckoutsOutput = { results: CheckoutPushResult[]; changed: string[]; } | { error: CheckoutPushError; }; //#endregion //#region src/setup/env.d.ts /** One set of names that the app reads, without its values. */ interface EnvDiffEntry { names: readonly string[]; prefix?: string; path?: string; owners?: readonly string[]; secret: boolean; } /** What `vitehub deploy --json` prints in `env`. Names only, never a value. */ interface DeployEnvOutput { /** `production`, or `preview` with `--preview`. It picks the `.env.` files. */ stage: string; /** Every name and prefix that the build lists. */ checked: string[]; /** Optional entries that neither the host nor a local value sets. Required ones stop the deploy. */ missing: EnvDiffEntry[]; /** Names that the deploy set on the host, or uploaded with the Cloudflare version. */ pushed: string[]; /** Names that the deploy generated, such as `VITEHUB_SECRET`. They are in `pushed` too. */ generated?: string[]; } //#endregion //#region src/provision.d.ts type ProvisionActionStatus = "create" | "update" | "pending" | "exists"; //#endregion //#region src/setup/deploy/provision.d.ts /** What `vitehub deploy --json` reports in `provision`. */ interface DeployProvisionOutput { /** The resources that this deploy created or changed. Empty when everything existed. */ changed: Array<{ status: Exclude; kind: string; name: string; step: string; }>; /** The ids of the host resources, by category and key, as `.vitehub/provision.json` records them. */ ids: Record>; } //#endregion //#region src/setup/deploy.d.ts interface SetupDeployArgs { /** The host of --host, as the user wrote it. */ host?: string; preview: boolean; /** `--push-env`: set every local value on the host, also the names that the host has. */ pushEnv: boolean; build: boolean; /** False with --no-provision. */ provision: boolean; /** False with --no-push. A preview deploy never pushes. */ push: boolean; /** False with --no-check: do not request the `deploy.check` paths after the upload. */ check: boolean; /** False with --no-index-now: do not send the sitemap URLs to IndexNow. */ indexNow: boolean; temporary: boolean; yes: boolean; json: boolean; help: boolean; } /** What `vitehub deploy --json` prints, after `schemaVersion: 1`. */ interface SetupDeployOutput { host: DeployHost; url: string; deploymentId?: string; version?: string; temporary?: { claimUrl: string; expiresAt?: string; }; commit?: DeployCommit; /** The host resources that the deploy provisioned. Missing when the host has none, or with --no-provision. */ provision?: DeployProvisionOutput; /** The Workspace push of the checkout folders of `vitehub.lock`. Missing when the deploy did not push. */ checkouts?: DeployCheckoutsOutput; /** The env names that the deploy checked and set. Never a value. */ env: DeployEnvOutput; /** The `deploy.check` paths and how the deployed app answered. Missing when the build has none, or with --no-check. */ checks?: DeployCheckResult[]; /** How to roll production back. Only when a check failed. */ rollback?: DeployRollback; /** The IndexNow submission. Missing when the build has no `deploy.indexNow`, for a preview, and with --no-index-now. */ indexNow?: DeployIndexNowOutput; } export declare function readDeployArgs(args: readonly string[]): SetupDeployArgs; export declare const deployCommand: ViteHubCliCommand; //#endregion //#region src/setup/deployments.d.ts /** How long `vitehub status` waits for the host before it reports `liveReason: "timeout"`. */ export declare const STATUS_HOST_TIMEOUT_MS = 5000; /** What `vitehub deployments --json` prints, after `schemaVersion: 1`. */ interface SetupDeploymentsOutput { host: SetupLinkHost; project: SetupLink["project"]; deployments: HostDeployment[]; } /** The deployment that receives production traffic, as `vitehub status` reports it. */ interface SetupLive { deploymentId: string; url?: string; commit?: DeployCommit; /** Commits on HEAD that the live deployment does not have. */ behind?: number; /** Commits in the live deployment that HEAD does not have. */ ahead?: number; /** Why `behind` and `ahead` are not known. */ unknownReason?: "commit-not-local" | "no-marker" | "no-git"; } /** Why `live` is `null`. */ type SetupLiveReason = "offline" | "not-linked" | "no-credentials" | "no-live-deployment" | "timeout" | "host-error"; interface SetupLiveStatus { live: SetupLive | null; liveReason: SetupLiveReason | null; } export declare const deploymentsCommand: ViteHubCliCommand; /** * The deployment that receives production traffic, for `vitehub status`. It asks the host only when the project is * linked and the credentials resolved. The signal shares status's deadline with credential discovery; standalone * callers get `STATUS_HOST_TIMEOUT_MS`. It never throws: a failure is a `liveReason`. */ export declare function readSetupLive(root: string, link: SetupLink | undefined, credentials: HostCredentials | undefined, context: ViteHubCliContext, options: { offline: boolean; signal?: AbortSignal; }): Promise; //#endregion //#region src/setup/stack.d.ts interface SetupStack { command: string | null; omits: readonly { path: string; reason: "opaque-config" | "spread" | "expression" | "unresolved-host" | "unresolved-feature" | "disabled-feature" | "unsupported-feature" | "non-replayable-option" | "credential-option" | "required-option" | "unplannable-stack"; }[]; } //#endregion //#region src/setup/init.d.ts declare const initHosts: readonly ["cloudflare", "vercel", "netlify", "deno", "node"]; type InitHost = typeof initHosts[number]; type InitFramework = "vite" | "nuxt"; /** * The packages of a new app, as `getting-started/installation.md` installs them. The Nitro and H3 versions match the * server integration of ViteHub. Nuxt 5 supplies Nitro 3, and its tutorials import H3 2. Valibot validates request * bodies in the docs' route examples. */ export declare const initPackages: Readonly>; /** The pinned Nuxt CLI that creates a new Nuxt app. */ export declare const nuxiPackage = "nuxi@3.37.0"; interface SetupInitArgs { dir?: string; host?: InitHost; /** `undefined` when `--features` is absent. */ features?: FeatureId[]; /** Raw `--option` values, such as `email.driver=resend`. */ options: string[]; framework?: InitFramework; pm?: SetupPackageManager; install: boolean; dryRun: boolean; yes: boolean; json: boolean; help: boolean; } interface SetupInitPlan { /** `planned` for a dry run or a plan that waits for `--yes`, `applied` when done, `unchanged` when there is nothing to do. */ status: "planned" | "applied" | "unchanged"; root: string; /** `create` for a new app, `adopt` for an existing Vite or Nuxt app. */ mode: "create" | "adopt"; framework: InitFramework; host: InitHost; packageManager: SetupPackageManager; features: readonly FeatureId[]; implied: readonly FeatureId[]; /** The Nuxt CLI command that creates a new Nuxt app before ViteHub adopts it. */ scaffold?: { command: string; }; changes: readonly SetupChange[]; install: { packages: readonly string[]; devPackages: readonly string[]; command?: string; }; stack: SetupStack; nextSteps: readonly string[]; } /** Reads the arguments. Throws `CLI_R0003` for an unknown flag or value. */ export declare function readInitArgs(args: readonly string[]): SetupInitArgs; export declare const initCommandDefinition: ViteHubCliCommand; //#endregion //#region src/setup/remove.d.ts interface SetupRemoveArgs { features: FeatureId[]; json: boolean; dryRun: boolean; yes: boolean; /** `--keep-files`: keep the starter Definitions. */ keepFiles: boolean; /** `--force`: turn the features off while the app still uses them, and write `false` for an implied feature. */ force: boolean; /** False with `--no-uninstall`. */ uninstall: boolean; help: boolean; } /** A place where the app still uses a feature that `vitehub remove` turns off. */ interface SetupReference { feature: FeatureId; /** Relative to the project root. */ file: string; line?: number; /** The import, such as `vite-hub/queue`. Undefined for a Definition file or a discovered file. */ module?: string; } interface SetupRemovePlan { /** `planned` for a dry run or a plan that waits for `--yes`, `applied` when done, `unchanged` when there is nothing to do. */ status: "planned" | "applied" | "unchanged"; root: string; host: SetupStatus["host"]; features: readonly FeatureId[]; /** Every feature that goes off, with the ones that only the removed features turned on, such as Workflow for Agent. */ turnedOff: readonly FeatureId[]; /** The config patch first, then the starter Definitions to delete. */ changes: readonly SetupChange[]; /** Files that stay: edited Definitions with `--force`, and starter Definitions with `--keep-files`. */ kept: readonly { path: string; reason: "edited" | "keep-files"; }[]; /** Uses of the features that `--force` ignored. */ references: readonly SetupReference[]; uninstall: { packages: readonly string[]; devPackages: readonly string[]; command?: string; }; nextSteps: readonly string[]; } /** Reads the arguments. Throws `CLI_R0003` for an unknown flag or feature. */ export declare function readRemoveArgs(args: readonly string[]): SetupRemoveArgs; /** A `vitehub remove` plan with the file contents that applying it checks and writes. */ interface PlannedRemove { plan: SetupRemovePlan; configFile?: { path: string; before: string; after: string; }; restartRequired: boolean; /** Starter Definitions to delete. */ deletes: { path: string; content: string; }[]; uninstall: string[]; } /** Plans `vitehub remove` without writing anything. Throws `SetupFailure` when the change is not safe or not possible. */ export declare function planSetupRemove(project: SetupProject, args: SetupRemoveArgs, env: NodeJS.ProcessEnv): Promise; /** Applies a removal. In-server sessions defer the restart-triggering config until cleanup finishes. */ export declare function applySetupRemove(project: SetupProject, planned: PlannedRemove, args: Pick, context: Pick, options?: { configLast?: boolean; }): Promise; export declare const removeCommand: ViteHubCliCommand; //#endregion //#region src/setup/update.d.ts interface SetupUpdateArgs { dryRun: boolean; help: boolean; install: boolean; json: boolean; /** A commit of vite-hub/vitehub. Its pkg.pr.new build replaces the npm release. */ preview?: string; } interface SetupUpdatePlan { /** `planned` for a dry run, `applied` when done, `unchanged` when every package is already on the target. */ status: "planned" | "applied" | "unchanged"; /** The npm version, such as `0.2.0`, or the pkg.pr.new commit of `--preview`. */ target: { version: string; } | { preview: string; }; /** The root of the workspace that the command updated. */ root: string; /** Each ViteHub package that the project names, with the specifier it now uses. */ packages: Readonly>; changes: readonly Pick[]; install: { command: string; }; } interface WorkspaceFile { path: string; before: string; after: string; } /** The command that installs the new specifiers. pnpm resolves ViteHub peers again only with `update`. */ export declare function updateInstallArgs(packageManager: SetupPackageManager, workspace: boolean): string[]; /** Reads the arguments. Throws `CLI_R0003` for an unknown flag or a value that is not a commit. */ export declare function readUpdateArgs(args: readonly string[]): SetupUpdateArgs; interface PlannedUpdate { plan: SetupUpdatePlan; files: readonly WorkspaceFile[]; packageManager: SetupPackageManager; installArgs: string[]; } /** Plans the update: finds every ViteHub specifier, resolves the target, and computes the new files. Writes nothing. */ export declare function planSetupUpdate(rootDir: string, args: Pick, context: Pick): Promise; export declare const updateCommand: ViteHubCliCommand; //#endregion //#region src/setup/session.d.ts /** * Runs the package manager with an argument array and no shell. `onOutput` gets its stdout and stderr as they arrive. * Tests pass a fake runner. */ type SetupCommandRunner = (command: string, args: readonly string[], options: { cwd: string; env: NodeJS.ProcessEnv; onOutput: (text: string, stream: "stdout" | "stderr") => void; }) => Promise<{ exitCode: number | null; signal?: NodeJS.Signals | null; }>; /** * A change that the dev Setup page asks for. It names features and options only: never a path or a command. The * session turns it into the same arguments as `vitehub add` or `vitehub remove`. */ interface SetupPlanRequest { action: "add" | "remove"; features: readonly string[]; /** `add`: `--option` values, such as `kv.driver=upstash`. */ options?: readonly string[]; /** `add`: `--name` of the starter Definitions. */ name?: string; /** `add`: false for `--no-install`. */ install?: boolean; /** `remove`: `--force`. */ force?: boolean; /** `remove`: `--keep-files`. */ keepFiles?: boolean; /** `remove`: false for `--no-uninstall`. */ uninstall?: boolean; } /** A JSON document of a setup command, the same as its `--json` output, and the exit code of the command. */ interface SetupSessionResult { exitCode: number; body: { schemaVersion: 1; [key: string]: unknown; }; } /** Fields that the session adds to a plan document. */ interface SetupSessionPlanFields { /** Applies this plan once with `apply()`. Absent when there is nothing to change. */ planId?: string; /** The CLI command that makes the same change. */ command: string; /** True when applying writes the config file, so the dev server restarts. */ restart: boolean; restartRequired?: true; } interface SetupSession { catalog: () => SetupSessionResult; status: () => Promise; /** Plans a change without writing anything. The document equals `vitehub add|remove ... --dry-run --json`, with {@link SetupSessionPlanFields}. */ plan: (request: unknown) => Promise; /** * Applies exactly the stored plan, once. It fails with exit code 4 when a file that the plan read changed, or when * planning again would give another plan. Applies run one at a time. */ apply: (planId: unknown, onOutput?: (text: string, stream: "stdout" | "stderr") => void) => Promise; } interface SetupSessionOptions { /** The project root. The session never takes a path from a request. */ root: string; env: NodeJS.ProcessEnv; run: SetupCommandRunner; /** The most plans that the session keeps. The oldest goes first. Defaults to 20. */ maxPlans?: number; } /** The CLI arguments of a request. Every value goes inline after `=`, so no value can become another flag. */ export declare function setupRequestArgs(request: unknown): { action: "add" | "remove"; argv: string[]; }; /** * The setup engine for a long-running process, such as the dev Setup page. It does what `vitehub status`, `catalog`, * `add`, and `remove` do, with the same documents, and keeps each plan until one `apply()` uses it. */ export declare function createSetupSession(options: SetupSessionOptions): SetupSession; //#endregion export type { ConsoleCredential, DeployCommit, HostDeployment, HostDeploymentSource, PlannedRemove, SetupAddArgs, SetupAddPlan, SetupAddPlanned, SetupCatalog, SetupChange, SetupChoice, SetupCommandRunner, SetupDeployArgs, SetupDeployOutput, SetupDeploymentsOutput, SetupError, SetupFailure, SetupFailureDetails, SetupFeatureStatus, SetupFramework, SetupInitArgs, SetupInitPlan, SetupLink, SetupLinkAccount, SetupLinkFile, SetupLinkHost, SetupLinkOptions, SetupLinkResult, SetupLinkSelection, SetupLinkState, SetupLinkStatus, SetupLinkSummary, SetupLinkTarget, SetupLinks, SetupLive, SetupLiveReason, SetupLiveStatus, SetupMissing, SetupOptions, SetupPackageManager, SetupPlanRequest, SetupProject, SetupReference, SetupRemoveArgs, SetupRemovePlan, SetupRerun, SetupSession, SetupSessionOptions, SetupSessionPlanFields, SetupSessionResult, SetupStatus, SetupUpdateArgs, SetupUpdatePlan };