@roomi-fields/grillhouse 0.52.0 → 0.53.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 (130) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +48 -0
  3. package/agents/direct.md +1 -1
  4. package/cadre/templates/projet/vitest.config.cjs +45 -0
  5. package/charte/superviseur.md +36 -37
  6. package/charte.md +1 -1
  7. package/dist/temporal/circuit/appel.d.ts +2 -0
  8. package/dist/temporal/circuit/appel.js +24 -2
  9. package/dist/temporal/circuit/appel.js.map +1 -1
  10. package/dist/temporal/circuit/client.d.ts +14 -5
  11. package/dist/temporal/circuit/client.js +41 -9
  12. package/dist/temporal/circuit/client.js.map +1 -1
  13. package/dist/temporal/circuit/commande.js +17 -6
  14. package/dist/temporal/circuit/commande.js.map +1 -1
  15. package/dist/temporal/circuit/contrat.d.ts +9 -0
  16. package/dist/temporal/circuit/contrat.js +6 -0
  17. package/dist/temporal/circuit/contrat.js.map +1 -1
  18. package/dist/temporal/circuit/deroule.js +25 -4
  19. package/dist/temporal/circuit/deroule.js.map +1 -1
  20. package/dist/temporal/client.d.ts +35 -1
  21. package/dist/temporal/client.js +144 -1
  22. package/dist/temporal/client.js.map +1 -1
  23. package/dist/temporal/commande.js +31 -13
  24. package/dist/temporal/commande.js.map +1 -1
  25. package/dist/temporal/etat.d.ts +3 -1
  26. package/dist/temporal/etat.js +31 -17
  27. package/dist/temporal/etat.js.map +1 -1
  28. package/dist/temporal/file/activites.js +1 -1
  29. package/dist/temporal/file/activites.js.map +1 -1
  30. package/dist/temporal/file/contrat.d.ts +4 -5
  31. package/dist/temporal/file/contrat.js +2 -2
  32. package/dist/temporal/file/contrat.js.map +1 -1
  33. package/dist/temporal/file/deroule.js +7 -5
  34. package/dist/temporal/file/deroule.js.map +1 -1
  35. package/dist/temporal/installation.d.ts +103 -53
  36. package/dist/temporal/installation.js +842 -237
  37. package/dist/temporal/installation.js.map +1 -1
  38. package/dist/temporal/nuits/deroule.js +3 -1
  39. package/dist/temporal/nuits/deroule.js.map +1 -1
  40. package/dist/temporal/places/deroule.js +2 -1
  41. package/dist/temporal/places/deroule.js.map +1 -1
  42. package/dist/temporal/sonde/deroule.js +2 -1
  43. package/dist/temporal/sonde/deroule.js.map +1 -1
  44. package/dist/temporal/tickets/deroule.js +4 -3
  45. package/dist/temporal/tickets/deroule.js.map +1 -1
  46. package/dist/temporal/travailleur.d.ts +7 -1
  47. package/dist/temporal/travailleur.js +49 -25
  48. package/dist/temporal/travailleur.js.map +1 -1
  49. package/docs/INTERFACE.md +17 -12
  50. package/docs/architecture/circuit.md +18 -15
  51. package/docs/architecture/entree.md +7 -8
  52. package/docs/architecture/greffon.md +30 -21
  53. package/docs/architecture/installation.md +87 -58
  54. package/docs/architecture/machine.md +1 -1
  55. package/docs/architecture/tests.md +14 -5
  56. package/docs/lexique.md +2 -2
  57. package/hooks/hooks.json +10 -0
  58. package/hooks/register.tsx +19 -25
  59. package/package.json +3 -2
  60. package/scripts/activites.mjs +5 -4
  61. package/scripts/aiguillage.mjs +1 -0
  62. package/scripts/circuit.mjs +254 -42
  63. package/scripts/circuits-du-serveur.mjs +3 -2
  64. package/scripts/circuits-tenus.d.mts +7 -0
  65. package/scripts/circuits-tenus.mjs +17 -0
  66. package/scripts/copie-de-montee.mjs +354 -0
  67. package/scripts/copies-du-depot.d.mts +13 -0
  68. package/scripts/copies-du-depot.mjs +66 -0
  69. package/scripts/copies-finies.mjs +6 -40
  70. package/scripts/crochets.mjs +16 -2
  71. package/scripts/direct.mjs +2 -2
  72. package/scripts/droits.mjs +2 -2
  73. package/scripts/engendres.mjs +5 -3
  74. package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
  75. package/scripts/etapes.mjs +11 -3
  76. package/scripts/faits-du-circuit.mjs +12 -5
  77. package/scripts/file-des-tickets.d.mts +13 -2
  78. package/scripts/file-des-tickets.mjs +44 -12
  79. package/scripts/greffons.mjs +42 -27
  80. package/scripts/grillhouse-maj.mjs +105 -85
  81. package/scripts/init.mjs +1 -1
  82. package/scripts/integration/file.mjs +5 -2
  83. package/scripts/integration/integrer.mjs +14 -4
  84. package/scripts/jointure.d.ts +16 -0
  85. package/scripts/langages/c/commandes.mjs +17 -7
  86. package/scripts/langages/cargo/commandes.mjs +87 -34
  87. package/scripts/langages/cargo/index.mjs +6 -3
  88. package/scripts/langages/cargo/sccache.mjs +15 -12
  89. package/scripts/langages/python/commandes.mjs +18 -8
  90. package/scripts/langages/python/squelette.mjs +2 -2
  91. package/scripts/langages/typescript/configurations-de-vitest.mjs +118 -0
  92. package/scripts/langages/typescript/index.mjs +2 -0
  93. package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +299 -0
  94. package/scripts/langages/typescript/squelette.mjs +20 -17
  95. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -3
  96. package/scripts/langages/typescript/turbo-des-paquets.mjs +24 -37
  97. package/scripts/langages/typescript/vitest-config/base.mjs +1 -1
  98. package/scripts/langages/typescript/vitest-config/bornes.mjs +1 -1
  99. package/scripts/langages/typescript/vitest-config/cibles.mjs +2 -2
  100. package/scripts/langages/typescript/{vitest.nuit.config.mjs → vitest.nuit.config.cjs} +61 -50
  101. package/scripts/mesure/pression.mjs +5 -3
  102. package/scripts/montee.mjs +524 -0
  103. package/scripts/outil.mjs +5 -3
  104. package/scripts/paquet-npm.mjs +22 -0
  105. package/scripts/paquet.mjs +5 -5
  106. package/scripts/pre-compact.mjs +25 -0
  107. package/scripts/reponses-du-circuit.d.mts +17 -2
  108. package/scripts/reponses-du-circuit.mjs +78 -20
  109. package/scripts/resultats.mjs +40 -12
  110. package/scripts/retirer-les-copies-finies.mjs +4 -7
  111. package/scripts/seances.mjs +28 -3
  112. package/scripts/services-du-noyau.mjs +7 -2
  113. package/scripts/session-start.sh +18 -11
  114. package/scripts/sortie.mjs +4 -7
  115. package/scripts/sous-commandes.mjs +1 -0
  116. package/scripts/superviseur.mjs +110 -70
  117. package/scripts/tableau.mjs +127 -108
  118. package/scripts/ticket-du-circuit.mjs +22 -0
  119. package/scripts/transitions.d.mts +6 -9
  120. package/scripts/transitions.mjs +123 -36
  121. package/scripts/verrou-de-fichier.d.mts +11 -0
  122. package/skills/direct/SKILL.md +21 -11
  123. package/skills/explorateur/SKILL.md +6 -1
  124. package/skills/grill/SKILL.md +9 -7
  125. package/skills/grill/references/paquets.md +4 -4
  126. package/skills/pitmaster/SKILL.md +45 -33
  127. package/skills/pitmaster/references/consigne-agent.md +1 -1
  128. package/skills/relecteur/SKILL.md +8 -1
  129. package/skills/testwriter/SKILL.md +1 -1
  130. package/cadre/templates/projet/vitest.config.ts +0 -44
