@roomi-fields/grillhouse 0.52.0 → 0.54.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 (155) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/CHANGELOG.md +96 -0
  3. package/agents/direct.md +1 -1
  4. package/cadre/templates/projet/docs/agents/issue-tracker.md +2 -2
  5. package/cadre/templates/projet/vitest.config.cjs +45 -0
  6. package/charte/superviseur.md +36 -37
  7. package/charte.md +13 -1
  8. package/dist/temporal/circuit/appel.d.ts +2 -0
  9. package/dist/temporal/circuit/appel.js +24 -2
  10. package/dist/temporal/circuit/appel.js.map +1 -1
  11. package/dist/temporal/circuit/client.d.ts +14 -5
  12. package/dist/temporal/circuit/client.js +41 -9
  13. package/dist/temporal/circuit/client.js.map +1 -1
  14. package/dist/temporal/circuit/commande.js +17 -6
  15. package/dist/temporal/circuit/commande.js.map +1 -1
  16. package/dist/temporal/circuit/contrat.d.ts +9 -0
  17. package/dist/temporal/circuit/contrat.js +6 -0
  18. package/dist/temporal/circuit/contrat.js.map +1 -1
  19. package/dist/temporal/circuit/deroule.js +29 -12
  20. package/dist/temporal/circuit/deroule.js.map +1 -1
  21. package/dist/temporal/client.d.ts +35 -1
  22. package/dist/temporal/client.js +144 -1
  23. package/dist/temporal/client.js.map +1 -1
  24. package/dist/temporal/commande.js +31 -13
  25. package/dist/temporal/commande.js.map +1 -1
  26. package/dist/temporal/etat.d.ts +3 -1
  27. package/dist/temporal/etat.js +31 -17
  28. package/dist/temporal/etat.js.map +1 -1
  29. package/dist/temporal/file/activites.js +1 -1
  30. package/dist/temporal/file/activites.js.map +1 -1
  31. package/dist/temporal/file/contrat.d.ts +4 -5
  32. package/dist/temporal/file/contrat.js +2 -2
  33. package/dist/temporal/file/contrat.js.map +1 -1
  34. package/dist/temporal/file/deroule.js +7 -5
  35. package/dist/temporal/file/deroule.js.map +1 -1
  36. package/dist/temporal/installation.d.ts +116 -53
  37. package/dist/temporal/installation.js +898 -241
  38. package/dist/temporal/installation.js.map +1 -1
  39. package/dist/temporal/nuits/deroule.js +3 -1
  40. package/dist/temporal/nuits/deroule.js.map +1 -1
  41. package/dist/temporal/places/deroule.js +2 -1
  42. package/dist/temporal/places/deroule.js.map +1 -1
  43. package/dist/temporal/sonde/deroule.js +2 -1
  44. package/dist/temporal/sonde/deroule.js.map +1 -1
  45. package/dist/temporal/tickets/deroule.js +4 -3
  46. package/dist/temporal/tickets/deroule.js.map +1 -1
  47. package/dist/temporal/travailleur.d.ts +7 -1
  48. package/dist/temporal/travailleur.js +49 -25
  49. package/dist/temporal/travailleur.js.map +1 -1
  50. package/docs/INTERFACE.md +37 -12
  51. package/docs/architecture/circuit.md +21 -18
  52. package/docs/architecture/entree.md +10 -11
  53. package/docs/architecture/greffon.md +45 -27
  54. package/docs/architecture/installation.md +92 -59
  55. package/docs/architecture/machine.md +2 -2
  56. package/docs/architecture/tests.md +15 -6
  57. package/docs/lexique.md +2 -2
  58. package/hooks/hooks.json +10 -0
  59. package/hooks/register.tsx +59 -39
  60. package/package.json +3 -2
  61. package/scripts/activites.mjs +5 -4
  62. package/scripts/aiguillage.mjs +5 -2
  63. package/scripts/bd-garde.mjs +69 -0
  64. package/scripts/ci-de-main.mjs +259 -56
  65. package/scripts/circuit.mjs +274 -47
  66. package/scripts/circuits-du-serveur.mjs +3 -2
  67. package/scripts/circuits-tenus.d.mts +7 -0
  68. package/scripts/circuits-tenus.mjs +17 -0
  69. package/scripts/commandes-composees.mjs +1 -1
  70. package/scripts/copie-de-montee.mjs +354 -0
  71. package/scripts/copies-du-depot.d.mts +13 -0
  72. package/scripts/copies-du-depot.mjs +66 -0
  73. package/scripts/copies-finies.mjs +6 -40
  74. package/scripts/crochets.mjs +16 -2
  75. package/scripts/direct.mjs +2 -2
  76. package/scripts/droits.mjs +13 -6
  77. package/scripts/engendres.mjs +5 -3
  78. package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
  79. package/scripts/etapes.mjs +11 -3
  80. package/scripts/faits-du-circuit.mjs +12 -5
  81. package/scripts/file-des-tickets.d.mts +13 -2
  82. package/scripts/file-des-tickets.mjs +71 -21
  83. package/scripts/greffons.mjs +42 -27
  84. package/scripts/grillhouse-maj.mjs +105 -85
  85. package/scripts/init.mjs +1 -1
  86. package/scripts/integration/file.mjs +5 -2
  87. package/scripts/integration/integrer.mjs +14 -4
  88. package/scripts/jointure.d.ts +16 -0
  89. package/scripts/langages/c/commandes.mjs +18 -8
  90. package/scripts/langages/cargo/commandes.mjs +88 -35
  91. package/scripts/langages/cargo/index.mjs +6 -3
  92. package/scripts/langages/cargo/sccache.mjs +15 -12
  93. package/scripts/langages/cargo/tailles-des-tests.mjs +115 -6
  94. package/scripts/langages/python/commandes.mjs +19 -9
  95. package/scripts/langages/python/squelette.mjs +2 -2
  96. package/scripts/langages/typescript/code-mort.mjs +36 -3
  97. package/scripts/langages/typescript/configurations-de-vitest.mjs +118 -0
  98. package/scripts/langages/typescript/index.mjs +2 -0
  99. package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +370 -0
  100. package/scripts/langages/typescript/mise-a-jour.mjs +49 -12
  101. package/scripts/langages/typescript/parcours.mjs +5 -1
  102. package/scripts/langages/typescript/squelette.mjs +20 -17
  103. package/scripts/langages/typescript/tests-de-nuit.mjs +3 -3
  104. package/scripts/langages/typescript/turbo-des-paquets.mjs +24 -37
  105. package/scripts/langages/typescript/vitest-config/base.mjs +1 -1
  106. package/scripts/langages/typescript/vitest-config/bornes.mjs +1 -1
  107. package/scripts/langages/typescript/vitest-config/cibles.mjs +2 -2
  108. package/scripts/langages/typescript/{vitest.nuit.config.mjs → vitest.nuit.config.cjs} +61 -50
  109. package/scripts/langages.d.mts +6 -0
  110. package/scripts/langages.mjs +6 -0
  111. package/scripts/lire.mjs +236 -0
  112. package/scripts/mesure/pression.mjs +5 -3
  113. package/scripts/migrations/cout-des-jetons-au-registre.mjs +136 -0
  114. package/scripts/migrations/lire-un-ticket.mjs +46 -0
  115. package/scripts/migrations.mjs +4 -0
  116. package/scripts/montee.mjs +588 -0
  117. package/scripts/nuit.sh +21 -12
  118. package/scripts/outil.mjs +5 -3
  119. package/scripts/paquet-npm.mjs +22 -0
  120. package/scripts/paquet.mjs +5 -5
  121. package/scripts/pre-compact.mjs +25 -0
  122. package/scripts/registre.d.mts +7 -1
  123. package/scripts/registre.mjs +114 -102
  124. package/scripts/reponses-du-circuit.d.mts +17 -2
  125. package/scripts/reponses-du-circuit.mjs +78 -20
  126. package/scripts/resultats.mjs +55 -17
  127. package/scripts/retirer-les-copies-finies.mjs +4 -7
  128. package/scripts/seances.mjs +28 -3
  129. package/scripts/services-du-noyau.mjs +7 -2
  130. package/scripts/session-start.sh +18 -11
  131. package/scripts/sortie.mjs +4 -7
  132. package/scripts/sous-commandes.mjs +2 -0
  133. package/scripts/suiveur.mjs +12 -4
  134. package/scripts/superviseur.mjs +135 -84
  135. package/scripts/tableau.mjs +651 -224
  136. package/scripts/tarifs.mjs +67 -0
  137. package/scripts/ticket-du-circuit.mjs +25 -4
  138. package/scripts/transitions.d.mts +6 -14
  139. package/scripts/transitions.mjs +126 -49
  140. package/scripts/verdict-de-la-nuit.mjs +2 -2
  141. package/scripts/verrou-de-fichier.d.mts +11 -0
  142. package/skills/direct/SKILL.md +21 -11
  143. package/skills/explorateur/SKILL.md +16 -6
  144. package/skills/grill/SKILL.md +9 -7
  145. package/skills/grill/references/paquets.md +4 -4
  146. package/skills/mesure/SKILL.md +4 -3
  147. package/skills/pitmaster/SKILL.md +56 -35
  148. package/skills/pitmaster/references/consigne-agent.md +1 -1
  149. package/skills/pitmaster/references/erreurs.md +4 -2
  150. package/skills/pitmaster/references/tour.md +11 -4
  151. package/skills/relecteur/SKILL.md +8 -1
  152. package/skills/testwriter/SKILL.md +1 -1
  153. package/types/index.d.ts +3 -1
  154. package/cadre/templates/projet/vitest.config.ts +0 -44
  155. package/scripts/base-des-workflows.mjs +0 -58
