@roomi-fields/grillhouse 0.27.0 → 0.28.1
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/explorateur.md +1 -1
- package/cadre/templates/paquet/docs/CADRE.md +36 -0
- package/cadre/templates/paquet/docs/INTERFACE.md +10 -0
- package/charte.md +26 -1
- package/docs/ARCHITECTURE.md +76 -8
- package/docs/INTERFACE.md +17 -2
- package/hooks/register.tsx +205 -24
- package/package.json +11 -1
- package/scripts/circuit.mjs +412 -98
- package/scripts/enveloppe/lancer.sh +10 -6
- package/scripts/etapes.mjs +21 -8
- package/scripts/grillhouse-maj.mjs +10 -9
- package/scripts/jointure.d.ts +18 -0
- package/scripts/langages/cargo/index.mjs +3 -0
- package/scripts/langages/cargo/squelette.mjs +111 -0
- package/scripts/langages/python/index.mjs +3 -0
- package/scripts/langages/python/squelette.mjs +66 -0
- package/scripts/langages/typescript/frontieres.mjs +14 -1
- package/scripts/langages/typescript/index.mjs +3 -0
- package/scripts/langages/typescript/squelette.mjs +120 -0
- package/scripts/langages-des-paquets.mjs +1 -1
- package/scripts/paquet.mjs +261 -0
- package/scripts/resultats.mjs +76 -1
- package/scripts/sous-commandes.mjs +1 -0
- package/scripts/tableau-des-composants.mjs +5 -3
- package/scripts/tableau.mjs +20 -10
- package/skills/developpeur/SKILL.md +3 -0
- package/skills/explorateur/SKILL.md +42 -4
- package/skills/grill/SKILL.md +6 -1
- package/skills/pitmaster/SKILL.md +30 -4
- package/skills/pitmaster/references/consigne-agent.md +34 -5
- package/skills/relecteur/SKILL.md +12 -0
- package/skills/testwriter/SKILL.md +2 -1
- package/types/index.d.ts +17 -3
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# plan, the packages it writes (one session of the testwriter or the developpeur for the whole
|
|
4
4
|
# ticket, `.` as its component and the plan as `--paquets`, grillhouse-3uv.95.6). The supervisor runs it in the background and is told when the session ends.
|
|
5
5
|
#
|
|
6
|
-
# npx grillhouse lancer [--modele <m>] [--effort <e>] [--seance <id> | --reprise <id>] [--paquets <liste>] <ticket> <rôle> <composant> <fichier de consigne>
|
|
6
|
+
# npx grillhouse lancer [--modele <m>] [--effort <e>] [--seance <id> | --reprise <id>] [--paquets <liste>] [--fiche <sorte>] <ticket> <rôle> <composant> <fichier de consigne>
|
|
7
7
|
#
|
|
8
8
|
# - <composant> is the component's path from the root (`packages/<nom>`, or `.` for the whole
|
|
9
9
|
# repository). It is judged before the copy is prepared, by the envelope's rule
|
|
@@ -91,7 +91,9 @@
|
|
|
91
91
|
# locks), its tools and the servers of the index, for the reading of the whole copy.
|
|
92
92
|
# - A role that ends on a sheet (scripts/resultats.mjs: the testwriter, the developpeur) runs with
|
|
93
93
|
# `--output-format json --json-schema <its schema>` (`npx grillhouse resultats --schema
|
|
94
|
-
# <rôle>`)
|
|
94
|
+
# <rôle>`); --fiche <sorte> names the schema of a sheet that is not its role's (`geste`, the
|
|
95
|
+
# explorateur's gesture of a mechanical ticket, grillhouse-sos), taking a value as --modele does:
|
|
96
|
+
# claude's JSON result, its sheet in `structured_output`, goes to
|
|
95
97
|
# .claude/worktrees/<ticket>.resultat.json, which a launch removes first and the circuit reads,
|
|
96
98
|
# then to the log; its errors go to the log.
|
|
97
99
|
# - Its output, and an envelope refusal (CODE_REFUS), are added to .claude/worktrees/<ticket>.log,
|
|
@@ -111,12 +113,12 @@
|
|
|
111
113
|
set -euo pipefail
|
|
112
114
|
ici="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
113
115
|
eval "$(node "$ici/codes.mjs")"
|
|
114
|
-
usage="usage: npx grillhouse lancer [--modele <m>] [--effort <e>] [--seance <id> | --reprise <id>] [--paquets <liste>] <ticket> <rôle> <composant> <fichier de consigne>"
|
|
116
|
+
usage="usage: npx grillhouse lancer [--modele <m>] [--effort <e>] [--seance <id> | --reprise <id>] [--paquets <liste>] [--fiche <sorte>] <ticket> <rôle> <composant> <fichier de consigne>"
|
|
115
117
|
refus_usage() { echo "$usage" >&2; exit "$CODE_USAGE"; }
|
|
116
|
-
modele="" effort="" seance="" reprise="" liste="" surcharge=()
|
|
118
|
+
modele="" effort="" seance="" reprise="" liste="" sorte="" surcharge=()
|
|
117
119
|
while [ $# -gt 0 ]; do
|
|
118
120
|
case "$1" in
|
|
119
|
-
--modele|--effort|--seance|--reprise|--paquets)
|
|
121
|
+
--modele|--effort|--seance|--reprise|--paquets|--fiche)
|
|
120
122
|
[ $# -ge 2 ] && [ -n "$2" ] && [[ "$2" != --* ]] || refus_usage
|
|
121
123
|
if [ "$1" = --modele ]; then
|
|
122
124
|
modele=$2
|
|
@@ -126,6 +128,8 @@ while [ $# -gt 0 ]; do
|
|
|
126
128
|
reprise=$2
|
|
127
129
|
elif [ "$1" = --paquets ]; then
|
|
128
130
|
liste=$2
|
|
131
|
+
elif [ "$1" = --fiche ]; then
|
|
132
|
+
sorte=$2
|
|
129
133
|
else
|
|
130
134
|
case "$2" in low|medium|high|xhigh|max) effort=$2 ;; *) refus_usage ;; esac
|
|
131
135
|
fi
|
|
@@ -260,7 +264,7 @@ mapfile -t droits_du_role <<<"$droits"
|
|
|
260
264
|
# The schema of the role's end-of-session sheet (scripts/resultats.mjs), for a role that has one:
|
|
261
265
|
# the session ends on it, which claude writes in its JSON result, on the standard output.
|
|
262
266
|
fiche=()
|
|
263
|
-
schema=$(node "$ici/../resultats.mjs" --schema "$role" 2> /dev/null) || schema=
|
|
267
|
+
schema=$(node "$ici/../resultats.mjs" --schema "${sorte:-$role}" 2> /dev/null) || schema=
|
|
264
268
|
[ -z "$schema" ] || fiche=(--output-format json --json-schema "$schema")
|
|
265
269
|
|
|
266
270
|
# An envelope in error does not stop the launcher (set -e): its code is kept for the exit.
|
package/scripts/etapes.mjs
CHANGED
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
// The plan (1) is read elsewhere in the state: by the work on the plan under way
|
|
14
14
|
// (`questionnement`, the explorateur's or the questionneur's session) and by its stop (`arrets`).
|
|
15
15
|
// The tri of the discoveries (5.3) is the explorateur's too, once the queue has brought the lot
|
|
16
|
-
// onto main, as Chromium and Mozilla give each new report a verdict before it is filed; the
|
|
17
|
-
//
|
|
16
|
+
// onto main, as Chromium and Mozilla give each new report a verdict before it is filed; so is the
|
|
17
|
+
// gesture of a mechanical ticket (1.1), the command its plan names played in the copy, as Rosie
|
|
18
|
+
// and ClangMR let a tool make a large-scale change at Google (grillhouse-sos); the role's own step
|
|
19
|
+
// stays the plan (`etapeDuRole`).
|
|
18
20
|
// SUITE is the tree in its order, each step before its sub-steps.
|
|
19
21
|
// - A step carries as many bounded loops as it needs (`boucles`), each spanning the step and its
|
|
20
22
|
// sub-steps: each its key (`cle`, which keys its count in the state's `boucles`), its label and
|
|
@@ -46,6 +48,9 @@ export const ETAPES = [
|
|
|
46
48
|
etat: null,
|
|
47
49
|
questionnement: 'plan',
|
|
48
50
|
arrets: ['questionnement'],
|
|
51
|
+
// The gesture of a mechanical ticket, in the copy, in place of the testwriter and the
|
|
52
|
+
// developpeur (grillhouse-sos).
|
|
53
|
+
sous: [{ numero: '1.1', titre: 'Geste mécanique', qui: [EXPLORATEUR], etat: 'geste' }],
|
|
49
54
|
},
|
|
50
55
|
{
|
|
51
56
|
numero: '2',
|
|
@@ -203,10 +208,10 @@ export const GESTES = [
|
|
|
203
208
|
{
|
|
204
209
|
genre: 'regeneration',
|
|
205
210
|
geste:
|
|
206
|
-
'à la régénération des références (4.2), puis la passe
|
|
211
|
+
'à la régénération des références (4.2), puis la passe qui juge l’arbre régénéré : après les contrôles, les contrôles du plan encore quand d’autres rouges s’y mêlent, sinon la passe finale qui est due ; après une passe finale, la passe finale restreinte à ce qu’elle change',
|
|
207
212
|
regle:
|
|
208
|
-
'un rouge de la passe finale est celui d’une référence, même mêlé à d’autres
|
|
209
|
-
cas: 'BP 320.9 : 292 min autour des références, dont 163 min d’attente pour régénérer à la main l’index des interfaces, le plafond et l’empreinte, des rouges de références mêlés à d’autres ; BP 320.3.9 : le plafond rouge aux contrôles, laissé à une passe finale qui rejoue les mêmes tests sur le même arbre (6,1 min)',
|
|
213
|
+
'un rouge des contrôles du plan ou de la passe finale est celui d’une référence, même mêlé à d’autres : une que le projet déclare (`grillhouse.references`), ou un fichier que le cadre engendre (l’index des interfaces, les fichiers que le module du langage engendre) ; ou la passe abaisse la dette des gardes (`dette.mjs --abaisser`, depuis ses notes)',
|
|
214
|
+
cas: 'BP 320.9 : 292 min autour des références, dont 163 min d’attente pour régénérer à la main l’index des interfaces, le plafond et l’empreinte, des rouges de références mêlés à d’autres ; BP 320.3.9 : le plafond rouge aux contrôles, laissé à une passe finale qui rejoue les mêmes tests sur le même arbre (6,1 min) ; BP 320.6.5 : un test qui lit les références des paquets, rouge à côté de leur garde, envoyé au développeur, qui n’a rien à livrer puis ne peut pas les écrire',
|
|
210
215
|
},
|
|
211
216
|
{
|
|
212
217
|
genre: 'rien-a-livrer',
|
|
@@ -215,6 +220,14 @@ export const GESTES = [
|
|
|
215
220
|
'un développeur qui ne change aucun fichier du plan n’a rien à livrer quand les contrôles sont verts ; rouges, l’arrêt monte (sans-livraison) ; sur le lot que l’intégration refuse, pour un développeur que --depuis developpeur lance, le geste ne joue pas : il est relancé une fois avec le refus',
|
|
216
221
|
cas: 'BP 320.9 : 995-tools n’a rien à livrer, 4 montées et 49 min (B5)',
|
|
217
222
|
},
|
|
223
|
+
{
|
|
224
|
+
genre: 'mecanique',
|
|
225
|
+
geste:
|
|
226
|
+
'ni testwriter, ni preuve du rouge, ni développeur : l’explorateur joue dans la copie la commande que le plan nomme (1.1), puis les contrôles, la passe finale, la relecture et l’intégration',
|
|
227
|
+
regle:
|
|
228
|
+
'le plan dit le ticket mécanique, avec sa raison et sa commande (`sorte` de la fiche de l’explorateur) : un geste sans comportement neuf ; tant qu’aucun testwriter ni développeur n’a travaillé le lot, un rouge des contrôles ou un RENDU monte, sans relancer personne',
|
|
229
|
+
cas: 'BP 320.16 : 38 outils déplacés par mv, 117 commentaires ; BP 320.40.1 : une variable inutilisée, 4 séances ; BP 322.11.1 : l’outil de test monté sur 31 paquets',
|
|
230
|
+
},
|
|
218
231
|
];
|
|
219
232
|
|
|
220
233
|
// The gesture of name <genre>, or null.
|
|
@@ -247,11 +260,11 @@ export const MONTEES = Object.fromEntries(
|
|
|
247
260
|
preuve:
|
|
248
261
|
'La troisième preuve du rouge refuse le lot de tests : quel contexte donner au testwriter, ou le plan doit-il changer ?',
|
|
249
262
|
controles:
|
|
250
|
-
'Un rouge reste, que le circuit ne rend pas au développeur (hors du plan, sans fichier, à arbitrer), ou que trois séances n’ont pas levé : avec quel contexte le lever, ou le plan doit-il s’étendre ?',
|
|
263
|
+
'Un rouge reste, que le circuit ne rend pas au développeur (hors du plan, sans fichier, à arbitrer, le lot d’un geste mécanique), ou que trois séances n’ont pas levé : avec quel contexte le lever, ou le plan doit-il s’étendre ?',
|
|
251
264
|
'sans-livraison':
|
|
252
|
-
'Le développeur ne change rien et le rouge reste : avec quel contexte le lever, ou le plan doit-il changer ?',
|
|
265
|
+
'Le développeur ne change rien et le rouge reste, ou le geste mécanique ne change aucun fichier du plan : avec quel contexte le lever, ou le plan doit-il changer ?',
|
|
253
266
|
'relecture-arret':
|
|
254
|
-
'La relecture ne rend pas le lot à un agent (un constat sans destinataire valide, un constat au testwriter que le plan saute, un critère en cause, ou la troisième relecture rendue) : que devient le plan, et qui reprend ?',
|
|
267
|
+
'La relecture ne rend pas le lot à un agent (un constat sans destinataire valide, un constat au testwriter que le plan saute, un lot mécanique rendu, un critère en cause, ou la troisième relecture rendue) : que devient le plan, et qui reprend ?',
|
|
255
268
|
integration:
|
|
256
269
|
'L’intégration refuse le lot, ou la file rouvre le ticket : que corrige le lot, et qui le reprend ?',
|
|
257
270
|
'hors-portee':
|
|
@@ -486,24 +486,25 @@ function installerLesBinairesDe(projet, langage) {
|
|
|
486
486
|
|
|
487
487
|
/**
|
|
488
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
|
|
489
|
+
* each once) whose output the project holds (every one with `tous`, for a project `grillhouse init` creates;
|
|
490
|
+
* every one of the module <langage>, for the first package of a language `grillhouse paquet` creates);
|
|
490
491
|
* returns the lines of failure.
|
|
491
492
|
*/
|
|
492
|
-
export function regenerer(projet, { tous = false } = {}) {
|
|
493
|
+
export function regenerer(projet, { tous = false, langage = null } = {}) {
|
|
493
494
|
const lignes = [];
|
|
494
495
|
const grillhouse = path.join(projet, 'node_modules', '.bin', 'grillhouse');
|
|
495
496
|
const aPaquets = lireJson(path.join(projet, 'package.json'), {})?.workspaces !== undefined;
|
|
496
497
|
const vus = new Set();
|
|
497
|
-
for (const g of langagesDe(projet).flatMap(m =>
|
|
498
|
+
for (const { g, m } of langagesDe(projet).flatMap(m =>
|
|
499
|
+
m.miseAJour.generateurs.map(g => ({ g, m }))
|
|
500
|
+
)) {
|
|
498
501
|
const cle = JSON.stringify([g.commande, ...g.args]);
|
|
499
|
-
|
|
502
|
+
const absente =
|
|
503
|
+
g.sortie !== null && !tous && m.nom !== langage && !existsSync(path.join(projet, g.sortie));
|
|
504
|
+
if (vus.has(cle) || (g.sortie === null ? !aPaquets : absente)) {
|
|
500
505
|
continue;
|
|
501
506
|
}
|
|
502
507
|
vus.add(cle);
|
|
503
|
-
const absente = g.sortie !== null && !tous && !existsSync(path.join(projet, g.sortie));
|
|
504
|
-
if (g.sortie === null ? !aPaquets : absente) {
|
|
505
|
-
continue;
|
|
506
|
-
}
|
|
507
508
|
if (g.sortie !== null) {
|
|
508
509
|
mkdirSync(path.dirname(path.join(projet, g.sortie)), { recursive: true });
|
|
509
510
|
}
|
|
@@ -548,7 +549,7 @@ export function rapport(b) {
|
|
|
548
549
|
|
|
549
550
|
// Whether the bilan <b> of `mettreAJour` asks for `npm install` (a tool or what the language's
|
|
550
551
|
// share declares), which the verification needs first.
|
|
551
|
-
const aInstaller = b => b.dependances.length > 0 || b.duLangage.installer;
|
|
552
|
+
export const aInstaller = b => b.dependances.length > 0 || b.duLangage.installer;
|
|
552
553
|
|
|
553
554
|
// The project's verification, the last step of the update (see the header): `{ code, ligne,
|
|
554
555
|
// erreur }`, the code of `npm run verifier` (null when it is not played), the line of the report,
|
package/scripts/jointure.d.ts
CHANGED
|
@@ -256,6 +256,24 @@ export interface Langage extends Composition {
|
|
|
256
256
|
* several languages (scripts/index-interfaces.mjs). */
|
|
257
257
|
entreesDeLIndex(racine: string): { rel: string; lignes: string[] }[];
|
|
258
258
|
miseAJour: MiseAJour;
|
|
259
|
+
/** The skeleton of a new package of this language at `chemin` (from the root) of the project at
|
|
260
|
+
* `racine`, without behaviour nor test, as `cargo new --lib` or `nx g @nx/js:lib` writes one
|
|
261
|
+
* (`grillhouse paquet`, scripts/paquet.mjs): `fichiers`, each file of the package from the root
|
|
262
|
+
* and its text (its manifest, the configuration of its tests and of its typing, a file of code,
|
|
263
|
+
* its folder of tests), which the core writes where absent; `espace`, the manifest of the
|
|
264
|
+
* workspace with the package's entry, from the root and its new text, null when it holds it
|
|
265
|
+
* already; `verrouiller`, the command, run in `dossier` (from the root), that brings the lock of
|
|
266
|
+
* the versions in line with the new package. `modele`: the package.json of the module's template
|
|
267
|
+
* (`miseAJour.gabarit`), the versions of its tools. Throws, named, for a path where the module
|
|
268
|
+
* holds no package. */
|
|
269
|
+
squelette(
|
|
270
|
+
racine: string,
|
|
271
|
+
o: { chemin: string; modele: Record<string, unknown> }
|
|
272
|
+
): {
|
|
273
|
+
fichiers: Record<string, string>;
|
|
274
|
+
espace: { fichier: string; texte: string } | null;
|
|
275
|
+
verrouiller: { commande: string; args: string[]; dossier: string };
|
|
276
|
+
};
|
|
259
277
|
}
|
|
260
278
|
|
|
261
279
|
/** The frame's languages, each its module. */
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
// languages. No migration yet.
|
|
31
31
|
// - Its share of the update (./mise-a-jour.mjs, `miseAJour`): the template of a project of cargo
|
|
32
32
|
// (`templates/cargo/`) and its test scripts.
|
|
33
|
+
// - The skeleton of a new crate (./squelette.mjs, `squelette`), which `grillhouse paquet` writes.
|
|
33
34
|
import { readFileSync } from 'node:fs';
|
|
34
35
|
import path from 'node:path';
|
|
35
36
|
import { fileURLToPath } from 'node:url';
|
|
@@ -46,6 +47,7 @@ import {
|
|
|
46
47
|
import { elementsDuLot } from './elements-du-lot.mjs';
|
|
47
48
|
import { enRetard, entreesDeLIndex, SORTIE } from './index-interfaces.mjs';
|
|
48
49
|
import { miseAJour } from './mise-a-jour.mjs';
|
|
50
|
+
import { squelette } from './squelette.mjs';
|
|
49
51
|
import { CACHE } from './sccache.mjs';
|
|
50
52
|
import { touches } from './touches.mjs';
|
|
51
53
|
import { verdict } from './verdict.mjs';
|
|
@@ -120,4 +122,5 @@ export default {
|
|
|
120
122
|
gardes: () => GARDES.map(({ script, args }) => [script, ...args]),
|
|
121
123
|
migrations: [],
|
|
122
124
|
miseAJour,
|
|
125
|
+
squelette,
|
|
123
126
|
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// The skeleton of a new crate of the module cargo, the demand `squelette` of the join
|
|
2
|
+
// (scripts/jointure.d.ts), which `grillhouse paquet` writes (scripts/paquet.mjs), as `cargo new
|
|
3
|
+
// --lib` writes one and adds it to the members of the workspace: no behaviour, no test.
|
|
4
|
+
//
|
|
5
|
+
// - Its files: its Cargo.toml (its name, the folder's; each field of `[workspace.package]` the
|
|
6
|
+
// workspace holds inherited, `<champ>.workspace = true`, as `cargo new` inherits them in a
|
|
7
|
+
// workspace, else its version 0.1.0 and its edition 2021; `[lints] workspace = true` when the
|
|
8
|
+
// workspace has `[workspace.lints]`); `src/lib.rs`, a library without code; `tests/.gitkeep`, its
|
|
9
|
+
// folder of tests by the interface. Cargo needs no configuration of its own for the tests
|
|
10
|
+
// (nextest, the frame's profile) nor for the typing (`cargo check`, clippy).
|
|
11
|
+
// - The workspace: the root Cargo.toml receives the crate's path in `members` of `[workspace]`,
|
|
12
|
+
// written in its text, the rest of the file as it was; a root without `members` receives the
|
|
13
|
+
// key, a root package without `[workspace]` the table, and a project without a root Cargo.toml a
|
|
14
|
+
// virtual workspace. A member or a pattern that covers the path leaves it as it is.
|
|
15
|
+
// - The lock of the versions: `cargo update --workspace`, at the root, which brings Cargo.lock in
|
|
16
|
+
// line with the members alone.
|
|
17
|
+
// - The manifest is read with smol-toml, the tool of this module (`outils`), loaded at the call.
|
|
18
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
19
|
+
import { createRequire } from 'node:module';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
|
|
22
|
+
const require = createRequire(import.meta.url);
|
|
23
|
+
|
|
24
|
+
// The fields of a package cargo inherits from `[workspace.package]`, in the order `cargo new`
|
|
25
|
+
// writes them.
|
|
26
|
+
const HERITES = [
|
|
27
|
+
'version',
|
|
28
|
+
'edition',
|
|
29
|
+
'rust-version',
|
|
30
|
+
'authors',
|
|
31
|
+
'description',
|
|
32
|
+
'documentation',
|
|
33
|
+
'readme',
|
|
34
|
+
'homepage',
|
|
35
|
+
'repository',
|
|
36
|
+
'license',
|
|
37
|
+
'license-file',
|
|
38
|
+
'keywords',
|
|
39
|
+
'categories',
|
|
40
|
+
'publish',
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
// The text <texte> of a root Cargo.toml with <chemin> added to `members` of `[workspace]`.
|
|
44
|
+
function ajouterLeMembre(texte, chemin) {
|
|
45
|
+
const entree = JSON.stringify(chemin);
|
|
46
|
+
const lignes = texte.split('\n');
|
|
47
|
+
const debut = lignes.findIndex(l => /^\s*\[workspace\]\s*(#.*)?$/.test(l));
|
|
48
|
+
if (debut < 0) {
|
|
49
|
+
const fin = texte.endsWith('\n') ? '' : '\n';
|
|
50
|
+
return `${texte}${fin}\n[workspace]\nmembers = [${entree}]\n`;
|
|
51
|
+
}
|
|
52
|
+
let fin = lignes.findIndex((l, i) => i > debut && /^\s*\[/.test(l));
|
|
53
|
+
if (fin < 0) {
|
|
54
|
+
fin = lignes.length;
|
|
55
|
+
}
|
|
56
|
+
const section = lignes.slice(debut + 1, fin).join('\n');
|
|
57
|
+
const m = /^(\s*members\s*=\s*\[)([\s\S]*?)(\])/m.exec(section);
|
|
58
|
+
let nouvelle;
|
|
59
|
+
if (!m) {
|
|
60
|
+
nouvelle = `members = [${entree}]\n${section}`;
|
|
61
|
+
} else if (m[2].includes('\n')) {
|
|
62
|
+
const corps = m[2].replace(/\s*$/, '');
|
|
63
|
+
const virgule = corps.trim() === '' || corps.trim().endsWith(',') ? '' : ',';
|
|
64
|
+
nouvelle = section.replace(m[0], `${m[1]}${corps}${virgule}\n ${entree},\n${m[3]}`);
|
|
65
|
+
} else {
|
|
66
|
+
const corps = m[2].trim().replace(/,$/, '');
|
|
67
|
+
nouvelle = section.replace(m[0], `${m[1]}${corps ? `${corps}, ` : ''}${entree}${m[3]}`);
|
|
68
|
+
}
|
|
69
|
+
return [...lignes.slice(0, debut + 1), nouvelle, ...lignes.slice(fin)].join('\n');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** @type {import('../../jointure.js').Langage['squelette']} */
|
|
73
|
+
export function squelette(racine, { chemin }) {
|
|
74
|
+
const nom = path.posix.basename(chemin);
|
|
75
|
+
const f = path.join(racine, 'Cargo.toml');
|
|
76
|
+
const texte = existsSync(f) ? readFileSync(f, 'utf8') : null;
|
|
77
|
+
const espace = texte === null ? null : (require('smol-toml').parse(texte).workspace ?? null);
|
|
78
|
+
const herites = HERITES.filter(c => espace?.package?.[c] !== undefined);
|
|
79
|
+
const paquet = [
|
|
80
|
+
'[package]',
|
|
81
|
+
`name = ${JSON.stringify(nom)}`,
|
|
82
|
+
...(herites.includes('version') ? [] : ['version = "0.1.0"']),
|
|
83
|
+
...(herites.includes('edition') ? [] : ['edition = "2021"']),
|
|
84
|
+
...herites.map(c => `${c}.workspace = true`),
|
|
85
|
+
...(espace?.lints ? ['', '[lints]', 'workspace = true'] : []),
|
|
86
|
+
'',
|
|
87
|
+
'[dependencies]',
|
|
88
|
+
'',
|
|
89
|
+
].join('\n');
|
|
90
|
+
const fichiers = {
|
|
91
|
+
[`${chemin}/Cargo.toml`]: paquet,
|
|
92
|
+
[`${chemin}/src/lib.rs`]: `//! The crate ${nom}: its interface, docs/INTERFACE.md, says what it offers.\n`,
|
|
93
|
+
[`${chemin}/tests/.gitkeep`]: '',
|
|
94
|
+
};
|
|
95
|
+
const membres = Array.isArray(espace?.members) ? espace.members : [];
|
|
96
|
+
const couvert = membres.some(m => typeof m === 'string' && path.matchesGlob(chemin, m));
|
|
97
|
+
let entree = null;
|
|
98
|
+
if (texte === null) {
|
|
99
|
+
entree = {
|
|
100
|
+
fichier: 'Cargo.toml',
|
|
101
|
+
texte: `[workspace]\nmembers = [${JSON.stringify(chemin)}]\nresolver = "2"\n`,
|
|
102
|
+
};
|
|
103
|
+
} else if (!couvert) {
|
|
104
|
+
entree = { fichier: 'Cargo.toml', texte: ajouterLeMembre(texte, chemin) };
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
fichiers,
|
|
108
|
+
espace: entree,
|
|
109
|
+
verrouiller: { commande: 'cargo', args: ['update', '--workspace'], dossier: '.' },
|
|
110
|
+
};
|
|
111
|
+
}
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
// No migration yet.
|
|
28
28
|
// - Its share of the update (./mise-a-jour.mjs): the template `templates/python/`, its test
|
|
29
29
|
// scripts, the generator of the index and the installation of uv.
|
|
30
|
+
// - The skeleton of a new package (./squelette.mjs, `squelette`), which `grillhouse paquet` writes.
|
|
30
31
|
import { readFileSync } from 'node:fs';
|
|
31
32
|
import path from 'node:path';
|
|
32
33
|
import { fileURLToPath } from 'node:url';
|
|
@@ -43,6 +44,7 @@ import {
|
|
|
43
44
|
import { enRetard, SORTIE } from './index-interfaces.mjs';
|
|
44
45
|
import { elementsDuLot, touches } from './lot.mjs';
|
|
45
46
|
import { miseAJour } from './mise-a-jour.mjs';
|
|
47
|
+
import { squelette } from './squelette.mjs';
|
|
46
48
|
import { verdict } from './verdict.mjs';
|
|
47
49
|
|
|
48
50
|
const ici = nom => path.join(path.dirname(fileURLToPath(import.meta.url)), nom);
|
|
@@ -91,4 +93,5 @@ export default {
|
|
|
91
93
|
gardes: () => GARDES.map(({ script, args }) => [script, ...args]),
|
|
92
94
|
migrations: [],
|
|
93
95
|
miseAJour,
|
|
96
|
+
squelette,
|
|
94
97
|
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// The skeleton of a new package of the module python, the demand `squelette` of the join
|
|
2
|
+
// (scripts/jointure.d.ts), which `grillhouse paquet` writes (scripts/paquet.mjs), as `uv init`
|
|
3
|
+
// writes one: no behaviour, no test.
|
|
4
|
+
//
|
|
5
|
+
// - Its files: its pyproject.toml (PEP 621: its name, the folder's, its version 0.1.0, the Python
|
|
6
|
+
// it requires, no dependency; its group `test` of `[dependency-groups]`, PEP 735, pytest, which
|
|
7
|
+
// the module runs by `uv run --group test pytest`; the configuration of pytest,
|
|
8
|
+
// `[tool.pytest.ini_options]`, its tests under `tests/` and its code importable from `src/`, as
|
|
9
|
+
// uv's layout of a library has it); `src/<module>/__init__.py`, the module named after the
|
|
10
|
+
// package (`-` read `_`), without code; `tests/.gitkeep`, its folder of tests. The typing is
|
|
11
|
+
// `python -m compileall`, which needs no configuration. No build system: uv neither builds nor
|
|
12
|
+
// installs the package to run its tests.
|
|
13
|
+
// - The workspace: a root pyproject.toml whose `[tool.uv.workspace]` names its `members` receives
|
|
14
|
+
// the package's path there, as `uv init` adds a project under a workspace to its members; without
|
|
15
|
+
// one, the package is its own project of uv, as the module plays each package (./commandes.mjs).
|
|
16
|
+
// - The lock of the versions: `uv lock`, at the workspace's root, else in the package.
|
|
17
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
18
|
+
import { createRequire } from 'node:module';
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
22
|
+
|
|
23
|
+
/** @type {import('../../jointure.js').Langage['squelette']} */
|
|
24
|
+
export function squelette(racine, { chemin }) {
|
|
25
|
+
const nom = path.posix.basename(chemin);
|
|
26
|
+
const module = nom.replace(/-/g, '_');
|
|
27
|
+
const manifeste = [
|
|
28
|
+
'[project]',
|
|
29
|
+
`name = ${JSON.stringify(nom)}`,
|
|
30
|
+
'version = "0.1.0"',
|
|
31
|
+
'requires-python = ">=3.12"',
|
|
32
|
+
'dependencies = []',
|
|
33
|
+
'',
|
|
34
|
+
'[dependency-groups]',
|
|
35
|
+
'test = ["pytest>=8"]',
|
|
36
|
+
'',
|
|
37
|
+
'[tool.pytest.ini_options]',
|
|
38
|
+
'testpaths = ["tests"]',
|
|
39
|
+
'pythonpath = ["src"]',
|
|
40
|
+
'',
|
|
41
|
+
].join('\n');
|
|
42
|
+
const fichiers = {
|
|
43
|
+
[`${chemin}/pyproject.toml`]: manifeste,
|
|
44
|
+
[`${chemin}/src/${module}/__init__.py`]: `"""The package ${nom}: its interface, docs/INTERFACE.md, says what it offers."""\n`,
|
|
45
|
+
[`${chemin}/tests/.gitkeep`]: '',
|
|
46
|
+
};
|
|
47
|
+
const f = path.join(racine, 'pyproject.toml');
|
|
48
|
+
const texte = existsSync(f) ? readFileSync(f, 'utf8') : null;
|
|
49
|
+
const espace =
|
|
50
|
+
texte === null ? null : (require('smol-toml').parse(texte).tool?.uv?.workspace ?? null);
|
|
51
|
+
const membres = Array.isArray(espace?.members) ? espace.members : null;
|
|
52
|
+
let entree = null;
|
|
53
|
+
if (membres && !membres.some(m => typeof m === 'string' && path.matchesGlob(chemin, m))) {
|
|
54
|
+
const m = /^(\s*members\s*=\s*\[)([\s\S]*?)(\])/m.exec(
|
|
55
|
+
texte.slice(texte.search(/^\s*\[tool\.uv\.workspace\]/m))
|
|
56
|
+
);
|
|
57
|
+
const corps = m[2].replace(/\s*$/, '').replace(/,$/, '');
|
|
58
|
+
const ajout = `${m[1]}${corps.trim() ? `${corps}, ` : ''}${JSON.stringify(chemin)}${m[3]}`;
|
|
59
|
+
entree = { fichier: 'pyproject.toml', texte: texte.replace(m[0], ajout) };
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
fichiers,
|
|
63
|
+
espace: entree,
|
|
64
|
+
verrouiller: { commande: 'uv', args: ['lock'], dossier: membres ? '.' : chemin },
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
// other option replaces the frame's at its first level, as the `extends` of dependency-cruiser does.
|
|
10
10
|
//
|
|
11
11
|
// npx grillhouse frontieres refuses a stale configuration, then runs dependency-cruiser
|
|
12
|
-
// npx grillhouse frontieres --ecrire writes the configuration
|
|
12
|
+
// npx grillhouse frontieres --ecrire writes the configuration, and `.dependency-cruiser.projet.cjs`
|
|
13
|
+
// empty when the project has none, so that knip resolves
|
|
14
|
+
// the require of the configuration (grillhouse-b32)
|
|
13
15
|
//
|
|
14
16
|
// The rules: no cycle; a package reaches another by its name, never by a path into its tree; a
|
|
15
17
|
// module of `src/` reaches another by its entry (`index`); the code of `src/` imports no test; the
|
|
@@ -46,6 +48,13 @@ import { CODE, horsCadre } from '../../paquets.mjs';
|
|
|
46
48
|
import { trancher } from '../../dette.mjs';
|
|
47
49
|
|
|
48
50
|
export const CONFIGURATION = '.dependency-cruiser.cjs';
|
|
51
|
+
// The project's own rules and options, which the configuration requires, and their text when
|
|
52
|
+
// `--ecrire` writes them for a project that has none.
|
|
53
|
+
const REGLES_DU_PROJET = '.dependency-cruiser.projet.cjs';
|
|
54
|
+
const REGLES_VIDES = `// The project's own rules and options of dependency-cruiser, which the generated
|
|
55
|
+
// ${CONFIGURATION} reads (\`npx grillhouse frontieres\`); written empty once, the project's own after.
|
|
56
|
+
module.exports = {};
|
|
57
|
+
`;
|
|
49
58
|
export const RACINES = ['src', 'packages'];
|
|
50
59
|
/** The test files, as a pattern of a path from the repository's root. */
|
|
51
60
|
export const TESTS = '(^|/)(test|tests|__tests__)/|[.](test|spec)[.][a-z]+$';
|
|
@@ -391,6 +400,10 @@ function frontieres(racine, args) {
|
|
|
391
400
|
const cible = path.join(racine, CONFIGURATION);
|
|
392
401
|
if (args.includes('--ecrire')) {
|
|
393
402
|
writeFileSync(cible, attendu);
|
|
403
|
+
const propres = path.join(racine, REGLES_DU_PROJET);
|
|
404
|
+
if (!existsSync(propres)) {
|
|
405
|
+
writeFileSync(propres, REGLES_VIDES);
|
|
406
|
+
}
|
|
394
407
|
return 0;
|
|
395
408
|
}
|
|
396
409
|
const present = existsSync(cible) ? readFileSync(cible, 'utf8') : '';
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
// - No binary of the machine (`binaires`); what its tools write in a project, `.turbo`
|
|
46
46
|
// (`ignorer`); its share of the update (./mise-a-jour.mjs, `miseAJour`): the tests by Vitest,
|
|
47
47
|
// the frame's package declared, the typing, the turbo.json, and the generators.
|
|
48
|
+
// - The skeleton of a new package (./squelette.mjs, `squelette`), which `grillhouse paquet` writes.
|
|
48
49
|
import { spawnSync } from 'node:child_process';
|
|
49
50
|
import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
50
51
|
import { createRequire } from 'node:module';
|
|
@@ -59,6 +60,7 @@ import { estUnTest, manifestes } from './regle-des-tests.mjs';
|
|
|
59
60
|
import { SCRIPT_DES_TESTS } from './script-des-tests.mjs';
|
|
60
61
|
import { verdict } from './verdict.mjs';
|
|
61
62
|
import { miseAJour } from './mise-a-jour.mjs';
|
|
63
|
+
import { squelette } from './squelette.mjs';
|
|
62
64
|
import * as configVitest from './migrations/0.23.0-config-vitest.mjs';
|
|
63
65
|
import * as nomsDeclaresInutilises from './migrations/0.24.4-noms-declares-inutilises.mjs';
|
|
64
66
|
import * as lignesMalFormees from './migrations/0.24.6-lignes-mal-formees.mjs';
|
|
@@ -330,4 +332,5 @@ export default {
|
|
|
330
332
|
cheminsDesTests,
|
|
331
333
|
],
|
|
332
334
|
miseAJour: miseAJour(joueDesTests),
|
|
335
|
+
squelette,
|
|
333
336
|
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// The skeleton of a new package of the module typescript, the demand `squelette` of the join
|
|
2
|
+
// (scripts/jointure.d.ts), which `grillhouse paquet` writes (scripts/paquet.mjs), as `nx g
|
|
3
|
+
// @nx/js:lib` and `turbo gen workspace` write one: no behaviour, no test.
|
|
4
|
+
//
|
|
5
|
+
// - A package of TypeScript lives under `packages/<nom>`, where the module finds its components
|
|
6
|
+
// (./composants.mjs); another path is refused, named.
|
|
7
|
+
// - Its files: its package.json (its name, the root's scope before the folder's name when the root's
|
|
8
|
+
// name has one, as Nx names a library after the workspace's scope; private; an ES module; its
|
|
9
|
+
// script `test:unit`, which makes it a package that plays tests, and the tools of its tests and
|
|
10
|
+
// of its typing the root does not declare, TypeScript, Vitest and Node's types, at the versions of
|
|
11
|
+
// the module's template); its tsconfig.json, which types its sources, its tests and its
|
|
12
|
+
// configuration, nothing emitted; its vitest.config.ts, the frame's base configuration by its
|
|
13
|
+
// name, which passes while the package has no test yet, as the configuration of a library that
|
|
14
|
+
// Nx generates (`passWithNoTests`); `src/index.ts`, an empty module; `tests/.gitkeep`, its folder
|
|
15
|
+
// of tests. The update gives it its script `typecheck` and the frame's package in its
|
|
16
|
+
// devDependencies (./mise-a-jour.mjs).
|
|
17
|
+
// - The workspace: the root package.json receives the package's path in its `workspaces` (created
|
|
18
|
+
// when the root has none), unless a pattern there covers it already.
|
|
19
|
+
// - The lock of the versions: `npm install`, at the root.
|
|
20
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
21
|
+
import path from 'node:path';
|
|
22
|
+
|
|
23
|
+
const CHAMPS = ['dependencies', 'devDependencies', 'optionalDependencies'];
|
|
24
|
+
// The tools of a package's tests and of its typing, at the versions of the module's template.
|
|
25
|
+
const OUTILS_DU_PAQUET = ['@types/node', 'typescript', 'vitest'];
|
|
26
|
+
|
|
27
|
+
const lireJson = f => (existsSync(f) ? JSON.parse(readFileSync(f, 'utf8')) : null);
|
|
28
|
+
const json = v => `${JSON.stringify(v, null, 2)}\n`;
|
|
29
|
+
|
|
30
|
+
const TSCONFIG = {
|
|
31
|
+
compilerOptions: {
|
|
32
|
+
target: 'ES2022',
|
|
33
|
+
lib: ['ES2022'],
|
|
34
|
+
module: 'Node16',
|
|
35
|
+
moduleResolution: 'Node16',
|
|
36
|
+
resolveJsonModule: true,
|
|
37
|
+
noEmit: true,
|
|
38
|
+
esModuleInterop: true,
|
|
39
|
+
forceConsistentCasingInFileNames: true,
|
|
40
|
+
isolatedModules: true,
|
|
41
|
+
strict: true,
|
|
42
|
+
noUnusedLocals: true,
|
|
43
|
+
noUnusedParameters: true,
|
|
44
|
+
noImplicitReturns: true,
|
|
45
|
+
noFallthroughCasesInSwitch: true,
|
|
46
|
+
noUncheckedIndexedAccess: true,
|
|
47
|
+
skipLibCheck: true,
|
|
48
|
+
},
|
|
49
|
+
include: ['src/**/*', 'tests/**/*', '*.ts'],
|
|
50
|
+
exclude: ['node_modules', 'dist'],
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const VITEST = `import { defineConfig, mergeConfig } from 'vitest/config';
|
|
54
|
+
import base from '@roomi-fields/grillhouse/vitest-config';
|
|
55
|
+
|
|
56
|
+
// The tests of the package: the frame's base configuration, by its name, extended with what is the
|
|
57
|
+
// package's own. It passes while the package has no test yet, as the configuration of a library
|
|
58
|
+
// that Nx generates; its first test plays as any other.
|
|
59
|
+
export default mergeConfig(
|
|
60
|
+
base,
|
|
61
|
+
defineConfig({
|
|
62
|
+
test: {
|
|
63
|
+
include: ['src/**/*.{test,spec}.{ts,js,mjs}', 'tests/**/*.{test,spec}.{ts,js,mjs}'],
|
|
64
|
+
passWithNoTests: true,
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
);
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
/** @type {import('../../jointure.js').Langage['squelette']} */
|
|
71
|
+
export function squelette(racine, { chemin, modele }) {
|
|
72
|
+
if (!/^packages\/[^/]+$/.test(chemin)) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
`${chemin} : un paquet typescript vit sous packages/<nom>, où le module trouve ses composants.`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
const racinePkg = lireJson(path.join(racine, 'package.json')) ?? {};
|
|
78
|
+
const nom = path.posix.basename(chemin);
|
|
79
|
+
const portee = /^(@[^/]+)\//.exec(String(racinePkg.name ?? ''))?.[1];
|
|
80
|
+
const declare = n => CHAMPS.some(c => racinePkg[c]?.[n] !== undefined);
|
|
81
|
+
const versions = modele.devDependencies ?? {};
|
|
82
|
+
const devDependencies = Object.fromEntries(
|
|
83
|
+
OUTILS_DU_PAQUET.filter(n => !declare(n) && typeof versions[n] === 'string').map(n => [
|
|
84
|
+
n,
|
|
85
|
+
versions[n],
|
|
86
|
+
])
|
|
87
|
+
);
|
|
88
|
+
const pkg = {
|
|
89
|
+
name: portee ? `${portee}/${nom}` : nom,
|
|
90
|
+
version: '0.0.0',
|
|
91
|
+
private: true,
|
|
92
|
+
type: 'module',
|
|
93
|
+
scripts: { 'test:unit': 'vitest run' },
|
|
94
|
+
...(Object.keys(devDependencies).length ? { devDependencies } : {}),
|
|
95
|
+
};
|
|
96
|
+
const fichiers = {
|
|
97
|
+
[`${chemin}/package.json`]: json(pkg),
|
|
98
|
+
[`${chemin}/tsconfig.json`]: json(TSCONFIG),
|
|
99
|
+
[`${chemin}/vitest.config.ts`]: VITEST,
|
|
100
|
+
[`${chemin}/src/index.ts`]: `// The entry of the package ${nom}: its interface, docs/INTERFACE.md, says what it exports.\nexport {};\n`,
|
|
101
|
+
[`${chemin}/tests/.gitkeep`]: '',
|
|
102
|
+
};
|
|
103
|
+
const espaces = Array.isArray(racinePkg.workspaces)
|
|
104
|
+
? racinePkg.workspaces
|
|
105
|
+
: (racinePkg.workspaces?.packages ?? null);
|
|
106
|
+
const couvert = (espaces ?? []).some(
|
|
107
|
+
m => typeof m === 'string' && !m.startsWith('!') && path.matchesGlob(chemin, m)
|
|
108
|
+
);
|
|
109
|
+
let espace = null;
|
|
110
|
+
if (!couvert) {
|
|
111
|
+
const p = { ...racinePkg };
|
|
112
|
+
if (Array.isArray(p.workspaces) || p.workspaces === undefined) {
|
|
113
|
+
p.workspaces = [...(p.workspaces ?? []), chemin];
|
|
114
|
+
} else {
|
|
115
|
+
p.workspaces = { ...p.workspaces, packages: [...(p.workspaces.packages ?? []), chemin] };
|
|
116
|
+
}
|
|
117
|
+
espace = { fichier: 'package.json', texte: json(p) };
|
|
118
|
+
}
|
|
119
|
+
return { fichiers, espace, verrouiller: { commande: 'npm', args: ['install'], dossier: '.' } };
|
|
120
|
+
}
|
|
@@ -50,7 +50,7 @@ function langageDeLInterface(dossier) {
|
|
|
50
50
|
if (!existsSync(f)) {
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
|
-
const m = readFileSync(f, 'utf8').match(/^\*\*
|
|
53
|
+
const m = readFileSync(f, 'utf8').match(/^\*\*Langu?age\*\*\s*:\s*(.+)$/m);
|
|
54
54
|
return m ? langageDeLaCellule(m[1]) || null : null;
|
|
55
55
|
}
|
|
56
56
|
|