@roomi-fields/grillhouse 0.24.15 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/grillhouse.mjs +40 -12
  3. package/cadre/templates/cargo/.config/nextest.toml +8 -0
  4. package/cadre/templates/cargo/deny.toml +41 -0
  5. package/cadre/templates/cargo/package.json +15 -0
  6. package/cadre/templates/cargo/rust-toolchain.toml +6 -0
  7. package/cadre/templates/projet/package.json +5 -1
  8. package/cadre/templates/turbo/paquets.json +1 -1
  9. package/cadre/templates/turbo/sans-paquets.json +1 -1
  10. package/charte.md +16 -0
  11. package/docs/ARCHITECTURE.md +160 -56
  12. package/docs/CADRE.md +47 -0
  13. package/docs/INTERFACE.md +176 -0
  14. package/package.json +66 -13
  15. package/scripts/arbitrages.mjs +23 -0
  16. package/scripts/avancement.mjs +15 -29
  17. package/scripts/circuit.mjs +89 -97
  18. package/scripts/commande-du-langage.mjs +56 -0
  19. package/scripts/composants-affectes.mjs +47 -170
  20. package/scripts/conformite.d.ts +27 -0
  21. package/scripts/conformite.mjs +226 -0
  22. package/scripts/demon.mjs +1 -1
  23. package/scripts/dernier-vert.mjs +11 -9
  24. package/scripts/droits.mjs +27 -21
  25. package/scripts/enveloppe/enveloppe.mjs +206 -64
  26. package/scripts/enveloppe/lancer.sh +20 -91
  27. package/scripts/enveloppe/paquets-du-plan.mjs +24 -2
  28. package/scripts/etapes.mjs +2 -2
  29. package/scripts/gardes-du-cadre.mjs +12 -18
  30. package/scripts/grillhouse-maj.mjs +246 -389
  31. package/scripts/init.mjs +2 -1
  32. package/scripts/integration/file.mjs +3 -3
  33. package/scripts/integration/integrer.mjs +13 -10
  34. package/scripts/integration/rejeu.mjs +36 -7
  35. package/scripts/jointure.d.ts +304 -0
  36. package/scripts/langages/cargo/binaires.json +4 -0
  37. package/scripts/langages/cargo/binaires.mjs +60 -0
  38. package/scripts/langages/cargo/clippy.mjs +103 -0
  39. package/scripts/langages/cargo/commandes.mjs +378 -0
  40. package/scripts/langages/cargo/composants.mjs +191 -0
  41. package/scripts/langages/cargo/elements-du-lot.mjs +139 -0
  42. package/scripts/langages/cargo/exemples.mjs +357 -0
  43. package/scripts/langages/cargo/frontieres.mjs +84 -0
  44. package/scripts/langages/cargo/index-interfaces.mjs +138 -0
  45. package/scripts/langages/cargo/index.mjs +115 -0
  46. package/scripts/langages/cargo/mise-a-jour.mjs +93 -0
  47. package/scripts/langages/cargo/nextest.toml +5 -0
  48. package/scripts/langages/cargo/touches.mjs +93 -0
  49. package/scripts/langages/cargo/verdict.mjs +85 -0
  50. package/scripts/langages/typescript/chemins-des-tests.mjs +68 -0
  51. package/scripts/{code-mort.mjs → langages/typescript/code-mort.mjs} +5 -5
  52. package/scripts/langages/typescript/composants.mjs +64 -0
  53. package/scripts/{consommateurs-arbitres.mjs → langages/typescript/consommateurs-arbitres.mjs} +6 -24
  54. package/scripts/{consommateurs.mjs → langages/typescript/consommateurs.mjs} +13 -71
  55. package/scripts/langages/typescript/construire.mjs +176 -0
  56. package/scripts/{elements-du-lot.mjs → langages/typescript/elements-du-lot.mjs} +2 -2
  57. package/scripts/langages/typescript/exemples.mjs +289 -0
  58. package/scripts/{frontieres.mjs → langages/typescript/frontieres.mjs} +3 -5
  59. package/scripts/{index-interfaces.mjs → langages/typescript/index-interfaces.mjs} +3 -3
  60. package/scripts/langages/typescript/index.mjs +335 -0
  61. package/scripts/{interfaces-contre-code.mjs → langages/typescript/interfaces-contre-code.mjs} +2 -2
  62. package/scripts/langages/typescript/lecteurs.mjs +179 -0
  63. package/scripts/{migrations → langages/typescript/migrations}/0.23.0-config-vitest.mjs +14 -29
  64. package/scripts/{migrations → langages/typescript/migrations}/0.24.4-noms-declares-inutilises.mjs +2 -2
  65. package/scripts/{migrations → langages/typescript/migrations}/0.24.6-lignes-mal-formees.mjs +2 -2
  66. package/scripts/{migrations → langages/typescript/migrations}/0.24.7-matiere-dans-les-tests.mjs +2 -2
  67. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +27 -0
  68. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +31 -0
  69. package/scripts/langages/typescript/mise-a-jour.mjs +320 -0
  70. package/scripts/{references-par-les-types.mjs → langages/typescript/references-par-les-types.mjs} +3 -3
  71. package/scripts/langages/typescript/regle-des-tests.mjs +39 -0
  72. package/scripts/{resumes.mjs → langages/typescript/resumes.mjs} +4 -4
  73. package/scripts/langages/typescript/script-des-tests.mjs +6 -0
  74. package/scripts/langages/typescript/tailles-des-tests.mjs +219 -0
  75. package/scripts/langages/typescript/tests-de-nuit.mjs +57 -0
  76. package/scripts/{tests.mjs → langages/typescript/tests.mjs} +41 -32
  77. package/scripts/{turbo-des-paquets.mjs → langages/typescript/turbo-des-paquets.mjs} +49 -23
  78. package/scripts/langages/typescript/verdict.mjs +105 -0
  79. package/scripts/{verifier.mjs → langages/typescript/verifier.mjs} +53 -34
  80. package/scripts/{vitest-config → langages/typescript/vitest-config}/avancement.reporter.mjs +10 -2
  81. package/scripts/{vitest-config → langages/typescript/vitest-config}/base.mjs +63 -9
  82. package/scripts/{vitest-config → langages/typescript/vitest-config}/changements.mjs +18 -11
  83. package/scripts/{vitest-config → langages/typescript/vitest-config}/cibles.mjs +7 -6
  84. package/scripts/langages/typescript/vitest-config/duree.reporter.d.ts +10 -0
  85. package/scripts/{vitest-config → langages/typescript/vitest-config}/duree.reporter.mjs +10 -3
  86. package/scripts/langages/typescript/vitest-config/lances.mjs +473 -0
  87. package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.setup.mjs +1 -1
  88. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.mjs +5 -5
  89. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.setup.mjs +4 -3
  90. package/scripts/{vitest.nuit.config.mjs → langages/typescript/vitest.nuit.config.mjs} +2 -2
  91. package/scripts/langages.mjs +85 -0
  92. package/scripts/{vitest-config → mesure}/avancement.mjs +4 -13
  93. package/scripts/{vitest-config → mesure}/base-de-passe.mjs +70 -33
  94. package/scripts/{vitest-config → mesure}/pression.mjs +5 -6
  95. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +29 -6
  96. package/scripts/migrations/0.24.0-circuit-simplifie.mjs +13 -6
  97. package/scripts/migrations/0.25.0-script-des-tests.mjs +92 -0
  98. package/scripts/migrations.mjs +17 -13
  99. package/scripts/nuit.sh +59 -63
  100. package/scripts/paquets.d.ts +5 -0
  101. package/scripts/paquets.mjs +24 -2
  102. package/scripts/resultats.mjs +8 -82
  103. package/scripts/services-du-noyau.mjs +30 -0
  104. package/scripts/session-start.sh +17 -9
  105. package/scripts/sources.mjs +35 -13
  106. package/scripts/sous-commandes.mjs +57 -17
  107. package/scripts/superviseur.mjs +1 -1
  108. package/scripts/tableau.mjs +1 -1
  109. package/scripts/un-commit-par-ticket.mjs +48 -14
  110. package/scripts/verrou-de-fichier.mjs +1 -1
  111. package/scripts/verrou-de-machine.mjs +4 -4
  112. package/scripts/verrous/verrou.mjs +28 -37
  113. package/skills/developpeur/SKILL.md +2 -2
  114. package/skills/explorateur/SKILL.md +13 -5
  115. package/skills/grill/SKILL.md +2 -2
  116. package/skills/pitmaster/references/cadre.md +1 -1
  117. package/skills/pitmaster/references/consigne-agent.md +10 -3
  118. package/skills/redacteur/references/documents-d-un-composant.md +4 -4
  119. package/skills/relecteur/SKILL.md +4 -1
  120. package/skills/testwriter/SKILL.md +20 -6
  121. /package/scripts/{consommateurs.d.ts → langages/typescript/consommateurs.d.ts} +0 -0
  122. /package/scripts/{vitest-config → langages/typescript/vitest-config}/base.d.ts +0 -0
  123. /package/scripts/{vitest-config → langages/typescript/vitest-config}/machine.setup.mjs +0 -0
  124. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.d.ts +0 -0
  125. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.mjs +0 -0
@@ -0,0 +1,64 @@
1
+ // The components of a repository of the module typescript and its packages of the shared test
2
+ // material: one reading, without a line `#!`, that ./consommateurs.mjs (the guard, which the entry
3
+ // `@roomi-fields/grillhouse/consommateurs` publishes) and the Vitest configuration of the frame
4
+ // (./vitest-config/lances.mjs, which Vite bundles and whose parser refuses a `#!` out of the first
5
+ // file) both import.
6
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
7
+ import path from 'node:path';
8
+ import { horsCadre } from '../../paquets.mjs';
9
+
10
+ // Every directory under `packages/` and `src/` of the repository at <racine>: [{ nom, dir }].
11
+ function tousDossiers(racine) {
12
+ const found = [];
13
+ for (const parent of ['packages', 'src']) {
14
+ const base = path.join(racine, parent);
15
+ if (!existsSync(base)) continue;
16
+ for (const e of readdirSync(base, { withFileTypes: true })) {
17
+ if (e.isDirectory()) found.push({ nom: e.name, dir: path.join(base, e.name) });
18
+ }
19
+ }
20
+ return found;
21
+ }
22
+
23
+ // The component directories of the repository at <racine>: [{ nom, dir }], each directory under
24
+ // `packages/` and `src/` that `docs/agents/hors-cadre.txt` does not list.
25
+ export function dossiers(racine) {
26
+ const hors = horsCadre(racine);
27
+ return tousDossiers(racine).filter(d => !hors.has(d.nom));
28
+ }
29
+
30
+ // The components of the repository at <racine>: [{ nom, dir, paquet }], `paquet` its package name.
31
+ // Throws when a package.json is unreadable.
32
+ export function composants(racine) {
33
+ return dossiers(racine).map(({ nom, dir }) => {
34
+ const pj = path.join(dir, 'package.json');
35
+ const paquet = existsSync(pj) ? (JSON.parse(readFileSync(pj, 'utf8')).name ?? null) : null;
36
+ return { nom, dir, paquet };
37
+ });
38
+ }
39
+
40
+ // The subpath export by which a component publishes the shared test material.
41
+ const EXPORT_MATIERE = './test-fixtures';
42
+
43
+ // The components of <racine> whose `package.json` exports `./test-fixtures`, in any form of its
44
+ // value, a package out of the frame never one: the packages of the shared test material,
45
+ // [{ nom, dir, paquet }] as `composants` gives.
46
+ // A component whose `package.json` is unreadable is not a package of the material.
47
+ export function matieres(racine) {
48
+ const found = [];
49
+ for (const { nom, dir } of dossiers(racine)) {
50
+ const pj = path.join(dir, 'package.json');
51
+ if (!existsSync(pj)) continue;
52
+ let paquet;
53
+ try {
54
+ paquet = JSON.parse(readFileSync(pj, 'utf8'));
55
+ } catch {
56
+ continue;
57
+ }
58
+ const { exports } = paquet ?? {};
59
+ if (exports !== null && typeof exports === 'object' && EXPORT_MATIERE in exports) {
60
+ found.push({ nom, dir, paquet: paquet.name ?? null });
61
+ }
62
+ }
63
+ return found;
64
+ }
@@ -6,12 +6,12 @@
6
6
  // npx grillhouse consommateurs-arbitres run from the repository root (a guard of grillhouse:gardes)
7
7
  //
8
8
  // - It judges the copy it runs in, on the branch `agent/<ticket>`: for each component the guards
9
- // judge (`aVerifier` of scripts/interfaces-contre-code.mjs; in an envelope,
9
+ // judge (`aVerifier` of scripts/langages/typescript/interfaces-contre-code.mjs; in an envelope,
10
10
  // `GRILLHOUSE_ENVELOPPE`, the components of its plan), each list line (`- …`) of the
11
11
  // `## Consommateurs` section of its `docs/INTERFACE.md` in the working tree that the section of
12
12
  // HEAD does not hold is a changed line (an interface absent from HEAD: all its lines). The
13
13
  // section is read out of the generated part (between the marks of
14
- // scripts/interfaces-contre-code.mjs): a bullet of an element's entry is no consumer. Out of a
14
+ // scripts/langages/typescript/interfaces-contre-code.mjs): a bullet of an element's entry is no consumer. Out of a
15
15
  // branch `agent/…` (main, the detached copy of the integration, the CI, the night), there is no
16
16
  // lot: nothing is judged.
17
17
  // - With a changed line, the comments of the ticket are read (`bd comments <ticket> --json`, run
@@ -37,32 +37,14 @@ import { existsSync, readFileSync } from 'node:fs';
37
37
  import path from 'node:path';
