Skip to content

Commit 51bf57c

Browse files
harish-sethuramanamareshsmmdjermanovic
authored
chore: add tech sponsors through actions (#18624)
* chore: add tech sponsors through actions * chore: add readme sponsors * chore: review changes Co-authored-by: Amaresh S M <[email protected]> * chore: review changes Co-authored-by: Milos Djermanovic <[email protected]> * chore: review changes Co-authored-by: Milos Djermanovic <[email protected]> --------- Co-authored-by: Amaresh S M <[email protected]> Co-authored-by: Milos Djermanovic <[email protected]>
1 parent 9f416db commit 51bf57c

File tree

2 files changed

+93
-31
lines changed

2 files changed

+93
-31
lines changed

README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J
3939
10. [License](#license)
4040
11. [Team](#team)
4141
12. [Sponsors](#sponsors)
42-
13. [Technology Sponsors](#technology-sponsors)
42+
13. [Technology Sponsors](#technology-sponsors) <!-- markdownlint-disable-line MD051 -->
4343

4444
## Installation and Usage
4545

@@ -294,14 +294,13 @@ The following companies, organizations, and individuals support ESLint's ongoing
294294
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
295295
<!--sponsorsstart-->
296296
<h3>Platinum Sponsors</h3>
297-
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="undefined"></a></p><h3>Gold Sponsors</h3>
297+
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
298298
<p><a href="#"><img src="https://images.opencollective.com/guest-bf377e88/avatar.png" alt="Eli Schleifer" height="96"></a> <a href="https://engineering.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a></p><h3>Silver Sponsors</h3>
299299
<p><a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3>
300300
<p><a href="https://www.notion.so"><img src="https://images.opencollective.com/notion/bf3b117/logo.png" alt="notion" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://usenextbase.com"><img src="https://avatars.githubusercontent.com/u/145838380?v=4" alt="Nextbase Starter Kit" height="32"></a></p>
301301
<!--sponsorsend-->
302302

303-
## Technology Sponsors
304-
305-
* Site search ([eslint.org](https://eslint.org)) is sponsored by [Algolia](https://www.algolia.com)
306-
* Hosting for ([eslint.org](https://eslint.org)) is sponsored by [Netlify](https://www.netlify.com)
307-
* Password management is sponsored by [1Password](https://www.1password.com)
303+
<!--techsponsorsstart-->
304+
<h2>Technology Sponsors</h2>
305+
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
306+
<!--techsponsorsend-->

tools/update-readme.js

+87-24
Original file line numberDiff line numberDiff line change
@@ -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";
2729
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";
2834

2935
const readme = fs.readFileSync(README_FILE_PATH, "utf8");
3036

3137
const heights = {
38+
platinum: 128,
3239
gold: 96,
3340
silver: 64,
3441
bronze: 32
@@ -67,14 +74,18 @@ async function fetchTeamData() {
6774
function 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
*/
8697
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+
);
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(/<!--teamstart-->[\w\W]*?<!--teamend-->/u, ejs.render(HTML_TEMPLATE, {
153-
team,
154-
formatTeamMembers
155-
}));
156-
157-
newReadme = newReadme.replace(/<!--sponsorsstart-->[\w\W]*?<!--sponsorsend-->/u, formatSponsors(allSponsors));
205+
let newReadme = readme.replace(
206+
/<!--teamstart-->[\w\W]*?<!--teamend-->/u,
207+
ejs.render(HTML_TEMPLATE, {
208+
team,
209+
formatTeamMembers
210+
})
211+
);
212+
213+
newReadme = newReadme.replace(
214+
/<!--sponsorsstart-->[\w\W]*?<!--sponsorsend-->/u,
215+
formatSponsors(allSponsors)
216+
);
217+
218+
newReadme = newReadme.replace(
219+
/<!--techsponsorsstart-->[\w\W]*?<!--techsponsorsend-->/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

Comments
 (0)