UNPKG

@elsikora/setup-wizard

Version:

Setup Wizard - CLI scaffolding utility

53 lines (49 loc) 2.19 kB
#!/usr/bin/env node import { COMMAND_FLAG_CONFIG } from '../../application/constant/command-flag-config.constant.js'; import { CommandOptionsMapper } from '../../application/mapper/command-options.mapper.js'; import { ECommand } from '../../infrastructure/enum/command.enum.js'; /** * Registrar for the 'init' command. * Configures and registers the command that initializes project configuration files. */ class InitCommandRegistrar { /** The command factory used to create command instances */ COMMAND_FACTORY; /** The root Commander program instance */ PROGRAM; /** * Initializes a new instance of the InitCommandRegistrar. * @param program - The Commander program to attach the command to * @param commandFactory - Factory for creating command instances */ constructor(program, commandFactory) { this.PROGRAM = program; this.COMMAND_FACTORY = commandFactory; } /** * Configures and registers the 'init' command. * Sets up command description, options, and action handler. * @returns The configured Commander command instance */ execute() { const command = this.PROGRAM.command(ECommand.INIT).description(`Initialize project configuration files This command generates configuration files for your project based on selected options.`); for (const commandFlagConfig of Object.values(COMMAND_FLAG_CONFIG)) { command.option(`-${commandFlagConfig.shortFlag}, --${commandFlagConfig.fullFlag}`, commandFlagConfig.description); } command.option(`-a, --all`, "Enable all modules"); command.action(async (properties) => { const mapperProperties = CommandOptionsMapper.fromFlagToModule(properties); if (properties.all) { for (const key of Object.keys(mapperProperties)) { mapperProperties[key] = true; } } const command = this.COMMAND_FACTORY.createCommand(ECommand.INIT, mapperProperties); await command.execute(); }); return command; } } export { InitCommandRegistrar }; //# sourceMappingURL=init.registrar.js.map