feat(installer): add badge prompt and auto-create README if missing
- Interactive prompt asks "Add BMAD badge to your README?" (default yes) - --no-badge skips the prompt and disables badge - --yes accepts badge by default - If user wants badge but no README exists, creates README.md with project name and badge Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
parent
707de90238
commit
4d0b0fdcd1
|
|
@ -96,7 +96,18 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const config = await ui.promptInstall(options);
|
const config = await ui.promptInstall(options);
|
||||||
config.noBadge = options.badge === false;
|
|
||||||
|
// Ask about badge unless --no-badge or --yes
|
||||||
|
if (options.badge === false) {
|
||||||
|
config.noBadge = true;
|
||||||
|
} else if (options.yes) {
|
||||||
|
config.noBadge = false;
|
||||||
|
} else {
|
||||||
|
config.noBadge = !(await prompts.confirm({
|
||||||
|
message: 'Add BMAD badge to your README?',
|
||||||
|
default: true,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
// Handle cancel
|
// Handle cancel
|
||||||
if (config.actionType === 'cancel') {
|
if (config.actionType === 'cancel') {
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,11 @@ function removeBadge(content) {
|
||||||
.join('\n');
|
.join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createReadmeWithBadge(owner, repo, projectName) {
|
||||||
|
const badgeLine = generateBadgeMarkdown(owner, repo);
|
||||||
|
return `# ${projectName}\n\n${badgeLine}\n`;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
resolveGitRemote,
|
resolveGitRemote,
|
||||||
findReadme,
|
findReadme,
|
||||||
|
|
@ -80,4 +85,5 @@ module.exports = {
|
||||||
generateBadgeMarkdown,
|
generateBadgeMarkdown,
|
||||||
injectBadge,
|
injectBadge,
|
||||||
removeBadge,
|
removeBadge,
|
||||||
|
createReadmeWithBadge,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1061,7 +1061,12 @@ class Installer {
|
||||||
|
|
||||||
const readmePath = await badge.findReadme(projectDir);
|
const readmePath = await badge.findReadme(projectDir);
|
||||||
if (!readmePath) {
|
if (!readmePath) {
|
||||||
addResult('Badge', 'warn', 'no README found');
|
// No README — create one with the badge
|
||||||
|
const projectName = path.basename(projectDir);
|
||||||
|
const content = badge.createReadmeWithBadge(remote.owner, remote.repo, projectName);
|
||||||
|
const newReadmePath = path.join(projectDir, 'README.md');
|
||||||
|
await fs.writeFile(newReadmePath, content, 'utf8');
|
||||||
|
addResult('Badge', 'ok', 'created README.md with badge');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue