refactor: hoist CustomHandler require to top of installer.js and ui.js
This commit is contained in:
parent
4d4290a71f
commit
6718475f16
|
|
@ -39,6 +39,7 @@ const { CLIUtils } = require('../../../lib/cli-utils');
|
||||||
const { ManifestGenerator } = require('./manifest-generator');
|
const { ManifestGenerator } = require('./manifest-generator');
|
||||||
const { IdeConfigManager } = require('./ide-config-manager');
|
const { IdeConfigManager } = require('./ide-config-manager');
|
||||||
const { replaceAgentSidecarFolders } = require('./post-install-sidecar-replacement');
|
const { replaceAgentSidecarFolders } = require('./post-install-sidecar-replacement');
|
||||||
|
const { CustomHandler } = require('../custom/handler');
|
||||||
|
|
||||||
class Installer {
|
class Installer {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -440,7 +441,6 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
|
||||||
|
|
||||||
// Handle selectedFiles (from existing install path or manual directory input)
|
// Handle selectedFiles (from existing install path or manual directory input)
|
||||||
if (config.customContent && config.customContent.selected && config.customContent.selectedFiles) {
|
if (config.customContent && config.customContent.selected && config.customContent.selectedFiles) {
|
||||||
const { CustomHandler } = require('../custom/handler');
|
|
||||||
const customHandler = new CustomHandler();
|
const customHandler = new CustomHandler();
|
||||||
for (const customFile of config.customContent.selectedFiles) {
|
for (const customFile of config.customContent.selectedFiles) {
|
||||||
const customInfo = await customHandler.getCustomInfo(customFile, path.resolve(config.directory));
|
const customInfo = await customHandler.getCustomInfo(customFile, path.resolve(config.directory));
|
||||||
|
|
@ -837,9 +837,8 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
|
||||||
// Regular custom content from user input (non-cached)
|
// Regular custom content from user input (non-cached)
|
||||||
if (finalCustomContent && finalCustomContent.selected && finalCustomContent.selectedFiles) {
|
if (finalCustomContent && finalCustomContent.selected && finalCustomContent.selectedFiles) {
|
||||||
// Add custom modules to the installation list
|
// Add custom modules to the installation list
|
||||||
|
const customHandler = new CustomHandler();
|
||||||
for (const customFile of finalCustomContent.selectedFiles) {
|
for (const customFile of finalCustomContent.selectedFiles) {
|
||||||
const { CustomHandler } = require('../custom/handler');
|
|
||||||
const customHandler = new CustomHandler();
|
|
||||||
const customInfo = await customHandler.getCustomInfo(customFile, projectDir);
|
const customInfo = await customHandler.getCustomInfo(customFile, projectDir);
|
||||||
if (customInfo && customInfo.id) {
|
if (customInfo && customInfo.id) {
|
||||||
allModules.push(customInfo.id);
|
allModules.push(customInfo.id);
|
||||||
|
|
@ -929,7 +928,6 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
|
||||||
|
|
||||||
// Finally check regular custom content
|
// Finally check regular custom content
|
||||||
if (!isCustomModule && finalCustomContent && finalCustomContent.selected && finalCustomContent.selectedFiles) {
|
if (!isCustomModule && finalCustomContent && finalCustomContent.selected && finalCustomContent.selectedFiles) {
|
||||||
const { CustomHandler } = require('../custom/handler');
|
|
||||||
const customHandler = new CustomHandler();
|
const customHandler = new CustomHandler();
|
||||||
for (const customFile of finalCustomContent.selectedFiles) {
|
for (const customFile of finalCustomContent.selectedFiles) {
|
||||||
const info = await customHandler.getCustomInfo(customFile, projectDir);
|
const info = await customHandler.getCustomInfo(customFile, projectDir);
|
||||||
|
|
@ -943,7 +941,6 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
|
||||||
|
|
||||||
if (isCustomModule && customInfo) {
|
if (isCustomModule && customInfo) {
|
||||||
// Install custom module using CustomHandler but as a proper module
|
// Install custom module using CustomHandler but as a proper module
|
||||||
const { CustomHandler } = require('../custom/handler');
|
|
||||||
const customHandler = new CustomHandler();
|
const customHandler = new CustomHandler();
|
||||||
|
|
||||||
// Install to module directory instead of custom directory
|
// Install to module directory instead of custom directory
|
||||||
|
|
@ -1086,9 +1083,8 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
|
||||||
config.customContent.selectedFiles
|
config.customContent.selectedFiles
|
||||||
) {
|
) {
|
||||||
// Filter out custom modules that were already installed
|
// Filter out custom modules that were already installed
|
||||||
|
const customHandler = new CustomHandler();
|
||||||
for (const customFile of config.customContent.selectedFiles) {
|
for (const customFile of config.customContent.selectedFiles) {
|
||||||
const { CustomHandler } = require('../custom/handler');
|
|
||||||
const customHandler = new CustomHandler();
|
|
||||||
const customInfo = await customHandler.getCustomInfo(customFile, projectDir);
|
const customInfo = await customHandler.getCustomInfo(customFile, projectDir);
|
||||||
|
|
||||||
// Skip if this was installed as a module
|
// Skip if this was installed as a module
|
||||||
|
|
@ -1100,7 +1096,6 @@ If AgentVibes party mode is enabled, immediately trigger TTS with agent's voice:
|
||||||
|
|
||||||
if (remainingCustomContent.length > 0) {
|
if (remainingCustomContent.length > 0) {
|
||||||
spinner.start('Installing remaining custom content...');
|
spinner.start('Installing remaining custom content...');
|
||||||
const { CustomHandler } = require('../custom/handler');
|
|
||||||
const customHandler = new CustomHandler();
|
const customHandler = new CustomHandler();
|
||||||
|
|
||||||
// Use the remaining files
|
// Use the remaining files
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ const path = require('node:path');
|
||||||
const os = require('node:os');
|
const os = require('node:os');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const { CLIUtils } = require('./cli-utils');
|
const { CLIUtils } = require('./cli-utils');
|
||||||
|
const { CustomHandler } = require('../installers/lib/custom/handler');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UI utilities for the installer
|
* UI utilities for the installer
|
||||||
|
|
@ -150,7 +151,6 @@ class UI {
|
||||||
const { CustomModuleCache } = require('../installers/lib/core/custom-module-cache');
|
const { CustomModuleCache } = require('../installers/lib/core/custom-module-cache');
|
||||||
const cache = new CustomModuleCache(bmadDir);
|
const cache = new CustomModuleCache(bmadDir);
|
||||||
|
|
||||||
const { CustomHandler } = require('../installers/lib/custom/handler');
|
|
||||||
const customHandler = new CustomHandler();
|
const customHandler = new CustomHandler();
|
||||||
const customFiles = await customHandler.findCustomContent(customContentConfig.customPath);
|
const customFiles = await customHandler.findCustomContent(customContentConfig.customPath);
|
||||||
|
|
||||||
|
|
@ -218,7 +218,6 @@ class UI {
|
||||||
customContentConfig.selectedFiles = selectedCustomContent.map((mod) => mod.replace('__CUSTOM_CONTENT__', ''));
|
customContentConfig.selectedFiles = selectedCustomContent.map((mod) => mod.replace('__CUSTOM_CONTENT__', ''));
|
||||||
// Convert custom content to module IDs for installation
|
// Convert custom content to module IDs for installation
|
||||||
const customContentModuleIds = [];
|
const customContentModuleIds = [];
|
||||||
const { CustomHandler } = require('../installers/lib/custom/handler');
|
|
||||||
const customHandler = new CustomHandler();
|
const customHandler = new CustomHandler();
|
||||||
for (const customFile of customContentConfig.selectedFiles) {
|
for (const customFile of customContentConfig.selectedFiles) {
|
||||||
// Get the module info to extract the ID
|
// Get the module info to extract the ID
|
||||||
|
|
@ -659,7 +658,6 @@ class UI {
|
||||||
}
|
}
|
||||||
} else if (customContentConfig.customPath) {
|
} else if (customContentConfig.customPath) {
|
||||||
// Existing installation - show from directory
|
// Existing installation - show from directory
|
||||||
const { CustomHandler } = require('../installers/lib/custom/handler');
|
|
||||||
const customHandler = new CustomHandler();
|
const customHandler = new CustomHandler();
|
||||||
const customFiles = await customHandler.findCustomContent(customContentConfig.customPath);
|
const customFiles = await customHandler.findCustomContent(customContentConfig.customPath);
|
||||||
|
|
||||||
|
|
@ -874,7 +872,6 @@ class UI {
|
||||||
expandedPath = this.expandUserPath(directory.trim());
|
expandedPath = this.expandUserPath(directory.trim());
|
||||||
|
|
||||||
// Check if directory has custom content
|
// Check if directory has custom content
|
||||||
const { CustomHandler } = require('../installers/lib/custom/handler');
|
|
||||||
const customHandler = new CustomHandler();
|
const customHandler = new CustomHandler();
|
||||||
const customFiles = await customHandler.findCustomContent(expandedPath);
|
const customFiles = await customHandler.findCustomContent(expandedPath);
|
||||||
|
|
||||||
|
|
@ -1269,7 +1266,6 @@ class UI {
|
||||||
const resolvedPath = CLIUtils.expandPath(customPath);
|
const resolvedPath = CLIUtils.expandPath(customPath);
|
||||||
|
|
||||||
// Find custom content
|
// Find custom content
|
||||||
const { CustomHandler } = require('../installers/lib/custom/handler');
|
|
||||||
const customHandler = new CustomHandler();
|
const customHandler = new CustomHandler();
|
||||||
const customFiles = await customHandler.findCustomContent(resolvedPath);
|
const customFiles = await customHandler.findCustomContent(resolvedPath);
|
||||||
|
|
||||||
|
|
@ -1294,12 +1290,10 @@ class UI {
|
||||||
|
|
||||||
// Display found items
|
// Display found items
|
||||||
console.log(chalk.cyan(`\nFound ${customFiles.length} custom content file(s):`));
|
console.log(chalk.cyan(`\nFound ${customFiles.length} custom content file(s):`));
|
||||||
const { CustomHandler: CustomHandler2 } = require('../installers/lib/custom/handler');
|
|
||||||
const customHandler2 = new CustomHandler2();
|
|
||||||
const customContentItems = [];
|
const customContentItems = [];
|
||||||
|
|
||||||
for (const customFile of customFiles) {
|
for (const customFile of customFiles) {
|
||||||
const customInfo = await customHandler2.getCustomInfo(customFile);
|
const customInfo = await customHandler.getCustomInfo(customFile);
|
||||||
if (customInfo) {
|
if (customInfo) {
|
||||||
customContentItems.push({
|
customContentItems.push({
|
||||||
name: `${chalk.cyan('✓')} ${customInfo.name} ${chalk.gray(`(${customInfo.relativePath})`)}`,
|
name: `${chalk.cyan('✓')} ${customInfo.name} ${chalk.gray(`(${customInfo.relativePath})`)}`,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue