@roomi-fields/grillhouse 0.25.5 → 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/agents/testwriter.md +1 -1
- package/bin/grillhouse.mjs +20 -3
- package/cadre/templates/cargo/package.json +3 -0
- package/cadre/templates/projet/.gitattributes +1 -0
- package/cadre/templates/projet/CLAUDE.md +13 -0
- package/cadre/templates/projet/docs/ARCHITECTURE.md +15 -0
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/cadre/templates/python/package.json +18 -0
- package/charte.md +32 -1
- package/docs/ARCHITECTURE.md +146 -40
- package/docs/CADRE.md +7 -6
- package/docs/INTERFACE.md +108 -32
- package/hooks/register.tsx +57 -16
- package/package.json +9 -3
- package/scripts/circuit.mjs +165 -27
- 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/copies-finies.mjs +167 -28
- package/scripts/crochets.mjs +9 -3
- package/scripts/dernier-vert.mjs +15 -2
- package/scripts/engendres.mjs +170 -0
- package/scripts/enveloppe/enveloppe.mjs +59 -17
- package/scripts/enveloppe/lancer.sh +15 -22
- package/scripts/enveloppe/travail-de-la-copie.mjs +262 -0
- package/scripts/etapes.mjs +1 -1
- package/scripts/fusion-du-changelog.mjs +120 -0
- package/scripts/gardes-du-cadre.mjs +7 -4
- package/scripts/grillhouse-maj.mjs +171 -99
- package/scripts/index-interfaces.mjs +78 -0
- package/scripts/init.mjs +5 -5
- package/scripts/integration/file.mjs +270 -117
- package/scripts/integration/integrer.mjs +50 -62
- package/scripts/jointure.d.ts +48 -14
- package/scripts/langages/cargo/binaires.json +2 -1
- package/scripts/langages/cargo/binaires.mjs +29 -6
- package/scripts/langages/cargo/clippy.mjs +12 -2
- package/scripts/langages/cargo/commandes.mjs +60 -7
- package/scripts/langages/cargo/composants.mjs +229 -8
- package/scripts/langages/cargo/exemples.mjs +1 -15
- package/scripts/langages/cargo/index-interfaces.mjs +20 -3
- package/scripts/langages/cargo/index.mjs +25 -17
- package/scripts/langages/cargo/mise-a-jour.mjs +2 -1
- package/scripts/langages/cargo/sccache.mjs +172 -0
- package/scripts/langages/cargo/verdict.mjs +50 -10
- 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 +15 -17
- package/scripts/langages/typescript/regle-des-tests.mjs +37 -0
- 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/nuit.sh +15 -1
- package/scripts/outils-cles.mjs +188 -0
- package/scripts/resultats.mjs +22 -6
- package/scripts/session-start.sh +34 -9
- package/scripts/sources.mjs +2 -1
- package/scripts/sous-commandes.mjs +21 -3
- package/scripts/tableau-des-composants.mjs +138 -0
- package/scripts/verrou-de-machine.mjs +14 -13
- package/scripts/verrous/verrou.mjs +53 -16
- package/skills/developpeur/SKILL.md +4 -0
- package/skills/explorateur/SKILL.md +3 -1
- package/skills/grill/SKILL.md +9 -1
- package/skills/pitmaster/SKILL.md +12 -3
- package/skills/pitmaster/references/consigne-agent.md +3 -3
- package/skills/redacteur/references/documents-d-un-composant.md +12 -0
- package/skills/relecteur/SKILL.md +6 -2
- package/skills/testwriter/SKILL.md +29 -6
|
@@ -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.
|
|
@@ -99,6 +102,10 @@
|
|
|
99
102
|
// `prepare`) also runs, in the hooks folder git reads for the project (`core.hooksPath`, else the
|
|
100
103
|
// default one; the configuration stays). A hook of the project keeps its lines, which still run;
|
|
101
104
|
// the frame's lines of a former version give way to the current ones.
|
|
105
|
+
// - The merge driver of the CHANGELOG (scripts/fusion-du-changelog.mjs): a `.gitattributes`
|
|
106
|
+
// without the line `CHANGELOG.md merge=grillhouse-changelog` receives it, after its own lines,
|
|
107
|
+
// and the driver's command is written in the repository's configuration with the hooks
|
|
108
|
+
// (scripts/crochets.mjs): two lots that each add an entry under the same heading both enter main.
|
|
102
109
|
// - The plugins: after the files, the command line installs the plugins the project's settings
|
|
103
110
|
// declare, for the project, by scripts/greffons.mjs (the mechanism `grillhouse init` also calls;
|
|
104
111
|
// `mettreAJour` itself never calls claude), and brings the frame's mod to the package's version,
|
|
@@ -112,7 +119,10 @@
|
|
|
112
119
|
// without file in a repository with `workspaces`, so that the frame's checks accept them; a
|
|
113
120
|
// generator that fails, or a project without its command, has its line, which says to run it
|
|
114
121
|
// after `npm install` (the frame's package and tools), and the exit code is non-zero.
|
|
115
|
-
// - 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).
|
|
116
126
|
// - Last, the update plays the project's verification, `npm run verifier`, from its root, its
|
|
117
127
|
// output shown, as Nx affected moves its base to the last green commit of main: its green keeps
|
|
118
128
|
// the last green (scripts/dernier-vert.mjs), HEAD and the tree of the working tree, the update's
|
|
@@ -132,9 +142,11 @@ import path from 'node:path';
|
|
|
132
142
|
import { pathToFileURL } from 'node:url';
|
|
133
143
|
import { CADRE, VERSION } from './cadre.mjs';
|
|
134
144
|
import { poserCrochets } from './crochets.mjs';
|
|
145
|
+
import { ATTRIBUT } from './fusion-du-changelog.mjs';
|
|
135
146
|
import { installerGreffons } from './greffons.mjs';
|
|
136
147
|
import { migrer, restesAuProjet } from './migrations.mjs';
|
|
137
|
-
import {
|
|
148
|
+
import { langageDe, langagesDe } from './langages.mjs';
|
|
149
|
+
import * as langagesDansLArchitecture from './migrations/0.27.0-langages-dans-l-architecture.mjs';
|
|
138
150
|
|
|
139
151
|
const SCRIPTS = {
|
|
140
152
|
tableau: 'grillhouse tableau --texte',
|
|
@@ -189,6 +201,19 @@ function ignorer(projet) {
|
|
|
189
201
|
}
|
|
190
202
|
}
|
|
191
203
|
|
|
204
|
+
// Adds to the `.gitattributes` of the project at <projet> the line that gives its CHANGELOG to the
|
|
205
|
+
// frame's merge driver (ATTRIBUT, scripts/fusion-du-changelog.mjs), when no line is it; its own
|
|
206
|
+
// lines stay.
|
|
207
|
+
function attribuer(projet) {
|
|
208
|
+
const f = path.join(projet, '.gitattributes');
|
|
209
|
+
const texte = existsSync(f) ? readFileSync(f, 'utf8') : '';
|
|
210
|
+
if (texte.split('\n').some(l => l.trim() === ATTRIBUT)) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const fin = texte === '' || texte.endsWith('\n') ? '' : '\n';
|
|
214
|
+
writeFileSync(f, `${texte}${fin}${ATTRIBUT}\n`);
|
|
215
|
+
}
|
|
216
|
+
|
|
192
217
|
// <deps> written sorted by name, as npm writes them.
|
|
193
218
|
const trie = deps =>
|
|
194
219
|
Object.fromEntries(Object.entries(deps).sort(([a], [b]) => a.localeCompare(b, 'en')));
|
|
@@ -198,13 +223,19 @@ const trie = deps =>
|
|
|
198
223
|
// they changed.
|
|
199
224
|
function reglerLigneEtat(projet) {
|
|
200
225
|
const f = path.join(projet, '.claude', 'settings.json');
|
|
201
|
-
if (!existsSync(f)) {
|
|
226
|
+
if (!existsSync(f)) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
202
229
|
const reglages = JSON.parse(readFileSync(f, 'utf8'));
|
|
203
230
|
const actuelle = reglages.statusLine;
|
|
204
231
|
const commande = typeof actuelle?.command === 'string' ? actuelle.command : '';
|
|
205
|
-
if (actuelle !== undefined && !commande.includes('ligne-etat')) {
|
|
232
|
+
if (actuelle !== undefined && !commande.includes('ligne-etat')) {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
206
235
|
const voulue = { type: 'command', command: LIGNE_ETAT };
|
|
207
|
-
if (JSON.stringify(actuelle) === JSON.stringify(voulue)) {
|
|
236
|
+
if (JSON.stringify(actuelle) === JSON.stringify(voulue)) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
208
239
|
reglages.statusLine = voulue;
|
|
209
240
|
writeFileSync(f, `${JSON.stringify(reglages, null, 2)}\n`);
|
|
210
241
|
return true;
|
|
@@ -219,7 +250,9 @@ export const GREFFON_DU_CADRE = `grillhouse@${MARCHE_DU_CADRE}`;
|
|
|
219
250
|
// and enables the frame's plugin (see the header); returns whether they changed.
|
|
220
251
|
function declarerGreffon(projet) {
|
|
221
252
|
const f = path.join(projet, '.claude', 'settings.json');
|
|
222
|
-
if (!existsSync(f)) {
|
|
253
|
+
if (!existsSync(f)) {
|
|
254
|
+
return false;
|
|
255
|
+
}
|
|
223
256
|
const avant = readFileSync(f, 'utf8');
|
|
224
257
|
const reglages = JSON.parse(avant);
|
|
225
258
|
reglages.extraKnownMarketplaces = {
|
|
@@ -227,40 +260,39 @@ function declarerGreffon(projet) {
|
|
|
227
260
|
[MARCHE_DU_CADRE]: { source: SOURCE_DU_MARCHE },
|
|
228
261
|
};
|
|
229
262
|
reglages.enabledPlugins = { ...(reglages.enabledPlugins ?? {}), [GREFFON_DU_CADRE]: true };
|
|
230
|
-
if (JSON.stringify(reglages) === JSON.stringify(JSON.parse(avant))) {
|
|
263
|
+
if (JSON.stringify(reglages) === JSON.stringify(JSON.parse(avant))) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
231
266
|
writeFileSync(f, `${JSON.stringify(reglages, null, 2)}\n`);
|
|
232
267
|
return true;
|
|
233
268
|
}
|
|
234
269
|
|
|
235
270
|
/**
|
|
236
|
-
* Declares the languages of the project at <projet>
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
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.
|
|
241
276
|
*/
|
|
242
|
-
export function
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
throw new Error(
|
|
246
|
-
`${projet} n'a pas de package.json, où un projet déclare ses langages (grillhouse.langages) ; la mise à jour du cadre s'y joue.`
|
|
247
|
-
);
|
|
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.`);
|
|
248
280
|
}
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const signes = Object.keys(LANGAGES)
|
|
254
|
-
.map(n => `${n} : ${langage(n).signe}`)
|
|
255
|
-
.join(' ; ');
|
|
256
|
-
throw new Error(
|
|
257
|
-
`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\`.`
|
|
258
|
-
);
|
|
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(' ; '));
|
|
259
285
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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;
|
|
264
296
|
}
|
|
265
297
|
|
|
266
298
|
/** The version of the frame the project at <projet> recorded (`grillhouse.version`), or null. */
|
|
@@ -276,7 +308,6 @@ export function versionDuProjet(projet) {
|
|
|
276
308
|
*/
|
|
277
309
|
export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
|
|
278
310
|
const bilan = {
|
|
279
|
-
langages: null,
|
|
280
311
|
dependances: [],
|
|
281
312
|
gardes: null,
|
|
282
313
|
ligneEtat: false,
|
|
@@ -285,41 +316,58 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
|
|
|
285
316
|
};
|
|
286
317
|
const pkg = path.join(projet, 'package.json');
|
|
287
318
|
if (existsSync(pkg)) {
|
|
288
|
-
|
|
289
|
-
const langage = langageDe(projet);
|
|
319
|
+
const modules = langagesDe(projet);
|
|
290
320
|
const p = lireJson(pkg, {});
|
|
291
|
-
if (inscrite !== null) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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']);
|
|
295
332
|
p.scripts = { ...(p.scripts ?? {}), ...SCRIPTS };
|
|
296
333
|
// The project's `prepare`, which npm runs at its install, places the frame's git hooks first.
|
|
297
334
|
const prepare = typeof p.scripts.prepare === 'string' ? p.scripts.prepare.trim() : '';
|
|
298
335
|
if (!prepare.split(/\s*&&\s*/).includes(PREPARE)) {
|
|
299
336
|
p.scripts.prepare = prepare === '' ? PREPARE : `${PREPARE} && ${prepare}`;
|
|
300
337
|
}
|
|
301
|
-
|
|
302
|
-
|
|
338
|
+
const api = duGabarit(g => (typeof g.scripts?.api === 'string' ? g.scripts.api : undefined));
|
|
339
|
+
if (api !== undefined) {
|
|
340
|
+
p.scripts.api = api;
|
|
303
341
|
}
|
|
304
|
-
// The tools of the declared
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
+
}
|
|
310
351
|
}
|
|
311
352
|
}
|
|
312
353
|
if (p.devDependencies) {
|
|
313
354
|
p.devDependencies = trie(p.devDependencies);
|
|
314
355
|
}
|
|
315
|
-
|
|
316
|
-
|
|
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;
|
|
317
364
|
}
|
|
318
|
-
if (typeof gardes === 'string') {p.scripts['grillhouse:gardes'] = gardes;}
|
|
319
365
|
// The commands of the known debt of the guards (scripts/dette.mjs) are the frame's.
|
|
320
366
|
for (const nom of ['grillhouse:dette:inscrire', 'grillhouse:dette:elaguer']) {
|
|
321
|
-
const script =
|
|
322
|
-
if (typeof script === 'string') {
|
|
367
|
+
const script = duGabarit(g => g.scripts?.[nom]);
|
|
368
|
+
if (typeof script === 'string') {
|
|
369
|
+
p.scripts[nom] = script;
|
|
370
|
+
}
|
|
323
371
|
}
|
|
324
372
|
// The frame's former wiring of the guards goes: Turborepo plays them (`npm run verifier`).
|
|
325
373
|
const pretest = typeof p.scripts.pretest === 'string' ? p.scripts.pretest.trim() : null;
|
|
@@ -349,31 +397,36 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
|
|
|
349
397
|
bilan.gardes = { deplace: false };
|
|
350
398
|
}
|
|
351
399
|
}
|
|
352
|
-
// The share of
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
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
|
+
}
|
|
366
418
|
writeFileSync(pkg, `${JSON.stringify(p, null, 2)}\n`);
|
|
367
419
|
ignorer(projet);
|
|
368
420
|
}
|
|
369
421
|
bilan.ligneEtat = reglerLigneEtat(projet);
|
|
370
422
|
bilan.greffon = declarerGreffon(projet);
|
|
371
423
|
poserCrochets(projet);
|
|
424
|
+
attribuer(projet);
|
|
372
425
|
return bilan;
|
|
373
426
|
}
|
|
374
427
|
|
|
375
428
|
/**
|
|
376
|
-
* 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
|
|
377
430
|
* its module) that its installation does not list at its version, by the commands its module
|
|
378
431
|
* describes (`miseAJour.installation`: `liste`, then `installer` for each one missing), each run by
|
|
379
432
|
* Node, as `npm install` brings what is installed to what is declared; a language without
|
|
@@ -382,7 +435,18 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
|
|
|
382
435
|
* the command to type.
|
|
383
436
|
*/
|
|
384
437
|
export function installerBinaires(projet) {
|
|
385
|
-
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) {
|
|
386
450
|
const voulus = Object.entries(langage.binaires);
|
|
387
451
|
const installation = langage.miseAJour.installation;
|
|
388
452
|
if (voulus.length === 0 || installation === null) {
|
|
@@ -421,21 +485,28 @@ export function installerBinaires(projet) {
|
|
|
421
485
|
}
|
|
422
486
|
|
|
423
487
|
/**
|
|
424
|
-
* Runs each generator of the
|
|
425
|
-
* 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);
|
|
426
490
|
* returns the lines of failure.
|
|
427
491
|
*/
|
|
428
492
|
export function regenerer(projet, { tous = false } = {}) {
|
|
429
493
|
const lignes = [];
|
|
430
494
|
const grillhouse = path.join(projet, 'node_modules', '.bin', 'grillhouse');
|
|
431
495
|
const aPaquets = lireJson(path.join(projet, 'package.json'), {})?.workspaces !== undefined;
|
|
432
|
-
|
|
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);
|
|
433
503
|
const absente = g.sortie !== null && !tous && !existsSync(path.join(projet, g.sortie));
|
|
434
504
|
if (g.sortie === null ? !aPaquets : absente) {
|
|
435
505
|
continue;
|
|
436
506
|
}
|
|
437
|
-
if (g.sortie !== null)
|
|
438
|
-
|
|
507
|
+
if (g.sortie !== null) {
|
|
508
|
+
mkdirSync(path.dirname(path.join(projet, g.sortie)), { recursive: true });
|
|
509
|
+
}
|
|
439
510
|
const r = spawnSync(grillhouse, [g.commande, ...g.args], { cwd: projet, encoding: 'utf8' });
|
|
440
511
|
if (r.status !== 0) {
|
|
441
512
|
lignes.push(
|
|
@@ -449,11 +520,6 @@ export function regenerer(projet, { tous = false } = {}) {
|
|
|
449
520
|
/** The report of an update, from the bilan <b> of `mettreAJour`: one line per change. */
|
|
450
521
|
export function rapport(b) {
|
|
451
522
|
const lignes = [];
|
|
452
|
-
if (b.langages?.ecrits) {
|
|
453
|
-
lignes.push(
|
|
454
|
-
`Langages : grillhouse.langages déclare ${b.langages.langages.join(', ')}, trouvé dans le dépôt ; le cadre sert le projet par ce langage.`
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
523
|
if (b.dependances.length > 0) {
|
|
458
524
|
lignes.push(
|
|
459
525
|
`Dépendances de développement ajoutées : ${b.dependances.join(', ')}. \`npm install\` les installe.`
|
|
@@ -541,31 +607,37 @@ function verifier(projet, { fichiersAFinir, installer, sansVerifier }) {
|
|
|
541
607
|
const USAGE =
|
|
542
608
|
'Usage : npx grillhouse maj met le projet à jour du paquet installé (npm install -D @roomi-fields/grillhouse@<version> d’abord)\n';
|
|
543
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
|
+
|
|
544
613
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
545
614
|
if (process.argv.length > 2) {
|
|
546
615
|
process.stderr.write(USAGE);
|
|
547
616
|
process.exitCode = 2;
|
|
548
617
|
} else {
|
|
549
618
|
const projet = process.cwd();
|
|
550
|
-
// The languages first: the migrations of the declared
|
|
551
|
-
let
|
|
619
|
+
// The languages first: the migrations of the declared languages play with the core's.
|
|
620
|
+
let premiere;
|
|
552
621
|
try {
|
|
553
|
-
|
|
622
|
+
premiere = declarerLesLangages(projet);
|
|
554
623
|
} catch (e) {
|
|
555
|
-
process.stderr.write(`⛔ ${e.message}\n`);
|
|
624
|
+
process.stderr.write(`⛔ ${e.message.replace(/^⛔ /, '')}\n`);
|
|
556
625
|
process.exitCode = 1;
|
|
557
626
|
}
|
|
558
|
-
if (
|
|
627
|
+
if (premiere !== undefined) {
|
|
628
|
+
mettreAJourLeProjet(projet, premiere);
|
|
629
|
+
}
|
|
559
630
|
}
|
|
560
631
|
}
|
|
561
632
|
|
|
562
|
-
// The update of the project at <projet>, its languages
|
|
563
|
-
|
|
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) {
|
|
564
636
|
const depuis = versionDuProjet(projet);
|
|
565
|
-
const migrations = migrer(projet, depuis);
|
|
637
|
+
const migrations = [...(premiere ? [premiere] : []), ...migrer(projet, depuis)];
|
|
566
638
|
const resteAFaire = migrations.some(m => m.aFaire.length > 0);
|
|
567
|
-
const b =
|
|
568
|
-
process.stdout.write(
|
|
639
|
+
const b = mettreAJour(projet, CADRE, resteAFaire ? { inscrite: null } : {});
|
|
640
|
+
process.stdout.write(`${LIGNE_DU_CADRE}\n`);
|
|
569
641
|
for (const { version, nom, lignes, aFaire } of migrations) {
|
|
570
642
|
process.stdout.write(
|
|
571
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 {
|