MCPcopy
hub / github.com/codeceptjs/CodeceptJS / contributorFaces

Function contributorFaces

runok.cjs:528–588  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

526 },
527
528 async contributorFaces() {
529 // update contributors list in readme
530 const owner = 'codeceptjs'
531 const repo = 'codeceptjs'
532 const token = process.env.GH_TOKEN
533
534 try {
535 const response = await axios.get(`https://api.github.com/repos/${owner}/${repo}/contributors`, {
536 headers: { Authorization: `token ${token}` },
537 })
538
539 // Filter out bot accounts
540 const excludeUsers = ['dependabot[bot]', 'actions-user']
541
542 const filteredContributors = response.data.filter(contributor => !excludeUsers.includes(contributor.login))
543
544 const contributors = filteredContributors.map(contributor => {
545 return `
546<td align="center">
547 <a href="${contributor.html_url}">
548 <img src="${contributor.avatar_url}" width="100" height="100" alt="${contributor.login}"/><br />
549 <sub><b>${contributor.login}</b></sub>
550 </a>
551</td>`
552 })
553
554 // Chunk contributors into rows of 4
555 const rows = []
556 const chunkSize = 4
557 for (let i = 0; i < contributors.length; i += chunkSize) {
558 rows.push(`<tr>${contributors.slice(i, i + chunkSize).join('')}</tr>`)
559 }
560
561 // Combine rows into a table
562 const contributorsTable = `
563<table>
564 ${rows.join('\n')}
565</table>
566 `
567
568 const readmePath = path.join(__dirname, 'README.md')
569 let content = fs.readFileSync(readmePath, 'utf-8')
570
571 // Replace or add the contributors section in the README
572 const contributorsSectionRegex = /(## Contributors\s*\n)([\s\S]*?)(\n##|$)/
573 const match = content.match(contributorsSectionRegex)
574
575 if (match) {
576 const updatedContent = content.replace(contributorsSectionRegex, `${match[1]}\n${contributorsTable}\n${match[3]}`)
577 fs.writeFileSync(readmePath, updatedContent, 'utf-8')
578 } else {
579 // If no contributors section exists, add one at the end
580 content += `\n${contributorsTable}`
581 fs.writeFileSync(readmePath, content, 'utf-8')
582 }
583
584 console.log('Contributors section updated successfully!')
585 } catch (error) {

Callers

nothing calls this directly

Calls 5

getMethod · 0.80
filterMethod · 0.80
includesMethod · 0.80
pushMethod · 0.80
logMethod · 0.80

Tested by

no test coverage detected