@roomi-fields/grillhouse 0.24.14 → 0.25.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 (124) 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 +36 -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 +167 -17
  12. package/docs/CADRE.md +47 -0
  13. package/docs/INTERFACE.md +168 -0
  14. package/package.json +71 -14
  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 +24 -75
  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} +61 -34
  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 -9
  83. package/scripts/{vitest-config → langages/typescript/vitest-config}/cibles.mjs +7 -6
  84. package/scripts/{vitest-config → langages/typescript/vitest-config}/duree.reporter.mjs +6 -1
  85. package/scripts/langages/typescript/vitest-config/lances.mjs +473 -0
  86. package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.setup.mjs +1 -1
  87. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.mjs +5 -5
  88. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.setup.mjs +4 -3
  89. package/scripts/{vitest.nuit.config.mjs → langages/typescript/vitest.nuit.config.mjs} +2 -2
  90. package/scripts/langages.mjs +85 -0
  91. package/scripts/{vitest-config → mesure}/avancement.mjs +4 -13
  92. package/scripts/{vitest-config → mesure}/base-de-passe.mjs +70 -33
  93. package/scripts/{vitest-config → mesure}/pression.mjs +5 -6
  94. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +29 -6
  95. package/scripts/migrations/0.24.0-circuit-simplifie.mjs +13 -6
  96. package/scripts/migrations/0.25.0-script-des-tests.mjs +92 -0
  97. package/scripts/migrations.mjs +17 -13
  98. package/scripts/nuit.sh +59 -63
  99. package/scripts/paquets.d.ts +5 -0
  100. package/scripts/paquets.mjs +24 -2
  101. package/scripts/resultats.mjs +8 -82
  102. package/scripts/services-du-noyau.mjs +30 -0
  103. package/scripts/session-start.sh +17 -9
  104. package/scripts/sources.mjs +35 -13
  105. package/scripts/sous-commandes.mjs +57 -17
  106. package/scripts/superviseur.mjs +1 -1
  107. package/scripts/tableau.mjs +1 -1
  108. package/scripts/un-commit-par-ticket.mjs +48 -14
  109. package/scripts/verrou-de-fichier.mjs +1 -1
  110. package/scripts/verrou-de-machine.mjs +4 -4
  111. package/scripts/verrous/verrou.mjs +28 -37
  112. package/skills/developpeur/SKILL.md +2 -2
  113. package/skills/explorateur/SKILL.md +13 -5
  114. package/skills/grill/SKILL.md +2 -2
  115. package/skills/pitmaster/references/cadre.md +1 -1
  116. package/skills/pitmaster/references/consigne-agent.md +10 -3
  117. package/skills/redacteur/references/documents-d-un-composant.md +4 -4
  118. package/skills/relecteur/SKILL.md +4 -1
  119. package/skills/testwriter/SKILL.md +20 -6
  120. /package/scripts/{consommateurs.d.ts → langages/typescript/consommateurs.d.ts} +0 -0
  121. /package/scripts/{vitest-config → langages/typescript/vitest-config}/base.d.ts +0 -0
  122. /package/scripts/{vitest-config → langages/typescript/vitest-config}/machine.setup.mjs +0 -0
  123. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.d.ts +0 -0
  124. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.mjs +0 -0
