@roomi-fields/grillhouse 0.24.5 → 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/package.json +1 -1
- package/scripts/consommateurs-arbitres.mjs +6 -15
- package/scripts/consommateurs.mjs +88 -25
- package/scripts/migrations/0.24.6-lignes-mal-formees.mjs +40 -0
- package/scripts/migrations.mjs +2 -0
- package/skills/redacteur/references/documents-d-un-composant.md +6 -2
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
|
);
|
|
@@ -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
|
/**
|
|
@@ -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
|