@roomi-fields/grillhouse 0.30.0 → 0.32.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 +48 -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/dist/temporal/circuit/client.d.ts +2 -2
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/commande.js +4 -4
- package/dist/temporal/circuit/commande.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +3 -3
- package/dist/temporal/circuit/contrat.js +8 -2
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +3 -3
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/commande.js +5 -6
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/installation.d.ts +3 -6
- package/dist/temporal/installation.js +19 -38
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/tickets/activites.d.ts +1 -0
- package/dist/temporal/tickets/activites.js +5 -0
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/dist/temporal/tickets/contrat.d.ts +10 -0
- package/dist/temporal/tickets/deroule.js +8 -1
- package/dist/temporal/tickets/deroule.js.map +1 -1
- package/docs/ARCHITECTURE.md +119 -27
- package/docs/CADRE.md +20 -0
- package/docs/INTERFACE.md +17 -4
- package/hooks/hooks.json +4 -0
- package/package.json +2 -2
- package/scripts/activites.mjs +155 -84
- package/scripts/aiguillage.mjs +35 -11
- package/scripts/attente-au-tour.mjs +99 -0
- package/scripts/avancement.mjs +27 -10
- package/scripts/base-des-workflows.mjs +57 -0
- package/scripts/bilan.mjs +101 -25
- package/scripts/cadre.mjs +5 -2
- package/scripts/circuit.mjs +173 -58
- package/scripts/composants-affectes.mjs +64 -21
- package/scripts/composition-des-langages.mjs +5 -3
- package/scripts/conformite.mjs +54 -19
- package/scripts/copies-finies.mjs +8 -1
- package/scripts/dependances-internes.mjs +9 -3
- package/scripts/dernier-vert.mjs +84 -23
- package/scripts/dette.mjs +32 -11
- package/scripts/donnees-cles.mjs +24 -8
- package/scripts/droits.mjs +40 -15
- package/scripts/effets.mjs +9 -0
- package/scripts/empreinte-d-etape.mjs +17 -0
- package/scripts/engendres.mjs +15 -5
- package/scripts/enveloppe/enveloppe.mjs +141 -48
- package/scripts/enveloppe/travail-de-la-copie.mjs +36 -12
- package/scripts/etapes.mjs +1 -1
- package/scripts/faits-du-circuit.mjs +1 -1
- package/scripts/flux-des-paquets.mjs +21 -7
- package/scripts/gardes-du-cadre.mjs +9 -3
- package/scripts/init.mjs +11 -4
- package/scripts/integration/file.mjs +84 -29
- package/scripts/integration/integrer.mjs +70 -24
- package/scripts/integration/rejeu.mjs +26 -9
- package/scripts/jointure.d.ts +10 -1
- package/scripts/journal-des-etats.d.mts +41 -0
- package/scripts/journal-des-etats.mjs +273 -0
- package/scripts/journal.mjs +119 -0
- package/scripts/langages/cargo/commandes.mjs +97 -18
- package/scripts/langages/cargo/composants.mjs +24 -8
- package/scripts/langages/cargo/index.mjs +7 -0
- package/scripts/langages/cargo/tests-de-head.mjs +25 -9
- package/scripts/langages/python/commandes.mjs +3 -1
- package/scripts/langages/python/index.mjs +6 -0
- 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/elements-du-lot.mjs +36 -12
- package/scripts/langages/typescript/frontieres.mjs +112 -22
- package/scripts/langages/typescript/index-interfaces.mjs +36 -13
- package/scripts/langages/typescript/index.mjs +12 -3
- package/scripts/langages/typescript/interfaces-contre-code.mjs +109 -41
- 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-tailles-des-outils-lourds.mjs +3 -1
- 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 +58 -16
- package/scripts/langages/typescript/tests-de-nuit.mjs +3 -1
- package/scripts/langages/typescript/tests.mjs +24 -8
- package/scripts/langages/typescript/titres-de-tests.mjs +35 -12
- package/scripts/langages/typescript/turbo-des-paquets.mjs +152 -51
- package/scripts/langages/typescript/verdict.mjs +3 -1
- package/scripts/langages/typescript/verifier.mjs +61 -14
- package/scripts/langages/typescript/vitest-config/avancement.reporter.mjs +15 -5
- package/scripts/langages/typescript/vitest-config/base.mjs +10 -2
- package/scripts/langages/typescript/vitest-config/changements.mjs +21 -8
- package/scripts/langages/typescript/vitest-config/delais.mjs +9 -3
- package/scripts/langages/typescript/vitest-config/duree.classement.mjs +12 -4
- package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +17 -6
- package/scripts/langages/typescript/vitest-config/lances.mjs +83 -27
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -0
- package/scripts/langages/typescript/vitest-config/resultats.mjs +3 -1
- package/scripts/langages.d.mts +20 -0
- package/scripts/lint-des-scripts.mjs +58 -0
- package/scripts/matiere-de-test.d.ts +11 -0
- package/scripts/mesure/base-de-passe.mjs +117 -25
- package/scripts/mesure/pression.mjs +9 -3
- 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 +48 -16
- 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 +6 -2
- package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +7 -7
- package/scripts/nuit.sh +24 -0
- package/scripts/outil.mjs +3 -1
- package/scripts/outils-cles.mjs +18 -7
- package/scripts/paquet-npm.mjs +15 -5
- package/scripts/paquets.mjs +12 -4
- package/scripts/passe-de-la-machine.mjs +7 -2
- package/scripts/places-de-la-machine.mjs +72 -12
- package/scripts/preparation.mjs +15 -5
- package/scripts/registre.mjs +6 -2
- package/scripts/reprise.mjs +66 -0
- package/scripts/resultats.mjs +105 -37
- package/scripts/seances.mjs +22 -4
- package/scripts/services-du-noyau.mjs +1 -0
- package/scripts/sous-commandes.mjs +5 -1
- package/scripts/style-a-l-ecriture.mjs +48 -17
- package/scripts/superviseur.mjs +127 -75
- package/scripts/tableau.mjs +133 -10
- package/scripts/taches-du-graphe.mjs +33 -13
- package/scripts/ticket-du-circuit.mjs +40 -0
- package/scripts/transitions.mjs +159 -29
- package/scripts/verrou-de-fichier.mjs +6 -2
- package/scripts/verrou-de-machine.mjs +123 -39
- 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/developpeur/SKILL.md +1 -1
- package/skills/explorateur/SKILL.md +8 -2
- package/skills/grill/SKILL.md +3 -57
- package/skills/grill/references/paquets.md +60 -0
- package/skills/mesure/SKILL.md +3 -0
- package/skills/pitmaster/SKILL.md +16 -27
- package/skills/questionneur/SKILL.md +1 -1
- package/skills/relecteur/SKILL.md +2 -2
- package/skills/testwriter/SKILL.md +19 -7
- package/skills/release/SKILL.md +0 -134
- package/skills/release/scripts/update-version.cjs +0 -92
|
@@ -55,8 +55,11 @@ function lignesConsommateurs(texte) {
|
|
|
55
55
|
const out = [];
|
|
56
56
|
let dedans = false;
|
|
57
57
|
for (const l of ecrites) {
|
|
58
|
-
if (/^##\s/.test(l))
|
|
59
|
-
|
|
58
|
+
if (/^##\s/.test(l)) {
|
|
59
|
+
dedans = /^##\s+Consommateurs\s*$/.test(l);
|
|
60
|
+
} else if (dedans && /^\s*-\s+\S/.test(l)) {
|
|
61
|
+
out.push(l.trim());
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
64
|
return out;
|
|
62
65
|
}
|
|
@@ -68,9 +71,14 @@ function section(description, titre) {
|
|
|
68
71
|
let niveau = 0;
|
|
69
72
|
for (const l of String(description ?? '').split('\n')) {
|
|
70
73
|
const t = /^(#{1,6})\s+(.*)$/.exec(l);
|
|
71
|
-
if (niveau && t && t[1].length <= niveau)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
if (niveau && t && t[1].length <= niveau) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
if (niveau) {
|
|
78
|
+
out.push(l);
|
|
79
|
+
} else if (t && titre.test(t[2].trim())) {
|
|
80
|
+
niveau = t[1].length;
|
|
81
|
+
}
|
|
74
82
|
}
|
|
75
83
|
return out.join('\n');
|
|
76
84
|
}
|
|
@@ -108,7 +116,9 @@ function bdJson(principal, args) {
|
|
|
108
116
|
encoding: 'utf8',
|
|
109
117
|
maxBuffer: 256 * 1024 * 1024,
|
|
110
118
|
});
|
|
111
|
-
if (r.status !== 0)
|
|
119
|
+
if (r.status !== 0) {
|
|
120
|
+
throw new Error(r.stderr || r.error?.message || `code ${r.status}`);
|
|
121
|
+
}
|
|
112
122
|
return JSON.parse(r.stdout || '[]');
|
|
113
123
|
}
|
|
114
124
|
|
|
@@ -117,11 +127,15 @@ function bdJson(principal, args) {
|
|
|
117
127
|
// and plan read by bd from the main tree, judged by `juger`.
|
|
118
128
|
export function verifier(racine, env = process.env) {
|
|
119
129
|
const ticket = ticketDeLaCopie(racine);
|
|
120
|
-
if (!ticket)
|
|
130
|
+
if (!ticket) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
121
133
|
const interfaces = [];
|
|
122
134
|
for (const c of aVerifier(racine, env)) {
|
|
123
135
|
const iface = path.join(c.dir, 'docs', 'INTERFACE.md');
|
|
124
|
-
if (!existsSync(iface))
|
|
136
|
+
if (!existsSync(iface)) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
125
139
|
const rel = path.relative(racine, iface);
|
|
126
140
|
const head = git(racine, 'show', `HEAD:${rel}`);
|
|
127
141
|
interfaces.push({
|
|
@@ -161,7 +175,9 @@ export function juger(ticket, interfaces, commentaires, ticketLu) {
|
|
|
161
175
|
nomsAvant.set(l.consommateur, new Set([...(nomsAvant.get(l.consommateur) ?? []), ...l.noms]));
|
|
162
176
|
}
|
|
163
177
|
for (const ligne of lignesConsommateurs(apres)) {
|
|
164
|
-
if (avant.has(ligne))
|
|
178
|
+
if (avant.has(ligne)) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
165
181
|
const l = lireLigne(ligne);
|
|
166
182
|
const lue = l?.noms ? l : null;
|
|
167
183
|
const deja = lue && nomsAvant.get(lue.consommateur);
|
|
@@ -169,7 +185,9 @@ export function juger(ticket, interfaces, commentaires, ticketLu) {
|
|
|
169
185
|
changees.push({ rel, ligne, lue, ajoutes });
|
|
170
186
|
}
|
|
171
187
|
}
|
|
172
|
-
if (changees.length === 0)
|
|
188
|
+
if (changees.length === 0) {
|
|
189
|
+
return [];
|
|
190
|
+
}
|
|
173
191
|
let comments;
|
|
174
192
|
try {
|
|
175
193
|
comments = (commentaires() ?? []).map(x => ({ text: String(x.text ?? '') }));
|
|
@@ -185,7 +203,9 @@ export function juger(ticket, interfaces, commentaires, ticketLu) {
|
|
|
185
203
|
const restantes = changees.filter(
|
|
186
204
|
({ ligne }) => !arbitrages.some(a => a.text.includes(consommateurDe(ligne)))
|
|
187
205
|
);
|
|
188
|
-
if (restantes.length === 0)
|
|
206
|
+
if (restantes.length === 0) {
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
189
209
|
// The lines no arbitrage settles: the ticket's plan, its title and its sections « Architecture »
|
|
190
210
|
// and « Noms publiés ».
|
|
191
211
|
let plan;
|
|
@@ -206,7 +226,9 @@ export function juger(ticket, interfaces, commentaires, ticketLu) {
|
|
|
206
226
|
const constats = [];
|
|
207
227
|
for (const { rel, ligne, lue, ajoutes } of restantes) {
|
|
208
228
|
const manquants = lue ? nonNommes(plan, [lue.consommateur, ...ajoutes]) : null;
|
|
209
|
-
if (manquants?.length === 0)
|
|
229
|
+
if (manquants?.length === 0) {
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
210
232
|
const consommateur = consommateurDe(ligne);
|
|
211
233
|
const dit = manquants
|
|
212
234
|
? ` ; le plan ne nomme pas ${manquants.map(n => `\`${n}\``).join(', ')}`
|
|
@@ -223,7 +245,11 @@ export function juger(ticket, interfaces, commentaires, ticketLu) {
|
|
|
223
245
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
224
246
|
const racine = process.cwd();
|
|
225
247
|
const { refus, lignes } = trancher(racine, 'consommateurs-arbitres', verifier(racine));
|
|
226
|
-
for (const r of refus)
|
|
227
|
-
|
|
248
|
+
for (const r of refus) {
|
|
249
|
+
process.stderr.write(`⛔ ${r.message}\n`);
|
|
250
|
+
}
|
|
251
|
+
for (const l of lignes) {
|
|
252
|
+
process.stderr.write(`${l}\n`);
|
|
253
|
+
}
|
|
228
254
|
process.exitCode = refus.length ? 1 : 0;
|
|
229
255
|
}
|
|
@@ -71,7 +71,9 @@ const NOM = /^(?:\*|[\p{ID_Start}$_][\p{ID_Continue}$]*)$/u;
|
|
|
71
71
|
// « : » is not a name (`NOM`), a bullet of prose; null for a line that is no bullet (a paragraph).
|
|
72
72
|
// The one reading of such a line, for this guard and for scripts/langages/typescript/consommateurs-arbitres.mjs.
|
|
73
73
|
export function lireLigne(ligne) {
|
|
74
|
-
if (!/^[-*]\s+\S/.test(ligne))
|
|
74
|
+
if (!/^[-*]\s+\S/.test(ligne)) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
75
77
|
const m = /^[-*]\s+`?([^`:\s]+)`?\s*:\s*(.+)$/.exec(ligne);
|
|
76
78
|
const noms = m
|
|
77
79
|
? m[2]
|
|
@@ -97,7 +99,9 @@ function lignesDeConsommateurs(texte) {
|
|
|
97
99
|
continue;
|
|
98
100
|
}
|
|
99
101
|
const lue = dedans ? lireLigne(l.trim()) : null;
|
|
100
|
-
if (lue)
|
|
102
|
+
if (lue) {
|
|
103
|
+
out.push({ texte: l.trim(), ...lue });
|
|
104
|
+
}
|
|
101
105
|
}
|
|
102
106
|
return out;
|
|
103
107
|
}
|
|
@@ -147,7 +151,9 @@ export function imports(source) {
|
|
|
147
151
|
.replace(/^\s*type\s+/, '')
|
|
148
152
|
.split(/\s+as\s+/)[0]
|
|
149
153
|
.trim();
|
|
150
|
-
if (nom)
|
|
154
|
+
if (nom) {
|
|
155
|
+
noms.push(nom);
|
|
156
|
+
}
|
|
151
157
|
}
|
|
152
158
|
}
|
|
153
159
|
if (
|
|
@@ -155,8 +161,9 @@ export function imports(source) {
|
|
|
155
161
|
.replace(/\{[^}]*\}/, '')
|
|
156
162
|
.replace(/,/g, '')
|
|
157
163
|
.trim()
|
|
158
|
-
)
|
|
164
|
+
) {
|
|
159
165
|
noms.push('*');
|
|
166
|
+
}
|
|
160
167
|
out.push({ spec: m[2], noms });
|
|
161
168
|
}
|
|
162
169
|
return out;
|
|
@@ -208,11 +215,19 @@ export function utilise(racine, tous = composants(racine), parLesTests = null) {
|
|
|
208
215
|
}
|
|
209
216
|
parLesTests.get(c).add(p);
|
|
210
217
|
}
|
|
211
|
-
if (!p || (test && !matiere.has(p.nom)))
|
|
212
|
-
|
|
218
|
+
if (!p || (test && !matiere.has(p.nom))) {
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
if (!out.has(p.nom)) {
|
|
222
|
+
out.set(p.nom, new Map());
|
|
223
|
+
}
|
|
213
224
|
const parConsommateur = out.get(p.nom);
|
|
214
|
-
if (!parConsommateur.has(c.nom))
|
|
215
|
-
|
|
225
|
+
if (!parConsommateur.has(c.nom)) {
|
|
226
|
+
parConsommateur.set(c.nom, new Set());
|
|
227
|
+
}
|
|
228
|
+
for (const n of noms) {
|
|
229
|
+
parConsommateur.get(c.nom).add(n);
|
|
230
|
+
}
|
|
216
231
|
}
|
|
217
232
|
}
|
|
218
233
|
}
|
|
@@ -269,19 +284,22 @@ export function verifier(racine) {
|
|
|
269
284
|
for (const [consommateur, noms] of utilises) {
|
|
270
285
|
const permis = declare.get(consommateur) ?? new Set();
|
|
271
286
|
for (const n of noms) {
|
|
272
|
-
if (!permis.has(n))
|
|
287
|
+
if (!permis.has(n)) {
|
|
273
288
|
refus.push({
|
|
274
289
|
fichier: rel,
|
|
275
290
|
regle: 'usage-non-declare',
|
|
276
291
|
message: `${consommateur} utilise « ${n} » de ${p.nom}, que ${rel} ne déclare pas.`,
|
|
277
292
|
});
|
|
293
|
+
}
|
|
278
294
|
}
|
|
279
295
|
}
|
|
280
296
|
for (const [consommateur, noms] of declare) {
|
|
281
|
-
if (hors.has(consommateur))
|
|
297
|
+
if (hors.has(consommateur)) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
282
300
|
const faits = utilises.get(consommateur) ?? new Set();
|
|
283
301
|
for (const n of noms) {
|
|
284
|
-
if (!faits.has(n))
|
|
302
|
+
if (!faits.has(n)) {
|
|
285
303
|
refus.push({
|
|
286
304
|
fichier: rel,
|
|
287
305
|
regle: DECLARE_NON_UTILISE,
|
|
@@ -289,6 +307,7 @@ export function verifier(racine) {
|
|
|
289
307
|
nom: n,
|
|
290
308
|
message: `${rel} déclare « ${n} » pour ${consommateur}, qu'aucun code de ${consommateur} n'utilise.`,
|
|
291
309
|
});
|
|
310
|
+
}
|
|
292
311
|
}
|
|
293
312
|
}
|
|
294
313
|
}
|
|
@@ -299,8 +318,12 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
|
299
318
|
const racine = process.cwd();
|
|
300
319
|
const verdict = verifier(racine);
|
|
301
320
|
const { refus, lignes } = trancher(racine, 'consommateurs', verdict.refus);
|
|
302
|
-
for (const r of refus)
|
|
303
|
-
|
|
321
|
+
for (const r of refus) {
|
|
322
|
+
process.stderr.write(`⛔ ${r.message}\n`);
|
|
323
|
+
}
|
|
324
|
+
for (const l of lignes) {
|
|
325
|
+
process.stderr.write(`${l}\n`);
|
|
326
|
+
}
|
|
304
327
|
if (refus.some(r => r.regle !== DECLARE_NON_UTILISE && r.regle !== LIGNE_MAL_FORMEE)) {
|
|
305
328
|
process.stderr.write(
|
|
306
329
|
"Une consommation nouvelle se décide (le titre du ticket, sa section « Architecture » ou sa section « Noms publiés » qui la nomment, sinon l'arbitrage du superviseur), puis entre dans la section « Consommateurs » de l'interface du fournisseur.\n"
|
|
@@ -311,5 +334,7 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
|
311
334
|
"Un nom que son consommateur n'utilise plus sort de sa ligne dans la section « Consommateurs » de l'interface du fournisseur.\n"
|
|
312
335
|
);
|
|
313
336
|
}
|
|
314
|
-
if (refus.length)
|
|
337
|
+
if (refus.length) {
|
|
338
|
+
process.exitCode = 1;
|
|
339
|
+
}
|
|
315
340
|
}
|
|
@@ -83,12 +83,16 @@ function declarationsDe(ts, sf) {
|
|
|
83
83
|
} else if (ts.isVariableStatement(st)) {
|
|
84
84
|
const decls = st.declarationList.declarations;
|
|
85
85
|
for (const d of decls) {
|
|
86
|
-
for (const n of noms(d.name))
|
|
86
|
+
for (const n of noms(d.name)) {
|
|
87
|
+
ajouter(n.text, 'constante', n, decls.length > 1 ? d : st);
|
|
88
|
+
}
|
|
87
89
|
}
|
|
88
90
|
} else if (ts.isExportDeclaration(st)) {
|
|
89
91
|
const clause = st.exportClause;
|
|
90
92
|
if (clause && ts.isNamedExports(clause)) {
|
|
91
|
-
for (const s of clause.elements)
|
|
93
|
+
for (const s of clause.elements) {
|
|
94
|
+
ajouter(s.name.text, 'export', s.name, st);
|
|
95
|
+
}
|
|
92
96
|
} else if (clause) {
|
|
93
97
|
ajouter(clause.name.text, 'export', clause.name, st);
|
|
94
98
|
} else {
|
|
@@ -104,10 +108,14 @@ function declarationsDe(ts, sf) {
|
|
|
104
108
|
// The declarations of an API report's text <texte>, as declarationsDe gives them, each line that
|
|
105
109
|
// of the report file; an empty Map without a report.
|
|
106
110
|
function declarationsDuRapport(ts, texte) {
|
|
107
|
-
if (texte === null)
|
|
111
|
+
if (texte === null) {
|
|
112
|
+
return new Map();
|
|
113
|
+
}
|
|
108
114
|
const lignes = texte.split('\n');
|
|
109
115
|
const debut = lignes.indexOf(`${CLOTURE}ts`);
|
|
110
|
-
if (debut < 0)
|
|
116
|
+
if (debut < 0) {
|
|
117
|
+
return new Map();
|
|
118
|
+
}
|
|
111
119
|
const fin = lignes.indexOf(CLOTURE, debut + 1);
|
|
112
120
|
const code = lignes.slice(debut + 1, fin < 0 ? undefined : fin).join('\n');
|
|
113
121
|
const sf = ts.createSourceFile('rapport.d.ts', code, ts.ScriptTarget.Latest, true);
|
|
@@ -180,7 +188,9 @@ function calculer(copie, avant, apres) {
|
|
|
180
188
|
for (const { fichier, supprime } of changes) {
|
|
181
189
|
const c = composantDe(fichier);
|
|
182
190
|
const abs = path.resolve(copie, fichier);
|
|
183
|
-
if (!c || !SOURCE.test(fichier) || estTest(c, abs))
|
|
191
|
+
if (!c || !SOURCE.test(fichier) || estTest(c, abs)) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
184
194
|
const lu = supprime ? null : lus.get(abs);
|
|
185
195
|
const lisible = supprime
|
|
186
196
|
? !s.raison && existsSync(path.join(c.dir, 'tsconfig.json'))
|
|
@@ -211,11 +221,16 @@ function calculer(copie, avant, apres) {
|
|
|
211
221
|
rapportApres.has(d.nom) || (d.noeud ? s.publie(c, d.noeud) : abs === s.entree(c));
|
|
212
222
|
for (const d of decApres.values()) {
|
|
213
223
|
const avantLui = decAvant.get(d.nom);
|
|
214
|
-
if (!avantLui)
|
|
215
|
-
|
|
224
|
+
if (!avantLui) {
|
|
225
|
+
element(d, 'neuf', exporteApres(d));
|
|
226
|
+
} else if (avantLui.texte !== d.texte) {
|
|
227
|
+
element(d, 'changé', exporteApres(d));
|
|
228
|
+
}
|
|
216
229
|
}
|
|
217
230
|
for (const d of decAvant.values()) {
|
|
218
|
-
if (!decApres.has(d.nom))
|
|
231
|
+
if (!decApres.has(d.nom)) {
|
|
232
|
+
element(d, 'supprimé', rapportAvant.has(d.nom));
|
|
233
|
+
}
|
|
219
234
|
}
|
|
220
235
|
}
|
|
221
236
|
|
|
@@ -223,7 +238,9 @@ function calculer(copie, avant, apres) {
|
|
|
223
238
|
const changesEnSet = new Set(changes.map(x => enPosix(x.fichier)));
|
|
224
239
|
for (const c of tous) {
|
|
225
240
|
const { fichier, avant: a, apres: p } = rapportsDe(c);
|
|
226
|
-
if (!changesEnSet.has(fichier))
|
|
241
|
+
if (!changesEnSet.has(fichier)) {
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
227
244
|
const nommes = new Set(elements.filter(e => e.paquet === nomDe(c)).map(e => e.nom));
|
|
228
245
|
const ajouter = (d, statut) =>
|
|
229
246
|
nommes.has(d.nom) ||
|
|
@@ -239,10 +256,17 @@ function calculer(copie, avant, apres) {
|
|
|
239
256
|
});
|
|
240
257
|
for (const d of p.values()) {
|
|
241
258
|
const avantLui = a.get(d.nom);
|
|
242
|
-
if (!avantLui)
|
|
243
|
-
|
|
259
|
+
if (!avantLui) {
|
|
260
|
+
ajouter(d, 'neuf');
|
|
261
|
+
} else if (avantLui.texte !== d.texte) {
|
|
262
|
+
ajouter(d, 'changé');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
for (const d of a.values()) {
|
|
266
|
+
if (!p.has(d.nom)) {
|
|
267
|
+
ajouter(d, 'supprimé');
|
|
268
|
+
}
|
|
244
269
|
}
|
|
245
|
-
for (const d of a.values()) if (!p.has(d.nom)) ajouter(d, 'supprimé');
|
|
246
270
|
}
|
|
247
271
|
|
|
248
272
|
elements.sort(
|
|
@@ -59,6 +59,7 @@ export const RACINES = ['src', 'packages'];
|
|
|
59
59
|
/** The test files, as a pattern of a path from the repository's root. */
|
|
60
60
|
export const TESTS = '(^|/)(test|tests|__tests__)/|[.](test|spec)[.][a-z]+$';
|
|
61
61
|
const REGLE_OUTILS = 'pas-d-outil-de-developpement-dans-le-code';
|
|
62
|
+
const REGLE_DECLARATION = 'pas-d-import-non-declare';
|
|
62
63
|
// The environment variable naming the file that holds the pattern of the published files.
|
|
63
64
|
const JUGES = 'GRILLHOUSE_JUGES';
|
|
64
65
|
|
|
@@ -83,7 +84,9 @@ function ecrire(regle, retrait) {
|
|
|
83
84
|
.map(l => {
|
|
84
85
|
const ligne = retrait + l;
|
|
85
86
|
const m = /^(\s*(?:"[^"]*": )?)"(.*)"(,?)$/.exec(ligne);
|
|
86
|
-
if (ligne.length <= LARGEUR || !m)
|
|
87
|
+
if (ligne.length <= LARGEUR || !m) {
|
|
88
|
+
return ligne;
|
|
89
|
+
}
|
|
87
90
|
const [, tete, valeur, virgule] = m;
|
|
88
91
|
const pieces = [];
|
|
89
92
|
let reste = valeur;
|
|
@@ -91,8 +94,12 @@ function ecrire(regle, retrait) {
|
|
|
91
94
|
while (reste.length > place) {
|
|
92
95
|
const dans = reste.slice(0, place);
|
|
93
96
|
let coupe = Math.max(dans.lastIndexOf(' '), dans.lastIndexOf('|')) + 1;
|
|
94
|
-
if (coupe === 0)
|
|
95
|
-
|
|
97
|
+
if (coupe === 0) {
|
|
98
|
+
coupe = place;
|
|
99
|
+
}
|
|
100
|
+
while (reste[coupe - 1] === '\\') {
|
|
101
|
+
coupe -= 1;
|
|
102
|
+
}
|
|
96
103
|
pieces.push(reste.slice(0, coupe));
|
|
97
104
|
reste = reste.slice(coupe);
|
|
98
105
|
}
|
|
@@ -108,7 +115,9 @@ function ecrire(regle, retrait) {
|
|
|
108
115
|
function entreesBin(racine) {
|
|
109
116
|
return composants(racine).flatMap(({ dir }) => {
|
|
110
117
|
const fichier = path.join(dir, 'package.json');
|
|
111
|
-
if (!existsSync(fichier))
|
|
118
|
+
if (!existsSync(fichier)) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
112
121
|
const { bin } = JSON.parse(readFileSync(fichier, 'utf8'));
|
|
113
122
|
const cibles = typeof bin === 'string' ? [bin] : Object.values(bin ?? {});
|
|
114
123
|
return cibles
|
|
@@ -152,6 +161,18 @@ export function configuration(racine) {
|
|
|
152
161
|
from: { path: CODE, pathNot: TESTS },
|
|
153
162
|
to: { dependencyTypes: ['npm-dev'] },
|
|
154
163
|
},
|
|
164
|
+
{
|
|
165
|
+
name: REGLE_DECLARATION,
|
|
166
|
+
comment:
|
|
167
|
+
"un import vise un paquet que le package.json du paquet importateur déclare (la règle no-non-package-json de dependency-cruiser) : l'usage se déclare s'il est valide pour l'architecture, sinon une question d'architecture s'ouvre",
|
|
168
|
+
severity: 'error',
|
|
169
|
+
// The development imports (the test files and the tools' configuration files) are out of
|
|
170
|
+
// the published code: the tools they import (vitest, typescript) are the workspace's.
|
|
171
|
+
from: { pathNot: `${TESTS}|(^|/)[^/]*[.]config[.][cm]?[jt]s$` },
|
|
172
|
+
// A peer dependency is declared by the package, yet dependency-cruiser types it `npm-no-pkg`
|
|
173
|
+
// too: the types it carries as peer are not refused.
|
|
174
|
+
to: { dependencyTypes: ['npm-no-pkg', 'npm-unknown'], dependencyTypesNot: ['npm-peer'] },
|
|
175
|
+
},
|
|
155
176
|
{
|
|
156
177
|
name: 'tout-import-se-resout',
|
|
157
178
|
comment: "un import se résout : un chemin qu'un paquet n'exporte pas est refusé",
|
|
@@ -165,7 +186,9 @@ export function configuration(racine) {
|
|
|
165
186
|
severity: 'warn',
|
|
166
187
|
from: {
|
|
167
188
|
orphan: true,
|
|
168
|
-
pathNot: [`${TESTS}|(^|/)index[.][a-z]+$|[.]d[.][mc]?ts$|[.]config[.][a-z]+$`, ...bin].join(
|
|
189
|
+
pathNot: [`${TESTS}|(^|/)index[.][a-z]+$|[.]d[.][mc]?ts$|[.]config[.][a-z]+$`, ...bin].join(
|
|
190
|
+
'|'
|
|
191
|
+
),
|
|
169
192
|
},
|
|
170
193
|
to: {},
|
|
171
194
|
},
|
|
@@ -263,15 +286,23 @@ export function sorties(dir) {
|
|
|
263
286
|
const hote = { ...ts.sys, onUnRecoverableConfigFileDiagnostic: () => {} };
|
|
264
287
|
const table = new Map();
|
|
265
288
|
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
266
|
-
if (!e.isFile() || !/^tsconfig.*[.]json$/.test(e.name))
|
|
289
|
+
if (!e.isFile() || !/^tsconfig.*[.]json$/.test(e.name)) {
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
267
292
|
const analyse = ts.getParsedCommandLineOfConfigFile(path.join(dir, e.name), {}, hote);
|
|
268
|
-
if (!analyse || analyse.options.noEmit)
|
|
293
|
+
if (!analyse || analyse.options.noEmit) {
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
269
296
|
for (const source of analyse.fileNames.map(f => path.resolve(f))) {
|
|
270
|
-
if (DECLARATION.test(source) || !existsSync(source))
|
|
297
|
+
if (DECLARATION.test(source) || !existsSync(source)) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
271
300
|
const emises = ts.getOutputFileNames(analyse, source, ts.sys.useCaseSensitiveFileNames);
|
|
272
301
|
for (const sortie of emises) {
|
|
273
302
|
const chemin = path.resolve(sortie);
|
|
274
|
-
if (chemin !== source)
|
|
303
|
+
if (chemin !== source) {
|
|
304
|
+
table.set(chemin, new Set([...(table.get(chemin) ?? []), source]));
|
|
305
|
+
}
|
|
275
306
|
}
|
|
276
307
|
}
|
|
277
308
|
}
|
|
@@ -281,7 +312,9 @@ export function sorties(dir) {
|
|
|
281
312
|
// The targets of an `exports` value: the string itself, or the targets of each value of an object
|
|
282
313
|
// (its subpaths and its conditions).
|
|
283
314
|
function cibles(valeur) {
|
|
284
|
-
if (typeof valeur === 'string')
|
|
315
|
+
if (typeof valeur === 'string') {
|
|
316
|
+
return [valeur];
|
|
317
|
+
}
|
|
285
318
|
return valeur && typeof valeur === 'object' ? Object.values(valeur).flatMap(cibles) : [];
|
|
286
319
|
}
|
|
287
320
|
|
|
@@ -293,13 +326,19 @@ function sourcesDuPaquet(racine, dir) {
|
|
|
293
326
|
const sources = new Set();
|
|
294
327
|
const refus = [];
|
|
295
328
|
const fichier = path.join(dir, 'package.json');
|
|
296
|
-
if (!existsSync(fichier))
|
|
329
|
+
if (!existsSync(fichier)) {
|
|
330
|
+
return { sources, refus };
|
|
331
|
+
}
|
|
297
332
|
const entrees = cibles(JSON.parse(readFileSync(fichier, 'utf8')).exports);
|
|
298
|
-
if (entrees.length === 0)
|
|
333
|
+
if (entrees.length === 0) {
|
|
334
|
+
return { sources, refus };
|
|
335
|
+
}
|
|
299
336
|
const emis = sorties(dir);
|
|
300
337
|
for (const cible of entrees) {
|
|
301
338
|
const abs = path.resolve(dir, cible);
|
|
302
|
-
if (DECLARATION.test(abs) || abs.endsWith('.json'))
|
|
339
|
+
if (DECLARATION.test(abs) || abs.endsWith('.json')) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
303
342
|
const source =
|
|
304
343
|
SOURCE_TS.test(abs) || (SOURCE_JS.test(abs) && !emis.has(abs) && existsSync(abs));
|
|
305
344
|
const trouvees = source ? [abs].filter(f => existsSync(f)) : [...(emis.get(abs) ?? [])];
|
|
@@ -309,7 +348,9 @@ function sourcesDuPaquet(racine, dir) {
|
|
|
309
348
|
'ni fichier source, ni configuration TypeScript du paquet qui la produise.'
|
|
310
349
|
);
|
|
311
350
|
}
|
|
312
|
-
for (const f of trouvees)
|
|
351
|
+
for (const f of trouvees) {
|
|
352
|
+
sources.add(f);
|
|
353
|
+
}
|
|
313
354
|
}
|
|
314
355
|
return { sources, refus };
|
|
315
356
|
}
|
|
@@ -321,7 +362,9 @@ export function publiees(racine) {
|
|
|
321
362
|
const refus = [];
|
|
322
363
|
for (const { dir } of composants(racine)) {
|
|
323
364
|
const trouve = sourcesDuPaquet(racine, dir);
|
|
324
|
-
for (const f of trouve.sources)
|
|
365
|
+
for (const f of trouve.sources) {
|
|
366
|
+
sources.add(posix(path.relative(racine, f)));
|
|
367
|
+
}
|
|
325
368
|
refus.push(...trouve.refus);
|
|
326
369
|
}
|
|
327
370
|
return { sources, refus };
|
|
@@ -367,11 +410,15 @@ function aJuger(graphe, sources) {
|
|
|
367
410
|
const pile = [...sources];
|
|
368
411
|
while (pile.length) {
|
|
369
412
|
const f = pile.pop();
|
|
370
|
-
if (atteints.has(f))
|
|
413
|
+
if (atteints.has(f)) {
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
371
416
|
atteints.add(f);
|
|
372
417
|
juges.add(f);
|
|
373
418
|
for (const d of modules.get(f)?.dependencies ?? []) {
|
|
374
|
-
if (d.couldNotResolve || d.coreModule || /(^|\/)node_modules\//.test(d.resolved))
|
|
419
|
+
if (d.couldNotResolve || d.coreModule || /(^|\/)node_modules\//.test(d.resolved)) {
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
375
422
|
pile.push(d.resolved);
|
|
376
423
|
}
|
|
377
424
|
}
|
|
@@ -391,6 +438,36 @@ export function constats(resultat) {
|
|
|
391
438
|
}));
|
|
392
439
|
}
|
|
393
440
|
|
|
441
|
+
// The package an import of a violation targets: the name in the `node_modules` path it resolves
|
|
442
|
+
// to (`@scope/name` or `name`), else the module's own name.
|
|
443
|
+
function paquetVise(violation) {
|
|
444
|
+
const m = /(?:^|\/)node_modules\/((?:@[^/]+\/)?[^/]+)/.exec(violation.to);
|
|
445
|
+
return m ? m[1] : violation.to;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// The refusal of an import the package does not declare, with its two ways on: the file, the
|
|
449
|
+
// package imported, then declaring the usage (and, for a component of the repository, in the
|
|
450
|
+
// provider's "Consommateurs" section), else an architecture question.
|
|
451
|
+
export function suitesDeLUsage(racine, violation) {
|
|
452
|
+
const importe = paquetVise(violation);
|
|
453
|
+
const propre = /^(packages\/[^/]+)\//.exec(violation.from);
|
|
454
|
+
const manifeste = `${propre ? `${propre[1]}/` : ''}package.json`;
|
|
455
|
+
const fournisseur = composants(racine).find(c => c.paquet === importe);
|
|
456
|
+
const tete = `⛔ ${violation.from} importe ${importe}, que ${manifeste} ne déclare pas.`;
|
|
457
|
+
if (fournisseur) {
|
|
458
|
+
const interfaceDuFournisseur = `${posix(path.relative(racine, fournisseur.dir))}/docs/INTERFACE.md`;
|
|
459
|
+
return (
|
|
460
|
+
`${tete}\n Si l'usage est valide pour l'architecture : le déclarer dans ${manifeste}, et dans ` +
|
|
461
|
+
`la section « Consommateurs » de ${interfaceDuFournisseur}.\n Sinon : ouvrir une question ` +
|
|
462
|
+
"d'architecture (au superviseur)."
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
return (
|
|
466
|
+
`${tete}\n Si l'usage est valide pour l'architecture : le déclarer dans ${manifeste}.\n` +
|
|
467
|
+
" Sinon : ouvrir une question d'architecture (au superviseur)."
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
|
|
394
471
|
// The pattern of the files to judge, as dependency-cruiser's `path` filter reads it.
|
|
395
472
|
const motifDes = fichiers => `^(${[...fichiers].sort().map(echappe).join('|')})$`;
|
|
396
473
|
|
|
@@ -420,21 +497,27 @@ function frontieres(racine, args) {
|
|
|
420
497
|
return 1;
|
|
421
498
|
}
|
|
422
499
|
const racines = RACINES.filter(r => existsSync(path.join(racine, r)));
|
|
423
|
-
if (racines.length === 0)
|
|
500
|
+
if (racines.length === 0) {
|
|
501
|
+
return 0;
|
|
502
|
+
}
|
|
424
503
|
const environnement = { ...process.env };
|
|
425
504
|
delete environnement[JUGES];
|
|
426
505
|
let dossier = null;
|
|
427
506
|
try {
|
|
428
507
|
if (sources.size > 0) {
|
|
429
508
|
const graphe = depcruise(racine, racines, 'json', environnement);
|
|
430
|
-
if (!graphe.stdout)
|
|
509
|
+
if (!graphe.stdout) {
|
|
510
|
+
return graphe.status || 1;
|
|
511
|
+
}
|
|
431
512
|
dossier = mkdtempSync(path.join(tmpdir(), 'frontieres-'));
|
|
432
513
|
const fichier = path.join(dossier, 'juges.txt');
|
|
433
514
|
writeFileSync(fichier, motifDes(aJuger(JSON.parse(graphe.stdout), sources)));
|
|
434
515
|
environnement[JUGES] = fichier;
|
|
435
516
|
}
|
|
436
517
|
const r = depcruise(racine, racines, 'json', environnement);
|
|
437
|
-
if (!r.stdout)
|
|
518
|
+
if (!r.stdout) {
|
|
519
|
+
return r.status || 1;
|
|
520
|
+
}
|
|
438
521
|
const resultat = JSON.parse(r.stdout);
|
|
439
522
|
const { refus, lignes } = trancher(racine, 'frontieres', constats(resultat));
|
|
440
523
|
// The report is dependency-cruiser's own (`err-long`): the result formatted as it is when the
|
|
@@ -457,10 +540,17 @@ function frontieres(racine, args) {
|
|
|
457
540
|
stdio: 'inherit',
|
|
458
541
|
});
|
|
459
542
|
}
|
|
460
|
-
for (const l of lignes)
|
|
543
|
+
for (const l of lignes) {
|
|
544
|
+
process.stderr.write(`${l}\n`);
|
|
545
|
+
}
|
|
546
|
+
for (const c of refus.filter(c => c.regle === REGLE_DECLARATION)) {
|
|
547
|
+
process.stderr.write(`${suitesDeLUsage(racine, c.violation)}\n`);
|
|
548
|
+
}
|
|
461
549
|
return refus.length ? 1 : 0;
|
|
462
550
|
} finally {
|
|
463
|
-
if (dossier)
|
|
551
|
+
if (dossier) {
|
|
552
|
+
rmSync(dossier, { recursive: true, force: true });
|
|
553
|
+
}
|
|
464
554
|
}
|
|
465
555
|
}
|
|
466
556
|
|