Skip to content

Commit

Permalink
Auto update the README for new extensions added (#145)
Browse files Browse the repository at this point in the history
* Auto update the README for new extensions added

* Whoops, on cron only

* Add the actual push part

* Set to node:22

* Unique job IDs
  • Loading branch information
ukmadlz authored Feb 11, 2025
1 parent 5f26260 commit 6104ea3
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
NODE_OPTIONS: --max_old_space_size=6144

jobs:
build:
directus-validate:
name: Validate
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
NODE_OPTIONS: --max_old_space_size=6144

jobs:
build:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
NODE_OPTIONS: --max_old_space_size=6144

jobs:
build:
check-package-json:
name: Package.json
runs-on: ubuntu-latest
steps:
Expand All @@ -25,7 +25,7 @@ jobs:
uses: pnpm/[email protected]
- name: Package
run: pnpm package:json
lockfile:
check-package-lockfile:
name: Lockfiles
runs-on: ubuntu-latest
steps:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: README

on:
# Since we're pushing from this CI, don't run this on the push event because
# that'll trigger an infinite loop
# push: [ main ]

# Add a schedule to run the job every day at 0:00 UTC
schedule:
- cron: '0 0 * * *'

# Allow running this workflow manually
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
NODE_OPTIONS: --max_old_space_size=6144

jobs:
update-readme:
name: Update & PR
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup pnpm
uses: pnpm/[email protected]
- name: Install dependencies
shell: bash
run: pnpm install
- name: Update README
run: pnpm run readme
- name: Commit changes
run: |
git config --local user.name \
"github-actions[bot]"
git config --local user.email \
"41898282+github-actions[bot]@users.noreply.github.com"
git add .
git diff-index --quiet HEAD \
|| git commit -m "Autocommit: updated at $(date -u)"
- name: Push changes
uses: ad-m/github-push-action@master
with:
force_with_lease: true
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,31 @@
"node": ">=18.18.0",
"pnpm": "~9"
},
"directus:meta": {
"maintained": [
"spreadsheet-layout",
"gantt-chart-layout",
"tour-group-interface",
"command-palette-module",
"calculated-fields-bundle"
]
},
"scripts": {
"premkcert": "mkcert -install",
"mkcert": "mkcert -ecdsa -key-file .local/caddy/key.pem -cert-file .local/caddy/cert.pem extensions.directus.labs",
"dev": "pnpm --stream -r dev",
"build": "pnpm --recursive run build",
"validate": "pnpm --recursive run validate",
"readme": "node ./scripts/update-readme.js",
"package:json": "pnpm --recursive exec node ../../scripts/check-package-json.js",
"package:lockfile": "pnpm --recursive exec node ../../scripts/check-lock-files.js",
"lint": "eslint --flag unstable_config_lookup_from_file --cache .",
"lint:fix": "pnpm run lint --fix"
},
"dependencies": {
"@directus/format-title": "^12.0.0",
"mustache": "^4.2.0"
},
"devDependencies": {
"@directus/eslint-config": "github:directus/eslint-config#hannes/temp-workaround",
"@nuxt/eslint-config": "^0.7.5",
Expand Down
27 changes: 24 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions scripts/templates/readme.md. mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
![Directus Labs Extensions](https://github.com/directus-labs/extensions/assets/1461554/aae72c6c-e47a-4a6f-968a-5cf1d6b5a73d)

---

## 🐰  Introduction

This repository is for our extensions published under the Directus Labs program. Unlike the core [@directus/directus](https://github.com/directus/directus) project, extensions here may not be actively developed after their initial release unless they are indicated as maintained in the table below.

## 📦  Extensions

The extensions in this repository are all published to the Directus Marketplace.

Some of the published extensions may not be compatible with the sandbox requirements currently, and are only available on Directus instances with the `MARKETPLACE_TRUST` env set to `all`.

| Extension | Type | Sandboxed | Maintained |
| --------- | --------- | --------- | ---------- |
${formattedPackages.join('\n')}`;
{{#extensions}}
| [{{name}}](//github.com/directus-labs/extensions/tree/main/packages/{{directory}}) | {{type}} | {{sandboxed}} | {{maintained}} |
{{/extensions}}

## 🔧  Boilerplates

| Extension | System Name | Type |
| -------------------------------------------------------------------------------------------------- | :--------------------- | :-------- |
| [WYSIWYG](//github.com/directus-labs/extensions/tree/main/boilerplates/input-rich-text-html) | `input-rich-text-html` | Interface |
| [Block Editor](//github.com/directus-labs/extensions/tree/main/boilerplates/input-block-editor) | `input-block-editor` | Interface |
| [Table](//github.com/directus-labs/extensions/tree/main/boilerplates/tabular-layout) | `tabular` | Layout |

<br>

## ❤️ &nbsp;Contributing

Please read the [Contributing Guide](//github.com/directus-labs/extensions/blob/main/.github/CONTRIBUTING.md) for this project before submitting Pull Requests or Issues.

All security vulnerabilities should be reported in accordance with our [Security Policy](//docs.directus.io/contributing/introduction.html#report-security-vulnerability).

Directus is a premium open-source ([BSL 1.1](//github.com/directus/directus/blob/main/license)) project, made possible with support from our passionate core team, talented contributors, and amazing [GitHub Sponsors](//github.com/sponsors/directus). Thank you all!!

© 2004-2024, Monospace, Inc.
36 changes: 36 additions & 0 deletions scripts/update-readme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const fs = require('node:fs');
const { formatTitle } = require('@directus/format-title');
const Mustache = require('mustache');

const metaData = JSON.parse(fs.readFileSync(`./package.json`))['directus:meta'];

/* Update the packages */
const packages = fs.readdirSync('./packages');

function removePrefix(name) {
if (name.startsWith('@')) {
name = name.split('/')[1];
}

if (name.startsWith('directus-extension-')) {
name = name.substring('directus-extension-'.length);
}

return name;
}

const formattedPackages = packages.map((packageDir) => {
const packageJson = JSON.parse(fs.readFileSync(`./packages/${packageDir}/package.json`));
return {
name: formatTitle(removePrefix(packageJson.name)),
type: formatTitle(packageJson['directus:extension'].type),
sandboxed: (packageJson['directus:extension'].sandbox ? '✅' : 'N/A'),
maintained: (metaData.maintained.includes(packageDir) ? '⭐' : ''),
directory: packageDir,
};
});

const readmeTemplate = fs.readFileSync('scripts/templates/readme.md. mustache').toString();
const readmeOutput = Mustache.render(readmeTemplate, { extensions: formattedPackages });

fs.writeFileSync('./readme.md', readmeOutput);

0 comments on commit 6104ea3

Please sign in to comment.