Skip to content

Commit

Permalink
chore: Add sponsors to README (#654)
Browse files Browse the repository at this point in the history
* chore: Add sponsors to README

* Update commit-data.sh
  • Loading branch information
amareshsm authored Oct 25, 2024
1 parent 110da23 commit 8a1ee47
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 12 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ In order to create a new translation:

The ESLint team will create a new domain name, set up analytics and ads, and otherwise prepare the website for deployment.

<!-- NOTE: This section is autogenerated. Do not manually edit.-->
<!--sponsorsstart-->

## Sponsors

The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
to get your logo on our READMEs and [website](https://eslint.org/sponsors).

<h3>Platinum Sponsors</h3>
<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>
<p><a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a></p><h3>Silver Sponsors</h3>
<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>
<p><a href="https://www.wordhint.net/"><img src="https://images.opencollective.com/wordhint/be86813/avatar.png" alt="WordHint" 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.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340?v=4" alt="GitBook" 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>
<h3>Technology Sponsors</h3>
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
<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>
<!--sponsorsend-->

## License

[Apache 2.0](LICENSE)
6 changes: 3 additions & 3 deletions tools/commit-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# Commits the data files if any have changed
#------------------------------------------------------------------------------

if [ -z "$(git status --porcelain)" ]; then
if [ -z "$(git status --porcelain)" ]; then
echo "Data did not change."
else
echo "Data changed!"

# commit the result
git add src/_data/ includes/
git add src/_data/ includes/ README.md
git commit -m "chore: Update remote data"

# push back to source control
git push origin HEAD
git push origin HEAD
fi
43 changes: 34 additions & 9 deletions tools/generate-sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* This script generates a markdown file containing sponsor information.
* It fetches sponsor data from specified JSON files, formats
* the data into HTML sections, and writes the output to a new markdown file.
* Additionally, it updates the README file with the latest sponsor information.
*
* Usage:
* Run the script using Node.js:
Expand Down Expand Up @@ -51,6 +52,8 @@ The following companies, organizations, and individuals support ESLint's ongoing
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
`;

const README_FILE_PATH = path.resolve(__dirname, "../README.md");

//-----------------------------------------------------------------------------
// Helpers
//-----------------------------------------------------------------------------
Expand All @@ -63,7 +66,7 @@ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
async function readData(filePath) {
try {
const data = await fs.readFile(filePath, "utf8");
return JSON.parse(data);
return data;
} catch (err) {
console.error("Error reading or parsing the file:", err);
return null;
Expand All @@ -76,18 +79,21 @@ async function readData(filePath) {
*/
async function fetchSponsorsData() {
const sponsorsData = await readData(SPONSORS_FILE_PATH);
if (sponsorsData) {
delete sponsorsData.backers;
const parsedSponsorData = JSON.parse(sponsorsData);
if (parsedSponsorData) {
delete parsedSponsorData.backers;
}
return sponsorsData;
return parsedSponsorData;
}

/**
* Fetches the latest tech sponsors data from the website.
* @returns {Array<Object>|null} The tech sponsors data object.
*/
async function fetchTechSponsors() {
return readData(TECH_SPONSORS_FILE_PATH);
const sponsorsData = await readData(TECH_SPONSORS_FILE_PATH);
const parsedSponsorData = JSON.parse(sponsorsData);
return parsedSponsorData;
}

/**
Expand Down Expand Up @@ -156,18 +162,37 @@ async function writeData(filePath, data) {
}
}

/**
* Updates the README file with the latest sponsors information.
* @param {string} sponsorsInfo The HTML string containing formatted sponsor information to be inserted.
* @returns {Promise<void>} A promise that resolves when the update operation is complete.
*/
async function updateReadme(sponsorsInfo) {
const readme = await readData(README_FILE_PATH);
let newReadme = readme.replace(
/<!--sponsorsstart-->[\w\W]*?<!--sponsorsend-->/u,
`<!--sponsorsstart-->\n\n${sponsorsInfo}\n<!--sponsorsend-->`,
);

// replace multiple consecutive blank lines with just one blank line
newReadme = newReadme.replace(/(?<=^|\n)\n{2,}/gu, "\n");
writeData(README_FILE_PATH, newReadme);
}

(async () => {
const [allSponsors, techSponsors] = await Promise.all([
const [sponsors, techSponsors] = await Promise.all([
fetchSponsorsData(),
fetchTechSponsors(),
]);

const newFileContent = stripIndents`
const allSponsors = stripIndents`
${SPONSOR_INTRO_TEXT}
${formatSponsors(allSponsors)}
${formatSponsors(sponsors)}
${formatTechSponsors(techSponsors)}
`;

await writeData(NEW_FILE_PATH, newFileContent);
await writeData(NEW_FILE_PATH, allSponsors);
console.log(`Sponsors information has been written to ${NEW_FILE_PATH}`);

updateReadme(allSponsors);
})();

0 comments on commit 8a1ee47

Please sign in to comment.