( plan: ReleasePlan, preamble: string, packageDirs: Map<string, string>, repo: string | undefined, prNumber: string | null, showNoPatWarning = false, )
| 1617 | const GH_BODY_SAFE = 64_000; |
| 1618 | |
| 1619 | export function formatVersionPrBody( |
| 1620 | plan: ReleasePlan, |
| 1621 | preamble: string, |
| 1622 | packageDirs: Map<string, string>, |
| 1623 | repo: string | undefined, |
| 1624 | prNumber: string | null, |
| 1625 | showNoPatWarning = false, |
| 1626 | ): string { |
| 1627 | const changesBaseUrl = repo && prNumber ? `https://github.com/${repo}/pull/${prNumber}/changes` : null; |
| 1628 | |
| 1629 | const groups: Record<string, PlannedRelease[]> = { major: [], minor: [], patch: [] }; |
| 1630 | for (const r of plan.releases) { |
| 1631 | groups[r.type]?.push(r); |
| 1632 | } |
| 1633 | |
| 1634 | // Render the body at a given detail level. `includeSummaries: false` drops |
| 1635 | // the per-change bullet points, leaving just the version-bump headers — a |
| 1636 | // big size reduction for releases with many or large change summaries. |
| 1637 | const render = (includeSummaries: boolean): string => { |
| 1638 | const lines: string[] = []; |
| 1639 | lines.push(preamble); |
| 1640 | lines.push(''); |
| 1641 | |
| 1642 | if (!includeSummaries) { |
| 1643 | lines.push( |
| 1644 | '> ℹ️ This release contains too many changes to summarize inline. See the **Files changed** tab and each package’s `CHANGELOG.md` for details.', |
| 1645 | ); |
| 1646 | lines.push(''); |
| 1647 | } |
| 1648 | |
| 1649 | for (const type of ['major', 'minor', 'patch'] as const) { |
| 1650 | const releases = groups[type]; |
| 1651 | if (!releases || releases.length === 0) continue; |
| 1652 | |
| 1653 | lines.push(bumpSectionHeader(type)); |
| 1654 | lines.push(''); |
| 1655 | for (const r of releases) { |
| 1656 | const suffix = r.isDependencyBump ? ' _(dep)_' : r.isCascadeBump ? ' _(cascade)_' : ''; |
| 1657 | const pkgDir = packageDirs.get(r.name); |
| 1658 | const diffLinks = pkgDir ? buildDiffLinks(pkgDir, changesBaseUrl) : ''; |
| 1659 | lines.push(`#### \`${r.name}\` ${r.oldVersion} → **${r.newVersion}**${suffix}${diffLinks}`); |
| 1660 | lines.push(''); |
| 1661 | |
| 1662 | if (!includeSummaries) continue; |
| 1663 | |
| 1664 | const relevantBumpFiles = plan.bumpFiles.filter((bf) => r.bumpFiles.includes(bf.id)); |
| 1665 | |
| 1666 | if (relevantBumpFiles.length > 0) { |
| 1667 | for (const bf of relevantBumpFiles) { |
| 1668 | if (bf.summary) { |
| 1669 | const bfLink = changesBaseUrl |
| 1670 | ? ` ([bump file](${changesBaseUrl}#diff-${sha256Hex(`.bumpy/${bf.id}.md`)}))` |
| 1671 | : ''; |
| 1672 | const summaryLines = bf.summary.split('\n'); |
| 1673 | lines.push(`- ${summaryLines[0]}${bfLink}`); |
| 1674 | for (let i = 1; i < summaryLines.length; i++) { |
| 1675 | if (summaryLines[i]!.trim()) { |
| 1676 | lines.push(` ${summaryLines[i]}`); |
no test coverage detected
searching dependent graphs…