MCPcopy Create free account
hub / github.com/Noumena-Network/code / fetchAndStoreChangelog

Function fetchAndStoreChangelog

src/utils/releaseNotes.ts:83–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81 * This runs in the background and doesn't block the UI
82 */
83export async function fetchAndStoreChangelog(): Promise<void> {
84 // Skip in noninteractive mode
85 if (getIsNonInteractiveSession()) {
86 return
87 }
88
89 // Skip network requests if nonessential traffic is disabled
90 if (isEssentialTrafficOnly()) {
91 return
92 }
93
94 const response = await axios.get(RAW_CHANGELOG_URL)
95 if (response.status === 200) {
96 const changelogContent = response.data
97
98 // Skip write if content unchanged — writing Date.now() defeats the
99 // dirty-check in saveGlobalConfig since the timestamp always differs.
100 if (changelogContent === changelogMemoryCache) {
101 return
102 }
103
104 const cachePath = getChangelogCachePath()
105
106 // Ensure cache directory exists
107 await mkdir(dirname(cachePath), { recursive: true })
108
109 // Write changelog to cache file
110 await writeFile(cachePath, changelogContent, { encoding: 'utf-8' })
111 changelogMemoryCache = changelogContent
112
113 // Update timestamp in config
114 const changelogLastFetched = Date.now()
115 saveGlobalConfig(current => ({
116 ...current,
117 changelogLastFetched,
118 }))
119 }
120}
121
122/**
123 * Get the stored changelog from cache file if available.

Callers 2

checkForReleaseNotesFunction · 0.85
callFunction · 0.85

Calls 6

isEssentialTrafficOnlyFunction · 0.85
getChangelogCachePathFunction · 0.85
mkdirFunction · 0.85
saveGlobalConfigFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected