@elsikora/commitizen-plugin-commitlint-ai
Version:
AI-powered Commitizen adapter with Commitlint integration
46 lines (45 loc) • 2.12 kB
TypeScript
import type { ICliInterfaceService } from '../../application/interface/cli-interface-service.interface';
import type { ICommandService } from '../../application/interface/command-service.interface';
/**
* Implementation of the command service using Node.js child_process.
* Provides functionality to execute shell commands.
*/
export declare class NodeCommandService implements ICommandService {
/** CLI interface service for user interaction */
readonly CLI_INTERFACE_SERVICE: ICliInterfaceService;
/**
* Promisified version of the exec function from child_process.
* Allows for async/await usage of command execution.
*/
private readonly EXEC_ASYNC;
/**
* @param {ICliInterfaceService} cliInterfaceService - The CLI interface service for user interactions
*/
constructor(cliInterfaceService: ICliInterfaceService);
/**
* Executes a shell command.
* @param {string} command - The shell command to execute
* @returns {Promise<void>} Promise that resolves when the command completes successfully
* @throws Will throw an error if the command execution fails, except for npm install which offers retry options
*/
execute(command: string): Promise<void>;
/**
* Execute a command and return its output
* @param {string} command - The command to execute
* @returns {Promise<string>} Promise that resolves to the command output
*/
executeWithOutput(command: string): Promise<string>;
/**
* Format and parse npm error to readable format
* @param {string} command - The original npm command that failed
* @param {INodeError} error - Error npm object
*/
private formatAndParseNpmError;
/**
* Handles npm install command failures by offering retry options to the user.
* @param {string} originalCommand - The original npm command that failed
* @returns {Promise<void>} Promise that resolves when the chosen action completes
* @throws Will throw an error if the user chooses to cancel or if retried command still fails
*/
private handleNpmInstallFailure;
}