@roomi-fields/grillhouse 0.24.4 → 0.24.6
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/docs/ARCHITECTURE.md +11 -4
- package/package.json +1 -1
- package/scripts/consommateurs-arbitres.mjs +6 -15
- package/scripts/consommateurs.mjs +88 -25
- package/scripts/dernier-vert.mjs +26 -0
- package/scripts/migrations/0.24.6-lignes-mal-formees.mjs +40 -0
- package/scripts/migrations.mjs +2 -0
- package/scripts/vitest-config/changements.mjs +60 -8
- package/skills/redacteur/references/documents-d-un-composant.md +6 -2
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -24,10 +24,17 @@ hit, replaying logs »), et cette relecture vaut un lancement. Une passe se mesu
|
|
|
24
24
|
dernier vert, l'arbre de la dernière passe verte de sa branche, celle de main pour une copie
|
|
25
25
|
qui n'en a pas encore, comme `vitest --changed` : un paquet que Turborepo rejoue joue les seuls tests que Vitest relie aux fichiers changés depuis,
|
|
26
26
|
et tous ses tests quand un changement sort du graphe de Vitest (un fichier supprimé, une
|
|
27
|
-
configuration, un fichier qu'aucun module n'importe,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
configuration, un fichier qu'aucun module n'importe, un fichier, changé ou supprimé, que lit
|
|
28
|
+
la construction d'un paquet dont il dépend, un chemin que ses tests déclarent lire,
|
|
29
|
+
`grillhouse.lit`) ; la construction d'un voisin lit les entrées du `build` de son turbo.json,
|
|
30
|
+
lues comme Turborepo les lit (`$TURBO_DEFAULT$` : tous les fichiers du paquet, `docs/`
|
|
31
|
+
compris ; `$TURBO_EXTENDS$` : les entrées du `build` de la racine), et, quand elles n'en
|
|
32
|
+
nomment aucune, son code et sa configuration hors de son `docs/` ; jamais un test ; sans vert
|
|
33
|
+
connu, la passe est complète, et `npm run verifier -- --tout` la joue pour de vrai, comme la
|
|
34
|
+
nuit. Un fichier que le commit du vert ne suit pas vit dans le seul arbre qui l'a gardé :
|
|
35
|
+
absent d'une copie mesurée contre le vert de main, il n'est pas supprimé, comme Nx et
|
|
36
|
+
Turborepo mesurent contre un commit. Ainsi un test ne tourne qu'une fois tant que rien ne
|
|
37
|
+
change, et corriger un test ne rejoue que lui.
|
|
31
38
|
|
|
32
39
|
**Tout se lit, le plan s'écrit** : un agent de rôle travaille dans l'enveloppe de sa copie
|
|
33
40
|
(`packages/grillhouse/scripts/enveloppe/`, un bac à sable bubblewrap) ; il lit toute la copie,
|
package/package.json
CHANGED
|
@@ -36,6 +36,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
36
36
|
import { existsSync, readFileSync } from 'node:fs';
|
|
37
37
|
import path from 'node:path';
|
|
38
38
|
import { pathToFileURL } from 'node:url';
|
|
39
|
+
import { lireLigne } from './consommateurs.mjs';
|
|
39
40
|
import { trancher } from './dette.mjs';
|
|
40
41
|
import { aVerifier, marques } from './interfaces-contre-code.mjs';
|
|
41
42
|
|
|
@@ -90,18 +91,6 @@ function section(description, titre) {
|
|
|
90
91
|
return out.join('\n');
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
// The consumer and the names of the `## Consommateurs` line <ligne>
|
|
94
|
-
// (``- `<consommateur>` : <nom>, <nom>``), or null for a line of another form.
|
|
95
|
-
function lireLigne(ligne) {
|
|
96
|
-
const m = /^[-*]\s+`?([^`:\s]+)`?\s*:\s*(.+)$/.exec(ligne);
|
|
97
|
-
if (!m) return null;
|
|
98
|
-
const noms = m[2]
|
|
99
|
-
.split(',')
|
|
100
|
-
.map(s => s.replace(/`/g, '').trim())
|
|
101
|
-
.filter(Boolean);
|
|
102
|
-
return { consommateur: m[1], noms };
|
|
103
|
-
}
|
|
104
|
-
|
|
105
94
|
// The names of <noms> the text <texte> does not name word for word: each one whole, with no
|
|
106
95
|
// character of a name (a letter, a digit, `_`, `$`, `-`) beside it; `*`, a namespace, between
|
|
107
96
|
// backquotes.
|
|
@@ -135,14 +124,16 @@ export function verifier(racine, env = process.env) {
|
|
|
135
124
|
const head = git(racine, 'show', `HEAD:${rel}`);
|
|
136
125
|
const lignesAvant = head.status === 0 ? lignesConsommateurs(head.stdout) : [];
|
|
137
126
|
const avant = new Set(lignesAvant);
|
|
138
|
-
// The names each consumer of HEAD's section reads.
|
|
127
|
+
// The names each consumer of HEAD's section reads (`lireLigne` of scripts/consommateurs.mjs,
|
|
128
|
+
// the one reading of such a line: a line that is no list of names gives none).
|
|
139
129
|
const nomsAvant = new Map();
|
|
140
|
-
for (const l of lignesAvant.map(lireLigne).filter(
|
|
130
|
+
for (const l of lignesAvant.map(lireLigne).filter(l => l?.noms)) {
|
|
141
131
|
nomsAvant.set(l.consommateur, new Set([...(nomsAvant.get(l.consommateur) ?? []), ...l.noms]));
|
|
142
132
|
}
|
|
143
133
|
for (const ligne of lignesConsommateurs(readFileSync(iface, 'utf8'))) {
|
|
144
134
|
if (avant.has(ligne)) continue;
|
|
145
|
-
const
|
|
135
|
+
const l = lireLigne(ligne);
|
|
136
|
+
const lue = l?.noms ? l : null;
|
|
146
137
|
const deja = lue && nomsAvant.get(lue.consommateur);
|
|
147
138
|
const ajoutes = lue ? lue.noms.filter(n => !deja?.has(n)) : null;
|
|
148
139
|
changees.push({ rel, ligne, lue, ajoutes });
|
|
@@ -11,12 +11,17 @@
|
|
|
11
11
|
// refuses (exit 1) a use that the provider's interface does not declare, and a declared name that
|
|
12
12
|
// no code of its consumer uses, as ESLint's `no-unused-vars` refuses a name nothing uses (BP
|
|
13
13
|
// 320.3.2.1: « LEVEL_TYPES » declared for 020-loader, only reported, caught by its second review).
|
|
14
|
-
// `*` stands for a namespace, default, re-export-all or side-effect import
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
14
|
+
// `*` stands for a namespace, default, re-export-all or side-effect import, and for a dynamic
|
|
15
|
+
// import not destructured; a literal dynamic import destructured gives its names, as knip reads
|
|
16
|
+
// it. A bullet of the section is a list of names, each a JavaScript identifier or `*`: a bullet of
|
|
17
|
+
// another form, with or without « : », is refused, and gives no name; a paragraph is no consumer
|
|
18
|
+
// and passes. A refusal inscribed in the project's debt
|
|
19
|
+
// (`grillhouse-dette.json`, see `dette.mjs`) passes, keyed by the provider's interface and
|
|
20
|
+
// `usage-non-declare`, `declare-non-utilise` or `ligne-mal-formee` (`homonyme` for two components
|
|
21
|
+
// of one name, keyed by the first path). The debt of a new rule is inscribed once, when a project
|
|
22
|
+
// updates to it (scripts/migrations/0.24.4-noms-declares-inutilises.mjs,
|
|
23
|
+
// scripts/migrations/0.24.6-lignes-mal-formees.mjs); in a ticket, the name leaves its line, and a
|
|
24
|
+
// line of prose is written as a list of names.
|
|
20
25
|
//
|
|
21
26
|
// npx grillhouse consommateurs run from the repository root
|
|
22
27
|
//
|
|
@@ -111,36 +116,80 @@ export function matieres(racine) {
|
|
|
111
116
|
return found;
|
|
112
117
|
}
|
|
113
118
|
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
// A name of a `## Consommateurs` line: a JavaScript identifier, or `*`.
|
|
120
|
+
const NOM = /^(?:\*|[\p{ID_Start}$_][\p{ID_Continue}$]*)$/u;
|
|
121
|
+
|
|
122
|
+
// The consumer and the names of the bullet <ligne> of a `## Consommateurs` section, trimmed, in
|
|
123
|
+
// its one form ``- `<consommateur>` : <nom>, <nom>``: `{ consommateur, noms }`; `{ consommateur:
|
|
124
|
+
// null, noms: null }` for a bullet of another form, with or without « : », or whose piece after
|
|
125
|
+
// « : » is not a name (`NOM`), a bullet of prose; null for a line that is no bullet (a paragraph).
|
|
126
|
+
// The one reading of such a line, for this guard and for scripts/consommateurs-arbitres.mjs.
|
|
127
|
+
export function lireLigne(ligne) {
|
|
128
|
+
if (!/^[-*]\s+\S/.test(ligne)) return null;
|
|
129
|
+
const m = /^[-*]\s+`?([^`:\s]+)`?\s*:\s*(.+)$/.exec(ligne);
|
|
130
|
+
const noms = m
|
|
131
|
+
? m[2]
|
|
132
|
+
.split(',')
|
|
133
|
+
.map(s => s.replace(/`/g, '').trim())
|
|
134
|
+
.filter(Boolean)
|
|
135
|
+
: [];
|
|
136
|
+
return noms.length && noms.every(n => NOM.test(n))
|
|
137
|
+
? { consommateur: m[1], noms }
|
|
138
|
+
: { consommateur: null, noms: null };
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// The bullets of the section `## Consommateurs` of an interface text, each read by `lireLigne`:
|
|
142
|
+
// [{ texte, consommateur, noms }]; a paragraph is none. The section ends at the next heading of any
|
|
143
|
+
// level: the generated part (scripts/interfaces-contre-code.mjs) opens on the heading of its first
|
|
144
|
+
// element, so its bullets are never read.
|
|
145
|
+
function lignesDeConsommateurs(texte) {
|
|
146
|
+
const out = [];
|
|
117
147
|
let dedans = false;
|
|
118
148
|
for (const l of texte.split('\n')) {
|
|
119
149
|
if (/^#{1,6} /.test(l)) {
|
|
120
150
|
dedans = /^## Consommateurs\s*$/.test(l);
|
|
121
151
|
continue;
|
|
122
152
|
}
|
|
123
|
-
const
|
|
124
|
-
if (
|
|
125
|
-
const noms = m[2]
|
|
126
|
-
.split(',')
|
|
127
|
-
.map(s => s.replace(/`/g, '').trim())
|
|
128
|
-
.filter(Boolean);
|
|
129
|
-
out.set(m[1], new Set(noms));
|
|
153
|
+
const lue = dedans ? lireLigne(l.trim()) : null;
|
|
154
|
+
if (lue) out.push({ texte: l.trim(), ...lue });
|
|
130
155
|
}
|
|
131
156
|
return out;
|
|
132
157
|
}
|
|
133
158
|
|
|
134
|
-
// The
|
|
159
|
+
// The declared consumers of an interface text: Map consumer → Set of element names. A line that
|
|
160
|
+
// is no list of names gives none.
|
|
161
|
+
export function declares(texte) {
|
|
162
|
+
return new Map(
|
|
163
|
+
lignesDeConsommateurs(texte)
|
|
164
|
+
.filter(l => l.noms)
|
|
165
|
+
.map(l => [l.consommateur, new Set(l.noms)])
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// The imports of a source text: [{ spec, noms }]. A dynamic `import` or a `require` of a literal
|
|
170
|
+
// specifier, destructured in a declaration (`const { a, b: c } = await import(…)`), gives the
|
|
171
|
+
// names it destructures, as a static import, a rest element or `default` `*`; one not
|
|
172
|
+
// destructured gives `*`,
|
|
173
|
+
// as knip reads them. A specifier computed at run time is not read.
|
|
135
174
|
export function imports(source) {
|
|
136
175
|
const out = [];
|
|
137
176
|
// A static clause holds only names, braces, commas, `*`, `as` and `type`: it never crosses a
|
|
138
177
|
// `;`, a quote, a parenthesis or an `=`, so it never runs from one statement into the next.
|
|
139
178
|
const re =
|
|
140
|
-
/^\s*(?:import|export)\s+(?:type\s+)?([^;'"()=]*?)\s*from\s*['"]([^'"]+)['"]|^\s*import\s*['"]([^'"]+)['"]|\b(?:require|import)\(\s*['"]([^'"]+)['"]\s*\)/gm;
|
|
179
|
+
/^\s*(?:import|export)\s+(?:type\s+)?([^;'"()=]*?)\s*from\s*['"]([^'"]+)['"]|^\s*import\s*['"]([^'"]+)['"]|\b(?:const|let|var)\s*\{([^{}]*)\}\s*=\s*(?:await\s+)?(?:require|import)\(\s*['"]([^'"]+)['"]\s*\)|\b(?:require|import)\(\s*['"]([^'"]+)['"]\s*\)/gm;
|
|
141
180
|
for (const m of source.matchAll(re)) {
|
|
142
|
-
if (m[
|
|
143
|
-
|
|
181
|
+
if (m[5]) {
|
|
182
|
+
const noms = m[4]
|
|
183
|
+
.split(',')
|
|
184
|
+
.map(p => p.trim())
|
|
185
|
+
.filter(Boolean)
|
|
186
|
+
.map(p => (p.startsWith('...') ? '*' : p.split(/[:=]/)[0].trim()))
|
|
187
|
+
.map(n => (n === 'default' ? '*' : n));
|
|
188
|
+
out.push({ spec: m[5], noms });
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
if (m[3] || m[6]) {
|
|
192
|
+
out.push({ spec: m[3] ?? m[6], noms: ['*'] });
|
|
144
193
|
continue;
|
|
145
194
|
}
|
|
146
195
|
const clause = m[1];
|
|
@@ -252,6 +301,10 @@ export function utilise(racine, tous = composants(racine)) {
|
|
|
252
301
|
// and the name, which the migration of 0.24.4 reports line by line.
|
|
253
302
|
export const DECLARE_NON_UTILISE = 'declare-non-utilise';
|
|
254
303
|
|
|
304
|
+
// The rule of a bullet of a `## Consommateurs` section that is no list of names; its finding
|
|
305
|
+
// names the line (`texte`), which the migration of 0.24.6 reports.
|
|
306
|
+
export const LIGNE_MAL_FORMEE = 'ligne-mal-formee';
|
|
307
|
+
|
|
255
308
|
// The refusals of the components that share a name: one finding per name, both paths.
|
|
256
309
|
function homonymes(racine) {
|
|
257
310
|
const parNom = new Map();
|
|
@@ -268,9 +321,10 @@ function homonymes(racine) {
|
|
|
268
321
|
}
|
|
269
322
|
|
|
270
323
|
// The refusals, as findings `{ fichier, regle, message }` the debt (`dette.mjs`) judges: the uses
|
|
271
|
-
// no interface declares (`usage-non-declare`),
|
|
272
|
-
//
|
|
273
|
-
//
|
|
324
|
+
// no interface declares (`usage-non-declare`), the declared names no code of their consumer uses
|
|
325
|
+
// (`declare-non-utilise`), and the lines of a section `## Consommateurs` that are no list of names
|
|
326
|
+
// (`ligne-mal-formee`), which give no name. A declared consumer out of the frame is passed over:
|
|
327
|
+
// its code is not read.
|
|
274
328
|
export function verifier(racine) {
|
|
275
329
|
const tous = composants(racine);
|
|
276
330
|
const hors = horsCadre(racine);
|
|
@@ -279,7 +333,16 @@ export function verifier(racine) {
|
|
|
279
333
|
for (const p of tous) {
|
|
280
334
|
const iface = path.join(p.dir, 'docs', 'INTERFACE.md');
|
|
281
335
|
const rel = path.relative(racine, iface);
|
|
282
|
-
const
|
|
336
|
+
const contenu = existsSync(iface) ? readFileSync(iface, 'utf8') : '';
|
|
337
|
+
const declare = declares(contenu);
|
|
338
|
+
for (const { texte } of lignesDeConsommateurs(contenu).filter(l => !l.noms)) {
|
|
339
|
+
refus.push({
|
|
340
|
+
fichier: rel,
|
|
341
|
+
regle: LIGNE_MAL_FORMEE,
|
|
342
|
+
texte,
|
|
343
|
+
message: `${rel} § Consommateurs : la ligne « ${texte} » n'est pas une liste de noms ; écrire la ligne en liste de noms : - \`consommateur\` : nom, nom.`,
|
|
344
|
+
});
|
|
345
|
+
}
|
|
283
346
|
const utilises = reel.get(p.nom) ?? new Map();
|
|
284
347
|
for (const [consommateur, noms] of utilises) {
|
|
285
348
|
const permis = declare.get(consommateur) ?? new Set();
|
|
@@ -316,7 +379,7 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
|
316
379
|
const { refus, lignes } = trancher(racine, 'consommateurs', verdict.refus);
|
|
317
380
|
for (const r of refus) process.stderr.write(`⛔ ${r.message}\n`);
|
|
318
381
|
for (const l of lignes) process.stderr.write(`${l}\n`);
|
|
319
|
-
if (refus.some(r => r.regle !== DECLARE_NON_UTILISE)) {
|
|
382
|
+
if (refus.some(r => r.regle !== DECLARE_NON_UTILISE && r.regle !== LIGNE_MAL_FORMEE)) {
|
|
320
383
|
process.stderr.write(
|
|
321
384
|
"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"
|
|
322
385
|
);
|
package/scripts/dernier-vert.mjs
CHANGED
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
// the repository. Then the changes are the files that differ between its tree and the tree of the
|
|
19
19
|
// working tree now (`git diff --raw --no-renames`): the files changed or added, and those
|
|
20
20
|
// removed. Any two trees compare: the ancestry keeps the measure to the history it belongs to.
|
|
21
|
+
// - A file the last green holds and its commit does not track (untracked, not ignored) lives in
|
|
22
|
+
// the working tree that kept it alone: measured against the last green of another branch (main's,
|
|
23
|
+
// from a copy or from the queue's detached replay), its absence is no removal, as Nx affected and
|
|
24
|
+
// Turborepo's `--filter=[ref]` measure against a commit. Against the branch's own, it is one: the
|
|
25
|
+
// copy created that file, then removed it. Witness: BPScript 320.3.2.1, 54 `.rapport-suite.json`
|
|
26
|
+
// untracked on main, each seen removed by every package of a copy, which played whole 264 times.
|
|
21
27
|
// - No last green counts without git, before the first commit, and while a submodule differs
|
|
22
28
|
// from the commit its parent records (its files changed, or its HEAD moved) or the changes
|
|
23
29
|
// reach a submodule: git's tree holds a submodule's commit, not its files. The pass is then
|
|
@@ -169,6 +175,21 @@ function difference(racine, avant, apres) {
|
|
|
169
175
|
return out;
|
|
170
176
|
}
|
|
171
177
|
|
|
178
|
+
// The files the commit <commit> of the repository at <racine> tracks that the tree <arbre> no longer
|
|
179
|
+
// holds, as a Set of paths from its top; null when git fails.
|
|
180
|
+
function supprimesDuCommit(racine, commit, arbre) {
|
|
181
|
+
const r = git(racine, [
|
|
182
|
+
'diff',
|
|
183
|
+
'--name-only',
|
|
184
|
+
'--no-renames',
|
|
185
|
+
'--diff-filter=D',
|
|
186
|
+
'-z',
|
|
187
|
+
commit,
|
|
188
|
+
arbre,
|
|
189
|
+
]);
|
|
190
|
+
return r.status === 0 ? new Set(r.stdout.split('\0').filter(Boolean)) : null;
|
|
191
|
+
}
|
|
192
|
+
|
|
172
193
|
// What a pass in <racine> measures itself against: `{ etat, env, ligne, retirer }`, the state to
|
|
173
194
|
// keep once green (null when none can count), the variables to add to the pass's environment (the
|
|
174
195
|
// changes since the last green, none for a complete pass), the line that says which, and the
|
|
@@ -192,6 +213,11 @@ export function mesure(racine, { tout = false, dans = os.tmpdir() } = {}) {
|
|
|
192
213
|
if (ch.sousModules.length) {
|
|
193
214
|
return { ...complete(`un sous-module a changé (${ch.sousModules[0]})`), etat: null };
|
|
194
215
|
}
|
|
216
|
+
if (vert.branche !== etat.branche) {
|
|
217
|
+
const suivis = supprimesDuCommit(etat.racine, vert.commit, etat.arbre);
|
|
218
|
+
if (!suivis) return complete('git échoue');
|
|
219
|
+
ch.supprimes = ch.supprimes.filter(f => suivis.has(f));
|
|
220
|
+
}
|
|
195
221
|
const dir = mkdtempSync(path.join(dans, 'grillhouse-changements-'));
|
|
196
222
|
const fichier = path.join(dir, 'changements.json');
|
|
197
223
|
writeFileSync(
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// From 0.24.6 the guard of the consumers refuses a bullet of a `## Consommateurs` section that is
|
|
2
|
+
// no list of names (`ligne-mal-formee`, scripts/consommateurs.mjs): one form only,
|
|
3
|
+
// ``- `consommateur` : nom, nom``, each name a JavaScript identifier or `*`. Before, the text after
|
|
4
|
+
// « : » was cut at its commas, and a bullet of prose gave « names » that are none, or was passed
|
|
5
|
+
// over without « : » (BPScript 990-corpus/docs/INTERFACE.md:274-289, at 0.24.5). A project that updates may hold such lines, and its
|
|
6
|
+
// main would turn red at its next pass without a word. As the update of 0.24.4 names its unused
|
|
7
|
+
// names, the update names these lines, and the command that inscribes them as the project's known
|
|
8
|
+
// debt, once, at the passage of the rule (dette.mjs, as ESLint's `--suppress-all`); in a ticket
|
|
9
|
+
// afterwards, the guard says to write the line as a list of names.
|
|
10
|
+
//
|
|
11
|
+
// - The migration changes no file (`migrer` returns no line): the project decides between the
|
|
12
|
+
// debt and the edit of its interfaces.
|
|
13
|
+
// - What stays to the project (`restes`): one line per bullet of prose of a `## Consommateurs`
|
|
14
|
+
// section, beyond what `grillhouse-dette.json` already inscribes (`juger` of dette.mjs), its
|
|
15
|
+
// interface and the bullet; then the line of the command,
|
|
16
|
+
// `npm run grillhouse:dette:inscrire`. Nothing once the debt holds them, or once each line is a
|
|
17
|
+
// list of names.
|
|
18
|
+
import { juger, lire } from '../dette.mjs';
|
|
19
|
+
import { LIGNE_MAL_FORMEE, verifier } from '../consommateurs.mjs';
|
|
20
|
+
|
|
21
|
+
export const version = '0.24.6';
|
|
22
|
+
export const nom = 'lignes de consommateurs mal formées';
|
|
23
|
+
|
|
24
|
+
/** The lines of prose the new rule refuses in the project at <projet>, and the command. */
|
|
25
|
+
export function restes(projet) {
|
|
26
|
+
const constats = verifier(projet).refus.filter(r => r.regle === LIGNE_MAL_FORMEE);
|
|
27
|
+
const { refus } = juger(lire(projet), 'consommateurs', constats);
|
|
28
|
+
if (refus.length === 0) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
return [
|
|
32
|
+
...refus.map(r => `${r.fichier} § Consommateurs : « ${r.texte} » n'est pas une liste de noms`),
|
|
33
|
+
`la garde des consommateurs refuse désormais ces lignes (${refus.length} en tout) : \`npm run grillhouse:dette:inscrire\` les inscrit dans grillhouse-dette.json, la dette connue du projet, ou chaque ligne s’écrit en liste de noms (- \`consommateur\` : nom, nom)`,
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Changes nothing: the lines are reported by `restes`. */
|
|
38
|
+
export function migrer() {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
package/scripts/migrations.mjs
CHANGED
|
@@ -27,6 +27,7 @@ import * as copiesDuCadre from './migrations/0.23.2-copies-du-cadre.mjs';
|
|
|
27
27
|
import * as circuitSimplifie from './migrations/0.24.0-circuit-simplifie.mjs';
|
|
28
28
|
import * as apiExtractorDuPaquet from './migrations/0.24.2-api-extractor-du-paquet.mjs';
|
|
29
29
|
import * as nomsDeclaresInutilises from './migrations/0.24.4-noms-declares-inutilises.mjs';
|
|
30
|
+
import * as lignesMalFormees from './migrations/0.24.6-lignes-mal-formees.mjs';
|
|
30
31
|
|
|
31
32
|
/** The migrations of the package. */
|
|
32
33
|
export const MIGRATIONS = [
|
|
@@ -38,6 +39,7 @@ export const MIGRATIONS = [
|
|
|
38
39
|
circuitSimplifie,
|
|
39
40
|
apiExtractorDuPaquet,
|
|
40
41
|
nomsDeclaresInutilises,
|
|
42
|
+
lignesMalFormees,
|
|
41
43
|
];
|
|
42
44
|
|
|
43
45
|
/**
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
// - The graph of a test is the test file and the modules it imports, statically or dynamically,
|
|
17
17
|
// node_modules left out (`getTestDependencies` of Vitest). Vitest does not see what lies out of
|
|
18
18
|
// it, and the package plays whole (`entier`) when a change lies there, the reason written:
|
|
19
|
-
// 1. a file removed
|
|
19
|
+
// 1. a file removed in the package: no graph of today holds it (one removed in a package it
|
|
20
|
+
// depends on, as 6 has it);
|
|
20
21
|
// 2. the frame's base configuration (this directory), which every configuration extends;
|
|
21
22
|
// 3. the configuration of the repository at its top: `package.json`, `package-lock.json`,
|
|
22
23
|
// `turbo.json`, `turbo.jsonc`, `tsconfig*.json`;
|
|
@@ -25,10 +26,18 @@
|
|
|
25
26
|
// `globalSetup`, which Vitest runs beside the graph;
|
|
26
27
|
// 5. a path its tests declare they read (`grillhouse.lit` of its package.json, from the top):
|
|
27
28
|
// a script they run, a file they read, as Bazel's `data`;
|
|
28
|
-
// 6. a file of a package it depends on (its
|
|
29
|
-
// `optionalDependencies` and `peerDependencies` that
|
|
30
|
-
//
|
|
31
|
-
// package built, not the source git follows
|
|
29
|
+
// 6. a file, changed or removed, that the build of a package it depends on reads (its
|
|
30
|
+
// `dependencies`, `devDependencies`, `optionalDependencies` and `peerDependencies` that
|
|
31
|
+
// resolve to a directory of the repository, out of node_modules, transitively): its tests read
|
|
32
|
+
// that package built, not the source git follows. As Turborepo hashes the inputs of a
|
|
33
|
+
// neighbour's `build` task and Bazel the `srcs` of its target, the build reads the inputs of
|
|
34
|
+
// the `build` of the neighbour's turbo.json, the one scripts/turbo-des-paquets.mjs generates,
|
|
35
|
+
// as Turborepo reads them: each pattern from the package, `$TURBO_ROOT$/…` from the top, `!…`
|
|
36
|
+
// an exclusion, `<x>/**` covering `<x>` itself, `$TURBO_DEFAULT$` every file of the package,
|
|
37
|
+
// `$TURBO_EXTENDS$` the inputs of the root's `build` (turbo.json or turbo.jsonc). When they
|
|
38
|
+
// name none (no turbo.json, no inputs), its files of code and configuration (the extension of
|
|
39
|
+
// a module), out of its `docs/`, its exclusions kept. A test file of the neighbour is never
|
|
40
|
+
// one: its build does not compile it;
|
|
32
41
|
// 7. a file of the package that no graph can hold, its extension not that of a module (`.js`,
|
|
33
42
|
// `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`, `.jsx`, `.tsx`, `.json`): data, a template, a
|
|
34
43
|
// script of the shell, a document, which a test reads without importing it.
|
|
@@ -39,8 +48,10 @@
|
|
|
39
48
|
// plays, changed or not. A package where none relates plays none and passes
|
|
40
49
|
// (`passWithNoTests`), as Vitest's `--changed` has it.
|
|
41
50
|
//
|
|
42
|
-
// This module uses Node alone.
|
|
51
|
+
// This module's top level uses Node alone (./cibles.mjs, scripts/tests.mjs import it); a
|
|
52
|
+
// turbo.json is read with jsonc-parser, the frame's reader of JSON with comments, loaded then.
|
|
43
53
|
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
54
|
+
import { createRequire } from 'node:module';
|
|
44
55
|
import path from 'node:path';
|
|
45
56
|
import { fileURLToPath } from 'node:url';
|
|
46
57
|
|
|
@@ -79,6 +90,46 @@ export function lireChangements(chemin) {
|
|
|
79
90
|
return c;
|
|
80
91
|
}
|
|
81
92
|
|
|
93
|
+
// The prefix of a pattern of Turborepo written from the top of the repository.
|
|
94
|
+
const DU_HAUT = '$TURBO_ROOT$/';
|
|
95
|
+
|
|
96
|
+
// The inputs of the `build` of the Turborepo configuration in <dir> (its <noms>, the first
|
|
97
|
+
// present): the patterns, an empty list when it names none or does not read.
|
|
98
|
+
function entreesDuBuild(dir, noms) {
|
|
99
|
+
const f = noms.map(n => path.join(dir, n)).find(n => existsSync(n));
|
|
100
|
+
if (!f) return [];
|
|
101
|
+
try {
|
|
102
|
+
const { parse } = createRequire(import.meta.url)('jsonc-parser');
|
|
103
|
+
const inputs = parse(readFileSync(f, 'utf8'), [], { allowTrailingComma: true })?.tasks?.build
|
|
104
|
+
?.inputs;
|
|
105
|
+
return Array.isArray(inputs) ? inputs.filter(m => typeof m === 'string') : [];
|
|
106
|
+
} catch {
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Whether the build of the package at <d>, in the repository at <racine>, reads the file at the
|
|
112
|
+
// absolute path <a>, which lies in it (6 above).
|
|
113
|
+
function construit(racine, d, a) {
|
|
114
|
+
const r = path.relative(d, a);
|
|
115
|
+
if (TEST.test(r)) return false;
|
|
116
|
+
const motifs = entreesDuBuild(d, ['turbo.json']).flatMap(m =>
|
|
117
|
+
m === '$TURBO_EXTENDS$' ? entreesDuBuild(racine, ['turbo.json', 'turbo.jsonc']) : [m]
|
|
118
|
+
);
|
|
119
|
+
// <m> covers <rel>, `<x>/**` covering `<x>` as Turborepo has it.
|
|
120
|
+
const couvre = (rel, m) =>
|
|
121
|
+
path.matchesGlob(rel, m) || (m.endsWith('/**') && path.matchesGlob(rel, m.slice(0, -3)));
|
|
122
|
+
const lu = m =>
|
|
123
|
+
m === '$TURBO_DEFAULT$' ||
|
|
124
|
+
(m.startsWith(DU_HAUT)
|
|
125
|
+
? couvre(path.relative(racine, a), m.slice(DU_HAUT.length))
|
|
126
|
+
: couvre(r, m));
|
|
127
|
+
if (motifs.some(m => m.startsWith('!') && lu(m.slice(1)))) return false;
|
|
128
|
+
const positifs = motifs.filter(m => !m.startsWith('!'));
|
|
129
|
+
if (positifs.length) return positifs.some(lu);
|
|
130
|
+
return MODULE.test(r) && r.split(path.sep)[0] !== 'docs';
|
|
131
|
+
}
|
|
132
|
+
|
|
82
133
|
// The directories of the packages of the repository at <racine> that the package at <dossier>
|
|
83
134
|
// depends on, transitively, itself left out.
|
|
84
135
|
function dependances(racine, dossier) {
|
|
@@ -129,7 +180,8 @@ function paquetEntier(ch, dossier, test = {}) {
|
|
|
129
180
|
.filter(f => typeof f === 'string')
|
|
130
181
|
.map(f => path.resolve(dossier, f));
|
|
131
182
|
for (const f of ch.supprimes) {
|
|
132
|
-
|
|
183
|
+
const a = abs(f);
|
|
184
|
+
if (sous(a, dossier) || deps.some(d => sous(a, d) && construit(racine, d, a))) {
|
|
133
185
|
return { raison: 'un fichier supprimé, que le graphe des tests ne tient plus', fichier: f };
|
|
134
186
|
}
|
|
135
187
|
}
|
|
@@ -145,7 +197,7 @@ function paquetEntier(ch, dossier, test = {}) {
|
|
|
145
197
|
? 'un fichier de préparation des tests'
|
|
146
198
|
: lit.some(l => f === l || f.startsWith(`${l}/`))
|
|
147
199
|
? 'un chemin que ses tests déclarent lire (grillhouse.lit)'
|
|
148
|
-
: deps.some(d => sous(a, d)
|
|
200
|
+
: deps.some(d => sous(a, d) && construit(racine, d, a))
|
|
149
201
|
? 'le code d’un paquet dont il dépend, que ses tests lisent construit'
|
|
150
202
|
: sous(a, dossier) && !MODULE.test(f)
|
|
151
203
|
? 'un fichier qu’aucun module n’importe, qu’un test lit sans l’importer'
|
|
@@ -50,8 +50,12 @@ voisin dit vrai.
|
|
|
50
50
|
composant produit.
|
|
51
51
|
**Les consommateurs sont déclarés** : une section `## Consommateurs` liste chaque composant qui
|
|
52
52
|
utilise l'interface, avec les éléments qu'il importe (``- `parser` : jeton, position``, `*` pour
|
|
53
|
-
un import entier)
|
|
54
|
-
un
|
|
53
|
+
un import entier) ; chaque puce de la section, hors partie générée, a cette seule forme, chaque
|
|
54
|
+
nom un identifiant JavaScript ou `*`, jamais une phrase ; un paragraphe hors puce (« Aucun paquet
|
|
55
|
+
de la v2. ») n'est pas un consommateur. Le garde `packages/grillhouse/scripts/consommateurs.mjs` refuse un import qu'elle ne déclare pas,
|
|
56
|
+
un nom déclaré qu'aucun code du consommateur n'emploie, et une puce d'une autre forme, avec ou
|
|
57
|
+
sans « : » ; il lit les noms d'un `import('x')` littéral déstructuré comme ceux d'un import statique, et
|
|
58
|
+
ne lit pas un chargeur dont le paquet se calcule : le consommateur écrit `import('x')` en clair. Une ligne nouvelle entre avec son arbitrage
|
|
55
59
|
tranché au ticket, qui nomme le consommateur, ou avec le plan du ticket (son titre, sa section
|
|
56
60
|
« Architecture », sa section « Noms publiés »), qui nomme mot pour mot le consommateur et chaque élément que le lot ajoute à la
|
|
57
61
|
ligne, et le garde `packages/grillhouse/scripts/consommateurs-arbitres.mjs` refuse une ligne
|