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