import type { CategoryConfig } from './category-config.js'; import type { PluginMeta } from './plugin-config.js'; /** * Type Definition: `PromptBase` * * This type is derived from a Zod schema and represents * the validated structure of `PromptBase` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#promptbase} */ type PromptBase = { key: string; message: string; }; /** * Type Definition: `PromptChoice` * * This type is derived from a Zod schema and represents * the validated structure of `PromptChoice` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#promptchoice} */ type PromptChoice = { name: string; value: T; }; /** * Type Definition: `InputPrompt` * * This type is derived from a Zod schema and represents * the validated structure of `InputPrompt` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#inputprompt} */ type InputPrompt = PromptBase & { type: 'input'; default: string; }; /** * Type Definition: `SelectPrompt` * * This type is derived from a Zod schema and represents * the validated structure of `SelectPrompt` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#selectprompt} */ type SelectPrompt = PromptBase & { type: 'select'; choices: PromptChoice[]; default: T; }; /** * Type Definition: `CheckboxPrompt` * * This type is derived from a Zod schema and represents * the validated structure of `CheckboxPrompt` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#checkboxprompt} */ type CheckboxPrompt = PromptBase & { type: 'checkbox'; choices: PromptChoice[]; default: T[]; }; /** * Type Definition: `ConfirmPrompt` * * This type is derived from a Zod schema and represents * the validated structure of `ConfirmPrompt` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#confirmprompt} */ type ConfirmPrompt = PromptBase & { type: 'confirm'; default: boolean; }; /** Declarative prompt definition used to collect plugin-specific options. */ /** * Type Definition: `PluginPromptDescriptor` * * This type is derived from a Zod schema and represents * the validated structure of `PluginPromptDescriptor` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#pluginpromptdescriptor} */ export type PluginPromptDescriptor = InputPrompt | SelectPrompt | CheckboxPrompt | ConfirmPrompt; /** A single value in the answers record produced by plugin prompts. */ /** * Type Definition: `PluginAnswer` * * This type is derived from a Zod schema and represents * the validated structure of `PluginAnswer` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#pluginanswer} */ export type PluginAnswer = string | string[] | boolean; /** * Type Definition: `ImportDeclarationStructure` * * This type is derived from a Zod schema and represents * the validated structure of `ImportDeclarationStructure` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#importdeclarationstructure} */ export type ImportDeclarationStructure = { moduleSpecifier: string; defaultImport?: string; namedImports?: string[]; isTypeOnly?: boolean; }; /** * Type Definition: `PluginDeclarationStructure` * * This type is derived from a Zod schema and represents * the validated structure of `PluginDeclarationStructure` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#plugindeclarationstructure} */ export type PluginDeclarationStructure = { identifier: string; expression: string; }; /** * Type Definition: `CategoryCodegenRefs` * * This type is derived from a Zod schema and represents * the validated structure of `CategoryCodegenRefs` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#categorycodegenrefs} */ type CategoryCodegenRefs = { refs: CategoryConfig['refs']; } | { refsExpression: string; }; /** * Type Definition: `CategoryCodegenConfig` * * This type is derived from a Zod schema and represents * the validated structure of `CategoryCodegenConfig` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#categorycodegenconfig} */ export type CategoryCodegenConfig = CategoryCodegenRefs & Pick; /** * Type Definition: `PluginCodegenResult` * * This type is derived from a Zod schema and represents * the validated structure of `PluginCodegenResult` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#plugincodegenresult} */ export type PluginCodegenResult = { imports: ImportDeclarationStructure[]; pluginDeclaration?: PluginDeclarationStructure; pluginInit: string[]; categories?: CategoryCodegenConfig[]; }; /** Minimal file system abstraction passed to plugin bindings. */ /** * Type Definition: `PluginSetupTree` * * This type is derived from a Zod schema and represents * the validated structure of `PluginSetupTree` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#pluginsetuptree} */ export type PluginSetupTree = { read: (path: string) => Promise; write: (path: string, content: string) => Promise; }; /** * Type Definition: `PluginCodegenInput` * * This type is derived from a Zod schema and represents * the validated structure of `PluginCodegenInput` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#plugincodegeninput} */ export type PluginCodegenInput = { answers: Record; tree: PluginSetupTree; targetDir: string; cliArgs: Record; }; /** * Defines how a plugin integrates with the setup wizard. * * Each supported plugin provides a binding that controls: * - Pre-selection: `isRecommended` detects if the plugin is relevant for the repository * - Configuration: `prompts` collect plugin-specific options interactively * - Code generation: `generateConfig` produces the import and initialization code */ /** * Type Definition: `PluginSetupBinding` * * This type is derived from a Zod schema and represents * the validated structure of `PluginSetupBinding` used within the application. * * @see {@link https://github.com/code-pushup/cli/blob/main/packages/models/docs/models-reference.md#pluginsetupbinding} */ export type PluginSetupBinding = { slug: PluginMeta['slug']; title: PluginMeta['title']; packageName: NonNullable; scope?: 'project' | 'root'; prompts?: (targetDir: string) => Promise; isRecommended?: (targetDir: string) => Promise; generateConfig: (input: PluginCodegenInput) => PluginCodegenResult | Promise; }; export {};