mirror of
https://github.com/bmadcode/BMAD-METHOD.git
synced 2025-12-17 09:45:25 +00:00
npx with version selector
This commit is contained in:
parent
334e24823a
commit
8ed721d029
12
README.md
12
README.md
@ -151,6 +151,18 @@ Install BMad to your project using npx:
|
||||
npx bmad-method install
|
||||
```
|
||||
|
||||
> **Version Selection:** When running `npx bmad-method install`, you'll be prompted to choose:
|
||||
>
|
||||
> - **Stable (v4.x)** - Production-ready version
|
||||
> - **Beta (v6.0.0-beta)** - Latest features with early access
|
||||
>
|
||||
> To install a specific version directly (skip prompt):
|
||||
>
|
||||
> ```bash
|
||||
> npx bmad-method@4 install # Stable v4.x
|
||||
> npx bmad-method@6.0.0-beta.0 install # Beta v6
|
||||
> ```
|
||||
|
||||
The interactive installer will guide you through:
|
||||
|
||||
1. **Project location** - Where to install BMad
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package.json",
|
||||
"name": "bmad-method",
|
||||
"version": "6.0.0-alpha.0",
|
||||
"version": "6.0.0-beta.0",
|
||||
"description": "Breakthrough Method of Agile AI-driven Development",
|
||||
"keywords": [
|
||||
"agile",
|
||||
@ -20,7 +20,8 @@
|
||||
"author": "Brian (BMad) Madison",
|
||||
"main": "tools/cli/bmad-cli.js",
|
||||
"bin": {
|
||||
"bmad": "tools/cli/bmad-cli.js"
|
||||
"bmad": "tools/bmad-npx-wrapper.js",
|
||||
"bmad-method": "tools/bmad-npx-wrapper.js"
|
||||
},
|
||||
"scripts": {
|
||||
"bmad:install": "node tools/cli/bmad-cli.js install",
|
||||
|
||||
126
tools/bmad-npx-wrapper.js
Executable file
126
tools/bmad-npx-wrapper.js
Executable file
@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* BMad Method CLI - Direct execution wrapper for npx
|
||||
* This file ensures proper execution when run via npx from GitHub or npm registry
|
||||
* Supports version selection between stable (v4) and beta (v6)
|
||||
*/
|
||||
|
||||
const { execSync } = require('node:child_process');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
|
||||
// Check if we're running in an npx temporary directory
|
||||
const isNpxExecution = __dirname.includes('_npx') || __dirname.includes('.npm');
|
||||
|
||||
async function promptVersionSelection() {
|
||||
const inquirer = require('inquirer');
|
||||
const chalk = require('chalk');
|
||||
|
||||
console.log(
|
||||
chalk.bold.cyan(`
|
||||
██████╗ ███╗ ███╗ █████╗ ██████╗ ███╗ ███╗███████╗████████╗██╗ ██╗ ██████╗ ██████╗
|
||||
██╔══██╗████╗ ████║██╔══██╗██╔══██╗ ████╗ ████║██╔════╝╚══██╔══╝██║ ██║██╔═══██╗██╔══██╗
|
||||
██████╔╝██╔████╔██║███████║██║ ██║█████╗██╔████╔██║█████╗ ██║ ███████║██║ ██║██║ ██║
|
||||
██╔══██╗██║╚██╔╝██║██╔══██║██║ ██║╚════╝██║╚██╔╝██║██╔══╝ ██║ ██╔══██║██║ ██║██║ ██║
|
||||
██████╔╝██║ ╚═╝ ██║██║ ██║██████╔╝ ██║ ╚═╝ ██║███████╗ ██║ ██║ ██║╚██████╔╝██████╔╝
|
||||
╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝
|
||||
`),
|
||||
);
|
||||
|
||||
console.log(chalk.bold.magenta('🚀 Universal AI Agent Framework for Any Domain\n'));
|
||||
|
||||
const answers = await inquirer.prompt([
|
||||
{
|
||||
type: 'list',
|
||||
name: 'version',
|
||||
message: 'Which version would you like to install?',
|
||||
choices: [
|
||||
{
|
||||
name: chalk.green('Stable (v4.x) - Production Ready'),
|
||||
value: 'stable',
|
||||
short: 'Stable v4.x',
|
||||
},
|
||||
{
|
||||
name: chalk.yellow('Beta (v6.0.0-beta) - Latest Features (Early Access)'),
|
||||
value: 'beta',
|
||||
short: 'Beta v6.0.0-beta',
|
||||
},
|
||||
],
|
||||
default: 'stable',
|
||||
},
|
||||
]);
|
||||
|
||||
return answers.version;
|
||||
}
|
||||
|
||||
async function installStableVersion(args) {
|
||||
const chalk = require('chalk');
|
||||
|
||||
console.log(chalk.cyan('\n📦 Installing BMad Method v4 (Stable)...\n'));
|
||||
|
||||
// Use npx to install the stable version from npm registry
|
||||
// The @4 tag will fetch the latest v4.x.x version
|
||||
const npxCommand = `npx bmad-method@4 ${args.join(' ')}`;
|
||||
|
||||
try {
|
||||
execSync(npxCommand, {
|
||||
stdio: 'inherit',
|
||||
cwd: process.cwd(),
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(chalk.red('Failed to install stable version'));
|
||||
process.exit(error.status || 1);
|
||||
}
|
||||
}
|
||||
|
||||
async function installBetaVersion(args) {
|
||||
const chalk = require('chalk');
|
||||
|
||||
console.log(chalk.yellow('\n📦 Installing BMad Method v6 Beta (Early Access)...\n'));
|
||||
|
||||
// Use the v6 installer from the current installation
|
||||
const bmadCliPath = path.join(__dirname, 'cli', 'bmad-cli.js');
|
||||
|
||||
if (!fs.existsSync(bmadCliPath)) {
|
||||
console.error(chalk.red('Error: Could not find bmad-cli.js at'), bmadCliPath);
|
||||
console.error(chalk.dim('Current directory:'), __dirname);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
execSync(`node "${bmadCliPath}" ${args.join(' ')}`, {
|
||||
stdio: 'inherit',
|
||||
cwd: path.dirname(__dirname),
|
||||
});
|
||||
} catch (error) {
|
||||
process.exit(error.status || 1);
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
// Check if user wants to skip version prompt
|
||||
const skipPrompt = args.includes('--skip-version-prompt');
|
||||
const filteredArgs = args.filter((arg) => arg !== '--skip-version-prompt');
|
||||
|
||||
if (isNpxExecution && !skipPrompt) {
|
||||
// Running via npx - prompt for version selection unless skipped
|
||||
const selectedVersion = await promptVersionSelection();
|
||||
|
||||
if (selectedVersion === 'stable') {
|
||||
await installStableVersion(filteredArgs);
|
||||
} else {
|
||||
await installBetaVersion(filteredArgs);
|
||||
}
|
||||
} else {
|
||||
// Local execution or skipped prompt - use the v6 installer directly
|
||||
require('./cli/bmad-cli.js');
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error('Unexpected error:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const { program } = require('commander');
|
||||
const path = require('node:path');
|
||||
const fs = require('node:fs');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user