UNPKG

@elsikora/setup-wizard

Version:

Setup Wizard - CLI scaffolding utility

48 lines (45 loc) 1.78 kB
#!/usr/bin/env node import { AnalyzeCommand } from '../command/analyze.command.js'; import { InitCommand } from '../command/init.command.js'; import { ECommand } from '../enum/command.enum.js'; /** * Factory for creating command instances based on command type. * Implements the factory pattern for generating different command objects. */ class CommandFactory { /** CLI interface service for user interaction */ CLI_INTERFACE_SERVICE; /** File system service for file operations */ FILE_SYSTEM_SERVICE; /** * Initializes a new instance of the CommandFactory. * @param cliInterfaceService - Service for CLI user interactions * @param fileSystemService - Service for file system operations */ constructor(cliInterfaceService, fileSystemService) { this.CLI_INTERFACE_SERVICE = cliInterfaceService; this.FILE_SYSTEM_SERVICE = fileSystemService; } /** * Creates a command instance of the specified type. * @param name - The enum value representing the command to create * @param options - Command-specific options and arguments * @returns An instance of the specified command * @throws Error if the command type is unknown */ createCommand(name, options) { switch (name) { case ECommand.ANALYZE: { return new AnalyzeCommand(options, this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE); } case ECommand.INIT: { return new InitCommand(options, this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE); } default: { throw new Error(`Unknown command: ${name}`); } } } } export { CommandFactory }; //# sourceMappingURL=command.factory.js.map