From 51bf57c493a65baeee3a935f2d0e52e27271fb48 Mon Sep 17 00:00:00 2001 From: Strek Date: Fri, 5 Jul 2024 20:28:14 +0530 Subject: [PATCH] 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 * chore: review changes Co-authored-by: Milos Djermanovic * chore: review changes Co-authored-by: Milos Djermanovic --------- Co-authored-by: Amaresh S M Co-authored-by: Milos Djermanovic --- README.md | 13 +++-- tools/update-readme.js | 111 ++++++++++++++++++++++++++++++++--------- 2 files changed, 93 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 11d75d4dcd1d..ee2ec9d3e0fb 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ ESLint is a tool for identifying and reporting on patterns found in ECMAScript/J 10. [License](#license) 11. [Team](#team) 12. [Sponsors](#sponsors) -13. [Technology Sponsors](#technology-sponsors) +13. [Technology Sponsors](#technology-sponsors) ## Installation and Usage @@ -294,14 +294,13 @@ The following companies, organizations, and individuals support ESLint's ongoing

Platinum Sponsors

-

Automattic Airbnb

Gold Sponsors

+

Automattic Airbnb

Gold Sponsors

Eli Schleifer Salesforce

Silver Sponsors

JetBrains Liftoff American Express Workleap

Bronze Sponsors

notion Anagram Solver Icons8 Discord Ignition Nx HeroCoders Nextbase Starter Kit

-## Technology Sponsors - -* Site search ([eslint.org](https://eslint.org)) is sponsored by [Algolia](https://www.algolia.com) -* Hosting for ([eslint.org](https://eslint.org)) is sponsored by [Netlify](https://www.netlify.com) -* Password management is sponsored by [1Password](https://www.1password.com) + +

Technology Sponsors

+

Netlify Algolia 1Password

+ \ No newline at end of file diff --git a/tools/update-readme.js b/tools/update-readme.js index 8918ecbc1cc4..5fad22a17dab 100644 --- a/tools/update-readme.js +++ b/tools/update-readme.js @@ -22,13 +22,20 @@ const got = require("got"); // Data //----------------------------------------------------------------------------- -const SPONSORS_URL = "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/sponsors.json"; -const TEAM_URL = "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/team.json"; +const SPONSORS_URL = + "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/sponsors.json"; +const TEAM_URL = + "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/team.json"; const README_FILE_PATH = "./README.md"; +const TECH_SPONSORS_URL = + "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/techsponsors.json"; +const TECH_SPONSORS_IMAGE_PATH = + "https://raw.githubusercontent.com/eslint/eslint.org/main/src"; const readme = fs.readFileSync(README_FILE_PATH, "utf8"); const heights = { + platinum: 128, gold: 96, silver: 64, bronze: 32 @@ -67,14 +74,18 @@ async function fetchTeamData() { function formatTeamMembers(members) { /* eslint-disable indent -- Allow deeper template substitution indent */ return stripIndents` - ${ - members.map((member, index) => `${(index + 1) % 9 === 0 ? "" : ""}` + ) + .join("")}
+ ${members + .map( + (member, index) => `${(index + 1) % 9 === 0 ? "" : ""}`).join("") - }
- ${member.name.trim()}'s Avatar
+ ${member.name.trim()}'s Avatar
${member.name.trim()}
-
`; +
`; /* eslint-enable indent -- Allow deeper template substitution indent */ } @@ -84,20 +95,62 @@ function formatTeamMembers(members) { * @returns {string} The HTML for the readme. */ function formatSponsors(sponsors) { - const nonEmptySponsors = Object.keys(sponsors).filter(tier => sponsors[tier].length > 0); + const nonEmptySponsors = Object.keys(sponsors).filter( + tier => sponsors[tier].length + ); /* eslint-disable indent -- Allow deeper template substitution indent */ return stripIndents` - ${ - nonEmptySponsors.map(tier => `

${tier[0].toUpperCase()}${tier.slice(1)} Sponsors

-

${ - sponsors[tier].map(sponsor => `${sponsor.name}`).join(" ") - }

`).join("") - } + ${nonEmptySponsors + .map( + tier => `

${tier[0].toUpperCase()}${tier.slice( + 1 + )} Sponsors

+

${sponsors[tier] + .map( + sponsor => + `${sponsor.name}` + ) + .join(" ")}

` + ) + .join("")} `; /* eslint-enable indent -- Allow deeper template substitution indent */ } +/** + * Fetches the latest tech sponsors data from the website. + * @returns {Array} The tech sponsors array of data object. + */ +async function fetchTechSponsors() { + const data = await got(TECH_SPONSORS_URL).json(); + + return data; +} + +/** + * Formats an array of sponsors into HTML for the readme. + * @param {Array} sponsors The array of sponsors. + * @returns {string} The HTML for the readme. + */ +function formatTechSponsors(sponsors) { + return stripIndents` +

Technology Sponsors

+

${sponsors + .map( + sponsor => + `${sponsor.name}` + ) + .join(" ")}

+ `; +} + //----------------------------------------------------------------------------- // Main //----------------------------------------------------------------------------- @@ -142,24 +195,34 @@ const HTML_TEMPLATE = stripIndents` `; (async () => { - - const [allSponsors, team] = await Promise.all([ + const [allSponsors, team, techSponsors] = await Promise.all([ fetchSponsorsData(), - fetchTeamData() + fetchTeamData(), + fetchTechSponsors() ]); // replace all of the section - let newReadme = readme.replace(/[\w\W]*?/u, ejs.render(HTML_TEMPLATE, { - team, - formatTeamMembers - })); - - newReadme = newReadme.replace(/[\w\W]*?/u, formatSponsors(allSponsors)); + let newReadme = readme.replace( + /[\w\W]*?/u, + ejs.render(HTML_TEMPLATE, { + team, + formatTeamMembers + }) + ); + + newReadme = newReadme.replace( + /[\w\W]*?/u, + formatSponsors(allSponsors) + ); + + newReadme = newReadme.replace( + /[\w\W]*?/u, + formatTechSponsors(techSponsors) + ); // replace multiple consecutive blank lines with just one blank line newReadme = newReadme.replace(/(?<=^|\n)\n{2,}/gu, "\n"); // output to the file fs.writeFileSync(README_FILE_PATH, newReadme, "utf8"); - })();