@roomi-fields/grillhouse 0.24.15 → 0.25.1

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 (125) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/grillhouse.mjs +40 -12
  3. package/cadre/templates/cargo/.config/nextest.toml +8 -0
  4. package/cadre/templates/cargo/deny.toml +41 -0
  5. package/cadre/templates/cargo/package.json +15 -0
  6. package/cadre/templates/cargo/rust-toolchain.toml +6 -0
  7. package/cadre/templates/projet/package.json +5 -1
  8. package/cadre/templates/turbo/paquets.json +1 -1
  9. package/cadre/templates/turbo/sans-paquets.json +1 -1
  10. package/charte.md +16 -0
  11. package/docs/ARCHITECTURE.md +160 -56
  12. package/docs/CADRE.md +47 -0
  13. package/docs/INTERFACE.md +176 -0
  14. package/package.json +66 -13
  15. package/scripts/arbitrages.mjs +23 -0
  16. package/scripts/avancement.mjs +15 -29
  17. package/scripts/circuit.mjs +89 -97
  18. package/scripts/commande-du-langage.mjs +56 -0
  19. package/scripts/composants-affectes.mjs +47 -170
  20. package/scripts/conformite.d.ts +27 -0
  21. package/scripts/conformite.mjs +226 -0
  22. package/scripts/demon.mjs +1 -1
  23. package/scripts/dernier-vert.mjs +11 -9
  24. package/scripts/droits.mjs +27 -21
  25. package/scripts/enveloppe/enveloppe.mjs +206 -64
  26. package/scripts/enveloppe/lancer.sh +20 -91
  27. package/scripts/enveloppe/paquets-du-plan.mjs +24 -2
  28. package/scripts/etapes.mjs +2 -2
  29. package/scripts/gardes-du-cadre.mjs +12 -18
  30. package/scripts/grillhouse-maj.mjs +246 -389
  31. package/scripts/init.mjs +2 -1
  32. package/scripts/integration/file.mjs +3 -3
  33. package/scripts/integration/integrer.mjs +13 -10
  34. package/scripts/integration/rejeu.mjs +36 -7
  35. package/scripts/jointure.d.ts +304 -0
  36. package/scripts/langages/cargo/binaires.json +4 -0
  37. package/scripts/langages/cargo/binaires.mjs +60 -0
  38. package/scripts/langages/cargo/clippy.mjs +103 -0
  39. package/scripts/langages/cargo/commandes.mjs +378 -0
  40. package/scripts/langages/cargo/composants.mjs +191 -0
  41. package/scripts/langages/cargo/elements-du-lot.mjs +139 -0
  42. package/scripts/langages/cargo/exemples.mjs +357 -0
  43. package/scripts/langages/cargo/frontieres.mjs +84 -0
  44. package/scripts/langages/cargo/index-interfaces.mjs +138 -0
  45. package/scripts/langages/cargo/index.mjs +115 -0
  46. package/scripts/langages/cargo/mise-a-jour.mjs +93 -0
  47. package/scripts/langages/cargo/nextest.toml +5 -0
  48. package/scripts/langages/cargo/touches.mjs +93 -0
  49. package/scripts/langages/cargo/verdict.mjs +85 -0
  50. package/scripts/langages/typescript/chemins-des-tests.mjs +68 -0
  51. package/scripts/{code-mort.mjs → langages/typescript/code-mort.mjs} +5 -5
  52. package/scripts/langages/typescript/composants.mjs +64 -0
  53. package/scripts/{consommateurs-arbitres.mjs → langages/typescript/consommateurs-arbitres.mjs} +6 -24
  54. package/scripts/{consommateurs.mjs → langages/typescript/consommateurs.mjs} +13 -71
  55. package/scripts/langages/typescript/construire.mjs +176 -0
  56. package/scripts/{elements-du-lot.mjs → langages/typescript/elements-du-lot.mjs} +2 -2
  57. package/scripts/langages/typescript/exemples.mjs +289 -0
  58. package/scripts/{frontieres.mjs → langages/typescript/frontieres.mjs} +3 -5
  59. package/scripts/{index-interfaces.mjs → langages/typescript/index-interfaces.mjs} +3 -3
  60. package/scripts/langages/typescript/index.mjs +335 -0
  61. package/scripts/{interfaces-contre-code.mjs → langages/typescript/interfaces-contre-code.mjs} +2 -2
  62. package/scripts/langages/typescript/lecteurs.mjs +179 -0
  63. package/scripts/{migrations → langages/typescript/migrations}/0.23.0-config-vitest.mjs +14 -29
  64. package/scripts/{migrations → langages/typescript/migrations}/0.24.4-noms-declares-inutilises.mjs +2 -2
  65. package/scripts/{migrations → langages/typescript/migrations}/0.24.6-lignes-mal-formees.mjs +2 -2
  66. package/scripts/{migrations → langages/typescript/migrations}/0.24.7-matiere-dans-les-tests.mjs +2 -2
  67. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +27 -0
  68. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +31 -0
  69. package/scripts/langages/typescript/mise-a-jour.mjs +320 -0
  70. package/scripts/{references-par-les-types.mjs → langages/typescript/references-par-les-types.mjs} +3 -3
  71. package/scripts/langages/typescript/regle-des-tests.mjs +39 -0
  72. package/scripts/{resumes.mjs → langages/typescript/resumes.mjs} +4 -4
  73. package/scripts/langages/typescript/script-des-tests.mjs +6 -0
  74. package/scripts/langages/typescript/tailles-des-tests.mjs +219 -0
  75. package/scripts/langages/typescript/tests-de-nuit.mjs +57 -0
  76. package/scripts/{tests.mjs → langages/typescript/tests.mjs} +41 -32
  77. package/scripts/{turbo-des-paquets.mjs → langages/typescript/turbo-des-paquets.mjs} +49 -23
  78. package/scripts/langages/typescript/verdict.mjs +105 -0
  79. package/scripts/{verifier.mjs → langages/typescript/verifier.mjs} +53 -34
  80. package/scripts/{vitest-config → langages/typescript/vitest-config}/avancement.reporter.mjs +10 -2
  81. package/scripts/{vitest-config → langages/typescript/vitest-config}/base.mjs +63 -9
  82. package/scripts/{vitest-config → langages/typescript/vitest-config}/changements.mjs +18 -11
  83. package/scripts/{vitest-config → langages/typescript/vitest-config}/cibles.mjs +7 -6
  84. package/scripts/langages/typescript/vitest-config/duree.reporter.d.ts +10 -0
  85. package/scripts/{vitest-config → langages/typescript/vitest-config}/duree.reporter.mjs +10 -3
  86. package/scripts/langages/typescript/vitest-config/lances.mjs +473 -0
  87. package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.setup.mjs +1 -1
  88. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.mjs +5 -5
  89. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.setup.mjs +4 -3
  90. package/scripts/{vitest.nuit.config.mjs → langages/typescript/vitest.nuit.config.mjs} +2 -2
  91. package/scripts/langages.mjs +85 -0
  92. package/scripts/{vitest-config → mesure}/avancement.mjs +4 -13
  93. package/scripts/{vitest-config → mesure}/base-de-passe.mjs +70 -33
  94. package/scripts/{vitest-config → mesure}/pression.mjs +5 -6
  95. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +29 -6
  96. package/scripts/migrations/0.24.0-circuit-simplifie.mjs +13 -6
  97. package/scripts/migrations/0.25.0-script-des-tests.mjs +92 -0
  98. package/scripts/migrations.mjs +17 -13
  99. package/scripts/nuit.sh +59 -63
  100. package/scripts/paquets.d.ts +5 -0
  101. package/scripts/paquets.mjs +24 -2
  102. package/scripts/resultats.mjs +8 -82
  103. package/scripts/services-du-noyau.mjs +30 -0
  104. package/scripts/session-start.sh +17 -9
  105. package/scripts/sources.mjs +35 -13
  106. package/scripts/sous-commandes.mjs +57 -17
  107. package/scripts/superviseur.mjs +1 -1
  108. package/scripts/tableau.mjs +1 -1
  109. package/scripts/un-commit-par-ticket.mjs +48 -14
  110. package/scripts/verrou-de-fichier.mjs +1 -1
  111. package/scripts/verrou-de-machine.mjs +4 -4
  112. package/scripts/verrous/verrou.mjs +28 -37
  113. package/skills/developpeur/SKILL.md +2 -2
  114. package/skills/explorateur/SKILL.md +13 -5
  115. package/skills/grill/SKILL.md +2 -2
  116. package/skills/pitmaster/references/cadre.md +1 -1
  117. package/skills/pitmaster/references/consigne-agent.md +10 -3
  118. package/skills/redacteur/references/documents-d-un-composant.md +4 -4
  119. package/skills/relecteur/SKILL.md +4 -1
  120. package/skills/testwriter/SKILL.md +20 -6
  121. /package/scripts/{consommateurs.d.ts → langages/typescript/consommateurs.d.ts} +0 -0
  122. /package/scripts/{vitest-config → langages/typescript/vitest-config}/base.d.ts +0 -0
  123. /package/scripts/{vitest-config → langages/typescript/vitest-config}/machine.setup.mjs +0 -0
  124. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.d.ts +0 -0
  125. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.mjs +0 -0
