@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.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +769 -0
- package/agents/developpeur.md +0 -1
- package/agents/explorateur.md +0 -1
- package/agents/questionneur.md +0 -1
- package/agents/testwriter.md +0 -1
- package/bin/grillhouse.mjs +79 -18
- package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
- package/cadre/templates/projet/CLAUDE.md +5 -1
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/cadre/templates/projet/package.json +2 -2
- package/charte.md +24 -0
- package/dist/temporal/acte.d.ts +24 -0
- package/dist/temporal/acte.js +139 -0
- package/dist/temporal/acte.js.map +1 -0
- package/dist/temporal/attributs.d.ts +6 -0
- package/dist/temporal/attributs.js +15 -0
- package/dist/temporal/attributs.js.map +1 -0
- package/dist/temporal/circuit/activites.d.ts +13 -0
- package/dist/temporal/circuit/activites.js +33 -0
- package/dist/temporal/circuit/activites.js.map +1 -0
- package/dist/temporal/circuit/client.d.ts +72 -0
- package/dist/temporal/circuit/client.js +247 -0
- package/dist/temporal/circuit/client.js.map +1 -0
- package/dist/temporal/circuit/commande.d.ts +2 -0
- package/dist/temporal/circuit/commande.js +238 -0
- package/dist/temporal/circuit/commande.js.map +1 -0
- package/dist/temporal/circuit/contrat.d.ts +305 -0
- package/dist/temporal/circuit/contrat.js +30 -0
- package/dist/temporal/circuit/contrat.js.map +1 -0
- package/dist/temporal/circuit/deroule.d.ts +3 -0
- package/dist/temporal/circuit/deroule.js +540 -0
- package/dist/temporal/circuit/deroule.js.map +1 -0
- package/dist/temporal/client.d.ts +47 -0
- package/dist/temporal/client.js +69 -0
- package/dist/temporal/client.js.map +1 -0
- package/dist/temporal/commande.d.ts +2 -0
- package/dist/temporal/commande.js +94 -0
- package/dist/temporal/commande.js.map +1 -0
- package/dist/temporal/deroules.d.ts +5 -0
- package/dist/temporal/deroules.js +10 -0
- package/dist/temporal/deroules.js.map +1 -0
- package/dist/temporal/etat.d.ts +33 -0
- package/dist/temporal/etat.js +59 -0
- package/dist/temporal/etat.js.map +1 -0
- package/dist/temporal/file/activites.d.ts +10 -0
- package/dist/temporal/file/activites.js +25 -0
- package/dist/temporal/file/activites.js.map +1 -0
- package/dist/temporal/file/client.d.ts +4 -0
- package/dist/temporal/file/client.js +6 -0
- package/dist/temporal/file/client.js.map +1 -0
- package/dist/temporal/file/contrat.d.ts +158 -0
- package/dist/temporal/file/contrat.js +14 -0
- package/dist/temporal/file/contrat.js.map +1 -0
- package/dist/temporal/file/deroule.d.ts +15 -0
- package/dist/temporal/file/deroule.js +235 -0
- package/dist/temporal/file/deroule.js.map +1 -0
- package/dist/temporal/installation.d.ts +120 -0
- package/dist/temporal/installation.js +386 -0
- package/dist/temporal/installation.js.map +1 -0
- package/dist/temporal/places/activites.d.ts +8 -0
- package/dist/temporal/places/activites.js +13 -0
- package/dist/temporal/places/activites.js.map +1 -0
- package/dist/temporal/places/client.d.ts +28 -0
- package/dist/temporal/places/client.js +64 -0
- package/dist/temporal/places/client.js.map +1 -0
- package/dist/temporal/places/contrat.d.ts +106 -0
- package/dist/temporal/places/contrat.js +21 -0
- package/dist/temporal/places/contrat.js.map +1 -0
- package/dist/temporal/places/deroule.d.ts +3 -0
- package/dist/temporal/places/deroule.js +198 -0
- package/dist/temporal/places/deroule.js.map +1 -0
- package/dist/temporal/sonde/activites.d.ts +6 -0
- package/dist/temporal/sonde/activites.js +52 -0
- package/dist/temporal/sonde/activites.js.map +1 -0
- package/dist/temporal/sonde/contrat.d.ts +35 -0
- package/dist/temporal/sonde/contrat.js +10 -0
- package/dist/temporal/sonde/contrat.js.map +1 -0
- package/dist/temporal/sonde/deroule.d.ts +3 -0
- package/dist/temporal/sonde/deroule.js +39 -0
- package/dist/temporal/sonde/deroule.js.map +1 -0
- package/dist/temporal/tickets/activites.d.ts +7 -0
- package/dist/temporal/tickets/activites.js +81 -0
- package/dist/temporal/tickets/activites.js.map +1 -0
- package/dist/temporal/tickets/client.d.ts +10 -0
- package/dist/temporal/tickets/client.js +31 -0
- package/dist/temporal/tickets/client.js.map +1 -0
- package/dist/temporal/tickets/contrat.d.ts +56 -0
- package/dist/temporal/tickets/contrat.js +13 -0
- package/dist/temporal/tickets/contrat.js.map +1 -0
- package/dist/temporal/tickets/deroule.d.ts +3 -0
- package/dist/temporal/tickets/deroule.js +94 -0
- package/dist/temporal/tickets/deroule.js.map +1 -0
- package/dist/temporal/travailleur.d.ts +2 -0
- package/dist/temporal/travailleur.js +69 -0
- package/dist/temporal/travailleur.js.map +1 -0
- package/docs/ARCHITECTURE.md +646 -87
- package/docs/CADRE.md +27 -0
- package/docs/INTERFACE.md +139 -42
- package/hooks/crochet.mjs +19 -2
- package/hooks/hooks.json +11 -0
- package/package.json +16 -4
- package/scripts/activites.mjs +2255 -0
- package/scripts/aiguillage.d.mts +37 -0
- package/scripts/aiguillage.mjs +40 -14
- package/scripts/avancement.mjs +155 -26
- package/scripts/bilan.mjs +137 -43
- package/scripts/cadre.mjs +16 -4
- package/scripts/circuit.mjs +993 -4075
- package/scripts/circuits-cles.d.mts +4 -0
- package/scripts/circuits-cles.mjs +21 -0
- package/scripts/circuits-du-serveur.mjs +105 -0
- package/scripts/codes-de-sortie.mjs +9 -0
- package/scripts/commandes-composees.mjs +45 -41
- package/scripts/commandes-du-path.d.mts +7 -0
- package/scripts/commandes-du-path.mjs +25 -0
- package/scripts/composants-affectes.mjs +64 -21
- package/scripts/composition-des-langages.mjs +18 -12
- package/scripts/conformite.mjs +56 -28
- package/scripts/copies-finies.mjs +52 -47
- package/scripts/depart-du-ticket.d.mts +53 -0
- package/scripts/depart-du-ticket.mjs +124 -0
- package/scripts/dependances-internes.mjs +121 -0
- package/scripts/dernier-vert.mjs +61 -34
- package/scripts/dette.mjs +32 -11
- package/scripts/donnees-cles.mjs +244 -0
- package/scripts/droits.mjs +51 -16
- package/scripts/effets.mjs +352 -0
- package/scripts/empreinte-d-etape.mjs +17 -0
- package/scripts/engendres.mjs +15 -5
- package/scripts/enveloppe/enveloppe.mjs +259 -55
- package/scripts/enveloppe/lancer.sh +14 -18
- package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
- package/scripts/enveloppe/travail-de-la-copie.mjs +41 -13
- package/scripts/etapes.mjs +5 -2
- package/scripts/faits-du-circuit.mjs +493 -0
- package/scripts/file-des-tickets.d.mts +21 -0
- package/scripts/file-des-tickets.mjs +58 -0
- package/scripts/flux-des-paquets.mjs +201 -0
- package/scripts/gardes-du-cadre.mjs +21 -5
- package/scripts/init.mjs +11 -4
- package/scripts/integration/file.mjs +544 -434
- package/scripts/integration/integrer.mjs +87 -43
- package/scripts/integration/rejeu.mjs +45 -13
- package/scripts/jointure.d.ts +151 -28
- package/scripts/langages/cargo/commandes.mjs +383 -124
- package/scripts/langages/cargo/composants.mjs +154 -42
- package/scripts/langages/cargo/exemples.mjs +12 -21
- package/scripts/langages/cargo/index.mjs +22 -8
- package/scripts/langages/cargo/sccache.mjs +8 -14
- package/scripts/langages/cargo/tests-de-head.mjs +25 -9
- package/scripts/langages/python/commandes.mjs +218 -100
- package/scripts/langages/python/composants.mjs +53 -21
- package/scripts/langages/python/exemples.mjs +6 -16
- package/scripts/langages/python/index.mjs +28 -8
- package/scripts/langages/python/lot.mjs +1 -36
- package/scripts/langages/typescript/chemins-des-tests.mjs +6 -2
- package/scripts/langages/typescript/composants.mjs +9 -3
- package/scripts/langages/typescript/consommateurs-arbitres.mjs +40 -14
- package/scripts/langages/typescript/consommateurs.mjs +39 -14
- package/scripts/langages/typescript/construire.mjs +6 -163
- package/scripts/langages/typescript/elements-du-lot.mjs +36 -12
- package/scripts/langages/typescript/exemples.mjs +3 -11
- package/scripts/langages/typescript/frontieres.mjs +66 -22
- package/scripts/langages/typescript/index-interfaces.mjs +36 -13
- package/scripts/langages/typescript/index.mjs +50 -61
- package/scripts/langages/typescript/interfaces-contre-code.mjs +113 -45
- package/scripts/langages/typescript/lecteurs.mjs +36 -11
- package/scripts/langages/typescript/migrations/0.23.0-config-vitest.mjs +15 -5
- package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +6 -2
- package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +6 -2
- package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
- package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +33 -0
- package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
- package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
- package/scripts/langages/typescript/parcours.mjs +12 -4
- package/scripts/langages/typescript/regle-des-tests.mjs +9 -3
- package/scripts/langages/typescript/resumes.mjs +9 -3
- package/scripts/langages/typescript/tailles-des-tests.mjs +93 -20
- package/scripts/langages/typescript/tests-de-nuit.mjs +15 -10
- package/scripts/langages/typescript/tests.mjs +40 -15
- package/scripts/langages/typescript/titres-de-tests.mjs +320 -0
- package/scripts/langages/typescript/turbo-des-paquets.mjs +327 -81
- package/scripts/langages/typescript/verdict.mjs +4 -2
- package/scripts/langages/typescript/verifier.mjs +58 -20
- package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
- package/scripts/langages/typescript/vitest-config/base.mjs +29 -3
- package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
- package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
- package/scripts/langages/typescript/vitest-config/cibles.mjs +36 -14
- package/scripts/langages/typescript/vitest-config/delais.mjs +60 -0
- package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
- package/scripts/langages/typescript/vitest-config/duree.classement.mjs +108 -0
- package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +56 -59
- package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +10 -0
- package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
- package/scripts/langages/typescript/vitest.nuit.config.mjs +4 -0
- package/scripts/lint-des-scripts.mjs +58 -0
- package/scripts/mesure/base-de-passe.mjs +117 -25
- package/scripts/mesure/pression.mjs +12 -6
- package/scripts/mesure-de-la-machine.d.mts +21 -0
- package/scripts/mesure-de-la-machine.mjs +76 -0
- package/scripts/migrations/0.23.0-charte-importee.mjs +6 -2
- package/scripts/migrations/0.23.0-crochets-de-seance.mjs +25 -8
- package/scripts/migrations/0.23.0-marche-du-projet.mjs +18 -6
- package/scripts/migrations/0.23.2-copies-du-cadre.mjs +56 -18
- package/scripts/migrations/0.24.12-tri-des-decouvertes.mjs +6 -2
- package/scripts/migrations/0.25.0-script-des-tests.mjs +15 -5
- package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +124 -0
- package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
- package/scripts/migrations.mjs +5 -0
- package/scripts/nuit.sh +25 -3
- package/scripts/outil.mjs +3 -1
- package/scripts/outils-cles.d.mts +24 -0
- package/scripts/outils-cles.mjs +18 -8
- package/scripts/paquet-npm.mjs +157 -0
- package/scripts/paquet.mjs +73 -4
- package/scripts/paquets.mjs +46 -10
- package/scripts/passe-de-la-machine.mjs +71 -0
- package/scripts/places-de-la-machine.mjs +414 -0
- package/scripts/places-du-serveur.mjs +170 -0
- package/scripts/prefixe-des-tickets.mjs +68 -0
- package/scripts/preparation.mjs +25 -8
- package/scripts/registre.mjs +9 -4
- package/scripts/regles-des-places.d.mts +36 -0
- package/scripts/regles-des-places.mjs +70 -0
- package/scripts/reponses-du-circuit.d.mts +6 -0
- package/scripts/reponses-du-circuit.mjs +28 -0
- package/scripts/reprise.mjs +66 -0
- package/scripts/resultats.mjs +112 -46
- package/scripts/retirer-les-copies-finies.mjs +25 -0
- package/scripts/sans-reponse.d.mts +4 -0
- package/scripts/sans-reponse.mjs +13 -0
- package/scripts/seances.mjs +936 -0
- package/scripts/services-du-noyau.mjs +27 -8
- package/scripts/session-start.sh +2 -2
- package/scripts/sortie.mjs +3 -3
- package/scripts/sous-commandes.mjs +41 -10
- package/scripts/style-a-l-ecriture.mjs +260 -0
- package/scripts/superviseur.mjs +122 -111
- package/scripts/tableau.mjs +180 -117
- package/scripts/taches-du-graphe.mjs +348 -0
- package/scripts/ticket-du-circuit.mjs +216 -0
- package/scripts/transitions.d.mts +148 -0
- package/scripts/transitions.mjs +1018 -0
- package/scripts/verrou-de-fichier.mjs +8 -4
- package/scripts/verrou-de-machine.mjs +150 -51
- package/scripts/verrous/commande.mjs +50 -17
- package/scripts/verrous/ticket-du-sous-agent.mjs +9 -3
- package/scripts/verrous/verrou.mjs +42 -14
- package/skills/explorateur/SKILL.md +9 -2
- package/skills/grill/SKILL.md +1 -1
- package/skills/mesure/SKILL.md +3 -0
- package/skills/pitmaster/SKILL.md +17 -18
- package/skills/pitmaster/references/consigne-agent.md +5 -1
- package/skills/release/SKILL.md +3 -3
- package/skills/relecteur/SKILL.md +5 -3
- package/skills/testwriter/SKILL.md +49 -31
- package/scripts/demon.mjs +0 -251
- package/scripts/integration/file-attente.mjs +0 -61
- package/scripts/langages/cargo/touches.mjs +0 -93
- package/scripts/langages/typescript/script-des-tests.mjs +0 -6
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// The classification of the duration reporter (./duree.reporter.mjs), a pure function: it takes
|
|
2
|
+
// data (the tasks of the run, the errors outside the tests, the CPU pressures at the start and at
|
|
3
|
+
// the end, Vitest's exit code, and per file its size label, whether it is out of the day and
|
|
4
|
+
// whether it is a time budget bench, by the rules of ./cibles.mjs) and
|
|
5
|
+
// never reads the disk nor the global state. The reporter reads those, calls `classer`, writes the
|
|
6
|
+
// lines and sets the exit code.
|
|
7
|
+
//
|
|
8
|
+
// A failure depends on a duration when it is a failure of a time budget bench (a file
|
|
9
|
+
// `*.budget.test.*`, `*.budget.spec.*`), of a test marked as a measure of time (`mesurerAuRepos`),
|
|
10
|
+
// or a delay past (« Test timed out in <n>ms. », « Hook timed out in <n>ms. ») in a file out of the
|
|
11
|
+
// day; every other failure is a real red, a delay past in a day test included.
|
|
12
|
+
//
|
|
13
|
+
// The verdict is `a-repasser` when every failure depends on a duration and at least one took place
|
|
14
|
+
// under load (pressure at or above the threshold at the start or at the end); `rouge` when they
|
|
15
|
+
// all took place at rest; `vitest` (Vitest's verdict stands) when a failure is real, an error is
|
|
16
|
+
// outside the tests, Vitest's code is not 1, or no pressure reads; no pressure measured at all
|
|
17
|
+
// (no failure of duration) gives no line of conclusion.
|
|
18
|
+
import { A_REPASSER, SEUIL_PRESSION } from '../../../services-du-noyau.mjs';
|
|
19
|
+
|
|
20
|
+
const DELAI = /^(Test|Hook) timed out in \d+ms\./;
|
|
21
|
+
|
|
22
|
+
function* taches(t) {
|
|
23
|
+
yield t;
|
|
24
|
+
for (const c of t.tasks ?? []) {
|
|
25
|
+
yield* taches(c);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const fichierDe = t => {
|
|
29
|
+
let x = t;
|
|
30
|
+
while (x && !x.filepath) {
|
|
31
|
+
x = x.suite ?? x.file;
|
|
32
|
+
}
|
|
33
|
+
return x?.filepath ?? '';
|
|
34
|
+
};
|
|
35
|
+
const nomDe = t => {
|
|
36
|
+
const noms = [];
|
|
37
|
+
for (let x = t; x && !x.filepath; x = x.suite) {
|
|
38
|
+
noms.unshift(x.name);
|
|
39
|
+
}
|
|
40
|
+
return noms.join(' › ');
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {{ files?: any[], errors?: unknown[], debut: number | null, fin: number | null,
|
|
45
|
+
* codeDeSortie: number | undefined, fichiers: Record<string, { horsDuJour: boolean, banc?: boolean, libelleDelai: string }> }} entree
|
|
46
|
+
*/
|
|
47
|
+
export function classer({ files = [], errors = [], debut, fin, codeDeSortie, fichiers }) {
|
|
48
|
+
const echecs = [];
|
|
49
|
+
for (const f of files) {
|
|
50
|
+
for (const t of taches(f)) {
|
|
51
|
+
const erreurs = t.result?.errors ?? [];
|
|
52
|
+
if (t.type === 'test' ? t.result?.state !== 'fail' : erreurs.length === 0) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const fichier = fichierDe(t);
|
|
56
|
+
const info = fichiers[fichier];
|
|
57
|
+
const delaiDepasse = erreurs.length > 0 && erreurs.every(e => DELAI.test(e.message ?? ''));
|
|
58
|
+
const cause =
|
|
59
|
+
t.type === 'test' && t.meta?.mesureDeTemps
|
|
60
|
+
? 'mesure de temps'
|
|
61
|
+
: info?.banc
|
|
62
|
+
? 'banc de temps'
|
|
63
|
+
: delaiDepasse && info?.horsDuJour
|
|
64
|
+
? 'délai dépassé'
|
|
65
|
+
: 'réel';
|
|
66
|
+
echecs.push({
|
|
67
|
+
fichier,
|
|
68
|
+
nom: nomDe(t),
|
|
69
|
+
cause,
|
|
70
|
+
delai: delaiDepasse ? (info?.libelleDelai ?? null) : null,
|
|
71
|
+
pressionDebut: t.type === 'test' ? (t.meta?.pressionDebut ?? debut) : debut,
|
|
72
|
+
pressionFin: t.type === 'test' ? (t.meta?.pressionFin ?? fin) : fin,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const dependants = echecs.filter(e => e.cause !== 'réel');
|
|
77
|
+
if (dependants.length === 0) {
|
|
78
|
+
// No failure of duration: no pressure measured, so no line of conclusion.
|
|
79
|
+
return { echecs, verdict: 'vitest', conclusion: null };
|
|
80
|
+
}
|
|
81
|
+
if (dependants.length < echecs.length || errors.length > 0 || codeDeSortie !== 1) {
|
|
82
|
+
return {
|
|
83
|
+
echecs,
|
|
84
|
+
verdict: 'vitest',
|
|
85
|
+
conclusion: 'un échec ne dépend pas d’une durée : verdict de Vitest.',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const lues = dependants.flatMap(e => [e.pressionDebut, e.pressionFin]).filter(p => p !== null);
|
|
89
|
+
if (lues.length === 0) {
|
|
90
|
+
return {
|
|
91
|
+
echecs,
|
|
92
|
+
verdict: 'vitest',
|
|
93
|
+
conclusion: 'pression CPU illisible (/proc/pressure/cpu) : verdict de Vitest.',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (lues.some(p => p >= SEUIL_PRESSION)) {
|
|
97
|
+
return {
|
|
98
|
+
echecs,
|
|
99
|
+
verdict: 'a-repasser',
|
|
100
|
+
conclusion: `à repasser (code ${A_REPASSER}) : chaque échec dépend d’une durée, et au moins un a eu lieu sous charge ; ni vert ni rouge, la mesure se rejoue au repos.`,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
return {
|
|
104
|
+
echecs,
|
|
105
|
+
verdict: 'rouge',
|
|
106
|
+
conclusion: `échecs de durée au repos (pression CPU sous ${SEUIL_PRESSION} %) : rouge.`,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -26,25 +26,36 @@ import {
|
|
|
26
26
|
lirePression,
|
|
27
27
|
SEUIL_PRESSION,
|
|
28
28
|
} from '../../../services-du-noyau.mjs';
|
|
29
|
-
import { estHorsDuJour } from './cibles.mjs';
|
|
29
|
+
import { estHorsDuJour, estUnBanc } from './cibles.mjs';
|
|
30
|
+
import { classer } from './duree.classement.mjs';
|
|
31
|
+
import { delaisSurLeDisque, libelleDuDelai } from './delais.mjs';
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
function aUnEchec(t) {
|
|
34
|
+
if (t.type === 'test' ? t.result?.state === 'fail' : (t.result?.errors ?? []).length > 0) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
return (t.tasks ?? []).some(aUnEchec);
|
|
38
|
+
}
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
// The 20 slowest files of the run, slowest first, each with its share of the total time.
|
|
41
|
+
const PLUS_LENTS = 20;
|
|
42
|
+
function plusLents(files, dire) {
|
|
43
|
+
const duree = f => f.result?.duration ?? 0;
|
|
44
|
+
const total = files.reduce((s, f) => s + duree(f), 0);
|
|
45
|
+
if (total <= 0) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const lents = [...files].sort((a, b) => duree(b) - duree(a)).slice(0, PLUS_LENTS);
|
|
49
|
+
dire(
|
|
50
|
+
`${lents.length === 1 ? '1 fichier le plus lent' : `${lents.length} fichiers les plus lents`} (part du temps total, ${Math.round(total)} ms) :`
|
|
51
|
+
);
|
|
52
|
+
for (const f of lents) {
|
|
53
|
+
const part = ((100 * duree(f)) / total).toFixed(1);
|
|
54
|
+
dire(
|
|
55
|
+
`${part.padStart(5)} % ${Math.round(duree(f))} ms ${path.relative(process.cwd(), f.filepath)}`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
37
58
|
}
|
|
38
|
-
const fichierDe = t => {
|
|
39
|
-
let x = t;
|
|
40
|
-
while (x && !x.filepath) x = x.suite ?? x.file;
|
|
41
|
-
return x?.filepath ?? '';
|
|
42
|
-
};
|
|
43
|
-
const nomDe = t => {
|
|
44
|
-
const noms = [];
|
|
45
|
-
for (let x = t; x && !x.filepath; x = x.suite) noms.unshift(x.name);
|
|
46
|
-
return noms.join(' › ');
|
|
47
|
-
};
|
|
48
59
|
|
|
49
60
|
export default class DureeReporter {
|
|
50
61
|
onInit() {
|
|
@@ -53,59 +64,45 @@ export default class DureeReporter {
|
|
|
53
64
|
|
|
54
65
|
onFinished(files = [], errors = []) {
|
|
55
66
|
const fin = lirePression();
|
|
56
|
-
const
|
|
67
|
+
const dire = l => process.stdout.write(`⏱ ${l}\n`);
|
|
68
|
+
plusLents(files, dire);
|
|
69
|
+
const fichiers = {};
|
|
57
70
|
for (const f of files) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (t.type === 'test' ? t.result?.state === 'fail' : erreurs.length > 0) echecs.push(t);
|
|
71
|
+
if (!aUnEchec(f) || f.filepath in fichiers) {
|
|
72
|
+
continue;
|
|
61
73
|
}
|
|
74
|
+
fichiers[f.filepath] = {
|
|
75
|
+
horsDuJour: estHorsDuJour(f.filepath),
|
|
76
|
+
banc: estUnBanc(f.filepath),
|
|
77
|
+
libelleDelai: libelleDuDelai(delaisSurLeDisque(f.filepath).taille),
|
|
78
|
+
};
|
|
62
79
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
? 'délai dépassé'
|
|
79
|
-
: null;
|
|
80
|
-
if (!cause) {
|
|
81
|
-
reels++;
|
|
80
|
+
const { echecs, verdict, conclusion } = classer({
|
|
81
|
+
files,
|
|
82
|
+
errors,
|
|
83
|
+
debut: this.debut,
|
|
84
|
+
fin,
|
|
85
|
+
codeDeSortie: process.exitCode,
|
|
86
|
+
fichiers,
|
|
87
|
+
});
|
|
88
|
+
for (const e of echecs) {
|
|
89
|
+
const nom = path.relative(process.cwd(), e.fichier) + (e.nom ? ` › ${e.nom}` : '');
|
|
90
|
+
const delai = e.delai ? ` (${e.delai})` : '';
|
|
91
|
+
if (e.cause === 'réel') {
|
|
92
|
+
if (e.delai) {
|
|
93
|
+
dire(`${nom} : délai dépassé${delai}.`);
|
|
94
|
+
}
|
|
82
95
|
continue;
|
|
83
96
|
}
|
|
84
|
-
const debut = t.type === 'test' ? (t.meta?.pressionDebut ?? this.debut) : this.debut;
|
|
85
|
-
const finT = t.type === 'test' ? (t.meta?.pressionFin ?? fin) : fin;
|
|
86
|
-
pressions.push(debut, finT);
|
|
87
|
-
const nom = nomDe(t);
|
|
88
97
|
dire(
|
|
89
|
-
`${
|
|
98
|
+
`${nom} : ${e.cause}${delai}, pression CPU ${ecrirePression(e.pressionDebut)} au début, ${ecrirePression(e.pressionFin)} à la fin (seuil ${SEUIL_PRESSION} %).`
|
|
90
99
|
);
|
|
91
100
|
}
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
dire('un échec ne dépend pas d’une durée : verdict de Vitest.');
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const lues = pressions.filter(p => p !== null);
|
|
98
|
-
if (lues.length === 0) {
|
|
99
|
-
dire('pression CPU illisible (/proc/pressure/cpu) : verdict de Vitest.');
|
|
100
|
-
return;
|
|
101
|
+
if (conclusion) {
|
|
102
|
+
dire(conclusion);
|
|
101
103
|
}
|
|
102
|
-
if (
|
|
103
|
-
dire(
|
|
104
|
-
`à repasser (code ${A_REPASSER}) : chaque échec dépend d’une durée, et au moins un a eu lieu sous charge ; ni vert ni rouge, la mesure se rejoue au repos.`
|
|
105
|
-
);
|
|
104
|
+
if (verdict === 'a-repasser') {
|
|
106
105
|
process.exitCode = A_REPASSER;
|
|
107
|
-
return;
|
|
108
106
|
}
|
|
109
|
-
dire(`échecs de durée au repos (pression CPU sous ${SEUIL_PRESSION} %) : rouge.`);
|
|
110
107
|
}
|
|
111
108
|
}
|
|
@@ -109,7 +109,9 @@ export function resoudreRelatif(de, spec, lireUn) {
|
|
|
109
109
|
const base = path.resolve(path.dirname(de), spec);
|
|
110
110
|
const sansJs = base.replace(/\.([cm]?)js$/, '.$1ts');
|
|
111
111
|
for (const c of [...SUFFIXES.map(s => base + s), sansJs]) {
|
|
112
|
-
if (lireUn(c) !== null)
|
|
112
|
+
if (lireUn(c) !== null) {
|
|
113
|
+
return c;
|
|
114
|
+
}
|
|
113
115
|
}
|
|
114
116
|
return null;
|
|
115
117
|
}
|
|
@@ -141,7 +143,9 @@ function sansCommentaires(texte) {
|
|
|
141
143
|
const c = texte[i];
|
|
142
144
|
const suivant = texte[i + 1];
|
|
143
145
|
if (c === '/' && suivant === '/') {
|
|
144
|
-
while (i < texte.length && texte[i] !== '\n')
|
|
146
|
+
while (i < texte.length && texte[i] !== '\n') {
|
|
147
|
+
i++;
|
|
148
|
+
}
|
|
145
149
|
} else if (c === '/' && suivant === '*') {
|
|
146
150
|
const fin = texte.indexOf('*/', i + 2);
|
|
147
151
|
i = fin < 0 ? texte.length : fin + 2;
|
|
@@ -181,7 +185,9 @@ function chainesDe(texte) {
|
|
|
181
185
|
j += texte[j] === '\\' ? 2 : 1;
|
|
182
186
|
}
|
|
183
187
|
const contenu = texte.slice(i + 1, j);
|
|
184
|
-
if (!(c === '`' && contenu.includes('${')))
|
|
188
|
+
if (!(c === '`' && contenu.includes('${'))) {
|
|
189
|
+
out.push(contenu);
|
|
190
|
+
}
|
|
185
191
|
i = j + 1;
|
|
186
192
|
}
|
|
187
193
|
return out;
|
|
@@ -200,7 +206,9 @@ function chaines(texte) {
|
|
|
200
206
|
// The value of <calcul>, kept in <memo> under <cle>: each reading of a directory, a resolution or a
|
|
201
207
|
// file's strings is made once per pass.
|
|
202
208
|
function memoise(memo, cle, calcul) {
|
|
203
|
-
if (!memo.has(cle))
|
|
209
|
+
if (!memo.has(cle)) {
|
|
210
|
+
memo.set(cle, calcul());
|
|
211
|
+
}
|
|
204
212
|
return memo.get(cle);
|
|
205
213
|
}
|
|
206
214
|
|
|
@@ -215,7 +223,9 @@ function resoudre(de, spec, racine) {
|
|
|
215
223
|
const f = resoudreRelatif(de, spec, lireLeDisque);
|
|
216
224
|
return f && reel(f);
|
|
217
225
|
}
|
|
218
|
-
if (spec.startsWith('node:') || path.isAbsolute(spec))
|
|
226
|
+
if (spec.startsWith('node:') || path.isAbsolute(spec)) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
219
229
|
try {
|
|
220
230
|
const f = reel(createRequire(de).resolve(spec));
|
|
221
231
|
return f && sous(f, racine) && horsModules(f) ? f : null;
|
|
@@ -227,7 +237,9 @@ function resoudre(de, spec, racine) {
|
|
|
227
237
|
// Whether the file <f> of the repository at <racine> is test material: under a directory of
|
|
228
238
|
// tests, or in a package of the shared material (`matieres` of ../composants.mjs).
|
|
229
239
|
function estMatiere(f, racine, memo) {
|
|
230
|
-
if (MATIERE.test(du(racine, f)))
|
|
240
|
+
if (MATIERE.test(du(racine, f))) {
|
|
241
|
+
return true;
|
|
242
|
+
}
|
|
231
243
|
return memoise(memo, 'matieres', () => matieres(racine)).some(m => sous(f, m.dir));
|
|
232
244
|
}
|
|
233
245
|
|
|
@@ -242,7 +254,9 @@ function commandes(racine, memo) {
|
|
|
242
254
|
? { [pkg.name.split('/').at(-1)]: pkg.bin }
|
|
243
255
|
: (pkg?.bin ?? {});
|
|
244
256
|
for (const [nom, f] of Object.entries(bin)) {
|
|
245
|
-
if (typeof f === 'string')
|
|
257
|
+
if (typeof f === 'string') {
|
|
258
|
+
out.set(nom, path.join(racine, dossier, f));
|
|
259
|
+
}
|
|
246
260
|
}
|
|
247
261
|
}
|
|
248
262
|
return out;
|
|
@@ -255,8 +269,12 @@ function commandes(racine, memo) {
|
|
|
255
269
|
function commandeLancee(chaine, racine, memo, ligne) {
|
|
256
270
|
const liste = commandes(racine, memo);
|
|
257
271
|
const parLien = /(?:^|\/)\.bin\/([\w@.-]+)$/.exec(chaine);
|
|
258
|
-
if (parLien)
|
|
259
|
-
|
|
272
|
+
if (parLien) {
|
|
273
|
+
return liste.get(parLien[1]) ?? null;
|
|
274
|
+
}
|
|
275
|
+
if (!ligne) {
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
260
278
|
for (const [nom, f] of liste) {
|
|
261
279
|
if (new RegExp(`(?:^|[\\s/"'])${nom.replace(/[.-]/g, '\\$&')}["']?\\s+[a-z]`).test(chaine)) {
|
|
262
280
|
return f;
|
|
@@ -270,9 +288,13 @@ function commandeLancee(chaine, racine, memo, ligne) {
|
|
|
270
288
|
// for a pattern that starts with a wildcard.
|
|
271
289
|
function couverts(motif, bases, racine) {
|
|
272
290
|
const fixe = motif.split('/').filter((s, i, l) => !l.slice(0, i + 1).some(x => MOTIF.test(x)));
|
|
273
|
-
if (fixe.length === 0)
|
|
291
|
+
if (fixe.length === 0) {
|
|
292
|
+
return [];
|
|
293
|
+
}
|
|
274
294
|
for (const b of bases) {
|
|
275
|
-
if (!existsSync(path.resolve(b, ...fixe)))
|
|
295
|
+
if (!existsSync(path.resolve(b, ...fixe))) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
276
298
|
return globSync(motif, { cwd: b, exclude: d => SAUTES.has(path.basename(d)) })
|
|
277
299
|
.map(f => path.resolve(b, f))
|
|
278
300
|
.filter(f => sous(f, racine) && horsModules(f) && !estDossier(f));
|
|
@@ -284,7 +306,9 @@ function couverts(motif, bases, racine) {
|
|
|
284
306
|
// first that exists): itself, or each file under it; none for a directory that holds the file
|
|
285
307
|
// <de> that writes it, or that is a package.
|
|
286
308
|
function nommes(chaine, bases, racine, de, memo, ligne = false) {
|
|
287
|
-
if (!/[\w.]/.test(chaine) || /^[a-z]+:/i.test(chaine))
|
|
309
|
+
if (!/[\w.]/.test(chaine) || /^[a-z]+:/i.test(chaine)) {
|
|
310
|
+
return [];
|
|
311
|
+
}
|
|
288
312
|
return memoise(memo, `nommes:${ligne}\0${bases.join('\0')}\0${path.dirname(de)}\0${chaine}`, () =>
|
|
289
313
|
resoudreNommes(chaine, bases, racine, de, memo, ligne)
|
|
290
314
|
);
|
|
@@ -292,16 +316,30 @@ function nommes(chaine, bases, racine, de, memo, ligne = false) {
|
|
|
292
316
|
|
|
293
317
|
function resoudreNommes(chaine, bases, racine, de, memo, ligne) {
|
|
294
318
|
const commande = commandeLancee(chaine, racine, memo, ligne);
|
|
295
|
-
if (commande)
|
|
296
|
-
|
|
297
|
-
|
|
319
|
+
if (commande) {
|
|
320
|
+
return [commande];
|
|
321
|
+
}
|
|
322
|
+
if (/[\s<>|^$]/.test(chaine)) {
|
|
323
|
+
return [];
|
|
324
|
+
}
|
|
325
|
+
if (MOTIF.test(chaine)) {
|
|
326
|
+
return couverts(chaine, bases, racine);
|
|
327
|
+
}
|
|
298
328
|
for (const b of bases) {
|
|
299
329
|
const c = path.resolve(b, chaine);
|
|
300
|
-
if (!existsSync(c))
|
|
330
|
+
if (!existsSync(c)) {
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
301
333
|
const r = reel(c);
|
|
302
|
-
if (!r || !sous(r, racine) || !horsModules(r))
|
|
303
|
-
|
|
304
|
-
|
|
334
|
+
if (!r || !sous(r, racine) || !horsModules(r)) {
|
|
335
|
+
return [];
|
|
336
|
+
}
|
|
337
|
+
if (!estDossier(r)) {
|
|
338
|
+
return [r];
|
|
339
|
+
}
|
|
340
|
+
if (sous(de, r) || existsSync(path.join(r, 'package.json'))) {
|
|
341
|
+
return [];
|
|
342
|
+
}
|
|
305
343
|
return memoise(memo, `dossier:${r}`, () => fichiersSous(r));
|
|
306
344
|
}
|
|
307
345
|
return [];
|
|
@@ -311,11 +349,15 @@ function resoudreNommes(chaine, bases, racine, de, memo, ligne) {
|
|
|
311
349
|
function materiel(fichier, racine, memo) {
|
|
312
350
|
const vus = [];
|
|
313
351
|
const suivre = f => {
|
|
314
|
-
if (vus.includes(f))
|
|
352
|
+
if (vus.includes(f)) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
315
355
|
vus.push(f);
|
|
316
356
|
for (const spec of specifiersDe(f, memo)) {
|
|
317
357
|
const cible = resoudreImport(f, spec, racine, memo);
|
|
318
|
-
if (cible && !TEST.test(cible) && estMatiere(cible, racine, memo))
|
|
358
|
+
if (cible && !TEST.test(cible) && estMatiere(cible, racine, memo)) {
|
|
359
|
+
suivre(cible);
|
|
360
|
+
}
|
|
319
361
|
}
|
|
320
362
|
};
|
|
321
363
|
suivre(fichier);
|
|
@@ -333,7 +375,9 @@ function nommesPar(fichier, dossier, racine, memo) {
|
|
|
333
375
|
for (const f of materiel(fichier, racine, memo)) {
|
|
334
376
|
const bases = [path.dirname(f), dossier, racine];
|
|
335
377
|
for (const c of chainesDuFichier(f, memo)) {
|
|
336
|
-
for (const n of nommes(c, bases, racine, f, memo, true))
|
|
378
|
+
for (const n of nommes(c, bases, racine, f, memo, true)) {
|
|
379
|
+
out.add(n);
|
|
380
|
+
}
|
|
337
381
|
}
|
|
338
382
|
}
|
|
339
383
|
return out;
|
|
@@ -347,7 +391,9 @@ function fermeture(depart, racine, memo) {
|
|
|
347
391
|
const pile = [...depart];
|
|
348
392
|
while (pile.length) {
|
|
349
393
|
const f = pile.pop();
|
|
350
|
-
if (vus.has(f))
|
|
394
|
+
if (vus.has(f)) {
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
351
397
|
vus.add(f);
|
|
352
398
|
if (SHELL.test(f)) {
|
|
353
399
|
// A script of the shell names the scripts it runs from its own directory, through a
|
|
@@ -361,7 +407,9 @@ function fermeture(depart, racine, memo) {
|
|
|
361
407
|
);
|
|
362
408
|
continue;
|
|
363
409
|
}
|
|
364
|
-
if (!MODULE.test(f))
|
|
410
|
+
if (!MODULE.test(f)) {
|
|
411
|
+
continue;
|
|
412
|
+
}
|
|
365
413
|
const suite = memoise(memo, `suite:${f}`, () => [
|
|
366
414
|
...specifiersDe(f, memo)
|
|
367
415
|
.map(s => resoudreImport(f, s, racine, memo))
|
|
@@ -395,10 +443,16 @@ export function testsDuPaquet(dossier) {
|
|
|
395
443
|
*/
|
|
396
444
|
export function testsQuiLancent(dossier, racine, changes) {
|
|
397
445
|
const cibles = new Set(changes.map(f => reel(f) ?? f));
|
|
398
|
-
if (cibles.size === 0)
|
|
446
|
+
if (cibles.size === 0) {
|
|
447
|
+
return [];
|
|
448
|
+
}
|
|
399
449
|
const memo = new Map();
|
|
400
450
|
return testsDuPaquet(dossier).filter(t => {
|
|
401
|
-
for (const f of lusPar(t, dossier, racine, memo))
|
|
451
|
+
for (const f of lusPar(t, dossier, racine, memo)) {
|
|
452
|
+
if (cibles.has(f)) {
|
|
453
|
+
return true;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
402
456
|
return false;
|
|
403
457
|
});
|
|
404
458
|
}
|
|
@@ -420,7 +474,9 @@ export function nonDeclares(dossier, racine, lit = [], memo = new Map()) {
|
|
|
420
474
|
const modules = [];
|
|
421
475
|
for (const f of fichiersSous(dossier)) {
|
|
422
476
|
const r = du(racine, f);
|
|
423
|
-
if (!MODULE.test(f) || TEST.test(f) || MATIERE.test(r) || dansLit(r, lit))
|
|
477
|
+
if (!MODULE.test(f) || TEST.test(f) || MATIERE.test(r) || dansLit(r, lit)) {
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
424
480
|
modules.push(f);
|
|
425
481
|
const parts = r.split('/');
|
|
426
482
|
for (let i = 0; i < parts.length; i++) {
|
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
// the temporary directory (GRILLHOUSE_TEMPORAIRE_LIBRE, 0) nor on the disk of their copy
|
|
8
8
|
// (GRILLHOUSE_COPIE_LIBRE, 0): the room of the machine is the pass's that plays the file, which
|
|
9
9
|
// waited for it.
|
|
10
|
+
//
|
|
11
|
+
// That trial machine takes no place of the user's machine (scripts/places-de-la-machine.mjs): only
|
|
12
|
+
// the server of trial a test names (GRILLHOUSE_PLACES_D_ESSAI).
|
|
10
13
|
import { randomUUID } from 'node:crypto';
|
|
11
14
|
import { tmpdir } from 'node:os';
|
|
12
15
|
import path from 'node:path';
|
|
@@ -15,5 +18,12 @@ process.env.GRILLHOUSE_VERROU_MACHINE ||= path.join(
|
|
|
15
18
|
tmpdir(),
|
|
16
19
|
`grillhouse-mesure-${process.pid}-${randomUUID()}.lock`
|
|
17
20
|
);
|
|
21
|
+
// The machine a test reads is a fixed one (GRILLHOUSE_MESURE_D_ESSAI, scripts/places-de-la-machine.mjs
|
|
22
|
+
// `etatDesPlaces`): no test reads the real load or memory of the user's machine.
|
|
23
|
+
process.env.GRILLHOUSE_MESURE_D_ESSAI ||= JSON.stringify({
|
|
24
|
+
coeurs: 12,
|
|
25
|
+
charge: 1,
|
|
26
|
+
memoireLibre: 16 * 1024 ** 3,
|
|
27
|
+
});
|
|
18
28
|
process.env.GRILLHOUSE_TEMPORAIRE_LIBRE ||= '0';
|
|
19
29
|
process.env.GRILLHOUSE_COPIE_LIBRE ||= '0';
|
|
@@ -17,7 +17,9 @@ export const VITEST = 'vitest';
|
|
|
17
17
|
// it; an empty list without the variable.
|
|
18
18
|
export function rapportJson(env = process.env, dossier = process.cwd()) {
|
|
19
19
|
const resultats = env[RESULTATS];
|
|
20
|
-
if (!resultats)
|
|
20
|
+
if (!resultats) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
21
23
|
const nom = `${dossier.split(path.sep).filter(Boolean).join('-') || 'racine'}-${process.pid}.json`;
|
|
22
24
|
return [['json', { outputFile: path.join(resultats, VITEST, nom) }]];
|
|
23
25
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// under load (scripts/langages/typescript/vitest-config/duree.reporter.mjs).
|
|
17
17
|
import base from './vitest-config/base.mjs';
|
|
18
18
|
import { HORS_DU_JOUR, nuit } from './vitest-config/cibles.mjs';
|
|
19
|
+
import { DELAI_NUIT_MS } from './vitest-config/bornes.mjs';
|
|
19
20
|
|
|
20
21
|
export default {
|
|
21
22
|
plugins: [nuit()],
|
|
@@ -26,6 +27,9 @@ export default {
|
|
|
26
27
|
setupFiles: base.test.setupFiles,
|
|
27
28
|
include: HORS_DU_JOUR,
|
|
28
29
|
exclude: ['**/node_modules/**', '**/dist/**', '**/.git/**'],
|
|
30
|
+
// The large delay of Bazel for a night test: 900 s (./vitest-config/delais.mjs).
|
|
31
|
+
testTimeout: DELAI_NUIT_MS,
|
|
32
|
+
hookTimeout: DELAI_NUIT_MS,
|
|
29
33
|
watch: false,
|
|
30
34
|
},
|
|
31
35
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// The guard `lint-des-scripts`, proper to the grillhouse package (it is in no project's list of
|
|
2
|
+
// guards): ESLint runs on `packages/grillhouse/scripts` of the working directory, and each error is
|
|
3
|
+
// counted per file and rule against the debt of `grillhouse-dette.json` (`trancher`, dette.mjs).
|
|
4
|
+
// An error beyond the inscribed count refuses with the file, the rule and the counts.
|
|
5
|
+
// ESLint is the repository's own tool, played by its executable (the package does not depend on it).
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
9
|
+
import { trancher } from './dette.mjs';
|
|
10
|
+
|
|
11
|
+
const DOSSIER = 'packages/grillhouse/scripts';
|
|
12
|
+
// The executable of ESLint in the repository's node_modules, from this file (packages/grillhouse/scripts).
|
|
13
|
+
const ESLINT = path.resolve(
|
|
14
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
15
|
+
'../../../node_modules/eslint/bin/eslint.js'
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
// The ESLint errors of the scripts of <racine>, as `{ fichier, regle, ligne, message }`.
|
|
19
|
+
export async function verifier(racine) {
|
|
20
|
+
const r = spawnSync(process.execPath, [ESLINT, DOSSIER, '--ext', '.mjs', '-f', 'json'], {
|
|
21
|
+
cwd: racine,
|
|
22
|
+
encoding: 'utf8',
|
|
23
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
24
|
+
});
|
|
25
|
+
let resultats;
|
|
26
|
+
try {
|
|
27
|
+
resultats = JSON.parse(r.stdout);
|
|
28
|
+
} catch {
|
|
29
|
+
throw new Error(`ESLint n'a pas rendu de JSON : ${r.stderr || r.error?.message || r.stdout}`);
|
|
30
|
+
}
|
|
31
|
+
const constats = [];
|
|
32
|
+
for (const r of resultats) {
|
|
33
|
+
const fichier = path.relative(racine, r.filePath).split(path.sep).join('/');
|
|
34
|
+
for (const m of r.messages.filter(m => m.severity === 2)) {
|
|
35
|
+
constats.push({
|
|
36
|
+
fichier,
|
|
37
|
+
regle: m.ruleId ?? 'parse',
|
|
38
|
+
ligne: m.line,
|
|
39
|
+
message: `${fichier}:${m.line} ${m.ruleId ?? 'parse'} — ${m.message}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return constats;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
47
|
+
// The root of the repository: the first argument (the script `lint` of the package passes it),
|
|
48
|
+
// the working directory otherwise.
|
|
49
|
+
const racine = path.resolve(process.argv[2] ?? process.cwd());
|
|
50
|
+
const { refus, lignes } = trancher(racine, 'lint-des-scripts', await verifier(racine));
|
|
51
|
+
for (const r of refus) {
|
|
52
|
+
process.stderr.write(`⛔ ${r.message}\n`);
|
|
53
|
+
}
|
|
54
|
+
for (const l of lignes) {
|
|
55
|
+
process.stderr.write(`${l}\n`);
|
|
56
|
+
}
|
|
57
|
+
process.exitCode = refus.length ? 1 : 0;
|
|
58
|
+
}
|