38
38
  import { pathToFileURL } from 'node:url';
39
39
  import { lireLigne } from './consommateurs.mjs';
40
- import { trancher } from './dette.mjs';
40
+ import { trancher } from '../../dette.mjs';
41
+ import { arbitrageTranche, estArbitrage } from '../../services-du-noyau.mjs';
41
42
  import { aVerifier, marques } from './interfaces-contre-code.mjs';
42
43
 
43
44
  const REGLE = 'consommateur-sans-arbitrage';
44
45
 
45
- // True when the text <text> of a comment is an arbitrage: a « ## Arbitrage… » comment, as the
46
- // supervisor writes it (the skill pitmaster, « Une question de conception se tranche par les
47
- // règles »).
48
- export const estArbitrage = text => /^\s*## Arbitrage\b/.test(String(text ?? ''));
49
-
50
- // True when the text <text> of a comment is the owner's answer, « ## Réponse du responsable — <la
51
- // question> », as the supervisor writes it (the skill pitmaster).
52
- export const estReponseDuResponsable = text =>
53
- /^\s*## Réponse du responsable\b/.test(String(text ?? ''));
54
-
55
- // True when the arbitrage <a> of <comments> (Beads' JSON, in their order) is settled: a line
56
- // `### Verdict — tranché`, or a « ## Réponse du responsable » comment after it.
57
- export function arbitrageTranche(comments, a) {
58
- const tranche = /^### Verdict\s*—\s*tranché/m.test(a.text);
59
- return (
60
- tranche || comments.slice(comments.indexOf(a) + 1).some(c => estReponseDuResponsable(c.text))
61
- );
62
- }
63
-
64
46
  // The list lines of the section `## Consommateurs` of <texte>, trimmed, read out of its generated
65
- // part (`marques`, scripts/interfaces-contre-code.mjs): a bullet the generator writes there (a
47
+ // part (`marques`, scripts/langages/typescript/interfaces-contre-code.mjs): a bullet the generator writes there (a
66
48
  // parameter, a member, a fault) is never a consumer.
