@roomi-fields/grillhouse 0.24.15 → 0.25.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.
Files changed (125) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/grillhouse.mjs +40 -12
  3. package/cadre/templates/cargo/.config/nextest.toml +8 -0
  4. package/cadre/templates/cargo/deny.toml +41 -0
  5. package/cadre/templates/cargo/package.json +15 -0
  6. package/cadre/templates/cargo/rust-toolchain.toml +6 -0
  7. package/cadre/templates/projet/package.json +5 -1
  8. package/cadre/templates/turbo/paquets.json +1 -1
  9. package/cadre/templates/turbo/sans-paquets.json +1 -1
  10. package/charte.md +16 -0
  11. package/docs/ARCHITECTURE.md +160 -56
  12. package/docs/CADRE.md +47 -0
  13. package/docs/INTERFACE.md +176 -0
  14. package/package.json +66 -13
  15. package/scripts/arbitrages.mjs +23 -0
  16. package/scripts/avancement.mjs +15 -29
  17. package/scripts/circuit.mjs +89 -97
  18. package/scripts/commande-du-langage.mjs +56 -0
  19. package/scripts/composants-affectes.mjs +47 -170
  20. package/scripts/conformite.d.ts +27 -0
  21. package/scripts/conformite.mjs +226 -0
  22. package/scripts/demon.mjs +1 -1
  23. package/scripts/dernier-vert.mjs +11 -9
  24. package/scripts/droits.mjs +27 -21
  25. package/scripts/enveloppe/enveloppe.mjs +206 -64
  26. package/scripts/enveloppe/lancer.sh +20 -91
  27. package/scripts/enveloppe/paquets-du-plan.mjs +24 -2
  28. package/scripts/etapes.mjs +2 -2
  29. package/scripts/gardes-du-cadre.mjs +12 -18
  30. package/scripts/grillhouse-maj.mjs +246 -389
  31. package/scripts/init.mjs +2 -1
  32. package/scripts/integration/file.mjs +3 -3
  33. package/scripts/integration/integrer.mjs +13 -10
  34. package/scripts/integration/rejeu.mjs +36 -7
  35. package/scripts/jointure.d.ts +304 -0
  36. package/scripts/langages/cargo/binaires.json +4 -0
  37. package/scripts/langages/cargo/binaires.mjs +60 -0
  38. package/scripts/langages/cargo/clippy.mjs +103 -0
  39. package/scripts/langages/cargo/commandes.mjs +378 -0
  40. package/scripts/langages/cargo/composants.mjs +191 -0
  41. package/scripts/langages/cargo/elements-du-lot.mjs +139 -0
  42. package/scripts/langages/cargo/exemples.mjs +357 -0
  43. package/scripts/langages/cargo/frontieres.mjs +84 -0
  44. package/scripts/langages/cargo/index-interfaces.mjs +138 -0
  45. package/scripts/langages/cargo/index.mjs +115 -0
  46. package/scripts/langages/cargo/mise-a-jour.mjs +93 -0
  47. package/scripts/langages/cargo/nextest.toml +5 -0
  48. package/scripts/langages/cargo/touches.mjs +93 -0
  49. package/scripts/langages/cargo/verdict.mjs +85 -0
  50. package/scripts/langages/typescript/chemins-des-tests.mjs +68 -0
  51. package/scripts/{code-mort.mjs → langages/typescript/code-mort.mjs} +5 -5
  52. package/scripts/langages/typescript/composants.mjs +64 -0
  53. package/scripts/{consommateurs-arbitres.mjs → langages/typescript/consommateurs-arbitres.mjs} +6 -24
  54. package/scripts/{consommateurs.mjs → langages/typescript/consommateurs.mjs} +13 -71
  55. package/scripts/langages/typescript/construire.mjs +176 -0
  56. package/scripts/{elements-du-lot.mjs → langages/typescript/elements-du-lot.mjs} +2 -2
  57. package/scripts/langages/typescript/exemples.mjs +289 -0
  58. package/scripts/{frontieres.mjs → langages/typescript/frontieres.mjs} +3 -5
  59. package/scripts/{index-interfaces.mjs → langages/typescript/index-interfaces.mjs} +3 -3
  60. package/scripts/langages/typescript/index.mjs +335 -0
  61. package/scripts/{interfaces-contre-code.mjs → langages/typescript/interfaces-contre-code.mjs} +2 -2
  62. package/scripts/langages/typescript/lecteurs.mjs +179 -0
  63. package/scripts/{migrations → langages/typescript/migrations}/0.23.0-config-vitest.mjs +14 -29
  64. package/scripts/{migrations → langages/typescript/migrations}/0.24.4-noms-declares-inutilises.mjs +2 -2
  65. package/scripts/{migrations → langages/typescript/migrations}/0.24.6-lignes-mal-formees.mjs +2 -2
  66. package/scripts/{migrations → langages/typescript/migrations}/0.24.7-matiere-dans-les-tests.mjs +2 -2
  67. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +27 -0
  68. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +31 -0
  69. package/scripts/langages/typescript/mise-a-jour.mjs +320 -0
  70. package/scripts/{references-par-les-types.mjs → langages/typescript/references-par-les-types.mjs} +3 -3
  71. package/scripts/langages/typescript/regle-des-tests.mjs +39 -0
  72. package/scripts/{resumes.mjs → langages/typescript/resumes.mjs} +4 -4
  73. package/scripts/langages/typescript/script-des-tests.mjs +6 -0
  74. package/scripts/langages/typescript/tailles-des-tests.mjs +219 -0
  75. package/scripts/langages/typescript/tests-de-nuit.mjs +57 -0
  76. package/scripts/{tests.mjs → langages/typescript/tests.mjs} +41 -32
  77. package/scripts/{turbo-des-paquets.mjs → langages/typescript/turbo-des-paquets.mjs} +49 -23
  78. package/scripts/langages/typescript/verdict.mjs +105 -0
  79. package/scripts/{verifier.mjs → langages/typescript/verifier.mjs} +53 -34
  80. package/scripts/{vitest-config → langages/typescript/vitest-config}/avancement.reporter.mjs +10 -2
  81. package/scripts/{vitest-config → langages/typescript/vitest-config}/base.mjs +63 -9
  82. package/scripts/{vitest-config → langages/typescript/vitest-config}/changements.mjs +18 -11
  83. package/scripts/{vitest-config → langages/typescript/vitest-config}/cibles.mjs +7 -6
  84. package/scripts/langages/typescript/vitest-config/duree.reporter.d.ts +10 -0
  85. package/scripts/{vitest-config → langages/typescript/vitest-config}/duree.reporter.mjs +10 -3
  86. package/scripts/langages/typescript/vitest-config/lances.mjs +473 -0
  87. package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.setup.mjs +1 -1
  88. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.mjs +5 -5
  89. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.setup.mjs +4 -3
  90. package/scripts/{vitest.nuit.config.mjs → langages/typescript/vitest.nuit.config.mjs} +2 -2
  91. package/scripts/langages.mjs +85 -0
  92. package/scripts/{vitest-config → mesure}/avancement.mjs +4 -13
  93. package/scripts/{vitest-config → mesure}/base-de-passe.mjs +70 -33
  94. package/scripts/{vitest-config → mesure}/pression.mjs +5 -6
  95. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +29 -6
  96. package/scripts/migrations/0.24.0-circuit-simplifie.mjs +13 -6
  97. package/scripts/migrations/0.25.0-script-des-tests.mjs +92 -0
  98. package/scripts/migrations.mjs +17 -13
  99. package/scripts/nuit.sh +59 -63
  100. package/scripts/paquets.d.ts +5 -0
  101. package/scripts/paquets.mjs +24 -2
  102. package/scripts/resultats.mjs +8 -82
  103. package/scripts/services-du-noyau.mjs +30 -0
  104. package/scripts/session-start.sh +17 -9
  105. package/scripts/sources.mjs +35 -13
  106. package/scripts/sous-commandes.mjs +57 -17
  107. package/scripts/superviseur.mjs +1 -1
  108. package/scripts/tableau.mjs +1 -1
  109. package/scripts/un-commit-par-ticket.mjs +48 -14
  110. package/scripts/verrou-de-fichier.mjs +1 -1
  111. package/scripts/verrou-de-machine.mjs +4 -4
  112. package/scripts/verrous/verrou.mjs +28 -37
  113. package/skills/developpeur/SKILL.md +2 -2
  114. package/skills/explorateur/SKILL.md +13 -5
  115. package/skills/grill/SKILL.md +2 -2
  116. package/skills/pitmaster/references/cadre.md +1 -1
  117. package/skills/pitmaster/references/consigne-agent.md +10 -3
  118. package/skills/redacteur/references/documents-d-un-composant.md +4 -4
  119. package/skills/relecteur/SKILL.md +4 -1
  120. package/skills/testwriter/SKILL.md +20 -6
  121. /package/scripts/{consommateurs.d.ts → langages/typescript/consommateurs.d.ts} +0 -0
  122. /package/scripts/{vitest-config → langages/typescript/vitest-config}/base.d.ts +0 -0
  123. /package/scripts/{vitest-config → langages/typescript/vitest-config}/machine.setup.mjs +0 -0
  124. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.d.ts +0 -0
  125. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.mjs +0 -0
@@ -7,9 +7,10 @@
7
7
  // - The versions pass by npm: the project installs the version of @roomi-fields/grillhouse it wants
8
8
  // (`npm install -D @roomi-fields/grillhouse@<version>`), then the update brings the project to it.
9
9
  // What the update reads of the frame is the package's own (scripts/cadre.mjs): the template of a
10
- // project (`templates/projet/package.json` for the frame's scripts and tools,
11
- // `templates/turbo/*.json` for a turbo.json). Any argument is refused: the usage is shown (the
12
- // exit code is non-zero) and nothing is updated, `--help` included.
10
+ // project of the declared language (`miseAJour.gabarit` of its module: `templates/projet/` for
11
+ // typescript, `templates/cargo/` for cargo), whose package.json gives the frame's scripts and
12
+ // the versions of the tools. Any argument is refused: the usage is shown (the exit code is
13
+ // non-zero) and nothing is updated, `--help` included.
13
14
  // - The migrations first (scripts/migrations.mjs): each migration of the package newer than the
14
15
  // version the project recorded (`grillhouse.version` of its package.json; none recorded, every
15
16
  // migration), in the order of their versions; each is replayable without effect, and the report
@@ -45,9 +46,9 @@
45
46
  // `grillhouse hooks && …`), and `grillhouse:gardes` (scripts/gardes-du-cadre.mjs, the frame's controls), `grillhouse:dette:inscrire` and
46
47
  // `grillhouse:dette:elaguer` (the known debt of the guards, scripts/dette.mjs), and `api` (`npm run api`, which writes
47
48
  // the API reports and the generated part of each `docs/INTERFACE.md`), each read as it is in the
48
- // template's `package.json` (a template without one writes none). Turborepo plays `grillhouse:gardes`
49
- // and the project's own guards, the root script `gardes`, after the build, beside the tests
50
- // (`turbo.json`, `npm run verifier`): the frame's former wiring goes, a `pretest` that is the
49
+ // template's `package.json` (a template without one writes none). `npm run verifier` plays
50
+ // `grillhouse:gardes` and the project's own guards, the root script `gardes`, beside the tests:
51
+ // the frame's former wiring goes, a `pretest` that is the
51
52
  // frame's call (`npm run --silent grillhouse:gardes`) removed or taken off the head of a longer
52
53
  // one (`… && <its pretest>`, the rest kept; a `pretest` of the project's own stays). An
53
54
  // `integration:gardes`, the script the former integration played, loses each head that is a
@@ -55,67 +56,42 @@
55
56
  // `node scripts/integration/gardes.mjs`); what remains is the project's own guards, which move to
56
57
  // `gardes` when the project has none (the report says so), else stay where nothing plays them
57
58
  // (the report names both); nothing remaining, the script goes.
58
- // - The typing: each package of TypeScript (a `tsconfig.json`) that has no `typecheck` script
59
- // receives the template's, `tsc -p tsconfig.json --noEmit` (its tsconfig.json types its sources
60
- // and its tests, nothing emitted, as the template's does; its tsconfig.build.json builds), as a
61
- // package of the examples of create-turbo types itself (`check-types`): each package of the frame
62
- // in a project with `workspaces` (a package out of the frame is not touched, the root's
63
- // `typecheck` stays the project's), the root in a project without. `npm run verifier` plays it,
64
- // the task `typecheck` of Turborepo, which the generator keeps in the root's turbo.json
65
- // (scripts/turbo-des-paquets.mjs). The report names the packages that received it. Witness:
66
- // BPScript 320.21.4, whose type errors in test/ showed only at night.
67
- // - `turbo.json` is the project's own file, as every repository run by Turborepo writes its own. A
68
- // project with a `package.json` and no `turbo.json` receives the frame's template of its form:
69
- // `templates/turbo/paquets.json` when its `package.json` declares
70
- // `workspaces` (the tasks of each package, and the root's guards, `//#grillhouse:gardes` and
71
- // `//#gardes`, and `typecheck`, after the build of each package and of its dependencies; the
72
- // tests live in the packages, the root has no `test:vitest`; the `build` of each package is set by its own
73
- // generated `turbo.json`, below), else `templates/turbo/sans-paquets.json` (`build`, then the
74
- // guards, the tests and `typecheck` beside each other).
75
- // A `turbo.json` present is never written again by the update; only the generator of the
76
- // packages' turbo.json (below) writes in it the `dependsOn` of the guard tasks, and adds one it
77
- // lacks, and the typing task.
78
- // - The tools the frame's checks run as commands (dependency-cruiser, knip, Turborepo) are added
79
- // to the project's `devDependencies` at the version the template's `devDependencies` give; a
80
- // tool the project already declares in `dependencies`, `devDependencies` or
81
- // `optionalDependencies` keeps its declaration, one a previous version added stays, and
82
- // `devDependencies` are written sorted by name. The report names each tool added and
83
- // `npm install`, which installs them. What the package's scripts import, it declares itself (its
84
- // `dependencies`, API Extractor among them; Vitest and TypeScript as peers), as npm leaves to a
85
- // package what it imports; the project's `tsdoc.json` extends the package's TSDoc base
86
- // (`@roomi-fields/grillhouse/tsdoc-base.json`), which extends API Extractor's. A project without
87
- // `packageManager` receives the template's (Turborepo requires it), and a `.gitignore` that does
88
- // not ignore `.turbo/` (Turborepo's runs and cache) receives the line.
89
- // - A project that runs Vitest (its `test` script names it, or `vitest` is in the `dependencies` or
90
- // `devDependencies` of its root `package.json` or of one of its packages, the workspaces as npm
91
- // maps them, read by `paquets` of scripts/paquets.mjs, the frame's one list of the
92
- // packages: a package a negation takes out is none, and a package out of the frame
93
- // (`docs/agents/hors-cadre.txt`), which Turborepo never tests, counts for nothing) has its root scripts
94
- // `test`, `test:vitest`, `test:forcer` and `verifier` become the template's (`npm test`, the tests
95
- // as Turborepo's tasks with its cache; `npm run test:forcer`, the same played for real;
96
- // `npm run verifier`, scripts/verifier.mjs, the guards and the tests beside each other, which the
97
- // integration, the queue, the continuous integration and the night play); the report says so, when the
98
- // Vitest of the project's root (`npx --no-install vitest`, the one `test:vitest` calls) satisfies
99
- // the range the template's package.json declares for `vitest`. Where the root resolves no Vitest or
100
- // another version, the project's scripts stay (the frame's included) and the report names the
101
- // version found and the range required. A `test` that runs anything else stays. The scripts of
102
- // the packages of a monorepo are not written, but their `typecheck` (above).
103
- // - The frame's base configuration of Vitest is the package's (`@roomi-fields/grillhouse/vitest-config`,
104
- // scripts/vitest-config/), which each Vitest configuration imports by its name
105
- // (`import base from '@roomi-fields/grillhouse/vitest-config'`), as the examples of Turborepo
106
- // reach @repo/eslint-config: a package is reached by its name, never by a path into it. In a
107
- // project with `workspaces`, each package of the frame that holds a `test:vitest` script
108
- // declares the frame's package in its `devDependencies`, at the range the root declares (else
109
- // `^<version>` of the package), a declaration it holds kept; a package out of the frame is not
110
- // touched. The report names the packages that received it, `npm install`, which links it, and the
111
- // import; the update writes no Vitest configuration.
112
- // - A package of the frame whose code imports the frame's package (a file of its `src/` out of the
113
- // tests, the files whose development dependencies the guard of the boundaries refuses,
114
- // scripts/frontieres.mjs; its imports read by TypeScript's `preProcessFile`) declares it in its
115
- // `dependencies`, as npm puts there what the published code imports: a declaration in its
116
- // `devDependencies` moves there with its range, else the range the root declares (else
117
- // `^<version>`); this comes first, so that the declaration of the Vitest base above keeps it.
118
- // The report names the packages and `npm install`.
59
+ // - The share of the declared language (`miseAJour.appliquer` of its module, as each plugin of Nx
60
+ // brings its `init` generator): what its tools ask of the project, in its package.json and its
61
+ // other files, and the lines of the report; the core writes the package.json after. Typescript
62
+ // (scripts/langages/typescript/mise-a-jour.mjs): the frame's test scripts in a project that runs
63
+ // its tests, the frame's package declared where the code or the tests read it, the typing of
64
+ // each package, the project's first configuration of its task runner. Cargo
65
+ // (scripts/langages/cargo/mise-a-jour.mjs): the files of its template a project lacks, and its
66
+ // test scripts.
67
+ // - The languages first (`declarerLangages`): a project that declares none (`grillhouse.langages`
68
+ // of its package.json) receives the languages the modules of the frame find in it
69
+ // (`langagesTrouves` of scripts/langages.mjs: typescript, a tsconfig.json at its root or in a
70
+ // package of the frame; cargo, a Cargo.toml at its root; the refusal names
71
+ // each one's sign, `signe` of its module), and the report says
72
+ // so; a declaration it holds stays. A directory
73
+ // without package.json, or a project where no module finds its language, is refused, named on
74
+ // the error stream, the exit code 1, nothing written: the frame invents no declaration, and the
75
+ // migrations of the declared language play with the core's. No import of the project is
76
+ // rewritten.
77
+ // - The tools of the declared language (the `outils` of its module: what it runs as commands and
78
+ // what its scripts import), and none other, are added to the project's `devDependencies` at the
79
+ // version the template's `devDependencies` give; a tool the project already declares in
80
+ // `dependencies`, `devDependencies` or `optionalDependencies` keeps its declaration, one a
81
+ // previous version added stays, and `devDependencies` are written sorted by name. The report
82
+ // names each tool added and `npm install`, which installs them. A project without
83
+ // `packageManager` receives the template's.
84
+ // - What the tools of the declared language write in a project (`ignorer` of its module:
85
+ // typescript's `.turbo`, cargo's `target`): a `.gitignore` that does not ignore one receives its
86
+ // line, `<nom>/`.
87
+ // - The binaries of the declared language (`binaires` of its module: cargo's nextest and
88
+ // cargo-deny), after the files: the command line runs the commands of its module
89
+ // (`miseAJour.installation`), which list what is installed and install each one missing or at
90
+ // another version (cargo's: `cargo install --list`, then `cargo binstall --no-confirm --locked
91
+ // <nom>@<version>`), as `npm install` brings what is installed to what is declared; the report
92
+ // names each one installed. One that cannot be installed has its line, the error stream of its
93
+ // command naming the command to type, and the exit code is non-zero. A language without
94
+ // binaries runs nothing.
119
95
  // - The git hooks: both of the frame (commit-msg « a closed ticket refuses a second commit, a reopened ticket takes its corrections », pre-push night branch
120
96
  // guard) are placed by scripts/crochets.mjs, the mechanism `grillhouse hooks` (the project's
121
97
  // `prepare`) also runs, in the hooks folder git reads for the project (`core.hooksPath`, else the
@@ -127,19 +103,13 @@
127
103
  // as `npm install` brings what is installed to what is declared. A plugin that cannot be
128
104
  // installed, or a mod left at another version, has its line naming the command to type; the
129
105
  // update has finished its files, and the exit code is non-zero.
130
- // - The generated files: after the package.json, each generator of the frame is run in the project
131
- // by the project's command (`node_modules/.bin/grillhouse`, its installed package) for the file
132
- // it writes when the project holds that file (`grillhouse frontieres --ecrire` for
133
- // `.dependency-cruiser.cjs`, `grillhouse index-interfaces` for
134
- // `docs/agents/index-des-interfaces.md`; every one of them for a project `grillhouse init`
135
- // creates), and `grillhouse turbo-des-paquets --ecrire`
136
- // in a repository with `workspaces` (the `turbo.json` of each of its packages, whose build waits
137
- // for its runtime dependencies only, and of which a package out of the frame plays no task; the
138
- // `dependsOn` of the guard tasks of the root's turbo.json, which wait for the builds), so that
139
- // the frame's checks accept them; a generator
140
- // that fails, or a project without its command, has its line, which says to run it after
141
- // `npm install` (the frame's package and tools), and the exit code is non-zero. `interfaces-contre-code.mjs` is not
142
- // run: it writes after a build.
106
+ // - The generated files: after the package.json, each generator of the declared language
107
+ // (`miseAJour.generateurs` of its module) is run in the project by the project's command
108
+ // (`node_modules/.bin/grillhouse`, its installed package) for the file it writes when the project
109
+ // holds that file (every one of them for a project `grillhouse init` creates), and a generator
110
+ // without file in a repository with `workspaces`, so that the frame's checks accept them; a
111
+ // generator that fails, or a project without its command, has its line, which says to run it
112
+ // after `npm install` (the frame's package and tools), and the exit code is non-zero.
143
113
  // - The report names the version of the frame, « Cadre 0.23.0. », the package's.
144
114
  // - Last, the update plays the project's verification, `npm run verifier`, from its root, its
145
115
  // output shown, as Nx affected moves its base to the last green commit of main: its green keeps
@@ -151,22 +121,18 @@
151
121
  // line says it: green, the last green kept; red, its code, the last green as it was; 75, « à
152
122
  // repasser ». It is not played, the line saying why, when the update leaves its files to finish
153
123
  // (a migration's `aFaire`, a generator that fails: on the error stream, the exit code already
154
- // non-zero), when the project has no `verifier` script, or when the report asks for
155
- // `npm install` first (a tool or the frame's package newly declared).
124
+ // non-zero), when the project has no `verifier` script (the line of the language's share says
125
+ // why), or when the report asks for `npm install` first (a tool or the frame's package newly
126
+ // declared).
156
127
  import { spawnSync } from 'node:child_process';
157
- import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
158
- import { createRequire } from 'node:module';
128
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
159
129
  import path from 'node:path';
160
130
  import { pathToFileURL } from 'node:url';
161
- import semver from 'semver';
162
131
  import { CADRE, VERSION } from './cadre.mjs';
