@elsikora/setup-wizard
Version:
Setup Wizard - CLI scaffolding utility
179 lines • 8.29 kB
TypeScript
import type { IModuleService } from "../../infrastructure/interface/module-service.interface";
import type { ICliInterfaceService } from "../interface/cli-interface-service.interface";
import type { ICommandService } from "../interface/command-service.interface";
import type { IConfigService } from "../interface/config-service.interface";
import type { IConfigCommitlint } from "../interface/config/commitlint.interface";
import type { IFileSystemService } from "../interface/file-system-service.interface";
import type { IModuleSetupResult } from "../interface/module-setup-result.interface";
import { ECommitlintMode } from "../../domain/enum/commitlint-mode.enum";
import { ECommitlintProvider } from "../../domain/enum/commitlint-provider.enum";
import { ECommitlintTicketMissingBranchLintBehavior } from "../../domain/enum/commitlint-ticket-missing-branch-lint-behavior.enum";
import { ECommitlintTicketNormalization } from "../../domain/enum/commitlint-ticket-normalization.enum";
import { ECommitlintTicketSource } from "../../domain/enum/commitlint-ticket-source.enum";
import { PackageJsonService } from "./package-json.service";
/**
* Service for setting up and managing Commitlint and Commitizen configuration.
* Provides functionality to enforce consistent commit message formats using Commitlint
* and simplify commit creation using Commitizen.
*/
export declare class CommitlintModuleService implements IModuleService {
/** CLI interface service for user interaction */
readonly CLI_INTERFACE_SERVICE: ICliInterfaceService;
/** Command service for executing shell commands */
readonly COMMAND_SERVICE: ICommandService;
/** Configuration service for managing app configuration */
readonly CONFIG_SERVICE: IConfigService;
/** File system service for file operations */
readonly FILE_SYSTEM_SERVICE: IFileSystemService;
/** Service for managing package.json */
readonly PACKAGE_JSON_SERVICE: PackageJsonService;
/** Cached commitlint module configuration */
private config;
/**
* Initializes a new instance of the CommitlintModuleService.
* @param cliInterfaceService - Service for CLI user interactions
* @param fileSystemService - Service for file system operations
* @param configService - Service for managing app configuration
*/
constructor(cliInterfaceService: ICliInterfaceService, fileSystemService: IFileSystemService, configService: IConfigService);
/**
* Handles existing Commitlint/Commitizen setup.
* Checks for existing configuration files and asks if user wants to remove them.
* @returns Promise resolving to true if setup should proceed, false otherwise
*/
handleExistingSetup(): Promise<boolean>;
/**
* Installs and configures Commitlint and Commitizen.
* Sets up configuration files, git hooks, and package.json scripts.
* @returns Promise resolving to the module setup result
*/
install(): Promise<IModuleSetupResult>;
/**
* Reads generation model.
* @param defaultModel - Default model value
* @returns Promise resolving to configured model
*/
readGenerationModel(defaultModel: string): Promise<string>;
/**
* Reads retry count with range validation.
* @param prompt - Prompt message
* @param errorPrompt - Error message
* @param defaultValue - Default retry value
* @returns Promise resolving to retry count
*/
readRetryCount(prompt: string, errorPrompt: string, defaultValue: number): Promise<number>;
/**
* Reads regex pattern for ticket extraction.
* @param defaultPattern - Default regex pattern
* @returns Promise resolving to configured regex pattern
*/
readTicketPattern(defaultPattern: string): Promise<string>;
/**
* Reads regex flags for ticket pattern.
* @param defaultPatternFlags - Default regex flags
* @returns Promise resolving to configured regex flags
*/
readTicketPatternFlags(defaultPatternFlags: string): Promise<string>;
/**
* Resolves commitlint-ai settings using config defaults and setup prompts.
* @returns Promise resolving to effective commitlint-ai settings
*/
resolveCommitlintAiConfig(): Promise<IConfigCommitlint>;
/**
* Selects generation mode.
* @param defaultMode - Default mode value
* @returns Promise resolving to selected mode
*/
selectGenerationMode(defaultMode: ECommitlintMode): Promise<ECommitlintMode>;
/**
* Selects generation provider.
* @param defaultProvider - Default provider value
* @returns Promise resolving to selected provider
*/
selectGenerationProvider(defaultProvider: ECommitlintProvider): Promise<ECommitlintProvider>;
/**
* Selects missing branch-lint behavior.
* @param defaultBehavior - Default behavior
* @returns Promise resolving to selected behavior
*/
selectMissingBranchLintBehavior(defaultBehavior: ECommitlintTicketMissingBranchLintBehavior): Promise<ECommitlintTicketMissingBranchLintBehavior>;
/**
* Selects ticket normalization mode.
* @param defaultNormalization - Default normalization mode
* @returns Promise resolving to selected normalization mode
*/
selectTicketNormalization(defaultNormalization: ECommitlintTicketNormalization): Promise<ECommitlintTicketNormalization>;
/**
* Selects ticket source strategy.
* @param defaultSource - Default source strategy
* @returns Promise resolving to selected source strategy
*/
selectTicketSource(defaultSource: ECommitlintTicketSource): Promise<ECommitlintTicketSource>;
/**
* Determines whether commit command script should be added.
* @returns Promise resolving to true when commit command should be added
*/
shouldEnableCommitCommand(): Promise<boolean>;
/**
* Determines whether ticket extraction should be enabled.
* @param defaultSource - Default ticket source
* @returns Promise resolving to true when ticket extraction should be enabled
*/
shouldEnableTicketIntegration(defaultSource: ECommitlintTicketSource): Promise<boolean>;
/**
* Determines if Commitlint/Commitizen should be installed.
* Asks the user if they want to set up these tools for their project.
* Uses the saved config value as default if it exists.
* @returns Promise resolving to true if the module should be installed, false otherwise
*/
shouldInstall(): Promise<boolean>;
/**
* Creates the Commitlint configuration file.
* @param commitlintAiConfig - Commitlint AI configuration
*/
private createConfigs;
/**
* Displays a summary of the setup results.
* @param commitlintAiConfig - Commitlint AI configuration
* @param isCommitCommandEnabled - Whether commit command was enabled
*/
private displaySetupSummary;
/**
* Finds existing Commitlint/Commitizen configuration files.
* @returns Promise resolving to an array of file paths for existing configuration files
*/
private findExistingConfigFiles;
/**
* Builds commitlint-ai config with defaults merged from setup-wizard config.
* @returns Defaulted commitlint-ai config
*/
private getDefaultCommitlintAiConfig;
/**
* Returns default model for selected provider.
* @param provider - Selected provider
* @returns Default model name
*/
private getDefaultModelByProvider;
/**
* Sets up Commitlint and Commitizen.
* Installs dependencies, creates configuration files, and configures git hooks.
* @param commitlintAiConfig - Commitlint AI configuration
* @param isCommitCommandEnabled - Whether commit command should be configured
*/
private setupCommitlint;
/**
* Sets up Husky git hooks.
* Initializes Husky, adds prepare script, and creates commit-msg and pre-push hooks.
*/
private setupHusky;
/**
* Sets up Commitizen configuration in package.json.
*/
private setupPackageJsonConfigs;
/**
* Sets up npm scripts for Commitizen.
* Adds 'commit' script for starting the Commitizen CLI.
*/
private setupScripts;
}
//# sourceMappingURL=commitlint-module.service.d.ts.map