( lastSeenVersion: string | null | undefined, currentVersion: string = MACRO.VERSION, )
| 310 | * @returns An object with hasReleaseNotes and the releaseNotes content |
| 311 | */ |
| 312 | export async function checkForReleaseNotes( |
| 313 | lastSeenVersion: string | null | undefined, |
| 314 | currentVersion: string = MACRO.VERSION, |
| 315 | ): Promise<{ hasReleaseNotes: boolean; releaseNotes: string[] }> { |
| 316 | // For Ant builds, use VERSION_CHANGELOG bundled at build time |
| 317 | if (process.env.USER_TYPE === 'ant') { |
| 318 | const changelog = MACRO.VERSION_CHANGELOG |
| 319 | if (changelog) { |
| 320 | const commits = changelog.trim().split('\n').filter(Boolean) |
| 321 | return { |
| 322 | hasReleaseNotes: commits.length > 0, |
| 323 | releaseNotes: commits, |
| 324 | } |
| 325 | } |
| 326 | return { |
| 327 | hasReleaseNotes: false, |
| 328 | releaseNotes: [], |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | // Ensure the in-memory cache is populated for subsequent sync reads |
| 333 | const cachedChangelog = await getStoredChangelog() |
| 334 | |
| 335 | // If the version has changed or we don't have a cached changelog, fetch a new one |
| 336 | // This happens in the background and doesn't block the UI |
| 337 | if (lastSeenVersion !== currentVersion || !cachedChangelog) { |
| 338 | fetchAndStoreChangelog().catch(error => logError(toError(error))) |
| 339 | } |
| 340 | |
| 341 | const releaseNotes = getRecentReleaseNotes( |
| 342 | currentVersion, |
| 343 | lastSeenVersion, |
| 344 | cachedChangelog, |
| 345 | ) |
| 346 | const hasReleaseNotes = releaseNotes.length > 0 |
| 347 | |
| 348 | return { |
| 349 | hasReleaseNotes, |
| 350 | releaseNotes, |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * Synchronous variant of checkForReleaseNotes for React render paths. |
no test coverage detected