@roomi-fields/grillhouse 0.26.0 → 0.27.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/cadre/templates/projet/CLAUDE.md +7 -0
- package/cadre/templates/projet/docs/ARCHITECTURE.md +15 -0
- package/cadre/templates/python/package.json +18 -0
- package/charte.md +22 -0
- package/docs/ARCHITECTURE.md +58 -17
- package/docs/CADRE.md +7 -6
- package/docs/INTERFACE.md +96 -32
- package/package.json +1 -1
- package/scripts/circuit.mjs +44 -8
- package/scripts/commande-du-langage.mjs +2 -2
- package/scripts/commandes-composees.mjs +156 -0
- package/scripts/composition-des-langages.mjs +306 -0
- package/scripts/conformite.mjs +1 -3
- package/scripts/dernier-vert.mjs +15 -2
- package/scripts/engendres.mjs +170 -0
- package/scripts/enveloppe/travail-de-la-copie.mjs +82 -8
- package/scripts/gardes-du-cadre.mjs +7 -4
- package/scripts/grillhouse-maj.mjs +152 -99
- package/scripts/index-interfaces.mjs +78 -0
- package/scripts/init.mjs +5 -5
- package/scripts/integration/file.mjs +74 -13
- package/scripts/integration/integrer.mjs +50 -62
- package/scripts/jointure.d.ts +26 -13
- package/scripts/langages/cargo/binaires.mjs +29 -6
- package/scripts/langages/cargo/clippy.mjs +4 -2
- package/scripts/langages/cargo/commandes.mjs +45 -7
- package/scripts/langages/cargo/exemples.mjs +1 -15
- package/scripts/langages/cargo/index-interfaces.mjs +20 -3
- package/scripts/langages/cargo/index.mjs +9 -10
- package/scripts/langages/cargo/mise-a-jour.mjs +2 -1
- package/scripts/langages/cargo/sccache.mjs +29 -0
- package/scripts/langages/python/binaires.json +3 -0
- package/scripts/langages/python/binaires.mjs +59 -0
- package/scripts/langages/python/commandes.mjs +411 -0
- package/scripts/langages/python/composants.mjs +272 -0
- package/scripts/langages/python/exemples.mjs +260 -0
- package/scripts/langages/python/index-interfaces.mjs +77 -0
- package/scripts/langages/python/index.mjs +94 -0
- package/scripts/langages/python/lot.mjs +76 -0
- package/scripts/langages/python/mise-a-jour.mjs +54 -0
- package/scripts/langages/python/tailles-des-tests.mjs +102 -0
- package/scripts/langages/python/verdict.mjs +85 -0
- package/scripts/langages/typescript/exemples.mjs +1 -20
- package/scripts/langages/typescript/index-interfaces.mjs +10 -3
- package/scripts/langages/typescript/index.mjs +11 -15
- package/scripts/langages-des-paquets.mjs +171 -0
- package/scripts/langages.mjs +60 -41
- package/scripts/migrations/0.27.0-langages-dans-l-architecture.mjs +182 -0
- package/scripts/migrations.mjs +2 -0
- package/scripts/outils-cles.mjs +1 -1
- package/scripts/session-start.sh +34 -9
- package/scripts/sources.mjs +2 -1
- package/scripts/sous-commandes.mjs +5 -3
- package/scripts/tableau-des-composants.mjs +138 -0
- package/scripts/verrous/verrou.mjs +3 -2
- package/skills/grill/SKILL.md +9 -1
- package/skills/pitmaster/SKILL.md +6 -1
- package/skills/redacteur/references/documents-d-un-composant.md +12 -0
- package/skills/testwriter/SKILL.md +6 -0
|
@@ -66,16 +66,18 @@
|
|
|
66
66
|
// test scripts. What the share leaves to the project (`aFaire`: for cargo, a Cargo.lock that git
|
|
67
67
|
// does not track) is written on the error stream, the exit code 1, and the verification is not
|
|
68
68
|
// played.
|
|
69
|
-
// -
|
|
70
|
-
//
|
|
71
|
-
// (
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
// migrations of the declared
|
|
78
|
-
//
|
|
69
|
+
// - A project of several languages (scripts/langages.mjs, `langagesDe`) receives the share of each,
|
|
70
|
+
// in the order of the declaration: its template's tools, its share of the update, its binaries,
|
|
71
|
+
// its generators (each once) and what its tools write; the frame's scripts of a template come
|
|
72
|
+
// from the first template that has each.
|
|
73
|
+
// - The languages first (`declarerLesLangages`): the languages of the project are the column
|
|
74
|
+
// « Langage » of the table of the components of its docs/ARCHITECTURE.md (scripts/langages.mjs),
|
|
75
|
+
// written at its design; the update writes there the declaration of a former version of the
|
|
76
|
+
// frame (the migration of 0.27.0, ./migrations/0.27.0-langages-dans-l-architecture.mjs), played
|
|
77
|
+
// before every other, since the migrations of the declared languages play with the core's. A
|
|
78
|
+
// directory without package.json, a project that declares no language, or one whose former
|
|
79
|
+
// declaration the migration leaves to it, is refused, named on the error stream, the exit code
|
|
80
|
+
// 1: the frame guesses no language from the files. No import of the project is rewritten.
|
|
79
81
|
// - The tools of the declared language (the `outils` of its module: what it runs as commands and
|
|
80
82
|
// what its scripts import), and none other, are added to the project's `devDependencies` at the
|
|
81
83
|
// version the template's `devDependencies` give; a tool the project already declares in
|
|
@@ -90,7 +92,8 @@
|
|
|
90
92
|
// cargo-deny), after the files: the command line runs the commands of its module
|
|
91
93
|
// (`miseAJour.installation`), which list what is installed and install each one missing or at
|
|
92
94
|
// another version (cargo's: `cargo install --list`, then `cargo binstall --no-confirm --locked
|
|
93
|
-
// <nom>@<version
|
|
95
|
+
// <nom>@<version>`, cargo-binstall installed by cargo first when it lacks), as `npm install`
|
|
96
|
+
// brings what is installed to what is declared; the report
|
|
94
97
|
// names each one installed. One that cannot be installed has its line, the error stream of its
|
|
95
98
|
// command naming the command to type, and the exit code is non-zero. A language without
|
|
96
99
|
// binaries runs nothing.
|
|
@@ -116,7 +119,10 @@
|
|
|
116
119
|
// without file in a repository with `workspaces`, so that the frame's checks accept them; a
|
|
117
120
|
// generator that fails, or a project without its command, has its line, which says to run it
|
|
118
121
|
// after `npm install` (the frame's package and tools), and the exit code is non-zero.
|
|
119
|
-
// - The report names the version of the frame,
|
|
122
|
+
// - The report names first the version of the frame, the package's, and the command that installs
|
|
123
|
+
// another before the update (`LIGNE_DU_CADRE`): npm reads a range `^0.25.5` as `>=0.25.5
|
|
124
|
+
// <0.26.0` (node-semver, caret ranges), so `npm install` never brings the next minor of a 0.x
|
|
125
|
+
// (grillhouse-qmk, OSC Bridge at 0.25.5 under ^0.25.5).
|
|
120
126
|
// - Last, the update plays the project's verification, `npm run verifier`, from its root, its
|
|
121
127
|
// output shown, as Nx affected moves its base to the last green commit of main: its green keeps
|
|
122
128
|
// the last green (scripts/dernier-vert.mjs), HEAD and the tree of the working tree, the update's
|
|
@@ -139,7 +145,8 @@ import { poserCrochets } from './crochets.mjs';
|
|
|
139
145
|
import { ATTRIBUT } from './fusion-du-changelog.mjs';
|
|
140
146
|
import { installerGreffons } from './greffons.mjs';
|
|
141
147
|
import { migrer, restesAuProjet } from './migrations.mjs';
|
|
142
|
-
import {
|
|
148
|
+
import { langageDe, langagesDe } from './langages.mjs';
|
|
149
|
+
import * as langagesDansLArchitecture from './migrations/0.27.0-langages-dans-l-architecture.mjs';
|
|
143
150
|
|
|
144
151
|
const SCRIPTS = {
|
|
145
152
|
tableau: 'grillhouse tableau --texte',
|
|
@@ -216,13 +223,19 @@ const trie = deps =>
|
|
|
216
223
|
// they changed.
|
|
217
224
|
function reglerLigneEtat(projet) {
|
|
218
225
|
const f = path.join(projet, '.claude', 'settings.json');
|
|
219
|
-
if (!existsSync(f)) {
|
|
226
|
+
if (!existsSync(f)) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
220
229
|
const reglages = JSON.parse(readFileSync(f, 'utf8'));
|
|
221
230
|
const actuelle = reglages.statusLine;
|
|
222
231
|
const commande = typeof actuelle?.command === 'string' ? actuelle.command : '';
|
|
223
|
-
if (actuelle !== undefined && !commande.includes('ligne-etat')) {
|
|
232
|
+
if (actuelle !== undefined && !commande.includes('ligne-etat')) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
224
235
|
const voulue = { type: 'command', command: LIGNE_ETAT };
|
|
225
|
-
if (JSON.stringify(actuelle) === JSON.stringify(voulue)) {
|
|
236
|
+
if (JSON.stringify(actuelle) === JSON.stringify(voulue)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
226
239
|
reglages.statusLine = voulue;
|
|
227
240
|
writeFileSync(f, `${JSON.stringify(reglages, null, 2)}\n`);
|
|
228
241
|
return true;
|
|
@@ -237,7 +250,9 @@ export const GREFFON_DU_CADRE = `grillhouse@${MARCHE_DU_CADRE}`;
|
|
|
237
250
|
// and enables the frame's plugin (see the header); returns whether they changed.
|
|
238
251
|
function declarerGreffon(projet) {
|
|
239
252
|
const f = path.join(projet, '.claude', 'settings.json');
|
|
240
|
-
if (!existsSync(f)) {
|
|
253
|
+
if (!existsSync(f)) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
241
256
|
const avant = readFileSync(f, 'utf8');
|
|
242
257
|
const reglages = JSON.parse(avant);
|
|
243
258
|
reglages.extraKnownMarketplaces = {
|
|
@@ -245,40 +260,39 @@ function declarerGreffon(projet) {
|
|
|
245
260
|
[MARCHE_DU_CADRE]: { source: SOURCE_DU_MARCHE },
|
|
246
261
|
};
|
|
247
262
|
reglages.enabledPlugins = { ...(reglages.enabledPlugins ?? {}), [GREFFON_DU_CADRE]: true };
|
|
248
|
-
if (JSON.stringify(reglages) === JSON.stringify(JSON.parse(avant))) {
|
|
263
|
+
if (JSON.stringify(reglages) === JSON.stringify(JSON.parse(avant))) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
249
266
|
writeFileSync(f, `${JSON.stringify(reglages, null, 2)}\n`);
|
|
250
267
|
return true;
|
|
251
268
|
}
|
|
252
269
|
|
|
253
270
|
/**
|
|
254
|
-
* Declares the languages of the project at <projet>
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
271
|
+
* Declares the languages of the project at <projet> in its architecture: plays the migration of
|
|
272
|
+
* 0.27.0, which writes there the declaration of a former version of the frame, then reads them
|
|
273
|
+
* (`langagesDe`). Returns what the migration did, `{ version, nom, lignes, aFaire }`, null when it
|
|
274
|
+
* did nothing. Throws, named, when the project has no package.json, when the migration leaves its
|
|
275
|
+
* declaration to it, or when it declares no language: the update guesses none.
|
|
259
276
|
*/
|
|
260
|
-
export function
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
throw new Error(
|
|
264
|
-
`${projet} n'a pas de package.json, où un projet déclare ses langages (grillhouse.langages) ; la mise à jour du cadre s'y joue.`
|
|
265
|
-
);
|
|
277
|
+
export function declarerLesLangages(projet) {
|
|
278
|
+
if (!existsSync(path.join(projet, 'package.json'))) {
|
|
279
|
+
throw new Error(`${projet} n'a pas de package.json ; la mise à jour du cadre s'y joue.`);
|
|
266
280
|
}
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const signes = Object.keys(LANGAGES)
|
|
272
|
-
.map(n => `${n} : ${langage(n).signe}`)
|
|
273
|
-
.join(' ; ');
|
|
274
|
-
throw new Error(
|
|
275
|
-
`aucun langage du cadre trouvé dans ${projet} (${signes}) ; déclare-le dans grillhouse.langages de ${fichier} (les langages du cadre : ${Object.keys(LANGAGES).join(', ')}), puis relance \`npx grillhouse maj\`.`
|
|
276
|
-
);
|
|
281
|
+
const tout = langagesDansLArchitecture.migrer(projet);
|
|
282
|
+
const aFaire = tout.filter(l => typeof l !== 'string').map(l => l.aFaire);
|
|
283
|
+
if (aFaire.length) {
|
|
284
|
+
throw new Error(aFaire.join(' ; '));
|
|
277
285
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
286
|
+
langagesDe(projet);
|
|
287
|
+
const lignes = tout.filter(l => typeof l === 'string');
|
|
288
|
+
return lignes.length
|
|
289
|
+
? {
|
|
290
|
+
version: langagesDansLArchitecture.version,
|
|
291
|
+
nom: langagesDansLArchitecture.nom,
|
|
292
|
+
lignes,
|
|
293
|
+
aFaire,
|
|
294
|
+
}
|
|
295
|
+
: null;
|
|
282
296
|
}
|
|
283
297
|
|
|
284
298
|
/** The version of the frame the project at <projet> recorded (`grillhouse.version`), or null. */
|
|
@@ -294,7 +308,6 @@ export function versionDuProjet(projet) {
|
|
|
294
308
|
*/
|
|
295
309
|
export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
|
|
296
310
|
const bilan = {
|
|
297
|
-
langages: null,
|
|
298
311
|
dependances: [],
|
|
299
312
|
gardes: null,
|
|
300
313
|
ligneEtat: false,
|
|
@@ -303,41 +316,58 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
|
|
|
303
316
|
};
|
|
304
317
|
const pkg = path.join(projet, 'package.json');
|
|
305
318
|
if (existsSync(pkg)) {
|
|
306
|
-
|
|
307
|
-
const langage = langageDe(projet);
|
|
319
|
+
const modules = langagesDe(projet);
|
|
308
320
|
const p = lireJson(pkg, {});
|
|
309
|
-
if (inscrite !== null) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
321
|
+
if (inscrite !== null) {
|
|
322
|
+
p.grillhouse = { ...(p.grillhouse ?? {}), version: inscrite };
|
|
323
|
+
}
|
|
324
|
+
// The template of each declared language, where the frame's scripts and tools are read; the
|
|
325
|
+
// frame's scripts from the first that has each.
|
|
326
|
+
const gabarits = modules.map(m => ({
|
|
327
|
+
module: m,
|
|
328
|
+
pkgSource: lireJson(path.join(source, m.miseAJour.gabarit, 'package.json'), {}),
|
|
329
|
+
}));
|
|
330
|
+
const duGabarit = lire => gabarits.map(g => lire(g.pkgSource)).find(v => v !== undefined);
|
|
331
|
+
const gardes = duGabarit(g => g.scripts?.['grillhouse:gardes']);
|
|
313
332
|
p.scripts = { ...(p.scripts ?? {}), ...SCRIPTS };
|
|
314
333
|
// The project's `prepare`, which npm runs at its install, places the frame's git hooks first.
|
|
315
334
|
const prepare = typeof p.scripts.prepare === 'string' ? p.scripts.prepare.trim() : '';
|
|
316
335
|
if (!prepare.split(/\s*&&\s*/).includes(PREPARE)) {
|
|
317
336
|
p.scripts.prepare = prepare === '' ? PREPARE : `${PREPARE} && ${prepare}`;
|
|
318
337
|
}
|
|
319
|
-
|
|
320
|
-
|
|
338
|
+
const api = duGabarit(g => (typeof g.scripts?.api === 'string' ? g.scripts.api : undefined));
|
|
339
|
+
if (api !== undefined) {
|
|
340
|
+
p.scripts.api = api;
|
|
321
341
|
}
|
|
322
|
-
// The tools of the declared
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
342
|
+
// The tools of the declared languages alone (each module's `outils`), at its template's
|
|
343
|
+
// versions.
|
|
344
|
+
for (const { module, pkgSource } of gabarits) {
|
|
345
|
+
for (const nom of module.outils) {
|
|
346
|
+
const version = pkgSource.devDependencies?.[nom];
|
|
347
|
+
if (typeof version === 'string' && !CHAMPS_INSTALLES.some(c => p[c]?.[nom] !== undefined)) {
|
|
348
|
+
p.devDependencies = { ...(p.devDependencies ?? {}), [nom]: version };
|
|
349
|
+
bilan.dependances.push(nom);
|
|
350
|
+
}
|
|
328
351
|
}
|
|
329
352
|
}
|
|
330
353
|
if (p.devDependencies) {
|
|
331
354
|
p.devDependencies = trie(p.devDependencies);
|
|
332
355
|
}
|
|
333
|
-
|
|
334
|
-
|
|
356
|
+
const gestionnaire = duGabarit(g =>
|
|
357
|
+
typeof g.packageManager === 'string' ? g.packageManager : undefined
|
|
358
|
+
);
|
|
359
|
+
if (gestionnaire !== undefined && typeof p.packageManager !== 'string') {
|
|
360
|
+
p.packageManager = gestionnaire;
|
|
361
|
+
}
|
|
362
|
+
if (typeof gardes === 'string') {
|
|
363
|
+
p.scripts['grillhouse:gardes'] = gardes;
|
|
335
364
|
}
|
|
336
|
-
if (typeof gardes === 'string') {p.scripts['grillhouse:gardes'] = gardes;}
|
|
337
365
|
// The commands of the known debt of the guards (scripts/dette.mjs) are the frame's.
|
|
338
366
|
for (const nom of ['grillhouse:dette:inscrire', 'grillhouse:dette:elaguer']) {
|
|
339
|
-
const script =
|
|
340
|
-
if (typeof script === 'string') {
|
|
367
|
+
const script = duGabarit(g => g.scripts?.[nom]);
|
|
368
|
+
if (typeof script === 'string') {
|
|
369
|
+
p.scripts[nom] = script;
|
|
370
|
+
}
|
|
341
371
|
}
|
|
342
372
|
// The frame's former wiring of the guards goes: Turborepo plays them (`npm run verifier`).
|
|
343
373
|
const pretest = typeof p.scripts.pretest === 'string' ? p.scripts.pretest.trim() : null;
|
|
@@ -367,20 +397,24 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
|
|
|
367
397
|
bilan.gardes = { deplace: false };
|
|
368
398
|
}
|
|
369
399
|
}
|
|
370
|
-
// The share of
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
400
|
+
// The share of each declared language (its module's `miseAJour`), in <p> and in its files, in
|
|
401
|
+
// the order of the declaration: the lines joined, `installer` when one asks it, the first line
|
|
402
|
+
// that says why the project has no script `verifier`.
|
|
403
|
+
for (const { module, pkgSource } of gabarits) {
|
|
404
|
+
const part = module.miseAJour.appliquer(projet, {
|
|
405
|
+
p,
|
|
406
|
+
modele: pkgSource,
|
|
407
|
+
source,
|
|
408
|
+
version: VERSION,
|
|
409
|
+
});
|
|
410
|
+
Object.assign(bilan, part.bilan);
|
|
411
|
+
bilan.duLangage = {
|
|
412
|
+
lignes: [...bilan.duLangage.lignes, ...part.lignes],
|
|
413
|
+
aFaire: [...bilan.duLangage.aFaire, ...part.aFaire],
|
|
414
|
+
installer: bilan.duLangage.installer || part.installer,
|
|
415
|
+
sansVerifier: bilan.duLangage.sansVerifier ?? part.sansVerifier,
|
|
416
|
+
};
|
|
417
|
+
}
|
|
384
418
|
writeFileSync(pkg, `${JSON.stringify(p, null, 2)}\n`);
|
|
385
419
|
ignorer(projet);
|
|
386
420
|
}
|
|
@@ -392,7 +426,7 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
|
|
|
392
426
|
}
|
|
393
427
|
|
|
394
428
|
/**
|
|
395
|
-
* Installs on the machine each binary of the
|
|
429
|
+
* Installs on the machine each binary of the languages of the project at <projet> (`binaires` of
|
|
396
430
|
* its module) that its installation does not list at its version, by the commands its module
|
|
397
431
|
* describes (`miseAJour.installation`: `liste`, then `installer` for each one missing), each run by
|
|
398
432
|
* Node, as `npm install` brings what is installed to what is declared; a language without
|
|
@@ -401,7 +435,18 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
|
|
|
401
435
|
* the command to type.
|
|
402
436
|
*/
|
|
403
437
|
export function installerBinaires(projet) {
|
|
404
|
-
const
|
|
438
|
+
const installes = [];
|
|
439
|
+
const lignes = [];
|
|
440
|
+
for (const m of langagesDe(projet)) {
|
|
441
|
+
const r = installerLesBinairesDe(projet, m);
|
|
442
|
+
installes.push(...r.installes);
|
|
443
|
+
lignes.push(...r.lignes);
|
|
444
|
+
}
|
|
445
|
+
return { installes, lignes };
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// The binaries of the module <langage> installed in the project at <projet> (`installerBinaires`).
|
|
449
|
+
function installerLesBinairesDe(projet, langage) {
|
|
405
450
|
const voulus = Object.entries(langage.binaires);
|
|
406
451
|
const installation = langage.miseAJour.installation;
|
|
407
452
|
if (voulus.length === 0 || installation === null) {
|
|
@@ -440,21 +485,28 @@ export function installerBinaires(projet) {
|
|
|
440
485
|
}
|
|
441
486
|
|
|
442
487
|
/**
|
|
443
|
-
* Runs each generator of the
|
|
444
|
-
* whose output the project holds (every one with `tous`, for a project `grillhouse init` creates);
|
|
488
|
+
* Runs each generator of the languages of the project (`miseAJour.generateurs` of each module,
|
|
489
|
+
* each once) whose output the project holds (every one with `tous`, for a project `grillhouse init` creates);
|
|
445
490
|
* returns the lines of failure.
|
|
446
491
|
*/
|
|
447
492
|
export function regenerer(projet, { tous = false } = {}) {
|
|
448
493
|
const lignes = [];
|
|
449
494
|
const grillhouse = path.join(projet, 'node_modules', '.bin', 'grillhouse');
|
|
450
495
|
const aPaquets = lireJson(path.join(projet, 'package.json'), {})?.workspaces !== undefined;
|
|
451
|
-
|
|
496
|
+
const vus = new Set();
|
|
497
|
+
for (const g of langagesDe(projet).flatMap(m => m.miseAJour.generateurs)) {
|
|
498
|
+
const cle = JSON.stringify([g.commande, ...g.args]);
|
|
499
|
+
if (vus.has(cle)) {
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
vus.add(cle);
|
|
452
503
|
const absente = g.sortie !== null && !tous && !existsSync(path.join(projet, g.sortie));
|
|
453
504
|
if (g.sortie === null ? !aPaquets : absente) {
|
|
454
505
|
continue;
|
|
455
506
|
}
|
|
456
|
-
if (g.sortie !== null)
|
|
457
|
-
|
|
507
|
+
if (g.sortie !== null) {
|
|
508
|
+
mkdirSync(path.dirname(path.join(projet, g.sortie)), { recursive: true });
|
|
509
|
+
}
|
|
458
510
|
const r = spawnSync(grillhouse, [g.commande, ...g.args], { cwd: projet, encoding: 'utf8' });
|
|
459
511
|
if (r.status !== 0) {
|
|
460
512
|
lignes.push(
|
|
@@ -468,11 +520,6 @@ export function regenerer(projet, { tous = false } = {}) {
|
|
|
468
520
|
/** The report of an update, from the bilan <b> of `mettreAJour`: one line per change. */
|
|
469
521
|
export function rapport(b) {
|
|
470
522
|
const lignes = [];
|
|
471
|
-
if (b.langages?.ecrits) {
|
|
472
|
-
lignes.push(
|
|
473
|
-
`Langages : grillhouse.langages déclare ${b.langages.langages.join(', ')}, trouvé dans le dépôt ; le cadre sert le projet par ce langage.`
|
|
474
|
-
);
|
|
475
|
-
}
|
|
476
523
|
if (b.dependances.length > 0) {
|
|
477
524
|
lignes.push(
|
|
478
525
|
`Dépendances de développement ajoutées : ${b.dependances.join(', ')}. \`npm install\` les installe.`
|
|
@@ -560,31 +607,37 @@ function verifier(projet, { fichiersAFinir, installer, sansVerifier }) {
|
|
|
560
607
|
const USAGE =
|
|
561
608
|
'Usage : npx grillhouse maj met le projet à jour du paquet installé (npm install -D @roomi-fields/grillhouse@<version> d’abord)\n';
|
|
562
609
|
|
|
610
|
+
/** The first line of the report: the version installed, and the command that installs another. */
|
|
611
|
+
export const LIGNE_DU_CADRE = `Cadre ${VERSION}, la version installée ; une autre s'installe d'abord par \`npm install -D @roomi-fields/grillhouse@<version>\` (une plage ^0.x n'admet pas la mineure suivante).`;
|
|
612
|
+
|
|
563
613
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
564
614
|
if (process.argv.length > 2) {
|
|
565
615
|
process.stderr.write(USAGE);
|
|
566
616
|
process.exitCode = 2;
|
|
567
617
|
} else {
|
|
568
618
|
const projet = process.cwd();
|
|
569
|
-
// The languages first: the migrations of the declared
|
|
570
|
-
let
|
|
619
|
+
// The languages first: the migrations of the declared languages play with the core's.
|
|
620
|
+
let premiere;
|
|
571
621
|
try {
|
|
572
|
-
|
|
622
|
+
premiere = declarerLesLangages(projet);
|
|
573
623
|
} catch (e) {
|
|
574
|
-
process.stderr.write(`⛔ ${e.message}\n`);
|
|
624
|
+
process.stderr.write(`⛔ ${e.message.replace(/^⛔ /, '')}\n`);
|
|
575
625
|
process.exitCode = 1;
|
|
576
626
|
}
|
|
577
|
-
if (
|
|
627
|
+
if (premiere !== undefined) {
|
|
628
|
+
mettreAJourLeProjet(projet, premiere);
|
|
629
|
+
}
|
|
578
630
|
}
|
|
579
631
|
}
|
|
580
632
|
|
|
581
|
-
// The update of the project at <projet>, its languages
|
|
582
|
-
|
|
633
|
+
// The update of the project at <projet>, its languages declared (declarerLesLangages), <premiere>
|
|
634
|
+
// what the migration of its languages did, null for nothing.
|
|
635
|
+
function mettreAJourLeProjet(projet, premiere) {
|
|
583
636
|
const depuis = versionDuProjet(projet);
|
|
584
|
-
const migrations = migrer(projet, depuis);
|
|
637
|
+
const migrations = [...(premiere ? [premiere] : []), ...migrer(projet, depuis)];
|
|
585
638
|
const resteAFaire = migrations.some(m => m.aFaire.length > 0);
|
|
586
|
-
const b =
|
|
587
|
-
process.stdout.write(
|
|
639
|
+
const b = mettreAJour(projet, CADRE, resteAFaire ? { inscrite: null } : {});
|
|
640
|
+
process.stdout.write(`${LIGNE_DU_CADRE}\n`);
|
|
588
641
|
for (const { version, nom, lignes, aFaire } of migrations) {
|
|
589
642
|
process.stdout.write(
|
|
590
643
|
`Migration ${version} (${nom}) :\n${lignes.map(l => `- ${l}\n`).join('')}`
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The index of the interfaces of a project of several languages, one generated file of the core,
|
|
3
|
+
// as a build of several languages writes one output from the outputs of each rule: each declared
|
|
4
|
+
// module gives the entries of its interfaces (`entreesDeLIndex` of the join), and the core
|
|
5
|
+
// assembles them, so that one file has one command and one check (./composition-des-langages.mjs
|
|
6
|
+
// gives them in place of each module's).
|
|
7
|
+
//
|
|
8
|
+
// node index-interfaces.mjs writes docs/agents/index-des-interfaces.md
|
|
9
|
+
// node index-interfaces.mjs --verifier refuses (exit 1) when that file is out of
|
|
10
|
+
// date, its finding in SARIF too
|
|
11
|
+
// node index-interfaces.mjs --publie <composant> asks each module (./commandes-composees.mjs)
|
|
12
|
+
//
|
|
13
|
+
// - The index and its check are the composition's (`indexDesInterfaces`, `indexEnRetard`), which
|
|
14
|
+
// this command writes and judges. The entries are each module's, in the order of their interfaces' paths; an interface two
|
|
15
|
+
// modules give (the root's) is written once, the first module's in the order of the declaration.
|
|
16
|
+
// - The finding of the check carries the name `index-interfaces`, as each module's.
|
|
17
|
+
// - Any other argument goes to the command `index-interfaces` of each module that describes it,
|
|
18
|
+
// which writes nothing then: what the providers of a component publish.
|
|
19
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
22
|
+
import {
|
|
23
|
+
INDEX_DES_INTERFACES,
|
|
24
|
+
indexDesInterfaces as index,
|
|
25
|
+
indexEnRetard as enRetard,
|
|
26
|
+
} from './composition-des-langages.mjs';
|
|
27
|
+
import { ecrireSarif } from './resultats.mjs';
|
|
28
|
+
|
|
29
|
+
/** This script. */
|
|
30
|
+
export const SCRIPT = fileURLToPath(import.meta.url);
|
|
31
|
+
/** The index of the interfaces, from the root. */
|
|
32
|
+
export const SORTIE = INDEX_DES_INTERFACES;
|
|
33
|
+
/** The name its finding carries, its command's in a module and in the project. */
|
|
34
|
+
export const GARDE = 'index-interfaces';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Runs the command in the project at <racine> with <args>: its exit code.
|
|
38
|
+
* @param {string} racine
|
|
39
|
+
* @param {string[]} args
|
|
40
|
+
* @param {{ modules: import('./jointure.js').Langage[], env?: NodeJS.ProcessEnv }} o
|
|
41
|
+
*/
|
|
42
|
+
export function commande(racine, args, { modules, env = process.env }) {
|
|
43
|
+
if (args.length === 0) {
|
|
44
|
+
mkdirSync(path.dirname(path.join(racine, SORTIE)), { recursive: true });
|
|
45
|
+
writeFileSync(path.join(racine, SORTIE), index(racine, modules));
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
const refus = enRetard(racine, modules);
|
|
49
|
+
for (const r of refus) {
|
|
50
|
+
process.stderr.write(`⛔ ${r.message}\n`);
|
|
51
|
+
}
|
|
52
|
+
ecrireSarif({ garde: GARDE, racine, constats: refus, env });
|
|
53
|
+
return refus.length ? 1 : 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Run as a command: the join and the composed commands are loaded here, without a top-level await,
|
|
57
|
+
// since the join, which composes the modules with this script, is loaded by `require`.
|
|
58
|
+
async function principal(racine, args) {
|
|
59
|
+
const { langagesDe } = await import('./langages.mjs');
|
|
60
|
+
const modules = langagesDe(racine);
|
|
61
|
+
if (args.length === 0 || (args.length === 1 && args[0] === '--verifier')) {
|
|
62
|
+
return commande(racine, args, { modules });
|
|
63
|
+
}
|
|
64
|
+
const { jouer } = await import('./commandes-composees.mjs');
|
|
65
|
+
return jouer('index-interfaces', args, { racine, modules });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
69
|
+
principal(process.cwd(), process.argv.slice(2)).then(
|
|
70
|
+
code => {
|
|
71
|
+
process.exitCode = code;
|
|
72
|
+
},
|
|
73
|
+
e => {
|
|
74
|
+
process.stderr.write(`${e.message}\n`);
|
|
75
|
+
process.exitCode = 1;
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
package/scripts/init.mjs
CHANGED
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
// then the plugins its settings declare: the template's declare the frame's,
|
|
18
18
|
// `grillhouse@roomi-fields`, whose marketplace names the package npm.
|
|
19
19
|
// - Then what the frame writes in a project, as `grillhouse maj` writes it (scripts/grillhouse-maj.mjs):
|
|
20
|
-
// its languages
|
|
21
|
-
// turbo.json, the status line of its settings, the
|
|
22
|
-
// files (the boundaries' configuration, the interfaces
|
|
23
|
-
// plugin or a generator that fails has its line, and the
|
|
24
|
-
// is created.
|
|
20
|
+
// its languages read in the template's docs/ARCHITECTURE.md (typescript, the column « Langage »
|
|
21
|
+
// of its table of the components), its turbo.json, the status line of its settings, the
|
|
22
|
+
// version of the frame; and the generated files (the boundaries' configuration, the interfaces
|
|
23
|
+
// index, run by the project's command). A plugin or a generator that fails has its line, and the
|
|
24
|
+
// exit code is non-zero once the project is created.
|
|
25
25
|
// - The project ends on one commit, « chore: initial commit from Roomi's Grillhouse ».
|
|
26
26
|
import { execFileSync } from 'node:child_process';
|
|
27
27
|
import {
|
|
@@ -22,7 +22,15 @@
|
|
|
22
22
|
// `npm run verifier` (Turborepo: the build, then the guards and every test of the day beside
|
|
23
23
|
// each other, each task replayed from the cache of the main tree when its inputs are
|
|
24
24
|
// unchanged), every command of the project run in the copy leaving its index up to date
|
|
25
|
-
// (rejeu.mjs); main moves forward onto the replaced branch when `npm run verifier` is green
|
|
25
|
+
// (rejeu.mjs); main moves forward onto the replaced branch when `npm run verifier` is green.
|
|
26
|
+
// A generated file the project declares (`grillhouse.engendres`, scripts/engendres.mjs, read
|
|
27
|
+
// from the main tree, a faulty key keeping the branch in the queue, named) is never merged, as
|
|
28
|
+
// npm writes package-lock.json again after a merge: a conflict on such files only takes main's
|
|
29
|
+
// version, and once the branch is replaced and installed, the command of each one whose files,
|
|
30
|
+
// or the files it reads, the branch touches writes it again, with the tools of the project,
|
|
31
|
+
// and what it writes enters the branch's commit; a command that fails makes the branch leave
|
|
32
|
+
// the queue, the command and its output named (OSC Bridge, 2026-10-31: four conflicts in one
|
|
33
|
+
// day on the generated files of synthhub and open-synth-descriptors);
|
|
26
34
|
// - a branch with nothing ahead of main does not enter: it leaves the queue, its ticket loses
|
|
27
35
|
// `en-file` and takes a comment, and stays as it is;
|
|
28
36
|
// - a branch that does not replace (the files in conflict) or whose `npm run verifier` is red once
|
|
@@ -75,6 +83,8 @@ import { existsSync, rmSync } from 'node:fs';
|
|
|
75
83
|
import { createRequire } from 'node:module';
|
|
76
84
|
import path from 'node:path';
|
|
77
85
|
import { pathToFileURL } from 'node:url';
|
|
86
|
+
import { couvertPar, engendresDe, regenerer, touchesPar } from '../engendres.mjs';
|
|
87
|
+
import { avecLesOutils, outilsDe } from '../outils-cles.mjs';
|
|
78
88
|
import { lireCommit } from '../poussee-cles.mjs';
|
|
79
89
|
import { commitsDelivering, gitLog } from '../un-commit-par-ticket.mjs';
|
|
80
90
|
import { attendreUnPeu, lacherVerrou, prendreVerrou } from '../verrou-de-fichier.mjs';
|
|
@@ -452,30 +462,81 @@ function main(argv) {
|
|
|
452
462
|
const rejouer = (tip, tete) => {
|
|
453
463
|
if (existsSync(copie))
|
|
454
464
|
spawnSync('git', ['-C', copie, 'rebase', '--abort'], { encoding: 'utf8' });
|
|
465
|
+
// The keys of the project, before any work: its generated files and its tools.
|
|
466
|
+
let engendres;
|
|
467
|
+
let env;
|
|
468
|
+
try {
|
|
469
|
+
engendres = engendresDe(racine);
|
|
470
|
+
env = avecLesOutils(outilsDe(racine), process.env);
|
|
471
|
+
} catch (e) {
|
|
472
|
+
return { garde: `une clé grillhouse du package.json est refusée :\n${e.message}` };
|
|
473
|
+
}
|
|
455
474
|
const ouverte = ouvrirCopie({ racine, copie, ref: tete, dire });
|
|
456
475
|
if (ouverte.refus) return { garde: ouverte.refus };
|
|
457
|
-
const { dansCopie, installer, tester } = ouverte;
|
|
476
|
+
const { dansCopie, monter, installer, tester } = ouverte;
|
|
458
477
|
if (dansCopie('checkout', '-q', '--detach', tip).status !== 0)
|
|
459
478
|
return { garde: `la copie ne prend pas ${tip.slice(0, 7)}` };
|
|
460
|
-
|
|
461
|
-
|
|
479
|
+
// A conflict on generated files the project declares only is no conflict: main's version is
|
|
480
|
+
// taken, and their command writes them again once the branch is replaced (below).
|
|
481
|
+
let rebase = dansCopie('rebase', tete);
|
|
482
|
+
let tours = Number(dansCopie('rev-list', '--count', `${tete}..${tip}`).stdout.trim()) || 1;
|
|
483
|
+
while (rebase.status !== 0) {
|
|
462
484
|
const conflits = dansCopie('diff', '--name-only', '--diff-filter=U')
|
|
463
485
|
.stdout.split('\n')
|
|
464
486
|
.filter(Boolean);
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
487
|
+
const engendresSeuls =
|
|
488
|
+
tours-- > 0 &&
|
|
489
|
+
conflits.length > 0 &&
|
|
490
|
+
conflits.every(f => engendres.some(e => couvertPar(e.entiers, f))) &&
|
|
491
|
+
dansCopie('checkout', '--ours', '--', ...conflits).status === 0 &&
|
|
492
|
+
dansCopie('add', '--', ...conflits).status === 0;
|
|
493
|
+
if (!engendresSeuls) {
|
|
494
|
+
dansCopie('rebase', '--abort');
|
|
495
|
+
return {
|
|
496
|
+
sortie: [
|
|
497
|
+
'elle ne se replace pas sur main.',
|
|
498
|
+
conflits.length
|
|
499
|
+
? `Fichiers en conflit :\n${conflits.map(f => ` ${f}`).join('\n')}`
|
|
500
|
+
: `Sortie de git :\n${rebase.stdout}${rebase.stderr}`,
|
|
501
|
+
],
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
rebase = dansCopie('-c', 'core.editor=true', 'rebase', '--continue');
|
|
474
505
|
}
|
|
475
506
|
const installation = installer();
|
|
476
507
|
if (installation) {
|
|
477
508
|
return { sortie: [installation, "Le verrou de la branche replacée ne s'installe pas."] };
|
|
478
509
|
}
|
|
510
|
+
const touches = touchesPar(
|
|
511
|
+
engendres,
|
|
512
|
+
dansCopie('diff', '--name-only', '--no-renames', '-z', tete, 'HEAD')
|
|
513
|
+
.stdout.split('\0')
|
|
514
|
+
.filter(Boolean)
|
|
515
|
+
);
|
|
516
|
+
if (touches.length) {
|
|
517
|
+
const refus = regenerer({
|
|
518
|
+
refs: touches.map(e => ({ ...e, cadre: false })),
|
|
519
|
+
dansCopie,
|
|
520
|
+
lancer: commande =>
|
|
521
|
+
spawnSync('bash', monter('sh', '-c', commande), {
|
|
522
|
+
cwd: copie,
|
|
523
|
+
encoding: 'utf8',
|
|
524
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
525
|
+
env,
|
|
526
|
+
}),
|
|
527
|
+
});
|
|
528
|
+
if (refus)
|
|
529
|
+
return { sortie: ['ses fichiers engendrés ne se régénèrent pas sur main.', refus] };
|
|
530
|
+
if (dansCopie('diff', '--cached', '--quiet').status !== 0) {
|
|
531
|
+
const corrige = dansCopie('commit', '-q', '--amend', '--no-edit', '--no-verify');
|
|
532
|
+
if (corrige.status !== 0) {
|
|
533
|
+
return {
|
|
534
|
+
garde: `ses fichiers régénérés n'entrent pas dans son commit :\n${corrige.stderr}`,
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
dire(`✓ fichiers engendrés régénérés sur main : ${touches.map(e => e.nom).join(', ')}`);
|
|
539
|
+
}
|
|
479
540
|
dire('— npm run verifier (construction, gardes, tests)');
|
|
480
541
|
const t = tester();
|
|
481
542
|
if (t.status === A_REPASSER) {
|