@roomi-fields/grillhouse 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/cadre/templates/projet/CLAUDE.md +7 -0
  3. package/cadre/templates/projet/docs/ARCHITECTURE.md +15 -0
  4. package/cadre/templates/python/package.json +18 -0
  5. package/charte.md +22 -0
  6. package/docs/ARCHITECTURE.md +58 -17
  7. package/docs/CADRE.md +7 -6
  8. package/docs/INTERFACE.md +96 -32
  9. package/package.json +1 -1
  10. package/scripts/circuit.mjs +44 -8
  11. package/scripts/commande-du-langage.mjs +2 -2
  12. package/scripts/commandes-composees.mjs +156 -0
  13. package/scripts/composition-des-langages.mjs +306 -0
  14. package/scripts/conformite.mjs +1 -3
  15. package/scripts/dernier-vert.mjs +15 -2
  16. package/scripts/engendres.mjs +170 -0
  17. package/scripts/enveloppe/travail-de-la-copie.mjs +82 -8
  18. package/scripts/gardes-du-cadre.mjs +7 -4
  19. package/scripts/grillhouse-maj.mjs +152 -99
  20. package/scripts/index-interfaces.mjs +78 -0
  21. package/scripts/init.mjs +5 -5
  22. package/scripts/integration/file.mjs +74 -13
  23. package/scripts/integration/integrer.mjs +50 -62
  24. package/scripts/jointure.d.ts +26 -13
  25. package/scripts/langages/cargo/binaires.mjs +29 -6
  26. package/scripts/langages/cargo/clippy.mjs +4 -2
  27. package/scripts/langages/cargo/commandes.mjs +45 -7
  28. package/scripts/langages/cargo/exemples.mjs +1 -15
  29. package/scripts/langages/cargo/index-interfaces.mjs +20 -3
  30. package/scripts/langages/cargo/index.mjs +9 -10
  31. package/scripts/langages/cargo/mise-a-jour.mjs +2 -1
  32. package/scripts/langages/cargo/sccache.mjs +29 -0
  33. package/scripts/langages/python/binaires.json +3 -0
  34. package/scripts/langages/python/binaires.mjs +59 -0
  35. package/scripts/langages/python/commandes.mjs +411 -0
  36. package/scripts/langages/python/composants.mjs +272 -0
  37. package/scripts/langages/python/exemples.mjs +260 -0
  38. package/scripts/langages/python/index-interfaces.mjs +77 -0
  39. package/scripts/langages/python/index.mjs +94 -0
  40. package/scripts/langages/python/lot.mjs +76 -0
  41. package/scripts/langages/python/mise-a-jour.mjs +54 -0
  42. package/scripts/langages/python/tailles-des-tests.mjs +102 -0
  43. package/scripts/langages/python/verdict.mjs +85 -0
  44. package/scripts/langages/typescript/exemples.mjs +1 -20
  45. package/scripts/langages/typescript/index-interfaces.mjs +10 -3
  46. package/scripts/langages/typescript/index.mjs +11 -15
  47. package/scripts/langages-des-paquets.mjs +171 -0
  48. package/scripts/langages.mjs +60 -41
  49. package/scripts/migrations/0.27.0-langages-dans-l-architecture.mjs +182 -0
  50. package/scripts/migrations.mjs +2 -0
  51. package/scripts/outils-cles.mjs +1 -1
  52. package/scripts/session-start.sh +34 -9
  53. package/scripts/sources.mjs +2 -1
  54. package/scripts/sous-commandes.mjs +5 -3
  55. package/scripts/tableau-des-composants.mjs +138 -0
  56. package/scripts/verrous/verrou.mjs +3 -2
  57. package/skills/grill/SKILL.md +9 -1
  58. package/skills/pitmaster/SKILL.md +6 -1
  59. package/skills/redacteur/references/documents-d-un-composant.md +12 -0
  60. package/skills/testwriter/SKILL.md +6 -0
