UNPKG

peezy-cli

Version:

Production-ready CLI for scaffolding modern applications with curated full-stack templates, intelligent migrations, and enterprise security.

59 lines 2.03 kB
import fs from "node:fs"; import path from "node:path"; import { log } from "../utils/logger.js"; export async function generateReadme(opts = {}) { const cwd = process.cwd(); const pkgPath = path.join(cwd, "package.json"); const pkg = fs.existsSync(pkgPath) ? JSON.parse(fs.readFileSync(pkgPath, "utf8")) : {}; const name = opts.name || pkg.name || path.basename(cwd); const readmePath = path.join(cwd, "README.md"); const badges = opts.badges !== false; const badgeLines = badges ? [ "[![CI](https://github.com/USER/REPO/actions/workflows/ci.yml/badge.svg)](#)", "[![Coverage](https://img.shields.io/badge/coverage-—-brightgreen)](#)", "[![Deploy](https://img.shields.io/badge/deploy-Railway-purple)](#)", ] : []; const content = `# ${name}\n\n${badgeLines.join(" ")}\n\nGenerated by Peezy.\n`; fs.writeFileSync(readmePath, content, "utf8"); if (opts.json) { return { file: readmePath, name, badges: badges ? badgeLines.length : 0, }; } else { log.ok("README.md generated"); } } export async function generateChangelog(opts = {}) { const cwd = process.cwd(); const changelogPath = path.join(cwd, "CHANGELOG.md"); const hasGit = fs.existsSync(path.join(cwd, ".git")); let content; if (!hasGit) { content = "# Changelog\n\n- Initial commit\n"; if (!opts.json) { log.warn("No git repository found. Creating a minimal CHANGELOG.md"); } } else { content = `# Changelog\n\nAll notable changes to this project will be documented in this file.\n`; } fs.writeFileSync(changelogPath, content, "utf8"); if (opts.json) { return { file: changelogPath, hasGit, type: hasGit ? "conventional" : "minimal", }; } else { log.ok("CHANGELOG.md generated"); } } //# sourceMappingURL=readme-changelog.js.map