@@ -17,11 +17,14 @@
17
17
  // description (its provenance, its notes) names nothing.
18
18
  // - A component is named by its package name, as a whole word, or by a path in it
19
19
  // (`packages/<x>`, `src/<x>`, its files included), the components being those of `composants`
20
- // (scripts/consommateurs.mjs).
20
+ // of the module of the project's language (scripts/langages.mjs, scripts/jointure.d.ts).
21
+ // - The providers, the readers and the survey by the types read the code: the module of the
22
+ // language gives them (`lecteurs`; for typescript, scripts/langages/typescript/lecteurs.mjs), and
23
+ // this survey reads the text, the paths read and the architecture.
21
24
  // - An element is a name between backquotes that begins with an identifier: a call (`f()`) or a
22
25
  // member (`A.b`) is read by its head. Its provider is the component whose interface
23
26
  // (`docs/INTERFACE.md`) publishes it: a heading of its generated part
24
- // (scripts/index-interfaces.mjs). A name no interface publishes, that names a symbol of the
27
+ // (scripts/langages/typescript/index-interfaces.mjs). A name no interface publishes, that names a symbol of the
25
28
  // repository (a declaration at the top of a component's source) or a path of it, is set apart
26
29
  // (`sansFournisseur`); a word that names neither (an example of the ticket, a fault to create)
27
30
  // is left out.
@@ -30,9 +33,9 @@
30
33
  // - The readers of an element are the other components that: its provider's `## Consommateurs`
31
34
  // declares for it, or for `*` (`consommateurs`); import it, or the whole provider, in their
32
35
  // production code, or in their tests for a package of the shared test material (`import`, the
33
- // uses of scripts/consommateurs.mjs); hold a test file that names
36
+ // uses of scripts/langages/typescript/consommateurs.mjs); hold a test file that names
34
37
  // it, as a whole word, and imports the provider (the test file's path).
35
- // - By the types (scripts/references-par-les-types.mjs): each element, a member of a type
38
+ // - By the types (scripts/langages/typescript/references-par-les-types.mjs): each element, a member of a type
36
39
  // included, resolved by TypeScript's language service over the components' `tsconfig.json`;