@@ -0,0 +1,588 @@
1
+ // The montée of a project by one command, `grillhouse maj [<x.y.z>]`, as `nx migrate` and
2
+ // `brew upgrade` bring everything to the version wanted. The mechanism is installation.md §5.2 and
3
+ // §5.3, under packages/grillhouse/docs/architecture/.
4
+ //
5
+ // - Launched in the main tree (`monter`), it lays the copy of the montée on the tip of main
6
+ // (scripts/copie-de-montee.mjs), installs there the package at the version wanted (`npm install -D`;
7
+ // the repository of the frame, which holds the package's sources, installs its dependencies
8
+ // alone), then hands the rest (`suivre`) to the command of the package so installed, or plays it
9
+ // itself in the repository of the frame. Without a version, the one the tip of main holds is kept
10
+ // (the key `grillhouse.outil` in the repository of the frame). The child learns it plays the
11
+ // rest from the variable `GRILLHOUSE_MONTEE`.
12
+ // - The rest, up to five passes: the files the frame writes (scripts/grillhouse-maj.mjs), the
13
+ // machine's part once (the published tool, the plugins, the binaries, the units and workers, the
14
+ // schedule of the nights; in the repository of the frame, the last two by the commands of the
15
+ // published tool), the verification of the sort « Montée » on the content of the commit
16
+ // alone; green, the commit, its tree kept as judged (scripts/arbres-juges.mjs), main advanced by
17
+ // fast-forward and pushed; main advanced meanwhile, the next pass writes everything again from
18
+ // its tip. Main advanced, the main tree installs its dependencies and the plugins the lot adds.
19
+ // - A montée in which a gesture failed ends its report, on the error output, by saying each such
20
+ // failure again, whole, with the command that plays the gesture again.
21
+ // - Exit code: 0; 1 for a failure, a refusal or a montée not entered; 75 for a verification to play
22
+ // again; 2 for the usage (scripts/grillhouse-maj.mjs).
23
+ import { spawnSync } from 'node:child_process';
24
+ import { existsSync, readFileSync, realpathSync } from 'node:fs';
25
+ import path from 'node:path';
26
+ import { dossierDeLOutil, installer, NOM_DU_PAQUET, versionDeLOutil } from './aiguillage.mjs';
27
+ import { garderLArbreJuge } from './arbres-juges.mjs';
28
+ import { installerBinaires } from './binaires.mjs';
29
+ import { poserCrochets } from './crochets.mjs';
30
+ import {
31
+ arbreDe,
32
+ brancheDeLaMontee,
33
+ changements,
34
+ conflits,
35
+ fichiersEcrits,
36
+ garderLEtat,
37
+ git,
38
+ preparerLaCopie,
39
+ remettreSur,
40
+ restaurer,
41
+ retirerLaCopie,
42
+ } from './copie-de-montee.mjs';
43
+ import { greffonsDuProjet, installerGreffons } from './greffons.mjs';
44
+ import { paquets } from './paquets.mjs';
45
+
46
+ /** The variable by which the command of the package installed in the copy plays the rest. */
47
+ export const VARIABLE_DE_LA_MONTEE = 'GRILLHOUSE_MONTEE';
48
+ const PASSES_MAX = 5;
49
+ // The root of the package that runs: this script's.
50
+ const PAQUET = path.resolve(import.meta.dirname, '..');
51
+ const CHAMPS = ['dependencies', 'devDependencies', 'optionalDependencies'];
52
+
53
+ const dire = l => process.stdout.write(`${l}\n`);
54
+ const signaler = l => process.stderr.write(`${l}\n`);
55
+
56
+ const lireJson = f => {
57
+ try {
58
+ return JSON.parse(readFileSync(f, 'utf8'));
59
+ } catch {
60
+ return null;
61
+ }
62
+ };
63
+
64
+ const resultatDeGit = (racine, args) =>
65
+ spawnSync('git', ['-C', racine, ...args], { encoding: 'utf8' });
66
+
67
+ // The JSON of the file `f` at the commit `commit`, or null.
68
+ function auCommit(racine, commit, f) {
69
+ const r = resultatDeGit(racine, ['show', `${commit}:${f}`]);
70
+ try {
71
+ return r.status === 0 ? JSON.parse(r.stdout) : null;
72
+ } catch {
73
+ return null;
74
+ }
75
+ }
76
+
77
+ /**
78
+ * The main tree `cwd` is the root of, its branch: `{ principal, branche }`; `{ refus }` in a copy,
79
+ * out of git, in a folder that is no root, or on a detached HEAD.
80
+ */
81
+ export function arbreDeLaMontee(cwd) {
82
+ const r = resultatDeGit(cwd, [
83
+ 'rev-parse',
84
+ '--path-format=absolute',
85
+ '--git-dir',
86
+ '--git-common-dir',
87
+ '--show-toplevel',
88
+ ]);
89
+ const refus = raison => ({
90
+ refus: `⛔ grillhouse maj se lance à la racine de l'arbre principal d'un dépôt git : ${raison}. Rien n'est fait.`,
91
+ });
92
+ if (r.status !== 0) {
93
+ return refus(`${cwd} n'est pas dans un dépôt git`);
94
+ }
95
+ const [dossier, commun, racine] = r.stdout.trim().split('\n');
96
+ if (dossier !== commun) {
97
+ return refus(`${racine} est une copie`);
98
+ }
99
+ if (realpathSync(cwd) !== realpathSync(racine)) {
100
+ return refus(`la racine du dépôt est ${racine}, pas ${cwd}`);
101
+ }
102
+ if (!existsSync(path.join(racine, 'package.json'))) {
103
+ return refus(`${racine} n'a pas de package.json`);
104
+ }
105
+ const branche = resultatDeGit(racine, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
106
+ if (branche.status !== 0) {
107
+ return refus('aucune branche n’y est extraite (HEAD détaché)');
108
+ }
109
+ return { principal: realpathSync(racine), branche: branche.stdout.trim() };
110
+ }
111
+
112
+ // The folder of the package's sources in the repository at `racine`, or null: the repository of
113
+ // the frame.
114
+ function sourcesDuCadre(racine) {
115
+ return paquets(racine).find(p => p.pkg.name === NOM_DU_PAQUET)?.dossier ?? null;
116
+ }
117
+
118
+ const declareLePaquet = pkg => CHAMPS.some(c => pkg?.[c]?.[NOM_DU_PAQUET] !== undefined);
119
+ const versionVerrouillee = verrou =>
120
+ verrou?.packages?.[`node_modules/${NOM_DU_PAQUET}`]?.version ?? null;
121
+ const versionInstallee = racine =>
122
+ lireJson(path.join(racine, 'node_modules', NOM_DU_PAQUET, 'package.json'))?.version ?? null;
123
+
124
+ // The version the tip of main holds, which `maj` without argument keeps.
125
+ function versionDeLaPointe(principal, pointe, sources) {
126
+ const pkg = auCommit(principal, pointe, 'package.json');
127
+ if (sources !== null) {
128
+ return (
129
+ pkg?.grillhouse?.outil ?? auCommit(principal, pointe, `${sources}/package.json`)?.version
130
+ );
131
+ }
132
+ if (!declareLePaquet(pkg)) {
133
+ return null;
134
+ }
135
+ const declaree = CHAMPS.map(c => pkg[c]?.[NOM_DU_PAQUET]).find(Boolean);
136
+ return (
137
+ versionVerrouillee(auCommit(principal, pointe, 'package-lock.json')) ??
138
+ versionInstallee(principal) ??
139
+ /\d+\.\d+\.\d+/.exec(declaree)?.[0] ??
140
+ null
141
+ );
142
+ }
143
+
144
+ // npm in `dossier`, its output the command's: null when it succeeds, else the line of its failure,
145
+ // said.
146
+ function npm(dossier, args) {
147
+ const r = spawnSync('npm', args, { cwd: dossier, stdio: 'inherit' });
148
+ if (r.status === 0) {
149
+ return null;
150
+ }
151
+ const ligne = `⛔ \`npm ${args.join(' ')}\` dans ${dossier} échoue (${r.error?.message ?? `code ${r.status}`}).`;
152
+ signaler(ligne);
153
+ return ligne;
154
+ }
155
+
156
+ // The installation of a montée in its copy: the package at `version` when the tip does not hold it
157
+ // there, else the declared dependencies alone.
158
+ function installerDansLaCopie({ copie, version, duCadre }) {
159
+ const aJour =
160
+ duCadre ||
161
+ (declareLePaquet(lireJson(path.join(copie, 'package.json'))) &&
162
+ versionVerrouillee(lireJson(path.join(copie, 'package-lock.json'))) === version);
163
+ return !npm(copie, aJour ? ['install'] : ['install', '-D', `${NOM_DU_PAQUET}@${version}`]);
164
+ }
165
+
166
+ /**
167
+ * A gesture that failed: the lines the montée said of it, and the line naming the command that
168
+ * plays it again.
169
+ * @typedef {{ lignes: string[], rejeu: string }} Echec
170
+ */
171
+
172
+ // The end of the report: each failure said again, whole, with its command; the exit code.
173
+ function redire(echecs) {
174
+ for (const { lignes, rejeu } of echecs) {
175
+ lignes.forEach(signaler);
176
+ signaler(rejeu);
177
+ }
178
+ return echecs.length > 0 ? 1 : 0;
179
+ }
180
+
181
+ // What the report says of a montée that did not enter main: its copy, the versions, the commands.
182
+ function nonEntree({ copie, version, principal, pointe, duCadre }, poste) {
183
+ const sources = duCadre ? sourcesDuCadre(principal) : null;
184
+ const duProjet = versionDeLaPointe(principal, pointe, sources) ?? 'inconnue';
185
+ signaler(
186
+ `Montée non entrée : main reste tel quel, sa copie reste, ${copie} (branche ${brancheDeLaMontee(version)}).`
187
+ );
188
+ signaler(
189
+ `${
190
+ poste
191
+ ? `Le poste est mené par ${version} (sa part est jouée)`
192
+ : 'La part du poste n’est pas jouée'
193
+ }, le projet est en ${duProjet} : \`npx grillhouse maj ${version}\` reprend la montée, \`npx grillhouse maj\` revient à la version du projet.`
194
+ );
195
+ }
196
+
197
+ /**
198
+ * What the montée receives of the files the frame writes (scripts/grillhouse-maj.mjs, which calls
199
+ * it): `ecrireLeProjet` and `verifier`.
200
+ * @typedef {{
201
+ * ecrireLeProjet: (copie: string, o: { version: string, duCadre: boolean,
202
+ * noterSansVerifier?: (ligne: string | null) => void }) => boolean,
203
+ * verifier: (copie: string, o: { fichiersAFinir: boolean, installer: boolean,
204
+ * sansVerifier?: string | null }) => { code: number | null, ligne: string, erreur: boolean }
205
+ * }} Fichiers
206
+ */
207
+
208
+ /**
209
+ * `grillhouse maj [<voulue>]` launched in `cwd` (see the header): the exit code.
210
+ * @param {string | null} voulue the version x.y.z wanted, null to keep the tip's
211
+ * @param {Fichiers} deLaMaj
212
+ * @param {string} [cwd]
213
+ */
214
+ export function monter(voulue, deLaMaj, cwd = process.cwd()) {
215
+ const arbre = arbreDeLaMontee(cwd);
216
+ if (arbre.refus) {
217
+ signaler(arbre.refus);
218
+ return 1;
219
+ }
220
+ const { principal, branche } = arbre;
221
+ const pointe = git(principal, 'rev-parse', 'HEAD');
222
+ const sources = sourcesDuCadre(principal);
223
+ const duCadre = sources !== null;
224
+ const tenue = versionDeLaPointe(principal, pointe, sources);
225
+ const version = voulue ?? tenue;
226
+ if (!version) {
227
+ signaler(
228
+ `⛔ la pointe de ${branche} ne déclare pas ${NOM_DU_PAQUET} : nomme la version, \`npx grillhouse maj <x.y.z>\`.`
229
+ );
230
+ return 1;
231
+ }
232
+ let copie;
233
+ try {
234
+ ({ copie } = preparerLaCopie(principal, version, pointe));
235
+ } catch (e) {
236
+ signaler(`⛔ Montée ${version} : ${e.message}`);
237
+ return 1;
238
+ }
239
+ const montee = { principal, branche, copie, version, pointe, duCadre };
240
+ const abandonner = () => {
241
+ restaurer(copie, version);
242
+ nonEntree(montee, false);
243
+ return 1;
244
+ };
245
+ if (existsSync(path.join(copie, '.gitmodules'))) {
246
+ const r = spawnSync('bash', [path.join(PAQUET, 'scripts', 'sous-modules.sh'), 'pose', copie], {
247
+ cwd: principal,
248
+ stdio: 'inherit',
249
+ });
250
+ if (r.status !== 0) {
251
+ return abandonner();
252
+ }
253
+ }
254
+ if (!installerDansLaCopie(montee)) {
255
+ signaler(`⛔ Montée ${version} : l'installation échoue ; aucun autre geste, aucun commit.`);
256
+ return abandonner();
257
+ }
258
+ if (duCadre) {
259
+ return suivre(montee, deLaMaj);
260
+ }
261
+ const paquet = path.join(copie, 'node_modules', NOM_DU_PAQUET);
262
+ if (existsSync(path.join(paquet, 'scripts', 'montee.mjs'))) {
263
+ const r = spawnSync(
264
+ process.execPath,
265
+ [path.join(paquet, 'bin', 'grillhouse.mjs'), 'maj', version],
266
+ {
267
+ cwd: copie,
268
+ stdio: 'inherit',
269
+ env: { ...process.env, [VARIABLE_DE_LA_MONTEE]: JSON.stringify(montee) },
270
+ }
271
+ );
272
+ return r.status ?? 1;
273
+ }
274
+ // A version from before the montée in one command: the machine alone goes back to the project's.
275
+ restaurer(copie, version);
276
+ if (version !== tenue) {
277
+ signaler(
278
+ `⛔ ${NOM_DU_PAQUET}@${version} ne connaît pas la montée en une commande : rien n'est écrit.`
279
+ );
280
+ nonEntree(montee, false);
281
+ return 1;
282
+ }
283
+ const echecs = [];
284
+ jouerLePoste(montee, echecs);
285
+ apresLAvance(montee, false, echecs);
286
+ retirerOuDire(montee);
287
+ return redire(echecs);
288
+ }
289
+
290
+ // The package whose commands the machine's part runs: in the repository of the frame, the published
291
+ // tool of the version the copy writes, never the build of the workspace (installation.md §5.5);
292
+ // elsewhere the package that runs, installed in the copy.
293
+ function paquetDuPoste({ copie, version, duCadre }) {
294
+ if (!duCadre) {
295
+ return PAQUET;
296
+ }
297
+ const publiee = versionDeLOutil(copie) ?? version;
298
+ const paquet = path.join(dossierDeLOutil(publiee), 'node_modules', NOM_DU_PAQUET);
299
+ if (!existsSync(paquet)) {
300
+ throw new Error(`l'outil publié ${publiee} n'est pas installé.`);
301
+ }
302
+ return paquet;
303
+ }
304
+
305
+ // Runs a command of <paquet> in the main tree; the line of its failure, which names `geste`.
306
+ function duPoste(principal, geste, paquet, script, args) {
307
+ const r = spawnSync(process.execPath, [path.join(paquet, script), ...args], {
308
+ cwd: principal,
309
+ encoding: 'utf8',
310
+ });
311
+ if (r.status === 0) {
312
+ dire(`Part du poste : ${r.stdout.trim()}`);
313
+ return [];
314
+ }
315
+ return [
316
+ `Part du poste : \`${geste}\` échoue : ${`${r.stdout ?? ''}${r.stderr ?? ''}`.trim() || r.error?.message || `code ${r.status}`}`,
317
+ ];
318
+ }
319
+
320
+ /**
321
+ * The machine's part (installation.md §5.3), at the version and by the declarations the copy
322
+ * holds, with the paths and names of the main tree: the lines of failure, each said, and its
323
+ * failure added to `echoues`.
324
+ * @param {{ principal: string, copie: string, version: string, duCadre: boolean }} montee
325
+ * @param {Echec[]} [echoues]
326
+ * @returns {string[]}
327
+ */
328
+ export function jouerLePoste(montee, echoues = []) {
329
+ const { principal, copie, version } = montee;
330
+ const echecs = [];
331
+ const essayer = (geste, jouer) => {
332
+ try {
333
+ echecs.push(...jouer());
334
+ } catch (e) {
335
+ echecs.push(`Part du poste : \`${geste}\` échoue : ${e.message}`);
336
+ }
337
+ };
338
+ essayer('npx grillhouse outil', () => {
339
+ const publiee = versionDeLOutil(copie) ?? version;
340
+ const r = installer(publiee, { retenue: 0 });
341
+ dire(`Part du poste : outil publié ${publiee} ${r.installe ? 'installé' : 'déjà là'}.`);
342
+ return [];
343
+ });
344
+ essayer('npx grillhouse greffons', () =>
345
+ installerGreffons(principal, {
346
+ declarations: copie,
347
+ seulement: greffonsDuProjet(principal),
348
+ version,
349
+ })
350
+ );
351
+ essayer('npx grillhouse binaires', () => {
352
+ const r = installerBinaires(copie);
353
+ if (r.installes.length > 0) {
354
+ dire(`Binaires installés : ${r.installes.join(', ')}.`);
355
+ }
356
+ return r.lignes;
357
+ });
358
+ essayer('npx grillhouse temporal installer', () =>
359
+ duPoste(
360
+ principal,
361
+ 'npx grillhouse temporal installer',
362
+ paquetDuPoste(montee),
363
+ 'dist/temporal/commande.js',
364
+ ['installer', '--racine', principal, '--declarations', copie]
365
+ )
366
+ );
367
+ essayer('npx grillhouse nuit --planifier', () =>
368
+ duPoste(
369
+ principal,
370
+ 'npx grillhouse nuit --planifier',
371
+ paquetDuPoste(montee),
372
+ 'dist/temporal/nuits/commande.js',
373
+ ['--planifier']
374
+ )
375
+ );
376
+ echecs.forEach(signaler);
377
+ if (echecs.length > 0) {
378
+ signaler(
379
+ `Part du poste en échec : \`npx grillhouse maj ${version}\` la rejoue, \`npx grillhouse maj\` revient à la version du projet.`
380
+ );
381
+ echoues.push({
382
+ lignes: echecs,
383
+ rejeu: `Part du poste en échec : \`npx grillhouse maj ${version}\` la rejoue.`,
384
+ });
385
+ }
386
+ return echecs;
387
+ }
388
+
389
+ // Whether a dependency of the main tree is not installed, or the frame's package not at the version
390
+ // its lock names.
391
+ function perime(principal) {
392
+ const pkg = lireJson(path.join(principal, 'package.json'));
393
+ const noms = CHAMPS.filter(c => c !== 'optionalDependencies').flatMap(c =>
394
+ Object.keys(pkg?.[c] ?? {})
395
+ );
396
+ const verrou = versionVerrouillee(lireJson(path.join(principal, 'package-lock.json')));
397
+ return (
398
+ noms.some(n => !existsSync(path.join(principal, 'node_modules', n, 'package.json'))) ||
399
+ (verrou !== null && declareLePaquet(pkg) && versionInstallee(principal) !== verrou)
400
+ );
401
+ }
402
+
403
+ // What follows the advance of main (`avance`) in the main tree: its dependencies, then the plugins
404
+ // it declares; their failures, each line said, added to `echoues`.
405
+ function apresLAvance({ principal, version }, avance, echoues) {
406
+ const deNpm = (avance || perime(principal)) && npm(principal, ['install']);
407
+ if (deNpm) {
408
+ const reste = `Arbre principal : \`npm install\` reste à jouer ; \`npx grillhouse maj ${version}\` le rejoue.`;
409
+ signaler(reste);
410
+ echoues.push({
411
+ lignes: [deNpm, reste],
412
+ rejeu: `\`npx grillhouse maj ${version}\` rejoue \`npm install\` dans l'arbre principal.`,
413
+ });
414
+ }
415
+ poserCrochets(principal);
416
+ const greffons = installerGreffons(principal, { version });
417
+ greffons.forEach(signaler);
418
+ if (greffons.length > 0) {
419
+ echoues.push({
420
+ lignes: greffons,
421
+ rejeu: `Greffons en échec : \`npx grillhouse greffons\` les rejoue dans ${principal}.`,
422
+ });
423
+ }
424
+ }
425
+
426
+ // Removes the copy, or says why it stays.
427
+ function retirerOuDire({ principal, copie, version }) {
428
+ if (!retirerLaCopie(principal, copie, version)) {
429
+ dire(
430
+ `La copie de la montée reste, ${copie} : elle porte un changement non commité d'un autre (${changements(copie).join(', ')}).`
431
+ );
432
+ }
433
+ }
434
+
435
+ // Main advanced to `commit` by fast-forward in the main tree: `{ avance }`, `{ bouge }` when main
436
+ // moved off `base`, else the files that hold it.
437
+ function avancer({ principal, branche }, base, commit, fichiers) {
438
+ const pointe = () => git(principal, 'rev-parse', `refs/heads/${branche}`);
439
+ if (pointe() !== base) {
440
+ return { bouge: true };
441
+ }
442
+ const r = resultatDeGit(principal, ['merge', '-q', '--ff-only', commit]);
443
+ if (r.status === 0) {
444
+ return { avance: true };
445
+ }
446
+ if (pointe() !== base) {
447
+ return { bouge: true };
448
+ }
449
+ const retenus = changements(principal).filter(f => fichiers.includes(f));
450
+ return { retenus, raison: r.stderr.trim() };
451
+ }
452
+
453
+ /**
454
+ * The rest of the montée `montee`, its copy installed (see the header): the exit code.
455
+ * @param {{ principal: string, branche: string, copie: string, version: string, pointe: string,
456
+ * duCadre: boolean }} montee
457
+ * @param {Fichiers} deLaMaj
458
+ */
459
+ export function suivre(montee, { ecrireLeProjet, verifier }) {
460
+ const { principal, branche, copie, version, duCadre } = montee;
461
+ let { pointe } = montee;
462
+ const echecs = [];
463
+ let posteJoue = false;
464
+ let entree = false;
465
+ // Lays back what was set aside, says the montée did not enter, and gives the exit code.
466
+ const arreter = (cause, code = 1) => {
467
+ const enConflit = restaurer(copie, version);
468
+ if (cause) {
469
+ signaler(cause);
470
+ }
471
+ if (enConflit.length > 0) {
472
+ signaler(`Le changement d'un autre reste tel quel dans la copie : ${enConflit.join(', ')}.`);
473
+ }
474
+ if (!entree) {
475
+ nonEntree({ ...montee, pointe }, posteJoue);
476
+ }
477
+ redire(echecs);
478
+ return code;
479
+ };
480
+ try {
481
+ for (let passe = 1; passe <= PASSES_MAX; passe++) {
482
+ if (passe > 1) {
483
+ pointe = git(principal, 'rev-parse', `refs/heads/${branche}`);
484
+ dire(`main a avancé : la montée se réécrit depuis ${pointe.slice(0, 7)} (passe ${passe}).`);
485
+ remettreSur(copie, pointe);
486
+ if (!installerDansLaCopie(montee)) {
487
+ return arreter(`⛔ Montée ${version} : l'installation échoue ; aucun commit.`);
488
+ }
489
+ }
490
+ let sansVerifier = null;
491
+ const aFaire = ecrireLeProjet(copie, {
492
+ version,
493
+ duCadre,
494
+ noterSansVerifier: ligne => {
495
+ sansVerifier = ligne;
496
+ },
497
+ });
498
+ const fichiers = fichiersEcrits(copie);
499
+ garderLEtat(copie, version, fichiers);
500
+ if (!posteJoue) {
501
+ jouerLePoste(montee, echecs);
502
+ posteJoue = true;
503
+ }
504
+ const enConflit = conflits(copie, version);
505
+ if (aFaire || enConflit.length > 0) {
506
+ const v = aFaire
507
+ ? verifier(copie, { fichiersAFinir: true, installer: false })
508
+ : {
509
+ ligne: `⛔ Conflit avec un changement non commité d'un autre : ${enConflit.join(', ')}.`,
510
+ };
511
+ return arreter(`${v.ligne}\nAucun commit.`);
512
+ }
513
+ if (fichiers.length === 0) {
514
+ dire(`Montée ${version} : rien à commiter, le projet est à jour ; aucun commit.`);
515
+ restaurer(copie, version);
516
+ apresLAvance(montee, false, echecs);
517
+ retirerOuDire(montee);
518
+ return redire(echecs);
519
+ }
520
+ const arbre = arbreDe(copie, pointe, fichiers);
521
+ const v = verifier(copie, { fichiersAFinir: false, installer: false, sansVerifier });
522
+ // What the verification wrote besides the montée's files goes.
523
+ const deLaVerification = changements(copie).filter(f => !fichiers.includes(f));
524
+ for (const f of deLaVerification) {
525
+ if (resultatDeGit(copie, ['checkout', '-q', 'HEAD', '--', f]).status !== 0) {
526
+ resultatDeGit(copie, ['clean', '-q', '-f', '--', f]);
527
+ }
528
+ }
529
+ (v.erreur ? signaler : dire)(v.ligne);
530
+ if (v.code !== 0) {
531
+ return arreter('Aucun commit.', v.code === 75 ? 75 : 1);
532
+ }
533
+ const commit = git(
534
+ copie,
535
+ 'commit-tree',
536
+ arbre,
537
+ '-p',
538
+ pointe,
539
+ '-m',
540
+ `Montée du cadre à ${version}`
541
+ );
542
+ garderLArbreJuge(copie, arbre);
543
+ garderLEtat(copie, version, fichiers, commit);
544
+ git(copie, 'reset', '-q', '--soft', commit);
545
+ git(copie, 'reset', '-q');
546
+ const a = avancer(montee, pointe, commit, fichiers);
547
+ if (a.bouge) {
548
+ continue;
549
+ }
550
+ if (!a.avance) {
551
+ return arreter(
552
+ `⛔ main n'avance pas : l'arbre principal porte un changement non commité sur un fichier du lot (${a.retenus.join(', ')}). ${a.raison}`
553
+ );
554
+ }
555
+ entree = true;
556
+ dire(
557
+ `Commit ${commit.slice(0, 7)} « Montée du cadre à ${version} » : ${fichiers.join(', ')} ; ${branche} avancée.`
558
+ );
559
+ if (resultatDeGit(principal, ['remote', 'get-url', 'origin']).status === 0) {
560
+ const p = resultatDeGit(principal, ['push', '-q', 'origin', branche]);
561
+ if (p.status !== 0) {
562
+ const ligne = `⛔ \`git push origin ${branche}\` échoue : ${p.stderr.trim()}`;
563
+ signaler(ligne);
564
+ echecs.push({
565
+ lignes: [ligne],
566
+ rejeu: `Poussée en échec : \`git push origin ${branche}\` la rejoue dans ${principal}.`,
567
+ });
568
+ }
569
+ }
570
+ apresLAvance(montee, true, echecs);
571
+ restaurer(copie, version);
572
+ retirerOuDire(montee);
573
+ return redire(echecs);
574
+ }
575
+ return arreter(
576
+ `⛔ main a avancé à chacune des ${PASSES_MAX} passes : la montée s'arrête sans avancer main.`
577
+ );
578
+ } catch (e) {
579
+ return arreter(`⛔ Montée ${version} : ${e.message}`);
580
+ }
581
+ }
582
+
583
+ /** The montée this process plays the rest of, from the variable of the launching command, or null. */
584
+ export function monteeRecue(env = process.env) {
585
+ const recue = env[VARIABLE_DE_LA_MONTEE];
586
+ delete env[VARIABLE_DE_LA_MONTEE];
587
+ return recue ? JSON.parse(recue) : null;
588
+ }
package/scripts/nuit.sh CHANGED
@@ -44,9 +44,10 @@
44
44
  # path, whatever the environment of the night's launcher; a faulty key turns the night red, the
45
45
  # log naming it, and nothing runs.
46
46
  # - TEMPORAL: after the tools of the project, before any command, the night lays the pinned program of
47
- # Temporal down (`grillhouse temporal installer --programme-seul`, by the built command of the
48
- # version playing the night, not the copy's: the copy has no build yet; idempotent: a program
49
- # already laid down is not downloaded again) and exports its path as TEMPORAL, over any key left
47
+ # Temporal down (`grillhouse temporal installer --programme-seul`, by the command of the
48
+ # version playing the night, in the frame's repository the published version the key
49
+ # grillhouse.outil names, never the copy's code: the copy has no build yet; idempotent: a
50
+ # program already laid down is not downloaded again) and exports its path as TEMPORAL, over any key left
50
51
  # in a package.json. A laying that fails does not stop the night: the log names it, TEMPORAL
51
52
  # stays unset, and a test that starts a server resolves the program from the shared cache
52
53
  # (~/.cache/grillhouse/temporal/<version>/temporal), or fails on itself naming the command that
@@ -119,7 +120,10 @@
119
120
  # among them), else the full pass by its command, the night tests, the project's
120
121
  # night script by its command, or the preparation when the night is red before any step. Each
121
122
  # red task comments the open ticket labelled `nuit` whose title names it (« <task> »), once per
122
- # ticket, or opens its own, « La nuit est rouge sur « <task> » depuis la nuit du <date> ». The
123
+ # ticket, or opens its own, « La nuit est rouge sur « <task> » depuis la nuit du <date> ». Its
124
+ # title, « number — subject — components », is one the departure of a circuit reads, so that
125
+ # the ticket launches itself; fixes may be created under it. Its components are those of a defect
126
+ # of the CI of main (scripts/ci-de-main.mjs), over the lots entered since the last green. The
123
127
  # text, the same for each, gives the commits since the last green, where `git bisect` looks for
124
128
  # the culprit, each red step and each red task, with or without a last green, then the end of
125
129
  # the log. With a last green, each red task of the full pass that comes with its command gets the
@@ -333,8 +337,9 @@ jouer() {
333
337
  fi
334
338
  eval "$outils"
335
339
  # The pinned program of Temporal, laid down and exported for every command. The command is that
336
- # of the version playing the night (already built), not the copy's: the copy is cleaned of its
337
- # build and has no node_modules before the `npm ci` below.
340
+ # of the version playing the night (already built; in the frame's repository the published one,
341
+ # installation.md §5.5), not the copy's code: the copy is cleaned of its build and has no
342
+ # node_modules before the `npm ci` below.
338
343
  local temporal
339
344
  if temporal=$(env -C "$copie" node "$ici/../bin/grillhouse.mjs" temporal installer --programme-seul); then
340
345
  export TEMPORAL="$temporal"
@@ -481,8 +486,9 @@ fi
481
486
  ouverts=
482
487
  commentes=" "
483
488
  # Reports one cause: comments the open night ticket whose title names it (once a night), or opens
484
- # its own (title « number — subject — parent », the number being the id without the project's
485
- # prefix as `prefixe` reads it in `.beads/config.yaml`, the subject naming « <cause> »); its id goes to
489
+ # its own (title « number — subject — components », the number being the id without the project's
490
+ # prefix as `prefixe` reads it in `.beads/config.yaml`, the subject naming « <cause> », the
491
+ # components those of `composants`; without a prefix, « subject — components »); its id goes to
486
492
  # `numero`.
487
493
  signaler() {
488
494
  local cause="$1" sujet="$2" texte="$3" ouvert neuf= prefixe
@@ -496,9 +502,9 @@ signaler() {
496
502
  commentes="$commentes$ouvert " ;;
497
503
  esac
498
504
  else
499
- neuf="$(cd "$racine" && bd create "$sujet" -t bug -p 1 -l nuit -d "$texte" --silent)"
505
+ neuf="$(cd "$racine" && bd create "$sujet — $composants" -t bug -p 1 -l nuit -d "$texte" --silent)"
500
506
  if prefixe="$(node "$ici/prefixe-des-tickets.mjs" "$racine" 2>&1)"; then
501
- [ -n "$neuf" ] && (cd "$racine" && bd update "$neuf" --title "${neuf#"$prefixe"-} — $sujet — parent" >/dev/null)
507
+ [ -n "$neuf" ] && (cd "$racine" && bd update "$neuf" --title "${neuf#"$prefixe"-} — $sujet — $composants" >/dev/null)
502
508
  else
503
509
  echo "⛔ ${prefixe}" >> "$journal"
504
510
  fi
@@ -543,8 +549,11 @@ $liste
543
549
  Journal : $journal
544
550
  Fin du journal :
545
551
  $(tail -40 "$journal")"
546
- # Each red task reports on the night ticket that names it, else on its own; a night ticket is the
547
- # mother of its fixes.
552
+ # The components of a ticket the night opens: those of the lots entered since its last green.
553
+ composants="$(node "$ici/ci-de-main.mjs" composants "$racine" "$vert" "$tete" 2>> "$journal")"
554
+ [ -n "$composants" ] || composants=.
555
+ # Each red task reports on the night ticket that names it, else on its own: a defect ticket that
556
+ # launches itself, under which its fixes may be created.
548
557
  for tache in "${taches[@]}"; do
549
558
  signaler "$tache" "La nuit est rouge sur « $tache » depuis la nuit du $(date +%Y-%m-%d)" "$texte"
550
559
  echo "✗ rouge : ticket ${numero:-neuf} (étiquette nuit) sur « $tache »." >> "$journal"
package/scripts/outil.mjs CHANGED
@@ -16,9 +16,11 @@ import path from 'node:path';
16
16
  import { pathToFileURL } from 'node:url';
17
17
  import { CLE, installer, NOM_DU_PAQUET, versionDeLOutil, X_Y_Z } from './aiguillage.mjs';
18
18
 
19
- // Writes <version> as the key of the package.json at <racine>, its other fields and its
20
- // indentation kept.
21
- function ecrireLaCle(racine, version) {
19
+ /**
20
+ * Writes `version` as the key of the package.json at `racine`, its other fields and its
21
+ * indentation kept.
22
+ */
23
+ export function ecrireLaCle(racine, version) {
22
24
  const f = path.join(racine, 'package.json');
23
25
  const texte = readFileSync(f, 'utf8');
24
26
  const pkg = JSON.parse(texte);