From 7a626f6fe0c78bda2942d888acbdbaef13bc1526 Mon Sep 17 00:00:00 2001 From: Strek Date: Fri, 21 Jun 2024 19:14:07 +0530 Subject: [PATCH] chore: add tech sponsors (#63) Co-authored-by: Nicholas C. Zakas --- README.md | 3 ++ packages/compat/README.md | 3 ++ packages/config-array/README.md | 3 ++ packages/migrate-config/README.md | 3 ++ packages/object-schema/README.md | 3 ++ tools/update-readme.js | 46 +++++++++++++++++++++++++++++-- 6 files changed, 59 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 55b622a0..65dc87cd 100644 --- a/README.md +++ b/README.md @@ -23,3 +23,6 @@ The following companies, organizations, and individuals support ESLint's ongoing

JetBrains Liftoff American Express Workleap

Bronze Sponsors

notion Anagram Solver Icons8 Discord Ignition Nx HeroCoders Nextbase Starter Kit

+ + + diff --git a/packages/compat/README.md b/packages/compat/README.md index 2e354c42..e4e87148 100644 --- a/packages/compat/README.md +++ b/packages/compat/README.md @@ -199,3 +199,6 @@ The following companies, organizations, and individuals support ESLint's ongoing

JetBrains Liftoff American Express Workleap

Bronze Sponsors

notion Anagram Solver Icons8 Discord Ignition Nx HeroCoders Nextbase Starter Kit

+ + + diff --git a/packages/config-array/README.md b/packages/config-array/README.md index 02f9df67..2f4dc944 100644 --- a/packages/config-array/README.md +++ b/packages/config-array/README.md @@ -351,3 +351,6 @@ The following companies, organizations, and individuals support ESLint's ongoing

JetBrains Liftoff American Express Workleap

Bronze Sponsors

notion Anagram Solver Icons8 Discord Ignition Nx HeroCoders Nextbase Starter Kit

+ + + diff --git a/packages/migrate-config/README.md b/packages/migrate-config/README.md index a051ef31..e4cd8537 100644 --- a/packages/migrate-config/README.md +++ b/packages/migrate-config/README.md @@ -96,3 +96,6 @@ The following companies, organizations, and individuals support ESLint's ongoing

JetBrains Liftoff American Express Workleap

Bronze Sponsors

notion Anagram Solver Icons8 Discord Ignition Nx HeroCoders Nextbase Starter Kit

+ + + diff --git a/packages/object-schema/README.md b/packages/object-schema/README.md index 15f21cbc..f7cb976d 100644 --- a/packages/object-schema/README.md +++ b/packages/object-schema/README.md @@ -235,3 +235,6 @@ The following companies, organizations, and individuals support ESLint's ongoing

JetBrains Liftoff American Express Workleap

Bronze Sponsors

notion Anagram Solver Icons8 Discord Ignition Nx HeroCoders Nextbase Starter Kit

+ + + diff --git a/tools/update-readme.js b/tools/update-readme.js index 9a87ff07..26691f71 100644 --- a/tools/update-readme.js +++ b/tools/update-readme.js @@ -21,6 +21,12 @@ import got from "got"; const SPONSORS_URL = "https://raw.githubusercontent.com/eslint/eslint.org/main/src/_data/sponsors.json"; +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_FILE_PATHS = [ "./README.md", ...readdirSync("./packages").map(dir => `./packages/${dir}/README.md`), @@ -49,9 +55,19 @@ async function fetchSponsorsData() { return data; } +/** + * 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. + * @param {Object} sponsors The object of sponsors. * @returns {string} The HTML for the readme. */ function formatSponsors(sponsors) { @@ -74,12 +90,33 @@ function formatSponsors(sponsors) { `; } +/** + * 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 //----------------------------------------------------------------------------- (async () => { - const allSponsors = await fetchSponsorsData(); + const [techSponsors, allSponsors] = await Promise.all([ + fetchTechSponsors(), + fetchSponsorsData(), + ]); README_FILE_PATHS.forEach(filePath => { // read readme file @@ -90,6 +127,11 @@ function formatSponsors(sponsors) { 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");