( currentVersion: string, previousVersion: string | null | undefined, changelogContent: string = getStoredChangelogFromMemory(), )
| 205 | * @returns Array of release notes to display |
| 206 | */ |
| 207 | export function getRecentReleaseNotes( |
| 208 | currentVersion: string, |
| 209 | previousVersion: string | null | undefined, |
| 210 | changelogContent: string = getStoredChangelogFromMemory(), |
| 211 | ): string[] { |
| 212 | try { |
| 213 | const releaseNotes = parseChangelog(changelogContent) |
| 214 | |
| 215 | // Strip SHA from both versions to compare only the base versions |
| 216 | const baseCurrentVersion = coerce(currentVersion) |
| 217 | const basePreviousVersion = previousVersion ? coerce(previousVersion) : null |
| 218 | |
| 219 | if ( |
| 220 | !basePreviousVersion || |
| 221 | (baseCurrentVersion && |
| 222 | gt(baseCurrentVersion.version, basePreviousVersion.version)) |
| 223 | ) { |
| 224 | // Get all versions that are newer than the last seen version |
| 225 | return Object.entries(releaseNotes) |
| 226 | .filter( |
| 227 | ([version]) => |
| 228 | !basePreviousVersion || gt(version, basePreviousVersion.version), |
| 229 | ) |
| 230 | .sort(([versionA], [versionB]) => (gt(versionA, versionB) ? -1 : 1)) // Sort newest first |
| 231 | .flatMap(([_, notes]) => notes) |
| 232 | .filter(Boolean) |
| 233 | .slice(0, MAX_RELEASE_NOTES_SHOWN) |
| 234 | } |
| 235 | } catch (error) { |
| 236 | logError(toError(error)) |
| 237 | return [] |
| 238 | } |
| 239 | return [] |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * Gets all release notes as an array of [version, notes] arrays. |
no test coverage detected