@@ -0,0 +1,299 @@
1
+ // The migration of the configurations of Vitest of a project to CommonJS, which the guard
2
+ // `turbo-des-paquets` asks (../configurations-de-vitest.mjs): Vite 5 writes a file beside an ESM
3
+ // configuration to load it, and fails in a package the envelope shows read-only. Migrations:
4
+ // packages/grillhouse/docs/architecture/installation.md §5.4.
5
+ //
6
+ // - Converted: a refused `vitest.config.*` made of static imports, plain statements and one
7
+ // `export default`, that no file reads by its name, becomes the `vitest.config.cjs` of its
8
+ // directory, its imports by `await import()` and its default export the value of the promise it
9
+ // exports; the former file is removed. Its types are stripped by Node.
10
+ // - Left intact, each named with its reason and the way out, then inscribed in the guard's debt,
11
+ // frozen: a configuration another file reads by its name (an import or a require, a path in the
12
+ // code, a script of a package.json or a shell script, a flow, `files` or a literal `include`
13
+ // of a tsconfig, a workspace of Vitest; a comment, a document or a pattern reads nothing), a
14
+ // configuration that reads such a one, one that uses `import.meta`, another export or a syntax
15
+ // Node cannot strip, a directory with a `vitest.config.cjs` already or several refused
16
+ // configurations, and every refused file not named `vitest.config.*` (an ESM `vite.config`, a
17
+ // configuration `--config` names). The migration writes no reader.
18
+ // - Replayable without effect: a configuration the debt holds is left, and nothing is returned.
19
+ import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
20
+ import { createRequire, stripTypeScriptTypes } from 'node:module';
21
+ import path from 'node:path';
22
+ import { FICHIER, lire, trancher } from '../../../dette.mjs';
23
+ import { paquets } from '../../../paquets.mjs';
24
+ import { sources } from '../../../services-du-noyau.mjs';
25
+ import { configurationsRefusees, GARDE } from '../configurations-de-vitest.mjs';
26
+ import { parcourir } from '../parcours.mjs';
27
+
28
+ export const version = '0.53.0';
29
+ export const nom = 'configurations en commonjs';
30
+
31
+ const CONFIGURATION = /^vitest\.config\.(?:[mc]?ts|m?js)$/;
32
+ // The directories no reader of a configuration lives in.
33
+ const HORS = new Set(['node_modules', '.git', 'dist', 'coverage', '.claude', '.turbo']);
34
+ const MOTIF = /[*?{}[\]]/;
35
+ // The files that name paths without being code (cheminsNommes).
36
+ const ENUMERE =
37
+ /(?:^|\/)(?:package\.json|tsconfig[^/]*\.json|vitest\.workspace\.json)$|^(?:\.github\/.*\.ya?ml|\.gitlab-ci\.yml)$|\.sh$/;
38
+ // The characters that separate the words of a command line, a flow or a JSON of paths.
39
+ const SEPARATEURS = /[\s"'`=,;()[\]|&<>]+/;
40
+
41
+ const posix = f => f.split(path.sep).join('/');
42
+ const sansExtension = f => f.replace(/\.[^./]+$/, '');
43
+ // TypeScript, a tool of every project of the module.
44
+ const typescript = () => createRequire(import.meta.url)('typescript');
45
+
46
+ // The string literals of the code `texte` of the file `f`, comments left out.
47
+ function chaines(ts, f, texte) {
48
+ const out = [];
49
+ const visiter = n => {
50
+ if (ts.isStringLiteralLike(n)) {
51
+ out.push(n.text);
52
+ }
53
+ ts.forEachChild(n, visiter);
54
+ };
55
+ visiter(ts.createSourceFile(f, texte, ts.ScriptTarget.Latest, true));
56
+ return out;
57
+ }
58
+
59
+ // The paths, from the root, that the file `f` names: each `{ chemin, module }`, `module` when an
60
+ // import can name it without its extension.
61
+ function cheminsNommes(ts, projet, f, espaces) {
62
+ const nomDuFichier = path.posix.basename(f);
63
+ const ici = path.posix.dirname(f);
64
+ const joindre = (base, m) => posix(path.relative(projet, path.resolve(projet, base, m)));
65
+ const mots = (texte, bases) =>
66
+ texte
67
+ .split(SEPARATEURS)
68
+ .filter(m => m && !MOTIF.test(m))
69
+ .flatMap(m => bases.map(b => ({ chemin: joindre(b, m) })));
70
+ const lu = () => readFileSync(path.join(projet, f), 'utf8');
71
+ if (nomDuFichier === 'package.json') {
72
+ // A manifest that is not JSON (a fixture) names no script.
73
+ let scripts;
74
+ try {
75
+ scripts = Object.values(JSON.parse(lu()).scripts ?? {});
76
+ } catch {
77
+ return [];
78
+ }
79
+ return scripts.flatMap(s => {
80
+ const racines = [...String(s).matchAll(/(?:--root|--prefix|--dir|-C)[ =]+([^\s"']+)/g)];
81
+ return mots(String(s), [ici, ...racines.map(r => path.posix.join(ici, r[1]))]);
82
+ });
83
+ }
84
+ if (/^tsconfig.*\.json$/.test(nomDuFichier)) {
85
+ const { config } = ts.parseConfigFileTextToJson(f, lu());
86
+ return [...(config?.files ?? []), ...(config?.include ?? [])]
87
+ .filter(m => typeof m === 'string' && !MOTIF.test(m))
88
+ .map(m => ({ chemin: joindre(ici, m) }));
89
+ }
90
+ if (/^vitest\.workspace\.json$/.test(nomDuFichier)) {
91
+ return mots(lu(), [ici]);
92
+ }
93
+ if (/^(\.github\/.*\.ya?ml|\.gitlab-ci\.yml)$/.test(f) || f.endsWith('.sh')) {
94
+ const texte = lu().replace(/(^|\s)#.*$/gm, '$1');
95
+ const dossiers = [...texte.matchAll(/working-directory:\s*["']?([^\s"']+)/g)].map(m => m[1]);
96
+ return mots(texte, ['.', ici, ...dossiers]);
97
+ }
98
+ return chaines(ts, f, lu()).flatMap(m => {
99
+ if (!m || MOTIF.test(m) || /\s/.test(m)) {
100
+ return [];
101
+ }
102
+ const paquet = espaces.find(e => m.startsWith(`${e.nom}/`));
103
+ if (paquet) {
104
+ return [{ chemin: joindre(paquet.dossier, m.slice(paquet.nom.length + 1)), module: true }];
105
+ }
106
+ const relatif = m.startsWith('.');
107
+ const bases = relatif || !m.includes('/') ? [ici] : [ici, '.'];
108
+ return bases.map(b => ({ chemin: joindre(b, m), module: relatif }));
109
+ });
110
+ }
111
+
112
+ // The files of the project that read each of `cibles` by its name: Map cible → files.
113
+ function lecteursDe(ts, projet, cibles) {
114
+ const espaces = paquets(projet)
115
+ .filter(p => typeof p.pkg.name === 'string')
116
+ .map(p => ({ nom: p.pkg.name, dossier: p.dossier }));
117
+ const out = new Map(cibles.map(c => [c, []]));
118
+ const autres = parcourir(projet, p => HORS.has(path.basename(p)))
119
+ .map(p => posix(path.relative(projet, p)))
120
+ .filter(f => ENUMERE.test(f));
121
+ for (const f of [...new Set([...sources(projet), ...autres])].sort()) {
122
+ const nommes = cheminsNommes(ts, projet, f, espaces);
123
+ for (const c of cibles) {
124
+ const lit = nommes.some(
125
+ ({ chemin, module }) =>
126
+ chemin === c ||
127
+ (module &&
128
+ (chemin === sansExtension(c) ||
129
+ (/\.[mc]?js$/.test(chemin) && sansExtension(chemin) === sansExtension(c))))
130
+ );
131
+ if (c !== f && lit) {
132
+ out.get(c).push(f);
133
+ }
134
+ }
135
+ }
136
+ return out;
137
+ }
138
+
139
+ // The declaration of the names an import binds, by `await import()`.
140
+ function importation(ts, n) {
141
+ const attributs = n.attributes
142
+ ? `, { with: { ${n.attributes.elements.map(e => e.getText()).join(', ')} } }`
143
+ : '';
144
+ const appel = `await import(${n.moduleSpecifier.getText()}${attributs})`;
145
+ const { name: defaut, namedBindings: liaisons } = n.importClause ?? {};
146
+ if (liaisons && ts.isNamespaceImport(liaisons)) {
147
+ const espace = `const ${liaisons.name.text} = ${appel};`;
148
+ return defaut ? `${espace}\nconst { default: ${defaut.text} } = ${liaisons.name.text};` : espace;
149
+ }
150
+ const noms = [
151
+ ...(defaut ? [`default: ${defaut.text}`] : []),
152
+ ...(liaisons?.elements ?? []).map(e =>
153
+ e.propertyName ? `${e.propertyName.getText()}: ${e.name.text}` : e.name.text
154
+ ),
155
+ ];
156
+ return noms.length ? `const { ${noms.join(', ')} } = ${appel};` : `${appel};`;
157
+ }
158
+
159
+ // The CommonJS form of the ESM configuration `source` of the file `f`, or null when it holds
160
+ // more than static imports, plain statements and one default export.
161
+ function enCommonJs(ts, f, source) {
162
+ let texte = source;
163
+ if (/ts$/.test(f)) {
164
+ try {
165
+ texte = stripTypeScriptTypes(source);
166
+ } catch {
167
+ return null;
168
+ }
169
+ }
170
+ const arbre = ts.createSourceFile('c.mjs', texte, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
171
+ let intraduisible = arbre.parseDiagnostics.length > 0;
172
+ // The ranges of the template literals, whose lines keep their indentation.
173
+ const gabarits = [];
174
+ const visiter = n => {
175
+ if (ts.isMetaProperty(n) && n.keywordToken === ts.SyntaxKind.ImportKeyword) {
176
+ intraduisible = true;
177
+ }
178
+ if (ts.isTemplateExpression(n) || ts.isStringLiteralLike(n)) {
179
+ gabarits.push([n.getStart(), n.end]);
180
+ }
181
+ ts.forEachChild(n, visiter);
182
+ };
183
+ visiter(arbre);
184
+ const imports = [];
185
+ const retouches = [];
186
+ let defauts = 0;
187
+ let valeur = 'configurationParDefaut';
188
+ for (const n of arbre.statements) {
189
+ const modificateurs = ts.canHaveModifiers(n) ? (ts.getModifiers(n) ?? []) : [];
190
+ const exporte = modificateurs.find(m => m.kind === ts.SyntaxKind.ExportKeyword);
191
+ const defaut = modificateurs.find(m => m.kind === ts.SyntaxKind.DefaultKeyword);
192
+ if (ts.isImportDeclaration(n)) {
193
+ imports.push(importation(ts, n));
194
+ retouches.push([n.getStart(), n.end, '']);
195
+ } else if (ts.isExportAssignment(n) && !n.isExportEquals) {
196
+ defauts += 1;
197
+ retouches.push([n.getStart(), n.expression.getFullStart(), `const ${valeur} =`]);
198
+ } else if (exporte && defaut) {
199
+ defauts += 1;
200
+ if (n.name) {
201
+ valeur = n.name.text;
202
+ retouches.push([exporte.getStart(), defaut.end + 1, '']);
203
+ } else {
204
+ retouches.push([exporte.getStart(), defaut.end, `const ${valeur} =`]);
205
+ }
206
+ } else if (exporte || ts.isExportDeclaration(n) || ts.isExportAssignment(n)) {
207
+ intraduisible = true;
208
+ }
209
+ }
210
+ if (intraduisible || defauts !== 1) {
211
+ return null;
212
+ }
213
+ // The comments at the head of the file stay at its head.
214
+ const debut = arbre.statements[0].getStart();
215
+ let corps = '';
216
+ let depuis = debut;
217
+ const indenter = (de, a) =>
218
+ texte.slice(de, a).replace(/\n(?=[^\n])/g, (saut, i) => {
219
+ const ou = de + i + 1;
220
+ return gabarits.some(([x, y]) => ou > x && ou < y) ? saut : '\n ';
221
+ });
222
+ for (const [de, a, neuf] of retouches) {
223
+ corps += indenter(depuis, de) + neuf;
224
+ depuis = neuf === '' && texte[a] === '\n' ? a + 1 : a;
225
+ }
226
+ corps += indenter(depuis, texte.length);
227
+ const lignes = [
228
+ ...imports.flatMap(i => i.split('\n')).map(l => ` ${l}`),
229
+ '',
230
+ ` ${corps.trim()}`,
231
+ ` return ${valeur};`,
232
+ ];
233
+ return `${texte.slice(0, debut)}module.exports = (async () => {\n${lignes.join('\n')}\n})();\n`;
234
+ }
235
+
236
+ /** Converts the configurations of Vitest of `projet` to CommonJS, the rest inscribed in the debt. */
237
+ export function migrer(projet) {
238
+ const inscrites = lire(projet)[GARDE] ?? {};
239
+ const neuves = () => configurationsRefusees(projet).filter(c => !inscrites[c.fichier]?.[c.regle]);
240
+ const refusees = neuves();
241
+ if (refusees.length === 0) {
242
+ return [];
243
+ }
244
+ const ts = typescript();
245
+ const toutes = configurationsRefusees(projet).map(c => c.fichier);
246
+ const lecteurs = lecteursDe(ts, projet, toutes);
247
+ const quiLisent = new Set([...lecteurs.values()].flat());
248
+ const lignes = [];
249
+ const raisons = new Map();
250
+ const aConvertir = [];
251
+ for (const { fichier } of refusees) {
252
+ const dossier = path.posix.dirname(fichier);
253
+ const cjs = path.posix.join(dossier, 'vitest.config.cjs');
254
+ const lue = lecteurs.get(fichier);
255
+ if (lue.length) {
256
+ raisons.set(fichier, `lue par son nom par ${lue.join(', ')}`);
257
+ } else if (!CONFIGURATION.test(path.posix.basename(fichier))) {
258
+ raisons.set(fichier, 'la migration ne convertit que `vitest.config.*`');
259
+ } else if (quiLisent.has(fichier)) {
260
+ raisons.set(fichier, "elle lit une autre configuration refusée, et la migration n'écrit aucun lecteur");
261
+ } else if (existsSync(path.join(projet, cjs))) {
262
+ raisons.set(fichier, `\`${cjs}\` est déjà là`);
263
+ } else if (
264
+ toutes.filter(
265
+ f => path.posix.dirname(f) === dossier && CONFIGURATION.test(path.posix.basename(f))
266
+ ).length > 1
267
+ ) {
268
+ raisons.set(fichier, 'plusieurs configurations de Vitest dans son dossier');
269
+ } else {
270
+ const neuf = enCommonJs(ts, fichier, readFileSync(path.join(projet, fichier), 'utf8'));
271
+ if (neuf === null) {
272
+ raisons.set(
273
+ fichier,
274
+ 'sa forme dépasse les imports statiques et un `export default` (`import.meta`, un autre export, une syntaxe que Node ne retire pas)'
275
+ );
276
+ } else {
277
+ aConvertir.push({ fichier, cjs, neuf });
278
+ }
279
+ }
280
+ }
281
+ for (const { fichier, cjs, neuf } of aConvertir) {
282
+ writeFileSync(path.join(projet, cjs), neuf);
283
+ rmSync(path.join(projet, fichier));
284
+ lignes.push(
285
+ `${fichier} : remplacée par ${cjs}, que Vite charge sans rien écrire à côté ; relis sa mise en forme`
286
+ );
287
+ }
288
+ const restantes = configurationsRefusees(projet);
289
+ if (restantes.some(c => raisons.has(c.fichier))) {
290
+ trancher(projet, GARDE, restantes, 'inscrire', {});
291
+ for (const [fichier, raison] of raisons) {
292
+ const cjs = path.posix.join(path.posix.dirname(fichier), 'vitest.config.cjs');
293
+ lignes.push(
294
+ `${fichier} : laissée, ${raison} ; elle peut échouer en EROFS quand son paquet est hors du plan. Pour la convertir : écris ${cjs} (\`module.exports = (async () => { … })();\`, chaque import par \`await import()\`), et fais-le nommer par ses lecteurs. Inscrite dans ${FICHIER} (${GARDE}), gelée : une neuve est refusée`
295
+ );
296
+ }
297
+ }
298
+ return lignes;
299
+ }
@@ -9,8 +9,8 @@
9
9
  // name has one, as Nx names a library after the workspace's scope; private; an ES module; its
10
10
  // script `test:unit`, which makes it a package that plays tests, and the tools of its tests and
11
11
  // of its typing the root does not declare, TypeScript, Vitest and Node's types, at the versions of
12
- // the module's template); its tsconfig.json, which types its sources, its tests and its
13
- // configuration, nothing emitted; its vitest.config.ts, the frame's base configuration by its
12
+ // the module's template); its tsconfig.json, which types its sources and its tests, nothing
13
+ // emitted; its vitest.config.cjs, the frame's base configuration by its
14
14
  // name, which passes while the package has no test yet, as the configuration of a library that
15
15
  // Nx generates (`passWithNoTests`); `src/index.ts`, an empty module; `tests/.gitkeep`, its folder
16
16
  // of tests. The update gives it its script `typecheck` and the frame's package in its
@@ -19,7 +19,7 @@
19
19
  // when the root has none), unless a pattern there covers it already.
20
20
  // - The lock of the versions: `npm install`, at the root.
21
21
  // - A folder that already holds code is taken as it is when its code lies under `src/` and
22
- // `tests/`, which its tsconfig.json and its vitest.config.ts cover, each file present kept; a
22
+ // `tests/`, which its tsconfig.json and its vitest.config.cjs cover, each file present kept; a
23
23
  // file of code out of them (`.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs`, `.cjs`), which
24
24
  // neither its typing nor its tests would reach, is refused by its name, nothing written, the
25
25
  // layout named, in place of a skeleton beside it.
@@ -59,21 +59,24 @@ const TSCONFIG = {
59
59
  exclude: ['node_modules', 'dist'],
60
60
  };
61
61
 
62
- const VITEST = `import { defineConfig, mergeConfig } from 'vitest/config';
63
- import base from '@roomi-fields/grillhouse/vitest-config';
64
-
65
- // The tests of the package: the frame's base configuration, by its name, extended with what is the
62
+ const VITEST = `// The tests of the package: the frame's base configuration, by its name, extended with what is the
66
63
  // package's own. It passes while the package has no test yet, as the configuration of a library
67
64
  // that Nx generates; its first test plays as any other.
68
- export default mergeConfig(
69
- base,
70
- defineConfig({
71
- test: {
72
- include: ['src/**/*.{test,spec}.{ts,js,mjs}', 'tests/**/*.{test,spec}.{ts,js,mjs}'],
73
- passWithNoTests: true,
74
- },
75
- })
76
- );
65
+ // CommonJS: Vite writes a file beside an ESM configuration to load it, and the envelope shows a
66
+ // package out of a plan read-only.
67
+ module.exports = (async () => {
68
+ const { defineConfig, mergeConfig } = await import('vitest/config');
69
+ const { default: base } = await import('@roomi-fields/grillhouse/vitest-config');
70
+ return mergeConfig(
71
+ base,
72
+ defineConfig({
73
+ test: {
74
+ include: ['src/**/*.{test,spec}.{ts,js,mjs}', 'tests/**/*.{test,spec}.{ts,js,mjs}'],
75
+ passWithNoTests: true,
76
+ },
77
+ })
78
+ );
79
+ })();
77
80
  `;
78
81
 
79
82
  /** @type {import('../../jointure.js').Langage['squelette']} */
@@ -113,7 +116,7 @@ export function squelette(racine, { chemin, modele, existants }) {
113
116
  const fichiers = {
114
117
  [`${chemin}/package.json`]: json(pkg),
115
118
  [`${chemin}/tsconfig.json`]: json(TSCONFIG),
116
- [`${chemin}/vitest.config.ts`]: VITEST,
119
+ [`${chemin}/vitest.config.cjs`]: VITEST,
117
120
  [`${chemin}/src/index.ts`]: `// The entry of the package ${nom}: its interface, docs/INTERFACE.md, says what it exports.\nexport {};\n`,
118
121
  [`${chemin}/tests/.gitkeep`]: '',
119
122
  };
@@ -17,7 +17,7 @@
17
17
  // `*.budget.spec.*`) and the time witnesses (a test file that imports `mesurerAuRepos`,
18
18
  // `fichiersTemoins` of ./vitest-config/cibles.mjs): what `npm test` and the integration leave
19
19
  // out (./vitest-config/cibles.mjs). A copy with none plays nothing, and the exit code is 0.
20
- // - Vitest plays them with the frame's configuration (./vitest.nuit.config.mjs), from the root of
20
+ // - Vitest plays them with the frame's configuration (./vitest.nuit.config.cjs), from the root of
21
21
  // the copy: `npx --no-install vitest run --root <copie> --config <configuration>`, once for the
22
22
  // night tests (GRILLHOUSE_TESTS_DE_NUIT=nuit), then once for the measures alone, one file at a
23
23
  // time (GRILLHOUSE_TESTS_DE_NUIT=mesures), as Bazel plays a test tagged `exclusive` after the
@@ -26,7 +26,7 @@
26
26
  // - Each run plays one Vitest per unit: the root under the frame's configuration alone, and each
27
27
  // directory below it that holds a Vitest configuration (`vitest.config.*`, else `vite.config.*`)
28
28
  // with `--root` at that directory, under that configuration merged with the frame's, what the
29
- // night sets winning (./vitest.nuit.config.mjs, `unitesDeLaNuit`).
29
+ // night sets winning (./vitest.nuit.config.cjs, `unitesDeLaNuit`).
30
30
  // - With `--hors-du-poste`, the night of a shared machine: the night tests alone, but those that
31
31
  // bear the tag `@poste` (`porteLEtiquetteDuPoste` of ./vitest-config/cibles.mjs, which the guard
32
32
  // ./tests-du-poste.mjs asks of a night test that depends on the poste), in one run
@@ -116,7 +116,7 @@ export function lireLesArguments(args) {
116
116
  return { horsDuPoste, sansEquipement, duPoste, mesuresSeules, tranche };
117
117
  }
118
118
 
119
- const CONFIGURATION = fileURLToPath(new URL('./vitest.nuit.config.mjs', import.meta.url));
119
+ const CONFIGURATION = fileURLToPath(new URL('./vitest.nuit.config.cjs', import.meta.url));
120
120
  const HORS = new Set(['node_modules', 'dist', '.git']);
121
121
 
122
122
  // Whether a file that <est> (the rules of ./vitest-config/cibles.mjs) lies under <dossier>.
@@ -78,11 +78,9 @@
78
78
  // writes its exclusion, `!$TURBO_ROOT$/<path>/.git` (`!<path>/.git` for a global dependency), in
79
79
  // the root's turbo.json and in the inputs of a package's; the check refuses a root input lacking it.
80
80
  //
81
- // The configuration of Vitest of the package of the shared test material (`matieres` of
82
- // ./consommateurs.mjs) is CommonJS (`vitest.config.cjs`): the envelope shows that package
83
- // read-only to every role but the testwriter, and Vite 5 bundles an ESM configuration into a file
84
- // beside it (`vitest.config.mjs.timestamp-<n>.mjs`). The check refuses a `vitest.config.mjs` or
85
- // `.mts` of that package, and a `.js` or `.ts` when its `type` is `module`.
81
+ // The check refuses a configuration of Vitest that Vite would write beside to load, in the root
82
+ // and in each package: a configuration of Vitest is CommonJS (`vitest.config.cjs`,
83
+ // ./configurations-de-vitest.mjs), the known debt aside.
86
84
  //
87
85
  // The root's tasks, in its turbo.json or turbo.jsonc (the rest of the file is the project's,
88
86
  // its comments and layout kept by jsonc-parser; a repository without one has nothing written or
@@ -121,7 +119,7 @@ import {
121
119
  TRACE,
122
120
  VARIABLE_TRAVAILLEURS as TRAVAILLEURS,
123
121
  } from '../../services-du-noyau.mjs';
124
- import { matieres } from './consommateurs.mjs';
122
+ import { configurationsRefusees, GARDE, trancherLaGarde } from './configurations-de-vitest.mjs';
125
123
  import { lecturesDesTests } from './vitest-config/lances.mjs';
126
124
  import { parcourir } from './parcours.mjs';
127
125
  import {
@@ -132,7 +130,8 @@ import {
132
130
  recouvreLaLecture,
133
131
  TYPAGE,
134
132
  } from '../../paquets.mjs';
135
- import { ecrireSarif, RESULTATS } from '../../resultats.mjs';
133
+ import { juger, lire as lireLaDette } from '../../dette.mjs';
134
+ import { RESULTATS } from '../../resultats.mjs';
136
135
  import {
137
136
  SCRIPT_DES_TESTS as TESTS,
138
137
  SCRIPTS_DE_GARDES,
@@ -1243,26 +1242,6 @@ function declarationsRefusees(racine) {
1243
1242
  return refus;
1244
1243
  }
1245
1244
 
1246
- // The refusals of the configurations of Vitest that Vite loads as ESM in a package of the shared
1247
- // test material of <racine>: one line per such file, as Vite judges it (`.mjs`, `.mts`, or `.js`,
1248
- // `.ts` in a package of `"type": "module"`).
1249
- function configsMatiereRefusees(racine) {
1250
- const refus = [];
1251
- for (const { dir } of matieres(racine)) {
1252
- const { type } = JSON.parse(readFileSync(path.join(dir, 'package.json'), 'utf8'));
1253
- for (const ext of ['mjs', 'mts', ...(type === 'module' ? ['js', 'ts'] : [])]) {
1254
- const f = path.relative(racine, path.join(dir, `vitest.config.${ext}`));
1255
- if (!existsSync(path.join(racine, f))) {
1256
- continue;
1257
- }
1258
- refus.push(
1259
- `⛔ ${f} : la configuration de Vitest du paquet de la matière s'écrit en CommonJS, \`vitest.config.cjs\` ; Vite écrit un fichier à côté d'une configuration ESM pour la charger, et la matière est en lecture seule chez tout rôle autre que le testwriter.`
1260
- );
1261
- }
1262
- }
1263
- return refus;
1264
- }
1265
-
1266
1245
  // Whether the pattern <motif> (from the root) can name a file of one of the <dossiers>: its fixed
1267
1246
  // part, before the first glob character, lies in one, or holds one under a glob.
1268
1247
  function visePaquet(motif, dossiers) {
@@ -1316,13 +1295,22 @@ function racineRefusee(racine) {
1316
1295
  // or that does not wait for the build of its package and of its dependencies, for a root `test:unit` whose `env`
1317
1296
  // lacks TESTS_CIBLES, per variable of PASSAGES the root's `globalPassThroughEnv` lacks, per configuration
1318
1297
  // of a package written by hand in the root's turbo.json, and per declaration of data or trace
1319
- // refused.
1298
+ // refused, and per configuration of Vitest refused that the known debt does not hold.
1299
+ /**
1300
+ * @param {string} racine
1301
+ * @returns {string[]}
1302
+ */
1320
1303
  export function verifier(racine) {
1304
+ const configurations = juger(lireLaDette(racine), GARDE, configurationsRefusees(racine)).refus;
1305
+ return [...refusDuGraphe(racine), ...configurations.map(c => c.message)];
1306
+ }
1307
+
1308
+ // The refusals of <racine> but those of the configurations of Vitest, none of which a debt holds.
1309
+ function refusDuGraphe(racine) {
1321
1310
  const refus = [
1322
1311
  ...racineRefusee(racine),
1323
1312
  ...controlesDeRacineRefuses(racine),
1324
1313
  ...declarationsRefusees(racine),
1325
- ...configsMatiereRefusees(racine),
1326
1314
  ];
1327
1315
  const gits = gitsAbsents(racine);
1328
1316
  for (const { ou, e, m, ligne } of (gits?.listes ?? []).flatMap(l => l.manques)) {
@@ -1402,16 +1390,15 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
1402
1390
  if (args.includes('--ecrire')) {
1403
1391
  ecrire(racine);
1404
1392
  } else {
1405
- const refus = verifier(racine);
1406
- for (const l of refus) {
1393
+ // A refusal of the graph judges the root's configuration: a finding without a file of a
1394
+ // component, that no debt holds.
1395
+ const { refus, lignes } = trancherLaGarde(racine, [
1396
+ ...refusDuGraphe(racine).map(message => ({ message })),
1397
+ ...configurationsRefusees(racine),
1398
+ ]);
1399
+ for (const l of [...refus.map(r => r.message), ...lignes]) {
1407
1400
  process.stderr.write(`${l}\n`);
1408
1401
  }
1409
- // Each refusal judges the root's configuration: a finding without a file of a component.
1410
- ecrireSarif({
1411
- garde: 'turbo-des-paquets',
1412
- racine,
1413
- constats: refus.map(l => ({ message: l })),
1414
- });
1415
1402
  process.exitCode = refus.length ? 1 : 0;
1416
1403
  }
1417
1404
  } catch (e) {
@@ -16,7 +16,7 @@
16
16
  // day, and every measure of time, a time budget bench (`*.budget.test.*`, `*.budget.spec.*`) or
17
17
  // a time witness (a test file that imports `mesurerAuRepos`), moves with the load of the day:
18
18
  // `npm test`, `npm run verifier` and the integration leave them out, and the night plays them
19
- // (scripts/nuit.sh, scripts/langages/typescript/vitest.nuit.config.mjs); a targeted run that
19
+ // (scripts/nuit.sh, scripts/langages/typescript/vitest.nuit.config.cjs); a targeted run that
20
20
  // names the file of one itself plays it, under the measure of time below (./cibles.mjs, where
21
21
  // the patterns live, and whose plugin leaves the witnesses out). `mergeConfig` adds the
22
22
  // exclusions of a configuration that extends this one to these.
@@ -1,6 +1,6 @@
1
1
  // The delays of the sizes of test, in ms, on the model of Bazel's test-encyclopedia: small, medium,
2
2
  // large. A module of its own, with no import: the configurations of Vitest (./base.mjs,
3
- // ../vitest.nuit.config.mjs) are bundled by Vite and read only these numbers, while the
3
+ // ../vitest.nuit.config.cjs) are bundled by Vite and read only these numbers, while the
4
4
  // classification that deduces a file's size (./delais.mjs) reads the guard of the sizes, a script.
5
5
  // Mechanism: packages/grillhouse/docs/architecture/tests.md, §3.4 (the guard of the sizes).
6
6
 
@@ -36,7 +36,7 @@
36
36
  // named leaves them out, as the day does.
37
37
  // - A run whose paths name no test file plays none, and fails: the base configuration keeps
38
38
  // Vitest's `passWithNoTests: false`.
39
- // - The night's configuration (scripts/langages/typescript/vitest.nuit.config.mjs) plays what the
39
+ // - The night's configuration (scripts/langages/typescript/vitest.nuit.config.cjs) plays what the
40
40
  // day leaves out, through the plugin `nuit`: the night tests, the benches and the witnesses; the
41
41
  // variable `GRILLHOUSE_TESTS_DE_NUIT` (NUIT_VARIABLE) chooses `nuit`, the night tests alone,
42
42
  // `hors-poste`, the night tests but those that bear the tag `@poste` at their head (the night of
@@ -61,7 +61,7 @@ import { lireChangements, restreindre } from './changements.mjs';
61
61
  // The name of the variable is the core's (`TESTS_CIBLES`); this module reads it under its own name.
62
62
  export const VARIABLE = TESTS_CIBLES;
63
63
  // The day's exclusions, which the base configuration (./base.mjs) sets and the night plays
64
- // (scripts/langages/typescript/vitest.nuit.config.mjs): the night tests, too long for the day, and the time budget
64
+ // (scripts/langages/typescript/vitest.nuit.config.cjs): the night tests, too long for the day, and the time budget
65
65
  // benches, whose measures move with the load of the day.
66
66
  export const NUIT = '**/*.nuit.{test,spec}.?(c|m)[jt]s?(x)';
67
67
  export const BUDGET = '**/*.budget.{test,spec}.?(c|m)[jt]s?(x)';