@roomi-fields/grillhouse 0.53.0 → 0.54.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/CHANGELOG.md +48 -0
- package/cadre/templates/projet/docs/agents/issue-tracker.md +2 -2
- package/charte.md +12 -0
- package/dist/temporal/circuit/deroule.js +5 -9
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +15 -2
- package/dist/temporal/installation.js +69 -17
- package/dist/temporal/installation.js.map +1 -1
- package/docs/INTERFACE.md +21 -1
- package/docs/architecture/circuit.md +3 -3
- package/docs/architecture/entree.md +4 -4
- package/docs/architecture/greffon.md +19 -10
- package/docs/architecture/installation.md +11 -7
- package/docs/architecture/machine.md +1 -1
- package/docs/architecture/tests.md +1 -1
- package/hooks/register.tsx +50 -24
- package/package.json +1 -1
- package/scripts/aiguillage.mjs +4 -2
- package/scripts/bd-garde.mjs +69 -0
- package/scripts/ci-de-main.mjs +259 -56
- package/scripts/circuit.mjs +20 -5
- package/scripts/commandes-composees.mjs +1 -1
- package/scripts/droits.mjs +11 -4
- package/scripts/file-des-tickets.mjs +27 -9
- package/scripts/langages/c/commandes.mjs +1 -1
- package/scripts/langages/cargo/commandes.mjs +1 -1
- package/scripts/langages/cargo/tailles-des-tests.mjs +115 -6
- package/scripts/langages/python/commandes.mjs +1 -1
- package/scripts/langages/typescript/code-mort.mjs +36 -3
- package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +95 -24
- package/scripts/langages/typescript/mise-a-jour.mjs +49 -12
- package/scripts/langages/typescript/parcours.mjs +5 -1
- package/scripts/langages.d.mts +6 -0
- package/scripts/langages.mjs +6 -0
- package/scripts/lire.mjs +236 -0
- package/scripts/migrations/cout-des-jetons-au-registre.mjs +136 -0
- package/scripts/migrations/lire-un-ticket.mjs +46 -0
- package/scripts/migrations.mjs +4 -0
- package/scripts/montee.mjs +110 -46
- package/scripts/nuit.sh +21 -12
- package/scripts/registre.d.mts +7 -1
- package/scripts/registre.mjs +114 -102
- package/scripts/resultats.mjs +15 -5
- package/scripts/sous-commandes.mjs +1 -0
- package/scripts/suiveur.mjs +12 -4
- package/scripts/superviseur.mjs +28 -17
- package/scripts/tableau.mjs +527 -119
- package/scripts/tarifs.mjs +67 -0
- package/scripts/ticket-du-circuit.mjs +3 -4
- package/scripts/transitions.d.mts +0 -5
- package/scripts/transitions.mjs +3 -13
- package/scripts/verdict-de-la-nuit.mjs +2 -2
- package/skills/explorateur/SKILL.md +10 -5
- package/skills/mesure/SKILL.md +4 -3
- package/skills/pitmaster/SKILL.md +11 -2
- package/skills/pitmaster/references/erreurs.md +4 -2
- package/skills/pitmaster/references/tour.md +11 -4
- package/types/index.d.ts +3 -1
- package/scripts/base-des-workflows.mjs +0 -58
|
@@ -42,6 +42,7 @@ import path from 'node:path';
|
|
|
42
42
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
43
43
|
import { RESULTATS } from '../../resultats.mjs';
|
|
44
44
|
import {
|
|
45
|
+
A_REPASSER,
|
|
45
46
|
AttenteDeLaMachine,
|
|
46
47
|
avecLaPasse,
|
|
47
48
|
cheminsDeLaTache,
|
|
@@ -80,7 +81,6 @@ const OUTIL = 'turbo';
|
|
|
80
81
|
const RACINE = '//';
|
|
81
82
|
/** The constructions of CMake, one directory per package, at the root. */
|
|
82
83
|
export const CONSTRUCTION = '.build-cmake';
|
|
83
|
-
const A_REPASSER = 75;
|
|
84
84
|
|
|
85
85
|
/** The guards of the module: each its name and its script beside this one. */
|
|
86
86
|
export const GARDES = [
|
|
@@ -151,6 +151,7 @@ import path from 'node:path';
|
|
|
151
151
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
152
152
|
import { RESULTATS } from '../../resultats.mjs';
|
|
153
153
|
import {
|
|
154
|
+
A_REPASSER,
|
|
154
155
|
AttenteDeLaMachine,
|
|
155
156
|
attendreLeRepos,
|
|
156
157
|
surUnePart,
|
|
@@ -200,7 +201,6 @@ export const NOMS = [
|
|
|
200
201
|
];
|
|
201
202
|
// The task runner of the graph of the packages.
|
|
202
203
|
const OUTIL = 'turbo';
|
|
203
|
-
const A_REPASSER = 75;
|
|
204
204
|
// The exit code of nextest when its filter keeps no test (NO_TESTS_RUN).
|
|
205
205
|
const AUCUN_TEST = 4;
|
|
206
206
|
// What the night out of the poste says of a filter that keeps no test: green.
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
// files under `src/`; a crate of the product it uses is not read: what it starts is its own.
|
|
20
20
|
// - large (`grand`): it starts a process (`std::process`, `tokio::process`, `assert_cmd`, `duct`,
|
|
21
21
|
// `xshell`), mounts a trial repository (git's `init`, `clone` or `worktree add`, as an
|
|
22
|
-
// argument or a command, or git2's `Repository::init` and
|
|
23
|
-
// there something else than git (`Command::new` of a binary of the product, `cargo_bin`,
|
|
22
|
+
// argument of a call of git or in a command, or git2's `Repository::init` and
|
|
23
|
+
// `Repository::clone`) and starts there something else than git (`Command::new` of a binary of the product, `cargo_bin`,
|
|
24
24
|
// `cmd!` of another program);
|
|
25
25
|
// - medium (`moyen`): it starts a process;
|
|
26
26
|
// - small (`petit`): it starts none.
|
|
@@ -46,10 +46,30 @@ export const GRAND_DE_JOUR = 'grand-de-jour';
|
|
|
46
46
|
|
|
47
47
|
// The use of a way to start a process.
|
|
48
48
|
const PROCESSUS = /\b(?:std|tokio|async_std)::process\b|\b(?:assert_cmd|duct|xshell)\b/;
|
|
49
|
-
// A trial repository mounted: git's `init`, `clone` or `worktree add
|
|
50
|
-
// git2's `Repository::init` or `Repository::clone`.
|
|
49
|
+
// A trial repository mounted without an argument of a call: git's `init`, `clone` or `worktree add`
|
|
50
|
+
// in a command, or git2's `Repository::init` or `Repository::clone`.
|
|
51
51
|
const DEPOT_D_ESSAI =
|
|
52
|
-
|
|
52
|
+
/\bgit\s+(?:-[Cc]\s+\S+\s+)*(?:init|clone|worktree\s+add)\b|\bRepository::(?:init|clone)\w*\s*\(/;
|
|
53
|
+
// The same three as the arguments of a call of git (`appelsDeGit`), in one list or one by one.
|
|
54
|
+
const ARGUMENT_DE_DEPOT = /"(?:init|clone)"|"worktree"(?:\s*,|\s*\)\s*\.arg\s*\()\s*"add"/;
|
|
55
|
+
// A comment, a string (raw or not) or a character, whose brackets and semicolons are no code.
|
|
56
|
+
const HORS_DU_CODE =
|
|
57
|
+
/\/\/[^\n]*|\/\*[\s\S]*?\*\/|\br(#*)"[\s\S]*?"\1|"(?:\\[\s\S]|[^"\\])*"|'(?:\\[^']+|[^\\'\n])'/g;
|
|
58
|
+
// The command of git, `Command::new("git")`.
|
|
59
|
+
const COMMANDE_GIT = /\bCommand::new\s*\(\s*r?#*"git"/g;
|
|
60
|
+
// The name a statement binds to the expression that follows it, `let mut c: Command = `.
|
|
61
|
+
const NOM_LIE =
|
|
62
|
+
/\blet\s+(?:mut\s+)?([A-Za-z_]\w*)\s*(?::\s*[\w:<>]+\s*)?=\s*(?:[A-Za-z_]\w*(?:::|\.))*$/;
|
|
63
|
+
// The next method of a chain, up to its parenthesis.
|
|
64
|
+
const METHODE = /\s*(?:\?|\.\s*await\b)?\s*\.\s*([A-Za-z_]\w*)\s*(?:::\s*<[^()]*>\s*)?\(/y;
|
|
65
|
+
// The return type of a function that gives a command.
|
|
66
|
+
const REND_UNE_COMMANDE = /->[^{]*\bCommand\b/;
|
|
67
|
+
// A call of git by its parentheses: a function or a macro named after git (`git(`, `run_git(`), or
|
|
68
|
+
// whose program is git (`cmd!("git", …)`, `cmd("git", …)`).
|
|
69
|
+
const APPEL_DE_GIT =
|
|
70
|
+
/\b(?:[A-Za-z0-9]+_)*git(?:_[A-Za-z0-9]+)*!?\s*\(|\b\w+!?\s*\(\s*(?=(?:[A-Za-z_]\w*\s*,\s*)?r?#*"git"\s*,)/g;
|
|
71
|
+
// A function and its parameters, up to the brace of its body.
|
|
72
|
+
const FONCTION = /\bfn\s+([A-Za-z_]\w*)([^{;]*(?:;[^{;\]]*\][^{;]*)*)\{/g;
|
|
53
73
|
// A call that starts a process, its program captured: `Command::new(<programme>`, assert_cmd's
|
|
54
74
|
// `cargo_bin(<binaire>`, the macro `cmd!` of duct (`cmd!("git", …)`) and of xshell (`cmd!(sh,
|
|
55
75
|
// "git …")`).
|
|
@@ -94,6 +114,93 @@ function fichierDuModule(f, nom, chemin, lire) {
|
|
|
94
114
|
return ordre.find(c => lire(c) !== null) ?? null;
|
|
95
115
|
}
|
|
96
116
|
|
|
117
|
+
// Where the code open at <debut> in <code> (its comments and strings blanked) ends: the bracket
|
|
118
|
+
// that closes it (`groupe`), the `;` that ends the statement (`instruction`), or the bracket that
|
|
119
|
+
// closes the block around (`bloc`).
|
|
120
|
+
function finDe(code, debut, portee = 'groupe') {
|
|
121
|
+
let ouverts = 0;
|
|
122
|
+
for (let i = debut; i < code.length; i++) {
|
|
123
|
+
if ('([{'.includes(code[i])) {
|
|
124
|
+
ouverts++;
|
|
125
|
+
} else if (')]}'.includes(code[i])) {
|
|
126
|
+
ouverts--;
|
|
127
|
+
if (ouverts < 0 || (ouverts === 0 && portee === 'groupe')) {
|
|
128
|
+
return i;
|
|
129
|
+
}
|
|
130
|
+
} else if (portee === 'instruction' && ouverts === 0 && code[i] === ';') {
|
|
131
|
+
return i;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return code.length;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// The `arg` and `args` of the method chain that follows <fin> in <texte> (<code>, its comments and
|
|
138
|
+
// strings blanked), each `.arg(…)`; empty for none.
|
|
139
|
+
function argumentsEnChaine(texte, code, fin) {
|
|
140
|
+
let args = '';
|
|
141
|
+
for (let i = fin; ;) {
|
|
142
|
+
METHODE.lastIndex = i;
|
|
143
|
+
const m = METHODE.exec(code);
|
|
144
|
+
if (!m) {
|
|
145
|
+
return args;
|
|
146
|
+
}
|
|
147
|
+
const ouvre = i + m[0].length - 1;
|
|
148
|
+
i = finDe(code, ouvre) + 1;
|
|
149
|
+
if (m[1] === 'arg' || m[1] === 'args') {
|
|
150
|
+
args += `.${m[1]}${texte.slice(ouvre, i)}`;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// The `arg` and `args` of the name <nom>, from <debut> to the end of its block or to the statement
|
|
156
|
+
// that binds it again, put end to end.
|
|
157
|
+
function argumentsDuNom(texte, code, nom, debut) {
|
|
158
|
+
const bloc = code.slice(debut, finDe(code, debut, 'bloc'));
|
|
159
|
+
const autre = bloc.search(new RegExp(`\\blet\\s+(?:mut\\s+)?${nom}\\b`));
|
|
160
|
+
const portee = autre < 0 ? bloc : bloc.slice(0, autre);
|
|
161
|
+
return [...portee.matchAll(new RegExp(`(?<![\\w.])${nom}\\b(?=\\s*\\.)`, 'g'))]
|
|
162
|
+
.map(a => argumentsEnChaine(texte, code, debut + a.index + nom.length))
|
|
163
|
+
.join('');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// The text of each call of git in <texte>: the parentheses of a call named after git or running it,
|
|
167
|
+
// and those of a call of a function of the text that passes its arguments to a command of git; and
|
|
168
|
+
// the `arg` and `args` of a command of git (`Command::new("git")`, a call named after git, or a
|
|
169
|
+
// call of a function of the text that returns such a command), chained on it or on the name it is
|
|
170
|
+
// bound to.
|
|
171
|
+
function appelsDeGit(texte) {
|
|
172
|
+
const code = texte.replace(HORS_DU_CODE, s => s.replace(/[^\n]/g, s.startsWith('/') ? ' ' : '_'));
|
|
173
|
+
const appels = [];
|
|
174
|
+
// The calls <motif> finds: their parentheses when <passe>, and the arguments of the command
|
|
175
|
+
// they give.
|
|
176
|
+
const suivre = (motif, passe) => {
|
|
177
|
+
for (const m of texte.matchAll(motif)) {
|
|
178
|
+
const ouvre = m.index + m[0].indexOf('(');
|
|
179
|
+
const fin = finDe(code, ouvre);
|
|
180
|
+
if (passe) {
|
|
181
|
+
appels.push(texte.slice(ouvre, fin));
|
|
182
|
+
}
|
|
183
|
+
appels.push(argumentsEnChaine(texte, code, fin + 1));
|
|
184
|
+
const lie = NOM_LIE.exec(code.slice(Math.max(0, m.index - 200), m.index));
|
|
185
|
+
if (lie) {
|
|
186
|
+
const suite = finDe(code, m.index, 'instruction') + 1;
|
|
187
|
+
appels.push(argumentsDuNom(texte, code, lie[1], suite));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
suivre(COMMANDE_GIT, false);
|
|
192
|
+
suivre(APPEL_DE_GIT, true);
|
|
193
|
+
for (const m of code.matchAll(FONCTION)) {
|
|
194
|
+
const corps = texte.slice(m.index, finDe(code, m.index + m[0].length - 1));
|
|
195
|
+
const passe = /\b(?:str|String|OsStr)\b/.test(m[2]);
|
|
196
|
+
const rend = REND_UNE_COMMANDE.test(m[2]);
|
|
197
|
+
if ((passe || rend) && corps.search(COMMANDE_GIT) >= 0) {
|
|
198
|
+
suivre(new RegExp(`\\b${m[1]}\\s*\\(`, 'g'), passe);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return appels;
|
|
202
|
+
}
|
|
203
|
+
|
|
97
204
|
/**
|
|
98
205
|
* The size of the test file <fichier> (absolute), read by <lire> (a path → its text, null when it
|
|
99
206
|
* does not read), the crates of the shared test material <matieres> (`[{ nom, fichiers }]`, `nom`
|
|
@@ -129,7 +236,9 @@ export function classer(fichier, lire = lireLeDisque, matieres = []) {
|
|
|
129
236
|
const tout = textes.join('\n');
|
|
130
237
|
const processus = PROCESSUS.test(tout);
|
|
131
238
|
const autreQueGit = [...tout.matchAll(APPEL)].some(m => !GIT.test((m[1] ?? m[2] ?? m[3]).trim()));
|
|
132
|
-
|
|
239
|
+
const depot = () =>
|
|
240
|
+
DEPOT_D_ESSAI.test(tout) || appelsDeGit(tout).some(a => ARGUMENT_DE_DEPOT.test(a));
|
|
241
|
+
if (processus && autreQueGit && depot()) {
|
|
133
242
|
return 'grand';
|
|
134
243
|
}
|
|
135
244
|
return processus ? 'moyen' : 'petit';
|
|
@@ -91,6 +91,7 @@ import path from 'node:path';
|
|
|
91
91
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
92
92
|
import { RESULTATS } from '../../resultats.mjs';
|
|
93
93
|
import {
|
|
94
|
+
A_REPASSER,
|
|
94
95
|
AttenteDeLaMachine,
|
|
95
96
|
surUnePart,
|
|
96
97
|
avecLaPasse,
|
|
@@ -133,7 +134,6 @@ export const NOMS = [
|
|
|
133
134
|
];
|
|
134
135
|
// The task runner of the graph of the packages.
|
|
135
136
|
const OUTIL = 'turbo';
|
|
136
|
-
const A_REPASSER = 75;
|
|
137
137
|
const RACINE = '//';
|
|
138
138
|
/** The night tests, which the day leaves out. */
|
|
139
139
|
export const DE_NUIT = '*_nuit_test.py';
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
// project's debt (`grillhouse-dette.json`, see `dette.mjs`) passes, keyed by its file and knip's
|
|
8
8
|
// kind of issue (`files`, `exports`, `types`, `dependencies`…).
|
|
9
9
|
// - A knip that measured nothing (it failed, or its output is not its report) refuses too: an
|
|
10
|
-
// empty green is the worst green.
|
|
10
|
+
// empty green is the worst green. So does a partial measure, before the debt is judged: a run
|
|
11
|
+
// that writes « ERROR: Error loading <file> » on stderr, its report readable or not, or that
|
|
12
|
+
// ends on another exit code than 0 and 1.
|
|
11
13
|
// - A finding that is not dead (a format's full table, a public name a consumer outside the
|
|
12
14
|
// repository reads) leaves by its name in `knip.json`, with its reason, never by a wide pattern.
|
|
13
15
|
// - The packages listed out of the frame (`docs/agents/hors-cadre.txt`, read by `horsCadre` of
|
|
@@ -43,6 +45,7 @@ import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'no
|
|
|
43
45
|
import { tmpdir } from 'node:os';
|
|
44
46
|
import path from 'node:path';
|
|
45
47
|
import { pathToFileURL } from 'node:url';
|
|
48
|
+
import { stripVTControlCharacters } from 'node:util';
|
|
46
49
|
import { fournisseursDuPaquet } from '../../services-du-noyau.mjs';
|
|
47
50
|
import { horsCadre, paquets as paquetsDuDepot } from '../../paquets.mjs';
|
|
48
51
|
import { MODE, trancher } from '../../dette.mjs';
|
|
@@ -348,9 +351,35 @@ function knip(racine, config, include) {
|
|
|
348
351
|
}
|
|
349
352
|
}
|
|
350
353
|
|
|
354
|
+
// Why the runs of knip <passes> (spawn results) measured only a part of the repository, as the
|
|
355
|
+
// lines of the refusal; null when every run is complete. First every « ERROR: Error loading » line
|
|
356
|
+
// any of them writes on stderr, colour sequences taken off: knip then reports without what that
|
|
357
|
+
// configuration declares. Else the first run that ends on another exit code than 0 (nothing found)
|
|
358
|
+
// and 1 (findings), or without one, with what it says.
|
|
359
|
+
function mesureIncomplete(passes) {
|
|
360
|
+
const nonCharges = new Set(
|
|
361
|
+
passes
|
|
362
|
+
.flatMap(p => stripVTControlCharacters(p.stderr ?? '').split(/\r?\n/))
|
|
363
|
+
.filter(l => l.includes('ERROR: Error loading '))
|
|
364
|
+
);
|
|
365
|
+
if (nonCharges.size) {
|
|
366
|
+
return [
|
|
367
|
+
"⛔ CODE MORT — knip n'a pas chargé une configuration : sa mesure est incomplète, et la dette ne l'absorbe pas. La configuration que knip nomme se corrige pour qu'il la charge, ou son greffon se règle dans knip.json avec sa raison.",
|
|
368
|
+
...[...nonCharges].map(l => ` ${l}`),
|
|
369
|
+
];
|
|
370
|
+
}
|
|
371
|
+
const fautive = passes.find(p => p.status !== 0 && p.status !== 1);
|
|
372
|
+
if (!fautive) {
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
const fin = fautive.status ?? fautive.signal ?? fautive.error?.code;
|
|
376
|
+
const dit = fautive.stderr || fautive.error?.message || fautive.stdout || '';
|
|
377
|
+
return [`⛔ CODE MORT — knip n'a pas fini sa mesure (fin : ${fin}) :\n${dit}`];
|
|
378
|
+
}
|
|
379
|
+
|
|
351
380
|
// The report of the dead-code check at <racine>: `lignes`, what the command writes on stderr (each
|
|
352
|
-
// refusal and the debt's lines), and `code`, its exit code (1 on a refusal
|
|
353
|
-
//
|
|
381
|
+
// refusal and the debt's lines), and `code`, its exit code (1 on a refusal, a knip it cannot read
|
|
382
|
+
// or an incomplete measure, which the debt is then never judged on). The functional core of the command: it runs knip and git and reads the project's debt, and
|
|
354
383
|
// writes nothing to the standard streams; the command below is its shell. The refusals reach SARIF
|
|
355
384
|
// through `trancher` under the results directory <env> names (scripts/resultats.mjs); without it none
|
|
356
385
|
// is written, and the debt's mode is <env>'s `GRILLHOUSE_DETTE`.
|
|
@@ -394,6 +423,10 @@ export async function codeMort(racine, env = process.env) {
|
|
|
394
423
|
DEPS.join(',')
|
|
395
424
|
)
|
|
396
425
|
: null;
|
|
426
|
+
const incomplete = mesureIncomplete(second ? [premier, second] : [premier]);
|
|
427
|
+
if (incomplete) {
|
|
428
|
+
return { lignes: [...lignes, ...incomplete], code: 1 };
|
|
429
|
+
}
|
|
397
430
|
const c2 = second ? constats(second.stdout ?? '', DEPS) : null;
|
|
398
431
|
let c = null;
|
|
399
432
|
if (c1 && (c2 || !second)) {
|
|
@@ -5,8 +5,12 @@
|
|
|
5
5
|
//
|
|
6
6
|
// - Converted: a refused `vitest.config.*` made of static imports, plain statements and one
|
|
7
7
|
// `export default`, that no file reads by its name, becomes the `vitest.config.cjs` of its
|
|
8
|
-
// directory, its
|
|
9
|
-
//
|
|
8
|
+
// directory, its default export the value of the promise it exports; the former file is removed.
|
|
9
|
+
// Its types are stripped by Node.
|
|
10
|
+
// - Its imports: a relative import whose file is TypeScript (`.ts`, `.mts`, `.cts`, `.tsx`) by
|
|
11
|
+
// `require()` of that file under its real name, any other by `await import()`. Before its
|
|
12
|
+
// `require()` calls, a resolution hook (`registerHooks`) resolves to its `.ts` a relative `.js`
|
|
13
|
+
// import no file answers, as TypeScript writes it: knip loads the configuration so.
|
|
10
14
|
// - Left intact, each named with its reason and the way out, then inscribed in the guard's debt,
|
|
11
15
|
// frozen: a configuration another file reads by its name (an import or a require, a path in the
|
|
12
16
|
// code, a script of a package.json or a shell script, a flow, `files` or a literal `include`
|
|
@@ -15,15 +19,17 @@
|
|
|
15
19
|
// Node cannot strip, a directory with a `vitest.config.cjs` already or several refused
|
|
16
20
|
// configurations, and every refused file not named `vitest.config.*` (an ESM `vite.config`, a
|
|
17
21
|
// configuration `--config` names). The migration writes no reader.
|
|
22
|
+
// - Its readers: Vite's temporary files are not read, a file gone between the listing and its
|
|
23
|
+
// read names none, and any other fault of a read stops the migration.
|
|
18
24
|
// - Replayable without effect: a configuration the debt holds is left, and nothing is returned.
|
|
19
|
-
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
25
|
+
import { existsSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
20
26
|
import { createRequire, stripTypeScriptTypes } from 'node:module';
|
|
21
27
|
import path from 'node:path';
|
|
22
28
|
import { FICHIER, lire, trancher } from '../../../dette.mjs';
|
|
23
29
|
import { paquets } from '../../../paquets.mjs';
|
|
24
30
|
import { sources } from '../../../services-du-noyau.mjs';
|
|
25
31
|
import { configurationsRefusees, GARDE } from '../configurations-de-vitest.mjs';
|
|
26
|
-
import { parcourir } from '../parcours.mjs';
|
|
32
|
+
import { estTemporaireDeVite, lireSiPresent, parcourir } from '../parcours.mjs';
|
|
27
33
|
|
|
28
34
|
export const version = '0.53.0';
|
|
29
35
|
export const nom = 'configurations en commonjs';
|
|
@@ -32,6 +38,28 @@ const CONFIGURATION = /^vitest\.config\.(?:[mc]?ts|m?js)$/;
|
|
|
32
38
|
// The directories no reader of a configuration lives in.
|
|
33
39
|
const HORS = new Set(['node_modules', '.git', 'dist', 'coverage', '.claude', '.turbo']);
|
|
34
40
|
const MOTIF = /[*?{}[\]]/;
|
|
41
|
+
const TYPESCRIPT = /\.(?:[mc]?ts|tsx)$/;
|
|
42
|
+
// The TypeScript files an import written in JavaScript names.
|
|
43
|
+
const SOURCES = { '.js': ['.ts', '.tsx'], '.jsx': ['.tsx'], '.mjs': ['.mts'], '.cjs': ['.cts'] };
|
|
44
|
+
// The extensions an import may leave out, in the order Vite tries them.
|
|
45
|
+
const OMISES = ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json'];
|
|
46
|
+
// Resolves a relative `.js` import no file answers to its `.ts`.
|
|
47
|
+
const CROCHET = `require('node:module').registerHooks({
|
|
48
|
+
resolve(specifier, context, nextResolve) {
|
|
49
|
+
try {
|
|
50
|
+
return nextResolve(specifier, context);
|
|
51
|
+
} catch (erreur) {
|
|
52
|
+
if (!/^\\.\\.?\\/.*\\.js$/.test(specifier)) {
|
|
53
|
+
throw erreur;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
return nextResolve(specifier.replace(/js$/, 'ts'), context);
|
|
57
|
+
} catch {
|
|
58
|
+
throw erreur;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
});`;
|
|
35
63
|
// The files that name paths without being code (cheminsNommes).
|
|
36
64
|
const ENUMERE =
|
|
37
65
|
/(?:^|\/)(?:package\.json|tsconfig[^/]*\.json|vitest\.workspace\.json)$|^(?:\.github\/.*\.ya?ml|\.gitlab-ci\.yml)$|\.sh$/;
|
|
@@ -57,7 +85,7 @@ function chaines(ts, f, texte) {
|
|
|
57
85
|
}
|
|
58
86
|
|
|
59
87
|
// The paths, from the root, that the file `f` names: each `{ chemin, module }`, `module` when an
|
|
60
|
-
// import can name it without its extension.
|
|
88
|
+
// import can name it without its extension. A file gone since it was listed names none.
|
|
61
89
|
function cheminsNommes(ts, projet, f, espaces) {
|
|
62
90
|
const nomDuFichier = path.posix.basename(f);
|
|
63
91
|
const ici = path.posix.dirname(f);
|
|
@@ -67,12 +95,15 @@ function cheminsNommes(ts, projet, f, espaces) {
|
|
|
67
95
|
.split(SEPARATEURS)
|
|
68
96
|
.filter(m => m && !MOTIF.test(m))
|
|
69
97
|
.flatMap(m => bases.map(b => ({ chemin: joindre(b, m) })));
|
|
70
|
-
const lu = (
|
|
98
|
+
const lu = lireSiPresent(path.join(projet, f));
|
|
99
|
+
if (lu === null) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
71
102
|
if (nomDuFichier === 'package.json') {
|
|
72
103
|
// A manifest that is not JSON (a fixture) names no script.
|
|
73
104
|
let scripts;
|
|
74
105
|
try {
|
|
75
|
-
scripts = Object.values(JSON.parse(lu
|
|
106
|
+
scripts = Object.values(JSON.parse(lu).scripts ?? {});
|
|
76
107
|
} catch {
|
|
77
108
|
return [];
|
|
78
109
|
}
|
|
@@ -82,20 +113,20 @@ function cheminsNommes(ts, projet, f, espaces) {
|
|
|
82
113
|
});
|
|
83
114
|
}
|
|
84
115
|
if (/^tsconfig.*\.json$/.test(nomDuFichier)) {
|
|
85
|
-
const { config } = ts.parseConfigFileTextToJson(f, lu
|
|
116
|
+
const { config } = ts.parseConfigFileTextToJson(f, lu);
|
|
86
117
|
return [...(config?.files ?? []), ...(config?.include ?? [])]
|
|
87
118
|
.filter(m => typeof m === 'string' && !MOTIF.test(m))
|
|
88
119
|
.map(m => ({ chemin: joindre(ici, m) }));
|
|
89
120
|
}
|
|
90
121
|
if (/^vitest\.workspace\.json$/.test(nomDuFichier)) {
|
|
91
|
-
return mots(lu
|
|
122
|
+
return mots(lu, [ici]);
|
|
92
123
|
}
|
|
93
124
|
if (/^(\.github\/.*\.ya?ml|\.gitlab-ci\.yml)$/.test(f) || f.endsWith('.sh')) {
|
|
94
|
-
const texte = lu
|
|
125
|
+
const texte = lu.replace(/(^|\s)#.*$/gm, '$1');
|
|
95
126
|
const dossiers = [...texte.matchAll(/working-directory:\s*["']?([^\s"']+)/g)].map(m => m[1]);
|
|
96
127
|
return mots(texte, ['.', ici, ...dossiers]);
|
|
97
128
|
}
|
|
98
|
-
return chaines(ts, f, lu
|
|
129
|
+
return chaines(ts, f, lu).flatMap(m => {
|
|
99
130
|
if (!m || MOTIF.test(m) || /\s/.test(m)) {
|
|
100
131
|
return [];
|
|
101
132
|
}
|
|
@@ -118,7 +149,8 @@ function lecteursDe(ts, projet, cibles) {
|
|
|
118
149
|
const autres = parcourir(projet, p => HORS.has(path.basename(p)))
|
|
119
150
|
.map(p => posix(path.relative(projet, p)))
|
|
120
151
|
.filter(f => ENUMERE.test(f));
|
|
121
|
-
|
|
152
|
+
const code = sources(projet).filter(f => !estTemporaireDeVite(f));
|
|
153
|
+
for (const f of [...new Set([...code, ...autres])].sort()) {
|
|
122
154
|
const nommes = cheminsNommes(ts, projet, f, espaces);
|
|
123
155
|
for (const c of cibles) {
|
|
124
156
|
const lit = nommes.some(
|
|
@@ -136,12 +168,46 @@ function lecteursDe(ts, projet, cibles) {
|
|
|
136
168
|
return out;
|
|
137
169
|
}
|
|
138
170
|
|
|
139
|
-
// The
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
171
|
+
// The real name, from `dossier`, of the TypeScript file the relative import `specifier` reads, or
|
|
172
|
+
// null when it reads anything else, or no file.
|
|
173
|
+
function sourceTypeScript(dossier, specifier) {
|
|
174
|
+
if (!/^\.\.?\//.test(specifier)) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const vise = path.resolve(dossier, specifier);
|
|
178
|
+
const extension = path.extname(vise);
|
|
179
|
+
const lu = [
|
|
180
|
+
vise,
|
|
181
|
+
...(SOURCES[extension] ?? []).map(e => vise.slice(0, -extension.length) + e),
|
|
182
|
+
...OMISES.map(e => vise + e),
|
|
183
|
+
...OMISES.map(e => path.join(vise, `index${e}`)),
|
|
184
|
+
].find(f => statSync(f, { throwIfNoEntry: false })?.isFile());
|
|
185
|
+
if (!lu || !TYPESCRIPT.test(lu)) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
const relatif = posix(path.relative(dossier, lu));
|
|
189
|
+
return relatif.startsWith('../') ? relatif : `./${relatif}`;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// The call that reads the module an import of a file of `dossier` names.
|
|
193
|
+
function lecture(n, dossier) {
|
|
194
|
+
const reel = sourceTypeScript(dossier, n.moduleSpecifier.text);
|
|
195
|
+
if (reel === null) {
|
|
196
|
+
const attributs = n.attributes
|
|
197
|
+
? `, { with: { ${n.attributes.elements.map(e => e.getText()).join(', ')} } }`
|
|
198
|
+
: '';
|
|
199
|
+
return { appel: `await import(${n.moduleSpecifier.getText()}${attributs})`, requis: false };
|
|
200
|
+
}
|
|
201
|
+
const appel = `require(${JSON.stringify(reel).replaceAll('"', "'")})`;
|
|
202
|
+
// A `.cts` is CommonJS: its default import is its `module.exports`, as `import()` gives it.
|
|
203
|
+
return {
|
|
204
|
+
appel: reel.endsWith('.cts') ? `{ ...${appel}, default: ${appel} }` : appel,
|
|
205
|
+
requis: true,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// The declaration of the names the import `n` binds to what `appel` reads.
|
|
210
|
+
function importation(ts, n, appel) {
|
|
145
211
|
const { name: defaut, namedBindings: liaisons } = n.importClause ?? {};
|
|
146
212
|
if (liaisons && ts.isNamespaceImport(liaisons)) {
|
|
147
213
|
const espace = `const ${liaisons.name.text} = ${appel};`;
|
|
@@ -156,9 +222,9 @@ function importation(ts, n) {
|
|
|
156
222
|
return noms.length ? `const { ${noms.join(', ')} } = ${appel};` : `${appel};`;
|
|
157
223
|
}
|
|
158
224
|
|
|
159
|
-
// The CommonJS form of the ESM configuration `source` of the file `f`, or null when
|
|
160
|
-
// more than static imports, plain statements and one default export.
|
|
161
|
-
function enCommonJs(ts, f, source) {
|
|
225
|
+
// The CommonJS form of the ESM configuration `source` of the file `f` of `dossier`, or null when
|
|
226
|
+
// it holds more than static imports, plain statements and one default export.
|
|
227
|
+
function enCommonJs(ts, dossier, f, source) {
|
|
162
228
|
let texte = source;
|
|
163
229
|
if (/ts$/.test(f)) {
|
|
164
230
|
try {
|
|
@@ -182,6 +248,7 @@ function enCommonJs(ts, f, source) {
|
|
|
182
248
|
};
|
|
183
249
|
visiter(arbre);
|
|
184
250
|
const imports = [];
|
|
251
|
+
let requis = false;
|
|
185
252
|
const retouches = [];
|
|
186
253
|
let defauts = 0;
|
|
187
254
|
let valeur = 'configurationParDefaut';
|
|
@@ -190,7 +257,9 @@ function enCommonJs(ts, f, source) {
|
|
|
190
257
|
const exporte = modificateurs.find(m => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
191
258
|
const defaut = modificateurs.find(m => m.kind === ts.SyntaxKind.DefaultKeyword);
|
|
192
259
|
if (ts.isImportDeclaration(n)) {
|
|
193
|
-
|
|
260
|
+
const lu = lecture(n, dossier);
|
|
261
|
+
requis ||= lu.requis;
|
|
262
|
+
imports.push(importation(ts, n, lu.appel));
|
|
194
263
|
retouches.push([n.getStart(), n.end, '']);
|
|
195
264
|
} else if (ts.isExportAssignment(n) && !n.isExportEquals) {
|
|
196
265
|
defauts += 1;
|
|
@@ -225,6 +294,7 @@ function enCommonJs(ts, f, source) {
|
|
|
225
294
|
}
|
|
226
295
|
corps += indenter(depuis, texte.length);
|
|
227
296
|
const lignes = [
|
|
297
|
+
...(requis ? CROCHET.split('\n').map(l => ` ${l}`) : []),
|
|
228
298
|
...imports.flatMap(i => i.split('\n')).map(l => ` ${l}`),
|
|
229
299
|
'',
|
|
230
300
|
` ${corps.trim()}`,
|
|
@@ -267,7 +337,8 @@ export function migrer(projet) {
|
|
|
267
337
|
) {
|
|
268
338
|
raisons.set(fichier, 'plusieurs configurations de Vitest dans son dossier');
|
|
269
339
|
} else {
|
|
270
|
-
const
|
|
340
|
+
const source = readFileSync(path.join(projet, fichier), 'utf8');
|
|
341
|
+
const neuf = enCommonJs(ts, path.join(projet, dossier), fichier, source);
|
|
271
342
|
if (neuf === null) {
|
|
272
343
|
raisons.set(
|
|
273
344
|
fichier,
|
|
@@ -291,7 +362,7 @@ export function migrer(projet) {
|
|
|
291
362
|
for (const [fichier, raison] of raisons) {
|
|
292
363
|
const cjs = path.posix.join(path.posix.dirname(fichier), 'vitest.config.cjs');
|
|
293
364
|
lignes.push(
|
|
294
|
-
`${fichier} : laissée, ${raison} ; elle peut échouer en EROFS quand son paquet est hors du plan. Pour la convertir : écris ${cjs} (\`module.exports = (async () => { … })();\`,
|
|
365
|
+
`${fichier} : laissée, ${raison} ; elle peut échouer en EROFS quand son paquet est hors du plan. Pour la convertir : écris ${cjs} (\`module.exports = (async () => { … })();\`, un fichier TypeScript relatif par \`require()\` sous son nom réel, après un crochet \`registerHooks\` de \`node:module\` quand ses voisins se nomment en \`.js\`, tout autre import par \`await import()\`), et fais-le nommer par ses lecteurs. Inscrite dans ${FICHIER} (${GARDE}), gelée : une neuve est refusée`
|
|
295
366
|
);
|
|
296
367
|
}
|
|
297
368
|
}
|
|
@@ -29,16 +29,18 @@
|
|
|
29
29
|
// - A package of the frame whose code imports the frame's package (a file of its `src/` out of the
|
|
30
30
|
// tests, its imports read by TypeScript's `preProcessFile`) declares it in its `dependencies`, as
|
|
31
31
|
// npm puts there what the published code imports: a declaration in its `devDependencies` moves
|
|
32
|
-
// there with its range, else the range the root declares (else `^<version>`).
|
|
32
|
+
// there with its range, else the range the root declares (else `^<version>`). The frame's package
|
|
33
|
+
// declares itself nowhere.
|
|
33
34
|
// - The frame's base configuration of Vitest is the package's (`@roomi-fields/grillhouse/vitest-config`),
|
|
34
35
|
// which each Vitest configuration imports by its name: in a project with `workspaces`, each
|
|
35
|
-
// package of the frame that plays tests (`joueDesTests`: its script `test:unit`)
|
|
36
|
-
//
|
|
36
|
+
// package of the frame that plays tests (`joueDesTests`: its script `test:unit`) by Vitest (that
|
|
37
|
+
// script calls `vitest`, or the package holds a `vitest.config.*`), the frame's own left out,
|
|
38
|
+
// declares the frame's package in its `devDependencies`, at the range the root declares (else `^<version>`),
|
|
37
39
|
// a declaration it holds kept (at its range, brought up as above). The update writes no Vitest configuration.
|
|
38
40
|
// - The typing: each package of TypeScript (a `tsconfig.json`) that has no `typecheck` script
|
|
39
41
|
// receives the template's, `tsc -p tsconfig.json --noEmit`: each package of the frame in a
|
|
40
42
|
// project with `workspaces` (the root's `typecheck` stays the project's), the root in a project
|
|
41
|
-
// without.
|
|
43
|
+
// without. A `tsconfig.json` that extends a relative file the copy does not hold receives none.
|
|
42
44
|
// - `turbo.json` is the project's own file. A project with no `turbo.json` receives the frame's
|
|
43
45
|
// template of its form: `templates/turbo/paquets.json` when its package.json declares
|
|
44
46
|
// `workspaces`, else `templates/turbo/sans-paquets.json`. A `turbo.json` present is never written
|
|
@@ -46,7 +48,7 @@
|
|
|
46
48
|
// - The generators: the boundaries' configuration (`.dependency-cruiser.cjs`), the index of the
|
|
47
49
|
// interfaces, and the turbo.json of each package in a repository with `workspaces`.
|
|
48
50
|
import { spawnSync } from 'node:child_process';
|
|
49
|
-
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
51
|
+
import { existsSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
50
52
|
import { createRequire } from 'node:module';
|
|
51
53
|
import path from 'node:path';
|
|
52
54
|
import { CODE, paquets, TYPAGE } from '../../paquets.mjs';
|
|
@@ -59,6 +61,9 @@ const CONFIG_VITEST = `${PAQUET_DU_CADRE}/vitest-config`;
|
|
|
59
61
|
// The root scripts of the tests, written together from the template.
|
|
60
62
|
const SCRIPTS_DES_TESTS = ['test', SCRIPT_DES_TESTS, 'test:forcer', 'verifier'];
|
|
61
63
|
const CHAMPS_INSTALLES = ['dependencies', 'devDependencies', 'optionalDependencies'];
|
|
64
|
+
const CONFIGURATIONS_DE_VITEST = ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs'].map(
|
|
65
|
+
e => `vitest.config.${e}`
|
|
66
|
+
);
|
|
62
67
|
// The frame's templates of `turbo.json`, one per form of repository, read in the source.
|
|
63
68
|
const TURBO = {
|
|
64
69
|
fichier: 'turbo.json',
|
|
@@ -198,7 +203,8 @@ function declarerDependanceDuCadre(projet, p, version) {
|
|
|
198
203
|
const declare = ['dependencies', 'optionalDependencies'].some(
|
|
199
204
|
c => pkg[c]?.[PAQUET_DU_CADRE] !== undefined
|
|
200
205
|
);
|
|
201
|
-
|
|
206
|
+
const soi = pkg.name === PAQUET_DU_CADRE;
|
|
207
|
+
if (hors || soi || declare || !codeImporteLeCadre(projet, dossier)) {
|
|
202
208
|
continue;
|
|
203
209
|
}
|
|
204
210
|
const { [PAQUET_DU_CADRE]: dev, ...autres } = pkg.devDependencies ?? {};
|
|
@@ -215,9 +221,15 @@ function declarerDependanceDuCadre(projet, p, version) {
|
|
|
215
221
|
return declarants.length > 0 ? { nom: PAQUET_DU_CADRE, paquets: declarants } : null;
|
|
216
222
|
}
|
|
217
223
|
|
|
224
|
+
// Whether the tests of the package.json <pkg>, read at <dossier>, run by Vitest: its `test:unit`
|
|
225
|
+
// calls it, or the directory holds a configuration of it.
|
|
226
|
+
const testeParVitest = (dossier, pkg) =>
|
|
227
|
+
/\bvitest\b/.test(pkg.scripts?.[SCRIPT_DES_TESTS] ?? '') ||
|
|
228
|
+
CONFIGURATIONS_DE_VITEST.some(f => existsSync(path.join(dossier, f)));
|
|
229
|
+
|
|
218
230
|
// Declares the frame's package, whose base configuration of Vitest each Vitest configuration
|
|
219
|
-
// imports, in the devDependencies of each package of the frame that plays tests (see
|
|
220
|
-
// { nom, paquets }, or null when nothing changes.
|
|
231
|
+
// imports, in the devDependencies of each package of the frame that plays its tests by Vitest (see
|
|
232
|
+
// the header): { nom, paquets }, or null when nothing changes.
|
|
221
233
|
function poserConfigVitest(projet, p, version, joueDesTests) {
|
|
222
234
|
if (p.workspaces === undefined) {
|
|
223
235
|
return null;
|
|
@@ -225,6 +237,8 @@ function poserConfigVitest(projet, p, version, joueDesTests) {
|
|
|
225
237
|
const testes = paquets(projet).filter(
|
|
226
238
|
({ dossier, pkg, hors }) =>
|
|
227
239
|
!hors &&
|
|
240
|
+
pkg.name !== PAQUET_DU_CADRE &&
|
|
241
|
+
testeParVitest(path.join(projet, dossier), pkg) &&
|
|
228
242
|
joueDesTests(projet, {
|
|
229
243
|
dossier: path.join(projet, dossier),
|
|
230
244
|
nom: path.basename(dossier),
|
|
@@ -247,13 +261,34 @@ function poserConfigVitest(projet, p, version, joueDesTests) {
|
|
|
247
261
|
return declarants.length > 0 ? { nom: PAQUET_DU_CADRE, paquets: declarants } : null;
|
|
248
262
|
}
|
|
249
263
|
|
|
264
|
+
const estUnFichier = f => statSync(f, { throwIfNoEntry: false })?.isFile() === true;
|
|
265
|
+
|
|
266
|
+
// Whether each relative file the tsconfig.json at <fichier> extends is there, as TypeScript resolves
|
|
267
|
+
// it (the path, else the path with `.json`); a base named by a package counts as there. Read by
|
|
268
|
+
// TypeScript, which accepts comments.
|
|
269
|
+
function basesPresentes(fichier) {
|
|
270
|
+
const texte = readFileSync(fichier, 'utf8');
|
|
271
|
+
if (!texte.includes('"extends"')) {
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
const ts = createRequire(import.meta.url)('typescript');
|
|
275
|
+
const bases = [ts.parseConfigFileTextToJson(fichier, texte).config?.extends ?? []].flat();
|
|
276
|
+
return bases
|
|
277
|
+
.filter(b => typeof b === 'string' && (b.startsWith('.') || path.isAbsolute(b)))
|
|
278
|
+
.map(b => path.resolve(path.dirname(fichier), b))
|
|
279
|
+
.every(b => estUnFichier(b) || estUnFichier(`${b}.json`));
|
|
280
|
+
}
|
|
281
|
+
|
|
250
282
|
// Gives the typing script of the template, <script>, to each package of TypeScript that has none
|
|
251
283
|
// (see the header): { script, paquets } (`.` for the root), or null when nothing changes.
|
|
252
284
|
function poserTypage(projet, p, script) {
|
|
253
285
|
if (typeof script !== 'string') {
|
|
254
286
|
return null;
|
|
255
287
|
}
|
|
256
|
-
const types = dossier =>
|
|
288
|
+
const types = dossier => {
|
|
289
|
+
const f = path.join(projet, dossier, 'tsconfig.json');
|
|
290
|
+
return existsSync(f) && basesPresentes(f);
|
|
291
|
+
};
|
|
257
292
|
const sans = pkg => typeof pkg.scripts?.[TYPAGE] !== 'string';
|
|
258
293
|
const declarants = [];
|
|
259
294
|
if (p.workspaces === undefined) {
|
|
@@ -333,6 +368,10 @@ function appliquer(projet, { p, modele, source, version }, joueDesTests) {
|
|
|
333
368
|
typage: poserTypage(projet, p, modele.scripts?.[TYPAGE]),
|
|
334
369
|
turbo: poserLeGabaritAbsent(projet, source, p, TURBO),
|
|
335
370
|
};
|
|
371
|
+
const sansVerifier = () =>
|
|
372
|
+
bilan.vitest
|
|
373
|
+
? 'La ligne « Vitest : » ci-dessus dit pourquoi : installe à la racine le Vitest que le cadre exige, puis relance `npx grillhouse maj`, qui écrit le script.'
|
|
374
|
+
: 'La mise à jour l’écrit dans un projet testé par Vitest ; sinon, écris-le pour ses tests.';
|
|
336
375
|
return {
|
|
337
376
|
bilan,
|
|
338
377
|
lignes: rapport(bilan),
|
|
@@ -341,9 +380,7 @@ function appliquer(projet, { p, modele, source, version }, joueDesTests) {
|
|
|
341
380
|
bilan.plageDuCadre !== null ||
|
|
342
381
|
bilan.configVitest !== null ||
|
|
343
382
|
bilan.dependanceDuCadre !== null,
|
|
344
|
-
sansVerifier:
|
|
345
|
-
? 'La ligne « Vitest : » ci-dessus dit pourquoi : installe à la racine le Vitest que le cadre exige, puis relance `npx grillhouse maj`, qui écrit le script.'
|
|
346
|
-
: 'La mise à jour l’écrit dans un projet testé par Vitest ; sinon, écris-le pour ses tests.',
|
|
383
|
+
sansVerifier: typeof p.scripts.verifier === 'string' ? null : sansVerifier(),
|
|
347
384
|
};
|
|
348
385
|
}
|
|
349
386
|
|
|
@@ -23,6 +23,10 @@ function siPresent(lire, f, absent) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/** Whether the path <f> is one of Vite's temporary files, for a listing `parcourir` did not
|
|
27
|
+
* make. */
|
|
28
|
+
export const estTemporaireDeVite = f => TEMPORAIRE_DE_VITE.test(f);
|
|
29
|
+
|
|
26
30
|
/**
|
|
27
31
|
* The files under <chemin> (a directory, or a file), each its absolute path: an entry below it
|
|
28
32
|
* whose path <sauter> keeps out is neither entered nor listed, and Vite's temporary files are
|
|
@@ -35,7 +39,7 @@ export function parcourir(chemin, sauter = () => false) {
|
|
|
35
39
|
const out = [];
|
|
36
40
|
const walk = (p, dossier) => {
|
|
37
41
|
if (!dossier) {
|
|
38
|
-
if (!
|
|
42
|
+
if (!estTemporaireDeVite(p)) {
|
|
39
43
|
out.push(p);
|
|
40
44
|
}
|
|
41
45
|
return;
|