import fs from "fs-extra"; import path from "path"; import { fileURLToPath } from "url"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const version = process.argv[2]; if (!version) { console.error("Version argument is required"); process.exit(1); } async function getChangelogEntry() { try { const changelogPath = path.resolve(__dirname, "../../CHANGELOG.md"); const content = await fs.readFile(changelogPath, "utf8"); // Find the section for this version const versionHeader = `## [${version}]`; const sections = content.split(versionHeader); if (sections.length < 2) { console.warn(`No changelog entry found for version ${version}`); return `Release ${version}`; } // Extract the content for this version const versionContent = sections[1].split("\n## ")[0].trim(); // Add the version header back return `${versionHeader}\n${versionContent}`; } catch (error) { console.error("Error reading changelog:", error); return `Release ${version}`; } } // Output the changelog entry (release-it will capture this stdout) getChangelogEntry() .then(console.log) .catch(() => process.exit(1));