fix: list the official plugins from JSR, where they now live #1

Merged
chrnx merged 1 commits from fix/jsr-only-entries into develop 2026-09-24 15:29:22 +00:00
6 changed files with 30 additions and 48 deletions

No files matched your search

-14
View File
@@ -1,14 +0,0 @@
// What the seed plugins declare, copied from their `package.json` in Green-Tea/plugins.
//
// This exists so the site can be designed and reviewed before the packages ship. It is used ONLY
// when a registry has no answer and `CI` is unset — in GitHub Actions a missing package fails the
// build instead, which is where the real check lives.
//
// **Delete this file, and its import in `src/pages/index.astro`, once the three are published.**
// Every entry here is a claim nobody verified; the registry is the source of truth and this is a
// stand-in for a registry that does not have the package yet.
export const PREVIEW = {
'@green-tea/jwt': { version: '26.9.0-beta.0', engines: { node: '>=22', deno: '>=2', bun: '>=1.3' } },
'@green-tea/metrics': { version: '26.9.0-beta.0', engines: { node: '>=22', deno: '>=2', bun: '>=1.3' } },
'@green-tea/rate-limit': { version: '26.9.0-beta.0', engines: { node: '>=22', deno: '>=2', bun: '>=1.3' } },
};
+9 -11
View File
@@ -10,8 +10,8 @@ export const RUNTIMES = Object.freeze(['node', 'deno', 'bun', 'workerd']);
*
* In GitHub Actions a package that does not answer is a failure — that is the check, and it runs
* against the live registries on every pull request and every push to main. Locally it is a
* warning and the card renders from `preview.mjs`, because a site you cannot look at until its
* packages ship is a site nobody can design.
* warning and the entry is left out, so the site can still be looked at while one package is
* broken — without rendering data nobody read from a registry.
*/
export const STRICT = process.env.CI === 'true';
@@ -109,19 +109,19 @@ export function declaredRuntimes({ engines, runtimeCompat }) {
}
/**
* Everything one card needs, live where possible.
* Everything one card needs, live.
*
* Under `CI` a registry that does not answer throws and fails the build, which is the rule that
* stops a stale or half-empty listing reaching production. Off CI it falls back to `preview.mjs`
* and says so, loudly, once per package.
* stops a stale or half-empty listing reaching production. Off CI it warns and returns `null`, and
* the caller leaves the entry out.
*/
export async function readEntry(entry, preview) {
export async function readEntry(entry) {
try {
const npm = entry.npm ? await readNpm(entry.npm) : undefined;
const jsr = entry.jsr ? await readJsr(entry.jsr) : undefined;
return {
version: (npm ?? jsr).newest,
version: (jsr ?? npm).newest,
// npm's `engines` is the richer of the two — JSR's `runtimeCompat` is empty far more often,
// including on `@green-tea/core` itself — so it wins when both exist.
runtimes: declaredRuntimes({ engines: npm?.engines, runtimeCompat: jsr?.runtimeCompat }),
@@ -129,10 +129,8 @@ export async function readEntry(entry, preview) {
};
} catch (error) {
if (STRICT) throw error;
const fallback = preview[entry.npm ?? entry.jsr];
if (!fallback) throw error;
console.warn(` not published yet, rendering from preview data: ${entry.npm ?? entry.jsr}`);
console.warn(` left out, registry did not answer: ${entry.jsr ?? entry.npm} (${error.message})`);
return { version: fallback.version, runtimes: declaredRuntimes({ engines: fallback.engines }), live: false };
return null;
}
}
-1
View File
@@ -1,4 +1,3 @@
npm: "@green-tea/jwt"
jsr: "@green-tea/jwt"
repo: https://github.com/Expressive-Tea/green-tea-plugins
description: "Loads JWT signing keys at boot and publishes a sign/verify registry into the graph."
-1
View File
@@ -1,4 +1,3 @@
npm: "@green-tea/metrics"
jsr: "@green-tea/metrics"
repo: https://github.com/Expressive-Tea/green-tea-plugins
description: "Counts green-tea's lifecycle events and renders them in the Prometheus text format."
-1
View File
@@ -1,4 +1,3 @@
npm: "@green-tea/rate-limit"
jsr: "@green-tea/rate-limit"
repo: https://github.com/Expressive-Tea/green-tea-plugins
description: "A per-request rate limiter with a branded 429 and a swept in-memory store."
+21 -20
View File
@@ -1,34 +1,35 @@
---
import { getCollection } from 'astro:content';
import { readEntry } from '../../scripts/registry.mjs';
// Remove this import together with scripts/preview.mjs once the seed plugins are published.
import { PREVIEW } from '../../scripts/preview.mjs';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import PluginCard from '../components/PluginCard.astro';
import '../styles/global.css';
// Read at build time, never at request time — this site is static files on cPanel. Under CI a
// registry that does not answer fails the build; off CI an unpublished package falls back to
// preview data so the page can still be looked at. See scripts/registry.mjs.
// registry that does not answer fails the build; off CI that entry is left out. See
// scripts/registry.mjs.
const entries = await getCollection('plugins');
const plugins = await Promise.all(
entries.map(async (entry) => {
const { version, runtimes } = await readEntry(entry.data, PREVIEW);
const plugins = (
await Promise.all(
entries.map(async (entry) => {
const live = await readEntry(entry.data);
if (!live) return null;
return {
name: entry.data.npm ?? entry.data.jsr,
description: entry.data.description,
repo: entry.data.repo,
npm: entry.data.npm,
jsr: entry.data.jsr,
version,
runtimes,
// An internal plugin could be listed on JSR alone and still be ours, so check both fields.
internal: (entry.data.npm ?? entry.data.jsr ?? '').startsWith('@green-tea/'),
};
}),
);
return {
name: entry.data.jsr ?? entry.data.npm,
description: entry.data.description,
repo: entry.data.repo,
npm: entry.data.npm,
jsr: entry.data.jsr,
version: live.version,
runtimes: live.runtimes,
// An internal plugin could be listed on npm alone and still be ours, so check both fields.
internal: (entry.data.jsr ?? entry.data.npm ?? '').startsWith('@green-tea/'),
};
}),
)
).filter((plugin) => plugin !== null);
plugins.sort((a, b) => a.name.localeCompare(b.name));
---