]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tools/update-readme.js
2 * @fileoverview Script to update the README with team and sponsors.
3 * Note that this requires eslint/website to be available in the same
4 * directory as the eslint repo.
6 * node tools/update-readme.js
8 * @author Nicholas C. Zakas
12 //-----------------------------------------------------------------------------
14 //-----------------------------------------------------------------------------
16 const path
= require("path");
17 const fs
= require("fs");
18 const { stripIndents
} = require("common-tags");
19 const ejs
= require("ejs");
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 const README_FILE_PATH
= path
.resolve(__dirname
, "../README.md");
26 const WEBSITE_DATA_PATH
= path
.resolve(__dirname
, "../../website/_data");
28 const team
= JSON
.parse(fs
.readFileSync(path
.join(WEBSITE_DATA_PATH
, "team.json")));
29 const allSponsors
= JSON
.parse(fs
.readFileSync(path
.join(WEBSITE_DATA_PATH
, "sponsors.json")));
30 const readme
= fs
.readFileSync(README_FILE_PATH
, "utf8");
38 // remove backers from sponsors list - not shown on readme
39 delete allSponsors
.backers
;
41 //-----------------------------------------------------------------------------
43 //-----------------------------------------------------------------------------
46 * Formats an array of team members for inclusion in the readme.
47 * @param {Array} members The array of members to format.
48 * @returns {string} The HTML for the members list.
50 function formatTeamMembers(members
) {
51 /* eslint-disable indent*/
54 members.map((member, index) => `<td align
="center" valign
="top" width
="11%">
55 <a href
="https://github.com/${member.username}">
56 <img src
="https://github.com/${member.username}.png?s=75" width
="75" height
="75"><br
/>
59 </td>${(index + 1) % 9 === 0 ? "</tr
><tr
>" : ""}`).join("")
60 }</tr></tbody></table>`;
61 /* eslint-enable indent*/
65 * Formats an array of sponsors into HTML for the readme.
66 * @param {Array} sponsors The array of sponsors.
67 * @returns {string} The HTML for the readme.
69 function formatSponsors(sponsors) {
70 const nonEmptySponsors = Object.keys(sponsors).filter(tier => sponsors[tier].length > 0);
72 /* eslint-disable indent*/
73 return stripIndents`<!--sponsorsstart-->
75 nonEmptySponsors.map(tier => `<h3>${tier[0].toUpperCase()}${tier.slice(1)} Sponsors</h3>
77 sponsors[tier].map(sponsor => `<a href="${sponsor.url}
"><img src="${sponsor.image}
" alt="${sponsor.name}
" height="${heights[tier]}
"></a>`).join(" ")
81 /* eslint-enable indent*/
84 //-----------------------------------------------------------------------------
86 //-----------------------------------------------------------------------------
88 const HTML_TEMPLATE = stripIndents`
92 ### Technical Steering Committee (TSC)
94 The people who manage releases, review feature requests, and meet regularly to ensure ESLint is properly maintained.
96 <%- formatTeamMembers(team.tsc) %>
98 <% if (team.reviewers.length > 0) { %>
101 The people who review and implement new features.
103 <%- formatTeamMembers(team.reviewers) %>
107 <% if (team.committers.length > 0) { %>
110 The people who review and fix bugs and help triage issues.
112 <%- formatTeamMembers(team.committers) %>
118 // replace all of the section
119 let newReadme = readme.replace(/<!--teamstart-->[\w\W]*?<!--teamend-->/u, ejs.render(HTML_TEMPLATE, {
124 newReadme = newReadme.replace(/<!--sponsorsstart-->[\w\W]*?<!--sponsorsend-->/u, formatSponsors(allSponsors));
126 // output to the file
127 fs.writeFileSync(README_FILE_PATH, newReadme, "utf8
");