@roomi-fields/grillhouse 0.32.0 → 0.33.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.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +22 -0
- package/bin/grillhouse.mjs +6 -4
- package/cadre/templates/projet/.github/workflows/ci.yml +136 -16
- package/cadre/templates/projet/.github/workflows/nuit.yml +111 -0
- package/cadre/templates/projet/deployment/docs/01-INSTALL.md +4 -4
- package/cadre/templates/projet/package.json +2 -2
- package/charte.md +8 -5
- package/dist/temporal/circuit/contrat.d.ts +15 -0
- package/dist/temporal/circuit/deroule.js +37 -14
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/deroules.d.ts +1 -0
- package/dist/temporal/deroules.js +3 -1
- package/dist/temporal/deroules.js.map +1 -1
- package/dist/temporal/file/activites.d.ts +1 -0
- package/dist/temporal/file/activites.js +5 -2
- package/dist/temporal/file/activites.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +50 -33
- package/dist/temporal/file/contrat.js +2 -2
- package/dist/temporal/file/contrat.js.map +1 -1
- package/dist/temporal/file/deroule.d.ts +3 -1
- package/dist/temporal/file/deroule.js +128 -26
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/nuits/activites.d.ts +10 -0
- package/dist/temporal/nuits/activites.js +114 -0
- package/dist/temporal/nuits/activites.js.map +1 -0
- package/dist/temporal/nuits/appel.d.ts +23 -0
- package/dist/temporal/nuits/appel.js +40 -0
- package/dist/temporal/nuits/appel.js.map +1 -0
- package/dist/temporal/nuits/choix.d.ts +14 -0
- package/dist/temporal/nuits/choix.js +119 -0
- package/dist/temporal/nuits/choix.js.map +1 -0
- package/dist/temporal/nuits/client.d.ts +28 -0
- package/dist/temporal/nuits/client.js +83 -0
- package/dist/temporal/nuits/client.js.map +1 -0
- package/dist/temporal/nuits/commande.d.ts +2 -0
- package/dist/temporal/nuits/commande.js +107 -0
- package/dist/temporal/nuits/commande.js.map +1 -0
- package/dist/temporal/nuits/contrat.d.ts +98 -0
- package/dist/temporal/nuits/contrat.js +30 -0
- package/dist/temporal/nuits/contrat.js.map +1 -0
- package/dist/temporal/nuits/deroule.d.ts +5 -0
- package/dist/temporal/nuits/deroule.js +100 -0
- package/dist/temporal/nuits/deroule.js.map +1 -0
- package/dist/temporal/travailleur.js +4 -1
- package/dist/temporal/travailleur.js.map +1 -1
- package/docs/ARCHITECTURE.md +186 -45
- package/docs/CADRE.md +31 -1
- package/docs/INTERFACE.md +45 -6
- package/hooks/register.tsx +11 -3
- package/package.json +4 -1
- package/scripts/abi-des-dependances.mjs +105 -0
- package/scripts/activites.mjs +94 -41
- package/scripts/aiguillage.mjs +1 -0
- package/scripts/avancement.mjs +8 -18
- package/scripts/ci-des-branches.mjs +91 -0
- package/scripts/circuit.mjs +79 -4
- package/scripts/composants-affectes.mjs +24 -7
- package/scripts/composition-des-langages.mjs +3 -0
- package/scripts/crochets.mjs +4 -0
- package/scripts/enveloppe/enveloppe.mjs +3 -1
- package/scripts/enveloppe/lancer.sh +1 -1
- package/scripts/enveloppe/travail-de-la-copie.mjs +219 -59
- package/scripts/etapes.mjs +18 -1
- package/scripts/faits-du-circuit.mjs +43 -20
- package/scripts/fichier-du-poste.mjs +87 -0
- package/scripts/grillhouse-maj.mjs +15 -1
- package/scripts/integration/file.mjs +215 -275
- package/scripts/integration/integrer.mjs +82 -41
- package/scripts/integration/rejeu.mjs +13 -64
- package/scripts/jointure.d.ts +26 -2
- package/scripts/langages/cargo/commandes.mjs +81 -19
- package/scripts/langages/cargo/exemples.mjs +2 -2
- package/scripts/langages/cargo/index.mjs +11 -5
- package/scripts/langages/cargo/tailles-des-tests.mjs +19 -11
- package/scripts/langages/python/commandes.mjs +11 -7
- package/scripts/langages/python/exemples.mjs +1 -1
- package/scripts/langages/python/index.mjs +9 -2
- package/scripts/langages/python/tailles-des-tests.mjs +19 -11
- package/scripts/langages/typescript/code-mort.mjs +41 -24
- package/scripts/langages/typescript/consommateurs.mjs +28 -17
- package/scripts/langages/typescript/exemples.mjs +2 -0
- package/scripts/langages/typescript/index.mjs +22 -3
- package/scripts/langages/typescript/migrations/0.33.0-binaire-de-jour.mjs +34 -0
- package/scripts/langages/typescript/migrations/0.33.0-tests-du-poste.mjs +31 -0
- package/scripts/langages/typescript/resumes.mjs +17 -7
- package/scripts/langages/typescript/tailles-des-tests.mjs +251 -22
- package/scripts/langages/typescript/tests-de-nuit.mjs +101 -9
- package/scripts/langages/typescript/tests-du-poste.mjs +172 -0
- package/scripts/langages/typescript/tranches.mjs +273 -0
- package/scripts/langages/typescript/verifier.mjs +131 -29
- package/scripts/langages/typescript/vitest-config/cibles.mjs +78 -7
- package/scripts/langages/typescript/vitest-config/lances.mjs +4 -4
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +9 -0
- package/scripts/langages/typescript/vitest.nuit.config.mjs +3 -2
- package/scripts/lint-des-scripts.mjs +23 -6
- package/scripts/migrations/0.33.0-cache-distant.mjs +36 -0
- package/scripts/migrations/0.33.0-ci-des-branches-de-ticket.mjs +31 -0
- package/scripts/migrations/0.33.0-ci-du-cadre.mjs +31 -0
- package/scripts/migrations/0.33.0-node-26.mjs +58 -0
- package/scripts/migrations.mjs +8 -0
- package/scripts/newday.mjs +18 -0
- package/scripts/nuit.sh +35 -17
- package/scripts/registre.d.mts +90 -0
- package/scripts/registre.mjs +28 -3
- package/scripts/reprise.mjs +12 -8
- package/scripts/services-du-noyau.mjs +4 -0
- package/scripts/session-start.sh +28 -32
- package/scripts/sous-commandes.mjs +29 -10
- package/scripts/tableau.mjs +124 -17
- package/scripts/taches-du-graphe.mjs +39 -6
- package/scripts/transitions.mjs +42 -3
- package/scripts/verrou-de-machine.mjs +1 -2
- package/scripts/workflows-du-cadre.mjs +75 -0
- package/skills/grill/SKILL.md +8 -6
- package/skills/pitmaster/SKILL.md +5 -4
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// npx grillhouse verifier [<argument of Turborepo>…] (npm run verifier -- --force)
|
|
7
7
|
// npx grillhouse verifier --tout [<argument>…] every test, played for real
|
|
8
8
|
// npx grillhouse verifier --gardes [<argument>…] the guards alone (the reviewer)
|
|
9
|
+
// npx grillhouse verifier --sans-tests [<argument>…] every control but the tests
|
|
10
|
+
// npx grillhouse verifier --tranche i/n [<argument>…] the tests of the tranche i of n
|
|
9
11
|
//
|
|
10
12
|
// - A pass measures itself against the last green (scripts/dernier-vert.mjs), as
|
|
11
13
|
// `vitest --changed` and `jest --onlyChanged` do: the tree of the last pass green on every
|
|
@@ -80,6 +82,18 @@
|
|
|
80
82
|
// run of Turborepo gets it in TMPDIR, TMP and TEMP, the root's `globalPassThroughEnv` passing
|
|
81
83
|
// TMPDIR on to every task (scripts/langages/typescript/turbo-des-paquets.mjs), and the pass
|
|
82
84
|
// removes it at its end, green, red or interrupted (SIGINT, SIGTERM, SIGHUP).
|
|
85
|
+
// - `--sans-tests` plays every task of the pass but the tests: the guards, the typing, the format
|
|
86
|
+
// check and the lint (`turbo run grillhouse:gardes gardes typecheck format:check lint …`), with no
|
|
87
|
+
// measure; `--tranche i/n` plays the tasks of tests alone (`turbo run test:unit …`), with the
|
|
88
|
+
// builds they depend on, each package of Vitest playing the i-th of n parts of its test files
|
|
89
|
+
// (./tranches.mjs): the n tranches and `--sans-tests` together play the complete pass, each task
|
|
90
|
+
// once, as the CI plays it, one job each. A tranche is measured as the pass is (against the last
|
|
91
|
+
// green or its `--base`; complete with `--tout`), carries itself in the variable
|
|
92
|
+
// `GRILLHOUSE_TESTS`, which the hash of the tests counts (two tranches never replay one another
|
|
93
|
+
// from the cache), plays for real, since it writes its reports (./tranches.mjs, under
|
|
94
|
+
// `.vitest-reports/`, its former ones removed first), and never keeps its tree as the last green,
|
|
95
|
+
// green or not; neither does `--sans-tests`. A tranche not of the form `i/n` (1 ≤ i ≤ n), or given
|
|
96
|
+
// with `--gardes` or `--sans-tests`, is refused before any work, code 1.
|
|
83
97
|
// - The run plays without the paths of a targeted run's tests: the variable `GRILLHOUSE_TESTS`
|
|
84
98
|
// (scripts/langages/typescript/vitest-config/cibles.mjs) carries only `rejouer`, for a complete
|
|
85
99
|
// pass.
|
|
@@ -95,6 +109,8 @@ import {
|
|
|
95
109
|
CHANGEMENTS,
|
|
96
110
|
garderLeTotal,
|
|
97
111
|
garderLeVert,
|
|
112
|
+
LA_FORME,
|
|
113
|
+
lireLaTranche,
|
|
98
114
|
mesure,
|
|
99
115
|
nommerLAvancement,
|
|
100
116
|
ouvrirAvancement,
|
|
@@ -106,6 +122,7 @@ import {
|
|
|
106
122
|
testsCibles,
|
|
107
123
|
} from '../../services-du-noyau.mjs';
|
|
108
124
|
import { paquets, TYPAGE } from '../../paquets.mjs';
|
|
125
|
+
import { fichiersDeLaTranche, RAPPORTS } from './tranches.mjs';
|
|
109
126
|
import { controlesDuDepot, planifier } from './turbo-des-paquets.mjs';
|
|
110
127
|
import { garderLesResumes } from './verdict.mjs';
|
|
111
128
|
|
|
@@ -136,6 +153,12 @@ export function verifier({
|
|
|
136
153
|
dire = l => process.stdout.write(`${l}\n`),
|
|
137
154
|
coeurs = availableParallelism(),
|
|
138
155
|
}) {
|
|
156
|
+
// A malformed request is refused before any work.
|
|
157
|
+
const { erreur } = lireLesDemandes(demandes);
|
|
158
|
+
if (erreur) {
|
|
159
|
+
dire(erreur);
|
|
160
|
+
return 1;
|
|
161
|
+
}
|
|
139
162
|
// The base of the pass, in the temporary directory of <env>: every task writes in it (TMPDIR,
|
|
140
163
|
// which Turborepo passes on), and it goes at the end of the pass.
|
|
141
164
|
const base = ouvrirBase('verification', { dans: env.TMPDIR || tmpdir() });
|
|
@@ -200,28 +223,40 @@ function depotAvecTests(racine) {
|
|
|
200
223
|
const filtre = args => args.some(a => a.startsWith('--filter=') || a === '--filter' || a === '-F');
|
|
201
224
|
|
|
202
225
|
// A pass green on every package keeps its tree as the last green (`garder`): not when it is
|
|
203
|
-
// restricted by a filter
|
|
204
|
-
|
|
205
|
-
|
|
226
|
+
// restricted by a filter or to a part of its tasks (<partielle>: a tranche, `--sans-tests`),
|
|
227
|
+
// measured against nothing, or run after a red module (PASSE_ROUGE).
|
|
228
|
+
export function poserLeVert({ code, etat, args, env, garder, partielle = false }) {
|
|
229
|
+
if (code === 0 && etat && !partielle && !filtre(args) && !env[PASSE_ROUGE]) {
|
|
206
230
|
garder(etat);
|
|
207
231
|
}
|
|
208
232
|
}
|
|
209
233
|
|
|
210
|
-
// The options of the pass in <demandes>: `{ gardesSeules, tout, base, args
|
|
211
|
-
// (or `--base=<commit>`) belongs to the verification alone: it never
|
|
212
|
-
// '' when it has no value (alone, or followed by another option), and
|
|
213
|
-
// given or when the guards alone ask for
|
|
234
|
+
// The options of the pass in <demandes>: `{ gardesSeules, sansTests, tranche, tout, base, args,
|
|
235
|
+
// erreur }`. `--base <commit>` (or `--base=<commit>`) belongs to the verification alone: it never
|
|
236
|
+
// reaches the tasks, `base` is '' when it has no value (alone, or followed by another option), and
|
|
237
|
+
// undefined when it is not given or when the guards alone, or the pass without its tests, ask for
|
|
238
|
+
// no measure. `--tranche i/n` (or `--tranche=i/n`) neither: `tranche` is `{ index, count }`;
|
|
239
|
+
// `erreur`, the line that refuses a tranche not of the form i/n, or given with `--gardes` or
|
|
240
|
+
// `--sans-tests`.
|
|
214
241
|
export function lireLesDemandes(demandes) {
|
|
215
242
|
const gardesSeules = demandes.includes('--gardes');
|
|
243
|
+
const sansTests = demandes.includes('--sans-tests');
|
|
216
244
|
const tout = demandes.includes('--tout') || demandes.includes('--force');
|
|
217
245
|
let base;
|
|
246
|
+
let texte;
|
|
218
247
|
const args = [];
|
|
219
248
|
for (let i = 0; i < demandes.length; i++) {
|
|
220
249
|
const a = demandes[i];
|
|
221
|
-
if (a === '--gardes' || a === '--tout') {
|
|
250
|
+
if (a === '--gardes' || a === '--tout' || a === '--sans-tests') {
|
|
222
251
|
continue;
|
|
223
252
|
}
|
|
224
|
-
if (a === '--
|
|
253
|
+
if (a === '--tranche') {
|
|
254
|
+
const suite = demandes[i + 1];
|
|
255
|
+
texte = suite !== undefined && !suite.startsWith('-') ? suite : '';
|
|
256
|
+
i += texte ? 1 : 0;
|
|
257
|
+
} else if (a.startsWith('--tranche=')) {
|
|
258
|
+
texte = a.slice('--tranche='.length);
|
|
259
|
+
} else if (a === '--base') {
|
|
225
260
|
const suite = demandes[i + 1];
|
|
226
261
|
if (suite !== undefined && !suite.startsWith('-')) {
|
|
227
262
|
base = suite;
|
|
@@ -235,21 +270,81 @@ export function lireLesDemandes(demandes) {
|
|
|
235
270
|
args.push(a);
|
|
236
271
|
}
|
|
237
272
|
}
|
|
238
|
-
|
|
273
|
+
const tranche = texte === undefined ? undefined : (lireLaTranche(texte) ?? undefined);
|
|
274
|
+
let erreur;
|
|
275
|
+
if (texte !== undefined && !tranche) {
|
|
276
|
+
erreur = `⛔ --tranche attend la forme ${LA_FORME}, deux entiers avec 1 ≤ i ≤ n (par exemple --tranche 1/3) : « ${texte} » ne l'a pas.`;
|
|
277
|
+
} else if (tranche && (gardesSeules || sansTests)) {
|
|
278
|
+
erreur = `⛔ --tranche joue les seuls tests : elle ne se combine ni avec --gardes ni avec --sans-tests.`;
|
|
279
|
+
}
|
|
280
|
+
const mesure = !gardesSeules && !sansTests;
|
|
281
|
+
return {
|
|
282
|
+
gardesSeules,
|
|
283
|
+
sansTests,
|
|
284
|
+
tranche,
|
|
285
|
+
tout,
|
|
286
|
+
base: mesure ? base : undefined,
|
|
287
|
+
args,
|
|
288
|
+
...(erreur ? { erreur } : {}),
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* The tasks of Turborepo a pass plays, from its options (`lireLesDemandes`), <controles> the tasks
|
|
294
|
+
* of the format check and the lint of the repository (`controlesDuDepot`): a tranche, the tests
|
|
295
|
+
* alone; `--gardes`, the guards and the controls; `--sans-tests`, every task but the tests; else
|
|
296
|
+
* every task.
|
|
297
|
+
* @param {{ gardesSeules?: boolean, sansTests?: boolean, tranche?: object }} demandes
|
|
298
|
+
* @param {string[]} controles
|
|
299
|
+
* @returns {string[]}
|
|
300
|
+
*/
|
|
301
|
+
export function tachesDeLaPasse({ gardesSeules, sansTests, tranche }, controles) {
|
|
302
|
+
if (tranche) {
|
|
303
|
+
return [SCRIPT_DES_TESTS];
|
|
304
|
+
}
|
|
305
|
+
if (gardesSeules) {
|
|
306
|
+
return [...GARDES, ...controles];
|
|
307
|
+
}
|
|
308
|
+
if (sansTests) {
|
|
309
|
+
return [...GARDES, TYPAGE, ...controles];
|
|
310
|
+
}
|
|
311
|
+
return [...TACHES, ...controles];
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* The content of the variable of the tests (`GRILLHOUSE_TESTS`) for the tranche <tranche> of a pass
|
|
316
|
+
* in <racine>: the tranche and the directory of its reports, and the moment of the pass, which no
|
|
317
|
+
* cached run holds.
|
|
318
|
+
* @param {{ index: number, count: number }} tranche
|
|
319
|
+
* @param {string} racine
|
|
320
|
+
*/
|
|
321
|
+
export function testsDeLaTranche(tranche, racine) {
|
|
322
|
+
return {
|
|
323
|
+
...testsCibles({ arguments: [], force: true }),
|
|
324
|
+
tranche: `${tranche.index}/${tranche.count}`,
|
|
325
|
+
rapports: path.join(racine, RAPPORTS),
|
|
326
|
+
};
|
|
239
327
|
}
|
|
240
328
|
|
|
241
329
|
function passe({ racine, demandes, env, dire, coeurs }) {
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
330
|
+
const lu = lireLesDemandes(demandes);
|
|
331
|
+
const { gardesSeules, sansTests, tranche, tout, base, args } = lu;
|
|
332
|
+
// The measure against the last green, or the base given: a pass without tests needs none.
|
|
333
|
+
const m = gardesSeules || sansTests ? null : mesure(racine, { tout, base, dans: env.TMPDIR });
|
|
245
334
|
if (m) {
|
|
246
335
|
dire(m.ligne);
|
|
247
336
|
}
|
|
248
337
|
const taches = new Set();
|
|
249
338
|
try {
|
|
339
|
+
// A tranche writes its reports anew.
|
|
340
|
+
if (tranche) {
|
|
341
|
+
for (const f of fichiersDeLaTranche(path.join(racine, RAPPORTS), tranche)) {
|
|
342
|
+
rmSync(f, { force: true });
|
|
343
|
+
}
|
|
344
|
+
}
|
|
250
345
|
const code = jouerLaPasse({
|
|
251
346
|
racine,
|
|
252
|
-
|
|
347
|
+
demandes: lu,
|
|
253
348
|
args,
|
|
254
349
|
tout,
|
|
255
350
|
ajouts: m?.env ?? {},
|
|
@@ -262,36 +357,43 @@ function passe({ racine, demandes, env, dire, coeurs }) {
|
|
|
262
357
|
writeFileSync(env[ROUGES], [...taches].map(t => `${t}\t${rejeu(t)}\n`).join(''));
|
|
263
358
|
}
|
|
264
359
|
// A pass green on every package keeps its tree as the last green.
|
|
265
|
-
poserLeVert({
|
|
360
|
+
poserLeVert({
|
|
361
|
+
code,
|
|
362
|
+
etat: m?.etat,
|
|
363
|
+
args,
|
|
364
|
+
env,
|
|
365
|
+
garder: garderLeVert,
|
|
366
|
+
partielle: Boolean(tranche) || sansTests,
|
|
367
|
+
});
|
|
266
368
|
return code;
|
|
267
369
|
} finally {
|
|
268
370
|
m?.retirer();
|
|
269
371
|
}
|
|
270
372
|
}
|
|
271
373
|
|
|
272
|
-
function jouerLaPasse({ racine,
|
|
374
|
+
function jouerLaPasse({ racine, demandes, args, tout, ajouts, env, dire, coeurs, taches }) {
|
|
375
|
+
const { gardesSeules, sansTests, tranche } = demandes;
|
|
273
376
|
const { [TESTS_CIBLES]: _, [CHANGEMENTS]: __, ...propre } = env;
|
|
274
377
|
// The environment of the run: measured against the last green; the moment of a complete pass,
|
|
275
|
-
// which moves the hash of every task of tests, so that each plays for real.
|
|
276
|
-
const
|
|
277
|
-
?
|
|
278
|
-
:
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
};
|
|
378
|
+
// which moves the hash of every task of tests, so that each plays for real; a tranche, with it.
|
|
379
|
+
const cibles = tranche
|
|
380
|
+
? testsDeLaTranche(tranche, racine)
|
|
381
|
+
: tout
|
|
382
|
+
? testsCibles({ arguments: [], force: true })
|
|
383
|
+
: undefined;
|
|
384
|
+
const e =
|
|
385
|
+
gardesSeules || sansTests
|
|
386
|
+
? propre
|
|
387
|
+
: { ...propre, ...ajouts, ...(cibles ? { [TESTS_CIBLES]: JSON.stringify(cibles) } : {}) };
|
|
285
388
|
const borne = args.some(a => CONCURRENCE.test(a)) ? [] : [`--concurrency=${concurrence(coeurs)}`];
|
|
286
389
|
const a = [
|
|
287
|
-
...(
|
|
288
|
-
...controlesDuDepot(racine),
|
|
390
|
+
...tachesDeLaPasse(demandes, controlesDuDepot(racine)),
|
|
289
391
|
'--continue=dependencies-successful',
|
|
290
392
|
...borne,
|
|
291
393
|
...args,
|
|
292
394
|
];
|
|
293
395
|
// The plan of the run, before it: the progress knows all its tasks.
|
|
294
|
-
if (!gardesSeules && depotAvecTests(racine)) {
|
|
396
|
+
if (!gardesSeules && !sansTests && depotAvecTests(racine)) {
|
|
295
397
|
planifier(env[AVANCEMENT], { racine, args: a, env: e });
|
|
296
398
|
}
|
|
297
399
|
// The run of Turborepo, and its summary.
|
|
@@ -38,9 +38,15 @@
|
|
|
38
38
|
// Vitest's `passWithNoTests: false`.
|
|
39
39
|
// - The night's configuration (scripts/langages/typescript/vitest.nuit.config.mjs) plays what the
|
|
40
40
|
// day leaves out, through the plugin `nuit`: the night tests, the benches and the witnesses; the
|
|
41
|
-
// variable `GRILLHOUSE_TESTS_DE_NUIT` (NUIT_VARIABLE) chooses `nuit`, the night tests alone,
|
|
42
|
-
// `
|
|
43
|
-
//
|
|
41
|
+
// variable `GRILLHOUSE_TESTS_DE_NUIT` (NUIT_VARIABLE) chooses `nuit`, the night tests alone,
|
|
42
|
+
// `hors-poste`, the night tests but those that bear the tag `@poste` at their head (the night of
|
|
43
|
+
// a shared machine), or `mesures`, the benches and the witnesses alone, one file at a time
|
|
44
|
+
// (`fileParallelism: false`), as scripts/langages/typescript/tests-de-nuit.mjs plays them; the
|
|
45
|
+
// variable `GRILLHOUSE_TRANCHE_DE_NUIT` (NUIT_TRANCHE) gives the run its tranche, as a tranche of
|
|
46
|
+
// the day (`trancher`, ../tranches.mjs).
|
|
47
|
+
// - A tranche of a pass (`tranche`, `i/n`, and `rapports` in the value, `npm run verifier --
|
|
48
|
+
// --tranche i/n`) plays its part of the files alone, writes its blob report and the files of its
|
|
49
|
+
// part (`trancher`, ../tranches.mjs).
|
|
44
50
|
// - The changes since the last green (`GRILLHOUSE_CHANGEMENTS`, ./changements.mjs) restrict the
|
|
45
51
|
// files played to those Vitest relates to them, the files named themselves kept, or leave every
|
|
46
52
|
// test when a change lies out of Vitest's graph.
|
|
@@ -48,6 +54,7 @@
|
|
|
48
54
|
import { globSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
49
55
|
import path from 'node:path';
|
|
50
56
|
import { CHANGEMENTS, TESTS_CIBLES } from '../../../services-du-noyau.mjs';
|
|
57
|
+
import { trancher } from '../tranches.mjs';
|
|
51
58
|
import { lireChangements, restreindre } from './changements.mjs';
|
|
52
59
|
|
|
53
60
|
// The name of the variable is the core's (`TESTS_CIBLES`); this module reads it under its own name.
|
|
@@ -60,6 +67,11 @@ export const BUDGET = '**/*.budget.{test,spec}.?(c|m)[jt]s?(x)';
|
|
|
60
67
|
export const HORS_DU_JOUR = [NUIT, BUDGET];
|
|
61
68
|
/** The variable that chooses the tests of a run of the night's configuration: `nuit` or `mesures`. */
|
|
62
69
|
export const NUIT_VARIABLE = 'GRILLHOUSE_TESTS_DE_NUIT';
|
|
70
|
+
/**
|
|
71
|
+
* The variable that carries the tranche of a run of the night's configuration, JSON: `tranche`,
|
|
72
|
+
* `i/n`, and `rapports`, the directory of its reports (`trancher`, ../tranches.mjs).
|
|
73
|
+
*/
|
|
74
|
+
export const NUIT_TRANCHE = 'GRILLHOUSE_TRANCHE_DE_NUIT';
|
|
63
75
|
// Whether the file at <fichier> bears the name of <motif>, a globstar then a name: by the name of
|
|
64
76
|
// the file, since a globstar passes no directory whose name starts with a dot, and a ticket's copy
|
|
65
77
|
// lives under `.claude/worktrees/`.
|
|
@@ -71,6 +83,28 @@ export const estUnTestDeNuit = fichier => parSonNom(fichier, NUIT);
|
|
|
71
83
|
export const estUnBanc = fichier => parSonNom(fichier, BUDGET);
|
|
72
84
|
/** Whether the file at <fichier> is a night test or a time budget bench, by its name. */
|
|
73
85
|
export const deNuitOuBanc = fichier => HORS_DU_JOUR.some(p => parSonNom(fichier, p));
|
|
86
|
+
// The tag of a night test that depends on the poste (its envelope, its tools, its session): a line
|
|
87
|
+
// `// @poste` of the comment at the head of the file, before its first line of code, its reason
|
|
88
|
+
// after it (`// @poste: l'enveloppe bwrap`), as Bazel's tags (`manual`, `exclusive`) and pytest's
|
|
89
|
+
// markers live with the test.
|
|
90
|
+
const ETIQUETTE_DU_POSTE = /^\/\/\s*@poste\b/;
|
|
91
|
+
/**
|
|
92
|
+
* Whether the text <texte> of a test file bears the tag `@poste` in the comment at its head: the
|
|
93
|
+
* night of a shared machine (`hors-poste`) leaves it out, the night of the poste plays it.
|
|
94
|
+
* @param {string} texte the text of the file
|
|
95
|
+
*/
|
|
96
|
+
export function porteLEtiquetteDuPoste(texte) {
|
|
97
|
+
for (const ligne of texte.split('\n')) {
|
|
98
|
+
const l = ligne.trim();
|
|
99
|
+
if (ETIQUETTE_DU_POSTE.test(l)) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
if (l !== '' && !l.startsWith('//') && !l.startsWith('#!')) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
74
108
|
// Vitest's default `include` (its configDefaults).
|
|
75
109
|
const INCLUDE = ['**/*.{test,spec}.?(c|m)[jt]s?(x)'];
|
|
76
110
|
// The mark of a time witness: the import of `mesurerAuRepos`, on a line of its own, from the
|
|
@@ -165,7 +199,11 @@ export const ciblage = (env = process.env, dire = l => process.stdout.write(`${l
|
|
|
165
199
|
// The files a targeted run names themselves, absolute.
|
|
166
200
|
let nommes = [];
|
|
167
201
|
if (texte) {
|
|
168
|
-
|
|
202
|
+
const valeur = JSON.parse(texte);
|
|
203
|
+
nommes = await cibler(config, test, valeur, new Set(temoins));
|
|
204
|
+
if (valeur.tranche) {
|
|
205
|
+
await trancher(config, test, valeur);
|
|
206
|
+
}
|
|
169
207
|
}
|
|
170
208
|
// The witnesses out of the day, but those named themselves (in the include then).
|
|
171
209
|
const joues = new Set(Array.isArray(test.include) ? test.include : []);
|
|
@@ -244,26 +282,59 @@ async function cibler(config, test, valeur, temoins) {
|
|
|
244
282
|
return nommes;
|
|
245
283
|
}
|
|
246
284
|
|
|
285
|
+
/**
|
|
286
|
+
* The night tests under <dir> that bear the tag `@poste` (`porteLEtiquetteDuPoste`), node_modules,
|
|
287
|
+
* dist, .git, .turbo and .claude left out; each path relative to <dir>, sorted.
|
|
288
|
+
* @param {string} dir the directory searched
|
|
289
|
+
*/
|
|
290
|
+
export function testsDuPoste(dir) {
|
|
291
|
+
return [
|
|
292
|
+
...new Set(
|
|
293
|
+
globSync([NUIT], { cwd: dir, exclude: d => HORS_TEMOINS.has(path.basename(d)) }).map(f =>
|
|
294
|
+
f.split(path.sep).join('/')
|
|
295
|
+
)
|
|
296
|
+
),
|
|
297
|
+
]
|
|
298
|
+
.filter(f => porteLEtiquetteDuPoste(lireTexte(path.join(dir, f))))
|
|
299
|
+
.sort();
|
|
300
|
+
}
|
|
301
|
+
|
|
247
302
|
/**
|
|
248
303
|
* The plugin of the night's configuration: the night tests, the benches and the time witnesses
|
|
249
|
-
* under its directory, or, as <env> chooses in NUIT_VARIABLE, the night tests alone (`nuit`)
|
|
250
|
-
* the
|
|
304
|
+
* under its directory, or, as <env> chooses in NUIT_VARIABLE, the night tests alone (`nuit`), the
|
|
305
|
+
* night tests but those tagged `@poste` (`hors-poste`, the night of a shared machine: a CI), or the
|
|
306
|
+
* measures alone, one file at a time (`mesures`), the benches and the witnesses; with
|
|
307
|
+
* NUIT_TRANCHE, the tranche it carries of these files.
|
|
251
308
|
* @param {NodeJS.ProcessEnv} [env] the environment that holds the choice
|
|
252
309
|
*/
|
|
253
310
|
export const nuit = (env = process.env) => ({
|
|
254
311
|
name: 'grillhouse:nuit',
|
|
255
|
-
config(config) {
|
|
312
|
+
async config(config) {
|
|
256
313
|
const choix = env[NUIT_VARIABLE];
|
|
314
|
+
const tranche = env[NUIT_TRANCHE];
|
|
257
315
|
delete env[NUIT_VARIABLE];
|
|
316
|
+
delete env[NUIT_TRANCHE];
|
|
258
317
|
const test = (config.test ??= {});
|
|
259
318
|
const temoins = temoinsDe(config, { ...test, include: INCLUDE });
|
|
260
319
|
if (choix === 'nuit') {
|
|
261
320
|
test.include = [NUIT];
|
|
321
|
+
} else if (choix === 'hors-poste') {
|
|
322
|
+
test.include = [NUIT];
|
|
323
|
+
const duPoste = testsDuPoste(path.resolve(config.root ?? process.cwd(), test.dir ?? ''));
|
|
324
|
+
if (duPoste.length) {
|
|
325
|
+
test.exclude = [
|
|
326
|
+
...(test.exclude ?? ['**/node_modules/**']),
|
|
327
|
+
...duPoste.map(r => r.replace(SPECIAUX, '\\$&')),
|
|
328
|
+
];
|
|
329
|
+
}
|
|
262
330
|
} else if (choix === 'mesures') {
|
|
263
331
|
test.include = [BUDGET, ...temoins];
|
|
264
332
|
test.fileParallelism = false;
|
|
265
333
|
} else {
|
|
266
334
|
test.include = [...HORS_DU_JOUR, ...temoins];
|
|
267
335
|
}
|
|
336
|
+
if (tranche) {
|
|
337
|
+
await trancher(config, test, JSON.parse(tranche));
|
|
338
|
+
}
|
|
268
339
|
},
|
|
269
340
|
});
|
|
@@ -167,7 +167,7 @@ function sansCommentaires(texte) {
|
|
|
167
167
|
|
|
168
168
|
// The code of <texte>: without its comments, whose words name no path read, nor its imports, whose
|
|
169
169
|
// strings are in Vitest's graph.
|
|
170
|
-
const code = texte => sansCommentaires(texte).replace(IMPORT, '');
|
|
170
|
+
export const code = texte => sansCommentaires(texte).replace(IMPORT, '');
|
|
171
171
|
|
|
172
172
|
// The strings of the code <texte> (without its comments), read character by character: a quoted
|
|
173
173
|
// string, or a template without a substitution, each once.
|
|
@@ -193,9 +193,9 @@ function chainesDe(texte) {
|
|
|
193
193
|
return out;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
function chaines(texte) {
|
|
196
|
+
/** The strings of the code <texte>, then the strings of each call of `join` or `resolve` written
|
|
197
|
+
* together, each once. */
|
|
198
|
+
export function chaines(texte) {
|
|
199
199
|
const jointes = [...texte.matchAll(APPEL)]
|
|
200
200
|
.map(a => chainesDe(a[1]).filter(Boolean))
|
|
201
201
|
.filter(l => l.length > 1)
|
|
@@ -27,3 +27,12 @@ process.env.GRILLHOUSE_MESURE_D_ESSAI ||= JSON.stringify({
|
|
|
27
27
|
});
|
|
28
28
|
process.env.GRILLHOUSE_TEMPORAIRE_LIBRE ||= '0';
|
|
29
29
|
process.env.GRILLHOUSE_COPIE_LIBRE ||= '0';
|
|
30
|
+
// The cache of a test's Turborepo is local alone: the remote cache of the CI or of the poste
|
|
31
|
+
// (scripts/fichier-du-poste.mjs) would serve a repository of trial the tasks another test or run
|
|
32
|
+
// wrote there. `TURBO_CACHE` says local alone; `TURBO_TOKEN`, named empty, keeps the file of the
|
|
33
|
+
// poste unread (`avecLeFichierDuPoste` leaves an environment that names one of its variables).
|
|
34
|
+
for (const nom of ['TURBO_API', 'TURBO_TEAM', 'TURBO_TEAMID', 'TURBO_REMOTE_CACHE_SIGNATURE_KEY']) {
|
|
35
|
+
delete process.env[nom];
|
|
36
|
+
}
|
|
37
|
+
process.env.TURBO_TOKEN = '';
|
|
38
|
+
process.env.TURBO_CACHE = 'local:rw';
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
// its copy (`vitest run --root <copy> --config <this file>`), after a green full pass (`npm run
|
|
9
9
|
// verifier -- --force`) and before the project's night script: its include names the night tests
|
|
10
10
|
// and the benches, and its plugin adds the witnesses under the root, or chooses the night tests
|
|
11
|
-
// alone
|
|
12
|
-
//
|
|
11
|
+
// alone, the night tests but those tagged `@poste` (the night of a shared machine, a CI), or the
|
|
12
|
+
// measures alone, one file at a time (`nuit` of ./vitest-config/cibles.mjs, the variable
|
|
13
|
+
// GRILLHOUSE_TESTS_DE_NUIT). It reads no day configuration of the project, whether the
|
|
13
14
|
// project has one at its root or one per package; it takes from the base configuration the common
|
|
14
15
|
// environment (git's settings) and the measure of time: the setup file that notes the CPU pressure
|
|
15
16
|
// of each test and the duration reporter, which gives 75, « à repasser », to a measure that fails
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { spawnSync } from 'node:child_process';
|
|
7
7
|
import path from 'node:path';
|
|
8
8
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
9
|
-
import { trancher } from './dette.mjs';
|
|
9
|
+
import { MODE, trancher } from './dette.mjs';
|
|
10
10
|
|
|
11
11
|
const DOSSIER = 'packages/grillhouse/scripts';
|
|
12
12
|
// The executable of ESLint in the repository's node_modules, from this file (packages/grillhouse/scripts).
|
|
@@ -43,16 +43,33 @@ export async function verifier(racine) {
|
|
|
43
43
|
return constats;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
// The report of the check at <racine>: `lignes`, what the command writes on stderr (each refusal
|
|
47
|
+
// prefixed with `⛔`, then the debt's lines), and `code`, its exit code (1 on a refusal). The
|
|
48
|
+
// functional core of the command: it runs ESLint and reads the project's debt, and writes nothing to
|
|
49
|
+
// the standard streams; the command below is its shell. The refusals reach SARIF through `trancher`
|
|
50
|
+
// under the results directory <env> names (scripts/resultats.mjs); without it none is written, and
|
|
51
|
+
// the debt's mode is <env>'s `GRILLHOUSE_DETTE`.
|
|
52
|
+
export async function rapport(racine, env = process.env) {
|
|
53
|
+
const { refus, lignes } = trancher(
|
|
54
|
+
racine,
|
|
55
|
+
'lint-des-scripts',
|
|
56
|
+
await verifier(racine),
|
|
57
|
+
env[MODE] || undefined,
|
|
58
|
+
env
|
|
59
|
+
);
|
|
60
|
+
return {
|
|
61
|
+
lignes: [...refus.map(r => `⛔ ${r.message}`), ...lignes],
|
|
62
|
+
code: refus.length ? 1 : 0,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
46
66
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
47
67
|
// The root of the repository: the first argument (the script `lint` of the package passes it),
|
|
48
68
|
// the working directory otherwise.
|
|
49
69
|
const racine = path.resolve(process.argv[2] ?? process.cwd());
|
|
50
|
-
const {
|
|
51
|
-
for (const r of refus) {
|
|
52
|
-
process.stderr.write(`⛔ ${r.message}\n`);
|
|
53
|
-
}
|
|
70
|
+
const { lignes, code } = await rapport(racine);
|
|
54
71
|
for (const l of lignes) {
|
|
55
72
|
process.stderr.write(`${l}\n`);
|
|
56
73
|
}
|
|
57
|
-
process.exitCode =
|
|
74
|
+
process.exitCode = code;
|
|
58
75
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// From 0.33.0 the remote cache of Turborepo is shared between the CI and the poste
|
|
2
|
+
// (grillhouse-44b.12.6): the template's CI takes its server from the repository's variables and
|
|
3
|
+
// secrets, and the commands of the frame on the poste read it from
|
|
4
|
+
// ~/.config/grillhouse/turbo-cache.env, read alone (scripts/fichier-du-poste.mjs).
|
|
5
|
+
//
|
|
6
|
+
// - The migration changes no file: without a server, the CI and the poste keep their local cache,
|
|
7
|
+
// and a marked workflow of the frame reaches the project by the update.
|
|
8
|
+
// - What stays to the project (`restes`), once: a project whose root's turbo.json does not sign
|
|
9
|
+
// the artifacts (`remoteCache.signature`) is told how to plug a server. One that signs them has
|
|
10
|
+
// plugged it already.
|
|
11
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
|
|
14
|
+
export const version = '0.33.0';
|
|
15
|
+
export const nom = 'cache distant';
|
|
16
|
+
|
|
17
|
+
/** Changes nothing: plugging a server is the project's gesture (`restes`). */
|
|
18
|
+
export function migrer() {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Whether the root's turbo.json (or turbo.jsonc) of <projet> signs the artifacts of its remote cache.
|
|
23
|
+
const signe = projet =>
|
|
24
|
+
['turbo.json', 'turbo.jsonc']
|
|
25
|
+
.map(f => path.join(projet, f))
|
|
26
|
+
.some(f => existsSync(f) && /"signature"\s*:\s*true/.test(readFileSync(f, 'utf8')));
|
|
27
|
+
|
|
28
|
+
/** How to plug a server of remote cache, for a project whose turbo.json does not sign. */
|
|
29
|
+
export function restes(projet) {
|
|
30
|
+
if (signe(projet)) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
return [
|
|
34
|
+
'turbo.json : le cache distant de Turborepo se partage entre la CI et le poste, s\'il y a un serveur (facultatif ; sans lui rien ne change). Pour le brancher : les variables TURBO_API et TURBO_TEAM et les secrets TURBO_TOKEN et TURBO_REMOTE_CACHE_SIGNATURE_KEY du dépôt sur GitHub (la CI du cadre les lit : un push vers main ou agent/** écrit, tout autre run lit), `"remoteCache": { "signature": true }` dans le turbo.json racine, et, sur le poste, les quatre mêmes variables dans ~/.config/grillhouse/turbo-cache.env (droits 600), que chaque projet du poste lit seul, sans jamais écrire.',
|
|
35
|
+
];
|
|
36
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// From 0.33.0 the queue enters a lot on main only once the CI of its branch `agent/<ticket>`
|
|
2
|
+
// judged it green (grillhouse-44b.12.5): the CI of the project runs on a push to `agent/**`.
|
|
3
|
+
//
|
|
4
|
+
// - The workflows of `.github/workflows/` that run on a push to the branch main is pushed to, and
|
|
5
|
+
// list the branches of their push, gain `agent/**` (scripts/ci-des-branches.mjs).
|
|
6
|
+
// - A project whose CI already runs on a push to `agent/**` is left, nothing said: a second pass
|
|
7
|
+
// changes nothing.
|
|
8
|
+
// - A project without such a workflow is left; `restes` says the gesture, which the update
|
|
9
|
+
// reports without failing, as the opening of a session names it under « Manque ».
|
|
10
|
+
import {
|
|
11
|
+
ajouterLesBranchesDeTicket,
|
|
12
|
+
BRANCHES_DE_TICKET,
|
|
13
|
+
ecouteLesBranchesDeTicket,
|
|
14
|
+
GESTE,
|
|
15
|
+
} from '../ci-des-branches.mjs';
|
|
16
|
+
|
|
17
|
+
export const version = '0.33.0';
|
|
18
|
+
export const nom = 'ci des branches de ticket';
|
|
19
|
+
|
|
20
|
+
/** Adds `agent/**` to the push of the CI of the lots; returns what it did. */
|
|
21
|
+
export function migrer(projet) {
|
|
22
|
+
return ajouterLesBranchesDeTicket(projet).map(
|
|
23
|
+
f =>
|
|
24
|
+
`${f} : '${BRANCHES_DE_TICKET}' ajoutée aux branches de son push, que la file pousse et dont la CI juge chaque lot`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** What stays to the project: the gesture, while no workflow runs on a push to `agent/**`. */
|
|
29
|
+
export function restes(projet) {
|
|
30
|
+
return ecouteLesBranchesDeTicket(projet) ? [] : [GESTE];
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// From 0.33.0 the frame carries the CI of a project (grillhouse-44b.12.7): the template's
|
|
2
|
+
// `.github/workflows/ci.yml` (the verification in tranches, for a lot) and `nuit.yml` (the night
|
|
3
|
+
// tests out of the poste), each bearing the frame's mark on its first line, which the update keeps
|
|
4
|
+
// (scripts/workflows-du-cadre.mjs).
|
|
5
|
+
//
|
|
6
|
+
// - The migration changes no file: a project's CI is its own until it adopts the frame's, and the
|
|
7
|
+
// update starts no CI on a repository.
|
|
8
|
+
// - What stays to the project (`restes`), once: a project that holds no workflow of the frame is
|
|
9
|
+
// told how to adopt them. One that holds one has nothing to do.
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { CADRE } from '../cadre.mjs';
|
|
12
|
+
import { aLaCiDuCadre, GABARIT_DES_WORKFLOWS, WORKFLOWS } from '../workflows-du-cadre.mjs';
|
|
13
|
+
|
|
14
|
+
export const version = '0.33.0';
|
|
15
|
+
export const nom = 'ci du cadre';
|
|
16
|
+
|
|
17
|
+
/** Changes nothing: the adoption of the frame's CI is the project's gesture (`restes`). */
|
|
18
|
+
export function migrer() {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The adoption of the frame's CI, for a project that holds none of its workflows. */
|
|
23
|
+
export function restes(projet) {
|
|
24
|
+
if (aLaCiDuCadre(projet)) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
const modele = path.relative(projet, path.join(CADRE, GABARIT_DES_WORKFLOWS, 'ci.yml'));
|
|
28
|
+
return [
|
|
29
|
+
`${WORKFLOWS} : le cadre porte la CI d'un projet (ci.yml, le lot en tranches ; nuit.yml, les tests de nuit hors du poste). Pour l'adopter, copier \`${modele}\` dans \`${WORKFLOWS}/\` (un ci.yml du projet cède sa place, ses étapes propres versées ailleurs), puis \`npx grillhouse maj\`, qui écrit nuit.yml et tient les deux à jour. Leur machine : la variable RUNNER du dépôt sur GitHub, facultative (ubuntu-latest sans elle).`,
|
|
30
|
+
];
|
|
31
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// From 0.33.0 the frame runs on Node 24 and 26, the supported long-term releases, Node 26 at the
|
|
2
|
+
// poste (grillhouse-3uv.99): the template's package.json declares `engines.node` `>=24.0.0` and
|
|
3
|
+
// the npm Node 26 ships as its `packageManager`.
|
|
4
|
+
//
|
|
5
|
+
// - A project's package.json that still holds the value of the template before (`engines.node`
|
|
6
|
+
// `>=22.0.0`, `packageManager` `npm@10.9.8`) receives the template's; a value the project chose
|
|
7
|
+
// stays, unsaid.
|
|
8
|
+
// - Only those values change in the text: the rest of the file keeps its bytes.
|
|
9
|
+
// - A project already migrated, or without package.json, is not written: a second pass changes
|
|
10
|
+
// nothing and returns no line.
|
|
11
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { CADRE } from '../cadre.mjs';
|
|
14
|
+
|
|
15
|
+
export const version = '0.33.0';
|
|
16
|
+
export const nom = 'node 26';
|
|
17
|
+
|
|
18
|
+
// The values of the template before this version.
|
|
19
|
+
const MOTEUR_AVANT = '>=22.0.0';
|
|
20
|
+
const GESTIONNAIRE_AVANT = 'npm@10.9.8';
|
|
21
|
+
|
|
22
|
+
// The template's package.json.
|
|
23
|
+
const gabarit = () =>
|
|
24
|
+
JSON.parse(readFileSync(path.join(CADRE, 'templates', 'projet', 'package.json'), 'utf8'));
|
|
25
|
+
|
|
26
|
+
// A text as a pattern that matches it alone.
|
|
27
|
+
const litteral = t => t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
28
|
+
|
|
29
|
+
// <texte> with the first string value <avant> of the key <cle> replaced by <apres>.
|
|
30
|
+
const remplacer = (texte, cle, avant, apres) =>
|
|
31
|
+
texte.replace(
|
|
32
|
+
new RegExp(`("${litteral(cle)}"\\s*:\\s*)${litteral(JSON.stringify(avant))}`),
|
|
33
|
+
(_, debut) => `${debut}${JSON.stringify(apres)}`
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
/** Gives the project the template's engines and npm when it holds the former ones. */
|
|
37
|
+
export function migrer(projet) {
|
|
38
|
+
const f = path.join(projet, 'package.json');
|
|
39
|
+
if (!existsSync(f)) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
let texte = readFileSync(f, 'utf8');
|
|
43
|
+
const pkg = JSON.parse(texte);
|
|
44
|
+
const neuf = gabarit();
|
|
45
|
+
const lignes = [];
|
|
46
|
+
if (pkg.engines?.node === MOTEUR_AVANT && neuf.engines?.node !== MOTEUR_AVANT) {
|
|
47
|
+
texte = remplacer(texte, 'node', MOTEUR_AVANT, neuf.engines.node);
|
|
48
|
+
lignes.push(`package.json : engines.node passe à ${neuf.engines.node}`);
|
|
49
|
+
}
|
|
50
|
+
if (pkg.packageManager === GESTIONNAIRE_AVANT && neuf.packageManager !== GESTIONNAIRE_AVANT) {
|
|
51
|
+
texte = remplacer(texte, 'packageManager', GESTIONNAIRE_AVANT, neuf.packageManager);
|
|
52
|
+
lignes.push(`package.json : packageManager passe à ${neuf.packageManager}`);
|
|
53
|
+
}
|
|
54
|
+
if (lignes.length) {
|
|
55
|
+
writeFileSync(f, texte);
|
|
56
|
+
}
|
|
57
|
+
return lignes;
|
|
58
|
+
}
|