UNPKG

@elsikora/setup-wizard

Version:

Setup Wizard - CLI scaffolding utility

83 lines (82 loc) 3.7 kB
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 { IFileSystemService } from "../interface/file-system-service.interface"; import type { IModuleSetupResult } from "../interface/module-setup-result.interface"; 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; /** * 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>; /** * 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. */ private createConfigs; /** * Displays a summary of the setup results. */ private displaySetupSummary; /** * Finds existing Commitlint/Commitizen configuration files. * @returns Promise resolving to an array of file paths for existing configuration files */ private findExistingConfigFiles; /** * Sets up Commitlint and Commitizen. * Installs dependencies, creates configuration files, and configures git hooks. */ 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; }