From 0158ad18433aef8a1bc2166900dfe1b75a398fba Mon Sep 17 00:00:00 2001 From: Mattia Date: Wed, 25 Nov 2026 19:58:48 +0100 Subject: [PATCH] feat: declarer accreditations distribuable depuis BS-accreditations v1.0.0 Ajoute le champ distributable pour distinguer un module integre d'un module installable, et pointe accreditations vers son nouveau depot. --- README.md | 47 ++++++++++++------------- catalog.json | 56 ++++++++++++++++++++++++------ scripts/validate.mjs | 82 ++++++++++++++++++++++++++++++-------------- 3 files changed, 126 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 6a38600..4a60547 100644 --- a/README.md +++ b/README.md @@ -8,35 +8,36 @@ integrés au monorepo (`bundled`) ou installables depuis leur propre dépôt ## Modules -| id | source | emplacement | env | -| --- | --- | --- | --- | -| `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` | — | +| id | source | emplacement | distribue | env | +| --- | --- | --- | --- | --- | +| `accreditations` | bundled | `modules/accreditations` | `v1.0.0` | `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` | oui | — | +| `daily-quote` | external | `mprnl/BS-daily-quote` `v1.0.0` | oui | — | ## 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. +- `source: bundled` : le module vit dans `mprnl/backstage`. +- `source: external` : le module vit dans son dépôt `mprnl/BS-*`. +- `distributable` : `true` quand un dépôt distant existe et porte une ref figée, + `repo`, `ref` et `visibility` renseignés. Un module peut être `bundled` **et** + `distributable` : c'est le cas d'`accreditations`, encore chargé par le + monorepo mais déjà installable depuis son dépôt. +- `ref` ne change qu'après une release du dépôt du module, 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 b56beeb..b1bc414 100644 --- a/catalog.json +++ b/catalog.json @@ -3,12 +3,15 @@ "id": "accreditations", "source": "bundled", "path": "modules/accreditations", - "repo": null, - "ref": null, + "repo": "https://github.com/mprnl/BS-accreditations", + "ref": "v1.0.0", + "distributable": true, "description": "Scan des emails d'accréditation, fiches de demande et relance J+7.", "kit": "^0.1.0", - "env": ["GROQ_API_KEY"], - "visibility": null + "env": [ + "GROQ_API_KEY" + ], + "visibility": "public" }, { "id": "calendar", @@ -16,9 +19,13 @@ "path": "modules/calendar", "repo": null, "ref": null, + "distributable": false, "description": "Google Calendar : création externe, recherche non fiable.", "kit": "^0.1.0", - "env": ["GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET"], + "env": [ + "GOOGLE_CLIENT_ID", + "GOOGLE_CLIENT_SECRET" + ], "visibility": null }, { @@ -27,9 +34,12 @@ "path": "modules/concerts", "repo": null, "ref": null, + "distributable": false, "description": "Concerts suivis et préparation terrain.", "kit": "^0.1.0", - "env": ["OPENWEATHERMAP_API_KEY"], + "env": [ + "OPENWEATHERMAP_API_KEY" + ], "visibility": null }, { @@ -38,6 +48,7 @@ "path": "modules/daily-brief", "repo": null, "ref": null, + "distributable": false, "description": "Job du brief du jour. Aucune page, aucun outil.", "kit": "^0.1.0", "env": [], @@ -49,9 +60,13 @@ "path": "modules/emails", "repo": null, "ref": null, + "distributable": false, "description": "Gmail : lecture non fiable, envoi confirmé.", "kit": "^0.1.0", - "env": ["GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET"], + "env": [ + "GOOGLE_CLIENT_ID", + "GOOGLE_CLIENT_SECRET" + ], "visibility": null }, { @@ -60,6 +75,7 @@ "path": "modules/followups", "repo": null, "ref": null, + "distributable": false, "description": "Relances datées, écriture vérifiée par relecture.", "kit": "^0.1.0", "env": [], @@ -71,9 +87,13 @@ "path": "modules/github", "repo": null, "ref": null, + "distributable": false, "description": "Issues GitHub : lecture non fiable, création externe.", "kit": "^0.1.0", - "env": ["GITHUB_TOKEN", "GITHUB_REPO"], + "env": [ + "GITHUB_TOKEN", + "GITHUB_REPO" + ], "visibility": null }, { @@ -82,6 +102,7 @@ "path": "modules/photo", "repo": null, "ref": null, + "distributable": false, "description": "Shootings photo, écritures vérifiées par relecture.", "kit": "^0.1.0", "env": [], @@ -93,6 +114,7 @@ "path": "modules/reminders", "repo": null, "ref": null, + "distributable": false, "description": "Rappels : module pilote du noyau modulaire.", "kit": "^0.1.0", "env": [], @@ -104,9 +126,13 @@ "path": "modules/schedule", "repo": null, "ref": null, + "distributable": false, "description": "Emploi du temps CESAR en lecture.", "kit": "^0.1.0", - "env": ["CESAR_USERNAME", "CESAR_PASSWORD"], + "env": [ + "CESAR_USERNAME", + "CESAR_PASSWORD" + ], "visibility": null }, { @@ -115,9 +141,12 @@ "path": "modules/weather", "repo": null, "ref": null, + "distributable": false, "description": "Météo, lecture externe non fiable.", "kit": "^0.1.0", - "env": ["OPENWEATHERMAP_API_KEY"], + "env": [ + "OPENWEATHERMAP_API_KEY" + ], "visibility": null }, { @@ -126,9 +155,12 @@ "path": "modules/web", "repo": null, "ref": null, + "distributable": false, "description": "Recherche web et métadonnées de page, non fiable.", "kit": "^0.1.0", - "env": ["BRAVE_SEARCH_API_KEY"], + "env": [ + "BRAVE_SEARCH_API_KEY" + ], "visibility": null }, { @@ -137,6 +169,7 @@ "path": null, "repo": "https://github.com/mprnl/BS-watch-later", "ref": "v1.0.1", + "distributable": true, "description": "Lien à regarder plus tard, avec page, rail, panneau et carte d'accueil.", "kit": "^0.1.0", "env": [], @@ -148,6 +181,7 @@ "path": null, "repo": "https://github.com/mprnl/BS-daily-quote", "ref": "v1.0.0", + "distributable": true, "description": "Une citation par jour, locale et déterministe. Module de référence.", "kit": "^0.1.0", "env": [], diff --git a/scripts/validate.mjs b/scripts/validate.mjs index 70cdf18..db20d9f 100644 --- a/scripts/validate.mjs +++ b/scripts/validate.mjs @@ -1,6 +1,17 @@ import { readFileSync } from "node:fs"; -const REQUIRED = ["id", "source", "path", "repo", "ref", "description", "kit", "env", "visibility"]; +const REQUIRED = [ + "id", + "source", + "path", + "repo", + "ref", + "distributable", + "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,14 +22,50 @@ 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 = entry?.id ? `${entry.id}` : `entree ${index}`; +function checkSource(where, entry) { + if (!SOURCES.has(entry.source)) errors.push(`${where} : source doit etre bundled ou external`); + + if (entry.source === "bundled" && (typeof entry.path !== "string" || !entry.path.startsWith("modules/"))) { + errors.push(`${where} : un module bundled declare son path dans modules/`); + } + if (entry.source === "external" && entry.path !== null) { + errors.push(`${where} : un module external n'a pas de path`); + } + if (entry.source === "external" && entry.distributable !== true) { + errors.push(`${where} : un module external est toujours distribuable`); + } +} + +function checkDistribution(where, entry) { + if (entry.distributable === false) { + if (entry.repo !== null || entry.ref !== null || entry.visibility !== null) { + errors.push(`${where} : un module non distribuable n'a ni repo, ni ref, ni visibility`); + } + return; + } + + if (entry.distributable !== true) { + errors.push(`${where} : distributable doit etre un booleen`); + return; + } + + 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`); +} +for (const [index, entry] of entries.entries()) { if (typeof entry !== "object" || entry === null) { - errors.push(`${where} : objet attendu`); + errors.push(`entree ${index} : objet attendu`); continue; } + const where = typeof entry.id === "string" && entry.id.length > 0 ? entry.id : `entree ${index}`; + for (const key of REQUIRED) { if (!(key in entry)) errors.push(`${where} : champ manquant ${key}`); } @@ -27,26 +74,8 @@ for (const [index, entry] of entries.entries()) { else if (seen.has(entry.id)) errors.push(`${where} : id duplique`); else seen.add(entry.id); - if (!SOURCES.has(entry.source)) errors.push(`${where} : source doit etre bundled ou external`); - - 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 (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`); - } + checkSource(where, entry); + checkDistribution(where, entry); if (!Array.isArray(entry.env) || entry.env.some((name) => typeof name !== "string")) { errors.push(`${where} : env doit etre un tableau de chaines`); @@ -55,10 +84,13 @@ for (const [index, entry] of entries.entries()) { const bundled = entries.filter((entry) => entry.source === "bundled").length; const external = entries.length - bundled; +const distributable = entries.filter((entry) => entry.distributable === true).length; if (errors.length > 0) { for (const error of errors) console.error(`- ${error}`); process.exit(1); } -console.log(`catalog.json valide : ${entries.length} module(s), ${bundled} integres, ${external} externes`); +console.log( + `catalog.json valide : ${entries.length} module(s), ${bundled} integres, ${external} externes, ${distributable} distribuable(s)` +);