MCPcopy Create free account
hub / github.com/massCodeIO/massCode / updateStats

Function updateStats

docs/website/scripts/update-github-stats.mjs:81–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79}
80
81async function updateStats() {
82 const existingStats = await readExistingStats()
83
84 try {
85 const [repo, releases] = await Promise.all([
86 fetchJson(`https://api.github.com/repos/${repository}`),
87 fetchAllReleases(),
88 ])
89
90 const stats = {
91 repository,
92 stars: repo.stargazers_count,
93 releaseDownloads: getReleaseDownloads(releases),
94 activeDevelopmentStartYear: startYear,
95 activeDevelopmentYears: new Date().getUTCFullYear() - startYear,
96 updatedAt: new Date().toISOString(),
97 }
98
99 await mkdir(dirname(outputPath), { recursive: true })
100 await writeFile(outputPath, `${JSON.stringify(stats, null, 2)}\n`)
101
102 console.log(`Updated GitHub stats: ${stats.stars} stars, ${stats.releaseDownloads} release downloads`)
103 }
104 catch (error) {
105 const message = error instanceof Error ? error.message : String(error)
106
107 console.warn(`Could not update GitHub stats, using existing values: ${message}`)
108
109 await mkdir(dirname(outputPath), { recursive: true })
110 await writeFile(outputPath, `${JSON.stringify(existingStats, null, 2)}\n`)
111 }
112}
113
114await updateStats()

Callers 1

Calls 6

readExistingStatsFunction · 0.85
fetchJsonFunction · 0.85
fetchAllReleasesFunction · 0.85
getReleaseDownloadsFunction · 0.85
dirnameFunction · 0.85
writeFileFunction · 0.85

Tested by

no test coverage detected