@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.
- 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 +41 -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 +160 -56
- package/docs/CADRE.md +47 -0
- package/docs/INTERFACE.md +176 -0
- package/package.json +66 -13
- 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 +20 -91
- 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} +49 -23
- 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 -11
- package/scripts/{vitest-config → langages/typescript/vitest-config}/cibles.mjs +7 -6
- package/scripts/langages/typescript/vitest-config/duree.reporter.d.ts +10 -0
- package/scripts/{vitest-config → langages/typescript/vitest-config}/duree.reporter.mjs +10 -3
- 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
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
// The files each test reads beyond the modules it imports: the scripts it launches and the data it
|
|
2
|
+
// reads by their path, as Bazel's `data` of a test target, which Vitest's graph (the modules a test
|
|
3
|
+
// imports) does not hold. The frame reads them in the test's text, and in the texts they lead to,
|
|
4
|
+
// as Bazel's runfiles of a target are those of its `data` and of their own dependencies.
|
|
5
|
+
//
|
|
6
|
+
// - What a test names (`nommesPar`): each path that a string of its code writes whole
|
|
7
|
+
// (`'../../scripts/verrous/verrou.mjs'`), or that the strings of one call of `join` or
|
|
8
|
+
// `resolve` write together (`path.join(DEPOT, 'packages/a', 'scripts/x.mjs')`), resolved from
|
|
9
|
+
// the directory of the file that writes it, then from the test's package, then from the top of
|
|
10
|
+
// the repository, the first that exists: the constant `SCRIPT` of a test that launches a script,
|
|
11
|
+
// or the data it reads. The code is the text without its comments and without its imports, whose
|
|
12
|
+
// strings are in Vitest's graph. The test material it imports is read as the test itself: a file
|
|
13
|
+
// under a directory `test`, `tests` or `__tests__`, or of a package of the shared material (whose
|
|
14
|
+
// package.json exports `./test-fixtures`). A directory names each file under it, except a
|
|
15
|
+
// directory that holds the file that writes it, or that is a package (it holds a package.json):
|
|
16
|
+
// it is a base, not a read. A path out of the repository, or under node_modules once its links
|
|
17
|
+
// are followed, is none. A pattern of files whose start is fixed
|
|
18
|
+
// (`'packages/grillhouse/scripts/**/*.mjs'`) names each file it covers. A command of a package of
|
|
19
|
+
// the workspace (its package.json's `bin`) is named by its link (`node_modules/.bin/grillhouse`,
|
|
20
|
+
// whole or written by the strings of one call) and, in a test's string, by a command line
|
|
21
|
+
// (`npx grillhouse maj`): its file, which names the script of each subcommand in its table.
|
|
22
|
+
// - What a test reads (`lusPar`): the test and the files it names, then, from file to file, the
|
|
23
|
+
// modules each one imports (a relative specifier, or a package of the workspace, resolved as Node
|
|
24
|
+
// resolves it, out of node_modules once its links are followed) and the paths each module's code
|
|
25
|
+
// writes from its own directory (`path.join(ICI, 'verrous/verrou.mjs')`), a command's link
|
|
26
|
+
// included (the hook of the plugin that runs `node_modules/.bin/grillhouse <sous-commande>`), and
|
|
27
|
+
// the paths a script of the shell writes from its own directory (`"$ici/superviseur.mjs"`): a
|
|
28
|
+
// script that launches another names it. A subcommand leads to every script of the command's
|
|
29
|
+
// table: naming the one it runs would need the table of the core, which no published entry
|
|
30
|
+
// gives to a module of language.
|
|
31
|
+
// - The tests that launch a file (`testsQuiLancent`): the test files of a package whose reads hold
|
|
32
|
+
// one of the files changed. ./changements.mjs adds them to the tests Vitest relates to the
|
|
33
|
+
// changes, so that a test plays when the script it launches changes, as it plays when a module it
|
|
34
|
+
// imports changes.
|
|
35
|
+
// - What a test names without the frame reading it (`nonDeclares`): a string of the test's code or
|
|
36
|
+
// of its material that ends the path of a module of its package (`'verrou.mjs'`,
|
|
37
|
+
// `'verrous/verrou.mjs'`), out of a directory of tests, the module out of what the test reads and
|
|
38
|
+
// out of the package's `grillhouse.lit`: a script it launches by a path built at run time
|
|
39
|
+
// (`path.join(SCRIPTS, nom)`), whose change would not play it; or a pattern that names a
|
|
40
|
+
// directory of the package without a fixed start (`'**/scripts/*.mjs'`), for each module it
|
|
41
|
+
// covers out of what the test reads. A pattern that names no directory (`'**/*.mjs'`, `'*'`) is
|
|
42
|
+
// the configuration of a trial project. The guard of the paths of the tests
|
|
43
|
+
// (../chemins-des-tests.mjs) refuses it; the test writes the path whole, or its package declares
|
|
44
|
+
// it in its `grillhouse.lit`.
|
|
45
|
+
//
|
|
46
|
+
// The reading of a test's text is one, shared: the guard of the sizes (../tailles-des-tests.mjs)
|
|
47
|
+
// takes from this module what a test file is, its material, its imports and their resolution.
|
|
48
|
+
//
|
|
49
|
+
// This module's top level uses Node alone (./changements.mjs imports it).
|
|
50
|
+
import { existsSync, globSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
51
|
+
import { createRequire } from 'node:module';
|
|
52
|
+
import path from 'node:path';
|
|
53
|
+
import { matieres } from '../composants.mjs';
|
|
54
|
+
import { paquets } from '../../../paquets.mjs';
|
|
55
|
+
|
|
56
|
+
/** A test file, as Vitest's default `include` names one. */
|
|
57
|
+
export const TEST = /\.(?:test|spec)\.[cm]?[jt]sx?$/;
|
|
58
|
+
// The extension of a module, whose code the reads follow.
|
|
59
|
+
const MODULE = /\.(?:[cm]?[jt]sx?)$/;
|
|
60
|
+
/** A file of test material: under a directory of tests. */
|
|
61
|
+
export const MATIERE = /(?:^|\/)(?:tests?|__tests__)\//;
|
|
62
|
+
/** The specifiers a text imports: static, dynamic, re-exported, required, or bare. */
|
|
63
|
+
export const IMPORT =
|
|
64
|
+
/(?:^|[\s;])(?:import|export)\s[^'"`;]*?from\s*['"]([^'"]+)['"]|\bimport\s*\(\s*['"]([^'"]+)['"]\s*\)|\brequire\(\s*['"]([^'"]+)['"]\s*\)|^\s*import\s*['"]([^'"]+)['"]/gm;
|
|
65
|
+
// One call of `join` or `resolve` (of `path` or imported alone), its arguments on one or several
|
|
66
|
+
// lines, a call among them (`process.cwd()`) kept.
|
|
67
|
+
const APPEL = /(?<![\w$])(?:path\.)?(?:join|resolve)\(((?:[^()]|\([^()]*\))*)\)/g;
|
|
68
|
+
// The extensions a relative specifier may leave out, or write `.js` for a `.ts`.
|
|
69
|
+
const SUFFIXES = ['', '.ts', '.mts', '.tsx', '.js', '.mjs', '.cjs', '/index.ts', '/index.js'];
|
|
70
|
+
// A script of the shell.
|
|
71
|
+
const SHELL = /\.(?:sh|bash)$/;
|
|
72
|
+
// A pattern of files: a glob's wildcard, or a set of alternatives.
|
|
73
|
+
const MOTIF = /[*?{]/;
|
|
74
|
+
// The directories a walk leaves out.
|
|
75
|
+
const SAUTES = new Set(['node_modules', '.git', '.turbo', 'dist', '.claude']);
|
|
76
|
+
|
|
77
|
+
const sous = (f, dir) => {
|
|
78
|
+
const r = path.relative(dir, f);
|
|
79
|
+
return r === '' || (!r.startsWith('..') && !path.isAbsolute(r));
|
|
80
|
+
};
|
|
81
|
+
const horsModules = f => !f.split(path.sep).includes('node_modules');
|
|
82
|
+
const du = (racine, f) => path.relative(racine, f).split(path.sep).join('/');
|
|
83
|
+
|
|
84
|
+
// <f> with its links followed, null when it does not exist.
|
|
85
|
+
const reel = f => {
|
|
86
|
+
try {
|
|
87
|
+
return realpathSync(f);
|
|
88
|
+
} catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** The reader of the files of the disk: a regular file's text, null otherwise. */
|
|
94
|
+
export function lireLeDisque(f) {
|
|
95
|
+
try {
|
|
96
|
+
return statSync(f).isFile() ? readFileSync(f, 'utf8') : null;
|
|
97
|
+
} catch {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const lire = f => lireLeDisque(f) ?? '';
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The file a relative <spec> of <de> resolves to, among those <lireUn> reads (a path → its text,
|
|
105
|
+
* null when it does not read); null otherwise.
|
|
106
|
+
*/
|
|
107
|
+
export function resoudreRelatif(de, spec, lireUn) {
|
|
108
|
+
const base = path.resolve(path.dirname(de), spec);
|
|
109
|
+
const sansJs = base.replace(/\.([cm]?)js$/, '.$1ts');
|
|
110
|
+
for (const c of [...SUFFIXES.map(s => base + s), sansJs]) {
|
|
111
|
+
if (lireUn(c) !== null) return c;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const estDossier = f => {
|
|
117
|
+
try {
|
|
118
|
+
return statSync(f).isDirectory();
|
|
119
|
+
} catch {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// The files under the directory <dir>, absolute, SAUTES left out.
|
|
125
|
+
function fichiersSous(dir) {
|
|
126
|
+
let entrees;
|
|
127
|
+
try {
|
|
128
|
+
entrees = readdirSync(dir, { withFileTypes: true });
|
|
129
|
+
} catch {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
return entrees.flatMap(e => {
|
|
133
|
+
if (SAUTES.has(e.name)) return [];
|
|
134
|
+
const f = path.join(dir, e.name);
|
|
135
|
+
return e.isDirectory() ? fichiersSous(f) : e.isFile() ? [f] : [];
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// The specifiers <texte> imports.
|
|
140
|
+
const specifiers = texte =>
|
|
141
|
+
[...texte.matchAll(IMPORT)].map(m => m[1] ?? m[2] ?? m[3] ?? m[4]).filter(Boolean);
|
|
142
|
+
|
|
143
|
+
// <texte> without its comments, read character by character so that a string holding `//` or
|
|
144
|
+
// `/*` (a URL, a glob) stays whole: a quoted string ends at its quote or at the end of its line,
|
|
145
|
+
// a template at its backtick.
|
|
146
|
+
function sansCommentaires(texte) {
|
|
147
|
+
let out = '';
|
|
148
|
+
let i = 0;
|
|
149
|
+
while (i < texte.length) {
|
|
150
|
+
const c = texte[i];
|
|
151
|
+
const suivant = texte[i + 1];
|
|
152
|
+
if (c === '/' && suivant === '/') {
|
|
153
|
+
while (i < texte.length && texte[i] !== '\n') i++;
|
|
154
|
+
} else if (c === '/' && suivant === '*') {
|
|
155
|
+
const fin = texte.indexOf('*/', i + 2);
|
|
156
|
+
i = fin < 0 ? texte.length : fin + 2;
|
|
157
|
+
out += ' ';
|
|
158
|
+
} else if (c === "'" || c === '"' || c === '`') {
|
|
159
|
+
let j = i + 1;
|
|
160
|
+
while (j < texte.length && texte[j] !== c && (c === '`' || texte[j] !== '\n')) {
|
|
161
|
+
j += texte[j] === '\\' ? 2 : 1;
|
|
162
|
+
}
|
|
163
|
+
out += texte.slice(i, j + 1);
|
|
164
|
+
i = j + 1;
|
|
165
|
+
} else {
|
|
166
|
+
out += c;
|
|
167
|
+
i++;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return out;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// The code of <texte>: without its comments, whose words name no path read, nor its imports, whose
|
|
174
|
+
// strings are in Vitest's graph.
|
|
175
|
+
const code = texte => sansCommentaires(texte).replace(IMPORT, '');
|
|
176
|
+
|
|
177
|
+
// The strings of the code <texte> (without its comments), read character by character: a quoted
|
|
178
|
+
// string, or a template without a substitution, each once.
|
|
179
|
+
function chainesDe(texte) {
|
|
180
|
+
const out = [];
|
|
181
|
+
let i = 0;
|
|
182
|
+
while (i < texte.length) {
|
|
183
|
+
const c = texte[i];
|
|
184
|
+
if (c !== "'" && c !== '"' && c !== '`') {
|
|
185
|
+
i++;
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
let j = i + 1;
|
|
189
|
+
while (j < texte.length && texte[j] !== c && (c === '`' || texte[j] !== '\n')) {
|
|
190
|
+
j += texte[j] === '\\' ? 2 : 1;
|
|
191
|
+
}
|
|
192
|
+
const contenu = texte.slice(i + 1, j);
|
|
193
|
+
if (!(c === '`' && contenu.includes('${'))) out.push(contenu);
|
|
194
|
+
i = j + 1;
|
|
195
|
+
}
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// The strings of the code <texte>, then the strings of each call of `join` or `resolve` written
|
|
200
|
+
// together, each once.
|
|
201
|
+
function chaines(texte) {
|
|
202
|
+
const jointes = [...texte.matchAll(APPEL)]
|
|
203
|
+
.map(a => chainesDe(a[1]).filter(Boolean))
|
|
204
|
+
.filter(l => l.length > 1)
|
|
205
|
+
.map(l => l.join('/'));
|
|
206
|
+
return [...new Set([...chainesDe(texte), ...jointes].filter(Boolean))];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// The value of <calcul>, kept in <memo> under <cle>: each reading of a directory, a resolution or a
|
|
210
|
+
// file's strings is made once per pass.
|
|
211
|
+
function memoise(memo, cle, calcul) {
|
|
212
|
+
if (!memo.has(cle)) memo.set(cle, calcul());
|
|
213
|
+
return memo.get(cle);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// The file a <spec> imported by <de> resolves to, in the repository at <racine>, out of
|
|
217
|
+
// node_modules once its links are followed; null otherwise.
|
|
218
|
+
function resoudreImport(de, spec, racine, memo) {
|
|
219
|
+
return memoise(memo, `import:${path.dirname(de)}\0${spec}`, () => resoudre(de, spec, racine));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function resoudre(de, spec, racine) {
|
|
223
|
+
if (spec.startsWith('.')) {
|
|
224
|
+
const f = resoudreRelatif(de, spec, lireLeDisque);
|
|
225
|
+
return f && reel(f);
|
|
226
|
+
}
|
|
227
|
+
if (spec.startsWith('node:') || path.isAbsolute(spec)) return null;
|
|
228
|
+
try {
|
|
229
|
+
const f = reel(createRequire(de).resolve(spec));
|
|
230
|
+
return f && sous(f, racine) && horsModules(f) ? f : null;
|
|
231
|
+
} catch {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Whether the file <f> of the repository at <racine> is test material: under a directory of
|
|
237
|
+
// tests, or in a package of the shared material (`matieres` of ../composants.mjs).
|
|
238
|
+
function estMatiere(f, racine, memo) {
|
|
239
|
+
if (MATIERE.test(du(racine, f))) return true;
|
|
240
|
+
return memoise(memo, 'matieres', () => matieres(racine)).some(m => sous(f, m.dir));
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// The commands of the packages of the workspace at <racine>, by their name: the file of each
|
|
244
|
+
// `bin` of their package.json (`grillhouse` → bin/grillhouse.mjs).
|
|
245
|
+
function commandes(racine, memo) {
|
|
246
|
+
return memoise(memo, 'commandes', () => {
|
|
247
|
+
const out = new Map();
|
|
248
|
+
for (const { dossier, pkg } of paquets(racine)) {
|
|
249
|
+
const bin =
|
|
250
|
+
typeof pkg?.bin === 'string' && pkg?.name
|
|
251
|
+
? { [pkg.name.split('/').at(-1)]: pkg.bin }
|
|
252
|
+
: (pkg?.bin ?? {});
|
|
253
|
+
for (const [nom, f] of Object.entries(bin)) {
|
|
254
|
+
if (typeof f === 'string') out.set(nom, path.join(racine, dossier, f));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return out;
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// The command of the workspace that the string <chaine> launches: a path ending
|
|
262
|
+
// `node_modules/.bin/<nom>`, or, with <ligne> (a test's string), a command line
|
|
263
|
+
// `<nom> <sous-commande>` (`npx grillhouse maj`); its file, or null.
|
|
264
|
+
function commandeLancee(chaine, racine, memo, ligne) {
|
|
265
|
+
const liste = commandes(racine, memo);
|
|
266
|
+
const parLien = /(?:^|\/)\.bin\/([\w@.-]+)$/.exec(chaine);
|
|
267
|
+
if (parLien) return liste.get(parLien[1]) ?? null;
|
|
268
|
+
if (!ligne) return null;
|
|
269
|
+
for (const [nom, f] of liste) {
|
|
270
|
+
if (new RegExp(`(?:^|[\\s/"'])${nom.replace(/[.-]/g, '\\$&')}["']?\\s+[a-z]`).test(chaine)) {
|
|
271
|
+
return f;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// The files of the repository at <racine> the pattern <motif> covers from the first of <bases>
|
|
278
|
+
// that holds its fixed start (the segments before its first wildcard), node_modules left out; none
|
|
279
|
+
// for a pattern that starts with a wildcard.
|
|
280
|
+
function couverts(motif, bases, racine) {
|
|
281
|
+
const fixe = motif.split('/').filter((s, i, l) => !l.slice(0, i + 1).some(x => MOTIF.test(x)));
|
|
282
|
+
if (fixe.length === 0) return [];
|
|
283
|
+
for (const b of bases) {
|
|
284
|
+
if (!existsSync(path.resolve(b, ...fixe))) continue;
|
|
285
|
+
return globSync(motif, { cwd: b, exclude: d => SAUTES.has(path.basename(d)) })
|
|
286
|
+
.map(f => path.resolve(b, f))
|
|
287
|
+
.filter(f => sous(f, racine) && horsModules(f) && !estDossier(f));
|
|
288
|
+
}
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// The files of the repository at <racine> that the path <chaine> names from one of <bases> (the
|
|
293
|
+
// first that exists): itself, or each file under it; none for a directory that holds the file
|
|
294
|
+
// <de> that writes it, or that is a package.
|
|
295
|
+
function nommes(chaine, bases, racine, de, memo, ligne = false) {
|
|
296
|
+
if (!/[\w.]/.test(chaine) || /^[a-z]+:/i.test(chaine)) return [];
|
|
297
|
+
return memoise(memo, `nommes:${ligne}\0${bases.join('\0')}\0${path.dirname(de)}\0${chaine}`, () =>
|
|
298
|
+
resoudreNommes(chaine, bases, racine, de, memo, ligne)
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function resoudreNommes(chaine, bases, racine, de, memo, ligne) {
|
|
303
|
+
const commande = commandeLancee(chaine, racine, memo, ligne);
|
|
304
|
+
if (commande) return [commande];
|
|
305
|
+
if (/[\s<>|^$]/.test(chaine)) return [];
|
|
306
|
+
if (MOTIF.test(chaine)) return couverts(chaine, bases, racine);
|
|
307
|
+
for (const b of bases) {
|
|
308
|
+
const c = path.resolve(b, chaine);
|
|
309
|
+
if (!existsSync(c)) continue;
|
|
310
|
+
const r = reel(c);
|
|
311
|
+
if (!r || !sous(r, racine) || !horsModules(r)) return [];
|
|
312
|
+
if (!estDossier(r)) return [r];
|
|
313
|
+
if (sous(de, r) || existsSync(path.join(r, 'package.json'))) return [];
|
|
314
|
+
return memoise(memo, `dossier:${r}`, () => fichiersSous(r));
|
|
315
|
+
}
|
|
316
|
+
return [];
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// The test file <fichier> and the test material it imports, from file to file, itself first.
|
|
320
|
+
function materiel(fichier, racine, memo) {
|
|
321
|
+
const vus = [];
|
|
322
|
+
const suivre = f => {
|
|
323
|
+
if (vus.includes(f)) return;
|
|
324
|
+
vus.push(f);
|
|
325
|
+
for (const spec of specifiersDe(f, memo)) {
|
|
326
|
+
const cible = resoudreImport(f, spec, racine, memo);
|
|
327
|
+
if (cible && !TEST.test(cible) && estMatiere(cible, racine, memo)) suivre(cible);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
suivre(fichier);
|
|
331
|
+
return vus;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// The specifiers the file <f> imports, and the strings of its code.
|
|
335
|
+
const specifiersDe = (f, memo) => memoise(memo, `specifiers:${f}`, () => specifiers(lire(f)));
|
|
336
|
+
const chainesDuFichier = (f, memo) => memoise(memo, `chaines:${f}`, () => chaines(code(lire(f))));
|
|
337
|
+
|
|
338
|
+
// The files the test file <fichier> (absolute) of the package at <dossier>, in the repository at
|
|
339
|
+
// <racine>, names by their path, its test material's included: absolute paths.
|
|
340
|
+
function nommesPar(fichier, dossier, racine, memo) {
|
|
341
|
+
const out = new Set();
|
|
342
|
+
for (const f of materiel(fichier, racine, memo)) {
|
|
343
|
+
const bases = [path.dirname(f), dossier, racine];
|
|
344
|
+
for (const c of chainesDuFichier(f, memo)) {
|
|
345
|
+
for (const n of nommes(c, bases, racine, f, memo, true)) out.add(n);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return out;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// The closure of the files <depart> in the repository at <racine>: themselves, the modules each
|
|
352
|
+
// imports and the paths each module's code writes from its own directory, from file to file; a
|
|
353
|
+
// Set of absolute paths. <memo> keeps what each module leads to across calls.
|
|
354
|
+
function fermeture(depart, racine, memo) {
|
|
355
|
+
const vus = new Set();
|
|
356
|
+
const pile = [...depart];
|
|
357
|
+
while (pile.length) {
|
|
358
|
+
const f = pile.pop();
|
|
359
|
+
if (vus.has(f)) continue;
|
|
360
|
+
vus.add(f);
|
|
361
|
+
if (SHELL.test(f)) {
|
|
362
|
+
// A script of the shell names the scripts it runs from its own directory, through a
|
|
363
|
+
// variable (`"$ici/superviseur.mjs"`).
|
|
364
|
+
pile.push(
|
|
365
|
+
...memoise(memo, `suite:${f}`, () =>
|
|
366
|
+
chainesDe(lire(f))
|
|
367
|
+
.map(c => c.replace(/^\$\{?\w+\}?\//, ''))
|
|
368
|
+
.flatMap(c => nommes(c, [path.dirname(f)], racine, f, memo))
|
|
369
|
+
)
|
|
370
|
+
);
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (!MODULE.test(f)) continue;
|
|
374
|
+
const suite = memoise(memo, `suite:${f}`, () => [
|
|
375
|
+
...specifiersDe(f, memo)
|
|
376
|
+
.map(s => resoudreImport(f, s, racine, memo))
|
|
377
|
+
.filter(Boolean),
|
|
378
|
+
...chainesDuFichier(f, memo).flatMap(c => nommes(c, [path.dirname(f)], racine, f, memo)),
|
|
379
|
+
]);
|
|
380
|
+
pile.push(...suite);
|
|
381
|
+
}
|
|
382
|
+
return vus;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* What the test file <fichier> (absolute) of the package at <dossier>, in the repository at
|
|
387
|
+
* <racine>, reads: itself and the files it names, with what they import and name, from file to
|
|
388
|
+
* file; a Set of absolute paths. <memo> keeps what each module leads to across calls.
|
|
389
|
+
*/
|
|
390
|
+
export function lusPar(fichier, dossier, racine, memo = new Map()) {
|
|
391
|
+
return fermeture([fichier, ...nommesPar(fichier, dossier, racine, memo)], racine, memo);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/** The test files under the package directory <dossier>, absolute, sorted. */
|
|
395
|
+
export function testsDuPaquet(dossier) {
|
|
396
|
+
return fichiersSous(dossier)
|
|
397
|
+
.filter(f => TEST.test(f))
|
|
398
|
+
.sort();
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* The test files of the package at <dossier>, in the repository at <racine>, whose reads
|
|
403
|
+
* (`lusPar`) hold one of the files <changes> (absolute): sorted.
|
|
404
|
+
*/
|
|
405
|
+
export function testsQuiLancent(dossier, racine, changes) {
|
|
406
|
+
const cibles = new Set(changes.map(f => reel(f) ?? f));
|
|
407
|
+
if (cibles.size === 0) return [];
|
|
408
|
+
const memo = new Map();
|
|
409
|
+
return testsDuPaquet(dossier).filter(t => {
|
|
410
|
+
for (const f of lusPar(t, dossier, racine, memo)) if (cibles.has(f)) return true;
|
|
411
|
+
return false;
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Whether the path <rel> (from the top) lies under one of the paths <lit> (from the top).
|
|
416
|
+
const dansLit = (rel, lit) => lit.some(l => rel === l || rel.startsWith(`${l}/`));
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* What the test files of the package at <dossier>, in the repository at <racine>, name without
|
|
420
|
+
* the frame reading it, <lit> the package's `grillhouse.lit` (paths from the top):
|
|
421
|
+
* `[{ test, fichier, chaine }]`, `test` and `fichier` from the top, `fichier` a module of the
|
|
422
|
+
* package out of a directory of tests whose path the string <chaine> of the test's code (or of its
|
|
423
|
+
* material) ends, out of what the test reads (`lusPar`) and out of lit; in the order of the tests.
|
|
424
|
+
*/
|
|
425
|
+
export function nonDeclares(dossier, racine, lit = [], memo = new Map()) {
|
|
426
|
+
// Each module of the package that may be named, by each end of its path (`verrou.mjs`,
|
|
427
|
+
// `verrous/verrou.mjs`, …).
|
|
428
|
+
const parFin = new Map();
|
|
429
|
+
const modules = [];
|
|
430
|
+
for (const f of fichiersSous(dossier)) {
|
|
431
|
+
const r = du(racine, f);
|
|
432
|
+
if (!MODULE.test(f) || TEST.test(f) || MATIERE.test(r) || dansLit(r, lit)) continue;
|
|
433
|
+
modules.push(f);
|
|
434
|
+
const parts = r.split('/');
|
|
435
|
+
for (let i = 0; i < parts.length; i++) {
|
|
436
|
+
const fin = parts.slice(i).join('/');
|
|
437
|
+
parFin.set(fin, [...(parFin.get(fin) ?? []), f]);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
const out = [];
|
|
441
|
+
for (const t of testsDuPaquet(dossier)) {
|
|
442
|
+
const lus = lusPar(t, dossier, racine, memo);
|
|
443
|
+
const signales = new Set();
|
|
444
|
+
for (const f of materiel(t, racine, memo)) {
|
|
445
|
+
for (const c of chainesDuFichier(f, memo)) {
|
|
446
|
+
const fin = c.replace(/^(?:\.{1,2}\/)+/, '').replace(/\/+$/, '');
|
|
447
|
+
// A pattern that names a directory by a segment without a wildcard (`**/scripts/*.mjs`):
|
|
448
|
+
// one that starts with a wildcard and names none (`**/*.mjs`, `*`) is the configuration
|
|
449
|
+
// of a trial project, not a read.
|
|
450
|
+
const motif =
|
|
451
|
+
MOTIF.test(fin) &&
|
|
452
|
+
!/\s/.test(fin) &&
|
|
453
|
+
fin
|
|
454
|
+
.split('/')
|
|
455
|
+
.slice(0, -1)
|
|
456
|
+
.some(x => x && !MOTIF.test(x) && x !== '..' && x !== '.');
|
|
457
|
+
const cibles = motif
|
|
458
|
+
? modules.filter(
|
|
459
|
+
m => path.matchesGlob(du(racine, m), fin) || path.matchesGlob(du(dossier, m), fin)
|
|
460
|
+
)
|
|
461
|
+
: (parFin.get(fin) ?? []);
|
|
462
|
+
for (const cible of cibles) {
|
|
463
|
+
const r = du(racine, cible);
|
|
464
|
+
if (!lus.has(cible) && !signales.has(r)) {
|
|
465
|
+
signales.add(r);
|
|
466
|
+
out.push({ test: du(racine, t), fichier: r, chaine: c });
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return out;
|
|
473
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// and at the end of each test in its `task.meta`, which reaches the duration reporter
|
|
3
3
|
// (./duree.reporter.mjs). The end is noted after a delay past too: Vitest plays `afterEach` then.
|
|
4
4
|
import { afterEach, beforeEach } from 'vitest';
|
|
5
|
-
import { lirePression } from '
|
|
5
|
+
import { lirePression } from '../../../services-du-noyau.mjs';
|
|
6
6
|
|
|
7
7
|
beforeEach(({ task }) => {
|
|
8
8
|
task.meta.pressionDebut = lirePression();
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// The JSON report of Vitest in the results directory of a run (
|
|
2
|
-
// it): the
|
|
3
|
-
// configuration adds while
|
|
1
|
+
// The JSON report of Vitest in the results directory of a run (`GRILLHOUSE_RESULTATS`,
|
|
2
|
+
// scripts/resultats.mjs; scripts/langages/typescript/verdict.mjs reads it): the reporter the base
|
|
3
|
+
// configuration adds while the variable is set (./base.mjs). Without it, Vitest writes no report.
|
|
4
4
|
//
|
|
5
5
|
// - Each run of Vitest writes its report to `<dossier>/vitest/<name>.json`, the name made of the
|
|
6
6
|
// package directory it runs in and its process: two packages, or the same one twice, never write
|
|
7
7
|
// the same file.
|
|
8
8
|
// - The variable passes through Turborepo without entering any hash (`globalPassThroughEnv` of the
|
|
9
|
-
// root's turbo.json, which scripts/turbo-des-paquets.mjs writes and checks).
|
|
9
|
+
// root's turbo.json, which scripts/langages/typescript/turbo-des-paquets.mjs writes and checks).
|
|
10
10
|
import path from 'node:path';
|
|
11
|
+
import { RESULTATS } from '../../../resultats.mjs';
|
|
11
12
|
|
|
12
|
-
export const RESULTATS = 'GRILLHOUSE_RESULTATS';
|
|
13
13
|
// The subdirectory of the reports of Vitest in a results directory.
|
|
14
14
|
export const VITEST = 'vitest';
|
|
15
15
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// A setup file of the base configuration: a test file's results are its own, as Bazel gives each
|
|
2
2
|
// test its own outputs directory (TEST_UNDECLARED_OUTPUTS_DIR). While the run names its results
|
|
3
|
-
// directory (`GRILLHOUSE_RESULTATS`,
|
|
3
|
+
// directory (`GRILLHOUSE_RESULTATS`, scripts/resultats.mjs), the file names for every process it starts
|
|
4
4
|
// a directory of its own, `<dossier>/essais/<process>-<token>/`, which no reader of the run reads
|
|
5
|
-
// (scripts/resultats.mjs
|
|
5
|
+
// (scripts/resultats.mjs and scripts/langages/typescript/verdict.mjs read `vitest/`, `sarif/` and
|
|
6
|
+
// `turbo/`): a Vitest, a `npm run verifier`
|
|
6
7
|
// or a circuit that a test plays in a repository of trial writes its results there, and its reds
|
|
7
8
|
// never count in the pass that plays it. The reporters of the run, set up in its main process,
|
|
8
9
|
// keep the run's own directory. Without the variable, nothing changes.
|
|
9
10
|
import { randomUUID } from 'node:crypto';
|
|
10
11
|
import path from 'node:path';
|
|
11
|
-
import { RESULTATS } from '
|
|
12
|
+
import { RESULTATS } from '../../../resultats.mjs';
|
|
12
13
|
|
|
13
14
|
if (process.env[RESULTATS]) {
|
|
14
15
|
process.env[RESULTATS] = path.join(
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// day, and its time budget benches (`*.budget.test.*`, `*.budget.spec.*`), whose measures move with
|
|
3
3
|
// the load of the day; `npm test`, `npm run verifier` and the integration leave them out (the
|
|
4
4
|
// frame's base configuration of the day, the package @roomi-fields/grillhouse/vitest-config, which every day
|
|
5
|
-
// configuration extends, excludes both). The night (scripts/nuit.sh) plays them with this
|
|
5
|
+
// configuration extends, excludes both). The night (scripts/nuit.sh, by ./tests-de-nuit.mjs) plays them with this
|
|
6
6
|
// configuration, from the root of its copy (`vitest run --root <copy> --config <this file>`),
|
|
7
7
|
// after a green full pass (`npm run verifier -- --force`) and before the project's night script.
|
|
8
8
|
// It reads no day configuration of the project, whether the project has one at its root or one
|
|
9
9
|
// per package; it takes from the base configuration the common environment (git's settings) and
|
|
10
10
|
// the measure of time: the setup file that notes the CPU pressure of each test and the duration
|
|
11
11
|
// reporter, which gives 75, « à repasser », to a bench that fails under load
|
|
12
|
-
// (scripts/vitest-config/duree.reporter.mjs).
|
|
12
|
+
// (scripts/langages/typescript/vitest-config/duree.reporter.mjs).
|
|
13
13
|
import base from './vitest-config/base.mjs';
|
|
14
14
|
import { HORS_DU_JOUR } from './vitest-config/cibles.mjs';
|
|
15
15
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// The join of the languages: the module of language that serves a project, as Pants activates the
|
|
2
|
+
// backends its configuration names (`backend_packages`). The core asks it what docs/INTERFACE.md
|
|
3
|
+
// writes and scripts/jointure.d.ts types, and imports no other file of a module of language.
|
|
4
|
+
//
|
|
5
|
+
// - A project declares its languages in its package.json, `grillhouse.langages`, a list of names
|
|
6
|
+
// of the frame's closed list (`LANGAGES`), each a module under `scripts/langages/<nom>/`. The
|
|
7
|
+
// declaration is the only reading: a project that declares none, or a directory without
|
|
8
|
+
// package.json, is refused, named, with the command that writes it (`grillhouse maj`).
|
|
9
|
+
// - What the update writes is what the modules find in the repository (`langagesTrouves`), as each
|
|
10
|
+
// plugin of Nx infers its projects from its own files (`createNodes`): each module answers by
|
|
11
|
+
// its `trouve`.
|
|
12
|
+
// - One language is served: a declaration of several is refused, each named; a name out of the
|
|
13
|
+
// list is refused, the list named.
|
|
14
|
+
// - A module is loaded once per process, synchronously (`require` of an ES module, Node 22): the
|
|
15
|
+
// locks and the guards ask it in a hook, where nothing waits.
|
|
16
|
+
import { readFileSync } from 'node:fs';
|
|
17
|
+
import { createRequire } from 'node:module';
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
|
|
20
|
+
// The frame's languages, each its module, from this directory.
|
|
21
|
+
export const LANGAGES = {
|
|
22
|
+
typescript: './langages/typescript/index.mjs',
|
|
23
|
+
cargo: './langages/cargo/index.mjs',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const requis = createRequire(import.meta.url);
|
|
27
|
+
const charges = new Map();
|
|
28
|
+
const charger = nom => {
|
|
29
|
+
if (!charges.has(nom)) {charges.set(nom, requis(LANGAGES[nom]).default);}
|
|
30
|
+
return charges.get(nom);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The module of the language <nom> of the frame's list, loaded once per process.
|
|
35
|
+
* @param {string} nom a name of LANGAGES
|
|
36
|
+
* @returns {import('./jointure.js').Langage}
|
|
37
|
+
*/
|
|
38
|
+
export const langage = nom => charger(nom);
|
|
39
|
+
|
|
40
|
+
// The languages the project at <racine> declares (`grillhouse.langages` of its package.json), an
|
|
41
|
+
// empty list when it declares none.
|
|
42
|
+
export function langagesDeclares(racine) {
|
|
43
|
+
let declares;
|
|
44
|
+
try {
|
|
45
|
+
declares = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8'))?.grillhouse
|
|
46
|
+
?.langages;
|
|
47
|
+
} catch {
|
|
48
|
+
declares = undefined;
|
|
49
|
+
}
|
|
50
|
+
return Array.isArray(declares) ? declares.map(String) : [];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// The languages of the frame whose module finds its code in the repository at <racine>, in the
|
|
54
|
+
// order of the list.
|
|
55
|
+
export function langagesTrouves(racine) {
|
|
56
|
+
return Object.keys(LANGAGES).filter(nom => charger(nom).trouve(racine));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The module of the language that serves the project at <racine>. Throws when the project
|
|
61
|
+
* declares none, a language out of the frame's list, or several.
|
|
62
|
+
* @param {string} racine the root of the project
|
|
63
|
+
* @returns {import('./jointure.js').Langage}
|
|
64
|
+
*/
|
|
65
|
+
export function langageDe(racine) {
|
|
66
|
+
const noms = langagesDeclares(racine);
|
|
67
|
+
const fichier = path.join(racine, 'package.json');
|
|
68
|
+
if (noms.length === 0) {
|
|
69
|
+
throw new Error(
|
|
70
|
+
`⛔ ${fichier} ne déclare aucun langage (grillhouse.langages) ; \`npx grillhouse maj\` l'écrit d'après ce qu'il trouve (les langages du cadre : ${Object.keys(LANGAGES).join(', ')}).`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
const inconnus = noms.filter(n => !Object.hasOwn(LANGAGES, n));
|
|
74
|
+
if (inconnus.length) {
|
|
75
|
+
throw new Error(
|
|
76
|
+
`⛔ langage inconnu du cadre : ${inconnus.join(', ')} (grillhouse.langages de ${fichier}) ; les langages du cadre : ${Object.keys(LANGAGES).join(', ')}.`
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
if (noms.length > 1) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
`⛔ ${noms.join(', ')} : le cadre sert un seul langage par projet (grillhouse.langages de ${fichier}).`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return charger(noms[0]);
|
|
85
|
+
}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
// The progress of a pass, as Bazel counts its actions « [1 234 / 2 000] »: the variable that names
|
|
2
|
-
// the progress directory of a pass, `GRILLHOUSE_AVANCEMENT`, the
|
|
3
|
-
//
|
|
2
|
+
// the progress directory of a pass, `GRILLHOUSE_AVANCEMENT`, and the writing of a record, which
|
|
3
|
+
// the reporter of the module of the language writes while it is set (for typescript,
|
|
4
|
+
// scripts/langages/typescript/vitest-config/avancement.reporter.mjs) and the queue for the steps of its CI. The
|
|
4
5
|
// reading, the plan and the totals kept are scripts/avancement.mjs.
|
|
5
6
|
//
|
|
6
7
|
// - Each task of a pass writes its own record to `<dossier>/taches/<nom>.json`: `{ hash, faits,
|
|
7
|
-
// prevus, a }`, the hash of its
|
|
8
|
+
// prevus, a }`, the hash of its task in the cache of its runner (null without one), its files
|
|
8
9
|
// done and planned, and the instant of the writing (ms). Two packages, or the same one twice,
|
|
9
10
|
// never write the same file.
|
|
10
11
|
// - A record is written whole or not at all: to a file of its own, renamed over the record.
|
|
11
|
-
// - The variable passes through Turborepo without entering any hash (`globalPassThroughEnv` of the
|
|
12
|
-
// root's turbo.json, which scripts/turbo-des-paquets.mjs writes and checks).
|
|
13
12
|
import { mkdirSync, renameSync, writeFileSync } from 'node:fs';
|
|
14
13
|
import path from 'node:path';
|
|
15
|
-
import { fileURLToPath } from 'node:url';
|
|
16
14
|
|
|
17
15
|
export const AVANCEMENT = 'GRILLHOUSE_AVANCEMENT';
|
|
18
16
|
// The subdirectory of the records in a progress directory.
|
|
@@ -30,10 +28,3 @@ export function ecrireAtomique(fichier, objet) {
|
|
|
30
28
|
export function ecrireTache(dossier, nom, { hash = null, faits, prevus }) {
|
|
31
29
|
ecrireAtomique(path.join(dossier, TACHES, `${nom}.json`), { hash, faits, prevus, a: Date.now() });
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
// The reporter of progress under <env>'s progress directory, as Vitest's `reporters` take it; an
|
|
35
|
-
// empty list without the variable.
|
|
36
|
-
export function rapportAvancement(env = process.env) {
|
|
37
|
-
if (!env[AVANCEMENT]) return [];
|
|
38
|
-
return [fileURLToPath(new URL('./avancement.reporter.mjs', import.meta.url))];
|
|
39
|
-
}
|