MCPcopy Create free account
hub / github.com/middleapi/orpc / main

Function main

scripts/sync-sponsor.ts:236–266  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

234}
235
236async function main(): Promise<void> {
237 const response = await fetch(SPONSORS_SOURCE_URL)
238
239 if (!response.ok) {
240 throw new Error(`Failed to fetch sponsors data: ${response.status} ${response.statusText}`)
241 }
242
243 const sponsors = (await response.json() as Sponsor[]).map(sponsor => ({ ...sponsor, link: withTracking(sponsor.link) }))
244 await writeWebsiteSponsorsFile(sponsors)
245 const readmeFiles = await findReadmes(ROOT_DIR)
246 const replacement = buildSponsorsSection(sponsors)
247
248 const readmeContents = await Promise.all(
249 readmeFiles.map(readmePath => readFile(readmePath, 'utf8')),
250 )
251
252 const writePromises: Promise<void>[] = []
253 let updatedCount = 0
254
255 for (const [i, content] of readmeContents.entries()) {
256 const nextContent = replaceSponsorsSection(content, replacement)
257
258 if (nextContent !== content) {
259 writePromises.push(writeFile(readmeFiles[i]!, nextContent))
260 updatedCount += 1
261 }
262 }
263
264 await Promise.all(writePromises)
265 console.log(`Updated sponsors section in ${updatedCount} README files.`)
266}
267
268main().catch((error) => {
269 console.error(error)

Callers 1

sync-sponsor.tsFile · 0.70

Calls 9

withTrackingFunction · 0.85
writeWebsiteSponsorsFileFunction · 0.85
findReadmesFunction · 0.85
buildSponsorsSectionFunction · 0.85
replaceSponsorsSectionFunction · 0.85
jsonMethod · 0.80
pushMethod · 0.80
logMethod · 0.80
fetchFunction · 0.50

Tested by

no test coverage detected