2025-06-13 09:01:52 -05:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
|
|
/**
|
2025-07-04 07:47:57 -05:00
|
|
|
* BMad Method CLI - Direct execution wrapper for npx
|
2025-06-13 09:01:52 -05:00
|
|
|
* This file ensures proper execution when run via npx from GitHub
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const { execSync } = require('child_process');
|
|
|
|
|
const path = require('path');
|
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
|
|
// Check if we're running in an npx temporary directory
|
|
|
|
|
const isNpxExecution = __dirname.includes('_npx') || __dirname.includes('.npm');
|
|
|
|
|
|
|
|
|
|
// If running via npx, we need to handle things differently
|
|
|
|
|
if (isNpxExecution) {
|
2025-07-27 18:02:08 -05:00
|
|
|
const args = process.argv.slice(2);
|
|
|
|
|
|
|
|
|
|
// Use the installer for all commands
|
2025-06-13 19:11:17 -05:00
|
|
|
const bmadScriptPath = path.join(__dirname, 'installer', 'bin', 'bmad.js');
|
2025-06-13 09:01:52 -05:00
|
|
|
|
|
|
|
|
if (!fs.existsSync(bmadScriptPath)) {
|
|
|
|
|
console.error('Error: Could not find bmad.js at', bmadScriptPath);
|
|
|
|
|
console.error('Current directory:', __dirname);
|
|
|
|
|
process.exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2025-07-27 18:02:08 -05:00
|
|
|
execSync(`node "${bmadScriptPath}" ${args.join(' ')}`, {
|
2025-06-13 09:01:52 -05:00
|
|
|
stdio: 'inherit',
|
2025-06-13 19:11:17 -05:00
|
|
|
cwd: path.dirname(__dirname)
|
2025-06-13 09:01:52 -05:00
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
process.exit(error.status || 1);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2025-07-27 18:02:08 -05:00
|
|
|
// Local execution - use installer for all commands
|
2025-06-13 19:11:17 -05:00
|
|
|
require('./installer/bin/bmad.js');
|
2025-06-13 09:01:52 -05:00
|
|
|
}
|