@roomi-fields/grillhouse 0.24.14 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/bin/grillhouse.mjs +40 -12
- package/cadre/templates/cargo/.config/nextest.toml +8 -0
- package/cadre/templates/cargo/deny.toml +36 -0
- package/cadre/templates/cargo/package.json +15 -0
- package/cadre/templates/cargo/rust-toolchain.toml +6 -0
- package/cadre/templates/projet/package.json +5 -1
- package/cadre/templates/turbo/paquets.json +1 -1
- package/cadre/templates/turbo/sans-paquets.json +1 -1
- package/charte.md +16 -0
- package/docs/ARCHITECTURE.md +167 -17
- package/docs/CADRE.md +47 -0
- package/docs/INTERFACE.md +168 -0
- package/package.json +71 -14
- package/scripts/arbitrages.mjs +23 -0
- package/scripts/avancement.mjs +15 -29
- package/scripts/circuit.mjs +89 -97
- package/scripts/commande-du-langage.mjs +56 -0
- package/scripts/composants-affectes.mjs +47 -170
- package/scripts/conformite.d.ts +27 -0
- package/scripts/conformite.mjs +226 -0
- package/scripts/demon.mjs +1 -1
- package/scripts/dernier-vert.mjs +11 -9
- package/scripts/droits.mjs +27 -21
- package/scripts/enveloppe/enveloppe.mjs +206 -64
- package/scripts/enveloppe/lancer.sh +24 -75
- package/scripts/enveloppe/paquets-du-plan.mjs +24 -2
- package/scripts/etapes.mjs +2 -2
- package/scripts/gardes-du-cadre.mjs +12 -18
- package/scripts/grillhouse-maj.mjs +246 -389
- package/scripts/init.mjs +2 -1
- package/scripts/integration/file.mjs +3 -3
- package/scripts/integration/integrer.mjs +13 -10
- package/scripts/integration/rejeu.mjs +36 -7
- package/scripts/jointure.d.ts +304 -0
- package/scripts/langages/cargo/binaires.json +4 -0
- package/scripts/langages/cargo/binaires.mjs +60 -0
- package/scripts/langages/cargo/clippy.mjs +103 -0
- package/scripts/langages/cargo/commandes.mjs +378 -0
- package/scripts/langages/cargo/composants.mjs +191 -0
- package/scripts/langages/cargo/elements-du-lot.mjs +139 -0
- package/scripts/langages/cargo/exemples.mjs +357 -0
- package/scripts/langages/cargo/frontieres.mjs +84 -0
- package/scripts/langages/cargo/index-interfaces.mjs +138 -0
- package/scripts/langages/cargo/index.mjs +115 -0
- package/scripts/langages/cargo/mise-a-jour.mjs +93 -0
- package/scripts/langages/cargo/nextest.toml +5 -0
- package/scripts/langages/cargo/touches.mjs +93 -0
- package/scripts/langages/cargo/verdict.mjs +85 -0
- package/scripts/langages/typescript/chemins-des-tests.mjs +68 -0
- package/scripts/{code-mort.mjs → langages/typescript/code-mort.mjs} +5 -5
- package/scripts/langages/typescript/composants.mjs +64 -0
- package/scripts/{consommateurs-arbitres.mjs → langages/typescript/consommateurs-arbitres.mjs} +6 -24
- package/scripts/{consommateurs.mjs → langages/typescript/consommateurs.mjs} +13 -71
- package/scripts/langages/typescript/construire.mjs +176 -0
- package/scripts/{elements-du-lot.mjs → langages/typescript/elements-du-lot.mjs} +2 -2
- package/scripts/langages/typescript/exemples.mjs +289 -0
- package/scripts/{frontieres.mjs → langages/typescript/frontieres.mjs} +3 -5
- package/scripts/{index-interfaces.mjs → langages/typescript/index-interfaces.mjs} +3 -3
- package/scripts/langages/typescript/index.mjs +335 -0
- package/scripts/{interfaces-contre-code.mjs → langages/typescript/interfaces-contre-code.mjs} +2 -2
- package/scripts/langages/typescript/lecteurs.mjs +179 -0
- package/scripts/{migrations → langages/typescript/migrations}/0.23.0-config-vitest.mjs +14 -29
- package/scripts/{migrations → langages/typescript/migrations}/0.24.4-noms-declares-inutilises.mjs +2 -2
- package/scripts/{migrations → langages/typescript/migrations}/0.24.6-lignes-mal-formees.mjs +2 -2
- package/scripts/{migrations → langages/typescript/migrations}/0.24.7-matiere-dans-les-tests.mjs +2 -2
- package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +27 -0
- package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +31 -0
- package/scripts/langages/typescript/mise-a-jour.mjs +320 -0
- package/scripts/{references-par-les-types.mjs → langages/typescript/references-par-les-types.mjs} +3 -3
- package/scripts/langages/typescript/regle-des-tests.mjs +39 -0
- package/scripts/{resumes.mjs → langages/typescript/resumes.mjs} +4 -4
- package/scripts/langages/typescript/script-des-tests.mjs +6 -0
- package/scripts/langages/typescript/tailles-des-tests.mjs +219 -0
- package/scripts/langages/typescript/tests-de-nuit.mjs +57 -0
- package/scripts/{tests.mjs → langages/typescript/tests.mjs} +41 -32
- package/scripts/{turbo-des-paquets.mjs → langages/typescript/turbo-des-paquets.mjs} +61 -34
- package/scripts/langages/typescript/verdict.mjs +105 -0
- package/scripts/{verifier.mjs → langages/typescript/verifier.mjs} +53 -34
- package/scripts/{vitest-config → langages/typescript/vitest-config}/avancement.reporter.mjs +10 -2
- package/scripts/{vitest-config → langages/typescript/vitest-config}/base.mjs +63 -9
- package/scripts/{vitest-config → langages/typescript/vitest-config}/changements.mjs +18 -9
- package/scripts/{vitest-config → langages/typescript/vitest-config}/cibles.mjs +7 -6
- package/scripts/{vitest-config → langages/typescript/vitest-config}/duree.reporter.mjs +6 -1
- package/scripts/langages/typescript/vitest-config/lances.mjs +473 -0
- package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.setup.mjs +1 -1
- package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.mjs +5 -5
- package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.setup.mjs +4 -3
- package/scripts/{vitest.nuit.config.mjs → langages/typescript/vitest.nuit.config.mjs} +2 -2
- package/scripts/langages.mjs +85 -0
- package/scripts/{vitest-config → mesure}/avancement.mjs +4 -13
- package/scripts/{vitest-config → mesure}/base-de-passe.mjs +70 -33
- package/scripts/{vitest-config → mesure}/pression.mjs +5 -6
- package/scripts/migrations/0.23.2-copies-du-cadre.mjs +29 -6
- package/scripts/migrations/0.24.0-circuit-simplifie.mjs +13 -6
- package/scripts/migrations/0.25.0-script-des-tests.mjs +92 -0
- package/scripts/migrations.mjs +17 -13
- package/scripts/nuit.sh +59 -63
- package/scripts/paquets.d.ts +5 -0
- package/scripts/paquets.mjs +24 -2
- package/scripts/resultats.mjs +8 -82
- package/scripts/services-du-noyau.mjs +30 -0
- package/scripts/session-start.sh +17 -9
- package/scripts/sources.mjs +35 -13
- package/scripts/sous-commandes.mjs +57 -17
- package/scripts/superviseur.mjs +1 -1
- package/scripts/tableau.mjs +1 -1
- package/scripts/un-commit-par-ticket.mjs +48 -14
- package/scripts/verrou-de-fichier.mjs +1 -1
- package/scripts/verrou-de-machine.mjs +4 -4
- package/scripts/verrous/verrou.mjs +28 -37
- package/skills/developpeur/SKILL.md +2 -2
- package/skills/explorateur/SKILL.md +13 -5
- package/skills/grill/SKILL.md +2 -2
- package/skills/pitmaster/references/cadre.md +1 -1
- package/skills/pitmaster/references/consigne-agent.md +10 -3
- package/skills/redacteur/references/documents-d-un-composant.md +4 -4
- package/skills/relecteur/SKILL.md +4 -1
- package/skills/testwriter/SKILL.md +20 -6
- /package/scripts/{consommateurs.d.ts → langages/typescript/consommateurs.d.ts} +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/base.d.ts +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/machine.setup.mjs +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.d.ts +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.mjs +0 -0
|
@@ -5,17 +5,25 @@
|
|
|
5
5
|
// - A base is a directory `<dans>/grillhouse-<genre>-XXXXXX/`, `<dans>` the temporary directory of
|
|
6
6
|
// whoever opens it (`os.tmpdir()`). It holds its owner (`.grillhouse-base`: the process that
|
|
7
7
|
// opened it and that process's PID namespace) and `t/`, the directory where the pass and its
|
|
8
|
-
// processes write: the pass names it in `TMPDIR` to its children
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
8
|
+
// processes write: the pass names it in `TMPDIR`, `TMP` and `TEMP` to its children (`env`), so
|
|
9
|
+
// `os.tmpdir()`, `mktemp`, Rust's `std::env::temp_dir()`, Python's `tempfile` and Claude Code
|
|
10
|
+
// (`CLAUDE_CODE_TMPDIR`, else `os.tmpdir()`) write there.
|
|
11
|
+
// - The genres: `vitest`, each run of the tests of the module typescript (a plugin of its base
|
|
12
|
+
// configuration, scripts/langages/typescript/vitest-config/base.mjs), which holds the runner's own temporary
|
|
13
|
+
// directory too; `tests`, `npm test` (scripts/langages/typescript/tests.mjs); `verification`,
|
|
14
|
+
// `npm run verifier` (scripts/langages/typescript/verifier.mjs), whose base Turborepo passes to its tasks
|
|
15
|
+
// (`globalPassThroughEnv`, scripts/langages/typescript/turbo-des-paquets.mjs); `circuit`, the results and progress
|
|
14
16
|
// of the passes of a circuit's run (scripts/circuit.mjs; its working directory is the ticket's,
|
|
15
17
|
// beside its copy, which no sweep touches); `integration`, the working directory of an
|
|
16
18
|
// integration (scripts/integration/integrer.mjs); `enveloppe`, the throwaway state of a session's envelope
|
|
17
19
|
// (scripts/enveloppe/enveloppe.mjs).
|
|
18
|
-
// - The base is removed at the end of the pass, green or red (`fermer`)
|
|
20
|
+
// - The base is removed at the end of the pass, green or red (`fermer`), and when the pass is
|
|
21
|
+
// interrupted (SIGINT, SIGTERM, SIGHUP: `retirerALInterruption`), as pytest's `tmp_path` and
|
|
22
|
+
// Rust's `tempfile` remove theirs.
|
|
23
|
+
// - The guard of a pass of tests: what its tests left in `t/` (`restes`) fails the pass, named
|
|
24
|
+
// (`ligneDesRestes`), as the CI of osc-bridge runs its tests under a temporary directory of
|
|
25
|
+
// their own and fails on anything left there; each module of language plays it in its runner of
|
|
26
|
+
// tests (the base configuration of Vitest, the module cargo's `tester` and `verifier`).
|
|
19
27
|
// - Opening a base first sweeps `<dans>`: every base there whose owner is gone is removed, whatever
|
|
20
28
|
// its genre. A base is judged by its owner's process only when that owner lives in the PID
|
|
21
29
|
// namespace of the sweeper (an envelope has its own, bwrap --unshare-pid, where a number means
|
|
@@ -102,12 +110,60 @@ function balayer(dans) {
|
|
|
102
110
|
}
|
|
103
111
|
}
|
|
104
112
|
|
|
113
|
+
// The variables that name the temporary directory: TMPDIR (POSIX, Node, Rust), TMP and TEMP
|
|
114
|
+
// (Windows, Python's `tempfile`).
|
|
115
|
+
const TEMPORAIRES = ['TMPDIR', 'TMP', 'TEMP'];
|
|
116
|
+
|
|
117
|
+
// The names in <dossier>, sorted; none when it does not read.
|
|
118
|
+
function contenu(dossier) {
|
|
119
|
+
try {
|
|
120
|
+
return readdirSync(dossier).sort();
|
|
121
|
+
} catch {
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The line of the guard of a pass of tests: what its tests left in their temporary directory,
|
|
128
|
+
* named; null when they left nothing.
|
|
129
|
+
* @param {string[]} restes the names left (`restes` of a base)
|
|
130
|
+
* @returns {string | null}
|
|
131
|
+
*/
|
|
132
|
+
export function ligneDesRestes(restes) {
|
|
133
|
+
if (restes.length === 0) return null;
|
|
134
|
+
return `⛔ Les tests ont laissé dans leur dossier temporaire : ${restes.join(', ')}. Un test retire ce qu'il y crée, rouge compris.`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// The signals that interrupt a pass: Ctrl-C, a kill, the end of its terminal.
|
|
138
|
+
const INTERRUPTIONS = ['SIGINT', 'SIGTERM', 'SIGHUP'];
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Runs <retirer> when the process is interrupted (SIGINT, SIGTERM, SIGHUP), then lets the signal
|
|
142
|
+
* end it as it would have: its handler gone, the signal sent again. A process blocked in a
|
|
143
|
+
* synchronous child (`spawnSync`) runs it once the child ends, which the same Ctrl-C ends.
|
|
144
|
+
* @param {() => void} retirer what goes at the interruption
|
|
145
|
+
* @returns {() => void} the removal of the handlers, at the end of the pass
|
|
146
|
+
*/
|
|
147
|
+
export function retirerALInterruption(retirer) {
|
|
148
|
+
const lacher = () => {
|
|
149
|
+
for (const s of INTERRUPTIONS) process.removeListener(s, surSignal);
|
|
150
|
+
};
|
|
151
|
+
function surSignal(signal) {
|
|
152
|
+
lacher();
|
|
153
|
+
retirer();
|
|
154
|
+
process.kill(process.pid, signal);
|
|
155
|
+
}
|
|
156
|
+
for (const s of INTERRUPTIONS) process.on(s, surSignal);
|
|
157
|
+
return lacher;
|
|
158
|
+
}
|
|
159
|
+
|
|
105
160
|
/**
|
|
106
161
|
* Opens the base of a pass of <genre> in <dans>, after sweeping the orphan bases there.
|
|
107
162
|
* @param {string} genre what the pass is (`vitest`, `circuit`…), in the base's name
|
|
108
163
|
* @param {{ dans?: string }} options `dans`, the directory of the base (`os.tmpdir()`)
|
|
109
|
-
* @returns {{ base: string, dossier: string,
|
|
110
|
-
*
|
|
164
|
+
* @returns {{ base: string, dossier: string, env: Record<string, string>, restes: () => string[],
|
|
165
|
+
* fermer: () => void }} the base; the directory its pass writes in; the variables that name it
|
|
166
|
+
* to the pass's children (TMPDIR, TMP, TEMP); what is in it, sorted; and the removal of the base
|
|
111
167
|
*/
|
|
112
168
|
export function ouvrirBase(genre, { dans = tmpdir() } = {}) {
|
|
113
169
|
balayer(dans);
|
|
@@ -119,30 +175,11 @@ export function ouvrirBase(genre, { dans = tmpdir() } = {}) {
|
|
|
119
175
|
);
|
|
120
176
|
const dossier = path.join(base, 't');
|
|
121
177
|
mkdirSync(dossier);
|
|
122
|
-
return { base, dossier, fermer: () => rmSync(base, { recursive: true, force: true }) };
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// The variable that marks the base of a run of Vitest: `<process>:<base>`, the process that opened
|
|
126
|
-
// it. A configuration loaded again in that process (Vite bundles each load) keeps that base.
|
|
127
|
-
const MARQUE = 'GRILLHOUSE_BASE_DE_VITEST';
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* The plugin of the base configuration that gives a run of Vitest its base: while Vite resolves
|
|
131
|
-
* the configuration, before Vitest makes its own temporary directory (`join(tmpdir(), nanoid())`,
|
|
132
|
-
* its transformed modules), the main process opens a base of genre `vitest` and names it in its
|
|
133
|
-
* `TMPDIR`, which every test process inherits; the base is removed when the process exits, green
|
|
134
|
-
* or red. A process that already opened its base keeps it.
|
|
135
|
-
* @returns {{ name: string, config: () => void }} a plugin of Vite
|
|
136
|
-
*/
|
|
137
|
-
export function baseDeVitest() {
|
|
138
178
|
return {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
process.env.TMPDIR = b.dossier;
|
|
145
|
-
process.on('exit', b.fermer);
|
|
146
|
-
},
|
|
179
|
+
base,
|
|
180
|
+
dossier,
|
|
181
|
+
env: Object.fromEntries(TEMPORAIRES.map(v => [v, dossier])),
|
|
182
|
+
restes: () => contenu(dossier),
|
|
183
|
+
fermer: () => rmSync(base, { recursive: true, force: true }),
|
|
147
184
|
};
|
|
148
185
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
// The CPU pressure of the machine, the witness of rest for every measure of time: a time witness
|
|
3
2
|
// is measured with the CPU at rest, and a failure that depends on a duration under load is played
|
|
4
3
|
// again at rest (« à repasser »), never taken as a red nor as a green. The model is Bazel's
|
|
@@ -9,11 +8,11 @@
|
|
|
9
8
|
// GRILLHOUSE_PRESSION_CPU names another file of the same form (the trials write it).
|
|
10
9
|
// - The machine is at rest under SEUIL_PRESSION (25 %); at or above it, it is under load.
|
|
11
10
|
// - A file that does not read (no pressure stall information on the machine) gives null: whoever
|
|
12
|
-
// reads it says « pression illisible » and leaves the verdict to
|
|
11
|
+
// reads it says « pression illisible » and leaves the verdict to the runner of the tests.
|
|
13
12
|
// - A_REPASSER, 75, is the exit code of « à repasser » (EX_TEMPFAIL of sysexits.h: try again
|
|
14
|
-
// later), neither green nor red: the duration reporter of
|
|
15
|
-
// (
|
|
16
|
-
// integration, the queue and the night.
|
|
13
|
+
// later), neither green nor red: the duration reporter of the module of the language gives it
|
|
14
|
+
// (scripts/langages/typescript/vitest-config/duree.reporter.mjs), `npm run verifier` reads it (scripts/langages/typescript/verifier.mjs),
|
|
15
|
+
// and so do the integration, the queue and the night.
|
|
17
16
|
//
|
|
18
17
|
// npx grillhouse pression attendre
|
|
19
18
|
//
|
|
@@ -60,7 +59,7 @@ export function attendreLeRepos({
|
|
|
60
59
|
for (;;) {
|
|
61
60
|
const p = lire();
|
|
62
61
|
if (p === null) {
|
|
63
|
-
dire('⏳ pression CPU illisible : la relance part sans attendre, verdict
|
|
62
|
+
dire('⏳ pression CPU illisible : la relance part sans attendre, verdict des tests.');
|
|
64
63
|
return true;
|
|
65
64
|
}
|
|
66
65
|
if (p < SEUIL_PRESSION) return true;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// - Each file `empreintes.json` records that a line of `fichiers.txt` keeps (the file itself, or a
|
|
8
8
|
// directory « …/ » above it; a line « - … » keeps none) goes when its bytes have the recorded
|
|
9
9
|
// SHA-256 (as the former update computed it), or had it before the migration 0.23.0 of Vitest
|
|
10
|
-
// rewrote its import of the base (`formesAnterieures
|
|
10
|
+
// rewrote its import of the base (`formesAnterieures`, below); a directory
|
|
11
11
|
// it leaves empty goes with it. A file the template of a project holds at the same path
|
|
12
12
|
// (`tsdoc.json`, `docs/agents/issue-tracker.md`) is the project's own since 0.23.0, as
|
|
13
13
|
// `grillhouse init` places it, and stays.
|
|
@@ -37,8 +37,7 @@ import path from 'node:path';
|
|
|
37
37
|
import { CADRE, PAQUET } from '../cadre.mjs';
|
|
38
38
|
import { paquets } from '../paquets.mjs';
|
|
39
39
|
import { importe, sources } from '../sources.mjs';
|
|
40
|
-
import {
|
|
41
|
-
import { formesAnterieures } from './0.23.0-config-vitest.mjs';
|
|
40
|
+
import { scriptsDesSousCommandes } from '../sous-commandes.mjs';
|
|
42
41
|
import { deRoleSupprime } from './0.24.0-circuit-simplifie.mjs';
|
|
43
42
|
import { dependanceDuPaquet, DU_PAQUET } from './0.24.2-api-extractor-du-paquet.mjs';
|
|
44
43
|
|
|
@@ -56,11 +55,34 @@ const APPEL = /(^|[\s;&|(])(?:node|bash)\s+(?:\.\/)?(scripts\/[^\s'";&|)]+)/g;
|
|
|
56
55
|
// The first line of a file the generator of the packages' turbo.json wrote.
|
|
57
56
|
const GENERE = /^\/\/ Généré par `[^`\n]*turbo-des-paquets[^`\n]*`/;
|
|
58
57
|
|
|
58
|
+
// What the migration of 0.23.0 of Vitest (the module typescript's) wrote in a copy: a quoted name
|
|
59
|
+
// of the package's base, in place of the former package's or of a former path of the base.
|
|
60
|
+
const ECRIT = /(['"])@roomi-fields\/grillhouse\/vitest-config(\/mesure)?\1/g;
|
|
61
|
+
const ANCIEN = '@grillhouse/vitest-config';
|
|
62
|
+
const ANCIENS_CHEMINS = [
|
|
63
|
+
'./scripts/vitest-config/base.mjs',
|
|
64
|
+
'./packages/grillhouse/scripts/vitest-config/base.mjs',
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
// The texts <texte> may have held before the migration of 0.23.0 rewrote it: each name it wrote
|
|
68
|
+
// back to the former package's, or each name of the base back to one former path; none when it
|
|
69
|
+
// wrote nothing.
|
|
70
|
+
function formesAnterieures(texte) {
|
|
71
|
+
if (texte.search(ECRIT) < 0) return [];
|
|
72
|
+
return [
|
|
73
|
+
texte.replace(ECRIT, (_, q, mesure) => `${q}${ANCIEN}${mesure ?? ''}${q}`),
|
|
74
|
+
...ANCIENS_CHEMINS.map(c =>
|
|
75
|
+
texte.replace(ECRIT, (tout, q, mesure) => (mesure ? tout : `${q}${c}${q}`))
|
|
76
|
+
),
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
|
|
59
80
|
const hacher = octets => createHash('sha256').update(octets).digest('hex');
|
|
60
81
|
const lireJson = f => JSON.parse(readFileSync(f, 'utf8'));
|
|
61
82
|
|
|
62
83
|
// The subcommand that runs each script of the package, by the path of its former copy.
|
|
63
|
-
const
|
|
84
|
+
const parCopie = projet =>
|
|
85
|
+
new Map(Object.entries(scriptsDesSousCommandes(projet)).map(([n, s]) => [`scripts/${s}`, n]));
|
|
64
86
|
|
|
65
87
|
// The lines of the list that keep a path: a file, or a directory « …/ ».
|
|
66
88
|
const gardees = texte =>
|
|
@@ -154,11 +176,12 @@ export function migrer(projet) {
|
|
|
154
176
|
const fPkg = path.join(projet, 'package.json');
|
|
155
177
|
if (!existsSync(fPkg)) return sortie;
|
|
156
178
|
const pkg = lireJson(fPkg);
|
|
179
|
+
const par = parCopie(projet);
|
|
157
180
|
let reecrit = false;
|
|
158
181
|
for (const [n, script] of Object.entries(pkg.scripts ?? {})) {
|
|
159
182
|
if (typeof script !== 'string') continue;
|
|
160
183
|
const neuf = script.replace(APPEL, (tout, avant, f) =>
|
|
161
|
-
retires.has(f) &&
|
|
184
|
+
retires.has(f) && par.has(f) ? `${avant}grillhouse ${par.get(f)}` : tout
|
|
162
185
|
);
|
|
163
186
|
if (neuf !== script) {
|
|
164
187
|
pkg.scripts[n] = neuf;
|
|
@@ -173,7 +196,7 @@ export function migrer(projet) {
|
|
|
173
196
|
}
|
|
174
197
|
}
|
|
175
198
|
for (const f of restes.filter(r => neuf.includes(r))) {
|
|
176
|
-
const sous =
|
|
199
|
+
const sous = par.get(f);
|
|
177
200
|
sortie.push({
|
|
178
201
|
aFaire: `package.json : le script ${n} lance ${f}, copie modifiée laissée en place ; son \`git rm\` le casse : ${sous ? `\`grillhouse ${sous}\` le remplace` : 'à réécrire'}`,
|
|
179
202
|
});
|
|
@@ -44,7 +44,7 @@ import { existsSync, lstatSync, readdirSync, readFileSync, writeFileSync } from
|
|
|
44
44
|
import path from 'node:path';
|
|
45
45
|
import { CADRE, PAQUET } from '../cadre.mjs';
|
|
46
46
|
import { CROCHETS } from '../crochets.mjs';
|
|
47
|
-
import {
|
|
47
|
+
import { scriptsDesSousCommandes } from '../sous-commandes.mjs';
|
|
48
48
|
|
|
49
49
|
export const version = '0.24.0';
|
|
50
50
|
export const nom = 'circuit simplifié';
|
|
@@ -156,12 +156,17 @@ function copies(projet) {
|
|
|
156
156
|
}));
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
// The path under `scripts/` where the frame of a former version kept the script <s> of the package
|
|
160
|
+
// (a path under `scripts/`): a script of a module of language lay where its module's folder now
|
|
161
|
+
// holds it, directly under `scripts/` (grillhouse-3dr.2.2).
|
|
162
|
+
const ancienne = s => s.replace(/^langages\/[^/]+\//, '');
|
|
163
|
+
|
|
159
164
|
// What replaces each script of the frame, by its path under `scripts/`: its subcommand, its hook,
|
|
160
165
|
// its named entry; none for a script of the package that has none of them.
|
|
161
|
-
function remplacants() {
|
|
166
|
+
function remplacants(projet) {
|
|
162
167
|
const r = new Map();
|
|
163
168
|
const ajouter = (script, quoi) => r.set(script, [...(r.get(script) ?? []), quoi]);
|
|
164
|
-
for (const [n, s] of Object.entries(
|
|
169
|
+
for (const [n, s] of Object.entries(scriptsDesSousCommandes(projet))) {
|
|
165
170
|
ajouter(s, `\`grillhouse ${n}\``);
|
|
166
171
|
}
|
|
167
172
|
for (const [n, c] of Object.entries(CROCHETS)) {
|
|
@@ -173,12 +178,14 @@ function remplacants() {
|
|
|
173
178
|
for (const [entree, cible] of Object.entries(exports)) {
|
|
174
179
|
const d = typeof cible === 'string' ? cible : cible?.default;
|
|
175
180
|
if (typeof d === 'string' && d.startsWith('./scripts/')) {
|
|
176
|
-
ajouter(d.slice('./scripts/'.length), `\`${name}${entree.slice(1)}\``);
|
|
181
|
+
ajouter(ancienne(d.slice('./scripts/'.length)), `\`${name}${entree.slice(1)}\``);
|
|
177
182
|
}
|
|
178
183
|
}
|
|
179
184
|
const scripts = path.join(PAQUET, 'scripts');
|
|
180
185
|
for (const e of readdirSync(scripts, { recursive: true, withFileTypes: true })) {
|
|
181
|
-
const s =
|
|
186
|
+
const s = ancienne(
|
|
187
|
+
path.relative(scripts, path.join(e.parentPath, e.name)).split(path.sep).join('/')
|
|
188
|
+
);
|
|
182
189
|
if (e.isFile() && SCRIPT.test(s) && !r.has(s)) {
|
|
183
190
|
r.set(s, []);
|
|
184
191
|
}
|
|
@@ -236,7 +243,7 @@ export function restes(projet) {
|
|
|
236
243
|
} catch {
|
|
237
244
|
return [];
|
|
238
245
|
}
|
|
239
|
-
const par = remplacants();
|
|
246
|
+
const par = remplacants(projet);
|
|
240
247
|
const sortie = [];
|
|
241
248
|
for (const f of suivis) {
|
|
242
249
|
const absolu = path.join(projet, f);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// From 0.25.0 the script of the tests is named `test:unit`, the same for every language (decision 4
|
|
2
|
+
// of the epic grillhouse-pkl): `test:vitest` named the runner of one language, and the core named
|
|
3
|
+
// it. The circuit asks the module of language which component plays tests (`joueDesTests`), and
|
|
4
|
+
// the module typescript answers by `test:unit`; Turborepo's task has the script's name.
|
|
5
|
+
//
|
|
6
|
+
// - Each package.json of the project, the root's and each package's of the frame (scripts/paquets.mjs,
|
|
7
|
+
// a package out of the frame is its own), whose scripts hold `test:vitest` has it named
|
|
8
|
+
// `test:unit`, its command and its place kept. One that already holds `test:unit` with the same
|
|
9
|
+
// command loses `test:vitest`; with another command, nothing is written, and the project
|
|
10
|
+
// chooses (`aFaire`): the former name never stays beside the new one.
|
|
11
|
+
// - Each turbo.json (or turbo.jsonc) of the root and of the packages of the frame that names the
|
|
12
|
+
// task `test:vitest` (a task, a dependency `^test:vitest` or `<paquet>#test:vitest`) names
|
|
13
|
+
// `test:unit` instead, its text kept otherwise; one that names both is left to the project.
|
|
14
|
+
// - A project already in the new form is not written: a second pass changes nothing.
|
|
15
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { paquets } from '../paquets.mjs';
|
|
18
|
+
|
|
19
|
+
export const version = '0.25.0';
|
|
20
|
+
export const nom = 'nom du script des tests';
|
|
21
|
+
|
|
22
|
+
const ANCIEN = 'test:vitest';
|
|
23
|
+
const NOUVEAU = 'test:unit';
|
|
24
|
+
// The task of the former name in the text of a turbo.json: a key or an entry of `dependsOn`.
|
|
25
|
+
const TACHE = /(?<=["^#])test:vitest(?=")/g;
|
|
26
|
+
const TACHE_NEUVE = /(?<=["^#])test:unit(?=")/;
|
|
27
|
+
|
|
28
|
+
const lireJson = f => JSON.parse(readFileSync(f, 'utf8'));
|
|
29
|
+
const ecrireJson = (f, v) => writeFileSync(f, `${JSON.stringify(v, null, 2)}\n`);
|
|
30
|
+
|
|
31
|
+
// The directories of the project at <projet> whose files this migration reads: the root, then
|
|
32
|
+
// each package of the frame.
|
|
33
|
+
const dossiers = projet => [
|
|
34
|
+
'.',
|
|
35
|
+
...paquets(projet)
|
|
36
|
+
.filter(p => !p.hors)
|
|
37
|
+
.map(p => p.dossier),
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
// The script of the package.json <rel> of <projet>; what it did, or what it leaves.
|
|
41
|
+
function renommerLeScript(projet, rel) {
|
|
42
|
+
const f = path.join(projet, rel);
|
|
43
|
+
if (!existsSync(f)) return [];
|
|
44
|
+
const pkg = lireJson(f);
|
|
45
|
+
const scripts = pkg.scripts;
|
|
46
|
+
if (!scripts || !Object.hasOwn(scripts, ANCIEN)) return [];
|
|
47
|
+
if (Object.hasOwn(scripts, NOUVEAU) && scripts[NOUVEAU] !== scripts[ANCIEN]) {
|
|
48
|
+
return [
|
|
49
|
+
{
|
|
50
|
+
aFaire: `${rel} : ${ANCIEN} et ${NOUVEAU} y portent deux commandes (« ${scripts[ANCIEN]} », « ${scripts[NOUVEAU]} ») ; garder la bonne sous ${NOUVEAU} et retirer ${ANCIEN}.`,
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
const double = Object.hasOwn(scripts, NOUVEAU);
|
|
55
|
+
pkg.scripts = Object.fromEntries(
|
|
56
|
+
Object.entries(scripts).flatMap(([k, v]) => {
|
|
57
|
+
if (k !== ANCIEN) return [[k, v]];
|
|
58
|
+
return double ? [] : [[NOUVEAU, v]];
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
ecrireJson(f, pkg);
|
|
62
|
+
return [`${rel} : le script ${ANCIEN} devient ${NOUVEAU}`];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// The task of the turbo.json <rel> of <projet>; what it did, or what it leaves.
|
|
66
|
+
function renommerLaTache(projet, rel) {
|
|
67
|
+
const f = path.join(projet, rel);
|
|
68
|
+
if (!existsSync(f)) return [];
|
|
69
|
+
const texte = readFileSync(f, 'utf8');
|
|
70
|
+
if (texte.search(TACHE) < 0) return [];
|
|
71
|
+
if (TACHE_NEUVE.test(texte)) {
|
|
72
|
+
return [
|
|
73
|
+
{
|
|
74
|
+
aFaire: `${rel} : les tâches ${ANCIEN} et ${NOUVEAU} y sont toutes deux ; garder ${NOUVEAU} et retirer ${ANCIEN}.`,
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
writeFileSync(f, texte.replace(TACHE, NOUVEAU));
|
|
79
|
+
return [`${rel} : la tâche ${ANCIEN} devient ${NOUVEAU}`];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Names `test:unit` the script and the task of the tests of the project; returns what it did. */
|
|
83
|
+
export function migrer(projet) {
|
|
84
|
+
const ds = dossiers(projet);
|
|
85
|
+
const rel = (d, n) => (d === '.' ? n : path.posix.join(d, n));
|
|
86
|
+
return [
|
|
87
|
+
...ds.flatMap(d => renommerLeScript(projet, rel(d, 'package.json'))),
|
|
88
|
+
...ds.flatMap(d =>
|
|
89
|
+
['turbo.json', 'turbo.jsonc'].flatMap(n => renommerLaTache(projet, rel(d, n)))
|
|
90
|
+
),
|
|
91
|
+
];
|
|
92
|
+
}
|
package/scripts/migrations.mjs
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
// writes on its error stream, its exit code non-zero, as `@turbo/codemod` fails on a file it
|
|
10
10
|
// could not transform. It is replayable without effect: a second pass changes no byte and
|
|
11
11
|
// returns no line.
|
|
12
|
-
// - MIGRATIONS lists
|
|
12
|
+
// - MIGRATIONS lists the core's, each imported by its module, and a module of language carries
|
|
13
|
+
// the ones that replay one of its guards (`migrations`, scripts/jointure.d.ts), as each plugin
|
|
14
|
+
// of Nx carries its own (`migrationsDe`); the update plays those newer than the
|
|
13
15
|
// version the project recorded (`grillhouse.version` of its package.json), in the order of their
|
|
14
16
|
// versions; a project that recorded none plays them all. The package carries no migration newer
|
|
15
17
|
// than itself once released, so the range ends with the package.
|
|
@@ -17,35 +19,37 @@
|
|
|
17
19
|
// update is done, which the update plays after its own update and its regeneration, for each
|
|
18
20
|
// migration it played, and reports (« reste au projet ») without holding back the version, as a
|
|
19
21
|
// codemod reports what it leaves without failing (restesAuProjet).
|
|
20
|
-
// - Each migration has its test, tests/unit/migration.<nom>.spec.ts
|
|
22
|
+
// - Each migration has its test, tests/unit/migration.<nom>.spec.ts (a module's, under its
|
|
23
|
+
// folder of tests, tests/unit/langages/<nom>/).
|
|
21
24
|
import semver from 'semver';
|
|
25
|
+
import { langageDe } from './langages.mjs';
|
|
22
26
|
import * as charteImportee from './migrations/0.23.0-charte-importee.mjs';
|
|
23
|
-
import * as configVitest from './migrations/0.23.0-config-vitest.mjs';
|
|
24
27
|
import * as crochetsDeSeance from './migrations/0.23.0-crochets-de-seance.mjs';
|
|
25
28
|
import * as marcheDuProjet from './migrations/0.23.0-marche-du-projet.mjs';
|
|
26
29
|
import * as copiesDuCadre from './migrations/0.23.2-copies-du-cadre.mjs';
|
|
27
30
|
import * as circuitSimplifie from './migrations/0.24.0-circuit-simplifie.mjs';
|
|
28
31
|
import * as apiExtractorDuPaquet from './migrations/0.24.2-api-extractor-du-paquet.mjs';
|
|
29
|
-
import * as nomsDeclaresInutilises from './migrations/0.24.4-noms-declares-inutilises.mjs';
|
|
30
|
-
import * as lignesMalFormees from './migrations/0.24.6-lignes-mal-formees.mjs';
|
|
31
|
-
import * as matiereDansLesTests from './migrations/0.24.7-matiere-dans-les-tests.mjs';
|
|
32
32
|
import * as triDesDecouvertes from './migrations/0.24.12-tri-des-decouvertes.mjs';
|
|
33
|
+
import * as scriptDesTests from './migrations/0.25.0-script-des-tests.mjs';
|
|
33
34
|
|
|
34
|
-
/** The migrations of the
|
|
35
|
+
/** The migrations of the core. */
|
|
35
36
|
export const MIGRATIONS = [
|
|
36
37
|
crochetsDeSeance,
|
|
37
|
-
configVitest,
|
|
38
38
|
marcheDuProjet,
|
|
39
39
|
charteImportee,
|
|
40
40
|
copiesDuCadre,
|
|
41
41
|
circuitSimplifie,
|
|
42
42
|
apiExtractorDuPaquet,
|
|
43
|
-
nomsDeclaresInutilises,
|
|
44
|
-
lignesMalFormees,
|
|
45
|
-
matiereDansLesTests,
|
|
46
43
|
triDesDecouvertes,
|
|
44
|
+
scriptDesTests,
|
|
47
45
|
];
|
|
48
46
|
|
|
47
|
+
/**
|
|
48
|
+
* The migrations of the project at <projet>: the core's, and the ones of the module of its
|
|
49
|
+
* language (`migrations`, scripts/jointure.d.ts), as `nx migrate` gathers each plugin's.
|
|
50
|
+
*/
|
|
51
|
+
export const migrationsDe = projet => [...MIGRATIONS, ...langageDe(projet).migrations];
|
|
52
|
+
|
|
49
53
|
/**
|
|
50
54
|
* The migrations of <liste> newer than <depuis> (all of them when it is null), in the order of
|
|
51
55
|
* their versions; two of one version keep their order in the list.
|
|
@@ -62,7 +66,7 @@ export function migrationsAJouer(depuis, liste = MIGRATIONS) {
|
|
|
62
66
|
* What stays to the project at <projet> after the update, for each migration newer than <depuis>
|
|
63
67
|
* that exports `restes` and names something: `{ version, nom, lignes }`.
|
|
64
68
|
*/
|
|
65
|
-
export function restesAuProjet(projet, depuis, liste =
|
|
69
|
+
export function restesAuProjet(projet, depuis, liste = migrationsDe(projet)) {
|
|
66
70
|
return migrationsAJouer(depuis, liste)
|
|
67
71
|
.filter(m => typeof m.restes === 'function')
|
|
68
72
|
.map(m => ({ version: m.version, nom: m.nom, lignes: m.restes(projet) }))
|
|
@@ -73,7 +77,7 @@ export function restesAuProjet(projet, depuis, liste = MIGRATIONS) {
|
|
|
73
77
|
* Plays on the project at <projet> each migration newer than <depuis>; returns, for each one that
|
|
74
78
|
* changed something or left something to do, `{ version, nom, lignes, aFaire }`.
|
|
75
79
|
*/
|
|
76
|
-
export function migrer(projet, depuis, liste =
|
|
80
|
+
export function migrer(projet, depuis, liste = migrationsDe(projet)) {
|
|
77
81
|
return migrationsAJouer(depuis, liste)
|
|
78
82
|
.map(m => {
|
|
79
83
|
const tout = m.migrer(projet);
|