37
40
  // the components whose entry exports it, and the readers its references reach (`types`). An
38
41
  // element that only names a symbol internal to a package leads to no component, its package
@@ -54,19 +57,7 @@ import { existsSync, readFileSync } from 'node:fs';
54
57
  import path from 'node:path';
55
58
  import { pathToFileURL } from 'node:url';
56
59
  import { spawnSync } from 'node:child_process';
57
- import {
58
- composants as lesComposants,
59
- declares,
60
- imports,
61
- lireSiPresent,
62
- NOM_DE_TEST,
63
- parcourir,
64
- utilise,
65
- } from './consommateurs.mjs';
66
- import { lire } from './index-interfaces.mjs';
67
- import { elementsEcrits, parLesTypes } from './references-par-les-types.mjs';
68
-
69
- const DOSSIERS_DE_TEST = new Set(['test', 'tests', '__tests__']);
60
+ import { langageDe } from './langages.mjs';
70
61
 
71
62
  /**
72
63
  * The paths that the tests of the package at <dir> declare they read: its `grillhouse.lit`, then
@@ -85,8 +76,6 @@ export function cheminsLus(dir) {
85
76
  ...Object.values(grillhouse?.traces ?? {}).flatMap(t => liste(t?.lit)),
86
77
  ];
87
78
  }
88
- const SAUTES = new Set(['node_modules', 'dist', 'build', 'coverage']);
89
- const SOURCE = /\.[cm]?[jt]sx?$/;
90
79
 
91
80
  // The sections the survey reads in <description>: « Architecture » and the criteria, as one text.
92
81
  function lesSections(description) {
@@ -101,17 +90,16 @@ function lesSections(description) {
101
90
  }
102
91
 
103
92
  const echapper = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
104
- // A package name as a whole word of a text; an identifier as a whole word of a source.
93
+ // A package name as a whole word of a text.
105
94
  const motEntier = nom => new RegExp(`(?<![\\w@/.-])${echapper(nom)}(?![\\w-])`);
106
- const identifiant = nom => new RegExp(`(?<![\\w$])${echapper(nom)}(?![\\w$])`);
107
95
 
108
96
  // The title's name of the component <c>: its package name, else its path.
109
- const nomAuTitre = (racine, c) => c.paquet ?? path.relative(racine, c.dir);
97
+ const nomAuTitre = (racine, c) => c.paquet ?? path.relative(racine, c.dossier);
110
98
 
111
99
  // The components <texte> names, by their package name or a path in them.
112
100
  function nommes(racine, tous, texte) {
113
101
  return tous.filter(c => {
114
- const rel = path.relative(racine, c.dir).split(path.sep).join('/');
102
+ const rel = path.relative(racine, c.dossier).split(path.sep).join('/');
115
103
  return (
116
104
  (c.paquet && motEntier(c.paquet).test(texte)) ||
117
105
  new RegExp(`(?<![\\w/.-])${echapper(rel)}(?![\\w-])`).test(texte)
@@ -151,9 +139,9 @@ const recouvre = (a, b) => a === b || b.startsWith(`${a}/`) || a.startsWith(`${b
151
139
  function lecteursDesChemins(racine, tous, changes) {
152
140
  const out = new Map();
153
141
  for (const c of tous) {
154
- const propre = path.relative(racine, c.dir).split(path.sep).join('/');
142
+ const propre = path.relative(racine, c.dossier).split(path.sep).join('/');
155
143
  const par = new Set();
156
- for (const brut of new Set(cheminsLus(c.dir))) {
144
+ for (const brut of new Set(cheminsLus(c.dossier))) {
157
145
  const lu = brut.replace(/^\.\//, '').replace(/\/+$/, '');
158
146
  const atteints = changes.filter(ch => !recouvre(propre, ch) && recouvre(lu, ch)).sort();
159
147
  if (atteints.length) par.add(`lit ${lu} (${atteints.join(', ')})`);
@@ -163,64 +151,6 @@ function lecteursDesChemins(racine, tous, changes) {
163
151
  return out;
164
152
  }
165
153
 
166
- // A declaration of <nom> at the top of a source, exported or not.
167
- const DECLARATION_EN_TETE = nom =>
168
- new RegExp(
169
- `^(?:export\\s+)?(?:default\\s+)?(?:declare\\s+)?(?:abstract\\s+)?(?:async\\s+)?(?:function\\*?|class|interface|type|enum|const|let|var)\\s+${echapper(nom)}(?![\\w$])`,
170
- 'm'
171
- );
172
- // The texts of the production sources of the components <tous>, their tests left out.
173
- function sourcesDe(tous) {
174
- return tous.flatMap(c =>
175
- parcourir(c.dir, p => SAUTES.has(path.basename(p)))
176
- .filter(f => {
177
- if (!SOURCE.test(f) || NOM_DE_TEST.test(path.basename(f))) return false;
178
- return !path
179
- .relative(c.dir, f)
180
- .split(path.sep)
181
- .some(d => DOSSIERS_DE_TEST.has(d));
182
- })
183
- .map(f => lireSiPresent(f) ?? '')
184
- );
185
- }
186
-
187
- // Each component's published elements and declared consumers, read in its interface.
188
- function interfacesDe(racine, tous) {
189
- const out = new Map();
190
- for (const c of tous) {
191
- const f = path.join(c.dir, 'docs', 'INTERFACE.md');
192
- if (!existsSync(f)) continue;
193
- const i = lire(path.relative(racine, f).split(path.sep).join('/'), readFileSync(f, 'utf8'));
194
- const publies = new Set(
195
- i.parties.filter(p => !p.consommateurs).map(p => p.titre.replace(/`/g, '').trim())
196
- );
197
- const consommateurs = i.parties.find(p => p.consommateurs)?.consommateurs ?? declares('');
198
- out.set(c, { publies, consommateurs });
199
- }
200
- return out;
201
- }
202
-
203
- // The test sources of the component <c>: test files, and the sources of its test folders, built
204
- // files left out.
205
- function testsDe(c) {
206
- return parcourir(c.dir, p => SAUTES.has(path.basename(p))).filter(f => {
207
- if (!SOURCE.test(f)) return false;
208
- const rel = path.relative(c.dir, f).split(path.sep);
209
- return NOM_DE_TEST.test(path.basename(f)) || rel.some(d => DOSSIERS_DE_TEST.has(d));
210
- });
211
- }
212
-
213
- // Whether the source <texte> of the file <fichier> imports the component <p>.
214
- function importe(texte, fichier, p) {
215
- return imports(texte).some(({ spec }) => {
216
- if (spec.startsWith('.')) {
217
- const cible = path.resolve(path.dirname(fichier), spec);
218
- return cible === p.dir || cible.startsWith(p.dir + path.sep);
219
- }
220
- return Boolean(p.paquet) && (spec === p.paquet || spec.startsWith(`${p.paquet}/`));
221
- });
222
- }
223
-
224
154
  // The components <liste> in the title's order: each one after those it reads among them
225
155
  // (<lit>: Map component → Set of its providers), in the order of <nom> otherwise.
226
156
  function ordonner(liste, lit, nom) {
@@ -242,74 +172,34 @@ function ordonner(liste, lit, nom) {
242
172
  // its title's name, `composants` in the title's order.
243
173
  export function releve(racine, description) {
244
174
  const texte = lesSections(description);
245
- const tous = lesComposants(racine);
246
- const reel = utilise(racine, tous);
247
- const ifaces = interfacesDe(racine, tous);
248
- const tests = new Map();
249
- const testsDuComposant = c => {
250
- if (!tests.has(c))
251
- tests.set(
252
- c,
253
- testsDe(c).map(f => ({ f, texte: lireSiPresent(f) ?? '' }))
254
- );
255
- return tests.get(c);
256
- };
257
- const trouves = new Set(nommes(racine, tous, texte));
258
- const elements = [];
259
- const sansFournisseur = [];
260
- for (const nom of elementsNommes(texte)) {
261
- const fournisseurs = tous.filter(c => ifaces.get(c)?.publies.has(nom));
262
- if (fournisseurs.length === 0) {
263
- if (!tous.some(c => c.paquet === nom)) sansFournisseur.push(nom);
264
- continue;
265
- }
266
- for (const p of fournisseurs) {
267
- trouves.add(p);
268
- const lecteurs = [];
269
- for (const c of tous) {
270
- if (c === p) continue;
271
- const par = [];
272
- const declare =
273
- ifaces.get(p).consommateurs.get(c.nom) ?? ifaces.get(p).consommateurs.get(c.paquet);
274
- if (declare && (declare.has(nom) || declare.has('*'))) par.push('consommateurs');
275
- const noms = reel.get(p.nom)?.get(c.nom);
276
- if (noms && (noms.has(nom) || noms.has('*'))) par.push('import');
277
- for (const t of testsDuComposant(c)) {
278
- if (identifiant(nom).test(t.texte) && importe(t.texte, t.f, p)) {
279
- par.push(path.relative(racine, t.f).split(path.sep).join('/'));
280
- }
281
- }
282
- if (par.length) {
283
- lecteurs.push({ c, par });
284
- trouves.add(c);
285
- }
286
- }
287
- elements.push({ nom, p, lecteurs });
288
- }
289
- }
290
- // By the types: each element resolved by the language service, the components that publish it
291
- // and their readers.
292
- const types = parLesTypes(racine, tous, elementsEcrits(texte), {
293
- fichiers: new Set(
294
- [...texte.matchAll(/[\w.-]+\.[cm]?[jt]sx?\b/g)].map(m => path.basename(m[0]))
295
- ),
296
- composants: new Set(nommes(racine, tous, texte)),
175
+ const langage = langageDe(racine);
176
+ const tous = langage.composants(racine);
177
+ const ceuxNommes = nommes(racine, tous, texte);
178
+ const code = langage.lecteurs(racine, {
179
+ composants: tous,
180
+ noms: elementsNommes(texte),
181
+ texte,
182
+ nommes: ceuxNommes,
297
183
  });
298
- const resolus = new Set(types.elements.map(e => e.ecrit));
299
- for (const e of types.elements) {
300
- for (const d of e.declarations) if (d.publie) trouves.add(d.c);
184
+ const trouves = new Set(ceuxNommes);
185
+ for (const e of code.elements) {
186
+ trouves.add(e.fournisseur);
187
+ for (const l of e.lecteurs) trouves.add(l.composant);
188
+ }
189
+ for (const e of code.types.elements) {
190
+ for (const d of e.declarations) if (d.publie) trouves.add(d.composant);
301
191
  for (const c of e.lecteurs.keys()) trouves.add(c);
302
192
  }
303
193
  // By the paths read: the components whose tests declare they read a path the ticket changes.
304
194
  const parChemins = lecteursDesChemins(racine, tous, [
305
195
  ...cheminsEcrits(racine, texte),
306
- ...nommes(racine, tous, texte).map(c => path.relative(racine, c.dir).split(path.sep).join('/')),
196
+ ...ceuxNommes.map(c => path.relative(racine, c.dossier).split(path.sep).join('/')),
307
197
  ]);
308
198
  for (const c of parChemins.keys()) trouves.add(c);
309
199
  // By the architecture: the Rend of the CADRE.md of each component that publishes an element.
310
200
  const declarants = new Set([
311
- ...elements.map(e => e.p),
312
- ...types.elements.flatMap(e => e.declarations.filter(d => d.publie).map(d => d.c)),
201
+ ...code.elements.map(e => e.fournisseur),
202
+ ...code.types.elements.flatMap(e => e.declarations.filter(d => d.publie).map(d => d.composant)),
313
203
  ]);
314
204
  const architecture = new Map();
315
205
  for (const p of declarants) {
@@ -322,43 +212,29 @@ export function releve(racine, description) {
322
212
  }
323
213
  }
324
214
  }
325
- // What each component reads: its imports, and the providers of the elements it reads.
326
- const lit = new Map(tous.map(c => [c, new Set()]));
327
- for (const p of tous) {
328
- for (const nomLecteur of reel.get(p.nom)?.keys() ?? []) {
329
- for (const c of tous) if (c.nom === nomLecteur) lit.get(c).add(p);
330
- }
331
- }
332
- for (const e of elements) for (const l of e.lecteurs) lit.get(l.c).add(e.p);
333
215
  const titre = c => nomAuTitre(racine, c);
334
216
  const parNom = (a, b) => titre(a).localeCompare(titre(b));
335
- let sources = null;
336
217
  const lecteursDe = m =>
337
218
  [...m]
338
219
  .sort(([a], [b]) => parNom(a, b))
339
220
  .map(([c, par]) => ({ composant: titre(c), par: [...par] }));
340
221
  return {
341
- nommes: [...nommes(racine, tous, texte)].sort(parNom).map(titre),
342
- elements: elements.map(e => ({
222
+ nommes: [...ceuxNommes].sort(parNom).map(titre),
223
+ elements: code.elements.map(e => ({
343
224
  nom: e.nom,
344
- fournisseur: titre(e.p),
225
+ fournisseur: titre(e.fournisseur),
345
226
  lecteurs: e.lecteurs
346
- .sort((a, b) => parNom(a.c, b.c))
347
- .map(l => ({ composant: titre(l.c), par: l.par })),
227
+ .sort((a, b) => parNom(a.composant, b.composant))
228
+ .map(l => ({ composant: titre(l.composant), par: l.par })),
348
229
  })),
349
- sansFournisseur: sansFournisseur.filter(
350
- n =>
351
- !resolus.has(n) &&
352
- (existsSync(path.join(racine, n)) ||
353
- (sources ??= sourcesDe(tous)).some(s => DECLARATION_EN_TETE(n).test(s)))
354
- ),
230
+ sansFournisseur: code.sansFournisseur,
355
231
  types: {
356
- etat: types.etat,
357
- raison: types.raison,
358
- elements: types.elements.map(e => ({
232
+ etat: code.types.etat,
233
+ raison: code.types.raison,
234
+ elements: code.types.elements.map(e => ({
359
235
  nom: e.nom,
360
236
  declarations: e.declarations.map(d => ({
361
- composant: titre(d.c),
237
+ composant: titre(d.composant),
362
238
  publie: d.publie,
363
239
  })),
364
240
  lecteurs: lecteursDe(e.lecteurs),
@@ -366,7 +242,7 @@ export function releve(racine, description) {
366
242
  },
367
243
  lit: lecteursDe(parChemins),
368
244
  architecture: lecteursDe(architecture),
369
- composants: ordonner([...trouves], lit, titre).map(titre),
245
+ composants: ordonner([...trouves], code.lit, titre).map(titre),
370
246
  };
371
247
  }
372
248
 
@@ -374,8 +250,9 @@ export function releve(racine, description) {
374
250
  // `##` heading that ends with that word), its rule (`**R4.**`, else its line), its continuation
375
251
  // lines included.
376
252
  function rendus(c) {
377
- const texte = lireSiPresent(path.join(c.dir, 'docs', 'CADRE.md'));
378
- if (!texte) return [];
253
+ const f = path.join(c.dossier, 'docs', 'CADRE.md');
254
+ if (!existsSync(f)) return [];
255
+ const texte = readFileSync(f, 'utf8');
379
256
  const out = [];
380
257
  let dedans = false;
381
258
  for (const [i, l] of texte.split('\n').entries()) {
@@ -397,9 +274,9 @@ function rendus(c) {
397
274
  // package names or paths, or `.`), in the survey's order.
398
275
  export function manquants(racine, r, titre) {
399
276
  if (titre.includes('.')) return [];
400
- const tous = lesComposants(racine);
277
+ const tous = langageDe(racine).composants(racine);
401
278
  const couvre = c => {
402
- const rel = path.relative(racine, c.dir).split(path.sep).join('/');
279
+ const rel = path.relative(racine, c.dossier).split(path.sep).join('/');
403
280
  return titre.some(t => {
404
281
  const n = path.normalize(t).replace(/\/$/, '');
405
282
  return t === c.paquet || rel === n || rel.startsWith(`${n}/`);
@@ -0,0 +1,27 @@
1
+ // The types of ./conformite.mjs as the entry `@roomi-fields/grillhouse/conformite` publishes it:
2
+ // the suite of conformity of a module of language to the join (./jointure.d.ts).
3
+ import type { Langage } from './jointure.js';
4
+
5
+ /** A case of the join: the faults its check finds on the valid entry (none expected) and on the
6
+ * defective entry (exactly `attendu` expected). */
7
+ export interface Cas {
8
+ nom: string;
9
+ valide(): string[];
10
+ invalide(): string[];
11
+ attendu: string[];
12
+ }
13
+
14
+ /** The entries of a module of language, prepared once under a directory. */
15
+ export interface Exemples {
16
+ preparer(dans: string): Record<string, unknown>;
17
+ }
18
+
19
+ /** The cases of the join for the module `langage`, its entries `exemples` prepared under `dans`. */
20
+ export function cas(langage: Langage, exemples: Exemples, options?: { dans?: string }): Cas[];
21
+
22
+ /** The cases the module `langage` fails, each with its reason. */
23
+ export function echecs(
24
+ langage: Langage,
25
+ exemples: Exemples,
26
+ options?: { dans?: string }
27
+ ): { nom: string; raison: string }[];
@@ -0,0 +1,226 @@
1
+ // The suite of conformity of the join of the languages: one check per demand that the core makes
2
+ // of a module of language (scripts/jointure.d.ts, docs/INTERFACE.md), held on every module, as
3
+ // ESLint's RuleTester holds a rule to its cases and Babel's test runner a plugin to its fixtures.
4
+ // It carries no test framework: a module's test asks it.
5
+ //
6
+ // - `cas(langage, exemples, { dans })`: one case per demand, `{ nom, valide, invalide, attendu }`.
7
+ // Each judges the module's answer on an entry and gives the faults it finds, as lines; a sound
8
+ // module gives none on its valid entry, and exactly `attendu` on its defective entry, so that a
9
+ // check that never fails is seen.
10
+ // - The entries are the module's (`exemples.preparer(dans)`, for typescript
11
+ // scripts/langages/typescript/exemples.mjs), prepared once per directory.
12
+ // - `echecs(langage, exemples, { dans })`: the cases a module fails, `{ nom, raison }`.
13
+ //
14
+ // The checks:
15
+ // - composants: each component of the repository of the entry, its name and its package, its
16
+ // folder absolute and existing;
17
+ // - composantDe: each file of the entry lies in the component it names, among `composants`;
18
+ // - lecteurs: what each component reads of another, by its code, and each name of the entry no
19
+ // component provides;
20
+ // - touches: what changed since the commit of the entry, each component touched, each dependent
21
+ // and each file out of the graph;
22
+ // - commandes: each command named is described (`{ script, args }`, the script a file), and asking
23
+ // them writes nothing in the repository;
24
+ // - verdict: each task neither green nor unplayed (« à repasser » at 75, red otherwise), the one
25
+ // that plays the tests marked, and each test failed;
26
+ // - estUnTest: each path the testwriter writes, with what it is (`joue`, `test`, `matiere`);
27
+ // - fichiersEngendres: each generated file whose check finds a gap;
28
+ // - gardes: each guard named that the module does not play, and each script it plays that does
29
+ // not exist;
30
+ // - elementsDuLot: each file the lot of the entry changes, each changed source the module reads no
31
+ // element of, and each element it adds, changes or removes;
32
+ // - matieres: each component of the shared test material of the repository of the entry;
33
+ // - joueDesTests: each component of the repository of the entry that plays tests;
34
+ // - trouve: each repository of the entry where the module finds its language.
35
+ import { existsSync, readdirSync, statSync } from 'node:fs';
36
+ import { tmpdir } from 'node:os';
37
+ import path from 'node:path';
38
+ import { isDeepStrictEqual } from 'node:util';
39
+
40
+ const preparees = new WeakMap();
41
+ // The entries of <exemples> under <dans>, prepared once.
42
+ function entrees(exemples, dans) {
43
+ if (!preparees.has(exemples)) preparees.set(exemples, new Map());
44
+ const parDossier = preparees.get(exemples);
45
+ if (!parDossier.has(dans)) parDossier.set(dans, exemples.preparer(dans));
46
+ return parDossier.get(dans);
47
+ }
48
+
49
+ // The files under <racine>, `.git` left out, with their instant of change.
50
+ function etat(racine) {
51
+ const out = new Map();
52
+ const parcourir = d => {
53
+ for (const n of readdirSync(d)) {
54
+ if (n === '.git') continue;
55
+ const f = path.join(d, n);
56
+ const s = statSync(f);
57
+ if (s.isDirectory()) parcourir(f);
58
+ else out.set(f, s.mtimeMs);
59
+ }
60
+ };
61
+ parcourir(racine);
62
+ return out;
63
+ }
64
+
65
+ // Whether <c> is a command described: an existing script and a list of arguments.
66
+ const decrite = c =>
67
+ c !== null &&
68
+ typeof c === 'object' &&
69
+ typeof c.script === 'string' &&
70
+ path.isAbsolute(c.script) &&
71
+ existsSync(c.script) &&
72
+ Array.isArray(c.args) &&
73
+ c.args.every(a => typeof a === 'string');
74
+
75
+ const nomDeGarde = g => path.basename(String(g?.[0] ?? '')).replace(/\.[cm]?js$/, '');
76
+
77
+ /**
78
+ * The cases of the join for the module <langage>, its entries <exemples> prepared under <dans>.
79
+ * @param {import('./jointure.js').Langage} langage the module of language
80
+ * @param {import('./conformite.js').Exemples} exemples its entries
81
+ * @param {{ dans?: string }} [options] the directory of the entries
82
+ * @returns {import('./conformite.js').Cas[]}
83
+ */
84
+ export function cas(langage, exemples, { dans = tmpdir() } = {}) {
85
+ const e = entrees(exemples, dans);
86
+ const nommer = c => `${c.nom} (${c.paquet ?? 'sans paquet'})`;
87
+ const juges = {
88
+ composants: racine =>
89
+ langage
90
+ .composants(racine)
91
+ .map(c =>
92
+ path.isAbsolute(c.dossier) && existsSync(c.dossier)
93
+ ? nommer(c)
94
+ : `${nommer(c)} : dossier ${c.dossier} absent`
95
+ ),
96
+ composantDe: liste =>
97
+ liste.flatMap(({ fichier, composant }) => {
98
+ const c = langage.composantDe(e.racine, fichier);
99
+ const rel = path.isAbsolute(fichier) ? path.relative(e.racine, fichier) : fichier;
100
+ if (!c) return [`${rel} : hors de tout composant`];
101
+ const connu = langage.composants(e.racine).some(k => k.dossier === c.dossier);
102
+ if (!connu) return [`${rel} : dans ${c.nom}, qui n'est pas un composant`];
103
+ return c.nom === composant ? [] : [`${rel} : dans ${c.nom}, attendu ${composant}`];
104
+ }),
105
+ lecteurs: ({ racine, noms }) => {
106
+ const l = langage.lecteurs(racine, {
107
+ composants: langage.composants(racine),
108
+ noms,
109
+ texte: noms.join(' '),
110
+ nommes: [],
111
+ });
112
+ return [
113
+ ...[...l.lit].flatMap(([c, lus]) => [...lus].map(f => `${c.nom} lit ${f.nom}`)).sort(),
114
+ ...l.sansFournisseur.map(n => `${n} : sans fournisseur`),
115
+ ];
116
+ },
117
+ touches: ({ racine, depuis }) => {
118
+ const t = langage.touches(racine, { depuis });
119
+ return [
120
+ ...t.touches.map(c => `touché ${c.nom}`),
121
+ ...t.dependants.map(c => `dépendant ${c.nom}`),
122
+ ...t.horsGraphe.map(f => `hors ${f}`),
123
+ ];
124
+ },
125
+ commandes: noms => {
126
+ const avant = etat(e.racine);
127
+ const c = langage.commandes(e.racine);
128
+ const out = noms.flatMap(n => {
129
+ if (!Object.hasOwn(c, n)) return [`${n} : absente`];
130
+ return decrite(c[n]) ? [] : [`${n} : pas une commande décrite`];
131
+ });
132
+ if (!isDeepStrictEqual(etat(e.racine), avant)) out.push('commandes écrit dans le dépôt');
133
+ return out;
134
+ },
135
+ verdict: dossier => {
136
+ const v = langage.verdict(dossier);
137
+ return [
138
+ ...v.taches
139
+ .filter(t => t.code !== null && t.code !== 0)
140
+ .map(t =>
141
+ t.code === 75
142
+ ? `${t.paquet}#${t.script} à repasser${t.tests ? ', tests' : ''}`
143
+ : `${t.paquet}#${t.script} rouge (${t.code})${t.tests ? ', tests' : ''}`
144
+ ),
145
+ ...v.rapports.flatMap(r =>
146
+ r.tests
147
+ .filter(t => t.etat === 'failed')
148
+ .map(t => `test ${path.basename(r.fichier)} › ${t.nom}`)
149
+ ),
150
+ ];
151
+ },
152
+ estUnTest: chemins =>
153
+ chemins.flatMap(chemin => {
154
+ const c = langage.estUnTest(chemin, e.racine);
155
+ if (c === null) return [];
156
+ return [`${chemin} : ${['joue', 'test', 'matiere'].filter(k => c[k]).join(', ')}`];
157
+ }),
158
+ fichiersEngendres: racine =>
159
+ langage
160
+ .fichiersEngendres(racine)
161
+ .filter(f => f.verifier(racine).length > 0)
162
+ .map(f => `${f.nom} : en retard`),
163
+ gardes: attendues => {
164
+ const gardes = langage.gardes(e.racine);
165
+ const noms = new Set(gardes.map(nomDeGarde));
166
+ return [
167
+ ...attendues.filter(n => !noms.has(n)).map(n => `${n} : manquante`),
168
+ ...gardes.filter(g => !existsSync(String(g?.[0]))).map(g => `${g?.[0]} : absent`),
169
+ ];
170
+ },
171
+ elementsDuLot: ({ racine, avant, apres }) => {
172
+ const l = langage.elementsDuLot(racine, { avant, apres });
173
+ if (l.etat !== 'fait') return [`impossible : ${l.raison}`];
174
+ return [
175
+ ...l.fichiers.map(f => `fichier ${f}`),
176
+ ...l.horsDuService.map(f => `hors du service ${f}`),
177
+ ...l.elements.map(x => `${x.statut} ${x.id}`),
178
+ ];
179
+ },
180
+ matieres: racine => langage.matieres(racine).map(nommer),
181
+ joueDesTests: racine =>
182
+ langage
183
+ .composants(racine)
184
+ .filter(c => langage.joueDesTests(racine, c))
185
+ .map(c => `${nommer(c)} : joue des tests`),
186
+ trouve: depots => depots.filter(d => langage.trouve(d.racine)).map(d => `${d.nom} : trouvé`),
187
+ };
188
+ const invalides = {
189
+ gardes: [...e.gardes.valide, 'garde-inexistante'],
190
+ };
191
+ const attendus = { gardes: ['garde-inexistante : manquante'] };
192
+ return Object.entries(juges).map(([nom, juger]) => ({
193
+ nom,
194
+ valide: () => juger(e[nom].valide),
195
+ invalide: () => juger(invalides[nom] ?? e[nom].invalide),
196
+ attendu: attendus[nom] ?? e[nom].attendu,
197
+ }));
198
+ }
199
+
200
+ /**
201
+ * The cases the module <langage> fails, a case whose check throws included.
202
+ * @param {import('./jointure.js').Langage} langage the module of language
203
+ * @param {import('./conformite.js').Exemples} exemples its entries
204
+ * @param {{ dans?: string }} [options] the directory of the entries
205
+ * @returns {{ nom: string, raison: string }[]}
206
+ */
207
+ export function echecs(langage, exemples, options) {
208
+ return cas(langage, exemples, options).flatMap(c => {
209
+ try {
210
+ const v = c.valide();
211
+ if (v.length) return [{ nom: c.nom, raison: `entrée valide : ${v.join(' ; ')}` }];
212
+ const i = c.invalide();
213
+ if (!isDeepStrictEqual(i, c.attendu)) {
214
+ return [
215
+ {
216
+ nom: c.nom,
217
+ raison: `entrée défectueuse : ${i.join(' ; ') || 'aucune faute'}, attendu ${c.attendu.join(' ; ')}`,
218
+ },
219
+ ];
220
+ }
221
+ return [];
222
+ } catch (err) {
223
+ return [{ nom: c.nom, raison: `lève : ${err?.message ?? err}` }];
224
+ }
225
+ });
226
+ }
package/scripts/demon.mjs CHANGED
@@ -30,7 +30,7 @@ import {
30
30
  } from 'node:fs';
