add installer warning when newer version is available
This commit is contained in:
parent
bd620e38e5
commit
d37ee7f27a
|
|
@ -1,6 +1,48 @@
|
|||
const { program } = require('commander');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
const { execSync } = require('node:child_process');
|
||||
|
||||
// Check for updates - do this asynchronously so it doesn't block startup
|
||||
const packageJson = require('../../package.json');
|
||||
const packageName = 'bmad-method';
|
||||
checkForUpdate().catch(() => {
|
||||
// Silently ignore errors - version check is best-effort
|
||||
});
|
||||
|
||||
async function checkForUpdate() {
|
||||
try {
|
||||
// For beta versions, check the beta tag; otherwise check latest
|
||||
const isBeta =
|
||||
packageJson.version.includes('Beta') ||
|
||||
packageJson.version.includes('beta') ||
|
||||
packageJson.version.includes('alpha') ||
|
||||
packageJson.version.includes('rc');
|
||||
const tag = isBeta ? 'beta' : 'latest';
|
||||
|
||||
const result = execSync(`npm view ${packageName}@${tag} version`, {
|
||||
encoding: 'utf8',
|
||||
stdio: 'pipe',
|
||||
timeout: 5000,
|
||||
}).trim();
|
||||
|
||||
if (result && result !== packageJson.version) {
|
||||
console.warn('');
|
||||
console.warn(' ╔═══════════════════════════════════════════════════════════════════════════════╗');
|
||||
console.warn(' ║ UPDATE AVAILABLE ║');
|
||||
console.warn(' ║ ║');
|
||||
console.warn(` ║ You are using version ${packageJson.version} but ${result} is available. ║`);
|
||||
console.warn(' ║ ║');
|
||||
console.warn(' ║ To update,exir and first run: ║');
|
||||
console.warn(` ║ npm cache clean --force && npx bmad-method@${tag} install ║`);
|
||||
console.warn(' ║ ║');
|
||||
console.warn(' ╚═══════════════════════════════════════════════════════════════════════════════╝');
|
||||
console.warn('');
|
||||
}
|
||||
} catch {
|
||||
// Silently fail - network issues or npm not available
|
||||
}
|
||||
}
|
||||
|
||||
// Fix for stdin issues when running through npm on Windows
|
||||
// Ensures keyboard interaction works properly with CLI prompts
|
||||
|
|
@ -20,9 +62,6 @@ if (process.stdin.isTTY) {
|
|||
}
|
||||
}
|
||||
|
||||
// Load package.json from root for version info
|
||||
const packageJson = require('../../package.json');
|
||||
|
||||
// Load all command modules
|
||||
const commandsPath = path.join(__dirname, 'commands');
|
||||
const commandFiles = fs.readdirSync(commandsPath).filter((file) => file.endsWith('.js'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue