| 122 | } |
| 123 | |
| 124 | function collectPrereleaseHeaders( |
| 125 | releaseLines: string[], |
| 126 | pkg: string, |
| 127 | ): string[] { |
| 128 | const lines: string[] = [] |
| 129 | for (const line of releaseLines) { |
| 130 | const match = line.match( |
| 131 | /^## (?:<small>)?\[([^\]]+)\]\(([^)]+)\)(?: \((\d{4}-\d{2}-\d{2})\))?/, |
| 132 | ) |
| 133 | if (!match) continue |
| 134 | const [, ver, compareUrl, date] = match |
| 135 | if (!/alpha|beta|rc/.test(ver)) continue |
| 136 | |
| 137 | const tagPrefix = pkg === 'vite' ? 'v' : `${pkg}@` |
| 138 | const tag = `${tagPrefix}${ver}` |
| 139 | const header = date |
| 140 | ? `#### [${ver}](${compareUrl}) (${date})` |
| 141 | : `#### [${ver}](${compareUrl})` |
| 142 | lines.push( |
| 143 | header, |
| 144 | '', |
| 145 | `See [${ver} changelog](https://github.com/vitejs/vite/blob/${tag}/packages/${pkg}/CHANGELOG.md)`, |
| 146 | '', |
| 147 | ) |
| 148 | } |
| 149 | return lines |
| 150 | } |
| 151 | |
| 152 | function buildOutputLines( |
| 153 | headerLine: string, |