@elsikora/setup-wizard
Version:
Setup Wizard - CLI scaffolding utility
129 lines (128 loc) • 6.02 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 { 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 semantic-release configuration.
* Provides functionality to automate version management and package publishing
* based on commit messages following conventional commits standard.
*/
export declare class SemanticReleaseModuleService 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 semantic-release configuration */
private config;
/**
* Initializes a new instance of the SemanticReleaseModuleService.
* @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 semantic-release 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 semantic-release.
* Guides the user through setting up automated versioning and publishing.
* @returns Promise resolving to the module setup result
*/
install(): Promise<IModuleSetupResult>;
/**
* Determines if semantic-release should be installed.
* Asks the user if they want to set up automated versioning and publishing.
* 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 semantic-release configuration files.
* Generates the config file with repository URL and branch settings.
* @param repositoryUrl - The repository URL for semantic-release
* @param mainBranch - The main branch for production releases
* @param preReleaseBranch - Optional branch for pre-releases
* @param preReleaseChannel - Optional channel name for pre-releases
* @param isBackmergeEnabled - Optional flag to enable backmerge to development branch
* @param developBranch - Optional development branch name for backmerge
*/
private createConfigs;
/**
* Displays a summary of the semantic-release setup results.
* Lists configured branches, scripts, and usage instructions.
* @param mainBranch - The main branch for production releases
* @param preReleaseBranch - Optional branch for pre-releases
* @param preReleaseChannel - Optional channel name for pre-releases
* @param isBackmergeEnabled - Optional flag indicating if backmerge is enabled
* @param developBranch - Optional development branch name for backmerge
*/
private displaySetupSummary;
/**
* Finds existing semantic-release configuration files.
* @returns Promise resolving to an array of file paths for existing configuration files
*/
private findExistingConfigFiles;
/**
* Prompts the user for the development branch name for backmerge.
* @returns Promise resolving to the development branch name
*/
private getDevelopBranch;
/**
* Prompts the user for the main release branch name.
* @returns Promise resolving to the main branch name
*/
private getMainBranch;
/**
* Prompts the user for the pre-release branch name.
* @returns Promise resolving to the pre-release branch name
*/
private getPreReleaseBranch;
/**
* Prompts the user for the pre-release channel name.
* @returns Promise resolving to the pre-release channel name
*/
private getPreReleaseChannel;
/**
* Gets the repository URL for semantic-release.
* Attempts to detect URL from package.json before prompting the user.
* @returns Promise resolving to the repository URL
*/
private getRepositoryUrl;
/**
* Prompts the user if they want to enable backmerge to development branch.
* Only applicable for the main branch.
* @param mainBranch - The main branch name
* @returns Promise resolving to true if backmerge should be enabled, false otherwise
*/
private isBackmergeEnabled;
/**
* Prompts the user if they want to enable pre-release channels.
* @returns Promise resolving to true if pre-release should be enabled, false otherwise
*/
private isPrereleaseEnabledChannel;
/**
* Sets up npm scripts for semantic-release.
* Adds scripts for running semantic-release and CI processes.
*/
private setupScripts;
/**
* Sets up semantic-release configuration.
* Collects user input, installs dependencies, creates config files,
* and sets up scripts.
* @returns Promise resolving to an object containing setup parameters
*/
private setupSemanticRelease;
}