@@ -22,13 +22,20 @@ const got = require("got");
22
22
// Data
23
23
//-----------------------------------------------------------------------------
24
24
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" ;
27
29
const 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" ;
28
34
29
35
const readme = fs . readFileSync ( README_FILE_PATH , "utf8" ) ;
30
36
31
37
const heights = {
38
+ platinum : 128 ,
32
39
gold : 96 ,
33
40
silver : 64 ,
34
41
bronze : 32
@@ -67,14 +74,18 @@ async function fetchTeamData() {
67
74
function formatTeamMembers ( members ) {
68
75
/* eslint-disable indent -- Allow deeper template substitution indent */
69
76
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%">
72
80
<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 />
74
84
${ member . name . trim ( ) }
75
85
</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>`;
78
89
/* eslint-enable indent -- Allow deeper template substitution indent */
79
90
}
80
91
@@ -84,20 +95,62 @@ function formatTeamMembers(members) {
84
95
* @returns {string } The HTML for the readme.
85
96
*/
86
97
function 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
+ ) ;
88
101
89
102
/* eslint-disable indent -- Allow deeper template substitution indent */
90
103
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 ( "" ) }
97
119
<!--sponsorsend-->` ;
98
120
/* eslint-enable indent -- Allow deeper template substitution indent */
99
121
}
100
122
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
+
101
154
//-----------------------------------------------------------------------------
102
155
// Main
103
156
//-----------------------------------------------------------------------------
@@ -142,24 +195,34 @@ const HTML_TEMPLATE = stripIndents`
142
195
` ;
143
196
144
197
( async ( ) => {
145
-
146
- const [ allSponsors , team ] = await Promise . all ( [
198
+ const [ allSponsors , team , techSponsors ] = await Promise . all ( [
147
199
fetchSponsorsData ( ) ,
148
- fetchTeamData ( )
200
+ fetchTeamData ( ) ,
201
+ fetchTechSponsors ( )
149
202
] ) ;
150
203
151
204
// 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
+ ) ;
158
222
159
223
// replace multiple consecutive blank lines with just one blank line
160
224
newReadme = newReadme . replace ( / (?< = ^ | \n ) \n { 2 , } / gu, "\n" ) ;
161
225
162
226
// output to the file
163
227
fs . writeFileSync ( README_FILE_PATH , newReadme , "utf8" ) ;
164
-
165
228
} ) ( ) ;
0 commit comments