@@ -0,0 +1,94 @@
1
+ // The module of language python: what the core asks of a language (scripts/jointure.d.ts,
2
+ // docs/INTERFACE.md), answered for the packages of Python by uv and pytest, as Pants's Python
3
+ // backend reads a pyproject.toml. The core loads it by scripts/langages.mjs, and this module
4
+ // imports of the core its published entries alone.
5
+ //
6
+ // - The manifest of its package, which the guard of the languages asks of a package the
7
+ // architecture declares python (`manifeste`): a pyproject.toml (PEP 621), its group `test` of
8
+ // `[dependency-groups]` (PEP 735) and its uv.lock. Its one tool of npm is smol-toml, the reader
9
+ // of a pyproject.toml (`outils`); uv lives on the machine, installed by the update at its exact
10
+ // version (`binaires`, ./binaires.json). What uv, pytest and Python write in a project: `.venv`,
11
+ // `.pytest_cache`, `__pycache__` (`ignorer`).
12
+ // - Where they write, which the envelope opens to a session (`sorties`): in writing, `.venv` and
13
+ // `.pytest_cache` at the root, where the commands make uv and pytest write for each package
14
+ // (./commandes.mjs), and uv's cache, `~/.cache/uv`; proper to the session, the
15
+ // tree of the bytecode at the root, `__pycache__` (PYTHONPYCACHEPREFIX, ./commandes.mjs); read,
16
+ // the Pythons uv installs, `~/.local/share/uv/python`. The version of Python is uv's choice, from
17
+ // `requires-python` and `.python-version`. The rules that refuse a role that writes pytest run
18
+ // directly (`droits`).
19
+ // - The packages, a file's, the test files, what the testwriter writes, of the manifests too, the
20
+ // readers, the entries of the index of the interfaces (./composants.mjs); the packages touched
21
+ // since a commit and the elements of a lot (./lot.mjs).
22
+ // - The commands `tester`, `verifier`, `typer`, `preparer` and `tests-de-nuit` (./commandes.mjs),
23
+ // each described, never run, and the verdict of a run (./verdict.mjs); the guard of the sizes of
24
+ // the tests (./tailles-des-tests.mjs) and the index of the interfaces up to date, each a command
25
+ // by its name too. The generated file, the index of the interfaces (./index-interfaces.mjs), its
26
+ // command and its check, which the core's takes the place of in a project of several languages.
27
+ // No migration yet.
28
+ // - Its share of the update (./mise-a-jour.mjs): the template `templates/python/`, its test
29
+ // scripts, the generator of the index and the installation of uv.
30
+ import { readFileSync } from 'node:fs';
31
+ import path from 'node:path';
32
+ import { fileURLToPath } from 'node:url';
33
+ import { commandes, GARDES, PYCACHE } from './commandes.mjs';
34
+ import {
35
+ composantDans,
36
+ composants,
37
+ entreesDeLIndex,
38
+ estUnTest,
39
+ joueDesTests,
40
+ lecteurs,
41
+ manifestes,
42
+ } from './composants.mjs';
43
+ import { enRetard, SORTIE } from './index-interfaces.mjs';
44
+ import { elementsDuLot, touches } from './lot.mjs';
45
+ import { miseAJour } from './mise-a-jour.mjs';
46
+ import { verdict } from './verdict.mjs';
47
+
48
+ const ici = nom => path.join(path.dirname(fileURLToPath(import.meta.url)), nom);
49
+
50
+ export default {
51
+ nom: 'python',
52
+ manifeste: 'pyproject.toml',
53
+ outils: ['smol-toml'],
54
+ binaires: JSON.parse(readFileSync(ici('binaires.json'), 'utf8')),
55
+ ignorer: ['.venv', '.pytest_cache', PYCACHE],
56
+ sorties: {
57
+ ecrites: ['.venv/', '.pytest_cache/', '~/.cache/uv/'],
58
+ propres: [PYCACHE],
59
+ lues: ['~/.local/share/uv/python/'],
60
+ },
61
+ // pytest run directly, by itself, by Python or by uv: `npm test` and `npm run verifier` play it.
62
+ droits: [
63
+ 'Bash(pytest*)',
64
+ 'Bash(python -m pytest*)',
65
+ 'Bash(python3 -m pytest*)',
66
+ 'Bash(uv run*pytest*)',
67
+ ],
68
+ composants,
69
+ composantDe: (racine, fichier) => composantDans(composants(racine), racine, fichier),
70
+ matieres: () => [],
71
+ joueDesTests,
72
+ lecteurs,
73
+ touches,
74
+ elementsDuLot,
75
+ commandes,
76
+ verdict,
77
+ estUnTest,
78
+ manifestes,
79
+ fichiersEngendres: () => [
80
+ {
81
+ nom: "l'index des interfaces",
82
+ commande: `node ${JSON.stringify(ici('index-interfaces.mjs'))}`,
83
+ fichiers: [SORTIE],
84
+ lit: ['docs/INTERFACE.md', '**/docs/INTERFACE.md'],
85
+ gardes: ['index-interfaces'],
86
+ entiers: [SORTIE],
87
+ verifier: enRetard,
88
+ },
89
+ ],
90
+ entreesDeLIndex,
91
+ gardes: () => GARDES.map(({ script, args }) => [script, ...args]),
92
+ migrations: [],
93
+ miseAJour,
94
+ };
@@ -0,0 +1,76 @@
1
+ // The changes of a project of Python read by git: the packages touched since a commit (`touches`
2
+ // of the join, scripts/jointure.d.ts) and the elements of a lot (`elementsDuLot`).
3
+ //
4
+ // - The files changed since a commit: what git sees changed, the working tree and the untracked
5
+ // files included (`git diff --name-only --no-renames <depuis>`, `git ls-files -o
6
+ // --exclude-standard`). Each touches the package of the longest folder that holds it
7
+ // (./composants.mjs); a file out of every package is out of the graph. No dependent: the module
8
+ // reads no dependency between packages of Python.
9
+ // - The lot between two commits (`git diff --name-only --no-renames <avant> <apres>`): every file
10
+ // it changes in `fichiers`; the module reads no element of a source of Python, so each `.py` is
11
+ // named in `horsDuService`, which the reviewer surveys himself.
12
+ import { spawnSync } from 'node:child_process';
13
+ import { composantDans, composants } from './composants.mjs';
14
+
15
+ const lignesDeGit = (racine, args) => {
16
+ const r = spawnSync('git', ['-C', racine, ...args, '-z'], {
17
+ encoding: 'utf8',
18
+ maxBuffer: 256 * 1024 * 1024,
19
+ });
20
+ if (r.status !== 0) {
21
+ throw new Error(`⛔ git ${args.join(' ')} : ${r.stderr.trim()}`);
22
+ }
23
+ return r.stdout.split('\0').filter(Boolean);
24
+ };
25
+
26
+ /** The packages the files <fichiers> (from <racine>) touch, and the files out of the graph. */
27
+ export function touchesDesFichiers(racine, fichiers) {
28
+ const liste = composants(racine);
29
+ const touches = new Set();
30
+ const horsGraphe = [];
31
+ for (const f of new Set(fichiers)) {
32
+ const c = composantDans(liste, racine, f);
33
+ if (c) {
34
+ touches.add(c);
35
+ } else {
36
+ horsGraphe.push(f);
37
+ }
38
+ }
39
+ return {
40
+ touches: [...touches].sort((a, b) => a.nom.localeCompare(b.nom)),
41
+ dependants: [],
42
+ horsGraphe: horsGraphe.sort(),
43
+ };
44
+ }
45
+
46
+ /** The packages touched in <racine> since the commit <depuis>, and the files out of the graph. */
47
+ export function touches(racine, { depuis }) {
48
+ return touchesDesFichiers(racine, [
49
+ ...lignesDeGit(racine, ['diff', '--name-only', '--no-renames', depuis]),
50
+ ...lignesDeGit(racine, ['ls-files', '-o', '--exclude-standard']),
51
+ ]);
52
+ }
53
+
54
+ /** The elements of the lot of <racine> between <avant> and <apres>. */
55
+ export function elementsDuLot(racine, { avant, apres }) {
56
+ try {
57
+ const fichiers = [
58
+ ...new Set(lignesDeGit(racine, ['diff', '--name-only', '--no-renames', avant, apres])),
59
+ ].sort();
60
+ return {
61
+ etat: 'fait',
62
+ raison: null,
63
+ elements: [],
64
+ horsDuService: fichiers.filter(f => f.endsWith('.py')),
65
+ fichiers,
66
+ };
67
+ } catch (e) {
68
+ return {
69
+ etat: 'impossible',
70
+ raison: `erreur : ${String(e.message).split('\n')[0]}`,
71
+ elements: [],
72
+ horsDuService: [],
73
+ fichiers: [],
74
+ };
75
+ }
76
+ }
@@ -0,0 +1,54 @@
1
+ // What the module python brings to the update of a project (`grillhouse maj`,
2
+ // scripts/grillhouse-maj.mjs), the demand `miseAJour` of the join (scripts/jointure.d.ts).
3
+ //
4
+ // - The template: `templates/python/` of the frame's files. Its package.json gives the frame's
5
+ // scripts, which run the frame's commands, and smol-toml, the reader of a pyproject.toml.
6
+ // - The root scripts `test`, `test:forcer` and `verifier` a project lacks become the template's;
7
+ // a project's own script stays.
8
+ // - The generator: the index of the interfaces (./index-interfaces.mjs), run where the project
9
+ // holds it, as the module cargo's.
10
+ // - The installation of uv (./binaires.json) by the commands of ./binaires.mjs, which the core runs.
11
+ import path from 'node:path';
12
+ import { fileURLToPath } from 'node:url';
13
+ import { SORTIE } from './index-interfaces.mjs';
14
+
15
+ const BINAIRES = path.join(path.dirname(fileURLToPath(import.meta.url)), 'binaires.mjs');
16
+ const GABARIT = 'templates/python';
17
+ const SCRIPTS_DES_TESTS = ['test', 'test:forcer', 'verifier'];
18
+
19
+ /** @type {import('../../jointure.js').MiseAJour['appliquer']} */
20
+ function appliquer(_projet, { p, modele }) {
21
+ p.scripts ??= {};
22
+ const scripts = [];
23
+ for (const nom of SCRIPTS_DES_TESTS) {
24
+ const script = modele.scripts?.[nom];
25
+ if (typeof script !== 'string' || typeof p.scripts[nom] === 'string') {
26
+ continue;
27
+ }
28
+ p.scripts[nom] = script;
29
+ scripts.push(nom);
30
+ }
31
+ return {
32
+ bilan: { scripts: scripts.length > 0 ? scripts : null },
33
+ lignes:
34
+ scripts.length > 0
35
+ ? [
36
+ `Scripts des tests : ${scripts.map(n => `${n} (\`${p.scripts[n]}\`)`).join(', ')} écrits ; les agents lancent \`npm test\`, l'intégration et la nuit \`npm run verifier\`.`,
37
+ ]
38
+ : [],
39
+ aFaire: [],
40
+ installer: false,
41
+ sansVerifier: null,
42
+ };
43
+ }
44
+
45
+ /** The share of the module python in the update. */
46
+ export const miseAJour = {
47
+ gabarit: GABARIT,
48
+ appliquer,
49
+ generateurs: [{ commande: 'index-interfaces', args: [], sortie: SORTIE }],
50
+ installation: {
51
+ liste: { script: BINAIRES, args: ['liste'] },
52
+ installer: (nom, version) => ({ script: BINAIRES, args: ['installer', `${nom}@${version}`] }),
53
+ },
54
+ };
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env node
2
+ // The size of each test of Python, on the model of the test pyramid of Google and of Bazel's
3
+ // `size`, as the module typescript's guard (../typescript/tailles-des-tests.mjs): a large test of
4
+ // the day is refused, as it belongs to the night.
5
+ //
6
+ // npx grillhouse tailles-des-tests run from the repository root (a guard of grillhouse:gardes)
7
+ //
8
+ // - The test files are those of each package (./composants.mjs, `fichiersDeTest`): `test_*.py`
9
+ // and `*_test.py`, a night test `*_nuit_test.py`.
10
+ // - A test is classed by a static reading of its text and of its package's `conftest.py` files on
11
+ // its path, which pytest loads with it:
12
+ // - large (`grand`): it starts a process (it imports `subprocess`), mounts a trial repository
13
+ // (git's `init`, `clone` or `worktree add`) and starts there something else than git;
14
+ // - medium (`moyen`): it starts a process;
15
+ // - small (`petit`): it starts none.
16
+ // - A large test of the day is a finding, `{ fichier, regle: 'grand-de-jour', message }`; a night
17
+ // test never is one. A finding inscribed in the project's debt (`grillhouse-dette.json`,
18
+ // ../../dette.mjs) passes, and a new one is refused.
19
+ // - The guard writes on its error stream the count of each size, the night's included.
20
+ import { existsSync, readFileSync } from 'node:fs';
21
+ import path from 'node:path';
22
+ import { pathToFileURL } from 'node:url';
23
+ import { trancher } from '../../dette.mjs';
24
+ import { composants, estDeNuit, fichiersDeTest } from './composants.mjs';
25
+
26
+ // The name of its findings and of its debt, apart from the module typescript's guard of the same
27
+ // command, whose section of the debt it never writes.
28
+ export const GARDE = 'tailles-des-tests-python';
29
+ export const GRAND_DE_JOUR = 'grand-de-jour';
30
+
31
+ // The import of the module that starts a process.
32
+ const PROCESSUS = /^\s*(?:import\s+subprocess\b|from\s+subprocess\s+import\b)/m;
33
+ // A trial repository mounted: git's `init`, `clone` or `worktree add`, as an argument or a command.
34
+ const DEPOT_D_ESSAI =
35
+ /['"](?:init|clone)['"]|\bgit\s+(?:-C\s+\S+\s+)?(?:init|clone)\b|['"]worktree['"]\s*,\s*['"]add['"]|\bworktree\s+add\b/;
36
+ // A call of subprocess, its first argument captured.
37
+ const APPEL = /\bsubprocess\.(?:run|Popen|call|check_call|check_output)\s*\(\s*\[?\s*([^,\])\n]*)/g;
38
+ // A first argument that names git.
39
+ const GIT = /^['"]git(?:['"]|\s)/;
40
+
41
+ /**
42
+ * The size of the test file <fichier> (absolute) of the package at <dossier>: `petit`, `moyen` or
43
+ * `grand`.
44
+ */
45
+ export function classer(fichier, dossier) {
46
+ const textes = [readFileSync(fichier, 'utf8')];
47
+ for (let d = path.dirname(fichier); ; d = path.dirname(d)) {
48
+ const conftest = path.join(d, 'conftest.py');
49
+ if (existsSync(conftest)) {
50
+ textes.push(readFileSync(conftest, 'utf8'));
51
+ }
52
+ if (d === dossier || path.dirname(d) === d) {
53
+ break;
54
+ }
55
+ }
56
+ const tout = textes.join('\n');
57
+ const processus = PROCESSUS.test(tout);
58
+ const autreQueGit = [...tout.matchAll(APPEL)].some(m => !GIT.test(m[1].trim()));
59
+ if (processus && autreQueGit && DEPOT_D_ESSAI.test(tout)) {
60
+ return 'grand';
61
+ }
62
+ return processus ? 'moyen' : 'petit';
63
+ }
64
+
65
+ /** Each test file of the project at <racine> and its size: `[{ fichier, taille, nuit }]`. */
66
+ export function tailles(racine) {
67
+ return composants(racine).flatMap(c =>
68
+ fichiersDeTest(c.dossier).map(f => ({
69
+ fichier: path.relative(racine, f).split(path.sep).join('/'),
70
+ taille: classer(f, c.dossier),
71
+ nuit: estDeNuit(path.basename(f)),
72
+ }))
73
+ );
74
+ }
75
+
76
+ /** The findings of the project at <racine>: one per large test of the day. */
77
+ export function verifier(racine) {
78
+ return tailles(racine)
79
+ .filter(t => t.taille === 'grand' && !t.nuit)
80
+ .map(({ fichier }) => ({
81
+ fichier,
82
+ regle: GRAND_DE_JOUR,
83
+ message: `${fichier} : un grand test (il monte un dépôt d'essai et y lance le produit ou le cadre) est un test de nuit, jamais joué au fil du travail ; il se renomme en *_nuit_test.py, ou il se réduit à la plus petite taille qui prouve son critère.`,
84
+ }));
85
+ }
86
+
87
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
88
+ const racine = process.cwd();
89
+ const toutes = tailles(racine);
90
+ const compte = t => toutes.filter(x => x.taille === t).length;
91
+ const { refus, lignes } = trancher(racine, GARDE, verifier(racine));
92
+ for (const r of refus) {
93
+ process.stderr.write(`⛔ ${r.message}\n`);
94
+ }
95
+ for (const l of lignes) {
96
+ process.stderr.write(`${l}\n`);
97
+ }
98
+ process.stderr.write(
99
+ `ℹ️ ${GARDE} : ${toutes.length} fichier(s) de tests, ${compte('petit')} petit(s), ${compte('moyen')} moyen(s), ${compte('grand')} grand(s) ; ${toutes.filter(x => x.nuit).length} de nuit.\n`
100
+ );
101
+ process.exitCode = refus.length ? 1 : 0;
102
+ }
@@ -0,0 +1,85 @@
1
+ // The verdict of a run of the module python, the demand `verdict` of the join
2
+ // (scripts/jointure.d.ts): what ./commandes.mjs left in the results directory of a pass
3
+ // (`GRILLHOUSE_RESULTATS`, scripts/resultats.mjs).
4
+ //
5
+ // - `<dossier>/python/<run>.json`, one per run: `{ taches, rapports }`, each task as the join types
6
+ // it (`code` null for a task planned that did not run; `tests` true for a run of pytest), and the
7
+ // folder of the package of each JUnit report by its file's name.
8
+ // - `<dossier>/pytest/<run>-<paquet>.xml`, the JUnit report of each run of pytest, in the family
9
+ // `xunit1`, whose `testcase` names its file (`file`, from the package's folder): each file gives
10
+ // a test file, each `testcase` a test, failed when it holds a `failure` or an `error`, skipped
11
+ // when it holds `skipped`; its message, the failure's.
12
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
13
+ import path from 'node:path';
14
+
15
+ export const TACHES = 'python';
16
+ export const JUNIT = 'pytest';
17
+
18
+ const fichiers = (dossier, extension) =>
19
+ existsSync(dossier)
20
+ ? readdirSync(dossier)
21
+ .filter(f => f.endsWith(extension))
22
+ .sort()
23
+ : [];
24
+ const lireJson = f => {
25
+ try {
26
+ return JSON.parse(readFileSync(f, 'utf8'));
27
+ } catch {
28
+ return null;
29
+ }
30
+ };
31
+
32
+ const ENTITES = { lt: '<', gt: '>', amp: '&', quot: '"', apos: "'" };
33
+ // The text <t> of XML, its entities read.
34
+ const texte = t =>
35
+ t.replace(/&(#x[0-9a-f]+|#\d+|\w+);/gi, (m, e) => {
36
+ if (e[0] === '#') {
37
+ return String.fromCodePoint(e[1] === 'x' ? parseInt(e.slice(2), 16) : Number(e.slice(1)));
38
+ }
39
+ return ENTITES[e] ?? m;
40
+ });
41
+ // The attribute <nom> of the opening tag <balise>, its text, or null.
42
+ const attribut = (balise, nom) => {
43
+ const m = new RegExp(`\\s${nom}="([^"]*)"`).exec(balise);
44
+ return m ? texte(m[1]) : null;
45
+ };
46
+
47
+ // The test files of the JUnit report <xml> of the package at <dossier>.
48
+ function rapportsDe(xml, dossier) {
49
+ const parFichier = new Map();
50
+ for (const c of xml.matchAll(/<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g)) {
51
+ const corps = c[2] ?? '';
52
+ const echec = /<(failure|error)\b([^>]*?)(?:\/>|>([\s\S]*?)<\/\1>)/.exec(corps);
53
+ const etat = echec ? 'failed' : /<skipped\b/.test(corps) ? 'skipped' : 'passed';
54
+ const message = echec ? (attribut(echec[2], 'message') ?? texte(echec[3] ?? '')) : '';
55
+ const titre = attribut(c[1], 'name') ?? '';
56
+ const fichier = path.resolve(dossier, attribut(c[1], 'file') ?? '');
57
+ if (!parFichier.has(fichier)) {
58
+ parFichier.set(fichier, []);
59
+ }
60
+ parFichier.get(fichier).push({ titre, nom: titre, etat, message });
61
+ }
62
+ return [...parFichier].map(([fichier, tests]) => ({
63
+ fichier,
64
+ etat: tests.some(t => t.etat === 'failed') ? 'failed' : 'passed',
65
+ message: '',
66
+ tests,
67
+ }));
68
+ }
69
+
70
+ /**
71
+ * The verdict the results directory <dossier> holds: `{ rapports, taches }`.
72
+ * @param {string} dossier the results directory of a pass
73
+ */
74
+ export function verdict(dossier) {
75
+ const runs = fichiers(path.join(dossier, TACHES), '.json')
76
+ .map(f => lireJson(path.join(dossier, TACHES, f)))
77
+ .filter(Boolean);
78
+ const dossiers = Object.assign({}, ...runs.map(r => r.rapports ?? {}));
79
+ return {
80
+ rapports: fichiers(path.join(dossier, JUNIT), '.xml')
81
+ .filter(f => dossiers[f])
82
+ .flatMap(f => rapportsDe(readFileSync(path.join(dossier, JUNIT, f), 'utf8'), dossiers[f])),
83
+ taches: runs.flatMap(r => r.taches ?? []),
84
+ };
85
+ }
@@ -11,8 +11,7 @@
11
11
  // `enRetard`; the same, committed, a file of `a` then changed and a file out of every package
