import { Diagnostic } from "nostics"; //#region ../internal/src/host-credentials.d.ts interface HostCliRunResult { exitCode: number | null; stdout: string; } /** Runs a host CLI with an argument array and no shell, and returns its stdout. */ type HostCliRun = (command: string, args: readonly string[], options: { cwd?: string; env: NodeJS.ProcessEnv; signal?: AbortSignal; }) => Promise; //#endregion //#region ../internal/src/provision.d.ts type ProvisionProvider = "cloudflare" | "vercel"; interface ProvisionLogger { log: (message: string) => void; warn: (message: string) => void; } interface ProvisionContext { env: Record; fetch: typeof globalThis.fetch; logger: ProvisionLogger; markPlanUnchecked?: () => void; } interface ProvisionState { cloudflare?: Record>; vercel?: Record>; } interface ProvisionResult { ids?: ProvisionState; } interface ProvisionAction { kind: string; name: string; exists: boolean; pending?: boolean; /** Describes the change that `apply()` makes to an existing resource, for example `read replication: disabled -> auto`. */ update?: string; apply: () => Promise; } /** One Provision State category that a step records, with the keys that current Definitions use. */ interface ProvisionStateCategory { category: string; declared: readonly string[]; /** Provider resource identity for shared-resource checks. Return undefined when the recorded id lacks enough information. Defaults to the recorded id. */ resourceIdentity?: (entry: { id: string; key: string; }) => string | undefined; /** Identity expected by current config for a declared key. Omit when it cannot be established without provider access. */ declaredResourceIdentity?: (key: string) => string | undefined; /** Tells a developer how to delete the resource of a recorded entry that no Definition declares. ViteHub never runs it. */ deleteHint: (entry: { id: string; key: string; }) => string; } interface ProvisionStep { id: string; provider: ProvisionProvider; plan: (context: ProvisionContext) => Promise; /** Describes the Provision State this step records. Runs without network access, also without credentials. */ recordedState?: (context: Pick) => ProvisionStateCategory[]; } //#endregion //#region ../internal/src/cli.d.ts interface ViteHubCliStreams { stderr: { write: (chunk: string | Uint8Array, encoding?: BufferEncoding | StdoutWriteCallback, callback?: StdoutWriteCallback) => unknown; }; stdout: { write: (chunk: string | Uint8Array) => unknown; }; } interface ViteHubCliSpawnResult { exitCode: number | null; signal?: NodeJS.Signals | null; /** The output of the child when `stdout` is `pipe`. */ stdout?: string; } interface ViteHubCliSpawnOptions { cwd?: string; env?: NodeJS.ProcessEnv; stderr?: "inherit" | "pipe"; /** `ignore` gives the child no terminal input, so a tool that asks questions on a terminal does not ask. */ stdin?: "ignore" | "inherit"; /** `stderr` sends the child's stdout to the parent's stderr, so the parent's stdout keeps only its own output. */ stdout?: "inherit" | "pipe" | "stderr"; } type ViteHubCliSpawn = (command: string, args: string[], options?: ViteHubCliSpawnOptions) => Promise; interface ViteHubCliContext extends ViteHubCliStreams { cwd: string; env: NodeJS.ProcessEnv; /** Replaces `fetch` for commands that call a running app, so tests need no server. */ fetch?: typeof fetch; /** * Loads the project config for a build on `host` and returns the Provision Steps of its plugins, with the config root * that holds `.vitehub/provision.json`. Setup commands, such as `vitehub deploy`, call it only when they need the * steps, so they still run on a config that throws. */ loadProvision?: (host: ProvisionProvider) => Promise; /** The deployed app's public origin from `vitehub({ publicUrl })`, when it is one string. */ publicUrl?: string; rootDir: string; /** Replaces the host CLI runner, such as for `wrangler auth token`, so tests need no real host CLI. */ runHostCli?: HostCliRun; spawn: ViteHubCliSpawn; } interface ViteHubCliProvision { rootDir: string; steps: readonly ProvisionStep[]; } interface ViteHubCliFeature { description?: string; name: string; run: (args: string[], context: ViteHubCliContext) => Promise | number | void; usage?: string; } interface ViteHubCliCommandNamespace { /** The feature that `vitehub ` runs when the next argument names no other feature. It gets every argument after ``. */ defaultFeature?: string; description?: string; features: ViteHubCliFeature[]; name: string; } /** The flags of `vitehub seed` that every seed gets. */ interface ViteHubCliSeedOptions { /** `--database `: seed only this Database. Only the Database seed runs. */ database?: string; /** The process environment with the env files of `--stage`. */ env: NodeJS.ProcessEnv; /** `--remote`: write the deployed stores. Without it, a seed writes only local data. */ remote: boolean; /** `--timeout ` of each call to the app. */ timeout?: number; /** The deployed app with `--remote`: `--url`, or `vitehub({ publicUrl })`. */ url?: string; } /** The seed files of one primitive, which `vitehub seed` writes. */ interface ViteHubCliSeed { /** Where the seed files are, such as `server/seed/kv/`. `vitehub seed` names it when it finds no seed files. */ files: string; /** The primitive, such as `database` or `kv`. `vitehub seed ` runs only this seed. */ name: string; /** Writes the seed files and returns the exit code, or `undefined` when the project has no seed files for this primitive. */ run: (options: ViteHubCliSeedOptions, context: ViteHubCliContext) => Promise; } interface ViteHubCliContributor { namespaces: ViteHubCliCommandNamespace[]; provision?: ProvisionStep[]; /** The seed files that `vitehub seed` writes. */ seeds?: ViteHubCliSeed[]; /** The deployed app's public origin. Commands receive it as `context.publicUrl`. */ publicUrl?: string; } type StdoutWriteCallback = (error?: Error | null) => void; //#endregion export { ViteHubCliContributor as n, ViteHubCliContext as t };