UNPKG

@mesh-tech/mesh-cli

Version:

CLI for Mesh platform development utilities

106 lines (105 loc) 3.46 kB
import { probeRegistryToken } from "../../utils/auth-preflight.js"; import { type RegistryLoginOptions } from "../registry.js"; import { type MeshJson } from "../../utils/mesh-json.js"; export interface WizardOptions { tenant?: string; local?: boolean; platform?: string; device?: boolean; profile?: string; skipRepo?: boolean; yes?: boolean; json?: boolean; } export type StepStatus = "pass" | "fail" | "warn" | "skip"; export interface StepResult { name: string; status: StepStatus; detail: string; fix?: string; blocking?: boolean; } export type WizardMode = "local" | { platform: string; }; export interface WizardCtx { cwd: string; tenant: string; mode: WizardMode; context: string | null; device?: boolean; profile?: string; interactive: boolean; remote: boolean; yes: boolean; skipRepo: boolean; prompts: Prompts; seams?: WizardSeams; } export interface WizardSeams { probe?: typeof probeRegistryToken; runRegistryLogin?: (opts: RegistryLoginOptions) => Promise<void>; gitInit?: (dir: string) => void; } export interface WizardStep { name: "registry" | "platform" | "repo" | "skills"; run(ctx: WizardCtx): Promise<StepResult>; } export interface WizardOutcome { tenant: string; mode: WizardMode; steps: StepResult[]; next: string[]; } export interface Prompts { input(args: { message: string; default?: string; validate?: (v: string) => true | string; }): Promise<string>; select<T extends string>(args: { message: string; choices: Array<{ name: string; value: T; }>; default?: T; }): Promise<T>; confirm(args: { message: string; default?: boolean; }): Promise<boolean>; } export declare const NO_SESSION_NO_TTY_MESSAGE: string; export declare const TENANT_REQUIRED_MESSAGE = "--tenant is required (no TTY for interactive mode)"; export declare const INTERRUPTED_EXIT_CODE = 130; export declare function wizardExitCode(steps: ReadonlyArray<Pick<StepResult, "status">>): number; export declare function wizardNextCommands(mode: WizardMode, steps?: ReadonlyArray<StepResult>): string[]; export declare function stepBlocks(result: StepResult): boolean; export declare function describeMode(mode: WizardMode): string; export declare function renderWizardSummary(outcome: WizardOutcome, opts?: { color?: boolean; }): string; export declare function resolveAnswers(opts: WizardOptions, recorded: MeshJson | null, interactive: boolean): { tenant?: string; mode?: WizardMode; open: Array<"tenant" | "mode">; }; export declare const registryStep: WizardStep; export type RepoKind = "platform-monorepo" | "empty-apps-repo" | "apps-repo" | "other-repo" | "empty-dir" | "no-repo"; export declare function classifyRepo(cwd: string): { kind: RepoKind; root: string; }; export declare const INIT_REPO_FIX = "git init && mesh init"; export declare const repoStep: WizardStep; export declare const WIZARD_STEPS: readonly WizardStep[]; export declare function runWizardSteps(ctx: WizardCtx, steps: readonly WizardStep[]): Promise<StepResult[]>; export declare function runInitWizard(opts: WizardOptions, deps?: { cwd?: string; prompts?: Prompts; steps?: readonly WizardStep[]; interactive?: boolean; remote?: boolean; seams?: WizardSeams; }): Promise<number>;