almost working installer updates

This commit is contained in:
Brian Madison
2025-12-07 15:38:49 -06:00
parent 38e65abd83
commit baaa984a90
9 changed files with 222 additions and 41 deletions

View File

@@ -275,10 +275,9 @@ class Detector {
hasV6Installation = true;
// Don't break - continue scanning to be thorough
} else {
// Not V6+, check if folder name contains "bmad" (case insensitive)
const nameLower = name.toLowerCase();
if (nameLower.includes('bmad')) {
// Potential V4 legacy folder
// Not V6+, check if this is the exact V4 folder name "bmad-method"
if (name === 'bmad-method') {
// This is the V4 default folder - flag it as legacy
potentialV4Folders.push(fullPath);
}
}

View File

@@ -22,11 +22,12 @@ const { getProjectRoot, getSourcePath, getModulePath } = require('../../../lib/p
* await manager.install('core-module', '/path/to/bmad');
*/
class ModuleManager {
constructor() {
constructor(options = {}) {
// Path to source modules directory
this.modulesSourcePath = getSourcePath('modules');
this.xmlHandler = new XmlHandler();
this.bmadFolderName = 'bmad'; // Default, can be overridden
this.scanProjectForModules = options.scanProjectForModules !== false; // Default to true for backward compatibility
}
/**
@@ -175,10 +176,11 @@ class ModuleManager {
/**
* List all available modules (excluding core which is always installed)
* @returns {Array} List of available modules with metadata
* @returns {Object} Object with modules array and customModules array
*/
async listAvailable() {
const modules = [];
const customModules = [];
// First, scan src/modules (the standard location)
if (await fs.pathExists(this.modulesSourcePath)) {
@@ -209,25 +211,31 @@ class ModuleManager {
}
}
// Then, find all other modules in the project
const otherModulePaths = await this.findModulesInProject();
for (const modulePath of otherModulePaths) {
const moduleName = path.basename(modulePath);
const relativePath = path.relative(getProjectRoot(), modulePath);
// Then, find all other modules in the project (only if scanning is enabled)
if (this.scanProjectForModules) {
const otherModulePaths = await this.findModulesInProject();
for (const modulePath of otherModulePaths) {
const moduleName = path.basename(modulePath);
const relativePath = path.relative(getProjectRoot(), modulePath);
// Skip core module - it's always installed first and not selectable
if (moduleName === 'core') {
continue;
}
// Skip core module - it's always installed first and not selectable
if (moduleName === 'core') {
continue;
}
const moduleInfo = await this.getModuleInfo(modulePath, moduleName, relativePath);
if (moduleInfo && !modules.some((m) => m.id === moduleInfo.id)) {
// Avoid duplicates - skip if we already have this module ID
modules.push(moduleInfo);
const moduleInfo = await this.getModuleInfo(modulePath, moduleName, relativePath);
if (moduleInfo && !modules.some((m) => m.id === moduleInfo.id) && !customModules.some((m) => m.id === moduleInfo.id)) {
// Avoid duplicates - skip if we already have this module ID
if (moduleInfo.isCustom) {
customModules.push(moduleInfo);
} else {
modules.push(moduleInfo);
}
}
}
}
return modules;
return { modules, customModules };
}
/**

View File

@@ -52,9 +52,6 @@ class UI {
await installer.handleLegacyV4Migration(confirmedDirectory, legacyV4);
}
// Prompt for custom content location (separate from installation directory)
const customContentConfig = await this.promptCustomContentLocation();
// Check if there's an existing BMAD installation
const fs = require('fs-extra');
const path = require('node:path');
@@ -62,6 +59,13 @@ class UI {
const bmadDir = await installer.findBmadDir(confirmedDirectory);
const hasExistingInstall = await fs.pathExists(bmadDir);
// Only ask for custom content if it's a NEW installation
let customContentConfig = { hasCustomContent: false };
if (!hasExistingInstall) {
// Prompt for custom content location (separate from installation directory)
customContentConfig = await this.promptCustomContentLocation();
}
// Track action type (only set if there's an existing installation)
let actionType;
@@ -88,12 +92,11 @@ class UI {
// Handle quick update separately
if (actionType === 'quick-update') {
// Even for quick update, ask about custom content
const customContentConfig = await this.promptCustomContentLocation();
// Quick update doesn't install custom content - just updates existing modules
return {
actionType: 'quick-update',
directory: confirmedDirectory,
customContent: customContentConfig,
customContent: { hasCustomContent: false },
};
}
@@ -511,11 +514,11 @@ class UI {
const moduleChoices = [];
const isNewInstallation = installedModuleIds.size === 0;
// Add custom content items first if found
if (customContentConfig && customContentConfig.hasCustomContent && customContentConfig.customPath) {
// Add separator before custom content
moduleChoices.push(new inquirer.Separator('── Custom Content ──'));
const customContentItems = [];
const hasCustomContentItems = false;
// Add custom content items from directory
if (customContentConfig && customContentConfig.hasCustomContent && customContentConfig.customPath) {
// Get the custom content info to display proper names
const { CustomHandler } = require('../installers/lib/custom/handler');
const customHandler = new CustomHandler();
@@ -524,29 +527,63 @@ class UI {
for (const customFile of customFiles) {
const customInfo = await customHandler.getCustomInfo(customFile);
if (customInfo) {
moduleChoices.push({
customContentItems.push({
name: `${chalk.cyan('✓')} ${customInfo.name} ${chalk.gray(`(${customInfo.relativePath})`)}`,
value: `__CUSTOM_CONTENT__${customFile}`, // Unique value for each custom content
checked: true, // Default to selected since user chose to provide custom content
path: customInfo.path, // Track path to avoid duplicates
});
}
}
// Add separator for official content
moduleChoices.push(new inquirer.Separator('── Official Content ──'));
}
// Add official modules
const { ModuleManager } = require('../installers/lib/modules/manager');
const moduleManager = new ModuleManager();
const availableModules = await moduleManager.listAvailable();
// Only scan project for modules if user selected custom content
const moduleManager = new ModuleManager({
scanProjectForModules: customContentConfig && customContentConfig.hasCustomContent && customContentConfig.selected,
});
const { modules: availableModules, customModules: customModulesFromProject } = await moduleManager.listAvailable();
// First, add all items to appropriate sections
const allCustomModules = [];
// Add custom content items from directory
allCustomModules.push(...customContentItems);
// Add custom modules from project scan (if scanning is enabled)
for (const mod of customModulesFromProject) {
// Skip if this module is already in customContentItems (by path)
const isDuplicate = allCustomModules.some((item) => item.path && mod.path && path.resolve(item.path) === path.resolve(mod.path));
if (!isDuplicate) {
allCustomModules.push({
name: `${chalk.cyan('✓')} ${mod.name} ${chalk.gray(`(${mod.source})`)}`,
value: mod.id,
checked: isNewInstallation ? mod.defaultSelected || false : installedModuleIds.has(mod.id),
});
}
}
// Add separators and modules in correct order
if (allCustomModules.length > 0) {
// Add separator for custom content, all custom modules, and official content separator
moduleChoices.push(
new inquirer.Separator('── Custom Content ──'),
...allCustomModules,
new inquirer.Separator('── Official Content ──'),
);
}
// Add official modules (only non-custom ones)
for (const mod of availableModules) {
moduleChoices.push({
name: mod.name,
value: mod.id,
checked: isNewInstallation ? mod.defaultSelected || false : installedModuleIds.has(mod.id),
});
if (!mod.isCustom) {
moduleChoices.push({
name: mod.name,
value: mod.id,
checked: isNewInstallation ? mod.defaultSelected || false : installedModuleIds.has(mod.id),
});
}
}
return moduleChoices;