Skip to content

Commit

Permalink
docs: Add sponsors to README (eslint#36)
Browse files Browse the repository at this point in the history
* docs: Add sponsors to README

* remove IIFE
  • Loading branch information
mdjermanovic authored Oct 6, 2024
1 parent be6b6a5 commit cac8847
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 5 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/update-readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Data Fetch

on:
schedule:
- cron: "0 8 * * *" # Every day at 1am PDT
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
with:
token: ${{ secrets.WORKFLOW_PUSH_BOT_TOKEN }}

- name: Set up Node.js
uses: actions/setup-node@v4

- name: Install npm packages
run: npm install

- name: Update README with latest sponsor data
run: npm run build:readme

- name: Setup Git
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<[email protected]>"
- name: Save updated files
run: |
chmod +x ./tools/commit-readme.sh
./tools/commit-readme.sh
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,20 @@ Any other rules that catch potential problems in JSON are welcome to be implemen

Apache 2.0

## Sponsors

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

<!--techsponsorsstart-->
<!--techsponsorsend-->
## 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-->
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"build:dedupe-types": "node tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
"build:cts": "node -e \"fs.copyFileSync('dist/esm/index.d.ts', 'dist/cjs/index.d.cts')\"",
"build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
"build:readme": "node tools/update-readme.js",
"test:jsr": "npx jsr@latest publish --dry-run",
"pretest": "npm run build",
"lint": "eslint",
Expand Down Expand Up @@ -71,6 +72,7 @@
"dedent": "^1.5.3",
"eslint": "^9.11.1",
"eslint-config-eslint": "^11.0.0",
"got": "^14.4.2",
"lint-staged": "^15.2.7",
"mocha": "^10.4.0",
"prettier": "^3.3.2",
Expand Down
18 changes: 18 additions & 0 deletions tools/commit-readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

#------------------------------------------------------------------------------
# Commits the data files if any have changed
#------------------------------------------------------------------------------

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

# commit the result
git add README.md
git commit -m "docs: Update README sponsors"

# push back to source control
git push origin HEAD
fi
55 changes: 55 additions & 0 deletions tools/update-readme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @fileoverview Script to update the README with sponsors details in all packages.
*
* node tools/update-readme.js
*
* @author Milos Djermanovic
*/

//-----------------------------------------------------------------------------
// Requirements
//-----------------------------------------------------------------------------

import { readFileSync, writeFileSync } from "node:fs";
import got from "got";

//-----------------------------------------------------------------------------
// Data
//-----------------------------------------------------------------------------

const SPONSORS_URL =
"https://raw.githubusercontent.com/eslint/eslint.org/main/includes/sponsors.md";

const README_FILE_PATH = "./README.md";

//-----------------------------------------------------------------------------
// Helpers
//-----------------------------------------------------------------------------

/**
* Fetches the latest sponsors from the website.
* @returns {Promise<string>}} Prerendered sponsors markdown.
*/
async function fetchSponsorsMarkdown() {
return got(SPONSORS_URL).text();
}

//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------

const allSponsors = await fetchSponsorsMarkdown();

// read readme file
const readme = readFileSync(README_FILE_PATH, "utf8");

let newReadme = readme.replace(
/<!--sponsorsstart-->[\w\W]*?<!--sponsorsend-->/u,
`<!--sponsorsstart-->\n\n${allSponsors}\n<!--sponsorsend-->`,
);

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

// output to the files
writeFileSync(README_FILE_PATH, newReadme, "utf8");

0 comments on commit cac8847

Please sign in to comment.