(ctx)
| 89 | |
| 90 | /** Default formatter — version heading with date, bullet points sorted by bump type */ |
| 91 | export const defaultFormatter: ChangelogFormatter = (ctx) => { |
| 92 | const { release, bumpFiles, date } = ctx; |
| 93 | const lines: string[] = []; |
| 94 | lines.push(`## ${release.newVersion}`); |
| 95 | lines.push(`<sub>${date}</sub>`); |
| 96 | lines.push(''); |
| 97 | |
| 98 | const relevantBumpFiles = bumpFiles.filter((bf) => release.bumpFiles.includes(bf.id)); |
| 99 | const sorted = sortBumpFilesByType(relevantBumpFiles, release.name); |
| 100 | |
| 101 | for (const bf of sorted) { |
| 102 | if (!bf.summary || isChangelogSuppressed(bf, release.name)) continue; |
| 103 | const type = getBumpTypeForPackage(bf, release.name); |
| 104 | const summaryLines = trimBlankEdges(bf.summary.split('\n')); |
| 105 | if (summaryLines.length === 0) continue; |
| 106 | |
| 107 | if (summaryNeedsBlockLayout(bf.summary)) { |
| 108 | // Metadata on its own line; summary block indented below |
| 109 | lines.push(`- *(${type})*`); |
| 110 | for (const sl of summaryLines) { |
| 111 | lines.push(sl.trim() ? ` ${sl}` : ''); |
| 112 | } |
| 113 | } else { |
| 114 | lines.push(`- *(${type})* ${summaryLines[0]}`); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | const sourceList = |
| 119 | release.bumpSources.length > 0 ? release.bumpSources.map((s) => `\`${s.name}\` v${s.newVersion}`).join(', ') : ''; |
| 120 | |
| 121 | if (release.isDependencyBump) { |
| 122 | const depBumpType = release.bumpSources.reduce<BumpType | undefined>( |
| 123 | (max, s) => maxBump(max, s.bumpType), |
| 124 | undefined, |
| 125 | ); |
| 126 | const depBumpTag = depBumpType ? `*(${depBumpType})* ` : ''; |
| 127 | lines.push(`- ${depBumpTag}Updated dependency ${sourceList || '(internal)'}`); |
| 128 | } |
| 129 | |
| 130 | if (release.isGroupBump) { |
| 131 | lines.push( |
| 132 | sourceList |
| 133 | ? `- *(${release.type})* Version bump from group with ${sourceList}` |
| 134 | : `- *(${release.type})* Version bump from group`, |
| 135 | ); |
| 136 | } |
| 137 | |
| 138 | if (release.isCascadeBump && !release.isDependencyBump && !release.isGroupBump) { |
| 139 | lines.push( |
| 140 | sourceList |
| 141 | ? `- *(${release.type})* Version bump from ${sourceList}` |
| 142 | : `- *(${release.type})* Version bump via cascade rule`, |
| 143 | ); |
| 144 | } |
| 145 | |
| 146 | lines.push(''); |
| 147 | return lines.join('\n'); |
| 148 | }; |
no test coverage detected
searching dependent graphs…