@roomi-fields/grillhouse 0.28.3 → 0.29.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 +55 -14
- package/cadre/templates/projet/CLAUDE.md +1 -1
- package/cadre/templates/projet/README.md +11 -11
- package/cadre/templates/projet/_gitignore +2 -5
- package/charte.md +13 -4
- package/docs/ARCHITECTURE.md +260 -29
- package/docs/INTERFACE.md +51 -12
- package/package.json +1 -1
- package/scripts/aiguillage.mjs +324 -0
- package/scripts/avancement.mjs +33 -50
- package/scripts/circuit.mjs +558 -146
- package/scripts/composition-des-langages.mjs +16 -1
- package/scripts/conformite.mjs +16 -0
- package/scripts/copies-finies.mjs +171 -30
- package/scripts/demon.mjs +134 -21
- package/scripts/enveloppe/lancer.sh +13 -14
- package/scripts/enveloppe/travail-de-la-copie.mjs +94 -11
- package/scripts/etapes.mjs +1 -1
- package/scripts/fusion-du-changelog.mjs +0 -1
- package/scripts/grillhouse-maj.mjs +16 -7
- package/scripts/integration/file.mjs +3 -3
- package/scripts/integration/integrer.mjs +3 -3
- package/scripts/jointure.d.ts +39 -17
- package/scripts/langages/cargo/commandes.mjs +152 -25
- package/scripts/langages/cargo/composants.mjs +90 -2
- package/scripts/langages/cargo/exemples.mjs +68 -1
- package/scripts/langages/cargo/index.mjs +17 -8
- package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
- package/scripts/langages/cargo/sccache.mjs +54 -2
- package/scripts/langages/cargo/squelette.mjs +72 -3
- package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
- package/scripts/langages/cargo/tests-de-head.mjs +159 -0
- package/scripts/langages/python/commandes.mjs +44 -7
- package/scripts/langages/python/composants.mjs +33 -3
- package/scripts/langages/python/exemples.mjs +19 -0
- package/scripts/langages/python/index.mjs +4 -0
- package/scripts/langages/python/squelette.mjs +119 -17
- package/scripts/langages/typescript/exemples.mjs +16 -0
- package/scripts/langages/typescript/index.mjs +6 -3
- package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
- package/scripts/langages/typescript/squelette.mjs +18 -2
- package/scripts/langages/typescript/tests-de-nuit.mjs +41 -21
- package/scripts/langages/typescript/verifier.mjs +82 -288
- package/scripts/langages/typescript/vitest-config/base.mjs +8 -9
- package/scripts/langages/typescript/vitest-config/cibles.mjs +92 -53
- package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +11 -5
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +4 -2
- package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
- package/scripts/langages/typescript/vitest.nuit.config.mjs +18 -13
- package/scripts/lecture-unique.mjs +51 -0
- package/scripts/mesure/pression.mjs +9 -7
- package/scripts/nuit.sh +19 -12
- package/scripts/outil.mjs +72 -0
- package/scripts/paquet.mjs +39 -10
- package/scripts/resultats.mjs +22 -5
- package/scripts/services-du-noyau.mjs +8 -9
- package/scripts/session-start.sh +10 -1
- package/scripts/sortie.mjs +20 -1
- package/scripts/sources.mjs +3 -3
- package/scripts/sous-commandes.mjs +1 -0
- package/scripts/superviseur.mjs +369 -14
- package/scripts/tableau.mjs +219 -58
- package/scripts/verrou-de-machine.mjs +303 -58
- package/skills/developpeur/SKILL.md +11 -3
- package/skills/pitmaster/SKILL.md +58 -23
- package/skills/relecteur/SKILL.md +18 -6
- package/skills/testwriter/SKILL.md +11 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The components of a project of Python, as uv finds a project (PEP 621, `pyproject.toml`): the
|
|
2
2
|
// packages the module python answers the join with (scripts/jointure.d.ts, `composants`,
|
|
3
|
-
// `composantDe`, `matieres`, `joueDesTests`, `lecteurs`, `estUnTest`, `manifestes`,
|
|
3
|
+
// `composantDe`, `matieres`, `joueDesTests`, `lecteurs`, `estUnTest`, `soeurDAvant`, `manifestes`,
|
|
4
4
|
// `entreesDeLIndex`).
|
|
5
5
|
//
|
|
6
6
|
// - A component is a folder that holds a pyproject.toml, found under the root, the folders whose
|
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
// any file under a folder `tests/` of a component, his helpers and his data. Of the manifests
|
|
20
20
|
// (`manifestes`): the group `test` of the table `[dependency-groups]` of a pyproject.toml (PEP
|
|
21
21
|
// 735), what the tests depend on, and the uv.lock of a component, which uv brings in line with
|
|
22
|
-
// it; a change of any other part of a pyproject.toml is named by it. The
|
|
22
|
+
// it; a change of any other part of a pyproject.toml is named by it. The sibling of HEAD's
|
|
23
|
+
// version of a test file (`soeurDAvant`), which the proof of the red plays beside it, is a name
|
|
24
|
+
// pytest collects, of its file's kind: `test_<nom>_circuit_avant.py`, `<nom>_circuit_avant_test.py`,
|
|
25
|
+
// `<nom>_circuit_avant_nuit_test.py`. The pyproject.toml is read
|
|
23
26
|
// with smol-toml, a tool of this module (`outils`), an optional peer of the package loaded when a
|
|
24
27
|
// manifest is judged.
|
|
25
28
|
// - The readers of a package: none read by the module (a dependency between two packages of
|
|
@@ -32,6 +35,7 @@ import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
|
32
35
|
import { createRequire } from 'node:module';
|
|
33
36
|
import path from 'node:path';
|
|
34
37
|
import { isDeepStrictEqual } from 'node:util';
|
|
38
|
+
import { luUneFois } from '../../services-du-noyau.mjs';
|
|
35
39
|
|
|
36
40
|
const require = createRequire(import.meta.url);
|
|
37
41
|
|
|
@@ -74,8 +78,14 @@ function dossiersAvecManifeste(dossier) {
|
|
|
74
78
|
return out;
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
/** The components of the project at <racine>, sorted by folder
|
|
81
|
+
/** The components of the project at <racine>, sorted by folder; read once in a scope of the core
|
|
82
|
+
* (`luUneFois`): a sweep asks it of every file of a folder. */
|
|
78
83
|
export function composants(racine) {
|
|
84
|
+
return luUneFois(`python composants ${path.resolve(racine)}`, () => lireLesComposants(racine));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// The components of `composants`, read at each call.
|
|
88
|
+
function lireLesComposants(racine) {
|
|
79
89
|
return dossiersAvecManifeste(racine)
|
|
80
90
|
.sort()
|
|
81
91
|
.map(dossier => ({
|
|
@@ -137,6 +147,26 @@ export function estUnTest(chemin, racine) {
|
|
|
137
147
|
return null;
|
|
138
148
|
}
|
|
139
149
|
|
|
150
|
+
/**
|
|
151
|
+
* The sibling of HEAD's version of the test file <chemin> (from <racine>), which pytest collects
|
|
152
|
+
* and plays in the same run: `test_<nom>_circuit_avant.py` beside `test_<nom>.py`,
|
|
153
|
+
* `<nom>_circuit_avant_test.py` beside `<nom>_test.py`, `<nom>_circuit_avant_nuit_test.py`
|
|
154
|
+
* beside a night test `<nom>_nuit_test.py`, so that it stays one; a name pytest collects by
|
|
155
|
+
* default (`python_files`), its tests named in its report as the file's; null for a file pytest
|
|
156
|
+
* does not play.
|
|
157
|
+
*/
|
|
158
|
+
export function soeurDAvant(chemin, racine) {
|
|
159
|
+
if (!estUnTest(chemin, racine)?.joue) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
if (estDeNuit(path.basename(chemin))) {
|
|
163
|
+
return chemin.replace(/_nuit_test\.py$/, '_circuit_avant_nuit_test.py');
|
|
164
|
+
}
|
|
165
|
+
return chemin.endsWith('_test.py')
|
|
166
|
+
? chemin.replace(/_test\.py$/, '_circuit_avant_test.py')
|
|
167
|
+
: chemin.replace(/\.py$/, '_circuit_avant.py');
|
|
168
|
+
}
|
|
169
|
+
|
|
140
170
|
// The parts of the parsed manifests <a> and <b> that differ, out of the group of the tests: each
|
|
141
171
|
// `[<table>]`, a group of `[dependency-groups]` as `[dependency-groups].<groupe>`, a key out of
|
|
142
172
|
// every table bare.
|
|
@@ -227,6 +227,25 @@ export default {
|
|
|
227
227
|
'site/tests/donnees.json : test',
|
|
228
228
|
],
|
|
229
229
|
},
|
|
230
|
+
versionDeHead: {
|
|
231
|
+
valide: [
|
|
232
|
+
'site/pages/generer.py',
|
|
233
|
+
'site/conftest.py',
|
|
234
|
+
'site/tests/donnees.json',
|
|
235
|
+
'README.md',
|
|
236
|
+
],
|
|
237
|
+
// A night test keeps its end, so that its sibling stays one.
|
|
238
|
+
invalide: [
|
|
239
|
+
'site/pages/test_pages.py',
|
|
240
|
+
'site/pages/pages_test.py',
|
|
241
|
+
'site/pages/site_nuit_test.py',
|
|
242
|
+
],
|
|
243
|
+
attendu: [
|
|
244
|
+
'site/pages/test_pages.py → site/pages/test_pages_circuit_avant.py',
|
|
245
|
+
'site/pages/pages_test.py → site/pages/pages_circuit_avant_test.py',
|
|
246
|
+
'site/pages/site_nuit_test.py → site/pages/site_circuit_avant_nuit_test.py',
|
|
247
|
+
],
|
|
248
|
+
},
|
|
230
249
|
fichiersEngendres: {
|
|
231
250
|
valide: aJour,
|
|
232
251
|
invalide: enRetard,
|
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
composants,
|
|
39
39
|
entreesDeLIndex,
|
|
40
40
|
estUnTest,
|
|
41
|
+
soeurDAvant,
|
|
41
42
|
joueDesTests,
|
|
42
43
|
lecteurs,
|
|
43
44
|
manifestes,
|
|
@@ -78,6 +79,9 @@ export default {
|
|
|
78
79
|
commandes,
|
|
79
80
|
verdict,
|
|
80
81
|
estUnTest,
|
|
82
|
+
soeurDAvant,
|
|
83
|
+
// Its tool plays HEAD's version of each test file beside it (`soeurDAvant`): no name to read.
|
|
84
|
+
testsDeHead: () => null,
|
|
81
85
|
manifestes,
|
|
82
86
|
fichiersEngendres: () => [
|
|
83
87
|
{
|
|
@@ -2,52 +2,152 @@
|
|
|
2
2
|
// (scripts/jointure.d.ts), which `grillhouse paquet` writes (scripts/paquet.mjs), as `uv init`
|
|
3
3
|
// writes one: no behaviour, no test.
|
|
4
4
|
//
|
|
5
|
-
// - Its
|
|
6
|
-
//
|
|
7
|
-
// the module
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
5
|
+
// - Its name: the folder's, prefixed by the project's name when the root declares one (the
|
|
6
|
+
// `[project].name` of its pyproject.toml, else the `name` of its package.json, its scope when it
|
|
7
|
+
// has one), as the module typescript prefixes a package with the root's scope and Nx names a
|
|
8
|
+
// library after the workspace's scope; normalized as uv writes the name of a project (PEP 503:
|
|
9
|
+
// lowercase, each run of `-`, `_` or `.` read `-`), its module the name with `-` read `_`.
|
|
10
|
+
// - A module that would bear the name of a module of the standard library of Python is refused,
|
|
11
|
+
// by its name, nothing written, the name to give named (the root folder's name before the
|
|
12
|
+
// package's), as `cargo new` refuses a name Rust reserves: `import site` reaches the standard
|
|
13
|
+
// module, never the package. The list is the interpreter's own, `sys.stdlib_module_names`, of
|
|
14
|
+
// the Python the package requires, which uv provides; without uv, the refusal names `npx
|
|
15
|
+
// grillhouse maj`, which installs it.
|
|
16
|
+
// - Its files: its pyproject.toml (PEP 621: its name, its version 0.1.0, the Python it requires, no
|
|
17
|
+
// dependency; its group `test` of `[dependency-groups]`, PEP 735, pytest, which the module runs
|
|
18
|
+
// by `uv run --group test pytest`; the configuration of pytest, `[tool.pytest.ini_options]`, its
|
|
19
|
+
// tests under `tests/` and its code importable from `src/`, as uv's layout of a library has it);
|
|
20
|
+
// `src/<module>/__init__.py`, without code; `tests/.gitkeep`, its folder of tests. The typing is
|
|
11
21
|
// `python -m compileall`, which needs no configuration. No build system: uv neither builds nor
|
|
12
22
|
// installs the package to run its tests.
|
|
13
23
|
// - The workspace: a root pyproject.toml whose `[tool.uv.workspace]` names its `members` receives
|
|
14
24
|
// the package's path there, as `uv init` adds a project under a workspace to its members; without
|
|
15
25
|
// one, the package is its own project of uv, as the module plays each package (./commandes.mjs).
|
|
16
26
|
// - The lock of the versions: `uv lock`, at the workspace's root, else in the package.
|
|
27
|
+
// - A folder that already holds Python code is taken as it is, as `cargo init` takes the code in
|
|
28
|
+
// place: its tests (`test_*.py`, `*_test.py`, pytest's names) are collected where they are, its
|
|
29
|
+
// testpaths the folders that hold them and `tests`, each once, the package itself for a test at
|
|
30
|
+
// its root; no `src/<module>/` beside its code, and no `pythonpath` for code out of `src/`
|
|
31
|
+
// (code under `src/` keeps `pythonpath = ["src"]`); each `requirements.txt` is
|
|
32
|
+
// taken by `uv add -r`, in the order of its path, run in the package, which declares its
|
|
33
|
+
// dependencies and locks them, in place of `uv lock`. A manifest the module does not read
|
|
34
|
+
// (`setup.py`, `setup.cfg`, `Pipfile`) is refused by its name, nothing written, what to do named.
|
|
35
|
+
import { spawnSync } from 'node:child_process';
|
|
17
36
|
import { existsSync, readFileSync } from 'node:fs';
|
|
18
37
|
import { createRequire } from 'node:module';
|
|
19
38
|
import path from 'node:path';
|
|
39
|
+
import { estUnFichierDeTest } from './composants.mjs';
|
|
20
40
|
|
|
21
41
|
const require = createRequire(import.meta.url);
|
|
22
42
|
|
|
43
|
+
// The Python a package requires.
|
|
44
|
+
const PYTHON = '>=3.12';
|
|
45
|
+
|
|
46
|
+
// The manifests of Python the module does not read.
|
|
47
|
+
const ETRANGERS = new Set(['setup.py', 'setup.cfg', 'Pipfile']);
|
|
48
|
+
|
|
49
|
+
// The testpaths of a package whose files of tests lie in <fichiers> (from the package): the
|
|
50
|
+
// folders that hold them and `tests`, each once, a folder under another left out; the package
|
|
51
|
+
// itself, `.`, for a test at its root.
|
|
52
|
+
function cheminsDesTests(fichiers) {
|
|
53
|
+
const dossiers = new Set(
|
|
54
|
+
fichiers.filter(f => estUnFichierDeTest(path.posix.basename(f))).map(f => path.posix.dirname(f))
|
|
55
|
+
);
|
|
56
|
+
if (dossiers.has('.')) {
|
|
57
|
+
return ['.'];
|
|
58
|
+
}
|
|
59
|
+
const tous = [...dossiers, 'tests'].filter((d, i, l) => l.indexOf(d) === i).sort();
|
|
60
|
+
return tous.filter(d => !tous.some(o => d.startsWith(`${o}/`)));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// <n> normalized as uv writes the name of a project (PEP 503).
|
|
64
|
+
const normaliser = n => n.toLowerCase().replace(/[-_.]+/g, '-');
|
|
65
|
+
|
|
66
|
+
// The project's name the root at <racine> declares (see the header), null for none; <racinePy>
|
|
67
|
+
// its pyproject.toml read, null without one.
|
|
68
|
+
function nomDuProjet(racine, racinePy) {
|
|
69
|
+
const py = racinePy?.project?.name;
|
|
70
|
+
if (typeof py === 'string' && py.trim()) {
|
|
71
|
+
return py;
|
|
72
|
+
}
|
|
73
|
+
const f = path.join(racine, 'package.json');
|
|
74
|
+
const n = existsSync(f) ? JSON.parse(readFileSync(f, 'utf8')).name : undefined;
|
|
75
|
+
return typeof n === 'string' && n.trim() ? (/^@([^/]+)\//.exec(n)?.[1] ?? n) : null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// The modules of the standard library of Python, `sys.stdlib_module_names`, of the interpreter uv
|
|
79
|
+
// provides for PYTHON; throws, uv named, when uv cannot give them.
|
|
80
|
+
function modulesStandard(racine) {
|
|
81
|
+
const code = 'import sys; print("\\n".join(sorted(sys.stdlib_module_names)))';
|
|
82
|
+
const r = spawnSync(
|
|
83
|
+
'uv',
|
|
84
|
+
['run', '--no-project', '--quiet', '--python', PYTHON, 'python', '-c', code],
|
|
85
|
+
{ cwd: racine, encoding: 'utf8' }
|
|
86
|
+
);
|
|
87
|
+
if (r.status !== 0) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`uv ne donne pas les modules de la bibliothèque standard de Python (${String(r.error?.message ?? r.stderr).trim()}) ; \`npx grillhouse maj\` installe uv, puis relance la commande.`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return new Set(r.stdout.split('\n').filter(Boolean));
|
|
93
|
+
}
|
|
94
|
+
|
|
23
95
|
/** @type {import('../../jointure.js').Langage['squelette']} */
|
|
24
|
-
export function squelette(racine, { chemin }) {
|
|
25
|
-
const
|
|
96
|
+
export function squelette(racine, { chemin, existants }) {
|
|
97
|
+
const etrangers = existants.filter(e => ETRANGERS.has(path.posix.basename(e)));
|
|
98
|
+
if (etrangers.length) {
|
|
99
|
+
throw new Error(
|
|
100
|
+
`${chemin} : ${etrangers.join(', ')} déclare un paquet Python que le module python ne lit pas. Reprends ses dépendances dans un requirements.txt, que le paquet reprend par \`uv add -r\`, retire-le, puis relance la commande.`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const code = existants.some(e => e.endsWith('.py'));
|
|
104
|
+
// Code out of src/ and tests/, which `pythonpath = ["src"]` would not reach.
|
|
105
|
+
const aPlat = existants.some(
|
|
106
|
+
e =>
|
|
107
|
+
e.endsWith('.py') &&
|
|
108
|
+
!e.startsWith('src/') &&
|
|
109
|
+
!e.startsWith('tests/') &&
|
|
110
|
+
!estUnFichierDeTest(path.posix.basename(e))
|
|
111
|
+
);
|
|
112
|
+
const exigences = existants.filter(e => path.posix.basename(e) === 'requirements.txt');
|
|
113
|
+
const f = path.join(racine, 'pyproject.toml');
|
|
114
|
+
const texte = existsSync(f) ? readFileSync(f, 'utf8') : null;
|
|
115
|
+
const racinePy = texte === null ? null : require('smol-toml').parse(texte);
|
|
116
|
+
const dossier = path.posix.basename(chemin);
|
|
117
|
+
const projet = nomDuProjet(racine, racinePy);
|
|
118
|
+
const nom = normaliser(projet ? `${projet}-${dossier}` : dossier);
|
|
26
119
|
const module = nom.replace(/-/g, '_');
|
|
120
|
+
if (modulesStandard(racine).has(module)) {
|
|
121
|
+
const autre = normaliser(`${path.basename(racine)}-${nom}`);
|
|
122
|
+
throw new Error(
|
|
123
|
+
`${chemin} : son module, ${module}, est un module de la bibliothèque standard de Python ; \`import ${module}\` le trouverait, jamais le paquet. Nomme-le ${autre} (le dossier et sa ligne du tableau des composants), ou déclare le nom du projet à la racine (le \`name\` de son package.json), qui préfixe le paquet.`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
27
126
|
const manifeste = [
|
|
28
127
|
'[project]',
|
|
29
128
|
`name = ${JSON.stringify(nom)}`,
|
|
30
129
|
'version = "0.1.0"',
|
|
31
|
-
|
|
130
|
+
`requires-python = ${JSON.stringify(PYTHON)}`,
|
|
32
131
|
'dependencies = []',
|
|
33
132
|
'',
|
|
34
133
|
'[dependency-groups]',
|
|
35
134
|
'test = ["pytest>=8"]',
|
|
36
135
|
'',
|
|
37
136
|
'[tool.pytest.ini_options]',
|
|
38
|
-
|
|
39
|
-
'pythonpath = ["src"]',
|
|
137
|
+
`testpaths = ${JSON.stringify(cheminsDesTests(existants)).replaceAll(',', ', ')}`,
|
|
138
|
+
...(aPlat ? [] : ['pythonpath = ["src"]']),
|
|
40
139
|
'',
|
|
41
140
|
].join('\n');
|
|
42
141
|
const fichiers = {
|
|
43
142
|
[`${chemin}/pyproject.toml`]: manifeste,
|
|
44
|
-
|
|
143
|
+
...(code
|
|
144
|
+
? {}
|
|
145
|
+
: {
|
|
146
|
+
[`${chemin}/src/${module}/__init__.py`]: `"""The package ${nom}: its interface, docs/INTERFACE.md, says what it offers."""\n`,
|
|
147
|
+
}),
|
|
45
148
|
[`${chemin}/tests/.gitkeep`]: '',
|
|
46
149
|
};
|
|
47
|
-
const
|
|
48
|
-
const texte = existsSync(f) ? readFileSync(f, 'utf8') : null;
|
|
49
|
-
const espace =
|
|
50
|
-
texte === null ? null : (require('smol-toml').parse(texte).tool?.uv?.workspace ?? null);
|
|
150
|
+
const espace = racinePy?.tool?.uv?.workspace ?? null;
|
|
51
151
|
const membres = Array.isArray(espace?.members) ? espace.members : null;
|
|
52
152
|
let entree = null;
|
|
53
153
|
if (membres && !membres.some(m => typeof m === 'string' && path.matchesGlob(chemin, m))) {
|
|
@@ -61,6 +161,8 @@ export function squelette(racine, { chemin }) {
|
|
|
61
161
|
return {
|
|
62
162
|
fichiers,
|
|
63
163
|
espace: entree,
|
|
64
|
-
verrouiller:
|
|
164
|
+
verrouiller: exigences.length
|
|
165
|
+
? exigences.map(e => ({ commande: 'uv', args: ['add', '-r', e], dossier: chemin }))
|
|
166
|
+
: [{ commande: 'uv', args: ['lock'], dossier: membres ? '.' : chemin }],
|
|
65
167
|
};
|
|
66
168
|
}
|
|
@@ -235,6 +235,22 @@ export default {
|
|
|
235
235
|
'packages/m/src/index.ts : matiere',
|
|
236
236
|
],
|
|
237
237
|
},
|
|
238
|
+
versionDeHead: {
|
|
239
|
+
valide: ['packages/a/src/index.ts', 'packages/a/tests/aide.ts', 'README.md'],
|
|
240
|
+
// A night test and a bench keep their mark, so that their sibling plays as they do.
|
|
241
|
+
invalide: [
|
|
242
|
+
'packages/a/src/index.test.ts',
|
|
243
|
+
'packages/a/src/index.spec.mjs',
|
|
244
|
+
'packages/a/tests/tout.nuit.test.ts',
|
|
245
|
+
'packages/a/tests/vitesse.budget.test.ts',
|
|
246
|
+
],
|
|
247
|
+
attendu: [
|
|
248
|
+
'packages/a/src/index.test.ts → packages/a/src/index.circuit-avant.test.ts',
|
|
249
|
+
'packages/a/src/index.spec.mjs → packages/a/src/index.circuit-avant.spec.mjs',
|
|
250
|
+
'packages/a/tests/tout.nuit.test.ts → packages/a/tests/tout.circuit-avant.nuit.test.ts',
|
|
251
|
+
'packages/a/tests/vitesse.budget.test.ts → packages/a/tests/vitesse.circuit-avant.budget.test.ts',
|
|
252
|
+
],
|
|
253
|
+
},
|
|
238
254
|
fichiersEngendres: {
|
|
239
255
|
valide: aJour,
|
|
240
256
|
invalide: enRetard,
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
// (./vitest-config/base.mjs).
|
|
33
33
|
// - The verdict: the summaries of Turborepo and the reports of Vitest of a results directory
|
|
34
34
|
// (./verdict.mjs).
|
|
35
|
-
// - The rule of a test file
|
|
36
|
-
// (./regle-des-tests.mjs).
|
|
35
|
+
// - The rule of a test file, the sibling of HEAD's version of a test file and what the testwriter
|
|
36
|
+
// writes of the manifests (./regle-des-tests.mjs).
|
|
37
37
|
// - The generated files, each its command, the guard that checks it and the names its findings
|
|
38
38
|
// carry: the index of the interfaces, the turbo.json of the packages, the reports of API.
|
|
39
39
|
// - The entries of the index of each interface (`entreesDeLIndex`, ./index-interfaces.mjs), which
|
|
@@ -56,7 +56,7 @@ import { composants as lesComposants, matieres } from './consommateurs.mjs';
|
|
|
56
56
|
import { elementsDuLot } from './elements-du-lot.mjs';
|
|
57
57
|
import { A_ELAGUER, lireSarif, RESULTATS } from '../../resultats.mjs';
|
|
58
58
|
import { lecteurs } from './lecteurs.mjs';
|
|
59
|
-
import { estUnTest, manifestes } from './regle-des-tests.mjs';
|
|
59
|
+
import { estUnTest, manifestes, soeurDAvant } from './regle-des-tests.mjs';
|
|
60
60
|
import { SCRIPT_DES_TESTS } from './script-des-tests.mjs';
|
|
61
61
|
import { verdict } from './verdict.mjs';
|
|
62
62
|
import { miseAJour } from './mise-a-jour.mjs';
|
|
@@ -264,6 +264,9 @@ export default {
|
|
|
264
264
|
}),
|
|
265
265
|
verdict,
|
|
266
266
|
estUnTest,
|
|
267
|
+
soeurDAvant,
|
|
268
|
+
// Its tool plays HEAD's version of each test file beside it (`soeurDAvant`): no name to read.
|
|
269
|
+
testsDeHead: () => null,
|
|
267
270
|
manifestes,
|
|
268
271
|
fichiersEngendres: () => [
|
|
269
272
|
engendre(
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
//
|
|
12
12
|
// Any other file is none of them: null.
|
|
13
13
|
//
|
|
14
|
+
// The sibling of HEAD's version of a test file Vitest plays (`soeurDAvant`), which the proof of
|
|
15
|
+
// the red plays beside it: `<nom>.circuit-avant.<test|spec>.<ext>`, the mark of a night test or of
|
|
16
|
+
// a bench kept before it (`<nom>.circuit-avant.nuit.test.<ext>`), so that it plays as its file.
|
|
17
|
+
//
|
|
14
18
|
// What the testwriter writes of the manifests (`manifestes`): the field that declares what the
|
|
15
19
|
// tests of a package depend on, `devDependencies` of its package.json (npm's docs,
|
|
16
20
|
// « devDependencies »), as the author of a test of Bazel declares the deps of its target; and
|
|
@@ -46,6 +50,15 @@ export function estUnTest(chemin, racine) {
|
|
|
46
50
|
return joue || test || matiere ? { joue, test, matiere } : null;
|
|
47
51
|
}
|
|
48
52
|
|
|
53
|
+
// The sibling of HEAD's version of the test file <chemin> (from the root <racine>), which Vitest
|
|
54
|
+
// plays in the same run: `<nom>.circuit-avant.<test|spec>.<ext>` beside it, a name of NOM_DE_TEST,
|
|
55
|
+
// of its file's kind (`.nuit` or `.budget` kept before `.test`);
|
|
56
|
+
// null for a file Vitest does not play.
|
|
57
|
+
export function soeurDAvant(chemin, racine) {
|
|
58
|
+
if (!estUnTest(chemin, racine)?.joue) return null;
|
|
59
|
+
return chemin.replace(/((?:\.nuit|\.budget)?\.(?:test|spec)\.[cm]?[jt]sx?)$/, '.circuit-avant$1');
|
|
60
|
+
}
|
|
61
|
+
|
|
49
62
|
// The field of a manifest that declares what its tests depend on.
|
|
50
63
|
const DES_TESTS = 'devDependencies';
|
|
51
64
|
|
|
@@ -17,9 +17,17 @@
|
|
|
17
17
|
// - The workspace: the root package.json receives the package's path in its `workspaces` (created
|
|
18
18
|
// when the root has none), unless a pattern there covers it already.
|
|
19
19
|
// - The lock of the versions: `npm install`, at the root.
|
|
20
|
+
// - A folder that already holds code is taken as it is when its code lies under `src/` and
|
|
21
|
+
// `tests/`, which its tsconfig.json and its vitest.config.ts cover, each file present kept; a
|
|
22
|
+
// file of code out of them (`.ts`, `.tsx`, `.mts`, `.cts`, `.js`, `.jsx`, `.mjs`, `.cjs`), which
|
|
23
|
+
// neither its typing nor its tests would reach, is refused by its name, nothing written, the
|
|
24
|
+
// layout named, in place of a skeleton beside it.
|
|
20
25
|
import { existsSync, readFileSync } from 'node:fs';
|
|
21
26
|
import path from 'node:path';
|
|
22
27
|
|
|
28
|
+
// A file of code of TypeScript or JavaScript.
|
|
29
|
+
const CODE = /\.(?:[cm]?[jt]s|[jt]sx)$/;
|
|
30
|
+
|
|
23
31
|
const CHAMPS = ['dependencies', 'devDependencies', 'optionalDependencies'];
|
|
24
32
|
// The tools of a package's tests and of its typing, at the versions of the module's template.
|
|
25
33
|
const OUTILS_DU_PAQUET = ['@types/node', 'typescript', 'vitest'];
|
|
@@ -68,12 +76,20 @@ export default mergeConfig(
|
|
|
68
76
|
`;
|
|
69
77
|
|
|
70
78
|
/** @type {import('../../jointure.js').Langage['squelette']} */
|
|
71
|
-
export function squelette(racine, { chemin, modele }) {
|
|
79
|
+
export function squelette(racine, { chemin, modele, existants }) {
|
|
72
80
|
if (!/^packages\/[^/]+$/.test(chemin)) {
|
|
73
81
|
throw new Error(
|
|
74
82
|
`${chemin} : un paquet typescript vit sous packages/<nom>, où le module trouve ses composants.`
|
|
75
83
|
);
|
|
76
84
|
}
|
|
85
|
+
const hors = existants.filter(
|
|
86
|
+
f => CODE.test(f) && !f.startsWith('src/') && !f.startsWith('tests/')
|
|
87
|
+
);
|
|
88
|
+
if (hors.length) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`${chemin} : ${hors.join(', ')} hors de la disposition du module typescript : son code sous src/, ses tests sous tests/, que son typage et ses tests couvrent. Range le code ainsi, puis relance la commande.`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
77
93
|
const racinePkg = lireJson(path.join(racine, 'package.json')) ?? {};
|
|
78
94
|
const nom = path.posix.basename(chemin);
|
|
79
95
|
const portee = /^(@[^/]+)\//.exec(String(racinePkg.name ?? ''))?.[1];
|
|
@@ -116,5 +132,5 @@ export function squelette(racine, { chemin, modele }) {
|
|
|
116
132
|
}
|
|
117
133
|
espace = { fichier: 'package.json', texte: json(p) };
|
|
118
134
|
}
|
|
119
|
-
return { fichiers, espace, verrouiller: { commande: 'npm', args: ['install'], dossier: '.' } };
|
|
135
|
+
return { fichiers, espace, verrouiller: [{ commande: 'npm', args: ['install'], dossier: '.' }] };
|
|
120
136
|
}
|
|
@@ -5,34 +5,42 @@
|
|
|
5
5
|
//
|
|
6
6
|
// node tests-de-nuit.mjs from the root of the copy
|
|
7
7
|
//
|
|
8
|
-
// - The files `*.nuit.test
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
8
|
+
// - The files `*.nuit.test.*` and `*.nuit.spec.*` of the copy, outside node_modules, dist and
|
|
9
|
+
// .git, the night tests, then its measures of time, the time budget benches (`*.budget.test.*`,
|
|
10
|
+
// `*.budget.spec.*`) and the time witnesses (a test file that imports `mesurerAuRepos`,
|
|
11
|
+
// `fichiersTemoins` of ./vitest-config/cibles.mjs): what `npm test` and the integration leave
|
|
12
|
+
// out (./vitest-config/cibles.mjs). A copy with none plays nothing, and the exit code is 0.
|
|
12
13
|
// - Vitest plays them with the frame's configuration (./vitest.nuit.config.mjs), from the root of
|
|
13
|
-
// the copy
|
|
14
|
-
//
|
|
15
|
-
//
|
|
14
|
+
// the copy: `npx --no-install vitest run --root <copie> --config <configuration>`, once for the
|
|
15
|
+
// night tests (GRILLHOUSE_TESTS_DE_NUIT=nuit), then once for the measures alone, one file at a
|
|
16
|
+
// time (GRILLHOUSE_TESTS_DE_NUIT=mesures), as Bazel plays a test tagged `exclusive` after the
|
|
17
|
+
// others, nothing beside it, and as the module cargo plays its benches after its night tests
|
|
18
|
+
// (grillhouse-bd7). Each run plays when the copy holds its files.
|
|
19
|
+
// - The exit code: 0 when every run is green; 75, « à repasser », when every red run is at 75
|
|
20
|
+
// (every failure depended on a duration, one under load, ./vitest-config/duree.reporter.mjs);
|
|
21
|
+
// else the code of the first red run.
|
|
16
22
|
// - They play once the temporary directory has room, as every heavy pass
|
|
17
23
|
// (`attendreDeLaPlace` of scripts/verrou-de-machine.mjs): a wait that reaches its bound ends at 75.
|
|
18
24
|
import { spawnSync } from 'node:child_process';
|
|
19
25
|
import { readdirSync } from 'node:fs';
|
|
20
26
|
import path from 'node:path';
|
|
21
27
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
22
|
-
import { attendreDeLaPlace } from '../../services-du-noyau.mjs';
|
|
28
|
+
import { A_REPASSER, attendreDeLaPlace } from '../../services-du-noyau.mjs';
|
|
29
|
+
import { fichiersTemoins, NUIT_VARIABLE } from './vitest-config/cibles.mjs';
|
|
23
30
|
|
|
24
31
|
const CONFIGURATION = fileURLToPath(new URL('./vitest.nuit.config.mjs', import.meta.url));
|
|
25
32
|
const HORS = new Set(['node_modules', 'dist', '.git']);
|
|
26
|
-
const DE_NUIT = /\.
|
|
33
|
+
const DE_NUIT = /\.nuit\.(test|spec)\.(c|m)?[jt]sx?$/;
|
|
34
|
+
const BANC = /\.budget\.(test|spec)\.(c|m)?[jt]sx?$/;
|
|
27
35
|
|
|
28
|
-
// Whether a
|
|
29
|
-
function enTient(dossier) {
|
|
36
|
+
// Whether a file whose name <motif> matches lies under <dossier>.
|
|
37
|
+
function enTient(dossier, motif) {
|
|
30
38
|
for (const e of readdirSync(dossier, { withFileTypes: true })) {
|
|
31
39
|
if (e.isDirectory()) {
|
|
32
|
-
if (!HORS.has(e.name) && enTient(path.join(dossier, e.name))) {
|
|
40
|
+
if (!HORS.has(e.name) && enTient(path.join(dossier, e.name), motif)) {
|
|
33
41
|
return true;
|
|
34
42
|
}
|
|
35
|
-
} else if (e.isFile() &&
|
|
43
|
+
} else if (e.isFile() && motif.test(e.name)) {
|
|
36
44
|
return true;
|
|
37
45
|
}
|
|
38
46
|
}
|
|
@@ -40,11 +48,16 @@ function enTient(dossier) {
|
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
/**
|
|
43
|
-
* Plays the night tests of the copy at <racine>:
|
|
51
|
+
* Plays the night tests, then the measures of time, of the copy at <racine>: 0, 75 or the code of
|
|
52
|
+
* the first red run of Vitest; 0 when there is none.
|
|
44
53
|
* @param {string} racine the root of the copy
|
|
45
54
|
*/
|
|
46
55
|
export function testsDeNuit(racine) {
|
|
47
|
-
|
|
56
|
+
const runs = [
|
|
57
|
+
enTient(racine, DE_NUIT) && 'nuit',
|
|
58
|
+
(enTient(racine, BANC) || fichiersTemoins(racine).length > 0) && 'mesures',
|
|
59
|
+
].filter(Boolean);
|
|
60
|
+
if (runs.length === 0) {
|
|
48
61
|
return 0;
|
|
49
62
|
}
|
|
50
63
|
try {
|
|
@@ -54,12 +67,19 @@ export function testsDeNuit(racine) {
|
|
|
54
67
|
process.stdout.write(`${e.message}\n`);
|
|
55
68
|
return e.code;
|
|
56
69
|
}
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
const codes = runs.map(choix => {
|
|
71
|
+
const r = spawnSync(
|
|
72
|
+
'npx',
|
|
73
|
+
['--no-install', 'vitest', 'run', '--root', racine, '--config', CONFIGURATION],
|
|
74
|
+
{ cwd: racine, stdio: 'inherit', env: { ...process.env, [NUIT_VARIABLE]: choix } }
|
|
75
|
+
);
|
|
76
|
+
return r.status ?? 1;
|
|
77
|
+
});
|
|
78
|
+
const rouges = codes.filter(c => c !== 0);
|
|
79
|
+
if (rouges.length === 0) {
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
return rouges.every(c => c === A_REPASSER) ? A_REPASSER : rouges.find(c => c !== A_REPASSER);
|
|
63
83
|
}
|
|
64
84
|
|
|
65
85
|
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|