31
31
  import os from 'node:os';
32
32
  import path from 'node:path';
33
- import { vivant } from './vitest-config/base-de-passe.mjs';
33
+ import { vivant } from './mesure/base-de-passe.mjs';
34
34
 
35
35
  // The variable that carries, to the relay and then to the daemon, its role, the directory of the
36
36
  // daemon's output and the caller's process.
@@ -1,5 +1,5 @@
1
1
  // The last green of a branch: the tree of the last pass of `npm run verifier` green on every
2
- // package (scripts/verifier.mjs), against which the next pass measures itself, as
2
+ // package (scripts/langages/typescript/verifier.mjs), against which the next pass measures itself, as
3
3
  // `vitest --changed <ref>` and `jest --onlyChanged` play the tests a change reaches, and Bazel
4
4
  // keeps by target the result of a test whose inputs did not move.
5
5
  //
@@ -28,11 +28,12 @@
28
28
  // from the commit its parent records (its files changed, or its HEAD moved) or the changes
29
29
  // reach a submodule: git's tree holds a submodule's commit, not its files. The pass is then
30
30
  // complete, and keeps no green.
31
- // - The changes go to Vitest in a file that the variable `GRILLHOUSE_CHANGEMENTS` names
32
- // (scripts/vitest-config/changements.mjs, which reads them in each package); the file lies in a
33
- // temporary directory of its own, which the pass removes at its end.
31
+ // - The changes go to the runner of the tests in a file that the variable `GRILLHOUSE_CHANGEMENTS`
32
+ // names (`CHANGEMENTS`; for the module typescript, scripts/langages/typescript/vitest-config/changements.mjs reads
33
+ // them in each package); the file lies in a temporary directory of its own, which the pass
34
+ // removes at its end.
34
35
  // - `npm test` measures itself against the last green under the circuit's mark,
