customize installation folder for the bmad content

This commit is contained in:
Brian Madison
2025-11-08 15:19:19 -06:00
parent 1728acfb0f
commit fd2521ec69
6 changed files with 242 additions and 58 deletions

View File

@@ -18,6 +18,15 @@ class BaseIdeSetup {
this.configFile = null; // Override in subclasses when detection is file-based
this.detectionPaths = []; // Additional paths that indicate the IDE is configured
this.xmlHandler = new XmlHandler();
this.bmadFolderName = 'bmad'; // Default, can be overridden
}
/**
* Set the bmad folder name for placeholder replacement
* @param {string} bmadFolderName - The bmad folder name
*/
setBmadFolderName(bmadFolderName) {
this.bmadFolderName = bmadFolderName;
}
/**
@@ -489,23 +498,52 @@ class BaseIdeSetup {
}
/**
* Write file with content
* Write file with content (replaces {bmad_folder} placeholder)
* @param {string} filePath - File path
* @param {string} content - File content
*/
async writeFile(filePath, content) {
// Replace {bmad_folder} placeholder if present
if (typeof content === 'string' && content.includes('{bmad_folder}')) {
content = content.replaceAll('{bmad_folder}', this.bmadFolderName);
}
await this.ensureDir(path.dirname(filePath));
await fs.writeFile(filePath, content, 'utf8');
}
/**
* Copy file from source to destination
* Copy file from source to destination (replaces {bmad_folder} placeholder in text files)
* @param {string} source - Source file path
* @param {string} dest - Destination file path
*/
async copyFile(source, dest) {
// List of text file extensions that should have placeholder replacement
const textExtensions = ['.md', '.yaml', '.yml', '.txt', '.json', '.js', '.ts', '.html', '.css', '.sh', '.bat', '.csv'];
const ext = path.extname(source).toLowerCase();
await this.ensureDir(path.dirname(dest));
await fs.copy(source, dest, { overwrite: true });
// Check if this is a text file that might contain placeholders
if (textExtensions.includes(ext)) {
try {
// Read the file content
let content = await fs.readFile(source, 'utf8');
// Replace {bmad_folder} placeholder with actual folder name
if (content.includes('{bmad_folder}')) {
content = content.replaceAll('{bmad_folder}', this.bmadFolderName);
}
// Write to dest with replaced content
await fs.writeFile(dest, content, 'utf8');
} catch {
// If reading as text fails, fall back to regular copy
await fs.copy(source, dest, { overwrite: true });
}
} else {
// Binary file or other file type - just copy directly
await fs.copy(source, dest, { overwrite: true });
}
}
/**

View File

@@ -10,6 +10,21 @@ class IdeManager {
constructor() {
this.handlers = new Map();
this.loadHandlers();
this.bmadFolderName = 'bmad'; // Default, can be overridden
}
/**
* Set the bmad folder name for all IDE handlers
* @param {string} bmadFolderName - The bmad folder name
*/
setBmadFolderName(bmadFolderName) {
this.bmadFolderName = bmadFolderName;
// Update all loaded handlers
for (const handler of this.handlers.values()) {
if (typeof handler.setBmadFolderName === 'function') {
handler.setBmadFolderName(bmadFolderName);
}
}
}
/**