diff --git a/tools/installer/bin/bmad.js b/tools/installer/bin/bmad.js index 49ea6dd..e27fc97 100755 --- a/tools/installer/bin/bmad.js +++ b/tools/installer/bin/bmad.js @@ -1,6 +1,7 @@ #!/usr/bin/env node const { program } = require('commander'); +const path = require('path'); // Dynamic imports for ES modules let chalk, inquirer; @@ -158,6 +159,33 @@ async function promptInstallation() { ]); answers.directory = directory; + // Check if this is an existing v4 installation + const installDir = path.resolve(answers.directory); + const state = await installer.detectInstallationState(installDir); + + if (state.type === 'v4_existing') { + console.log(chalk.yellow('\nšŸ” Found existing BMAD v4 installation')); + console.log(` Directory: ${installDir}`); + console.log(` Version: ${state.manifest?.version || 'Unknown'}`); + console.log(` Installed: ${state.manifest?.installed_at ? new Date(state.manifest.installed_at).toLocaleDateString() : 'Unknown'}`); + + const { shouldUpdate } = await inquirer.prompt([ + { + type: 'confirm', + name: 'shouldUpdate', + message: 'Would you like to update your existing BMAD v4 installation?', + default: true + } + ]); + + if (shouldUpdate) { + // Skip other prompts and go directly to update + answers.installType = 'update'; + return await installer.install(answers); + } + // If user doesn't want to update, continue with normal flow + } + // Ask for installation type const { installType } = await inquirer.prompt([ { diff --git a/tools/installer/lib/installer.js b/tools/installer/lib/installer.js index a240ed3..1757f07 100644 --- a/tools/installer/lib/installer.js +++ b/tools/installer/lib/installer.js @@ -102,6 +102,17 @@ class Installer { spinner.start("Analyzing installation directory..."); } + // If this is an update request from early detection, handle it directly + if (config.installType === 'update') { + const state = await this.detectInstallationState(installDir); + if (state.type === 'v4_existing') { + return await this.performUpdate(config, installDir, state.manifest, spinner); + } else { + spinner.fail('No existing v4 installation found to update'); + throw new Error('No existing v4 installation found'); + } + } + // Detect current state const state = await this.detectInstallationState(installDir);