@roomi-fields/grillhouse 0.29.0 → 0.31.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 (263) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +769 -0
  3. package/agents/developpeur.md +0 -1
  4. package/agents/explorateur.md +0 -1
  5. package/agents/questionneur.md +0 -1
  6. package/agents/testwriter.md +0 -1
  7. package/bin/grillhouse.mjs +79 -18
  8. package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
  9. package/cadre/templates/projet/CLAUDE.md +5 -1
  10. package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
  11. package/cadre/templates/projet/package.json +2 -2
  12. package/charte.md +24 -0
  13. package/dist/temporal/acte.d.ts +24 -0
  14. package/dist/temporal/acte.js +139 -0
  15. package/dist/temporal/acte.js.map +1 -0
  16. package/dist/temporal/attributs.d.ts +6 -0
  17. package/dist/temporal/attributs.js +15 -0
  18. package/dist/temporal/attributs.js.map +1 -0
  19. package/dist/temporal/circuit/activites.d.ts +13 -0
  20. package/dist/temporal/circuit/activites.js +33 -0
  21. package/dist/temporal/circuit/activites.js.map +1 -0
  22. package/dist/temporal/circuit/client.d.ts +72 -0
  23. package/dist/temporal/circuit/client.js +247 -0
  24. package/dist/temporal/circuit/client.js.map +1 -0
  25. package/dist/temporal/circuit/commande.d.ts +2 -0
  26. package/dist/temporal/circuit/commande.js +238 -0
  27. package/dist/temporal/circuit/commande.js.map +1 -0
  28. package/dist/temporal/circuit/contrat.d.ts +305 -0
  29. package/dist/temporal/circuit/contrat.js +30 -0
  30. package/dist/temporal/circuit/contrat.js.map +1 -0
  31. package/dist/temporal/circuit/deroule.d.ts +3 -0
  32. package/dist/temporal/circuit/deroule.js +540 -0
  33. package/dist/temporal/circuit/deroule.js.map +1 -0
  34. package/dist/temporal/client.d.ts +47 -0
  35. package/dist/temporal/client.js +69 -0
  36. package/dist/temporal/client.js.map +1 -0
  37. package/dist/temporal/commande.d.ts +2 -0
  38. package/dist/temporal/commande.js +94 -0
  39. package/dist/temporal/commande.js.map +1 -0
  40. package/dist/temporal/deroules.d.ts +5 -0
  41. package/dist/temporal/deroules.js +10 -0
  42. package/dist/temporal/deroules.js.map +1 -0
  43. package/dist/temporal/etat.d.ts +33 -0
  44. package/dist/temporal/etat.js +59 -0
  45. package/dist/temporal/etat.js.map +1 -0
  46. package/dist/temporal/file/activites.d.ts +10 -0
  47. package/dist/temporal/file/activites.js +25 -0
  48. package/dist/temporal/file/activites.js.map +1 -0
  49. package/dist/temporal/file/client.d.ts +4 -0
  50. package/dist/temporal/file/client.js +6 -0
  51. package/dist/temporal/file/client.js.map +1 -0
  52. package/dist/temporal/file/contrat.d.ts +158 -0
  53. package/dist/temporal/file/contrat.js +14 -0
  54. package/dist/temporal/file/contrat.js.map +1 -0
  55. package/dist/temporal/file/deroule.d.ts +15 -0
  56. package/dist/temporal/file/deroule.js +235 -0
  57. package/dist/temporal/file/deroule.js.map +1 -0
  58. package/dist/temporal/installation.d.ts +120 -0
  59. package/dist/temporal/installation.js +386 -0
  60. package/dist/temporal/installation.js.map +1 -0
  61. package/dist/temporal/places/activites.d.ts +8 -0
  62. package/dist/temporal/places/activites.js +13 -0
  63. package/dist/temporal/places/activites.js.map +1 -0
  64. package/dist/temporal/places/client.d.ts +28 -0
  65. package/dist/temporal/places/client.js +64 -0
  66. package/dist/temporal/places/client.js.map +1 -0
  67. package/dist/temporal/places/contrat.d.ts +106 -0
  68. package/dist/temporal/places/contrat.js +21 -0
  69. package/dist/temporal/places/contrat.js.map +1 -0
  70. package/dist/temporal/places/deroule.d.ts +3 -0
  71. package/dist/temporal/places/deroule.js +198 -0
  72. package/dist/temporal/places/deroule.js.map +1 -0
  73. package/dist/temporal/sonde/activites.d.ts +6 -0
  74. package/dist/temporal/sonde/activites.js +52 -0
  75. package/dist/temporal/sonde/activites.js.map +1 -0
  76. package/dist/temporal/sonde/contrat.d.ts +35 -0
  77. package/dist/temporal/sonde/contrat.js +10 -0
  78. package/dist/temporal/sonde/contrat.js.map +1 -0
  79. package/dist/temporal/sonde/deroule.d.ts +3 -0
  80. package/dist/temporal/sonde/deroule.js +39 -0
  81. package/dist/temporal/sonde/deroule.js.map +1 -0
  82. package/dist/temporal/tickets/activites.d.ts +7 -0
  83. package/dist/temporal/tickets/activites.js +81 -0
  84. package/dist/temporal/tickets/activites.js.map +1 -0
  85. package/dist/temporal/tickets/client.d.ts +10 -0
  86. package/dist/temporal/tickets/client.js +31 -0
  87. package/dist/temporal/tickets/client.js.map +1 -0
  88. package/dist/temporal/tickets/contrat.d.ts +56 -0
  89. package/dist/temporal/tickets/contrat.js +13 -0
  90. package/dist/temporal/tickets/contrat.js.map +1 -0
  91. package/dist/temporal/tickets/deroule.d.ts +3 -0
  92. package/dist/temporal/tickets/deroule.js +94 -0
  93. package/dist/temporal/tickets/deroule.js.map +1 -0
  94. package/dist/temporal/travailleur.d.ts +2 -0
  95. package/dist/temporal/travailleur.js +69 -0
  96. package/dist/temporal/travailleur.js.map +1 -0
  97. package/docs/ARCHITECTURE.md +646 -87
  98. package/docs/CADRE.md +27 -0
  99. package/docs/INTERFACE.md +139 -42
  100. package/hooks/crochet.mjs +19 -2
  101. package/hooks/hooks.json +11 -0
  102. package/package.json +16 -4
  103. package/scripts/activites.mjs +2255 -0
  104. package/scripts/aiguillage.d.mts +37 -0
  105. package/scripts/aiguillage.mjs +40 -14
  106. package/scripts/avancement.mjs +155 -26
  107. package/scripts/bilan.mjs +137 -43
  108. package/scripts/cadre.mjs +16 -4
  109. package/scripts/circuit.mjs +993 -4075
  110. package/scripts/circuits-cles.d.mts +4 -0
  111. package/scripts/circuits-cles.mjs +21 -0
  112. package/scripts/circuits-du-serveur.mjs +105 -0
  113. package/scripts/codes-de-sortie.mjs +9 -0
  114. package/scripts/commandes-composees.mjs +45 -41
  115. package/scripts/commandes-du-path.d.mts +7 -0
  116. package/scripts/commandes-du-path.mjs +25 -0
  117. package/scripts/composants-affectes.mjs +64 -21
  118. package/scripts/composition-des-langages.mjs +18 -12
  119. package/scripts/conformite.mjs +56 -28
  120. package/scripts/copies-finies.mjs +52 -47
  121. package/scripts/depart-du-ticket.d.mts +53 -0
  122. package/scripts/depart-du-ticket.mjs +124 -0
  123. package/scripts/dependances-internes.mjs +121 -0
  124. package/scripts/dernier-vert.mjs +61 -34
  125. package/scripts/dette.mjs +32 -11
  126. package/scripts/donnees-cles.mjs +244 -0
  127. package/scripts/droits.mjs +51 -16
  128. package/scripts/effets.mjs +352 -0
  129. package/scripts/empreinte-d-etape.mjs +17 -0
  130. package/scripts/engendres.mjs +15 -5
  131. package/scripts/enveloppe/enveloppe.mjs +259 -55
  132. package/scripts/enveloppe/lancer.sh +14 -18
  133. package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
  134. package/scripts/enveloppe/travail-de-la-copie.mjs +41 -13
  135. package/scripts/etapes.mjs +5 -2
  136. package/scripts/faits-du-circuit.mjs +493 -0
  137. package/scripts/file-des-tickets.d.mts +21 -0
  138. package/scripts/file-des-tickets.mjs +58 -0
  139. package/scripts/flux-des-paquets.mjs +201 -0
  140. package/scripts/gardes-du-cadre.mjs +21 -5
  141. package/scripts/init.mjs +11 -4
  142. package/scripts/integration/file.mjs +544 -434
  143. package/scripts/integration/integrer.mjs +87 -43
  144. package/scripts/integration/rejeu.mjs +45 -13
  145. package/scripts/jointure.d.ts +151 -28
  146. package/scripts/langages/cargo/commandes.mjs +383 -124
  147. package/scripts/langages/cargo/composants.mjs +154 -42
  148. package/scripts/langages/cargo/exemples.mjs +12 -21
  149. package/scripts/langages/cargo/index.mjs +22 -8
  150. package/scripts/langages/cargo/sccache.mjs +8 -14
  151. package/scripts/langages/cargo/tests-de-head.mjs +25 -9
  152. package/scripts/langages/python/commandes.mjs +218 -100
  153. package/scripts/langages/python/composants.mjs +53 -21
  154. package/scripts/langages/python/exemples.mjs +6 -16
  155. package/scripts/langages/python/index.mjs +28 -8
  156. package/scripts/langages/python/lot.mjs +1 -36
  157. package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
  158. package/scripts/langages/typescript/composants.mjs +9 -3
  159. package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
  160. package/scripts/langages/typescript/consommateurs.mjs +39 -14
  161. package/scripts/langages/typescript/construire.mjs +6 -163
  162. package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
  163. package/scripts/langages/typescript/exemples.mjs +3 -11
  164. package/scripts/langages/typescript/frontieres.mjs +66 -22
  165. package/scripts/langages/typescript/index-interfaces.mjs +36 -13
  166. package/scripts/langages/typescript/index.mjs +50 -61
  167. package/scripts/langages/typescript/interfaces-contre-code.mjs +113 -45
  168. package/scripts/langages/typescript/lecteurs.mjs +36 -11
  169. package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
  170. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
  171. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
  172. package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
  173. package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +33 -0
  174. package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
  175. package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
  176. package/scripts/langages/typescript/parcours.mjs +12 -4
  177. package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
  178. package/scripts/langages/typescript/resumes.mjs +9 -3
  179. package/scripts/langages/typescript/tailles-des-tests.mjs +93 -20
  180. package/scripts/langages/typescript/tests-de-nuit.mjs +15 -10
  181. package/scripts/langages/typescript/tests.mjs +40 -15
  182. package/scripts/langages/typescript/titres-de-tests.mjs +320 -0
  183. package/scripts/langages/typescript/turbo-des-paquets.mjs +327 -81
  184. package/scripts/langages/typescript/verdict.mjs +4 -2
  185. package/scripts/langages/typescript/verifier.mjs +58 -20
  186. package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
  187. package/scripts/langages/typescript/vitest-config/base.mjs +29 -3
  188. package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
  189. package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
  190. package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
  191. package/scripts/langages/typescript/vitest-config/delais.mjs +60 -0
  192. package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
  193. package/scripts/langages/typescript/vitest-config/duree.classement.mjs +108 -0
  194. package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +56 -59
  195. package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
  196. package/scripts/langages/typescript/vitest-config/machine.setup.mjs +10 -0
  197. package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
  198. package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
  199. package/scripts/lint-des-scripts.mjs +58 -0
  200. package/scripts/mesure/base-de-passe.mjs +117 -25
  201. package/scripts/mesure/pression.mjs +12 -6
  202. package/scripts/mesure-de-la-machine.d.mts +21 -0
  203. package/scripts/mesure-de-la-machine.mjs +76 -0
  204. package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
  205. package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
  206. package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
  207. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +56 -18
  208. package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
  209. package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
  210. package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +124 -0
  211. package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
  212. package/scripts/migrations.mjs +5 -0
  213. package/scripts/nuit.sh +25 -3
  214. package/scripts/outil.mjs +3 -1
  215. package/scripts/outils-cles.d.mts +24 -0
  216. package/scripts/outils-cles.mjs +18 -8
  217. package/scripts/paquet-npm.mjs +157 -0
  218. package/scripts/paquet.mjs +73 -4
  219. package/scripts/paquets.mjs +46 -10
  220. package/scripts/passe-de-la-machine.mjs +71 -0
  221. package/scripts/places-de-la-machine.mjs +414 -0
  222. package/scripts/places-du-serveur.mjs +170 -0
  223. package/scripts/prefixe-des-tickets.mjs +68 -0
  224. package/scripts/preparation.mjs +25 -8
  225. package/scripts/registre.mjs +9 -4
  226. package/scripts/regles-des-places.d.mts +36 -0
  227. package/scripts/regles-des-places.mjs +70 -0
  228. package/scripts/reponses-du-circuit.d.mts +6 -0
  229. package/scripts/reponses-du-circuit.mjs +28 -0
  230. package/scripts/reprise.mjs +66 -0
  231. package/scripts/resultats.mjs +112 -46
  232. package/scripts/retirer-les-copies-finies.mjs +25 -0
  233. package/scripts/sans-reponse.d.mts +4 -0
  234. package/scripts/sans-reponse.mjs +13 -0
  235. package/scripts/seances.mjs +936 -0
  236. package/scripts/services-du-noyau.mjs +27 -8
  237. package/scripts/session-start.sh +2 -2
  238. package/scripts/sortie.mjs +3 -3
  239. package/scripts/sous-commandes.mjs +41 -10
  240. package/scripts/style-a-l-ecriture.mjs +260 -0
  241. package/scripts/superviseur.mjs +122 -111
  242. package/scripts/tableau.mjs +180 -117
  243. package/scripts/taches-du-graphe.mjs +348 -0
  244. package/scripts/ticket-du-circuit.mjs +216 -0
  245. package/scripts/transitions.d.mts +148 -0
  246. package/scripts/transitions.mjs +1018 -0
  247. package/scripts/verrou-de-fichier.mjs +8 -4
  248. package/scripts/verrou-de-machine.mjs +150 -51
  249. package/scripts/verrous/commande.mjs +50 -17
  250. package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
  251. package/scripts/verrous/verrou.mjs +42 -14
  252. package/skills/explorateur/SKILL.md +9 -2
  253. package/skills/grill/SKILL.md +1 -1
  254. package/skills/mesure/SKILL.md +3 -0
  255. package/skills/pitmaster/SKILL.md +17 -18
  256. package/skills/pitmaster/references/consigne-agent.md +5 -1
  257. package/skills/release/SKILL.md +3 -3
  258. package/skills/relecteur/SKILL.md +5 -3
  259. package/skills/testwriter/SKILL.md +49 -31
  260. package/scripts/demon.mjs +0 -251
  261. package/scripts/integration/file-attente.mjs +0 -61
  262. package/scripts/langages/cargo/touches.mjs +0 -93
  263. package/scripts/langages/typescript/script-des-tests.mjs +0 -6