12
12
  // added: `change`, measured from its commit; the same where the code of `b` imports `a` and the
13
13
  // code of `c` imports `b`: `lus`; the same with a second commit that changes a file of `a`:
14
- // `lot`. A directory whose package.json names no package: `vide`. A tsconfig.json at the root of
15
- // a directory, and in a package of a repository of packages: `aLaRacine`, `dansUnPaquet`. A
14
+ // `lot`. A directory whose package.json names no package: `vide`. A
16
15
  // repository of two packages, one with the script of the tests (`test:unit`): `avecTests`.
17
16
  // - Two results directories of a run: every task and test green (`vert`); `a` at 75, `b` red, a
18
17
  // test of `b` failed (`defaut`).
@@ -113,13 +112,6 @@ export default {
113
112
  const aJour = depot(dans);
114
113
  const vide = mkdtempSync(path.join(dans, 'vide-'));
115
114
  writeFileSync(path.join(vide, 'package.json'), json({ name: 'vide', private: true }));
116
- const aLaRacine = mkdtempSync(path.join(dans, 'tsconfig-'));
117
- writeFileSync(path.join(aLaRacine, 'package.json'), json({ name: 'r', private: true }));
118
- writeFileSync(path.join(aLaRacine, 'tsconfig.json'), json({}));
119
- const dansUnPaquet = mkdtempSync(path.join(dans, 'tsconfig-'));
120
- ecrireDans(dansUnPaquet)('package.json', json({ name: 'p', workspaces: ['packages/*'] }));
121
- ecrireDans(dansUnPaquet)('packages/a/package.json', json({ name: '@p/a' }));
122
- ecrireDans(dansUnPaquet)('packages/a/tsconfig.json', json({}));
123
115
  // A repository of two packages, `a` with the script of the tests, `b` without.
124
116
  const avecTests = mkdtempSync(path.join(dans, 'tests-'));
125
117
  ecrireDans(avecTests)('package.json', json({ name: 't', workspaces: ['packages/*'] }));
@@ -273,17 +265,6 @@ export default {
273
265
  },
274
266
  matieres: { valide: vide, invalide: aJour, attendu: ['m (@e/m)'] },
275
267
  joueDesTests: { valide: aJour, invalide: avecTests, attendu: ['a (@t/a) : joue des tests'] },
276
- trouve: {
277
- valide: [
278
- { nom: 'vide', racine: vide },
279
- { nom: 'paquets sans tsconfig', racine: aJour },
280
- ],
281
- invalide: [
282
- { nom: 'à la racine', racine: aLaRacine },
283
- { nom: 'dans un paquet', racine: dansUnPaquet },
284
- ],
285
- attendu: ['à la racine : trouvé', 'dans un paquet : trouvé'],
286
- },
287
268
  };
