@roomi-fields/grillhouse 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/cadre/templates/projet/CLAUDE.md +7 -0
  3. package/cadre/templates/projet/docs/ARCHITECTURE.md +15 -0
  4. package/cadre/templates/python/package.json +18 -0
  5. package/charte.md +22 -0
  6. package/docs/ARCHITECTURE.md +58 -17
  7. package/docs/CADRE.md +7 -6
  8. package/docs/INTERFACE.md +96 -32
  9. package/package.json +1 -1
  10. package/scripts/circuit.mjs +44 -8
  11. package/scripts/commande-du-langage.mjs +2 -2
  12. package/scripts/commandes-composees.mjs +156 -0
  13. package/scripts/composition-des-langages.mjs +306 -0
  14. package/scripts/conformite.mjs +1 -3
  15. package/scripts/dernier-vert.mjs +15 -2
  16. package/scripts/engendres.mjs +170 -0
  17. package/scripts/enveloppe/travail-de-la-copie.mjs +82 -8
  18. package/scripts/gardes-du-cadre.mjs +7 -4
  19. package/scripts/grillhouse-maj.mjs +152 -99
  20. package/scripts/index-interfaces.mjs +78 -0
  21. package/scripts/init.mjs +5 -5
  22. package/scripts/integration/file.mjs +74 -13
  23. package/scripts/integration/integrer.mjs +50 -62
  24. package/scripts/jointure.d.ts +26 -13
  25. package/scripts/langages/cargo/binaires.mjs +29 -6
  26. package/scripts/langages/cargo/clippy.mjs +4 -2
  27. package/scripts/langages/cargo/commandes.mjs +45 -7
  28. package/scripts/langages/cargo/exemples.mjs +1 -15
  29. package/scripts/langages/cargo/index-interfaces.mjs +20 -3
  30. package/scripts/langages/cargo/index.mjs +9 -10
  31. package/scripts/langages/cargo/mise-a-jour.mjs +2 -1
  32. package/scripts/langages/cargo/sccache.mjs +29 -0
  33. package/scripts/langages/python/binaires.json +3 -0
  34. package/scripts/langages/python/binaires.mjs +59 -0
  35. package/scripts/langages/python/commandes.mjs +411 -0
  36. package/scripts/langages/python/composants.mjs +272 -0
  37. package/scripts/langages/python/exemples.mjs +260 -0
  38. package/scripts/langages/python/index-interfaces.mjs +77 -0
  39. package/scripts/langages/python/index.mjs +94 -0
  40. package/scripts/langages/python/lot.mjs +76 -0
  41. package/scripts/langages/python/mise-a-jour.mjs +54 -0
  42. package/scripts/langages/python/tailles-des-tests.mjs +102 -0
  43. package/scripts/langages/python/verdict.mjs +85 -0
  44. package/scripts/langages/typescript/exemples.mjs +1 -20
  45. package/scripts/langages/typescript/index-interfaces.mjs +10 -3
  46. package/scripts/langages/typescript/index.mjs +11 -15
  47. package/scripts/langages-des-paquets.mjs +171 -0
  48. package/scripts/langages.mjs +60 -41
  49. package/scripts/migrations/0.27.0-langages-dans-l-architecture.mjs +182 -0
  50. package/scripts/migrations.mjs +2 -0
  51. package/scripts/outils-cles.mjs +1 -1
  52. package/scripts/session-start.sh +34 -9
  53. package/scripts/sources.mjs +2 -1
  54. package/scripts/sous-commandes.mjs +5 -3
  55. package/scripts/tableau-des-composants.mjs +138 -0
  56. package/scripts/verrous/verrou.mjs +3 -2
  57. package/skills/grill/SKILL.md +9 -1
  58. package/skills/pitmaster/SKILL.md +6 -1
  59. package/skills/redacteur/references/documents-d-un-composant.md +12 -0
  60. package/skills/testwriter/SKILL.md +6 -0
