diff --git a/tools/cli/installers/lib/core/installer.js b/tools/cli/installers/lib/core/installer.js index b84e2dd65..ab3f0b3e5 100644 --- a/tools/cli/installers/lib/core/installer.js +++ b/tools/cli/installers/lib/core/installer.js @@ -15,18 +15,11 @@ const { CustomHandler } = require('../custom-handler'); const prompts = require('../../../lib/prompts'); const { BMAD_FOLDER_NAME } = require('../ide/shared/path-utils'); const { InstallPaths } = require('./install-paths'); - -let _externalManager; -function getExternalManager() { - if (!_externalManager) { - const { ExternalModuleManager } = require('../modules/external-manager'); - _externalManager = new ExternalModuleManager(); - } - return _externalManager; -} +const { ExternalModuleManager } = require('../modules/external-manager'); class Installer { constructor() { + this.externalModuleManager = new ExternalModuleManager(); this.detector = new Detector(); this.manifest = new Manifest(); this.moduleManager = new ModuleManager(); @@ -213,7 +206,7 @@ class Installer { } // Check if this is an external official module - skip cache for those - const isExternal = await getExternalManager().hasModule(moduleId); + const isExternal = await this.externalModuleManager.hasModule(moduleId); if (isExternal) { // External modules are handled via cloneExternalModule, not from cache continue; @@ -297,7 +290,7 @@ class Installer { } // Check if this is an external official module - skip cache for those - const isExternal = await getExternalManager().hasModule(moduleId); + const isExternal = await this.externalModuleManager.hasModule(moduleId); if (isExternal) { // External modules are handled via cloneExternalModule, not from cache continue; @@ -1843,7 +1836,7 @@ class Installer { } // Check if this is an external official module - skip cache for those - const isExternal = await getExternalManager().hasModule(moduleId); + const isExternal = await this.externalModuleManager.hasModule(moduleId); if (isExternal) { // External modules are handled via cloneExternalModule, not from cache continue; @@ -2069,7 +2062,7 @@ class Installer { } // Check if this is an external official module - skip cache for those - const isExternal = await getExternalManager().hasModule(moduleId); + const isExternal = await this.externalModuleManager.hasModule(moduleId); if (isExternal) { // External modules are handled via cloneExternalModule, not from cache continue; diff --git a/tools/cli/installers/lib/modules/manager.js b/tools/cli/installers/lib/modules/manager.js index 4bbc1e947..e862df93a 100644 --- a/tools/cli/installers/lib/modules/manager.js +++ b/tools/cli/installers/lib/modules/manager.js @@ -3,32 +3,11 @@ const fs = require('fs-extra'); const yaml = require('yaml'); const prompts = require('../../../lib/prompts'); const { getProjectRoot, getSourcePath, getModulePath } = require('../../../lib/project-root'); +const { ExternalModuleManager } = require('./external-manager'); -let _externalManager; -function getExternalManager() { - if (!_externalManager) { - const { ExternalModuleManager } = require('./external-manager'); - _externalManager = new ExternalModuleManager(); - } - return _externalManager; -} - -/** - * Manages the installation, updating, and removal of BMAD modules. - * Handles module discovery, dependency resolution, and configuration processing. - * - * @class ModuleManager - * @requires fs-extra - * @requires yaml - * @requires prompts - * - * @example - * const manager = new ModuleManager(); - * const modules = await manager.listAvailable(); - * await manager.install('core-module', '/path/to/bmad'); - */ class ModuleManager { constructor(options = {}) { + this.externalModuleManager = new ExternalModuleManager(); this.customModulePaths = new Map(); } @@ -178,7 +157,7 @@ class ModuleManager { } // Check external official modules - const externalSource = await getExternalManager().findExternalModuleSource(moduleCode, options); + const externalSource = await this.externalModuleManager.findExternalModuleSource(moduleCode, options); if (externalSource) { return externalSource; }