From 232347a178b8cb95c402e1bdacb6357bdbc9b6b8 Mon Sep 17 00:00:00 2001 From: Mattia Date: Wed, 25 Nov 2026 19:22:29 +0100 Subject: [PATCH] feat: cataloguer les douze modules integres en plus des deux externes Le catalogue ne listait que les modules deja extraits. Il distingue desormais source bundled et external, et couvre les quatorze modules du produit. --- README.md | 43 +++++++++---- catalog.json | 140 ++++++++++++++++++++++++++++++++++++++++++- scripts/validate.mjs | 35 +++++++---- 3 files changed, 193 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 5351b53..6a38600 100644 --- a/README.md +++ b/README.md @@ -2,24 +2,41 @@ Catalogue des modules de [BACKSTAGE](https://github.com/mprnl/backstage). -L'application lit ce dépôt pour proposer les modules installables, sans que -l'utilisateur ait à connaître une URL. Un module vit dans son propre dépôt -`mprnl/BS-` ; ce dépôt ne contient que la liste et son schéma. +L'application lit ce dépôt pour connaître l'ensemble des modules, qu'ils soient +integrés au monorepo (`bundled`) ou installables depuis leur propre dépôt +(`external`, `mprnl/BS-`). -## Entrées +## Modules -| id | dépôt | ref | visibilité | +| id | source | emplacement | env | | --- | --- | --- | --- | -| `watch-later` | `mprnl/BS-watch-later` | `v1.0.1` | privé | -| `daily-quote` | `mprnl/BS-daily-quote` | `v1.0.0` | public | - -## Règles - -- Une entrée pointe vers un **tag ou un commit**, jamais une branche mobile. -- `id` doit être unique, et égal à l'identifiant déclaré par le module. -- `ref` ne se met à jour qu'après une release du dépôt du module. +| `accreditations` | bundled | `modules/accreditations` | `GROQ_API_KEY` | +| `calendar` | bundled | `modules/calendar` | Google | +| `concerts` | bundled | `modules/concerts` | `OPENWEATHERMAP_API_KEY` | +| `daily-brief` | bundled | `modules/daily-brief` | — | +| `emails` | bundled | `modules/emails` | Google | +| `followups` | bundled | `modules/followups` | — | +| `github` | bundled | `modules/github` | `GITHUB_TOKEN`, `GITHUB_REPO` | +| `photo` | bundled | `modules/photo` | — | +| `reminders` | bundled | `modules/reminders` | — | +| `schedule` | bundled | `modules/schedule` | `CESAR_USERNAME`, `CESAR_PASSWORD` | +| `weather` | bundled | `modules/weather` | `OPENWEATHERMAP_API_KEY` | +| `web` | bundled | `modules/web` | `BRAVE_SEARCH_API_KEY` | +| `watch-later` | external | `mprnl/BS-watch-later` `v1.0.1` | — | +| `daily-quote` | external | `mprnl/BS-daily-quote` `v1.0.0` | — | + +## Regles + +- `bundled` : le module vit dans `mprnl/backstage`, il se désactive mais ne + s'installe pas. +- `external` : le module vit dans son dépôt `mprnl/BS-*` et s'installe avec une + ref figée (tag ou commit), jamais une branche mobile. +- `id` unique, égal à l'identifiant déclaré par le module. +- `ref` ne change qu'après une release du dépôt du module. - Le catalogue n'est pas une source de confiance : l'application revérifie l'`id`, la ref figée et la compatibilité du kit avant d'installer. +- Un module `bundled` qui importe `@/lib/*` n'est pas distribuable : il ne + bascule pas en `external` avant que ce point soit tranché (#255). ## Validation diff --git a/catalog.json b/catalog.json index efb3ff0..b56beeb 100644 --- a/catalog.json +++ b/catalog.json @@ -1,18 +1,154 @@ [ + { + "id": "accreditations", + "source": "bundled", + "path": "modules/accreditations", + "repo": null, + "ref": null, + "description": "Scan des emails d'accréditation, fiches de demande et relance J+7.", + "kit": "^0.1.0", + "env": ["GROQ_API_KEY"], + "visibility": null + }, + { + "id": "calendar", + "source": "bundled", + "path": "modules/calendar", + "repo": null, + "ref": null, + "description": "Google Calendar : création externe, recherche non fiable.", + "kit": "^0.1.0", + "env": ["GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET"], + "visibility": null + }, + { + "id": "concerts", + "source": "bundled", + "path": "modules/concerts", + "repo": null, + "ref": null, + "description": "Concerts suivis et préparation terrain.", + "kit": "^0.1.0", + "env": ["OPENWEATHERMAP_API_KEY"], + "visibility": null + }, + { + "id": "daily-brief", + "source": "bundled", + "path": "modules/daily-brief", + "repo": null, + "ref": null, + "description": "Job du brief du jour. Aucune page, aucun outil.", + "kit": "^0.1.0", + "env": [], + "visibility": null + }, + { + "id": "emails", + "source": "bundled", + "path": "modules/emails", + "repo": null, + "ref": null, + "description": "Gmail : lecture non fiable, envoi confirmé.", + "kit": "^0.1.0", + "env": ["GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET"], + "visibility": null + }, + { + "id": "followups", + "source": "bundled", + "path": "modules/followups", + "repo": null, + "ref": null, + "description": "Relances datées, écriture vérifiée par relecture.", + "kit": "^0.1.0", + "env": [], + "visibility": null + }, + { + "id": "github", + "source": "bundled", + "path": "modules/github", + "repo": null, + "ref": null, + "description": "Issues GitHub : lecture non fiable, création externe.", + "kit": "^0.1.0", + "env": ["GITHUB_TOKEN", "GITHUB_REPO"], + "visibility": null + }, + { + "id": "photo", + "source": "bundled", + "path": "modules/photo", + "repo": null, + "ref": null, + "description": "Shootings photo, écritures vérifiées par relecture.", + "kit": "^0.1.0", + "env": [], + "visibility": null + }, + { + "id": "reminders", + "source": "bundled", + "path": "modules/reminders", + "repo": null, + "ref": null, + "description": "Rappels : module pilote du noyau modulaire.", + "kit": "^0.1.0", + "env": [], + "visibility": null + }, + { + "id": "schedule", + "source": "bundled", + "path": "modules/schedule", + "repo": null, + "ref": null, + "description": "Emploi du temps CESAR en lecture.", + "kit": "^0.1.0", + "env": ["CESAR_USERNAME", "CESAR_PASSWORD"], + "visibility": null + }, + { + "id": "weather", + "source": "bundled", + "path": "modules/weather", + "repo": null, + "ref": null, + "description": "Météo, lecture externe non fiable.", + "kit": "^0.1.0", + "env": ["OPENWEATHERMAP_API_KEY"], + "visibility": null + }, + { + "id": "web", + "source": "bundled", + "path": "modules/web", + "repo": null, + "ref": null, + "description": "Recherche web et métadonnées de page, non fiable.", + "kit": "^0.1.0", + "env": ["BRAVE_SEARCH_API_KEY"], + "visibility": null + }, { "id": "watch-later", + "source": "external", + "path": null, "repo": "https://github.com/mprnl/BS-watch-later", "ref": "v1.0.1", - "description": "Lien a regarder plus tard, avec page, rail, panneau et carte d'accueil.", + "description": "Lien à regarder plus tard, avec page, rail, panneau et carte d'accueil.", "kit": "^0.1.0", "env": [], "visibility": "private" }, { "id": "daily-quote", + "source": "external", + "path": null, "repo": "https://github.com/mprnl/BS-daily-quote", "ref": "v1.0.0", - "description": "Une citation par jour, locale et deterministe. Module de reference.", + "description": "Une citation par jour, locale et déterministe. Module de référence.", "kit": "^0.1.0", "env": [], "visibility": "public" diff --git a/scripts/validate.mjs b/scripts/validate.mjs index 1705120..70cdf18 100644 --- a/scripts/validate.mjs +++ b/scripts/validate.mjs @@ -1,6 +1,7 @@ import { readFileSync } from "node:fs"; -const REQUIRED = ["id", "repo", "ref", "description", "kit", "env", "visibility"]; +const REQUIRED = ["id", "source", "path", "repo", "ref", "description", "kit", "env", "visibility"]; +const SOURCES = new Set(["bundled", "external"]); const VISIBILITY = new Set(["public", "private"]); const MOVING_REF = /^(main|master|develop|dev|HEAD)$/; @@ -11,7 +12,7 @@ const seen = new Set(); if (!Array.isArray(entries)) errors.push("catalog.json doit contenir un tableau"); for (const [index, entry] of entries.entries()) { - const where = `entree ${index}`; + const where = entry?.id ? `${entry.id}` : `entree ${index}`; if (typeof entry !== "object" || entry === null) { errors.push(`${where} : objet attendu`); @@ -23,27 +24,41 @@ for (const [index, entry] of entries.entries()) { } if (typeof entry.id !== "string" || entry.id.length === 0) errors.push(`${where} : id invalide`); - else if (seen.has(entry.id)) errors.push(`${where} : id duplique ${entry.id}`); + else if (seen.has(entry.id)) errors.push(`${where} : id duplique`); else seen.add(entry.id); - if (typeof entry.repo !== "string" || !entry.repo.startsWith("https://github.com/mprnl/BS-")) { - errors.push(`${where} : repo doit etre une URL https://github.com/mprnl/BS-*`); - } + if (!SOURCES.has(entry.source)) errors.push(`${where} : source doit etre bundled ou external`); - if (typeof entry.ref !== "string" || MOVING_REF.test(entry.ref) || entry.ref.length === 0) { - errors.push(`${where} : ref doit etre un tag ou un commit, pas une branche`); + if (entry.source === "bundled") { + if (typeof entry.path !== "string" || !entry.path.startsWith("modules/")) { + errors.push(`${where} : un module bundled declare son path dans modules/`); + } + if (entry.repo !== null || entry.ref !== null) errors.push(`${where} : un module bundled n'a ni repo ni ref`); + if (entry.visibility !== null) errors.push(`${where} : un module bundled a visibility null`); } - if (!VISIBILITY.has(entry.visibility)) errors.push(`${where} : visibility doit etre public ou private`); + if (entry.source === "external") { + if (entry.path !== null) errors.push(`${where} : un module external n'a pas de path`); + if (typeof entry.repo !== "string" || !entry.repo.startsWith("https://github.com/mprnl/BS-")) { + errors.push(`${where} : repo doit etre une URL https://github.com/mprnl/BS-*`); + } + if (typeof entry.ref !== "string" || entry.ref.length === 0 || MOVING_REF.test(entry.ref)) { + errors.push(`${where} : ref doit etre un tag ou un commit, pas une branche`); + } + if (!VISIBILITY.has(entry.visibility)) errors.push(`${where} : visibility doit etre public ou private`); + } if (!Array.isArray(entry.env) || entry.env.some((name) => typeof name !== "string")) { errors.push(`${where} : env doit etre un tableau de chaines`); } } +const bundled = entries.filter((entry) => entry.source === "bundled").length; +const external = entries.length - bundled; + if (errors.length > 0) { for (const error of errors) console.error(`- ${error}`); process.exit(1); } -console.log(`catalog.json valide : ${entries.length} module(s)`); +console.log(`catalog.json valide : ${entries.length} module(s), ${bundled} integres, ${external} externes`);