@@ -9,8 +9,8 @@
9
9
  // - The command is the subcommand <nom> of the module (`commandeDe` of ./sous-commandes.mjs), run
10
10
  // by Node with its arguments then these, in the working directory, this process's standard
11
11
  // streams; its exit code is this command's, 128 plus the number of a signal that ended it.
12
- // - A project that declares no language (`grillhouse.langages`), or whose module describes no
13
- // command <nom>, plays nothing: exit 0.
12
+ // - A project that declares no language (the column « Langage » of its docs/ARCHITECTURE.md),
13
+ // or whose module describes no command <nom>, plays nothing: exit 0.
14
14
  // - A name of the core (`grillhouse <nom>`), or none, is refused, exit 2.
15
15
  import { spawnSync } from 'node:child_process';
16
16
  import { constants } from 'node:os';
@@ -0,0 +1,156 @@
1
+ #!/usr/bin/env node
2
+ // A command of a project of several languages (./composition-des-langages.mjs, `commandes`):
3
+ // each declared module that describes it plays it with its own tool, one after the other, and the
4
+ // verdicts join into one, as Bazel runs each target with the rule of its language and one red
5
+ // fails the build. `grillhouse tests`, `grillhouse verifier` and every command of a module run it
6
+ // in such a project; the circuit, the queue and the night reach it by them.
7
+ //
8
+ // node commandes-composees.mjs <nom> [arguments…] from the root of the project
9
+ //
10
+ // - The modules are the project's (scripts/langages.mjs, `langagesDe`), in the order of the
11
+ // declaration; each one that describes the command <nom> plays it, by Node, its arguments then
12
+ // these, in the working directory, with this process's standard streams and environment, its
13
+ // results directory included (`GRILLHOUSE_RESULTATS`), where each module writes under names of
14
+ // its own. A line on the error stream names each module before it plays, so that what a
15
+ // command prints on its standard output stays its own.
16
+ // - `tester`: an argument that begins with « - » is an option, given to every module; any other is
17
+ // a path from the root, given to the module of the component that holds it
18
+ // (`moduleDuFichier`), or out of every component to the first module whose rule of a test file
19
+ // judges it (`estUnTest`). With paths, the modules that receive none do not play. A path no
20
+ // module takes is refused, named, and nothing plays (code 2).
21
+ // - The last green (scripts/dernier-vert.mjs) is kept once, after the last module: while the
22
+ // modules play, a module green defers its own (`VERT_DIFFERE`); when every module played green
23
+ // and each deferred one, the first deferred is kept, the state of the repository when the pass
24
+ // began. A pass with one module red keeps none, so that the next pass plays its changes again.
25
+ // - The exit code: 0 when every module is green, 75 when the only reds are « à repasser », else the
26
+ // first other code; 128 plus the number of a signal that ended a module.
27
+ import { spawnSync } from 'node:child_process';
28
+ import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
29
+ import { constants, tmpdir } from 'node:os';
30
+ import path from 'node:path';
31
+ import { fileURLToPath, pathToFileURL } from 'node:url';
32
+ import { moduleDuFichier } from './composition-des-langages.mjs';
33
+ import { garderLeVert, VERT_DIFFERE } from './dernier-vert.mjs';
34
+ import { langagesDe } from './langages.mjs';
35
+
36
+ /** This script, the one every composed command runs. */
37
+ export const SCRIPT = fileURLToPath(import.meta.url);
38
+ const A_REPASSER = 75;
39
+
40
+ /**
41
+ * The verdict of the codes <codes> joined: 0 when every code is 0, 75 when the others are 75,
42
+ * else the first other.
43
+ * @param {number[]} codes
44
+ */
45
+ export const unir = codes =>
46
+ codes.find(c => c !== 0 && c !== A_REPASSER) ??
47
+ (codes.some(c => c === A_REPASSER) ? A_REPASSER : 0);
48
+
49
+ // The arguments of each module of <modules> for the command <nom>: `{ parts: [{ module, args }] }`,
50
+ // or `{ refus }`, the paths no module takes.
51
+ function repartir(nom, args, modules, racine) {
52
+ if (nom !== 'tester') {
53
+ return { parts: modules.map(module => ({ module, args })) };
54
+ }
55
+ const estChemin = a => !a.startsWith('-');
56
+ if (!args.some(estChemin)) {
57
+ return { parts: modules.map(module => ({ module, args })) };
58
+ }
59
+ const parModule = new Map();
60
+ const refus = [];
61
+ for (const a of args.filter(estChemin)) {
62
+ const m =
63
+ moduleDuFichier(modules, racine, a) ??
64
+ modules.find(x => x.estUnTest(a, racine) !== null) ??
65
+ null;
66
+ if (m) {
67
+ parModule.set(m, [...(parModule.get(m) ?? []), a]);
68
+ } else {
69
+ refus.push(a);
70
+ }
71
+ }
72
+ if (refus.length) {
73
+ return { refus };
74
+ }
75
+ return {
76
+ parts: modules
77
+ .filter(m => parModule.has(m))
78
+ .map(module => ({
79
+ module,
80
+ args: args.filter(a => !estChemin(a) || parModule.get(module).includes(a)),
81
+ })),
82
+ };
83
+ }
84
+
85
+ /**
86
+ * Plays the command <nom> with <args> in each module of <modules> that describes it, in the
87
+ * project at <racine>, under <env>: the joined exit code.
88
+ * @param {string} nom
89
+ * @param {string[]} args
90
+ * @param {{ racine?: string, modules?: import('./jointure.js').Langage[], env?: NodeJS.ProcessEnv,
91
+ * dire?: (ligne: string) => void }} [o]
92
+ * @returns {number}
93
+ */
94
+ export function jouer(
95
+ nom,
96
+ args,
97
+ {
98
+ racine = process.cwd(),
99
+ modules = langagesDe(racine),
100
+ env = process.env,
101
+ dire = l => process.stderr.write(`${l}\n`),
102
+ } = {}
103
+ ) {
104
+ const avec = modules.filter(m => Object.hasOwn(m.commandes(racine), nom));
105
+ const r = repartir(nom, args, avec, racine);
106
+ if (r.refus) {
107
+ for (const a of r.refus) {
108
+ process.stderr.write(`⛔ ${a} : aucun composant ne le tient, d'aucun langage du projet.\n`);
109
+ }
110
+ return 2;
111
+ }
112
+ const dossier = mkdtempSync(path.join(tmpdir(), 'grillhouse-vert-differe-'));
113
+ const differe = path.join(dossier, 'verts');
114
+ try {
115
+ const codes = r.parts.map(({ module, args: siens }) => {
116
+ const c = module.commandes(racine)[nom];
117
+ dire(`▶ ${module.nom} : ${nom}`);
118
+ const p = spawnSync(process.execPath, [c.script, ...c.args, ...siens], {
119
+ cwd: racine,
120
+ stdio: 'inherit',
121
+ env: { ...env, [VERT_DIFFERE]: differe },
122
+ });
123
+ if (p.error) {
124
+ process.stderr.write(`⛔ ${module.nom} : ${nom} : ${p.error.message}\n`);
125
+ return 1;
126
+ }
127
+ return p.status ?? 128 + (constants.signals[p.signal ?? 'SIGTERM'] ?? 0);
128
+ });
129
+ const code = unir(codes);
130
+ let verts = [];
131
+ try {
132
+ verts = readFileSync(differe, 'utf8')
133
+ .split('\n')
134
+ .filter(Boolean)
135
+ .map(l => JSON.parse(l));
136
+ } catch {
137
+ verts = [];
138
+ }
139
+ if (code === 0 && verts.length > 0 && verts.length === r.parts.length) {
140
+ garderLeVert(verts[0], {});
141
+ }
142
+ return code;
143
+ } finally {
144
+ rmSync(dossier, { recursive: true, force: true });
145
+ }
146
+ }
147
+
148
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
149
+ const [nom, ...args] = process.argv.slice(2);
150
+ try {
151
+ process.exitCode = jouer(nom, args);
152
+ } catch (e) {
153
+ process.stderr.write(`${e.message}\n`);
154
+ process.exitCode = 1;
155
+ }
156
+ }
@@ -0,0 +1,306 @@
1
+ // The composition of the modules of language a project declares (scripts/langages.mjs,
2
+ // `langageDe`), as Bazel and Nx run one list of targets, one tool per language, each target of one
3
+ // language alone: a project has several languages, a package one. The composition answers what the
4
+ // core asks of a language (scripts/jointure.d.ts, `Composition`), by asking each module.
5
+ //
6
+ // - One module declared: the composition is the module itself.
7
+ // - The components are each module's, in the order of the declaration. A folder two modules claim
8
+ // is refused, named with both languages: a package has one language. A file belongs to the
9
+ // module of the component that holds it, the deepest (`moduleDuFichier`); a file out of every
10
+ // component stays the core's, as with one language: the first module, in the order of the
11
+ // declaration, whose answer is not null judges it (`estUnTest`, `manifestes.horsDesTests`).
12
+ // - Whether a component plays tests, the readers of components and the components touched are
13
+ // each module's on its own components, the results joined: a name without supplier is without
14
+ // supplier in every module, a file out of the graph is out of every module's graph.
15
+ // - The elements of a lot are every module's; a changed source that no element reads is the one
16
+ // its own module names (every module, for a file out of every component); the lot is impossible
17
+ // when one module cannot read it, its reason named with its language.
18
+ // - The verdict of a run is every module's, read in the same results directory, where each module
19
+ // writes under names of its own (scripts/resultats.mjs).
20
+ // - Each command a module describes is the composed command by its name
21
+ // (./commandes-composees.mjs), which plays it in each module that describes it and joins their
22
+ // codes.
23
+ // - The guards, the generated files, the migrations, the shared test material: every module's, in
24
+ // the order of the declaration; but the index of the interfaces, which each module generates:
25
+ // one of the core (./index-interfaces.mjs), assembled from each module's entries, its command
26
+ // (`index-interfaces`), its generated file and its guard in place of the modules', at the place
27
+ // of the first. What the role lock, the envelope and the update ask (the lock
28
+ // files, the outputs, the rules of the roles, the tools, the binaries, the directories to
29
+ // ignore): the union, each once.
30
+ import { existsSync, readFileSync } from 'node:fs';
31
+ import path from 'node:path';
32
+ import { fileURLToPath } from 'node:url';
33
+
34
+ // The scripts of the commands above the composition, named by their paths, never imported: the
35
+ // one that plays a composed command (./commandes-composees.mjs), and the index of the interfaces
36
+ // (./index-interfaces.mjs).
37
+ const ICI = path.dirname(fileURLToPath(import.meta.url));
38
+ const COMMANDES_COMPOSEES = path.join(ICI, 'commandes-composees.mjs');
39
+ const INDEX = path.join(ICI, 'index-interfaces.mjs');
40
+ /** The index of the interfaces, from the root. */
41
+ export const INDEX_DES_INTERFACES = 'docs/agents/index-des-interfaces.md';
42
+
43
+ /**
44
+ * The index of the interfaces of the project at <racine>, from the modules <modules>: each one's
45
+ * entries (`entreesDeLIndex`), in the order of their paths, an interface two modules give (the
46
+ * root's) once, the first module's.
47
+ * @param {string} racine
48
+ * @param {import('./jointure.js').Langage[]} modules
49
+ */
50
+ export function indexDesInterfaces(racine, modules) {
51
+ const parRel = new Map();
52
+ for (const m of modules) {
53
+ for (const e of m.entreesDeLIndex(racine)) {
54
+ if (!parRel.has(e.rel)) {
55
+ parRel.set(e.rel, e.lignes);
56
+ }
57
+ }
58
+ }
59
+ const corps = [...parRel]
60
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
61
+ .flatMap(([, lignes]) => lignes);
62
+ return [
63
+ '# Index des interfaces',
64
+ '',
65
+ 'Généré par `npx grillhouse index-interfaces` depuis les `INTERFACE.md` de chaque langage ; ne pas éditer.',
66
+ "Une ligne par composant, puis, selon son langage, une par élément qu'il fournit ; l'interface donne le détail.",
67
+ '',
68
+ ...corps,
69
+ ].join('\n');
70
+ }
71
+
72
+ /**
73
+ * The findings of the check of the index of the project at <racine>: none when it is up to date.
74
+ * @param {string} racine
75
+ * @param {import('./jointure.js').Langage[]} modules
76
+ */
77
+ export function indexEnRetard(racine, modules) {
78
+ const cible = path.join(racine, INDEX_DES_INTERFACES);
79
+ const present = existsSync(cible) ? readFileSync(cible, 'utf8') : '';
80
+ return present === indexDesInterfaces(racine, modules)
81
+ ? []
82
+ : [
83
+ {
84
+ fichier: INDEX_DES_INTERFACES,
85
+ message: `${INDEX_DES_INTERFACES} n'est pas à jour avec les interfaces : npx grillhouse index-interfaces le régénère.`,
86
+ },
87
+ ];
88
+ }
89
+
90
+ const unique = liste => [...new Set(liste)];
91
+ // The index of the interfaces, which each module generates, and its command: one of the core
92
+ // for several languages (./index-interfaces.mjs).
93
+ const INDEX_COMMANDE = 'index-interfaces';
94
+ const deLIndex = e => e.fichiers.includes(INDEX_DES_INTERFACES);
95
+ const sous = (dossier, abs) => abs === dossier || abs.startsWith(`${dossier}${path.sep}`);
96
+
97
+ /**
98
+ * The components of the modules <modules> in the repository at <racine>, each with its module:
99
+ * `[{ composant, module }]`, in the order of the declaration. Throws when two modules claim a
100
+ * folder.
101
+ * @param {import('./jointure.js').Langage[]} modules
102
+ * @param {string} racine
103
+ */
104
+ export function composantsRanges(modules, racine) {
105
+ const ranges = modules.flatMap(module =>
106
+ module.composants(racine).map(composant => ({ composant, module }))
107
+ );
108
+ const parDossier = new Map();
109
+ for (const r of ranges) {
110
+ const deja = parDossier.get(r.composant.dossier);
111
+ if (deja && deja.module !== r.module) {
112
+ const rel = path.relative(racine, r.composant.dossier) || '.';
113
+ throw new Error(
114
+ `⛔ ${rel} : revendiqué par ${deja.module.nom} et ${r.module.nom} ; un paquet n'a qu'un seul langage.`
115
+ );
116
+ }
117
+ parDossier.set(r.composant.dossier, r);
118
+ }
119
+ return ranges;
120
+ }
121
+
122
+ /**
123
+ * The module of the component that holds <fichier> (absolute, or from <racine>), the deepest;
124
+ * null when no component of <modules> holds it.
125
+ * @param {import('./jointure.js').Langage[]} modules
126
+ * @param {string} racine
127
+ * @param {string} fichier
128
+ */
129
+ export function moduleDuFichier(modules, racine, fichier) {
130
+ return rangeDe(composantsRanges(modules, racine), racine, fichier)?.module ?? null;
131
+ }
132
+
133
+ function rangeDe(ranges, racine, fichier) {
134
+ const abs = path.resolve(racine, fichier);
135
+ return (
136
+ ranges
137
+ .filter(r => sous(r.composant.dossier, abs))
138
+ .sort((a, b) => b.composant.dossier.length - a.composant.dossier.length)[0] ?? null
139
+ );
140
+ }
141
+
142
+ // The answer of the module of <fichier>'s component, else the first of <modules> not null.
143
+ function premiereReponse(modules, racine, fichier, demander) {
144
+ const proprietaire = moduleDuFichier(modules, racine, fichier);
145
+ if (proprietaire) {
146
+ return demander(proprietaire);
147
+ }
148
+ for (const m of modules) {
149
+ const r = demander(m);
150
+ if (r !== null) {
151
+ return r;
152
+ }
153
+ }
154
+ return null;
155
+ }
156
+
157
+ /**
158
+ * The composition of <modules>, in the order of the declaration; the module itself for one.
159
+ * @param {import('./jointure.js').Langage[]} modules
160
+ * @returns {import('./jointure.js').Composition}
161
+ */
162
+ export function composer(modules) {
163
+ if (modules.length === 1) {
164
+ return modules[0];
165
+ }
166
+ const ranges = racine => composantsRanges(modules, racine);
167
+ const moduleDe = (racine, fichier) => moduleDuFichier(modules, racine, fichier);
168
+ const moduleDuComposant = (racine, composant) =>
169
+ ranges(racine).find(r => r.composant.dossier === composant.dossier)?.module ?? null;
170
+ const leurs = (racine, liste) =>
171
+ new Map(modules.map(m => [m, liste.filter(c => moduleDuComposant(racine, c) === m)]));
172
+ return {
173
+ nom: modules.map(m => m.nom).join('+'),
174
+ outils: unique(modules.flatMap(m => m.outils)),
175
+ binaires: Object.assign({}, ...modules.map(m => m.binaires)),
176
+ ignorer: unique(modules.flatMap(m => m.ignorer)),
177
+ sorties: {
178
+ ecrites: unique(modules.flatMap(m => m.sorties.ecrites)),
179
+ propres: unique(modules.flatMap(m => m.sorties.propres)),
180
+ lues: unique(modules.flatMap(m => m.sorties.lues)),
181
+ },
182
+ droits: unique(modules.flatMap(m => m.droits)),
183
+ composants: racine => ranges(racine).map(r => r.composant),
184
+ composantDe: (racine, fichier) => rangeDe(ranges(racine), racine, fichier)?.composant ?? null,
185
+ matieres: racine => modules.flatMap(m => m.matieres(racine)),
186
+ joueDesTests: (racine, composant) =>
187
+ moduleDuComposant(racine, composant)?.joueDesTests(racine, composant) ?? false,
188
+ lecteurs(racine, o) {
189
+ const composants = leurs(racine, o.composants);
190
+ const nommes = leurs(racine, o.nommes);
191
+ const parts = modules
192
+ .filter(m => composants.get(m).length)
193
+ .map(m =>
194
+ m.lecteurs(racine, { ...o, composants: composants.get(m), nommes: nommes.get(m) })
195
+ );
196
+ const pasFaits = parts.filter(p => p.types.etat !== 'fait');
197
+ return {
198
+ elements: parts.flatMap(p => p.elements),
199
+ sansFournisseur: parts.length
200
+ ? parts[0].sansFournisseur.filter(n => parts.every(p => p.sansFournisseur.includes(n)))
201
+ : [...o.noms],
202
+ types: {
203
+ etat: pasFaits[0]?.types.etat ?? 'fait',
204
+ raison:
205
+ pasFaits
206
+ .map(p => p.types.raison)
207
+ .filter(Boolean)
208
+ .join(' ; ') || null,
209
+ elements: parts.flatMap(p => p.types.elements),
210
+ },
211
+ lit: new Map(parts.flatMap(p => [...p.lit])),
212
+ parLesTests: new Map(parts.flatMap(p => [...p.parLesTests])),
213
+ };
214
+ },
215
+ touches(racine, o) {
216
+ const parts = modules.map(m => m.touches(racine, o));
217
+ const touches = parts.flatMap(p => p.touches);
218
+ const vus = new Set(touches.map(c => c.dossier));
219
+ return {
220
+ touches,
221
+ dependants: parts.flatMap(p => p.dependants).filter(c => !vus.has(c.dossier)),
222
+ horsGraphe: parts[0].horsGraphe.filter(f => parts.every(p => p.horsGraphe.includes(f))),
223
+ };
224
+ },
225
+ elementsDuLot(racine, o) {
226
+ const parts = modules.map(m => ({ m, l: m.elementsDuLot(racine, o) }));
227
+ const impossibles = parts.filter(p => p.l.etat !== 'fait');
228
+ const horsDuService = unique(parts.flatMap(p => p.l.horsDuService)).filter(f => {
229
+ const proprietaire = moduleDe(racine, f);
230
+ return parts
231
+ .filter(p => (proprietaire ? p.m === proprietaire : true))
232
+ .every(p => p.l.horsDuService.includes(f));
233
+ });
234
+ return {
235
+ etat: impossibles.length ? 'impossible' : 'fait',
236
+ raison: impossibles.length
237
+ ? impossibles.map(p => `${p.m.nom} : ${p.l.raison}`).join(' ; ')
238
+ : null,
239
+ elements: parts.flatMap(p => p.l.elements),
240
+ horsDuService: horsDuService.sort(),
241
+ fichiers: unique(parts.flatMap(p => p.l.fichiers)).sort(),
242
+ };
243
+ },
244
+ commandes: racine =>
245
+ Object.fromEntries(
246
+ unique(modules.flatMap(m => Object.keys(m.commandes(racine)))).map(nom => [
247
+ nom,
248
+ nom === INDEX_COMMANDE
249
+ ? { script: INDEX, args: [] }
250
+ : { script: COMMANDES_COMPOSEES, args: [nom] },
251
+ ])
252
+ ),
253
+ verdict(dossier) {
254
+ const parts = modules.map(m => m.verdict(dossier));
255
+ return {
256
+ rapports: parts.flatMap(p => p.rapports),
257
+ taches: parts.flatMap(p => p.taches),
258
+ };
259
+ },
260
+ estUnTest: (chemin, racine) =>
261
+ premiereReponse(modules, racine, chemin, m => m.estUnTest(chemin, racine)),
262
+ manifestes: {
263
+ verrous: unique(modules.flatMap(m => m.manifestes.verrous)),
264
+ horsDesTests: (chemin, racine, avant, apres) =>
265
+ premiereReponse(modules, racine, chemin, m =>
266
+ m.manifestes.horsDesTests(chemin, racine, avant, apres)
267
+ ),
268
+ },
269
+ fichiersEngendres(racine) {
270
+ const tous = modules.flatMap(m => m.fichiersEngendres(racine));
271
+ const index = tous.filter(deLIndex);
272
+ if (index.length === 0) {
273
+ return tous;
274
+ }
275
+ const reste = tous.filter(e => !deLIndex(e));
276
+ reste.splice(tous.findIndex(deLIndex), 0, {
277
+ nom: index[0].nom,
278
+ commande: `node ${JSON.stringify(INDEX)}`,
279
+ fichiers: [INDEX_DES_INTERFACES],
280
+ lit: unique(index.flatMap(e => e.lit)),
281
+ gardes: unique(index.flatMap(e => e.gardes)),
282
+ entiers: [INDEX_DES_INTERFACES],
283
+ verifier: r => indexEnRetard(r, modules),
284
+ });
285
+ return reste;
286
+ },
287
+ gardes(racine) {
288
+ const tous = modules.flatMap(m => m.gardes(racine));
289
+ const noms = new Set(
290
+ modules
291
+ .flatMap(m => m.fichiersEngendres(racine))
292
+ .filter(deLIndex)
293
+ .flatMap(e => e.gardes)
294
+ );
295
+ if (noms.size === 0) {
296
+ return tous;
297
+ }
298
+ const deLaGarde = g => noms.has(path.basename(g[0]).replace(/\.[cm]?js$/, ''));
299
+ const reste = tous.filter(g => !deLaGarde(g));
300
+ const i = tous.findIndex(deLaGarde);
301
+ reste.splice(i < 0 ? reste.length : i, 0, [INDEX, '--verifier']);
302
+ return reste;
303
+ },
304
+ migrations: modules.flatMap(m => m.migrations),
305
+ };
306
+ }
@@ -30,8 +30,7 @@
30
30
  // - elementsDuLot: each file the lot of the entry changes, each changed source the module reads no
