Skip to content

Commit cac8847

Browse files
authored
docs: Add sponsors to README (#36)
* docs: Add sponsors to README * remove IIFE
1 parent be6b6a5 commit cac8847

File tree

5 files changed

+123
-5
lines changed

5 files changed

+123
-5
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Data Fetch
2+
3+
on:
4+
schedule:
5+
- cron: "0 8 * * *" # Every day at 1am PDT
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out repo
13+
uses: actions/checkout@v4
14+
with:
15+
token: ${{ secrets.WORKFLOW_PUSH_BOT_TOKEN }}
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
20+
- name: Install npm packages
21+
run: npm install
22+
23+
- name: Update README with latest sponsor data
24+
run: npm run build:readme
25+
26+
- name: Setup Git
27+
run: |
28+
git config user.name "GitHub Actions Bot"
29+
git config user.email "<[email protected]>"
30+
31+
- name: Save updated files
32+
run: |
33+
chmod +x ./tools/commit-readme.sh
34+
./tools/commit-readme.sh

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,20 @@ Any other rules that catch potential problems in JSON are welcome to be implemen
208208

209209
Apache 2.0
210210

211-
## Sponsors
212-
213211
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
214212
<!--sponsorsstart-->
215-
<!--sponsorsend-->
216213

217-
<!--techsponsorsstart-->
218-
<!--techsponsorsend-->
214+
## Sponsors
215+
216+
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
217+
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
218+
219+
<h3>Platinum Sponsors</h3>
220+
<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>
221+
<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>
222+
<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>
223+
<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>
224+
<h3>Technology Sponsors</h3>
225+
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.
226+
<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>
227+
<!--sponsorsend-->

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"build:dedupe-types": "node tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
4545
"build:cts": "node -e \"fs.copyFileSync('dist/esm/index.d.ts', 'dist/cjs/index.d.cts')\"",
4646
"build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
47+
"build:readme": "node tools/update-readme.js",
4748
"test:jsr": "npx jsr@latest publish --dry-run",
4849
"pretest": "npm run build",
4950
"lint": "eslint",
@@ -71,6 +72,7 @@
7172
"dedent": "^1.5.3",
7273
"eslint": "^9.11.1",
7374
"eslint-config-eslint": "^11.0.0",
75+
"got": "^14.4.2",
7476
"lint-staged": "^15.2.7",
7577
"mocha": "^10.4.0",
7678
"prettier": "^3.3.2",

tools/commit-readme.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
#------------------------------------------------------------------------------
4+
# Commits the data files if any have changed
5+
#------------------------------------------------------------------------------
6+
7+
if [ -z "$(git status --porcelain)" ]; then
8+
echo "Data did not change."
9+
else
10+
echo "Data changed!"
11+
12+
# commit the result
13+
git add README.md
14+
git commit -m "docs: Update README sponsors"
15+
16+
# push back to source control
17+
git push origin HEAD
18+
fi

tools/update-readme.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @fileoverview Script to update the README with sponsors details in all packages.
3+
*
4+
* node tools/update-readme.js
5+
*
6+
* @author Milos Djermanovic
7+
*/
8+
9+
//-----------------------------------------------------------------------------
10+
// Requirements
11+
//-----------------------------------------------------------------------------
12+
13+
import { readFileSync, writeFileSync } from "node:fs";
14+
import got from "got";
15+
16+
//-----------------------------------------------------------------------------
17+
// Data
18+
//-----------------------------------------------------------------------------
19+
20+
const SPONSORS_URL =
21+
"https://raw.githubusercontent.com/eslint/eslint.org/main/includes/sponsors.md";
22+
23+
const README_FILE_PATH = "./README.md";
24+
25+
//-----------------------------------------------------------------------------
26+
// Helpers
27+
//-----------------------------------------------------------------------------
28+
29+
/**
30+
* Fetches the latest sponsors from the website.
31+
* @returns {Promise<string>}} Prerendered sponsors markdown.
32+
*/
33+
async function fetchSponsorsMarkdown() {
34+
return got(SPONSORS_URL).text();
35+
}
36+
37+
//-----------------------------------------------------------------------------
38+
// Main
39+
//-----------------------------------------------------------------------------
40+
41+
const allSponsors = await fetchSponsorsMarkdown();
42+
43+
// read readme file
44+
const readme = readFileSync(README_FILE_PATH, "utf8");
45+
46+
let newReadme = readme.replace(
47+
/<!--sponsorsstart-->[\w\W]*?<!--sponsorsend-->/u,
48+
`<!--sponsorsstart-->\n\n${allSponsors}\n<!--sponsorsend-->`,
49+
);
50+
51+
// replace multiple consecutive blank lines with just one blank line
52+
newReadme = newReadme.replace(/(?<=^|\n)\n{2,}/gu, "\n");
53+
54+
// output to the files
55+
writeFileSync(README_FILE_PATH, newReadme, "utf8");

0 commit comments

Comments
 (0)