UNPKG

@elsikora/setup-wizard

Version:

Setup Wizard - CLI scaffolding utility

114 lines (113 loc) 5.2 kB
import type { IModuleService } from "../../infrastructure/interface/module-service.interface"; import type { ICliInterfaceService } from "../interface/cli-interface-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"; /** * Service for setting up and managing Continuous Integration (CI) modules. * Handles the selection, configuration, and setup of CI workflows for different providers. */ export declare class CiModuleService implements IModuleService { /** CLI interface service for user interaction */ readonly CLI_INTERFACE_SERVICE: ICliInterfaceService; /** Configuration service for managing app configuration */ readonly CONFIG_SERVICE: IConfigService; /** File system service for file operations */ readonly FILE_SYSTEM_SERVICE: IFileSystemService; /** Cached CI configuration */ private config; /** Selected CI modules to install */ private selectedModules; /** Selected CI provider (e.g., GitHub) */ private selectedProvider?; /** * Initializes a new instance of the CiModuleService. * @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 CI setup files. * Checks for existing CI configuration files and asks for user confirmation if found. * @returns Promise resolving to true if setup should proceed, false otherwise */ handleExistingSetup(): Promise<boolean>; /** * Installs and configures selected CI modules. * Guides the user through selecting and configuring CI modules. * @returns Promise resolving to the module setup result */ install(): Promise<IModuleSetupResult>; /** * Determines if the CI module should be installed. * Asks the user if they want to set up CI workflows. * 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>; /** * Collects module-specific properties from the user. * @param module - The CI module to collect properties for * @param savedProperties - Previously saved properties for this module * @returns Promise resolving to a record of collected properties */ private collectModuleProperties; /** * Determines the type of CI module based on whether it's an NPM package. * @param isSavedNpmPackage - Whether the package was previously saved as an NPM package * @returns Promise resolving to the determined module type */ private determineModuleType; /** * Displays a summary of successful and failed CI module setups. * @param successful - Array of successfully set up modules * @param failed - Array of modules that failed to set up */ private displaySetupSummary; /** * Extracts module-specific properties from a module configuration. * @param moduleConfig - The module configuration object or boolean * @returns Record of module properties, or empty object if none found */ private extractModuleProperties; /** * Finds existing CI configuration files that might be overwritten. * @returns Promise resolving to an array of file paths for existing CI configurations */ private findExistingCiFiles; /** * Gets a human-readable description for a CI provider. * @param provider - The CI provider to get a description for * @returns Description string for the provider */ private getProviderDescription; /** * Selects compatible CI modules based on the module type and saved configuration. * @param moduleType - The type of CI module (NPM or non-NPM) * @param savedModules - Previously saved modules * @returns Promise resolving to an array of selected CI module enum values */ private selectCompatibleModules; /** * Prompts the user to select a CI provider. * @param savedProvider - Previously saved provider * @returns Promise resolving to the selected CI provider */ private selectProvider; /** * Sets up a specific CI module. * Creates necessary directories and configuration files. * @param module - The CI module to set up * @param properties - Module-specific properties to use in configuration * @returns Promise resolving to an object indicating success or failure */ private setupModule; /** * Sets up all selected CI modules. * Collects module properties and creates configuration files. * @param savedProperties - Previously saved module properties * @returns Promise resolving to a record of module properties */ private setupSelectedModules; }