35
- // `GRILLHOUSE_DEPUIS_LE_VERT` (scripts/tests.mjs, scripts/circuit.mjs); it never keeps one.
36
+ // `GRILLHOUSE_DEPUIS_LE_VERT` (scripts/langages/typescript/tests.mjs, scripts/circuit.mjs); it never keeps one.
36
37
  import { spawnSync } from 'node:child_process';
37
38
  import {
38
39
  copyFileSync,
@@ -46,8 +47,9 @@ import {
46
47
  } from 'node:fs';
47
48
  import os from 'node:os';
48
49
  import path from 'node:path';
49
- import { CHANGEMENTS } from './vitest-config/changements.mjs';
50
-
50
+ // The variable that names the file of the changes since the last green, which the runner of the
51
+ // tests of the module of the language reads in each package.
52
+ export const CHANGEMENTS = 'GRILLHOUSE_CHANGEMENTS';
51
53
  export const DEPUIS_LE_VERT = 'GRILLHOUSE_DEPUIS_LE_VERT';
52
54
  const SHA = /^[0-9a-f]{40,64}$/;
53
55
 
@@ -194,7 +196,7 @@ function supprimesDuCommit(racine, commit, arbre) {
194
196
  // keep once green (null when none can count), the variables to add to the pass's environment (the
195
197
  // changes since the last green, none for a complete pass), the line that says which, and the
196
198
  // function that removes the file of the changes. <tout> asks for the complete pass; the file lies
197
- // in <dans>, the base of the pass (scripts/vitest-config/base-de-passe.mjs), which a killed pass
199
+ // in <dans>, the base of the pass (scripts/mesure/base-de-passe.mjs), which a killed pass
198
200
  // leaves to the next one to sweep.
199
201
  export function mesure(racine, { tout = false, dans = os.tmpdir() } = {}) {
200
202
  const etat = etatDuDepot(racine);
@@ -228,7 +230,7 @@ export function mesure(racine, { tout = false, dans = os.tmpdir() } = {}) {
228
230
  return {
229
231
  etat,
230
232
  env: { [CHANGEMENTS]: fichier },
231
- ligne: `↳ depuis le dernier vert de ${vert.branche} (${vert.commit.slice(0, 12)}, arbre ${vert.arbre.slice(0, 12)}) : ${n} fichier(s) changé(s) ; chaque paquet que Turborepo rejoue joue les tests que Vitest y relie.`,
233
+ ligne: `↳ depuis le dernier vert de ${vert.branche} (${vert.commit.slice(0, 12)}, arbre ${vert.arbre.slice(0, 12)}) : ${n} fichier(s) changé(s) ; chaque paquet rejoué joue les tests que ses changements atteignent.`,
232
234
  retirer: () => rmSync(dir, { recursive: true, force: true }),
233
235
  };
234
236
  }