288
269
  },
289
270
  };
@@ -261,10 +261,17 @@ export function publie(racine, composant) {
261
261
  return out.join('\n');
262
262
  }
263
263
 
264
+ // The entries of the index of each interface of the repository at <racine>, `{ rel, lignes }`, in
265
+ // the order of `interfaces`: what the module gives the core's index of a project of several
266
+ // languages (`entreesDeLIndex` of the join).
267
+ export const entreesDeLIndex = racine =>
268
+ interfaces(racine).map(rel => ({
269
+ rel,
270
+ lignes: entrees(rel, readFileSync(path.join(racine, rel), 'utf8')),
271
+ }));
272
+
264
273
  export function index(racine) {
265
- const corps = interfaces(racine).flatMap(rel =>
266
- entrees(rel, readFileSync(path.join(racine, rel), 'utf8'))
267
- );
274
+ const corps = entreesDeLIndex(racine).flatMap(e => e.lignes);
268
275
  return [
269
276
  '# Index des interfaces',
270
277
  '',
@@ -4,9 +4,9 @@
4
4
  // guards of structure and their generators. The core loads it by scripts/langages.mjs, and this
5
5
  // module imports of the core its published entries alone.
6
6
  //
7
- // - Where it is found: a repository with a tsconfig.json at its root or in a package of the frame
8
- // (`trouve`), which the update declares typescript; its tools, the optional peers of the package
9
- // the update installs in such a project (`outils`).
7
+ // - The manifest of its package, which the guard of the languages asks of a package the
8
+ // architecture declares typescript (`manifeste`): a package.json; its tools, the optional peers of
9
+ // the package the update installs in such a project (`outils`).
10
10
  // - The components: the folders `packages/<x>` and `src/<x>` of the frame (`composants` of
11
11
  // ./consommateurs.mjs), out of the frame left out; a file's is the component that holds it; the
12
12
  // shared test material, the components whose package exports `./test-fixtures` (`matieres`); a
@@ -36,6 +36,8 @@
36
36
  // (./regle-des-tests.mjs).
37
37
  // - The generated files, each its command, the guard that checks it and the names its findings
38
38
  // carry: the index of the interfaces, the turbo.json of the packages, the reports of API.
39
+ // - The entries of the index of each interface (`entreesDeLIndex`, ./index-interfaces.mjs), which
40
+ // the core assembles in a project of several languages.
39
41
  // - The guards of structure, in the order they play.
40
42
  // - The migrations of a project of TypeScript (./migrations/): the base configuration of Vitest,
41
43
  // and the ones that replay a guard of this module, which the update plays with the core's
@@ -44,7 +46,7 @@
44
46
  // (`ignorer`); its share of the update (./mise-a-jour.mjs, `miseAJour`): the tests by Vitest,
45
47
  // the frame's package declared, the typing, the turbo.json, and the generators.
46
48
  import { spawnSync } from 'node:child_process';
47
- import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
49
+ import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
48
50
  import { createRequire } from 'node:module';
49
51
  import { tmpdir } from 'node:os';
50
52
  import path from 'node:path';
@@ -52,7 +54,6 @@ import { fileURLToPath } from 'node:url';
52
54
  import { composants as lesComposants, matieres } from './consommateurs.mjs';
53
55
  import { elementsDuLot } from './elements-du-lot.mjs';
54
56
  import { A_ELAGUER, lireSarif, RESULTATS } from '../../resultats.mjs';
55
- import { paquets } from '../../paquets.mjs';
56
57
  import { lecteurs } from './lecteurs.mjs';
57
58
  import { estUnTest, manifestes } from './regle-des-tests.mjs';
58
59
  import { SCRIPT_DES_TESTS } from './script-des-tests.mjs';
@@ -67,6 +68,7 @@ import * as cheminsDesTests from './migrations/0.25.0-chemins-des-tests.mjs';
67
68
 
68
69
  // The scripts of this module, beside this file.
69
70
  const SCRIPTS = path.dirname(fileURLToPath(import.meta.url));
71
+ const requis = createRequire(import.meta.url);
70
72
  const ici = nom => path.join(SCRIPTS, nom);
71
73
  const generateur = (script, ...args) => [`node ${JSON.stringify(ici(script))}`, ...args].join(' ');
72
74
  const CHAMPS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
@@ -195,18 +197,9 @@ const joueDesTests = (_racine, composant) =>
195
197
  typeof lireJson(path.join(composant.dossier, 'package.json'))?.scripts?.[SCRIPT_DES_TESTS] ===
196
198
  'string';
197
199
 
198
- // Whether the repository at <racine> holds TypeScript: a tsconfig.json at its root or in one of its
199
- // packages of the frame, as @nx/js infers a project from its tsconfig.
200
- const trouve = racine =>
201
- existsSync(path.join(racine, 'tsconfig.json')) ||
202
- paquets(racine).some(
203
- ({ dossier, hors }) => !hors && existsSync(path.join(racine, dossier, 'tsconfig.json'))
204
- );
205
-
206
200
  export default {
207
201
  nom: 'typescript',
208
- trouve,
209
- signe: 'un tsconfig.json à la racine ou dans un paquet',
202
+ manifeste: 'package.json',
210
203
  // The tools a project of TypeScript installs, optional peers of the package: what this module
211
204
  // runs as commands (Turborepo, knip, dependency-cruiser) and what its scripts import (API
212
205
  // Extractor, its model, TSDoc's configuration, jsonc-parser); the project's own TypeScript and
@@ -313,6 +306,9 @@ export default {
313
306
  []
314
307
  ),
315
308
  ],
309
+ // Loaded at the call: ./index-interfaces.mjs imports the services of the core, which import the
310
+ // join that loads this module.
311
+ entreesDeLIndex: racine => requis('./index-interfaces.mjs').entreesDeLIndex(racine),
316
312
  gardes: () => [
317
313
  [ici('turbo-des-paquets.mjs')],
318
314
  [ici('index-interfaces.mjs'), '--verifier'],