feat: add early v4 detection for improved update flow
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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([
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user