67
49
  function lignesConsommateurs(texte) {
68
50
  const m = marques(texte);
@@ -124,7 +106,7 @@ export function verifier(racine, env = process.env) {
124
106
  const head = git(racine, 'show', `HEAD:${rel}`);
125
107
  const lignesAvant = head.status === 0 ? lignesConsommateurs(head.stdout) : [];
126
108
  const avant = new Set(lignesAvant);
127
- // The names each consumer of HEAD's section reads (`lireLigne` of scripts/consommateurs.mjs,
109
+ // The names each consumer of HEAD's section reads (`lireLigne` of scripts/langages/typescript/consommateurs.mjs,
128
110
  // the one reading of such a line: a line that is no list of names gives none).
129
111
  const nomsAvant = new Map();
130
112
  for (const l of lignesAvant.map(lireLigne).filter(l => l?.noms)) {
@@ -20,9 +20,9 @@
20
20
  // (`grillhouse-dette.json`, see `dette.mjs`) passes, keyed by the provider's interface and
21
21
  // `usage-non-declare`, `declare-non-utilise` or `ligne-mal-formee` (`homonyme` for two components
22
22
  // of one name, keyed by the first path). The debt of a new rule is inscribed once, when a project
23
- // updates to it (scripts/migrations/0.24.4-noms-declares-inutilises.mjs,
24
- // scripts/migrations/0.24.6-lignes-mal-formees.mjs,
25
- // scripts/migrations/0.24.7-matiere-dans-les-tests.mjs); in a ticket, the name leaves its line, and a
23
+ // updates to it (scripts/langages/typescript/migrations/0.24.4-noms-declares-inutilises.mjs,
24
+ // scripts/langages/typescript/migrations/0.24.6-lignes-mal-formees.mjs,
25
+ // scripts/langages/typescript/migrations/0.24.7-matiere-dans-les-tests.mjs); in a ticket, the name leaves its line, and a
26
26
  // line of prose is written as a list of names.
27
27
  //
28
28
  // npx grillhouse consommateurs run from the repository root
@@ -31,7 +31,7 @@
31
31
  // path) and under `src/` (reached by a relative path), except those listed out of the frame in
32
32
  // `docs/agents/hors-cadre.txt`: neither read nor checked, as provider or as consumer. Every check
33
33
  // of the frame enumerates the components through `composants`. In a repository of packages, such a
34
- // package stays a workspace, and Turborepo plays none of its tasks (scripts/turbo-des-paquets.mjs
34
+ // package stays a workspace, and Turborepo plays none of its tasks (scripts/langages/typescript/turbo-des-paquets.mjs
35
35
  // writes its configuration). For the check of the uses, test files (under a folder `test/`,
36
36
  // `tests/` or `__tests__/`, or named `*.test.*`, `*.spec.*`) count only for their imports of a
37
37
  // package of the material; `dist/`, `docs/` and `node_modules/` are never read, nor are Vite's
@@ -46,8 +46,13 @@
46
46
  import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
47
47
  import path from 'node:path';
48
48
  import { pathToFileURL } from 'node:url';
49
- import { trancher } from './dette.mjs';
50
- import { horsCadre } from './paquets.mjs';
49
+ import { trancher } from '../../dette.mjs';
50
+ import { horsCadre } from '../../paquets.mjs';
51
+ import { composants, dossiers, matieres } from './composants.mjs';
52
+
53
+ // The components and the packages of the shared material, read by ./composants.mjs; the entry
54
+ // publishes `matieres` from here.
55
+ export { composants, matieres };
51
56
 
52
57
  const SOURCE = /\.(ts|tsx|mts|cts|js|jsx|mjs|cjs|svelte|vue)$/;
53
58
  const TEST_DIR = new Set(['test', 'tests', '__tests__']);
@@ -56,69 +61,6 @@ export const NOM_DE_TEST = /\.(test|spec)\.[cm]?[jt]sx?$/;
56
61
  const isTest = name => NOM_DE_TEST.test(name);
57
62
  const SKIP = new Set(['node_modules', 'dist', 'docs']);
58
63
 
59
- // Every directory under `packages/` and `src/` of the repository at <racine>: [{ nom, dir }].
60
- function tousDossiers(racine) {
61
- const found = [];
62
- for (const parent of ['packages', 'src']) {
63
- const base = path.join(racine, parent);
64
- if (!existsSync(base)) continue;
65
- for (const e of readdirSync(base, { withFileTypes: true })) {
66
- if (e.isDirectory()) found.push({ nom: e.name, dir: path.join(base, e.name) });
67
- }
68
- }
69
- return found;
70
- }
71
-
72
- // The component directories of the repository at <racine>: [{ nom, dir }], each directory under
73
- // `packages/` and `src/` that `docs/agents/hors-cadre.txt` does not list.
74
- function dossiers(racine) {
75
- const hors = horsCadre(racine);
76
- return tousDossiers(racine).filter(d => !hors.has(d.nom));
77
- }
78
-
79
- // The names of `docs/agents/hors-cadre.txt` that no directory under `packages/` or `src/` bears,
80
- // in the order of the list.
81
- export function horsCadreInconnus(racine) {
82
- const presents = new Set(tousDossiers(racine).map(d => d.nom));
83
- return [...horsCadre(racine)].filter(nom => !presents.has(nom));
84
- }
85
-
86
- // The components of the repository at <racine>: [{ nom, dir, paquet }], `paquet` its package name.
87
- // Throws when a package.json is unreadable.
88
- export function composants(racine) {
89
- return dossiers(racine).map(({ nom, dir }) => {
90
- const pj = path.join(dir, 'package.json');
91
- const paquet = existsSync(pj) ? (JSON.parse(readFileSync(pj, 'utf8')).name ?? null) : null;
92
- return { nom, dir, paquet };
93
- });
94
- }
95
-
96
- // The subpath export by which a component publishes the shared test material.
97
- const EXPORT_MATIERE = './test-fixtures';
98
-
99
- // The components of <racine> whose `package.json` exports `./test-fixtures`, in any form of its
100
- // value, a package out of the frame never one: the packages of the shared test material,
101
- // [{ nom, dir, paquet }] as `composants` gives.
102
- // A component whose `package.json` is unreadable is not a package of the material.
103
- export function matieres(racine) {
104
- const found = [];
105
- for (const { nom, dir } of dossiers(racine)) {
106
- const pj = path.join(dir, 'package.json');
107
- if (!existsSync(pj)) continue;
108
- let paquet;
109
- try {
110
- paquet = JSON.parse(readFileSync(pj, 'utf8'));
111
- } catch {
112
- continue;
113
- }
114
- const { exports } = paquet ?? {};
115
- if (exports !== null && typeof exports === 'object' && EXPORT_MATIERE in exports) {
116
- found.push({ nom, dir, paquet: paquet.name ?? null });
117
- }
118
- }
119
- return found;
120
- }
121
-
122
64
  // A name of a `## Consommateurs` line: a JavaScript identifier, or `*`.
123
65
  const NOM = /^(?:\*|[\p{ID_Start}$_][\p{ID_Continue}$‌‍]*)$/u;
124
66
 
@@ -126,7 +68,7 @@ const NOM = /^(?:\*|[\p{ID_Start}$_][\p{ID_Continue}$‌‍]*)$/u;
126
68
  // its one form ``- `<consommateur>` : <nom>, <nom>``: `{ consommateur, noms }`; `{ consommateur:
127
69
  // null, noms: null }` for a bullet of another form, with or without « : », or whose piece after
128
70
  // « : » is not a name (`NOM`), a bullet of prose; null for a line that is no bullet (a paragraph).
129
- // The one reading of such a line, for this guard and for scripts/consommateurs-arbitres.mjs.
71
+ // The one reading of such a line, for this guard and for scripts/langages/typescript/consommateurs-arbitres.mjs.
130
72
  export function lireLigne(ligne) {
131
73
  if (!/^[-*]\s+\S/.test(ligne)) return null;
132
74
  const m = /^[-*]\s+`?([^`:\s]+)`?\s*:\s*(.+)$/.exec(ligne);
@@ -143,7 +85,7 @@ export function lireLigne(ligne) {
143
85
 
144
86
  // The bullets of the section `## Consommateurs` of an interface text, each read by `lireLigne`:
145
87
  // [{ texte, consommateur, noms }]; a paragraph is none. The section ends at the next heading of any
146
- // level: the generated part (scripts/interfaces-contre-code.mjs) opens on the heading of its first
88
+ // level: the generated part (scripts/langages/typescript/interfaces-contre-code.mjs) opens on the heading of its first
147
89
  // element, so its bullets are never read.
148
90
  function lignesDeConsommateurs(texte) {
149
91
  const out = [];
@@ -0,0 +1,176 @@
1
+ #!/usr/bin/env node
2
+ // The build of an agent's copy before its session, the command `construire` of the module
3
+ // typescript (scripts/jointure.d.ts), which the launcher (scripts/enveloppe/lancer.sh) runs in the
4
+ // prepared copy, through its mounts: the session finds built what it reads out of its plan.
5
+ //
6
+ // node construire.mjs --echec <fichier> <plan> from the root of the copy
7
+ //
8
+ // - <plan> is the session's plan, the paths of the packages it writes, in the form of the
9
+ // envelope's variable (`lireLaListe` of the core's services, `packages/a:packages/b`).
10
+ // - As Bazel builds the dependencies of a target before the target: for a plan whose every path
11
+ // is a package of the frame, their providers are built first (the builds their builds wait for,
12
+ // read in Turborepo's graph, `turbo run build --filter=<paquet>… --dry=json`), and a failure
13
+ // stops the launch; then the traces of other packages their tests wait for
14
+ // (`grillhouse.traces`, read in Turborepo's plan of their tests, `turbo run test:unit
15
+ // --filter=<paquet>… --dry=json`), which the envelope shows read-only, and a failure stops the
16
+ // launch. A task of either step that waits, directly or not, for a task of a package of the plan
17
+ // (`attendentLePlan` of ./turbo-des-paquets.mjs) is not played there: as with Bazel's
18
+ // --keep_going, a package of the plan stays a target of the plan even as another's provider
19
+ // (BPScript's 990-corpus, the shared test material, which the trace of 060-encoder waits for),
20
+ // and goes with the plan. Then the packages, the traces of the plan or that wait for it, and what
21
+ // their tests read (`turbo run build <those traces> --filter=<paquet>...…
22
+ // --continue=dependencies-successful`), whose failure does not stop the launch: each task whose
23
+ // dependencies succeed goes to its end, so what their tests read without depending on them is
24
+ // built whole. Their consumers are not built.
25
+ // - Any other plan, the whole repository (`.`) included, or a path that is no package of the frame
26
+ // (BPScript's libraries/), reads the graph of the whole copy dry (`turbo run build --dry=json`),
27
+ // whose failure (Turborepo absent, its configuration refused) stops the launch, then builds the
28
+ // copy whole as far as it builds (`turbo run build --continue=dependencies-successful`), whose
29
+ // failure does not stop the launch either.
30
+ // - A build that fails without stopping the launch writes in <fichier> the line that says which
31
+ // build failed and what was built, then its output, which the launcher puts in the session's
32
+ // instruction (« La construction échoue »): repairing it is the session's work. Its output goes
33
+ // to the standard output too.
34
+ // - The exit code: 0 when the launch goes on, a build failure included; 1 for a step that stops it;
35
+ // 2 for a malformed call.
36
+ import { spawnSync } from 'node:child_process';
37
+ import { closeSync, openSync, readFileSync, writeFileSync } from 'node:fs';
38
+ import path from 'node:path';
39
+ import { pathToFileURL } from 'node:url';
40
+ import { paquets } from '../../paquets.mjs';
41
+ import { lireLaListe } from '../../services-du-noyau.mjs';
42
+ import { SCRIPT_DES_TESTS } from './script-des-tests.mjs';
43
+ import { attendentLePlan, tracesDuPlan } from './turbo-des-paquets.mjs';
44
+
45
+ const TURBO = ['--no-install', 'turbo'];
46
+ const ENTIERE =
47
+ "La construction de la copie entière échoue ; ce qui n'attend pas la construction en échec est construit.";
48
+ const DU_PLAN =
49
+ "La construction des paquets de ton plan échoue ; leurs fournisseurs et ce que leurs tests lisent sans dépendre d'eux sont construits.";
50
+
51
+ class Arret extends Error {}
52
+
53
+ // Turborepo with <args> in <racine>, its output on this process's; throws Arret on a failure.
54
+ function turbo(racine, args) {
55
+ const r = spawnSync('npx', [...TURBO, ...args], { cwd: racine, stdio: 'inherit' });
56
+ if (r.status !== 0) {
57
+ throw new Arret(`turbo ${args.join(' ')}`);
58
+ }
59
+ }
60
+
61
+ // Turborepo's plan of <args> in <racine>, parsed; throws Arret on a failure.
62
+ function plan(racine, args) {
63
+ const r = spawnSync('npx', [...TURBO, ...args, '--dry=json'], {
64
+ cwd: racine,
65
+ encoding: 'utf8',
66
+ maxBuffer: 256 * 1024 * 1024,
67
+ stdio: ['ignore', 'pipe', 'inherit'],
68
+ });
69
+ if (r.status !== 0) {
70
+ throw new Arret(`turbo ${args.join(' ')} --dry=json`);
71
+ }
72
+ return JSON.parse(r.stdout);
73
+ }
74
+
75
+ // The build <args> in <racine>, its output in <echec> then on this process's: when it fails,
76
+ // <echec> holds <ligne> then that output, and the warning <alerte> follows it.
77
+ function construireJusquOuIlConstruit(racine, args, echec, ligne, alerte) {
78
+ const fd = openSync(echec, 'w');
79
+ let r;
80
+ try {
81
+ r = spawnSync('npx', [...TURBO, ...args], { cwd: racine, stdio: ['ignore', fd, fd] });
82
+ } finally {
83
+ closeSync(fd);
84
+ }
85
+ const sortie = readFileSync(echec, 'utf8');
86
+ process.stdout.write(sortie);
87
+ if (r.status === 0) {
88
+ writeFileSync(echec, '');
89
+ return;
90
+ }
91
+ process.stdout.write(`${alerte}\n`);
92
+ writeFileSync(echec, `${ligne}\n${sortie}`);
93
+ }
94
+
95
+ /**
96
+ * Builds the copy at <racine> for the plan <liste>, the failure of a build that does not stop the
97
+ * launch written in <echec>: the exit code (see the header).
98
+ * @param {string} racine the root of the copy
99
+ * @param {string} liste the plan, in the form of the envelope's variable
100
+ * @param {string} echec the file of a build that fails
101
+ */
102
+ export function construire(racine, liste, echec) {
103
+ writeFileSync(echec, '');
104
+ const tous = paquets(racine).filter(p => !p.hors);
105
+ const noms = lireLaListe(liste).map(
106
+ d => tous.find(p => p.dossier === path.normalize(d).replace(/\/$/, ''))?.pkg.name ?? null
107
+ );
108
+ try {
109
+ if (noms.length === 0 || !noms.every(Boolean)) {
110
+ plan(racine, ['run', 'build']);
111
+ construireJusquOuIlConstruit(
112
+ racine,
113
+ ['run', 'build', '--continue=dependencies-successful'],
114
+ echec,
115
+ ENTIERE,
116
+ "⚠️ La construction de la copie échoue : la séance s'ouvre, la consigne porte l'erreur."
117
+ );
118
+ return 0;
119
+ }
120
+ const cibles = noms.map(n => `--filter=${n}`);
121
+ // Their providers: the builds their own builds wait for, save those that wait for a package
122
+ // of the plan, which go with the plan below.
123
+ const graphe = plan(racine, ['run', 'build', ...cibles]);
124
+ const avecLePlan = attendentLePlan(graphe, noms);
125
+ const fournisseurs = graphe.tasks
126
+ .map(t => t.taskId)
127
+ .filter(id => !avecLePlan.has(id))
128
+ .sort();
129
+ if (fournisseurs.length) {
130
+ turbo(racine, ['run', ...fournisseurs]);
131
+ }
132
+ // The traces their tests wait for: another package's trace that waits for no package of the
133
+ // plan is produced here, a failure stopping the launch, as a provider's; a trace of the plan,
134
+ // or one that waits for it, is produced with the plan below.
135
+ const tests = plan(racine, ['run', SCRIPT_DES_TESTS, ...cibles]);
136
+ const attend = attendentLePlan(tests, noms);
137
+ const autres = tracesDuPlan(tests, t => !attend.has(t.taskId));
138
+ if (autres.length) {
139
+ turbo(racine, ['run', ...autres]);
140
+ }
141
+ const avec = tracesDuPlan(tests, t => attend.has(t.taskId));
142
+ construireJusquOuIlConstruit(
143
+ racine,
144
+ [
145
+ 'run',
146
+ 'build',
147
+ ...avec,
148
+ ...noms.map(n => `--filter=${n}...`),
149
+ '--continue=dependencies-successful',
150
+ ],
151
+ echec,
152
+ DU_PLAN,
153
+ `⚠️ La construction du plan (${noms.join(' ')}) échoue : la séance s'ouvre, la consigne porte l'erreur.`
154
+ );
155
+ return 0;
156
+ } catch (e) {
157
+ if (!(e instanceof Arret)) {
158
+ throw e;
159
+ }
160
+ process.stderr.write(`⛔ ${e.message} échoue.\n`);
161
+ return 1;
162
+ }
163
+ }
164
+
165
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
166
+ const args = process.argv.slice(2);
167
+ const i = args.indexOf('--echec');
168
+ const echec = i >= 0 ? args[i + 1] : undefined;
169
+ const reste = i >= 0 ? [...args.slice(0, i), ...args.slice(i + 2)] : args;
170
+ if (!echec || reste.length !== 1) {
171
+ process.stderr.write('usage: construire.mjs --echec <fichier> <plan>\n');
172
+ process.exitCode = 2;
173
+ } else {
174
+ process.exitCode = construire(process.cwd(), reste[0], echec);
175
+ }
176
+ }
@@ -9,14 +9,14 @@
9
9
  // the lot the circuit keeps): its changed files by `git diff --name-status -z`, the text of a
10
10
  // file before by `git show <avant>:<fichier>`.
11
11
  // - The declarations are read by TypeScript's language service over the components'
12
- // `tsconfig.json` (`leService` of scripts/references-par-les-types.mjs): the production
12
+ // `tsconfig.json` (`leService` of scripts/langages/typescript/references-par-les-types.mjs): the production
13
13
  // sources it reads, the tests and the declaration files left out; the file before, by
14
14
  // TypeScript's parser. A declaration of the lot is new when its name is not in the file before,
15
15
  // removed when it is not in the file after, and changed when its text differs (its TSDoc
16
16
  // comment included), as the declarations of the reports are compared.
17
17
  // - An element is exported when the entry of its package exports it (the service's symbols), or
18
18
  // when the API report of its package names it (`docs/INTERFACE.api.md`, which
19
- // scripts/interfaces-contre-code.mjs writes): after the lot for a new or changed one, before
19
+ // scripts/langages/typescript/interfaces-contre-code.mjs writes): after the lot for a new or changed one, before
20
20
  // it for a removed one. A declaration of a report that the lot adds, changes or removes, and
21
21
  // that no element of its package's sources already names (a type that changed through another),
22
22
  // is an element of the report itself, exported.