()
| 54 | * before any other config saves that might re-add the deprecated field. |
| 55 | */ |
| 56 | export async function migrateChangelogFromConfig(): Promise<void> { |
| 57 | const config = getGlobalConfig() |
| 58 | if (!config.cachedChangelog) { |
| 59 | return |
| 60 | } |
| 61 | |
| 62 | const cachePath = getChangelogCachePath() |
| 63 | |
| 64 | // If cache file doesn't exist, create it from old config |
| 65 | try { |
| 66 | await mkdir(dirname(cachePath), { recursive: true }) |
| 67 | await writeFile(cachePath, config.cachedChangelog, { |
| 68 | encoding: 'utf-8', |
| 69 | flag: 'wx', // Write only if file doesn't exist |
| 70 | }) |
| 71 | } catch { |
| 72 | // File already exists, which is fine - skip silently |
| 73 | } |
| 74 | |
| 75 | // Remove the deprecated field from config |
| 76 | saveGlobalConfig(({ cachedChangelog: _, ...rest }) => rest) |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Fetch the changelog from GitHub and store it in cache file |
no test coverage detected