@@ -34,13 +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
+ // - Only the measure of the changed files and the keeping of the green live here: the files go to
38
+ // `vitest --changed`, and no module of language chooses the packages it plays by the last green
39
+ // (the tests of a crate or a Python project are tasks of Turborepo, which its cache selects).
40
+ // The green is kept by the one pass of the verification (scripts/langages/typescript/verifier.mjs),
41
+ // once, when every task of every language of the graph is green, and never when one is red.
41
42
  import { spawnSync } from 'node:child_process';
42
43
  import {
43
- appendFileSync,
44
44
  copyFileSync,
45
45
  existsSync,
46
46
  mkdirSync,
@@ -56,9 +56,6 @@ import path from 'node:path';
56
56
  // tests of the module of the language reads in each package.
57
57
  export const CHANGEMENTS = 'GRILLHOUSE_CHANGEMENTS';
58
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';
62
59
  const SHA = /^[0-9a-f]{40,64}$/;
63
60
 
64
61
  const git = (racine, args, env = process.env) =>
@@ -91,7 +88,9 @@ function brancheDeMain(racine) {
91
88
  // Whether a submodule of the repository at <racine> differs from the commit its parent records.
92
89
  function sousModuleModifie(racine) {
93
90
  const r = git(racine, ['status', '--porcelain=v2', '-z', '--ignore-submodules=none']);
94
- if (r.status !== 0) return true;
91
+ if (r.status !== 0) {
92
+ return true;
93
+ }
95
94
  // An entry of a changed path: `1 <XY> <sub> …` (or `2` for a rename), <sub> `S<c><m><u>` for a
96
95
  // submodule whose commit, tracked files or untracked files changed, `N...` for any other path.
97
96
  return r.stdout.split('\0').some(e => /^[12] \S+ S/.test(e));
@@ -102,21 +101,34 @@ function sousModuleModifie(racine) {
102
101
  // detached) and main (brancheDeMain); `{ raison }` when no last green can count.
103
102
  function etatDuDepot(racine) {
104
103
  const haut = sortie(racine, ['rev-parse', '--show-toplevel']);
105
- if (!haut) return { raison: 'hors de git' };
104
+ if (!haut) {
105
+ return { raison: 'hors de git' };
106
+ }
106
107
  const top = realpathSync(haut);
107
108
  const commit = sortie(top, ['rev-parse', '--verify', '-q', 'HEAD^{commit}']);
108
- if (!commit) return { raison: 'aucun commit' };
109
- if (sousModuleModifie(top)) return { raison: 'un sous-module diffère de son commit' };
109
+ if (!commit) {
110
+ return { raison: 'aucun commit' };
111
+ }
112
+ if (sousModuleModifie(top)) {
113
+ return { raison: 'un sous-module diffère de son commit' };
114
+ }
110
115
  const dir = mkdtempSync(path.join(os.tmpdir(), 'grillhouse-vert-'));
111
116
  try {
112
117
  const index = path.join(dir, 'index');
113
118
  const reel = sortie(top, ['rev-parse', '--path-format=absolute', '--git-path', 'index']);
114
119
  const env = { ...process.env, GIT_INDEX_FILE: index };
115
- if (reel && existsSync(reel)) copyFileSync(reel, index);
116
- else if (git(top, ['read-tree', 'HEAD'], env).status !== 0) return { raison: 'git échoue' };
117
- if (git(top, ['add', '-A'], env).status !== 0) return { raison: 'git échoue' };
120
+ if (reel && existsSync(reel)) {
121
+ copyFileSync(reel, index);
122
+ } else if (git(top, ['read-tree', 'HEAD'], env).status !== 0) {
123
+ return { raison: 'git échoue' };
124
+ }
125
+ if (git(top, ['add', '-A'], env).status !== 0) {
126
+ return { raison: 'git échoue' };
127
+ }
118
128
  const arbre = sortie(top, ['write-tree'], env);
119
- if (!arbre) return { raison: 'git échoue' };
129
+ if (!arbre) {
130
+ return { raison: 'git échoue' };
131
+ }
120
132
  const branche = sortie(top, ['symbolic-ref', '--short', '-q', 'HEAD']);
121
133
  return { racine: top, commit, arbre, branche, main: brancheDeMain(top) };
122
134
  } finally {
@@ -132,7 +144,9 @@ function lireLeVert(etat) {
132
144
  let vert = { raison: 'aucun vert connu' };
133
145
  for (const branche of branches) {
134
146
  vert = lireLeVertDe(etat, branche);
135
- if (!vert.raison) return vert;
147
+ if (!vert.raison) {
148
+ return vert;
149
+ }
136
150
  }
137
151
  return vert;
138
152
  }
@@ -159,16 +173,13 @@ function lireLeVertDe(etat, branche) {
159
173
  return { commit: v.commit, arbre: v.arbre, branche };
160
174
  }
161
175
 
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
- }
176
+ // Keeps <etat> (etatDuDepot) as the last green of its branch, of main when HEAD is detached.
177
+ export function garderLeVert(etat) {
169
178
  const branche = etat.branche ?? etat.main;
170
179
  const f = branche ? fichierDuVert(etat.racine, branche) : null;
171
- if (!f) return;
180
+ if (!f) {
181
+ return;
182
+ }
172
183
  mkdirSync(path.dirname(f), { recursive: true });
173
184
  writeFileSync(f, `${JSON.stringify({ commit: etat.commit, arbre: etat.arbre }, null, 2)}\n`);
174
185
  }
@@ -177,15 +188,21 @@ export function garderLeVert(etat, env = process.env) {
177
188
  // `{ fichiers, supprimes, sousModules }`, each path from its top; null when git fails.
178
189
  function difference(racine, avant, apres) {
179
190
  const r = git(racine, ['diff', '--raw', '--no-renames', '-z', avant, apres]);
180
- if (r.status !== 0) return null;
191
+ if (r.status !== 0) {
192
+ return null;
193
+ }
181
194
  const champs = r.stdout.split('\0');
182
195
  const out = { fichiers: [], supprimes: [], sousModules: [] };
183
196
  for (let i = 0; i + 1 < champs.length; i += 2) {
184
197
  const [modeAvant, modeApres, , , statut] = champs[i].replace(/^:/, '').split(' ');
185
198
  const f = champs[i + 1];
186
- if (modeAvant === '160000' || modeApres === '160000') out.sousModules.push(f);
187
- else if (statut === 'D') out.supprimes.push(f);
188
- else out.fichiers.push(f);
199
+ if (modeAvant === '160000' || modeApres === '160000') {
200
+ out.sousModules.push(f);
201
+ } else if (statut === 'D') {
202
+ out.supprimes.push(f);
203
+ } else {
204
+ out.fichiers.push(f);
205
+ }
189
206
  }
190
207
  return out;
191
208
  }
@@ -219,18 +236,28 @@ export function mesure(racine, { tout = false, dans = os.tmpdir() } = {}) {
219
236
  ligne: `↳ passe complète : ${raison}.`,
220
237
  retirer: () => {},
221
238
  });
222
- if (etat.raison) return complete(etat.raison);
223
- if (tout) return complete('demandée');
239
+ if (etat.raison) {
240
+ return complete(etat.raison);
241
+ }
242
+ if (tout) {
243
+ return complete('demandée');
244
+ }
224
245
  const vert = lireLeVert(etat);
225
- if (vert.raison) return complete(vert.raison);
246
+ if (vert.raison) {
247
+ return complete(vert.raison);
248
+ }
226
249
  const ch = difference(etat.racine, vert.arbre, etat.arbre);
227
- if (!ch) return complete('git échoue');
250
+ if (!ch) {
251
+ return complete('git échoue');
252
+ }
228
253
  if (ch.sousModules.length) {
229
254
  return { ...complete(`un sous-module a changé (${ch.sousModules[0]})`), etat: null };
230
255
  }
231
256
  if (vert.branche !== etat.branche) {
232
257
  const suivis = supprimesDuCommit(etat.racine, vert.commit, etat.arbre);
233
- if (!suivis) return complete('git échoue');
258
+ if (!suivis) {
259
+ return complete('git échoue');
260
+ }
234
261
  ch.supprimes = ch.supprimes.filter(f => suivis.has(f));
235
262
  }
236
263
  const dir = mkdtempSync(path.join(dans, 'grillhouse-changements-'));
package/scripts/dette.mjs CHANGED
@@ -42,7 +42,9 @@ const inscriptible = c => Boolean(c.fichier && c.regle);
42
42
  function compter(constats) {
43
43
  const out = new Map();
44
44
  for (const c of constats.filter(inscriptible)) {
45
- if (!out.has(c.fichier)) out.set(c.fichier, new Map());
45
+ if (!out.has(c.fichier)) {
46
+ out.set(c.fichier, new Map());
47
+ }
46
48
  const parRegle = out.get(c.fichier);
47
49
  parRegle.set(c.regle, (parRegle.get(c.regle) ?? 0) + 1);
48
50
  }
@@ -65,7 +67,9 @@ function section(comptes) {
65
67
  // The debt written at <racine>: {} without the file. Throws, naming the file, when it is not JSON.
66
68
  export function lire(racine) {
67
69
  const f = path.join(racine, FICHIER);
68
- if (!existsSync(f)) return {};
70
+ if (!existsSync(f)) {
71
+ return {};
72
+ }
69
73
  try {
70
74
  return JSON.parse(readFileSync(f, 'utf8'));
71
75
  } catch (e) {
@@ -91,8 +95,12 @@ export function elaguer(dette, garde, constats) {
91
95
  for (const [fichier, regles] of Object.entries(ancienne)) {
92
96
  for (const [regle, { count }] of Object.entries(regles)) {
93
97
  const n = Math.min(count, comptes.get(fichier)?.get(regle) ?? 0);
94
- if (n === 0) continue;
95
- if (!garde2.has(fichier)) garde2.set(fichier, new Map());
98
+ if (n === 0) {
99
+ continue;
100
+ }
101
+ if (!garde2.has(fichier)) {
102
+ garde2.set(fichier, new Map());
103
+ }
96
104
  garde2.get(fichier).set(regle, n);
97
105
  }
98
106
  }
@@ -114,14 +122,18 @@ export function juger(dette, garde, constats) {
114
122
  for (const [fichier, regles] of comptes) {
115
123
  for (const [regle, trouve] of regles) {
116
124
  const inscrit = permis(fichier, regle);
117
- if (inscrit > 0 && trouve > inscrit) depasses.push({ fichier, regle, trouve, inscrit });
125
+ if (inscrit > 0 && trouve > inscrit) {
126
+ depasses.push({ fichier, regle, trouve, inscrit });
127
+ }
118
128
  }
119
129
  }
120
130
  const corriges = [];
121
131
  for (const [fichier, regles] of Object.entries(inscrite)) {
122
132
  for (const [regle, { count }] of Object.entries(regles)) {
123
133
  const trouve = comptes.get(fichier)?.get(regle) ?? 0;
124
- if (trouve < count) corriges.push({ fichier, regle, trouve, inscrit: count });
134
+ if (trouve < count) {
135
+ corriges.push({ fichier, regle, trouve, inscrit: count });
136
+ }
125
137
  }
126
138
  }
127
139
  return { refus, depasses, corriges, tus: constats.length - refus.length };
@@ -170,17 +182,25 @@ function abaisser(racine, notes) {
170
182
  for (const { garde, fichier, regle, trouve } of notes) {
171
183
  const parRegle = dette[garde]?.[fichier];
172
184
  const cle = parRegle?.[regle];
173
- if (!cle || !Number.isInteger(trouve) || trouve >= cle.count) continue;
185
+ if (!cle || !Number.isInteger(trouve) || trouve >= cle.count) {
186
+ continue;
187
+ }
174
188
  if (trouve > 0) {
175
189
  cle.count = trouve;
176
190
  continue;
177
191
  }
178
192
  delete parRegle[regle];
179
- if (!Object.keys(parRegle).length) delete dette[garde][fichier];
180
- if (!Object.keys(dette[garde]).length) delete dette[garde];
193
+ if (!Object.keys(parRegle).length) {
194
+ delete dette[garde][fichier];
195
+ }
196
+ if (!Object.keys(dette[garde]).length) {
197
+ delete dette[garde];
198
+ }
181
199
  }
182
200
  const change = JSON.stringify(dette) !== JSON.stringify(avant);
183
- if (change) ecrire(racine, dette);
201
+ if (change) {
202
+ ecrire(racine, dette);
203
+ }
184
204
  return change;
185
205
  }
186
206
 
@@ -217,8 +237,9 @@ function juge(racine, garde, constats, mode) {
217
237
  `⚠️ ${garde} : ${c.fichier} · ${c.regle} — ${c.trouve} constat(s) pour ${c.inscrit} inscrit(s) dans ${FICHIER} : npm run grillhouse:dette:elaguer retire ce qui est corrigé.`
218
238
  );
219
239
  }
220
- if (tus > 0)
240
+ if (tus > 0) {
221
241
  lignes.push(`ℹ️ ${garde} : ${tus} constat(s) connu(s), inscrit(s) dans ${FICHIER}.`);
242
+ }
222
243
  return { refus, lignes, corriges };
223
244
  }
224
245
 
@@ -0,0 +1,244 @@
1
+ #!/usr/bin/env node
2
+ // The reading of the `grillhouse.donnees` key of a package.json, the data of a package, as Bazel's
3
+ // `data` declare the output of another target that a test runs (`data = ["//crates/service:bin"]`):
4
+ // `{ "<VARIABLE>": "<paquet>#<sortie>" }`. The consumer lists the provider in its `devDependencies`,
5
+ // so that Turborepo builds the provider before the consumer's tests (`^build`,
6
+ // scripts/langages/typescript/turbo-des-paquets.mjs), even when the provider is out of the plan; the
7
+ // variable carries the absolute path of the built output, which `npm test`, `npm run verifier`
8
+ // (bin/grillhouse.mjs), the circuit (scripts/circuit.mjs), the envelope, the integration and the
9
+ // night pass to the tests as they pass `grillhouse.outils` (scripts/outils-cles.mjs).
10
+ //
11
+ // - The key is absent, null or an object; each name is a variable's (`[A-Za-z_][A-Za-z0-9_]*`),
12
+ // each value of the form `<paquet>#<sortie>`: a package of the repository by its package.json
13
+ // name, in the `devDependencies` of the consumer, and an output its language knows. Every fault is
14
+ // named with its key (`grillhouse.donnees.<VARIABLE>`), one per line; a faulty key gives no
15
+ // variable, before any work.
16
+ // - The output is asked of the language of the provider (`sortieDuPaquet`, scripts/jointure.d.ts):
17
+ // for a crate, a binary (target of kind `bin`) of `cargo metadata`, in its target directory, under
18
+ // `release` when the `build` script of the provider's package.json carries `--release`, `debug`
19
+ // otherwise; another language is refused, « sortie non prise en charge pour <langage> ».
20
+ // - The consumers are the root and the packages of the main tree of the repository (`arbrePrincipal`,
21
+ // scripts/outils-cles.mjs); the paths are resolved from the directory given, the copy.
22
+ // - `controlerLesDonnees` runs after the build: an output absent at its path is refused, the
23
+ // variable and the path named.
24
+ // - `node donnees-cles.mjs <dir>` writes one line `export VARIABLE='chemin'` per datum of the
25
+ // project that holds <dir> (`exportsDesDonnees`), which the night evaluates, exit 0; a faulty key
26
+ // writes its faults on stderr, exit 1.
27
+ import { existsSync, readFileSync } from 'node:fs';
28
+ import path from 'node:path';
29
+ import { pathToFileURL } from 'node:url';
30
+ import { LANGAGES, langage } from './langages.mjs';
31
+ import { arbrePrincipal } from './outils-cles.mjs';
32
+ import { paquets } from './paquets.mjs';
33
+ import { paquetsSansPackageJson } from './paquet-npm.mjs';
34
+
35
+ const NOM = /^[A-Za-z_][A-Za-z0-9_]*$/;
36
+ const FORME = /^([^#\s]+)#([^#\s]+)$/;
37
+ const RELEASE = /(^|\s)--release(\s|$)/;
38
+
39
+ // The language of the package at <chemin> (from <racine>): the one whose manifest is not the
40
+ // package.json when the tables declare it so, else the language of the package.json.
41
+ function langageDuPaquet(racine, chemin) {
42
+ const hors = paquetsSansPackageJson(racine).find(p => p.chemin === chemin);
43
+ if (hors) {
44
+ return hors.langage;
45
+ }
46
+ return Object.keys(LANGAGES).find(n => langage(n).manifeste === 'package.json') ?? 'typescript';
47
+ }
48
+
49
+ const lireJson = f => {
50
+ try {
51
+ return JSON.parse(readFileSync(f, 'utf8'));
52
+ } catch {
53
+ return null;
54
+ }
55
+ };
56
+
57
+ // The data the project of <dir> declares: { donnees, parPaquet, fautes }, `parPaquet` the variables
58
+ // of each consumer by its folder from the root.
59
+ function lire(dir) {
60
+ const racine = arbrePrincipal(dir);
61
+ const fautes = [];
62
+ /** @type {Record<string, string>} */
63
+ const donnees = {};
64
+ /** @type {Map<string, string[]>} */
65
+ const parPaquet = new Map();
66
+ /** @type {Map<string, string[]>} */
67
+ const fournisseurs = new Map();
68
+ const racinePkg = lireJson(path.join(racine, 'package.json'));
69
+ if (racinePkg === null) {
70
+ return { donnees, parPaquet, fournisseurs, fautes };
71
+ }
72
+ const liste = paquets(racine);
73
+ const consommateurs = [{ dossier: '.', pkg: racinePkg }, ...liste];
74
+ for (const { dossier, pkg } of consommateurs) {
75
+ const d = pkg?.grillhouse?.donnees;
76
+ if (d === undefined || d === null) {
77
+ continue;
78
+ }
79
+ const ou = dossier === '.' ? 'package.json' : `${dossier}/package.json`;
80
+ if (typeof d !== 'object' || Array.isArray(d)) {
81
+ fautes.push(
82
+ `${ou} : la clé grillhouse.donnees vaut ${JSON.stringify(d)}, pas un objet { VARIABLE: "<paquet>#<sortie>" }.`
83
+ );
84
+ continue;
85
+ }
86
+ for (const [nom, v] of Object.entries(d)) {
87
+ const cle = `grillhouse.donnees.${nom}`;
88
+ const faute = f => fautes.push(`${ou} : la clé ${cle} ${f}`);
89
+ if (!NOM.test(nom)) {
90
+ fautes.push(`${ou} : la clé grillhouse.donnees nomme « ${nom} », pas un nom de variable.`);
91
+ continue;
92
+ }
93
+ const forme = typeof v === 'string' ? FORME.exec(v) : null;
94
+ if (!forme) {
95
+ faute(`vaut ${JSON.stringify(v)}, pas de la forme <paquet>#<sortie>.`);
96
+ continue;
97
+ }
98
+ const [, nomDuPaquet, sortie] = forme;
99
+ const fournisseur = liste.find(p => p.pkg?.name === nomDuPaquet);
100
+ if (!fournisseur) {
101
+ faute(`nomme le paquet « ${nomDuPaquet} », qu'aucun paquet du dépôt ne porte.`);
102
+ continue;
103
+ }
104
+ if (!Object.hasOwn(pkg.devDependencies ?? {}, nomDuPaquet)) {
105
+ faute(
106
+ `nomme le paquet « ${nomDuPaquet} », absent des devDependencies de ${ou} : la construction du fournisseur avant les tests passe par cette dépendance.`
107
+ );
108
+ continue;
109
+ }
110
+ const langageNom = langageDuPaquet(racine, fournisseur.dossier);
111
+ const release = RELEASE.test(String(fournisseur.pkg.scripts?.build ?? ''));
112
+ let chemin;
113
+ try {
114
+ chemin = langage(langageNom).sortieDuPaquet(dir, fournisseur.dossier, sortie, { release });
115
+ } catch (e) {
116
+ faute(`nomme ${v} : ${e.message.replace(/^⛔ /, '')}`);
117
+ continue;
118
+ }
119
+ if (Object.hasOwn(donnees, nom) && donnees[nom] !== chemin) {
120
+ faute(`est déclarée deux fois, pour deux sorties différentes.`);
121
+ continue;
122
+ }
123
+ donnees[nom] = chemin;
124
+ parPaquet.set(dossier, [...(parPaquet.get(dossier) ?? []), nom]);
125
+ fournisseurs.set(dossier, [...(fournisseurs.get(dossier) ?? []), nomDuPaquet]);
126
+ }
127
+ }
128
+ return { donnees: fautes.length ? {} : donnees, parPaquet, fournisseurs, fautes };
129
+ }
130
+
131
+ /**
132
+ * The data of the project that holds <dir>: each variable and the absolute path of the output it
133
+ * names, none without `grillhouse.donnees`. Nothing exists yet: the paths are those the build will
134
+ * write.
135
+ * @param {string} dir a directory of the project: its main tree or a copy
136
+ * @returns {Record<string, string>}
137
+ * @throws {Error} the faults of the key, one per line
138
+ */
139
+ export function donneesDe(dir) {
140
+ const { donnees, fautes } = lire(dir);
141
+ if (fautes.length) {
142
+ throw new Error(fautes.join('\n'));
143
+ }
144
+ return donnees;
145
+ }
146
+
147
+ /**
148
+ * The variables of the consumer at <chemin> (from the root) with their paths, to be checked once
149
+ * the build is done.
150
+ * @param {string} dir
151
+ * @param {string} chemin
152
+ * @returns {Record<string, string>}
153
+ * @throws {Error} the faults of the key, one per line
154
+ */
155
+ export function donneesDuPaquet(dir, chemin) {
156
+ const { donnees, parPaquet, fautes } = lire(dir);
157
+ if (fautes.length) {
158
+ throw new Error(fautes.join('\n'));
159
+ }
160
+ return Object.fromEntries(
161
+ [...parPaquet]
162
+ .filter(([d]) => contient(d, chemin))
163
+ .flatMap(([, ns]) => ns.map(n => [n, donnees[n]]))
164
+ );
165
+ }
166
+
167
+ // Whether the consumer folder <dossier> is <chemin> or holds it (a file or a folder in the package).
168
+ const contient = (dossier, chemin) =>
169
+ dossier === '.' ? chemin === '.' : chemin === dossier || chemin.startsWith(`${dossier}/`);
170
+
171
+ /**
172
+ * The names of the providers of the consumer that holds <chemin> (the package folder, or a file or
173
+ * folder in it), which a run of its tests builds first.
174
+ * @param {string} dir
175
+ * @param {string} chemin
176
+ * @returns {string[]}
177
+ * @throws {Error} the faults of the key, one per line
178
+ */
179
+ export function fournisseursDuPaquet(dir, chemin) {
180
+ const { fautes, fournisseurs } = lire(dir);
181
+ if (fautes.length) {
182
+ throw new Error(fautes.join('\n'));
183
+ }
184
+ return [
185
+ ...new Set([...fournisseurs].filter(([d]) => contient(d, chemin)).flatMap(([, ns]) => ns)),
186
+ ];
187
+ }
188
+
189
+ /**
190
+ * Builds the providers <noms> by the module of the language whose manifest is the package.json.
191
+ * @param {string[]} noms
192
+ * @throws {Error} a build that fails
193
+ */
194
+ export function construireLesFournisseurs(noms) {
195
+ if (!noms.length) {
196
+ return;
197
+ }
198
+ const nom = Object.keys(LANGAGES).find(n => langage(n).manifeste === 'package.json');
199
+ const module = nom ? langage(nom) : null;
200
+ if (!module?.construireLesPaquets) {
201
+ throw new Error('aucun langage du projet ne construit les paquets par leur nom.');
202
+ }
203
+ module.construireLesPaquets(noms);
204
+ }
205
+
206
+ /**
207
+ * Refuses an output absent after the build, its variable and its path named, one per line.
208
+ * @param {Record<string, string>} donnees
209
+ * @throws {Error}
210
+ */
211
+ export function controlerLesDonnees(donnees) {
212
+ const absents = Object.entries(donnees)
213
+ .filter(([, c]) => !existsSync(c))
214
+ .map(
215
+ ([n, c]) => `la variable ${n} nomme ${c}, que la construction du fournisseur n'a pas produit.`
216
+ );
217
+ if (absents.length) {
218
+ throw new Error(absents.join('\n'));
219
+ }
220
+ }
221
+
222
+ /**
223
+ * The environment <env> of a pass with the data <donnees> (`donneesDe`), the data winning.
224
+ * @param {Record<string, string>} donnees
225
+ * @param {Record<string, string | undefined>} env
226
+ */
227
+ export function avecLesDonnees(donnees, env) {
228
+ return { ...env, ...donnees };
229
+ }
230
+
231
+ // The shell's text that exports the data <donnees>, one `export VARIABLE='chemin'` per line.
232
+ export const exportsDesDonnees = donnees =>
233
+ Object.entries(donnees)
234
+ .map(([n, c]) => `export ${n}='${c.replaceAll("'", "'\\''")}'\n`)
235
+ .join('');
236
+
237
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
238
+ try {
239
+ process.stdout.write(exportsDesDonnees(donneesDe(path.resolve(process.argv[2] ?? '.'))));
240
+ } catch (e) {
241
+ process.stderr.write(`${/** @type {Error} */ (e).message}\n`);
242
+ process.exitCode = 1;
243
+ }
244
+ }