Skip to content

Commit

Permalink
Auto update the README for new extensions added
Browse files Browse the repository at this point in the history
  • Loading branch information
ukmadlz committed Feb 11, 2025
1 parent 5f26260 commit 4938f44
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 3 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: README

on:
pull_request:
branches:
- main

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

env:
NODE_OPTIONS: --max_old_space_size=6144

jobs:
build:
name: Update & PR
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
- 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)"
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 4938f44

Please sign in to comment.