UNPKG

@elsikora/setup-wizard

Version:

Setup Wizard - CLI scaffolding utility

105 lines (102 loc) 5.8 kB
#!/usr/bin/env node import { BranchLintModuleService } from '../../application/service/branch-lint-module.service.js'; import { BuilderModuleService } from '../../application/service/builder-module.service.js'; import { CiModuleService } from '../../application/service/ci-module.service.js'; import { CommitlintModuleService } from '../../application/service/commitlint-module.service.js'; import { EslintModuleService } from '../../application/service/eslint-module.service.js'; import { GitignoreModuleService } from '../../application/service/gitignore-module.service.js'; import { IdeModuleService } from '../../application/service/ide-module.service.js'; import { LicenseModuleService } from '../../application/service/license-module.service.js'; import { LintStagedModuleService } from '../../application/service/lint-staged-module.service.js'; import { PrettierModuleService } from '../../application/service/prettier-module.service.js'; import { PrlintModuleService } from '../../application/service/prlint-module.service.js'; import { SemanticReleaseModuleService } from '../../application/service/semantic-release-module.service.js'; import { StylelintModuleService } from '../../application/service/stylelint-module.service.js'; import { TestingModuleService } from '../../application/service/testing-module.service.js'; import { TypescriptModuleService } from '../../application/service/typescript-module.service.js'; import { EModule } from '../../domain/enum/module.enum.js'; import { CosmicConfigService } from '../service/cosmi-config-config.service.js'; /** * Mapper class for creating module service instances based on module type. * Provides a central factory for all available module services in the application. */ class ModuleServiceMapper { /** CLI interface service for user interaction */ CLI_INTERFACE_SERVICE; /** Configuration service for reading and writing config */ CONFIG_SERVICE; /** File system service for file operations */ FILE_SYSTEM_SERVICE; /** * Initializes a new instance of the ModuleServiceMapper. * @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; this.CONFIG_SERVICE = new CosmicConfigService(fileSystemService); } /** * Gets a module service instance based on the specified module type. * Factory method that creates the appropriate service implementation. * @param module - The module type enum value * @returns An implementation of IModuleService for the specified module * @throws Error if the module type is not supported */ getModuleService(module) { // eslint-disable-next-line @elsikora/unicorn/prefer-module switch (module) { case EModule.BRANCH_LINT: { return new BranchLintModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.BUILDER: { return new BuilderModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.CI: { return new CiModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.COMMITLINT: { return new CommitlintModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.ESLINT: { return new EslintModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.GITIGNORE: { return new GitignoreModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.IDE: { return new IdeModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.LICENSE: { return new LicenseModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.LINT_STAGED: { return new LintStagedModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.PRETTIER: { return new PrettierModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.PRLINT: { return new PrlintModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.SEMANTIC_RELEASE: { return new SemanticReleaseModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.STYLELINT: { return new StylelintModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.TESTING: { return new TestingModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } case EModule.TYPESCRIPT: { return new TypescriptModuleService(this.CLI_INTERFACE_SERVICE, this.FILE_SYSTEM_SERVICE, this.CONFIG_SERVICE); } default: { throw new Error(`Module ${module} is not supported`); } } } } export { ModuleServiceMapper }; //# sourceMappingURL=module-service.mapper.js.map