163
132
  import { poserCrochets } from './crochets.mjs';
164
133
  import { installerGreffons } from './greffons.mjs';
165
134
  import { migrer, restesAuProjet } from './migrations.mjs';
166
- import { CODE, TESTS } from './frontieres.mjs';
167
- import { paquets } from './paquets.mjs';
168
- import { sources } from './sources.mjs';
169
- import { TYPAGE } from './turbo-des-paquets.mjs';
135
+ import { LANGAGES, langage, langageDe, langagesDeclares, langagesTrouves } from './langages.mjs';
170
136
 
171
137
  const SCRIPTS = {
172
138
  tableau: 'grillhouse tableau --texte',
@@ -174,20 +140,10 @@ const SCRIPTS = {
174
140
  };
175
141
  // The command of the project's `prepare` that places the frame's git hooks (Husky's model).
176
142
  const PREPARE = 'grillhouse hooks';
177
- // The template's package.json, where the frame's scripts and tools are read.
178
- const GABARIT = 'templates/projet/package.json';
179
- // The frame's package, as a project declares it, and its base configuration of Vitest.
180
- const PAQUET_DU_CADRE = '@roomi-fields/grillhouse';
181
- const CONFIG_VITEST = `${PAQUET_DU_CADRE}/vitest-config`;
182
143
 
183
144
  /** The frame's status line, as the settings of a project run it. */
184
145
  export const LIGNE_ETAT = '"$CLAUDE_PROJECT_DIR/node_modules/.bin/grillhouse" ligne-etat';
185
146
 
186
- // The frame's tools a project runs as commands: their names are the frame's, their versions are
187
- // read in the template.
188
- const OUTILS_DU_CADRE = ['dependency-cruiser', 'knip', 'turbo'];
189
- // The root scripts of the tests, written together from the template.
190
- const SCRIPTS_DES_TESTS = ['test', 'test:vitest', 'test:forcer', 'verifier'];
191
147
  const CHAMPS_INSTALLES = ['dependencies', 'devDependencies', 'optionalDependencies'];
192
148
 
193
149
  // The frame's former wiring of the guards: the call its `pretest` held, and the commands its
@@ -202,28 +158,7 @@ const ANCIENS_GARDES_D_INTEGRATION = [
202
158
  // the one the former integration played.
203
159
  const GARDES_DU_PROJET = 'gardes';
204
160
  const ANCIEN_GARDES_DU_PROJET = 'integration:gardes';
205
- // The line of `.gitignore` that keeps Turborepo's folder out of git.
206
- const TURBO_IGNORE = '.turbo/';
207
- // The frame's templates of `turbo.json`, one per form of repository, read in the source.
208
- const TURBO_PAQUETS = 'templates/turbo/paquets.json';
209
- const TURBO_SANS_PAQUETS = 'templates/turbo/sans-paquets.json';
210
161
 
211
- // Whether `vitest` is declared in the dependencies of the package.json <p> (read at <dossier>) or of
212
- // one of its packages of the frame (`paquets`: the workspaces as npm maps them, a package out of
213
- // the frame left out, which Turborepo never tests).
214
- const declareVitest = (dossier, p) => {
215
- const a = pkg => Boolean(pkg?.dependencies?.vitest ?? pkg?.devDependencies?.vitest);
216
- return a(p) || paquets(dossier).some(({ pkg, hors }) => !hors && a(pkg));
217
- };
218
- // The version of the Vitest the project's root resolves, as `test:vitest` calls it
219
- // (`npx --no-install vitest --version`); null when it answers none.
220
- const vitestDeLaRacine = projet => {
221
- const r = spawnSync('npx', ['--no-install', 'vitest', '--version'], {
222
- cwd: projet,
223
- encoding: 'utf8',
224
- });
225
- return r.status === 0 ? (/vitest\/(\d+\.\d+\.\d+\S*)/.exec(r.stdout)?.[1] ?? null) : null;
226
- };
227
162
  const lireJson = (f, defaut) => {
228
163
  try {
229
164
  return JSON.parse(readFileSync(f, 'utf8'));
@@ -232,157 +167,42 @@ const lireJson = (f, defaut) => {
232
167
  }
233
168
  };
234
169
 
235
- // Adds `.turbo/` to the `.gitignore` of the project at <projet> when no line ignores it.
236
- function ignorerTurbo(projet) {
170
+ // Adds to the `.gitignore` of the project at <projet> each directory its language's tools write
171
+ // (`ignorer` of its module: `<nom>/`), when no line ignores it (`<nom>`, `<nom>/`, `/<nom>`,
172
+ // `/<nom>/`); its own lines stay.
173
+ function ignorer(projet) {
237
174
  const f = path.join(projet, '.gitignore');
238
- const texte = existsSync(f) ? readFileSync(f, 'utf8') : '';
239
- const lignes = texte.split('\n').map(l => l.trim());
240
- if (lignes.some(l => l === '.turbo' || l === TURBO_IGNORE || l === '/.turbo' || l === '/.turbo/'))
241
- return;
242
- const fin = texte === '' || texte.endsWith('\n') ? '' : '\n';
243
- writeFileSync(f, `${texte}${fin}${TURBO_IGNORE}\n`);
244
- }
245
-
246
- // Writes the `turbo.json` of the project at <projet>, when it has a package.json and no turbo.json,
247
- // from the source's template of its form (`workspaces` declared: a repository of packages).
248
- // Returns the template written, or null.
249
- function poserTurbo(projet, source) {
250
- const f = path.join(projet, 'turbo.json');
251
- const pkg = path.join(projet, 'package.json');
252
- if (existsSync(f) || !existsSync(pkg)) return null;
253
- const gabarit = lireJson(pkg, {}).workspaces !== undefined ? TURBO_PAQUETS : TURBO_SANS_PAQUETS;
254
- if (!existsSync(path.join(source, gabarit))) return null;
255
- copyFileSync(path.join(source, gabarit), f);
256
- return gabarit;
257
- }
258
-
259
- // <deps> written sorted by name, as npm writes them.
260
- const trie = deps =>
261
- Object.fromEntries(Object.entries(deps).sort(([a], [b]) => a.localeCompare(b, 'en')));
262
- // The range at which the root package.json <p> declares the frame's package, or undefined.
263
- const plageDeLaRacine = p =>
264
- CHAMPS_INSTALLES.map(c => p[c]?.[PAQUET_DU_CADRE]).find(v => v !== undefined);
265
-
266
- // Whether the code of the package at <dossier> of <projet> imports the frame's package (an entry of
267
- // it): a file of its `src/` out of the tests (CODE and TESTS of scripts/frontieres.mjs, the files
268
- // whose development dependencies its guard refuses), its imports read by TypeScript
269
- // (`preProcessFile`), a comment or a string importing nothing.
270
- function codeImporteLeCadre(projet, dossier) {
271
- const ts = createRequire(import.meta.url)('typescript');
272
- return sources(path.join(projet, dossier))
273
- .map(f => `${dossier}/${f}`)
274
- .filter(f => new RegExp(CODE).test(f) && !new RegExp(TESTS).test(f))
275
- .some(f =>
276
- ts
277
- .preProcessFile(readFileSync(path.join(projet, f), 'utf8'), true, true)
278
- .importedFiles.some(
279
- ({ fileName: m }) => m === PAQUET_DU_CADRE || m.startsWith(`${PAQUET_DU_CADRE}/`)
280
- )
281
- );
282
- }
283
-
284
- // Declares the frame's package in the dependencies of each package of the frame of the project of
285
- // packages at <projet> (root package.json <p>) whose code imports it (codeImporteLeCadre), as npm
286
- // puts what the published code imports: a declaration in its devDependencies moves there with its
287
- // range, else the range the root declares (else `^<version>` of the package); one already in its
288
- // dependencies or optionalDependencies stays. Returns { nom, paquets } (paquets: the packages
289
- // whose dependencies received it), or null when nothing changes.
290
- function declarerDependanceDuCadre(projet, p) {
291
- if (p.workspaces === undefined) {
292
- return null;
293
- }
294
- const racine = plageDeLaRacine(p);
295
- const declarants = [];
296
- for (const { dossier, pkg, hors } of paquets(projet)) {
297
- const declare = ['dependencies', 'optionalDependencies'].some(
298
- c => pkg[c]?.[PAQUET_DU_CADRE] !== undefined
299
- );
300
- if (hors || declare || !codeImporteLeCadre(projet, dossier)) {
175
+ let texte = existsSync(f) ? readFileSync(f, 'utf8') : '';
176
+ const avant = texte;
177
+ for (const nom of langageDe(projet).ignorer) {
178
+ const lignes = texte.split('\n').map(l => l.trim());
179
+ if ([nom, `${nom}/`, `/${nom}`, `/${nom}/`].some(l => lignes.includes(l))) {
301
180
  continue;
302
181
  }
303
- const { [PAQUET_DU_CADRE]: dev, ...autres } = pkg.devDependencies ?? {};
304
- pkg.dependencies = trie({
305
- ...(pkg.dependencies ?? {}),
306
- [PAQUET_DU_CADRE]: dev ?? racine ?? `^${VERSION}`,
307
- });
308
- if (dev !== undefined) {
309
- pkg.devDependencies = autres;
310
- }
311
- writeFileSync(path.join(projet, dossier, 'package.json'), `${JSON.stringify(pkg, null, 2)}\n`);
312
- declarants.push(dossier);
182
+ const fin = texte === '' || texte.endsWith('\n') ? '' : '\n';
183
+ texte = `${texte}${fin}${nom}/\n`;
313
184
  }
314
- return declarants.length > 0 ? { nom: PAQUET_DU_CADRE, paquets: declarants } : null;
315
- }
316
-
317
- // Declares the frame's package, whose base configuration of Vitest each Vitest configuration
318
- // imports, in the devDependencies of each package of the frame of the project of packages at
319
- // <projet> (root package.json <p>) whose scripts hold `test:vitest`, at the range the root declares
320
- // (else `^<version>` of the package), a declaration the package holds kept; a package out of the
321
- // frame is not touched. Returns { nom, paquets } (paquets: the packages that received the
322
- // declaration), or null when nothing changes.
323
- function poserConfigVitest(projet, p) {
324
- if (p.workspaces === undefined) return null;
325
- const testes = paquets(projet).filter(
326
- ({ pkg, hors }) => !hors && typeof pkg.scripts?.['test:vitest'] === 'string'
327
- );
328
- const racine = plageDeLaRacine(p);
329
- const declarants = [];
330
- for (const { dossier, pkg } of testes) {
331
- if (CHAMPS_INSTALLES.some(c => pkg[c]?.[PAQUET_DU_CADRE] !== undefined)) continue;
332
- pkg.devDependencies = trie({
333
- ...(pkg.devDependencies ?? {}),
334
- [PAQUET_DU_CADRE]: racine ?? `^${VERSION}`,
335
- });
336
- writeFileSync(path.join(projet, dossier, 'package.json'), `${JSON.stringify(pkg, null, 2)}\n`);
337
- declarants.push(dossier);
185
+ if (texte !== avant) {
186
+ writeFileSync(f, texte);
338
187
  }
339
- return declarants.length > 0 ? { nom: PAQUET_DU_CADRE, paquets: declarants } : null;
340
188
  }
341
189
 
342
- // Gives the typing script of the template, <script> (`tsc -p tsconfig.json --noEmit`: its
343
- // tsconfig.json types its sources and its tests, nothing emitted), to each package of TypeScript
344
- // (a `tsconfig.json`) of the project at <projet> (root package.json <p>) that has no `typecheck`:
345
- // each package of the frame in a project of packages, written in its package.json (a package out
346
- // of the frame is not touched, and the root's `typecheck` stays the project's); the root itself in
347
- // a project without packages, set in <p>, which the caller writes. `npm run verifier` plays it, a
348
- // task of Turborepo (scripts/turbo-des-paquets.mjs). Returns { script, paquets } (paquets: each
349
- // package's directory, `.` for the root), or null when nothing changes.
350
- function poserTypage(projet, p, script) {
351
- if (typeof script !== 'string') return null;
352
- const types = dossier => existsSync(path.join(projet, dossier, 'tsconfig.json'));
353
- const sans = pkg => typeof pkg.scripts?.[TYPAGE] !== 'string';
354
- const declarants = [];
355
- if (p.workspaces === undefined) {
356
- if (types('.') && sans(p)) {
357
- p.scripts = { ...(p.scripts ?? {}), [TYPAGE]: script };
358
- declarants.push('.');
359
- }
360
- } else {
361
- for (const { dossier, pkg, hors } of paquets(projet)) {
362
- if (hors || !types(dossier) || !sans(pkg)) continue;
363
- pkg.scripts = { ...(pkg.scripts ?? {}), [TYPAGE]: script };
364
- writeFileSync(
365
- path.join(projet, dossier, 'package.json'),
366
- `${JSON.stringify(pkg, null, 2)}\n`
367
- );
368
- declarants.push(dossier);
369
- }
370
- }
371
- return declarants.length > 0 ? { script, paquets: declarants } : null;
372
- }
190
+ // <deps> written sorted by name, as npm writes them.
191
+ const trie = deps =>
192
+ Object.fromEntries(Object.entries(deps).sort(([a], [b]) => a.localeCompare(b, 'en')));
373
193
 
374
194
  // Writes the frame's status line in the settings of the project at <projet>, when they exist and
375
195
  // hold none or the frame's (see the header); their other keys keep their order. Returns whether
376
196
  // they changed.
377
197
  function reglerLigneEtat(projet) {
378
198
  const f = path.join(projet, '.claude', 'settings.json');
379
- if (!existsSync(f)) return false;
199
+ if (!existsSync(f)) {return false;}
380
200
  const reglages = JSON.parse(readFileSync(f, 'utf8'));
381
201
  const actuelle = reglages.statusLine;
382
202
  const commande = typeof actuelle?.command === 'string' ? actuelle.command : '';
383
- if (actuelle !== undefined && !commande.includes('ligne-etat')) return false;
203
+ if (actuelle !== undefined && !commande.includes('ligne-etat')) {return false;}
384
204
  const voulue = { type: 'command', command: LIGNE_ETAT };
385
- if (JSON.stringify(actuelle) === JSON.stringify(voulue)) return false;
205
+ if (JSON.stringify(actuelle) === JSON.stringify(voulue)) {return false;}
386
206
  reglages.statusLine = voulue;
387
207
  writeFileSync(f, `${JSON.stringify(reglages, null, 2)}\n`);
388
208
  return true;
@@ -397,7 +217,7 @@ export const GREFFON_DU_CADRE = `grillhouse@${MARCHE_DU_CADRE}`;
397
217
  // and enables the frame's plugin (see the header); returns whether they changed.
398
218
  function declarerGreffon(projet) {
399
219
  const f = path.join(projet, '.claude', 'settings.json');
400
- if (!existsSync(f)) return false;
220
+ if (!existsSync(f)) {return false;}
401
221
  const avant = readFileSync(f, 'utf8');
402
222
  const reglages = JSON.parse(avant);
403
223
  reglages.extraKnownMarketplaces = {
@@ -405,11 +225,42 @@ function declarerGreffon(projet) {
405
225
  [MARCHE_DU_CADRE]: { source: SOURCE_DU_MARCHE },
406
226
  };
407
227
  reglages.enabledPlugins = { ...(reglages.enabledPlugins ?? {}), [GREFFON_DU_CADRE]: true };
408
- if (JSON.stringify(reglages) === JSON.stringify(JSON.parse(avant))) return false;
228
+ if (JSON.stringify(reglages) === JSON.stringify(JSON.parse(avant))) {return false;}
409
229
  writeFileSync(f, `${JSON.stringify(reglages, null, 2)}\n`);
410
230
  return true;
411
231
  }
412
232
 
233
+ /**
234
+ * Declares the languages of the project at <projet> (`grillhouse.langages` of its package.json)
235
+ * from what the modules of the frame find in it (`langagesTrouves`, scripts/langages.mjs), when it
236
+ * declares none; a declaration it holds stays. Returns `{ langages, ecrits }` (ecrits: whether the
237
+ * update wrote them). Throws, writing nothing, when the project has no package.json or the modules
238
+ * find no language of the frame in it: the update invents no declaration.
239
+ */
240
+ export function declarerLangages(projet) {
241
+ const fichier = path.join(projet, 'package.json');
242
+ if (!existsSync(fichier)) {
243
+ throw new Error(
244
+ `${projet} n'a pas de package.json, où un projet déclare ses langages (grillhouse.langages) ; la mise à jour du cadre s'y joue.`
245
+ );
246
+ }
247
+ const declares = langagesDeclares(projet);
248
+ if (declares.length > 0) {return { langages: declares, ecrits: false };}
249
+ const trouves = langagesTrouves(projet);
250
+ if (trouves.length === 0) {
251
+ const signes = Object.keys(LANGAGES)
252
+ .map(n => `${n} : ${langage(n).signe}`)
253
+ .join(' ; ');
254
+ throw new Error(
255
+ `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\`.`
256
+ );
257
+ }
258
+ const p = lireJson(fichier, {});
259
+ p.grillhouse = { ...(p.grillhouse ?? {}), langages: trouves };
260
+ writeFileSync(fichier, `${JSON.stringify(p, null, 2)}\n`);
261
+ return { langages: trouves, ecrits: true };
262
+ }
263
+
413
264
  /** The version of the frame the project at <projet> recorded (`grillhouse.version`), or null. */
414
265
  export function versionDuProjet(projet) {
415
266
  const v = lireJson(path.join(projet, 'package.json'), {})?.grillhouse?.version;
@@ -423,22 +274,21 @@ export function versionDuProjet(projet) {
423
274
  */
424
275
  export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
425
276
  const bilan = {
277
+ langages: null,
426
278
  dependances: [],
427
- test: null,
428
- vitest: null,
429
- turbo: null,
430
- configVitest: null,
431
- dependanceDuCadre: null,
432
- typage: null,
433
279
  gardes: null,
434
280
  ligneEtat: false,
435
281
  greffon: false,
282
+ duLangage: { lignes: [], installer: false, sansVerifier: null },
436
283
  };
437
284
  const pkg = path.join(projet, 'package.json');
438
285
  if (existsSync(pkg)) {
286
+ bilan.langages = declarerLangages(projet);
287
+ const langage = langageDe(projet);
439
288
  const p = lireJson(pkg, {});
440
- if (inscrite !== null) p.grillhouse = { ...(p.grillhouse ?? {}), version: inscrite };
441
- const pkgSource = lireJson(path.join(source, GABARIT), {});
289
+ if (inscrite !== null) {p.grillhouse = { ...(p.grillhouse ?? {}), version: inscrite };}
290
+ // The template of the declared language, where the frame's scripts and tools are read.
291
+ const pkgSource = lireJson(path.join(source, langage.miseAJour.gabarit, 'package.json'), {});
442
292
  const gardes = pkgSource.scripts?.['grillhouse:gardes'];
443
293
  p.scripts = { ...(p.scripts ?? {}), ...SCRIPTS };
444
294
  // The project's `prepare`, which npm runs at its install, places the frame's git hooks first.
@@ -449,39 +299,8 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
449
299
  if (typeof pkgSource.scripts?.api === 'string') {
450
300
  p.scripts.api = pkgSource.scripts.api;
451
301
  }
452
- // The frame's tests (Turborepo's tasks) replace a project's own test that runs Vitest.
453
- const testDuCadre = pkgSource.scripts?.test;
454
- const testDuProjet = p.scripts.test;
455
- const vitestExige = pkgSource.devDependencies?.vitest ?? pkgSource.dependencies?.vitest;
456
- const lanceVitest =
457
- typeof testDuCadre === 'string' &&
458
- typeof testDuProjet === 'string' &&
459
- (testDuProjet === testDuCadre || /\bvitest\b/.test(testDuProjet) || declareVitest(projet, p));
460
- if (lanceVitest) {
461
- // The root must resolve the Vitest the frame requires (`test:vitest` calls it).
462
- const trouvee = typeof vitestExige === 'string' ? vitestDeLaRacine(projet) : null;
463
- const convient =
464
- typeof vitestExige !== 'string' ||
465
- (trouvee !== null && semver.satisfies(trouvee, vitestExige));
466
- if (!convient) {
467
- bilan.vitest = { trouvee, exigee: vitestExige };
468
- } else {
469
- if (testDuProjet !== testDuCadre)
470
- bilan.test = { ancien: testDuProjet, nouveau: testDuCadre };
471
- for (const nom of SCRIPTS_DES_TESTS) {
472
- const script = pkgSource.scripts?.[nom];
473
- if (typeof script !== 'string') continue;
474
- // A repository of packages keeps its tests in its packages, as Turborepo does: its root
475
- // gets no `test:vitest`, and the frame's own leaves.
476
- if (p.workspaces !== undefined && nom === 'test:vitest') {
477
- if (p.scripts[nom] === script) delete p.scripts[nom];
478
- continue;
479
- }
480
- p.scripts[nom] = script;
481
- }
482
- }
483
- }
484
- for (const nom of OUTILS_DU_CADRE) {
302
+ // The tools of the declared language alone (its module's `outils`), at the template's versions.
303
+ for (const nom of langage.outils) {
485
304
  const version = pkgSource.devDependencies?.[nom];
486
305
  if (typeof version === 'string' && !CHAMPS_INSTALLES.some(c => p[c]?.[nom] !== undefined)) {
487
306
  p.devDependencies = { ...(p.devDependencies ?? {}), [nom]: version };
@@ -494,11 +313,11 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
494
313
  if (typeof pkgSource.packageManager === 'string' && typeof p.packageManager !== 'string') {
495
314
  p.packageManager = pkgSource.packageManager;
496
315
  }
497
- if (typeof gardes === 'string') p.scripts['grillhouse:gardes'] = gardes;
316
+ if (typeof gardes === 'string') {p.scripts['grillhouse:gardes'] = gardes;}
498
317
  // The commands of the known debt of the guards (scripts/dette.mjs) are the frame's.
499
318
  for (const nom of ['grillhouse:dette:inscrire', 'grillhouse:dette:elaguer']) {
500
319
  const script = pkgSource.scripts?.[nom];
501
- if (typeof script === 'string') p.scripts[nom] = script;
320
+ if (typeof script === 'string') {p.scripts[nom] = script;}
502
321
  }
503
322
  // The frame's former wiring of the guards goes: Turborepo plays them (`npm run verifier`).
504
323
  const pretest = typeof p.scripts.pretest === 'string' ? p.scripts.pretest.trim() : null;
@@ -528,43 +347,92 @@ export function mettreAJour(projet, source, { inscrite = VERSION } = {}) {
528
347
  bilan.gardes = { deplace: false };
529
348
  }
530
349
  }
531
- bilan.dependanceDuCadre = declarerDependanceDuCadre(projet, p);
532
- bilan.configVitest = poserConfigVitest(projet, p);
533
- bilan.typage = poserTypage(projet, p, pkgSource.scripts?.[TYPAGE]);
350
+ // The share of the declared language (its module's `miseAJour`), in <p> and in its files.
351
+ const part = langage.miseAJour.appliquer(projet, {
352
+ p,
353
+ modele: pkgSource,
354
+ source,
355
+ version: VERSION,
356
+ });
357
+ Object.assign(bilan, part.bilan);
358
+ bilan.duLangage = {
359
+ lignes: part.lignes,
360
+ installer: part.installer,
361
+ sansVerifier: part.sansVerifier,
362
+ };
534
363
  writeFileSync(pkg, `${JSON.stringify(p, null, 2)}\n`);
364
+ ignorer(projet);
535
365
  }
536
- bilan.turbo = poserTurbo(projet, source);
537
366
  bilan.ligneEtat = reglerLigneEtat(projet);
538
367
  bilan.greffon = declarerGreffon(projet);
539
- ignorerTurbo(projet);
540
368
  poserCrochets(projet);
541
369
  return bilan;
542
370
  }
543
371
 
544
- // The frame's generators, subcommands of the project's command, and the file each writes: run in
545
- // the project after its package.json. A generator without `sortie` (the `turbo.json` of each
546
- // package) runs in every project whose package.json declares `workspaces`.
547
- const GENERATEURS = [
548
- { commande: 'frontieres', args: ['--ecrire'], sortie: '.dependency-cruiser.cjs' },
549
- { commande: 'index-interfaces', args: [], sortie: 'docs/agents/index-des-interfaces.md' },
550
- { commande: 'turbo-des-paquets', args: ['--ecrire'], sortie: null },
551
- ];
372
+ /**
373
+ * Installs on the machine each binary of the language of the project at <projet> (`binaires` of
374
+ * its module) that its installation does not list at its version, by the commands its module
375
+ * describes (`miseAJour.installation`: `liste`, then `installer` for each one missing), each run by
376
+ * Node, as `npm install` brings what is installed to what is declared; a language without
377
+ * binaries runs nothing. Returns `{ installes, lignes }`: each binary installed
378
+ * (`<nom>@<version>`), and the line of each failure, the error stream of its command, which names
379
+ * the command to type.
380
+ */
381
+ export function installerBinaires(projet) {
382
+ const langage = langageDe(projet);
383
+ const voulus = Object.entries(langage.binaires);
384
+ const installation = langage.miseAJour.installation;
385
+ if (voulus.length === 0 || installation === null) {
386
+ return { installes: [], lignes: [] };
387
+ }
388
+ const lancer = c =>
389
+ spawnSync(process.execPath, [c.script, ...c.args], { cwd: projet, encoding: 'utf8' });
390
+ const cause = r => (r.error ? r.error.message : (r.stderr ?? '').trim() || `code ${r.status}`);
391
+ const liste = lancer(installation.liste);
392
+ let presents;
393
+ try {
394
+ if (liste.error || liste.status !== 0) {
395
+ throw new Error(cause(liste));
396
+ }
397
+ presents = JSON.parse(liste.stdout);
398
+ } catch (e) {
399
+ return {
400
+ installes: [],
401
+ lignes: [`Binaires : la liste des binaires installés échoue. ${e.message}`],
402
+ };
403
+ }
404
+ const installes = [];
405
+ const lignes = [];
406
+ for (const [nom, version] of voulus) {
407
+ if (presents[nom] === version) {
408
+ continue;
409
+ }
410
+ const r = lancer(installation.installer(nom, version));
411
+ if (!r.error && r.status === 0) {
412
+ installes.push(`${nom}@${version}`);
413
+ } else {
414
+ lignes.push(`Binaire ${nom}@${version} : ${cause(r)}`);
415
+ }
416
+ }
417
+ return { installes, lignes };
418
+ }
552
419
 
553
420
  /**
554
- * Runs each generator whose output the project holds (every one with `tous`, for a project
555
- * `grillhouse init` creates); returns the lines of failure.
421
+ * Runs each generator of the language of the project (`miseAJour.generateurs` of its module)
422
+ * whose output the project holds (every one with `tous`, for a project `grillhouse init` creates);
423
+ * returns the lines of failure.
556
424
  */
557
425
  export function regenerer(projet, { tous = false } = {}) {
558
426
  const lignes = [];
559
427
  const grillhouse = path.join(projet, 'node_modules', '.bin', 'grillhouse');
560
428
  const aPaquets = lireJson(path.join(projet, 'package.json'), {})?.workspaces !== undefined;
561
- for (const g of GENERATEURS) {
429
+ for (const g of langageDe(projet).miseAJour.generateurs) {
562
430
  const absente = g.sortie !== null && !tous && !existsSync(path.join(projet, g.sortie));
563
431
  if (g.sortie === null ? !aPaquets : absente) {
564
432
  continue;
565
433
  }
566
434
  if (g.sortie !== null)
567
- mkdirSync(path.dirname(path.join(projet, g.sortie)), { recursive: true });
435
+ {mkdirSync(path.dirname(path.join(projet, g.sortie)), { recursive: true });}
568
436
  const r = spawnSync(grillhouse, [g.commande, ...g.args], { cwd: projet, encoding: 'utf8' });
569
437
  if (r.status !== 0) {
570
438
  lignes.push(
@@ -578,33 +446,17 @@ export function regenerer(projet, { tous = false } = {}) {
578
446
  /** The report of an update, from the bilan <b> of `mettreAJour`: one line per change. */
579
447
  export function rapport(b) {
580
448
  const lignes = [];
581
- if (b.dependances.length > 0) {
582
- lignes.push(
583
- `Dépendances de développement ajoutées : ${b.dependances.join(', ')}. \`npm install\` les installe.`
584
- );
585
- }
586
- if (b.configVitest) {
587
- const { nom, paquets: declarants } = b.configVitest;
588
- lignes.push(
589
- `Configuration de base de Vitest : ${nom} déclaré dans les devDependencies de ${declarants.join(', ')}. \`npm install\` relie le paquet. La configuration Vitest de chaque paquet l'importe par son nom : \`import base from '${CONFIG_VITEST}'\`.`
590
- );
591
- }
592
- if (b.dependanceDuCadre) {
593
- const { nom, paquets: declarants } = b.dependanceDuCadre;
594
- lignes.push(
595
- `Dépendance d'exécution : ${nom} déclaré dans les dependencies de ${declarants.join(', ')}, dont le code hors des tests importe une entrée du paquet. \`npm install\` relie le paquet.`
596
- );
597
- }
598
- if (b.typage) {
449
+ if (b.langages?.ecrits) {
599
450
  lignes.push(
600
- `Typage : \`${b.typage.script}\` écrit dans ${b.typage.paquets.join(', ')} (le script typecheck, ses sources et ses tests, que son tsconfig.json inclut) ; \`npm run verifier\` le joue à côté des gardes et des tests.`
451
+ `Langages : grillhouse.langages déclare ${b.langages.langages.join(', ')}, trouvé dans le dépôt ; le cadre sert le projet par ce langage.`
601
452
  );
602
453
  }
603
- if (b.turbo) {
454
+ if (b.dependances.length > 0) {
604
455
  lignes.push(
605
- `turbo.json écrit depuis le gabarit du cadre ${b.turbo} ; il est au projet, la mise à jour n'y touche plus.`
456
+ `Dépendances de développement ajoutées : ${b.dependances.join(', ')}. \`npm install\` les installe.`
606
457
  );
607
458
  }
459
+ lignes.push(...(b.duLangage?.lignes ?? []));
608
460
  if (b.ligneEtat) {
609
461
  lignes.push(`Ligne d'état : .claude/settings.json lance \`grillhouse ligne-etat\`.`);
610
462
  }
@@ -615,35 +467,25 @@ export function rapport(b) {
615
467
  }
616
468
  if (b.gardes?.deplace) {
617
469
  lignes.push(
618
- `Gardes du projet : le script integration:gardes devient gardes, que \`npm run verifier\` joue après la construction (turbo.json).`
470
+ `Gardes du projet : le script integration:gardes devient gardes, que \`npm run verifier\` joue à côté des tests.`
619
471
  );
620
472
  } else if (b.gardes) {
621
473
  lignes.push(
622
474
  `Gardes du projet : integration:gardes et gardes coexistent ; rien ne joue plus integration:gardes, \`npm run verifier\` joue gardes. Verse l'un dans l'autre.`
623
475
  );
624
476
  }
625
- if (b.vitest) {
626
- lignes.push(
627
- `Vitest : la racine résout ${b.vitest.trouvee ?? 'aucune version'}, le cadre exige ${b.vitest.exigee} ; le script test du projet reste tel quel.`
628
- );
629
- }
630
- if (b.test) {
631
- lignes.push(
632
- `Script test : \`${b.test.ancien}\` remplacé par le test du cadre \`${b.test.nouveau}\` (Turborepo : construction, puis tests ; une tâche dont rien n'a bougé est relue de son cache ; \`npm run verifier\` joue les gardes et les tests).`
633
- );
634
- }
635
477
  return lignes.map(l => `${l}\n`).join('');
636
478
  }
637
479
 
638
- // Whether the bilan <b> of `mettreAJour` asks for `npm install` (a tool or the frame's package
639
- // newly declared), which the verification needs first.
640
- const aInstaller = b =>
641
- b.dependances.length > 0 || b.configVitest !== null || b.dependanceDuCadre !== null;
480
+ // Whether the bilan <b> of `mettreAJour` asks for `npm install` (a tool or what the language's
481
+ // share declares), which the verification needs first.
482
+ const aInstaller = b => b.dependances.length > 0 || b.duLangage.installer;
642
483
 
643
484
  // The project's verification, the last step of the update (see the header): `{ code, ligne,
644
485
  // erreur }`, the code of `npm run verifier` (null when it is not played), the line of the report,
645
- // and whether it goes on the error stream.
646
- function verifier(projet, { fichiersAFinir, installer, vitest }) {
486
+ // and whether it goes on the error stream. <sansVerifier>: the language's line on a project
487
+ // without script `verifier`.
488
+ function verifier(projet, { fichiersAFinir, installer, sansVerifier }) {
647
489
  const VERT_INTACT = 'le dernier vert reste où il était';
648
490
  if (fichiersAFinir) {
649
491
  return {
@@ -657,9 +499,7 @@ function verifier(projet, { fichiersAFinir, installer, vitest }) {
657
499
  code: null,
658
500
  erreur: false,
659
501
  ligne: `Vérification non jouée : le projet n’a pas de script verifier ; aucun dernier vert n’est posé. ${
660
- vitest
661
- ? 'La ligne « Vitest : » ci-dessus dit pourquoi : installe à la racine le Vitest que le cadre exige, puis relance `npx grillhouse maj`, qui écrit le script.'
662
- : 'La mise à jour l’écrit dans un projet testé par Vitest ; sinon, écris-le pour ses tests.'
502
+ sansVerifier ?? 'Écris-le pour ses tests.'
663
503
  }`,
664
504
  };
665
505
  }
@@ -704,41 +544,58 @@ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
704
544
  process.exitCode = 2;
705
545
  } else {
706
546
  const projet = process.cwd();
707
- const depuis = versionDuProjet(projet);
708
- const migrations = migrer(projet, depuis);
709
- const resteAFaire = migrations.some(m => m.aFaire.length > 0);
710
- const b = mettreAJour(projet, CADRE, resteAFaire ? { inscrite: null } : {});
711
- process.stdout.write(`Cadre ${VERSION}.\n`);
712
- for (const { version, nom, lignes, aFaire } of migrations) {
713
- process.stdout.write(
714
- `Migration ${version} (${nom}) :\n${lignes.map(l => `- ${l}\n`).join('')}`
715
- );
716
- if (aFaire.length > 0) {
717
- process.stderr.write(
718
- `Migration ${version} (${nom}), à faire :\n${aFaire.map(l => `- ${l}\n`).join('')}`
719
- );
720
- process.exitCode = 1;
721
- }
722
- }
723
- process.stdout.write(rapport(b));
724
- const echecsDesGeneres = regenerer(projet);
725
- for (const l of [...echecsDesGeneres, ...installerGreffons(projet)]) {
726
- process.stderr.write(`${l}\n`);
547
+ // The languages first: the migrations of the declared language play with the core's.
548
+ let langages = null;
549
+ try {
550
+ langages = declarerLangages(projet);
551
+ } catch (e) {
552
+ process.stderr.write(`⛔ ${e.message}\n`);
727
553
  process.exitCode = 1;
728
554
  }
729
- for (const { version, nom, lignes } of restesAuProjet(projet, depuis)) {
730
- process.stdout.write(
731
- `Migration ${version} (${nom}), reste au projet :\n${lignes.map(l => `- ${l}\n`).join('')}`
555
+ if (langages !== null) {mettreAJourLeProjet(projet, langages);}
556
+ }
557
+ }
558
+
559
+ // The update of the project at <projet>, its languages <langages> declared (declarerLangages).
560
+ function mettreAJourLeProjet(projet, langages) {
561
+ const depuis = versionDuProjet(projet);
562
+ const migrations = migrer(projet, depuis);
563
+ const resteAFaire = migrations.some(m => m.aFaire.length > 0);
564
+ const b = { ...mettreAJour(projet, CADRE, resteAFaire ? { inscrite: null } : {}), langages };
565
+ process.stdout.write(`Cadre ${VERSION}.\n`);
566
+ for (const { version, nom, lignes, aFaire } of migrations) {
567
+ process.stdout.write(
568
+ `Migration ${version} (${nom}) :\n${lignes.map(l => `- ${l}\n`).join('')}`
569
+ );
570
+ if (aFaire.length > 0) {
571
+ process.stderr.write(
572
+ `Migration ${version} (${nom}), à faire :\n${aFaire.map(l => `- ${l}\n`).join('')}`
732
573
  );
574
+ process.exitCode = 1;
733
575
  }
734
- const v = verifier(projet, {
735
- fichiersAFinir: resteAFaire || echecsDesGeneres.length > 0,
736
- installer: aInstaller(b),
737
- vitest: b.vitest,
738
- });
739
- (v.erreur ? process.stderr : process.stdout).write(`${v.ligne}\n`);
740
- if (v.code !== null && !process.exitCode) {
741
- process.exitCode = v.code;
742
- }
576
+ }
577
+ process.stdout.write(rapport(b));
578
+ const binaires = installerBinaires(projet);
579
+ if (binaires.installes.length > 0) {
580
+ process.stdout.write(`Binaires installés : ${binaires.installes.join(', ')}.\n`);
581
+ }
582
+ const echecsDesGeneres = regenerer(projet);
583
+ for (const l of [...binaires.lignes, ...echecsDesGeneres, ...installerGreffons(projet)]) {
584
+ process.stderr.write(`${l}\n`);
585
+ process.exitCode = 1;
586
+ }
587
+ for (const { version, nom, lignes } of restesAuProjet(projet, depuis)) {
588
+ process.stdout.write(
589
+ `Migration ${version} (${nom}), reste au projet :\n${lignes.map(l => `- ${l}\n`).join('')}`
590
+ );
591
+ }
592
+ const v = verifier(projet, {
593
+ fichiersAFinir: resteAFaire || echecsDesGeneres.length > 0,
594
+ installer: aInstaller(b),
595
+ sansVerifier: b.duLangage.sansVerifier,
596
+ });
597
+ (v.erreur ? process.stderr : process.stdout).write(`${v.ligne}\n`);
598
+ if (v.code !== null && !process.exitCode) {
599
+ process.exitCode = v.code;
743
600
  }
744
601
  }