UNPKG

@elsikora/setup-wizard

Version:

Setup Wizard - CLI scaffolding utility

82 lines (81 loc) 4.03 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 generating and managing LICENSE files for projects. * Provides functionality to select a license type, generate the LICENSE file, * and update the package.json with license information. */ export declare class LicenseModuleService 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 License configuration */ private config; /** * Initializes a new instance of the LicenseModuleService. * @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 license setup. * Checks for existing license files and asks if user wants to replace them. * @returns Promise resolving to true if setup should proceed, false otherwise */ handleExistingSetup(): Promise<boolean>; /** * Installs and configures a LICENSE file. * Guides the user through selecting a license type and generating the file. * @returns Promise resolving to the module setup result */ install(): Promise<IModuleSetupResult>; /** * Determines if the LICENSE module should be installed. * Asks the user if they want to generate a LICENSE file 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 a LICENSE file with the selected license type and author information. * Also updates the package.json license field. * @param license - The selected license type * @param savedAuthor - Previously saved author name, if any * @returns Promise resolving to an object containing the author name */ private createLicenseFile; /** * Displays a summary of the LICENSE setup results. * Lists details about the generated license file. * @param isSuccess - Whether the setup was successful * @param license - The selected license type, if successful * @param author - The copyright holder's name, if successful * @param error - Optional error if setup failed */ private displaySetupSummary; /** * Generates a new LICENSE file. * @param savedConfig - Previously saved license configuration, if any * @returns Promise resolving to an object indicating success or failure with optional license, author, and error details */ private generateNewLicense; /** * Prompts the user to select a license type for their project. * @param savedLicense - Previously saved license type, if any * @returns Promise resolving to the selected license enum value */ private selectLicense; }