31
31
  // element of, and each element it adds, changes or removes;
32
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.
33
+ // - joueDesTests: each component of the repository of the entry that plays tests.
35
34
  import { existsSync, readdirSync, statSync } from 'node:fs';
36
35
  import { tmpdir } from 'node:os';
37
36
  import path from 'node:path';
@@ -183,7 +182,6 @@ export function cas(langage, exemples, { dans = tmpdir() } = {}) {
183
182
  .composants(racine)
184
183
  .filter(c => langage.joueDesTests(racine, c))
185
184
  .map(c => `${nommer(c)} : joue des tests`),
186
- trouve: depots => depots.filter(d => langage.trouve(d.racine)).map(d => `${d.nom} : trouvé`),
187
185
  };
188
186
  const invalides = {
189
187
  gardes: [...e.gardes.valide, 'garde-inexistante'],
@@ -34,8 +34,13 @@
34
34
  // removes at its end.
35
35
  // - `npm test` measures itself against the last green under the circuit's mark,
36
36
  // `GRILLHOUSE_DEPUIS_LE_VERT` (scripts/langages/typescript/tests.mjs, scripts/circuit.mjs); it never keeps one.
37
+ // - In a project of several languages, each language's pass defers its green to the file that
38
+ // `GRILLHOUSE_VERT_DIFFERE` names (`VERT_DIFFERE`): the composed command keeps the first one once
39
+ // every language played green (scripts/commandes-composees.mjs), so that a language played after
40
+ // another does not measure itself against the green of the first.
37
41
  import { spawnSync } from 'node:child_process';
38
42
  import {
43
+ appendFileSync,
39
44
  copyFileSync,
40
45
  existsSync,
41
46
  mkdirSync,
@@ -51,6 +56,9 @@ import path from 'node:path';
51
56
  // tests of the module of the language reads in each package.
52
57
  export const CHANGEMENTS = 'GRILLHOUSE_CHANGEMENTS';
53
58
  export const DEPUIS_LE_VERT = 'GRILLHOUSE_DEPUIS_LE_VERT';
59
+ // The variable that names the file where a pass of one language among several defers its green,
60
+ // which the composed command keeps once every language played green (scripts/commandes-composees.mjs).
61
+ export const VERT_DIFFERE = 'GRILLHOUSE_VERT_DIFFERE';
54
62
  const SHA = /^[0-9a-f]{40,64}$/;
55
63
 
56
64
  const git = (racine, args, env = process.env) =>
@@ -151,8 +159,13 @@ function lireLeVertDe(etat, branche) {
151
159
  return { commit: v.commit, arbre: v.arbre, branche };
152
160
  }
153
161
 
154
- // Keeps <etat> (etatDuDepot) as the last green of its branch, of main when HEAD is detached.
155
- export function garderLeVert(etat) {
162
+ // Keeps <etat> (etatDuDepot) as the last green of its branch, of main when HEAD is detached; while
163
+ // <env> names a file of deferred greens (`VERT_DIFFERE`), adds it there instead, one line of JSON.
164
+ export function garderLeVert(etat, env = process.env) {
165
+ if (env[VERT_DIFFERE]) {
166
+ appendFileSync(env[VERT_DIFFERE], `${JSON.stringify(etat)}\n`);
167
+ return;
168
+ }
156
169
  const branche = etat.branche ?? etat.main;
157
170
  const f = branche ? fichierDuVert(etat.racine, branche) : null;
158
171
  if (!f) return;