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