2025-09-28 23:17:07 -05:00
|
|
|
const chalk = require('chalk');
|
|
|
|
|
const path = require('node:path');
|
|
|
|
|
const { Installer } = require('../installers/lib/core/installer');
|
|
|
|
|
const { UI } = require('../lib/ui');
|
|
|
|
|
|
|
|
|
|
const installer = new Installer();
|
|
|
|
|
const ui = new UI();
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
command: 'install',
|
|
|
|
|
description: 'Install BMAD Core agents and tools',
|
|
|
|
|
options: [],
|
|
|
|
|
action: async () => {
|
|
|
|
|
try {
|
|
|
|
|
const config = await ui.promptInstall();
|
2025-10-02 21:45:59 -05:00
|
|
|
|
2025-10-28 12:47:45 -05:00
|
|
|
// Handle cancel
|
|
|
|
|
if (config.actionType === 'cancel') {
|
|
|
|
|
console.log(chalk.yellow('Installation cancelled.'));
|
|
|
|
|
process.exit(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-02 21:45:59 -05:00
|
|
|
// Handle agent compilation separately
|
|
|
|
|
if (config.actionType === 'compile') {
|
|
|
|
|
const result = await installer.compileAgents(config);
|
|
|
|
|
console.log(chalk.green('\n✨ Agent compilation complete!'));
|
|
|
|
|
console.log(chalk.cyan(`Rebuilt ${result.agentCount} agents and ${result.taskCount} tasks`));
|
|
|
|
|
process.exit(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-26 16:17:37 -05:00
|
|
|
// Handle quick update separately
|
|
|
|
|
if (config.actionType === 'quick-update') {
|
|
|
|
|
const result = await installer.quickUpdate(config);
|
|
|
|
|
console.log(chalk.green('\n✨ Quick update complete!'));
|
|
|
|
|
console.log(chalk.cyan(`Updated ${result.moduleCount} modules with preserved settings`));
|
|
|
|
|
process.exit(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-28 12:47:45 -05:00
|
|
|
// Handle reinstall by setting force flag
|
|
|
|
|
if (config.actionType === 'reinstall') {
|
|
|
|
|
config._requestedReinstall = true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-02 21:45:59 -05:00
|
|
|
// Regular install/update flow
|
2025-09-28 23:17:07 -05:00
|
|
|
const result = await installer.install(config);
|
|
|
|
|
|
2025-10-04 19:46:16 -05:00
|
|
|
// Check if installation was cancelled
|
|
|
|
|
if (result && result.cancelled) {
|
|
|
|
|
process.exit(0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check if installation succeeded
|
|
|
|
|
if (result && result.success) {
|
|
|
|
|
console.log(chalk.green('\n✨ Installation complete!'));
|
2025-11-08 13:58:43 -06:00
|
|
|
console.log(chalk.cyan('BMAD Core and Selected Modules have been installed to:'), chalk.bold(result.path));
|
2025-10-04 19:46:16 -05:00
|
|
|
console.log(chalk.yellow('\nThank you for helping test the early release version of the new BMad Core and BMad Method!'));
|
2025-10-31 19:39:06 -05:00
|
|
|
console.log(chalk.cyan('Stable Beta coming soon - please read the full readme.md and linked documentation to get started!'));
|
2025-10-04 19:46:16 -05:00
|
|
|
process.exit(0);
|
|
|
|
|
}
|
2025-09-28 23:17:07 -05:00
|
|
|
} catch (error) {
|
|
|
|
|
// Check if error has a complete formatted message
|
|
|
|
|
if (error.fullMessage) {
|
|
|
|
|
console.error(error.fullMessage);
|
|
|
|
|
if (error.stack) {
|
|
|
|
|
console.error('\n' + chalk.dim(error.stack));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// Generic error handling for all other errors
|
|
|
|
|
console.error(chalk.red('Installation failed:'), error.message);
|
|
|
|
|
console.error(chalk.dim(error.stack));
|
|
|
|
|
}
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|