@@ -0,0 +1,289 @@
1
+ // The entries of the suite of conformity (scripts/conformite.mjs) for the module typescript, as
2
+ // the valid and invalid cases a rule of ESLint gives its RuleTester: each a trial, built under the
3
+ // directory the suite gives, with what a sound module answers on it.
4
+ //
5
+ // - A repository of four packages: `@e/a`; `@e/b`, which depends on `@e/a`; `@e/c`, which depends
6
+ // on `@e/b`; `@e/m`, the shared test material (it exports `./test-fixtures`). Each has its
7
+ // interface, and the generated files are written by their own commands (the index of the
8
+ // interfaces, the turbo.json of the packages): `aJour`; the same with each generated file out
9
+ // of date: the interface of `a` changed after its index, a fault listed that its code never
10
+ // produces (the check of the interfaces against the code), the turbo.json of `b` stale:
11
+ // `enRetard`; the same, committed, a file of `a` then changed and a file out of every package
12
+ // added: `change`, measured from its commit; the same where the code of `b` imports `a` and the
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
16
+ // repository of two packages, one with the script of the tests (`test:unit`): `avecTests`.
17
+ // - Two results directories of a run: every task and test green (`vert`); `a` at 75, `b` red, a
18
+ // test of `b` failed (`defaut`).
19
+ import { execFileSync } from 'node:child_process';
20
+ import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
21
+ import path from 'node:path';
22
+ import { fileURLToPath } from 'node:url';
23
+
24
+ const SCRIPTS = path.dirname(fileURLToPath(import.meta.url));
25
+ const json = o => `${JSON.stringify(o, null, 2)}\n`;
26
+ const ecrireDans = racine => (rel, texte) => {
27
+ mkdirSync(path.dirname(path.join(racine, rel)), { recursive: true });
28
+ writeFileSync(path.join(racine, rel), texte);
29
+ };
30
+ const git = (racine, ...args) => execFileSync('git', ['-C', racine, ...args], { stdio: 'pipe' });
31
+ const node = (racine, script, ...args) =>
32
+ execFileSync(process.execPath, [path.join(SCRIPTS, script), ...args], {
33
+ cwd: racine,
34
+ stdio: 'pipe',
35
+ });
36
+
37
+ const PAQUETS = {
38
+ a: { name: '@e/a' },
39
+ b: { name: '@e/b', dependencies: { '@e/a': '*' } },
40
+ c: { name: '@e/c', devDependencies: { '@e/b': '*' } },
41
+ m: { name: '@e/m', exports: { './test-fixtures': './src/index.ts' } },
42
+ };
43
+
44
+ // The repository of the four packages in a new directory under <dans>, its generated files
45
+ // written, committed.
46
+ function depot(dans) {
47
+ const racine = mkdtempSync(path.join(dans, 'depot-'));
48
+ const ecrire = ecrireDans(racine);
49
+ ecrire('package.json', json({ name: 'e', private: true, workspaces: ['packages/*'] }));
50
+ ecrire(
51
+ 'turbo.json',
52
+ json({ $schema: 'https://turborepo.com/schema.json', tasks: { build: { outputs: [] } } })
53
+ );
54
+ for (const [nom, pkg] of Object.entries(PAQUETS)) {
55
+ ecrire(`packages/${nom}/package.json`, json({ type: 'module', ...pkg }));
56
+ ecrire(`packages/${nom}/src/index.ts`, `export const ${nom} = 1;\n`);
57
+ ecrire(
58
+ `packages/${nom}/docs/INTERFACE.md`,
59
+ `# ${nom}\n\n${nom.toUpperCase()} rend un nombre.\n`
60
+ );
61
+ }
62
+ mkdirSync(path.join(racine, 'docs/agents'), { recursive: true });
63
+ node(racine, 'turbo-des-paquets.mjs', '--ecrire');
64
+ node(racine, 'index-interfaces.mjs');
65
+ git(racine, 'init', '-q', '-b', 'main');
66
+ git(racine, 'config', 'user.email', 'essai@example.com');
67
+ git(racine, 'config', 'user.name', 'essai');
68
+ git(racine, 'config', 'commit.gpgsign', 'false');
69
+ git(racine, 'add', '-A');
70
+ git(racine, 'commit', '-q', '-m', 'essai');
71
+ return racine;
72
+ }
73
+
74
+ // A results directory under <dans> of the tasks <taches> (`[paquet, code]` of `test:unit`) and
75
+ // the test files <fichiers> (`[fichier, nom, etat]`).
76
+ function resultats(dans, taches, fichiers) {
77
+ const dossier = mkdtempSync(path.join(dans, 'resultats-'));
78
+ const ecrire = ecrireDans(dossier);
79
+ ecrire(
80
+ 'turbo/run.json',
81
+ json({
82
+ tasks: taches.map(([paquet, code]) => ({
83
+ taskId: `${paquet}#test:unit`,
84
+ package: paquet,
85
+ directory: `packages/${paquet}`,
86
+ task: 'test:unit',
87
+ execution: { exitCode: code },
88
+ cache: { status: 'MISS' },
89
+ logFile: `packages/${paquet}/.turbo/turbo-test.log`,
90
+ })),
91
+ })
92
+ );
93
+ ecrire(
94
+ 'vitest/rapport.json',
95
+ json({
96
+ testResults: fichiers.map(([fichier, nom, etat]) => ({
97
+ name: path.join(dossier, fichier),
98
+ status: etat,
99
+ message: '',
100
+ assertionResults: [{ title: nom, fullName: nom, status: etat, failureMessages: [] }],
101
+ })),
102
+ })
103
+ );
104
+ return dossier;
105
+ }
106
+
107
+ const tete = racine =>
108
+ execFileSync('git', ['-C', racine, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
109
+
110
+ export default {
111
+ // The trials under <dans>.
112
+ preparer(dans) {
113
+ const aJour = depot(dans);
114
+ const vide = mkdtempSync(path.join(dans, 'vide-'));
115
+ 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
+ // A repository of two packages, `a` with the script of the tests, `b` without.
124
+ const avecTests = mkdtempSync(path.join(dans, 'tests-'));
125
+ ecrireDans(avecTests)('package.json', json({ name: 't', workspaces: ['packages/*'] }));
126
+ ecrireDans(avecTests)(
127
+ 'packages/a/package.json',
128
+ json({ name: '@t/a', scripts: { 'test:unit': 'vitest run' } })
129
+ );
130
+ ecrireDans(avecTests)('packages/b/package.json', json({ name: '@t/b', scripts: {} }));
131
+ const enRetard = depot(dans);
132
+ writeFileSync(
133
+ path.join(enRetard, 'packages/a/docs/INTERFACE.md'),
134
+ '# a\n\nA rend un autre nombre.\n\n## Les fautes\n\n- `A_ABSENTE` : jamais produite.\n'
135
+ );
136
+ writeFileSync(path.join(enRetard, 'packages/b/turbo.json'), '{}\n');
137
+ // The specifiers are written apart, so that no reading of the package's imports takes a
138
+ // trial's for its own.
139
+ const lus = depot(dans);
140
+ writeFileSync(
141
+ path.join(lus, 'packages/b/src/index.ts'),
142
+ `import { a } from ${"'@e/a'"};\nexport const b = a;\n`
143
+ );
144
+ writeFileSync(
145
+ path.join(lus, 'packages/c/src/index.ts'),
146
+ `import { b } from ${"'@e/b'"};\nexport const c = b;\n`
147
+ );
148
+ const lot = depot(dans);
149
+ const avantLeLot = tete(lot);
150
+ writeFileSync(path.join(lot, 'packages/a/src/index.ts'), 'export const a = 3;\n');
151
+ git(lot, 'commit', '-q', '-am', 'lot');
152
+ const change = depot(dans);
153
+ const depuis = tete(change);
154
+ writeFileSync(path.join(change, 'packages/a/src/index.ts'), 'export const a = 2;\n');
155
+ writeFileSync(path.join(change, 'notes.txt'), 'hors des paquets\n');
156
+ return {
157
+ racine: aJour,
158
+ composants: {
159
+ valide: vide,
160
+ invalide: aJour,
161
+ attendu: ['a (@e/a)', 'b (@e/b)', 'c (@e/c)', 'm (@e/m)'],
162
+ },
163
+ composantDe: {
164
+ valide: [
165
+ { fichier: 'packages/a/src/index.ts', composant: 'a' },
166
+ { fichier: 'packages/b/docs/INTERFACE.md', composant: 'b' },
167
+ { fichier: path.join(aJour, 'packages/c/package.json'), composant: 'c' },
168
+ ],
169
+ invalide: [{ fichier: 'package.json' }, { fichier: 'docs/agents/index-des-interfaces.md' }],
170
+ attendu: [
171
+ 'package.json : hors de tout composant',
172
+ 'docs/agents/index-des-interfaces.md : hors de tout composant',
173
+ ],
174
+ },
175
+ lecteurs: {
176
+ valide: { racine: aJour, noms: [] },
177
+ invalide: { racine: lus, noms: ['package.json'] },
178
+ attendu: ['b lit a', 'c lit b', 'package.json : sans fournisseur'],
179
+ },
180
+ touches: {
181
+ valide: { racine: aJour, depuis: 'HEAD' },
182
+ invalide: { racine: change, depuis },
183
+ attendu: ['touché a', 'dépendant b', 'dépendant c', 'hors notes.txt'],
184
+ },
185
+ commandes: {
186
+ valide: [
187
+ 'tester',
188
+ 'verifier',
189
+ 'typer',
190
+ 'chemins-des-tests',
191
+ 'code-mort',
192
+ 'consommateurs',
193
+ 'consommateurs-arbitres',
194
+ 'frontieres',
195
+ 'index-interfaces',
196
+ 'interfaces-contre-code',
197
+ 'resumes',
198
+ 'tailles-des-tests',
199
+ 'turbo-des-paquets',
200
+ ],
201
+ invalide: ['tester', 'deployer'],
202
+ attendu: ['deployer : absente'],
203
+ },
204
+ verdict: {
205
+ valide: resultats(
206
+ dans,
207
+ [
208
+ ['a', 0],
209
+ ['b', 0],
210
+ ],
211
+ [['packages/a/x.test.ts', 'a', 'passed']]
212
+ ),
213
+ invalide: resultats(
214
+ dans,
215
+ [
216
+ ['a', 75],
217
+ ['b', 1],
218
+ ['c', null],
219
+ ],
220
+ [
221
+ ['packages/a/x.test.ts', 'a', 'passed'],
222
+ ['packages/b/x.test.ts', 'b', 'failed'],
223
+ ]
224
+ ),
225
+ attendu: [
226
+ 'a#test:unit à repasser, tests',
227
+ 'b#test:unit rouge (1), tests',
228
+ 'test x.test.ts › b',
229
+ ],
230
+ },
231
+ estUnTest: {
232
+ valide: ['packages/a/src/index.ts', 'packages/a/src/testing.ts', 'README.md'],
233
+ invalide: [
234
+ 'packages/a/src/index.spec.mjs',
235
+ 'packages/a/src/index.test.ts',
236
+ 'packages/a/tests/aide.ts',
237
+ 'packages/m/src/index.ts',
238
+ ],
239
+ attendu: [
240
+ 'packages/a/src/index.spec.mjs : joue, test',
241
+ 'packages/a/src/index.test.ts : joue, test',
242
+ 'packages/a/tests/aide.ts : test',
243
+ 'packages/m/src/index.ts : matiere',
244
+ ],
245
+ },
246
+ fichiersEngendres: {
247
+ valide: aJour,
248
+ invalide: enRetard,
249
+ attendu: [
250
+ "l'index des interfaces : en retard",
251
+ 'les turbo.json des paquets : en retard',
252
+ "les rapports d'API : en retard",
253
+ ],
254
+ },
255
+ gardes: {
256
+ valide: [
257
+ 'turbo-des-paquets',
258
+ 'index-interfaces',
259
+ 'consommateurs',
260
+ 'consommateurs-arbitres',
261
+ 'frontieres',
262
+ 'interfaces-contre-code',
263
+ 'code-mort',
264
+ 'tailles-des-tests',
265
+ 'chemins-des-tests',
266
+ 'resumes',
267
+ ],
268
+ },
269
+ elementsDuLot: {
270
+ valide: { racine: aJour, avant: 'HEAD', apres: 'HEAD' },
271
+ invalide: { racine: lot, avant: avantLeLot, apres: 'HEAD' },
272
+ attendu: ['fichier packages/a/src/index.ts', 'hors du service packages/a/src/index.ts'],
273
+ },
274
+ matieres: { valide: vide, invalide: aJour, attendu: ['m (@e/m)'] },
275
+ 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
+ };
288
+ },
289
+ };
@@ -19,7 +19,7 @@
19
19
  // import; every import resolves (a path a package does not export is refused); an orphan file is
20
20
  // reported, without refusing, unless it is an entry: an index, a configuration, a declaration, a
21
21
  // test, or a file that the `bin` field of a package names (its commands, as knip takes them). Who uses which component is the consumers check's
22
- // (`scripts/consommateurs.mjs`). The files of a package out of the frame
22
+ // (`scripts/langages/typescript/consommateurs.mjs`). The files of a package out of the frame
23
23
  // (`docs/agents/hors-cadre.txt`) are excluded, and no module rule is written for it.
24
24
  //
25
25
  // An error of dependency-cruiser inscribed in the project's debt (`grillhouse-dette.json`, see
@@ -42,15 +42,13 @@ import { tmpdir } from 'node:os';
42
42
  import path from 'node:path';
43
43
  import { pathToFileURL } from 'node:url';
44
44
  import { composants } from './consommateurs.mjs';
45
- import { horsCadre } from './paquets.mjs';
46
- import { trancher } from './dette.mjs';
45
+ import { CODE, horsCadre } from '../../paquets.mjs';
46
+ import { trancher } from '../../dette.mjs';
47
47
 
48
48
  export const CONFIGURATION = '.dependency-cruiser.cjs';
49
49
  export const RACINES = ['src', 'packages'];
50
50
  /** The test files, as a pattern of a path from the repository's root. */
51
51
  export const TESTS = '(^|/)(test|tests|__tests__)/|[.](test|spec)[.][a-z]+$';
52
- /** The code of `src/` (the root's, or a package's under `packages/`), as a pattern of such a path. */
53
- export const CODE = '^src/|^packages/[^/]+/src/';
54
52
  const REGLE_OUTILS = 'pas-d-outil-de-developpement-dans-le-code';
55
53
  // The environment variable naming the file that holds the pattern of the published files.
56
54
  const JUGES = 'GRILLHOUSE_JUGES';
@@ -10,7 +10,7 @@
10
10
  // prints what the providers of <composant> publish
11
11
  //
12
12
  // The providers of a component are the components whose `## Consommateurs` section names it: the
13
- // frame's one written and checked record of who uses whom (scripts/consommateurs.mjs). `--publie`
13
+ // frame's one written and checked record of who uses whom (scripts/langages/typescript/consommateurs.mjs). `--publie`
14
14
  // is the first level of a progressive disclosure, as the skills of Claude Code, llms.txt or
15
15
  // Aider's repository map: for each provider, its line, the names of the elements declared for the
16
16
  // component (the only ones the check of the consumers lets it use) and the address of the rubric
@@ -36,9 +36,9 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
36
36
  import path from 'node:path';
37
37
  import { pathToFileURL } from 'node:url';
38
38
  import { composants, declares } from './consommateurs.mjs';
39
- import { lireLaListe } from './enveloppe/paquets-du-plan.mjs';
39
+ import { lireLaListe } from '../../services-du-noyau.mjs';
40
40
  import { DEBUT, FIN, marques } from './interfaces-contre-code.mjs';
41
- import { ecrireSarif } from './resultats.mjs';
41
+ import { ecrireSarif } from '../../resultats.mjs';
42
42
 
43
43
  export const SORTIE = 'docs/agents/index-des-interfaces.md';
44
44
 
@@ -0,0 +1,335 @@
1
+ // The module of language typescript: what the core asks of a language (scripts/jointure.d.ts,
2
+ // docs/INTERFACE.md), answered by the scripts of this directory — the components of the frame
3
+ // (./consommateurs.mjs), the tests by Turborepo and Vitest (./tests.mjs, ./verifier.mjs), the
4
+ // guards of structure and their generators. The core loads it by scripts/langages.mjs, and this
5
+ // module imports of the core its published entries alone.
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`).
10
+ // - The components: the folders `packages/<x>` and `src/<x>` of the frame (`composants` of
11
+ // ./consommateurs.mjs), out of the frame left out; a file's is the component that holds it; the
12
+ // shared test material, the components whose package exports `./test-fixtures` (`matieres`); a
13
+ // component plays tests when its package.json holds the script `test:unit` (`joueDesTests`),
14
+ // which Turborepo runs in it (./tests.mjs).
15
+ // - The components touched since a commit: the files git sees changed since it, the working tree
16
+ // and the untracked files included (`git diff --name-only <depuis>`, `git ls-files -o
17
+ // --exclude-standard`), each in its component, and the components that depend on them by their
18
+ // package.json (its `dependencies`, `devDependencies`, `optionalDependencies` and
19
+ // `peerDependencies` that name another component), transitively, as Turborepo's
20
+ // `--filter=...[<depuis>]`; a file out of every component is out of the graph.
21
+ // - The elements of a lot (./elements-du-lot.mjs).
22
+ // - Where its tools write, which the envelope opens to a session (`sorties`), and the rules that
23
+ // refuse a role that writes the test tool run directly (`droits`).
24
+ // - The commands: `grillhouse tests` (./tests.mjs) tests, `grillhouse verifier` (./verifier.mjs)
25
+ // verifies, and TypeScript's compiler, the project's or else the frame's, types (`tsc
26
+ // --noEmit`); the launcher builds an agent's copy (./construire.mjs) and the night plays the
27
+ // night tests (./tests-de-nuit.mjs); each guard and generator of this directory is a command
28
+ // too, by its name (`grillhouse frontieres`); each one described, `{ script, args }`, never run.
29
+ // - The tool of a test's temporary directory, `mkdtempSync(path.join(tmpdir(), '<prefix>-'))`
30
+ // removed in `afterAll`, and its guard: each run of Vitest plays under a base of its own,
31
+ // named in TMPDIR, TMP and TEMP, and fails naming what its tests left there
32
+ // (./vitest-config/base.mjs).
33
+ // - The verdict: the summaries of Turborepo and the reports of Vitest of a results directory
34
+ // (./verdict.mjs).
35
+ // - The rule of a test file (./regle-des-tests.mjs).
36
+ // - The generated files, each its command, the guard that checks it and the names its findings
37
+ // carry: the index of the interfaces, the turbo.json of the packages, the reports of API.
38
+ // - The guards of structure, in the order they play.
39
+ // - The migrations of a project of TypeScript (./migrations/): the base configuration of Vitest,
40
+ // and the ones that replay a guard of this module, which the update plays with the core's
41
+ // (scripts/migrations.mjs), as each plugin of Nx carries its own.
42
+ // - No binary of the machine (`binaires`); what its tools write in a project, `.turbo`
43
+ // (`ignorer`); its share of the update (./mise-a-jour.mjs, `miseAJour`): the tests by Vitest,
44
+ // the frame's package declared, the typing, the turbo.json, and the generators.
45
+ import { spawnSync } from 'node:child_process';
46
+ import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
47
+ import { createRequire } from 'node:module';
48
+ import { tmpdir } from 'node:os';
49
+ import path from 'node:path';
50
+ import { fileURLToPath } from 'node:url';
51
+ import { composants as lesComposants, matieres } from './consommateurs.mjs';
52
+ import { elementsDuLot } from './elements-du-lot.mjs';
53
+ import { A_ELAGUER, lireSarif, RESULTATS } from '../../resultats.mjs';
54
+ import { paquets } from '../../paquets.mjs';
55
+ import { lecteurs } from './lecteurs.mjs';
56
+ import { estUnTest } from './regle-des-tests.mjs';
57
+ import { SCRIPT_DES_TESTS } from './script-des-tests.mjs';
58
+ import { verdict } from './verdict.mjs';
59
+ import { miseAJour } from './mise-a-jour.mjs';
60
+ import * as configVitest from './migrations/0.23.0-config-vitest.mjs';
61
+ import * as nomsDeclaresInutilises from './migrations/0.24.4-noms-declares-inutilises.mjs';
62
+ import * as lignesMalFormees from './migrations/0.24.6-lignes-mal-formees.mjs';
63
+ import * as matiereDansLesTests from './migrations/0.24.7-matiere-dans-les-tests.mjs';
64
+ import * as taillesDesTests from './migrations/0.25.0-tailles-des-tests.mjs';
65
+ import * as cheminsDesTests from './migrations/0.25.0-chemins-des-tests.mjs';
66
+
67
+ // The scripts of this module, beside this file.
68
+ const SCRIPTS = path.dirname(fileURLToPath(import.meta.url));
69
+ const ici = nom => path.join(SCRIPTS, nom);
70
+ const generateur = (script, ...args) => [`node ${JSON.stringify(ici(script))}`, ...args].join(' ');
71
+ const CHAMPS = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies'];
72
+
73
+ const composants = racine =>
74
+ lesComposants(racine).map(({ nom, dir, paquet }) => ({ nom, dossier: dir, paquet }));
75
+ // The guards and the generators of this directory, each a command by its name.
76
+ const OUTILS = [
77
+ 'chemins-des-tests',
78
+ 'code-mort',
79
+ 'consommateurs',
80
+ 'consommateurs-arbitres',
81
+ 'frontieres',
82
+ 'index-interfaces',
83
+ 'interfaces-contre-code',
84
+ 'resumes',
85
+ 'tailles-des-tests',
86
+ 'turbo-des-paquets',
87
+ ];
88
+
89
+ // The component of <liste> that holds <fichier> (absolute, or from <racine>), null for none.
90
+ function composantDans(liste, racine, fichier) {
91
+ const abs = path.resolve(racine, fichier);
92
+ const tenants = liste.filter(c => abs === c.dossier || abs.startsWith(`${c.dossier}${path.sep}`));
93
+ return tenants.sort((a, b) => b.dossier.length - a.dossier.length)[0] ?? null;
94
+ }
95
+
96
+ const lireJson = f => {
97
+ try {
98
+ return JSON.parse(readFileSync(f, 'utf8'));
99
+ } catch {
100
+ return null;
101
+ }
102
+ };
103
+
104
+ const lignesDeGit = (racine, args) => {
105
+ const r = spawnSync('git', ['-C', racine, ...args, '-z'], {
106
+ encoding: 'utf8',
107
+ maxBuffer: 256 * 1024 * 1024,
108
+ });
109
+ if (r.status !== 0) throw new Error(`⛔ git ${args.join(' ')} : ${r.stderr.trim()}`);
110
+ return r.stdout.split('\0').filter(Boolean);
111
+ };
112
+
113
+ // The components touched in <racine> since the commit <depuis>, their dependents, and the files
114
+ // out of every component.
115
+ function touches(racine, { depuis }) {
116
+ const liste = composants(racine);
117
+ const fichiers = new Set([
118
+ ...lignesDeGit(racine, ['diff', '--name-only', '--no-renames', depuis]),
119
+ ...lignesDeGit(racine, ['ls-files', '-o', '--exclude-standard']),
120
+ ]);
121
+ const touches = new Set();
122
+ const horsGraphe = [];
123
+ for (const f of fichiers) {
124
+ const c = composantDans(liste, racine, f);
125
+ if (c) touches.add(c);
126
+ else horsGraphe.push(f);
127
+ }
128
+ // The components that read each one, by the packages their package.json names.
129
+ const parPaquet = new Map(liste.filter(c => c.paquet).map(c => [c.paquet, c]));
130
+ const lecteursDe = new Map(liste.map(c => [c, new Set()]));
131
+ for (const c of liste) {
132
+ const pkg = lireJson(path.join(c.dossier, 'package.json')) ?? {};
133
+ for (const nom of new Set(CHAMPS.flatMap(ch => Object.keys(pkg[ch] ?? {})))) {
134
+ const lu = parPaquet.get(nom);
135
+ if (lu && lu !== c) lecteursDe.get(lu).add(c);
136
+ }
137
+ }
138
+ const dependants = new Set();
139
+ const suivre = c => {
140
+ for (const l of lecteursDe.get(c)) {
141
+ if (touches.has(l) || dependants.has(l)) continue;
142
+ dependants.add(l);
143
+ suivre(l);
144
+ }
145
+ };
146
+ for (const c of touches) suivre(c);
147
+ const parNom = (a, b) => a.nom.localeCompare(b.nom);
148
+ return {
149
+ touches: [...touches].sort(parNom),
150
+ dependants: [...dependants].sort(parNom),
151
+ horsGraphe: horsGraphe.sort(),
152
+ };
153
+ }
154
+
155
+ // TypeScript's compiler, the project's at <racine>, else the frame's.
156
+ function compilateur(racine) {
157
+ for (const depuis of [path.join(racine, 'package.json'), import.meta.url]) {
158
+ try {
159
+ return createRequire(depuis).resolve('typescript/bin/tsc');
160
+ } catch {
161
+ // The next one.
162
+ }
163
+ }
164
+ return null;
165
+ }
166
+
167
+ // The findings the guard <script> <args> writes on the repository <racine>, the notes of the debt
168
+ // left out; a red guard that wrote none gives one, without location.
169
+ function constatsDe(racine, script, args) {
170
+ const dossier = mkdtempSync(path.join(tmpdir(), 'grillhouse-engendre-'));
171
+ try {
172
+ const r = spawnSync(process.execPath, [script, ...args], {
173
+ cwd: racine,
174
+ env: { ...process.env, [RESULTATS]: dossier },
175
+ encoding: 'utf8',
176
+ });
177
+ const constats = lireSarif(dossier).constats.filter(k => k.genre !== A_ELAGUER);
178
+ if (r.status !== 0 && constats.length === 0) {
179
+ return [{ message: `${path.basename(script)} rouge (code ${r.status ?? r.signal}).` }];
180
+ }
181
+ return r.status === 0 ? [] : constats;
182
+ } finally {
183
+ rmSync(dossier, { recursive: true, force: true });
184
+ }
185
+ }
186
+
187
+ const engendre = (o, script, args) => ({
188
+ ...o,
189
+ verifier: racine => constatsDe(racine, ici(script), args),
190
+ });
191
+
192
+ // Whether the component plays tests: its package.json holds the script `test:unit`.
193
+ const joueDesTests = (_racine, composant) =>
194
+ typeof lireJson(path.join(composant.dossier, 'package.json'))?.scripts?.[SCRIPT_DES_TESTS] ===
195
+ 'string';
196
+
197
+ // Whether the repository at <racine> holds TypeScript: a tsconfig.json at its root or in one of its
198
+ // packages of the frame, as @nx/js infers a project from its tsconfig.
199
+ const trouve = racine =>
200
+ existsSync(path.join(racine, 'tsconfig.json')) ||
201
+ paquets(racine).some(
202
+ ({ dossier, hors }) => !hors && existsSync(path.join(racine, dossier, 'tsconfig.json'))
203
+ );
204
+
205
+ export default {
206
+ nom: 'typescript',
207
+ trouve,
208
+ signe: 'un tsconfig.json à la racine ou dans un paquet',
209
+ // The tools a project of TypeScript installs, optional peers of the package: what this module
210
+ // runs as commands (Turborepo, knip, dependency-cruiser) and what its scripts import (API
211
+ // Extractor, its model, TSDoc's configuration, jsonc-parser); the project's own TypeScript and
212
+ // Vitest left out, which it writes its code and its tests with.
213
+ outils: [
214
+ '@microsoft/api-extractor',
215
+ '@microsoft/api-extractor-model',
216
+ '@microsoft/tsdoc-config',
217
+ 'dependency-cruiser',
218
+ 'jsonc-parser',
219
+ 'knip',
220
+ 'turbo',
221
+ ],
222
+ // No binary of the machine: its tools are packages of npm.
223
+ binaires: {},
224
+ // What its tools write in a project: Turborepo's runs and cache.
225
+ ignorer: ['.turbo'],
226
+ // Where its tools write: the cache of Turborepo in the main tree, shared by every copy, written;
227
+ // the logs of Turborepo's tasks (`.turbo/turbo-<task>.log`, written on every run, a task replayed
228
+ // from its cache included, and which no option of Turborepo sends elsewhere) and the cache of
229
+ // Vite, where Vitest writes the results of a run (`node_modules/.vite/vitest/`) and whose failure
230
+ // fails it, proper to the session.
231
+ sorties: {
232
+ ecrites: ['//.turbo/cache/'],
233
+ propres: ['.turbo', 'node_modules/.vite'],
234
+ lues: [],
235
+ },
236
+ // The test tool run directly, Vitest or Turborepo that plays it: `npm test` and `npm run
237
+ // verifier` play it with what it depends on. `turbo *` ends on a word, so `npx grillhouse
238
+ // turbo-des-paquets` stays open.
239
+ droits: [
240
+ 'Bash(vitest*)',
241
+ 'Bash(npx vitest*)',
242
+ 'Bash(npx * vitest*)',
243
+ 'Bash(npm exec vitest*)',
244
+ 'Bash(npm exec * vitest*)',
245
+ 'Bash(node_modules/.bin/vitest*)',
246
+ 'Bash(turbo *)',
247
+ 'Bash(npx turbo *)',
248
+ 'Bash(npx * turbo *)',
249
+ 'Bash(npm exec turbo *)',
250
+ 'Bash(npm exec * turbo *)',
251
+ 'Bash(node_modules/.bin/turbo *)',
252
+ ],
253
+ composants,
254
+ composantDe: (racine, fichier) => composantDans(composants(racine), racine, fichier),
255
+ matieres: racine =>
256
+ matieres(racine).map(({ nom, dir, paquet }) => ({ nom, dossier: dir, paquet })),
257
+ joueDesTests,
258
+ lecteurs,
259
+ touches,
260
+ elementsDuLot,
261
+ commandes: racine => ({
262
+ tester: { script: ici('tests.mjs'), args: [] },
263
+ verifier: { script: ici('verifier.mjs'), args: [] },
264
+ typer: { script: compilateur(racine), args: ['--noEmit'] },
265
+ construire: { script: ici('construire.mjs'), args: [] },
266
+ 'tests-de-nuit': { script: ici('tests-de-nuit.mjs'), args: [] },
267
+ ...Object.fromEntries(OUTILS.map(n => [n, { script: ici(`${n}.mjs`), args: [] }])),
268
+ }),
269
+ verdict,
270
+ estUnTest,
271
+ fichiersEngendres: () => [
272
+ engendre(
273
+ {
274
+ nom: "l'index des interfaces",
275
+ commande: generateur('index-interfaces.mjs'),
276
+ fichiers: ['docs/agents/index-des-interfaces.md'],
277
+ lit: ['docs/INTERFACE.md', '**/docs/INTERFACE.md'],
278
+ gardes: ['index-interfaces'],
279
+ entiers: ['docs/agents/index-des-interfaces.md'],
280
+ },
281
+ 'index-interfaces.mjs',
282
+ ['--verifier']
283
+ ),
284
+ engendre(
285
+ {
286
+ nom: 'les turbo.json des paquets',
287
+ commande: generateur('turbo-des-paquets.mjs', '--ecrire'),
288
+ fichiers: ['turbo.json', 'turbo.jsonc', '**/turbo.json'],
289
+ lit: [],
290
+ gardes: ['turbo-des-paquets'],
291
+ entiers: ['*/**/turbo.json'],
292
+ },
293
+ 'turbo-des-paquets.mjs',
294
+ []
295
+ ),
296
+ engendre(
297
+ {
298
+ nom: "les rapports d'API",
299
+ commande: generateur('interfaces-contre-code.mjs', '--ecrire'),
300
+ fichiers: [
301
+ 'docs/INTERFACE.api.md',
302
+ 'docs/INTERFACE.md',
303
+ '**/docs/INTERFACE.api.md',
304
+ '**/docs/INTERFACE.md',
305
+ ],
306
+ lit: [],
307
+ gardes: ['rapport-api', 'partie-generee'],
308
+ entiers: [],
309
+ },
310
+ 'interfaces-contre-code.mjs',
311
+ []
312
+ ),
313
+ ],
314
+ gardes: () => [
315
+ [ici('turbo-des-paquets.mjs')],
316
+ [ici('index-interfaces.mjs'), '--verifier'],
317
+ [ici('consommateurs.mjs')],
318
+ [ici('consommateurs-arbitres.mjs')],
319
+ [ici('frontieres.mjs')],
320
+ [ici('interfaces-contre-code.mjs')],
321
+ [ici('code-mort.mjs')],
322
+ [ici('tailles-des-tests.mjs')],
323
+ [ici('chemins-des-tests.mjs')],
324
+ [ici('resumes.mjs')],
325
+ ],
326
+ migrations: [
327
+ configVitest,
328
+ nomsDeclaresInutilises,
329
+ lignesMalFormees,
330
+ matiereDansLesTests,
331
+ taillesDesTests,
332
+ cheminsDesTests,
333
+ ],
334
+ miseAJour: miseAJour(joueDesTests),
335
+ };