@@ -22,13 +22,20 @@ const got = require("got");
2222// Data
2323//-----------------------------------------------------------------------------
2424
25- const SPONSORS_URL = "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/sponsors.json" ;
26- const TEAM_URL = "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/team.json" ;
25+ const SPONSORS_URL =
26+ "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/sponsors.json" ;
27+ const TEAM_URL =
28+ "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/team.json" ;
2729const README_FILE_PATH = "./README.md" ;
30+ const TECH_SPONSORS_URL =
31+ "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/techsponsors.json" ;
32+ const TECH_SPONSORS_IMAGE_PATH =
33+ "https://raw.githubusercontent.com/eslint/eslint.org/main/src" ;
2834
2935const readme = fs . readFileSync ( README_FILE_PATH , "utf8" ) ;
3036
3137const heights = {
38+ platinum : 128 ,
3239 gold : 96 ,
3340 silver : 64 ,
3441 bronze : 32
@@ -67,14 +74,18 @@ async function fetchTeamData() {
6774function formatTeamMembers ( members ) {
6875 /* eslint-disable indent -- Allow deeper template substitution indent */
6976 return stripIndents `
70- <table><tbody><tr>${
71- members . map ( ( member , index ) => `<td align="center" valign="top" width="11%">
77+ <table><tbody><tr>${ members
78+ . map (
79+ ( member , index ) => `<td align="center" valign="top" width="11%">
7280 <a href="https://github.com/${ member . username } ">
73- <img src="https://github.com/${ member . username } .png?s=75" width="75" height="75" alt="${ member . name . trim ( ) } 's Avatar"><br />
81+ <img src="https://github.com/${
82+ member . username
83+ } .png?s=75" width="75" height="75" alt="${ member . name . trim ( ) } 's Avatar"><br />
7484 ${ member . name . trim ( ) }
7585 </a>
76- </td>${ ( index + 1 ) % 9 === 0 ? "</tr><tr>" : "" } ` ) . join ( "" )
77- } </tr></tbody></table>`;
86+ </td>${ ( index + 1 ) % 9 === 0 ? "</tr><tr>" : "" } `
87+ )
88+ . join ( "" ) } </tr></tbody></table>`;
7889 /* eslint-enable indent -- Allow deeper template substitution indent */
7990}
8091
@@ -84,20 +95,62 @@ function formatTeamMembers(members) {
8495 * @returns {string } The HTML for the readme.
8596 */
8697function formatSponsors ( sponsors ) {
87- const nonEmptySponsors = Object . keys ( sponsors ) . filter ( tier => sponsors [ tier ] . length > 0 ) ;
98+ const nonEmptySponsors = Object . keys ( sponsors ) . filter (
99+ tier => sponsors [ tier ] . length
100+ ) ;
88101
89102 /* eslint-disable indent -- Allow deeper template substitution indent */
90103 return stripIndents `<!--sponsorsstart-->
91- ${
92- nonEmptySponsors . map ( tier => `<h3>${ tier [ 0 ] . toUpperCase ( ) } ${ tier . slice ( 1 ) } Sponsors</h3>
93- <p>${
94- sponsors [ tier ] . map ( sponsor => `<a href="${ sponsor . url || "#" } "><img src="${ sponsor . image } " alt="${ sponsor . name } " height="${ heights [ tier ] } "></a>` ) . join ( " " )
95- } </p>`) . join ( "" )
96- }
104+ ${ nonEmptySponsors
105+ . map (
106+ tier => `<h3>${ tier [ 0 ] . toUpperCase ( ) } ${ tier . slice (
107+ 1
108+ ) } Sponsors</h3>
109+ <p>${ sponsors [ tier ]
110+ . map (
111+ sponsor =>
112+ `<a href="${ sponsor . url || "#" } "><img src="${
113+ sponsor . image
114+ } " alt="${ sponsor . name } " height="${ heights [ tier ] } "></a>`
115+ )
116+ . join ( " " ) } </p>`
117+ )
118+ . join ( "" ) }
97119 <!--sponsorsend-->` ;
98120 /* eslint-enable indent -- Allow deeper template substitution indent */
99121}
100122
123+ /**
124+ * Fetches the latest tech sponsors data from the website.
125+ * @returns {Array<Object> } The tech sponsors array of data object.
126+ */
127+ async function fetchTechSponsors ( ) {
128+ const data = await got ( TECH_SPONSORS_URL ) . json ( ) ;
129+
130+ return data ;
131+ }
132+
133+ /**
134+ * Formats an array of sponsors into HTML for the readme.
135+ * @param {Array } sponsors The array of sponsors.
136+ * @returns {string } The HTML for the readme.
137+ */
138+ function formatTechSponsors ( sponsors ) {
139+ return stripIndents `<!--techsponsorsstart-->
140+ <h2>Technology Sponsors</h2>
141+ <p>${ sponsors
142+ . map (
143+ sponsor =>
144+ `<a href="${ sponsor . url || "#" } "><img src="${
145+ TECH_SPONSORS_IMAGE_PATH + sponsor . image
146+ } " alt="${ sponsor . name } " height="${
147+ heights . bronze
148+ } "></a>`
149+ )
150+ . join ( " " ) } </p>
151+ <!--techsponsorsend-->` ;
152+ }
153+
101154//-----------------------------------------------------------------------------
102155// Main
103156//-----------------------------------------------------------------------------
@@ -142,24 +195,34 @@ const HTML_TEMPLATE = stripIndents`
142195` ;
143196
144197( async ( ) => {
145-
146- const [ allSponsors , team ] = await Promise . all ( [
198+ const [ allSponsors , team , techSponsors ] = await Promise . all ( [
147199 fetchSponsorsData ( ) ,
148- fetchTeamData ( )
200+ fetchTeamData ( ) ,
201+ fetchTechSponsors ( )
149202 ] ) ;
150203
151204 // replace all of the section
152- let newReadme = readme . replace ( / < ! - - t e a m s t a r t - - > [ \w \W ] * ?< ! - - t e a m e n d - - > / u, ejs . render ( HTML_TEMPLATE , {
153- team,
154- formatTeamMembers
155- } ) ) ;
156-
157- newReadme = newReadme . replace ( / < ! - - s p o n s o r s s t a r t - - > [ \w \W ] * ?< ! - - s p o n s o r s e n d - - > / u, formatSponsors ( allSponsors ) ) ;
205+ let newReadme = readme . replace (
206+ / < ! - - t e a m s t a r t - - > [ \w \W ] * ?< ! - - t e a m e n d - - > / u,
207+ ejs . render ( HTML_TEMPLATE , {
208+ team,
209+ formatTeamMembers
210+ } )
211+ ) ;
212+
213+ newReadme = newReadme . replace (
214+ / < ! - - s p o n s o r s s t a r t - - > [ \w \W ] * ?< ! - - s p o n s o r s e n d - - > / u,
215+ formatSponsors ( allSponsors )
216+ ) ;
217+
218+ newReadme = newReadme . replace (
219+ / < ! - - t e c h s p o n s o r s s t a r t - - > [ \w \W ] * ?< ! - - t e c h s p o n s o r s e n d - - > / u,
220+ formatTechSponsors ( techSponsors )
221+ ) ;
158222
159223 // replace multiple consecutive blank lines with just one blank line
160224 newReadme = newReadme . replace ( / (?< = ^ | \n ) \n { 2 , } / gu, "\n" ) ;
161225
162226 // output to the file
163227 fs . writeFileSync ( README_FILE_PATH , newReadme , "utf8" ) ;
164-
165228} ) ( ) ;
0 commit comments