feat: installer offers option to install web bundles

This commit is contained in:
Brian Madison
2025-06-17 09:55:21 -05:00
parent fe27d68319
commit e934769a5e
5 changed files with 1638 additions and 181 deletions

View File

@@ -289,6 +289,36 @@ async function promptInstallation() {
// Use selected IDEs directly
answers.ides = ides;
// Ask for web bundles installation
const { includeWebBundles } = await inquirer.prompt([
{
type: 'confirm',
name: 'includeWebBundles',
message: 'Would you like to include pre-built web bundles? (standalone agent/team files)',
default: true
}
]);
if (includeWebBundles) {
const { webBundlesDirectory } = await inquirer.prompt([
{
type: 'input',
name: 'webBundlesDirectory',
message: 'Enter directory for web bundles:',
default: `${directory}/web-bundles`,
validate: (input) => {
if (!input.trim()) {
return 'Please enter a valid directory path';
}
return true;
}
}
]);
answers.webBundlesDirectory = webBundlesDirectory;
}
answers.includeWebBundles = includeWebBundles;
return answers;
}

View File

@@ -115,6 +115,11 @@ class ConfigLoader {
return path.join(__dirname, '..', '..', '..', 'bmad-core');
}
getDistPath() {
// Get the path to dist directory relative to the installer
return path.join(__dirname, '..', '..', '..', 'dist');
}
getAgentPath(agentId) {
return path.join(this.getBmadCorePath(), 'agents', `${agentId}.md`);
}

View File

@@ -324,6 +324,12 @@ class Installer {
const expansionFiles = await this.installExpansionPacks(installDir, config.expansionPacks, spinner);
files.push(...expansionFiles);
// Install web bundles if requested
if (config.includeWebBundles && config.webBundlesDirectory) {
spinner.text = "Installing web bundles...";
await this.installWebBundles(config.webBundlesDirectory, spinner);
}
// Set up IDE integration if requested
const ides = config.ides || (config.ide ? [config.ide] : []);
if (ides.length > 0) {
@@ -573,6 +579,10 @@ class Installer {
console.log(chalk.green(`✓ Expansion packs installed: ${packNames}`));
}
if (config.includeWebBundles && config.webBundlesDirectory) {
console.log(chalk.green(`✓ Web bundles installed to: ${config.webBundlesDirectory}`));
}
if (ides.length > 0) {
const ideNames = ides.map(ide => {
const ideConfig = configLoader.getIdeConfiguration(ide);
@@ -582,11 +592,13 @@ class Installer {
}
// Information about web bundles
console.log(chalk.bold("\n📦 Web Bundles Available:"));
console.log("Pre-built web bundles are available in the project distribution:");
console.log(chalk.cyan(` ${path.join(path.dirname(installDir), 'dist')}/`));
console.log("These bundles work independently and can be shared, moved, or used");
console.log("in other projects as standalone files.");
if (!config.includeWebBundles) {
console.log(chalk.bold("\n📦 Web Bundles Available:"));
console.log("Pre-built web bundles are available and can be added later:");
console.log(chalk.cyan(" Run the installer again to add them to your project"));
console.log("These bundles work independently and can be shared, moved, or used");
console.log("in other projects as standalone files.");
}
if (config.installType === "single-agent") {
console.log(
@@ -797,6 +809,31 @@ class Installer {
return installedFiles;
}
async installWebBundles(webBundlesDirectory, spinner) {
// Ensure modules are initialized
await initializeModules();
try {
// Find the dist directory in the BMAD installation
const distDir = configLoader.getDistPath();
if (!(await fileManager.pathExists(distDir))) {
console.warn(chalk.yellow('Web bundles not found. Run "npm run build" to generate them.'));
return;
}
// Ensure web bundles directory exists
await fileManager.ensureDirectory(webBundlesDirectory);
// Copy the entire dist directory structure to web bundles directory
await fileManager.copyDirectory(distDir, webBundlesDirectory);
console.log(chalk.green(`✓ Installed web bundles to: ${webBundlesDirectory}`));
} catch (error) {
console.error(chalk.red(`Failed to install web bundles: ${error.message}`));
}
}
async findInstallation() {
// Look for .bmad-core in current directory or parent directories
let currentDir = process.cwd();