From 29e7bbf4c5aa7e17854061a5ee695f44324f307a Mon Sep 17 00:00:00 2001 From: Brian Madison Date: Thu, 19 Jun 2025 12:38:06 -0500 Subject: [PATCH] feat: add early v4 detection for improved update flow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Now detects existing v4 installations immediately after directory prompt - Offers update option upfront for existing v4 installations - If user declines update, continues with normal installation flow - Added 'update' install type handling in installer - Improves user experience by streamlining the update process šŸ¤– Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- tools/installer/bin/bmad.js | 28 ++++++++++++++++++++++++++++ tools/installer/lib/installer.js | 11 +++++++++++ 2 files changed, 39 insertions(+) diff --git a/tools/installer/bin/bmad.js b/tools/installer/bin/bmad.js index 49ea6dd8..e27fc971 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 a240ed33..1757f07d 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);