Skip to content

Commit

Permalink
docs: Add sponsors to README (#287)
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 93ff7c4 commit 3abc1cf
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 1 deletion.
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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ You can individually disable rules in Markdown using HTML comments, such as:
| `commonmark` | Parse using [CommonMark](https://commonmark.org) Markdown format |
| `gfm` | Parse using [GitHub-Flavored Markdown](https://github.github.com/gfm/) format |


In order to individually configure a language in your `eslint.config.js` file, import `@eslint/markdown` and configure a `language`:

```js
Expand Down Expand Up @@ -152,3 +151,20 @@ $ npm test
```

This project follows the [ESLint contribution guidelines](https://eslint.org/docs/latest/contribute/).

<!-- 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-->
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"build:rules": "node tools/build-rules.js",
"build:update-rules-docs": "node tools/update-rules-docs.js",
"build": "npm run build:rules && rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:update-rules-docs",
"build:readme": "node tools/update-readme.js",
"prepare": "node ./npm-prepare.cjs && npm run build",
"test": "c8 mocha \"tests/**/*.test.js\" --timeout 30000",
"test:jsr": "npx jsr@latest publish --dry-run"
Expand All @@ -68,6 +69,7 @@
"eslint": "^9.10.0",
"eslint-config-eslint": "^11.0.0",
"globals": "^15.1.0",
"got": "^14.4.2",
"lint-staged": "^15.2.9",
"mocha": "^10.6.0",
"prettier": "^3.3.3",
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 3abc1cf

Please sign in to comment.