mirror of
https://github.com/bmad-code-org/BMAD-METHOD.git
synced 2026-09-19 08:11:52 +08:00
7ee5fa313b
* fix(installer): require --tools for fresh --yes installs; remove --tools none (closes #2326) Fresh non-interactive installs without --tools previously produced a config-only install (~35 files vs ~1400 in the manifest) with no warning and a "BMAD is ready to use" success card, leaving slash commands unreachable. --tools none was an explicit opt-in for the same broken state. Now: fresh install + -y without --tools throws a helpful error pointing at --list-tools. --tools none is rejected as an unknown ID. Empty and typo'd tool IDs are also rejected. Existing-install paths (--action update, quick-update, modify) are unchanged - they continue to reuse previously-configured tools when --tools is omitted. Adds --list-tools flag that prints all 42 supported tool IDs (id, name, target_dir, preferred star) sourced from platform-codes.yaml. English docs updated; localized docs (vi-vn, fr, cs, etc.) will sync via the normal translation pass. * fix(installer): address review for #2326 — single source of truth, drop dead code, add tests - Refactor formatPlatformList to use IdeManager so --list-tools and --tools validation see the same set of platforms. Eliminates the drift where suspended platforms appeared in --list-tools but were rejected at validation. - Drop unused getValidPlatformIds export. - Flatten redundant block scope around the throw in the --yes-without-tools branch (refactor leftover). - Drop dead String() defensive cast (Commander always passes a string). - Add Test Suite 42: 8 unit tests covering _parseToolsFlag empty/whitespace/ unknown/typo cases plus an integration check that --list-tools output and --tools validation agree on the ID set. * fix(installer): close --tools "" bypass and drop hardcoded tool count - Replace truthy `if (options.tools)` guard with `!== undefined` in both upgrade and fresh-install branches. Empty string now reaches _parseToolsFlag and produces the specific "passed empty" error instead of falling through to a generic message (fresh-install) or being silently ignored (existing-install). - Drop the hardcoded "42 supported tools" count from the prereqs in install-bmad.md so the doc doesn't drift as platform-codes.yaml changes. Addresses augment / coderabbit review on #2346.
81 lines
2.4 KiB
JavaScript
81 lines
2.4 KiB
JavaScript
const fs = require('../fs-native');
|
|
const path = require('node:path');
|
|
const yaml = require('yaml');
|
|
|
|
const PLATFORM_CODES_PATH = path.join(__dirname, 'platform-codes.yaml');
|
|
|
|
let _cachedPlatformCodes = null;
|
|
|
|
/**
|
|
* Load the platform codes configuration from YAML
|
|
* @returns {Object} Platform codes configuration
|
|
*/
|
|
async function loadPlatformCodes() {
|
|
if (_cachedPlatformCodes) {
|
|
return _cachedPlatformCodes;
|
|
}
|
|
|
|
if (!(await fs.pathExists(PLATFORM_CODES_PATH))) {
|
|
throw new Error(`Platform codes configuration not found at: ${PLATFORM_CODES_PATH}`);
|
|
}
|
|
|
|
const content = await fs.readFile(PLATFORM_CODES_PATH, 'utf8');
|
|
_cachedPlatformCodes = yaml.parse(content);
|
|
return _cachedPlatformCodes;
|
|
}
|
|
|
|
/**
|
|
* Clear the cached platform codes (useful for testing)
|
|
*/
|
|
function clearCache() {
|
|
_cachedPlatformCodes = null;
|
|
}
|
|
|
|
/**
|
|
* Format the installable platform list for human-readable output (used by --list-tools).
|
|
* Sourced from IdeManager so this view matches what --tools accepts at install time
|
|
* (suspended platforms excluded).
|
|
* @returns {Promise<string>} Formatted multi-line string with id, name, target_dir, preferred flag.
|
|
*/
|
|
async function formatPlatformList() {
|
|
const { IdeManager } = require('./manager');
|
|
const ideManager = new IdeManager();
|
|
await ideManager.ensureInitialized();
|
|
|
|
const entries = ideManager.getAvailableIdes().map((ide) => {
|
|
const handler = ideManager.handlers.get(ide.value);
|
|
return {
|
|
id: ide.value,
|
|
name: ide.name,
|
|
targetDir: handler?.installerConfig?.target_dir || '',
|
|
preferred: ide.preferred,
|
|
};
|
|
});
|
|
|
|
const idWidth = Math.max(...entries.map((e) => e.id.length), 'ID'.length);
|
|
const nameWidth = Math.max(...entries.map((e) => e.name.length), 'Name'.length);
|
|
|
|
const pad = (s, w) => s + ' '.repeat(Math.max(0, w - s.length));
|
|
const lines = [
|
|
`Supported tool IDs (pass via --tools <id>[,<id>...]):`,
|
|
'',
|
|
` ${pad('ID', idWidth)} ${pad('Name', nameWidth)} Target dir`,
|
|
` ${pad('-'.repeat(idWidth), idWidth)} ${pad('-'.repeat(nameWidth), nameWidth)} ${'-'.repeat(10)}`,
|
|
];
|
|
|
|
for (const e of entries) {
|
|
const star = e.preferred ? ' *' : ' ';
|
|
lines.push(`${star}${pad(e.id, idWidth)} ${pad(e.name, nameWidth)} ${e.targetDir}`);
|
|
}
|
|
|
|
lines.push('', '* = recommended / preferred', '', 'Example: bmad-method install --modules bmm --tools claude-code');
|
|
|
|
return lines.join('\n');
|
|
}
|
|
|
|
module.exports = {
|
|
loadPlatformCodes,
|
|
clearCache,
|
|
formatPlatformList,
|
|
};
|