@roomi-fields/grillhouse 0.24.15 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/bin/grillhouse.mjs +40 -12
- package/cadre/templates/cargo/.config/nextest.toml +8 -0
- package/cadre/templates/cargo/deny.toml +36 -0
- package/cadre/templates/cargo/package.json +15 -0
- package/cadre/templates/cargo/rust-toolchain.toml +6 -0
- package/cadre/templates/projet/package.json +5 -1
- package/cadre/templates/turbo/paquets.json +1 -1
- package/cadre/templates/turbo/sans-paquets.json +1 -1
- package/charte.md +16 -0
- package/docs/ARCHITECTURE.md +157 -54
- package/docs/CADRE.md +47 -0
- package/docs/INTERFACE.md +168 -0
- package/package.json +62 -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/{vitest-config → langages/typescript/vitest-config}/duree.reporter.mjs +6 -1
- package/scripts/langages/typescript/vitest-config/lances.mjs +473 -0
- package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.setup.mjs +1 -1
- package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.mjs +5 -5
- package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.setup.mjs +4 -3
- package/scripts/{vitest.nuit.config.mjs → langages/typescript/vitest.nuit.config.mjs} +2 -2
- package/scripts/langages.mjs +85 -0
- package/scripts/{vitest-config → mesure}/avancement.mjs +4 -13
- package/scripts/{vitest-config → mesure}/base-de-passe.mjs +70 -33
- package/scripts/{vitest-config → mesure}/pression.mjs +5 -6
- package/scripts/migrations/0.23.2-copies-du-cadre.mjs +29 -6
- package/scripts/migrations/0.24.0-circuit-simplifie.mjs +13 -6
- package/scripts/migrations/0.25.0-script-des-tests.mjs +92 -0
- package/scripts/migrations.mjs +17 -13
- package/scripts/nuit.sh +59 -63
- package/scripts/paquets.d.ts +5 -0
- package/scripts/paquets.mjs +24 -2
- package/scripts/resultats.mjs +8 -82
- package/scripts/services-du-noyau.mjs +30 -0
- package/scripts/session-start.sh +17 -9
- package/scripts/sources.mjs +35 -13
- package/scripts/sous-commandes.mjs +57 -17
- package/scripts/superviseur.mjs +1 -1
- package/scripts/tableau.mjs +1 -1
- package/scripts/un-commit-par-ticket.mjs +48 -14
- package/scripts/verrou-de-fichier.mjs +1 -1
- package/scripts/verrou-de-machine.mjs +4 -4
- package/scripts/verrous/verrou.mjs +28 -37
- package/skills/developpeur/SKILL.md +2 -2
- package/skills/explorateur/SKILL.md +13 -5
- package/skills/grill/SKILL.md +2 -2
- package/skills/pitmaster/references/cadre.md +1 -1
- package/skills/pitmaster/references/consigne-agent.md +10 -3
- package/skills/redacteur/references/documents-d-un-composant.md +4 -4
- package/skills/relecteur/SKILL.md +4 -1
- package/skills/testwriter/SKILL.md +20 -6
- /package/scripts/{consommateurs.d.ts → langages/typescript/consommateurs.d.ts} +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/base.d.ts +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/machine.setup.mjs +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.d.ts +0 -0
- /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.mjs +0 -0
package/scripts/init.mjs
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
// then the plugins its settings declare: the template's declare the frame's,
|
|
18
18
|
// `grillhouse@roomi-fields`, whose marketplace names the package npm.
|
|
19
19
|
// - Then what the frame writes in a project, as `grillhouse maj` writes it (scripts/grillhouse-maj.mjs):
|
|
20
|
-
// its
|
|
20
|
+
// its languages (`grillhouse.langages`, typescript, the template's tsconfig.json found), its
|
|
21
|
+
// turbo.json, the status line of its settings, the version of the frame; and the generated
|
|
21
22
|
// files (the boundaries' configuration, the interfaces index, run by the project's command). A
|
|
22
23
|
// plugin or a generator that fails has its line, and the exit code is non-zero once the project
|
|
23
24
|
// is created.
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
// - a branch whose replay cannot be done (the copy does not get ready, main does not take the
|
|
33
33
|
// branch, the main tree holds a file of the lot), or whose `npm run verifier` is « à repasser »
|
|
34
34
|
// once replaced (75: a failure of duration under load, which found no rest in its bound,
|
|
35
|
-
// scripts/verifier.mjs; neither green nor red), stays in the queue, the reason written to its
|
|
35
|
+
// scripts/langages/typescript/verifier.mjs; neither green nor red), stays in the queue, the reason written to its
|
|
36
36
|
// ticket, which is neither reopened nor closed, and the queue goes on; the next queue takes it
|
|
37
37
|
// again. Any other code than 0 and 75 is red.
|
|
38
38
|
// At its entry on main, the branch's ticket closes « intégré : <commit> », loses `en-file`, the
|
|
@@ -70,8 +70,8 @@ import { lireCommit } from '../poussee-cles.mjs';
|
|
|
70
70
|
import { attendreUnPeu, lacherVerrou, prendreVerrou } from '../verrou-de-fichier.mjs';
|
|
71
71
|
import { dossierCommun, lireEntrees, retirerEntree } from './file-attente.mjs';
|
|
72
72
|
import { ouvrirCopie } from './rejeu.mjs';
|
|
73
|
-
import { A_REPASSER } from '../
|
|
74
|
-
import { AVANCEMENT, ecrireTache } from '../
|
|
73
|
+
import { A_REPASSER } from '../mesure/pression.mjs';
|
|
74
|
+
import { AVANCEMENT, ecrireTache } from '../mesure/avancement.mjs';
|
|
75
75
|
|
|
76
76
|
const ESSAIS_PAR_BRANCHE = 5;
|
|
77
77
|
// The variable in which bd reads the author of a comment, and the queue's author.
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
// (`arbitrageTranche`: `### Verdict — tranché`, or a « ## Réponse du
|
|
19
19
|
// responsable » comment after it): `refusArbitrage`, the one rule of the label, which the
|
|
20
20
|
// circuit plays too at its launch and at each resumption (scripts/circuit.mjs);
|
|
21
|
-
// 2. the lots: the tests lot touches only what the testwriter writes (`
|
|
22
|
-
// and the shared test material), the code lot none of it;
|
|
21
|
+
// 2. the lots: the tests lot touches only what the testwriter writes (`estUnTest` of the module
|
|
22
|
+
// of the language: test files and the shared test material), the code lot none of it;
|
|
23
23
|
// 3. the main tree: every file of the lots is unmodified there; the ticket's copy is on its
|
|
24
24
|
// branch and carries the lot and nothing else: a modified or untracked file outside the lot
|
|
25
25
|
// refuses, named (what an ignored folder such as node_modules holds is not work);
|
|
@@ -33,14 +33,16 @@
|
|
|
33
33
|
// file and the manifests the lot leaves (`npm ci`, as the continuous integration runs it); an
|
|
34
34
|
// install that fails refuses the lot, « Les dépendances de la copie ne s'installent pas. »;
|
|
35
35
|
// then the references regenerate (below);
|
|
36
|
-
// 6. the tests:
|
|
36
|
+
// 6. the tests: the preparation the module of the language describes, when it describes one
|
|
37
|
+
// (`preparer`, cargo's `cargo fetch --locked`), then `npm run verifier` in the copy, one
|
|
38
|
+
// command (TypeScript's, by Turborepo: the build, then the
|
|
37
39
|
// guards, the frame's and the project's own (its root script `gardes`), and every test of the
|
|
38
40
|
// day beside each other, each task replayed from the cache of the
|
|
39
41
|
// main tree when its inputs are unchanged). Green is required: main stays green, and nothing is compared with a base. A test
|
|
40
42
|
// known red is put in quarantine in the test itself (`it.skip` or `it.fails`, with its
|
|
41
43
|
// ticket), as a mature continuous integration does; the integration admits none. A
|
|
42
44
|
// `npm run verifier` « à repasser » (75: a failure of duration under load, which found no rest
|
|
43
|
-
// in its bound, scripts/verifier.mjs) is neither green nor red: the run stops there, exit 75,
|
|
45
|
+
// in its bound, scripts/langages/typescript/verifier.mjs) is neither green nor red: the run stops there, exit 75,
|
|
44
46
|
// nothing committed and nothing refused, the lot where it was, for the same command again;
|
|
45
47
|
// any other code than 0 refuses;
|
|
46
48
|
// 7. the commit in the copy, its hooks included, under GRILLHOUSE_INTEGRATION=1: a pre-commit
|
|
@@ -81,14 +83,14 @@ import { spawnSync } from 'node:child_process';
|
|
|
81
83
|
import { existsSync, readFileSync } from 'node:fs';
|
|
82
84
|
import path from 'node:path';
|
|
83
85
|
import { pathToFileURL } from 'node:url';
|
|
84
|
-
import { arbitrageTranche, estArbitrage } from '../
|
|
85
|
-
import {
|
|
86
|
+
import { arbitrageTranche, estArbitrage } from '../arbitrages.mjs';
|
|
87
|
+
import { langageDe } from '../langages.mjs';
|
|
86
88
|
import { lacherVerrou, prendreVerrou } from '../verrou-de-fichier.mjs';
|
|
87
89
|
import { dossierCommun, inscrireEntree } from './file-attente.mjs';
|
|
88
90
|
import { ouvrirCopie, RETIRER_COPIE } from './rejeu.mjs';
|
|
89
91
|
import { verdictDe } from './verdict.mjs';
|
|
90
|
-
import { A_REPASSER } from '../
|
|
91
|
-
import { ouvrirBase } from '../
|
|
92
|
+
import { A_REPASSER } from '../mesure/pression.mjs';
|
|
93
|
+
import { ouvrirBase } from '../mesure/base-de-passe.mjs';
|
|
92
94
|
|
|
93
95
|
// A file name as git writes it in a patch: a name with a character outside ASCII, a quote, a
|
|
94
96
|
// backslash or a control character comes between quotes with C escapes (`\303\251` for `é`).
|
|
@@ -159,7 +161,8 @@ export function refusArbitrage(ticket, comments) {
|
|
|
159
161
|
// The refusal for the files of the lots, or null. The files are relative to the repository root
|
|
160
162
|
// <racine>; the tests lot holds only what the testwriter writes, the code lot none of it.
|
|
161
163
|
export function refusLots(tests, code, racine) {
|
|
162
|
-
const
|
|
164
|
+
const langage = langageDe(racine);
|
|
165
|
+
const testwriter = f => langage.estUnTest(f, racine) !== null;
|
|
163
166
|
const horsTests = tests.filter(f => !testwriter(f));
|
|
164
167
|
if (horsTests.length) return `Le lot de tests touche du code : ${horsTests.join(', ')}.`;
|
|
165
168
|
const duTestwriter = code.filter(testwriter);
|
|
@@ -305,7 +308,7 @@ function main(argv) {
|
|
|
305
308
|
prendreVerrou(verrou, { attendre: true });
|
|
306
309
|
const debut = Date.now();
|
|
307
310
|
// The working directory of the integration: a base of its own, removed at its end, swept by the
|
|
308
|
-
// next one to open a base when the integration is killed (../
|
|
311
|
+
// next one to open a base when the integration is killed (../mesure/base-de-passe.mjs).
|
|
309
312
|
const base = ouvrirBase('integration');
|
|
310
313
|
const tmp = base.dossier;
|
|
311
314
|
try {
|
|
@@ -22,11 +22,14 @@
|
|
|
22
22
|
// lot that changes the lock file or a manifest is installed as the continuous integration
|
|
23
23
|
// installs it (`npm ci` refuses a lock file in disagreement with its manifest). The tests run on
|
|
24
24
|
// dependencies in agreement, and they neither read the key nor install.
|
|
25
|
-
// - `tester` plays
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
25
|
+
// - `tester` plays the commands of the verification in the copy (`commandesDeVerification`): the
|
|
26
|
+
// preparation the module of its language describes (`preparer` of its `commandes`, cargo's
|
|
27
|
+
// `cargo fetch --locked`), as a CI fetches the dependencies of a job before its tests, then
|
|
28
|
+
// `npm run verifier`, the command of the module (TypeScript's builds the project with Turborepo,
|
|
29
|
+
// then plays its guards and its tests beside each other, each task kept in the cache of the main
|
|
30
|
+
// tree, shared by every copy). It gives the result of the first command that is not green, else
|
|
31
|
+
// of the last: green (status 0), « à repasser » (75) or red (any other), its output written as it
|
|
32
|
+
// comes.
|
|
30
33
|
// - Every command of the project run in the copy (`lancer`: the install, the tests) leaves the
|
|
31
34
|
// index of its copy up to date, green or red: the consumers that apply a lot with `--index` (the
|
|
32
35
|
// integration, the queue) read an index that matches the files the command touched, and none
|
|
@@ -36,6 +39,7 @@ import { createHash } from 'node:crypto';
|
|
|
36
39
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
37
40
|
import path from 'node:path';
|
|
38
41
|
import { fileURLToPath } from 'node:url';
|
|
42
|
+
import { langageDe } from '../langages.mjs';
|
|
39
43
|
|
|
40
44
|
const SOUS_MODULES = fileURLToPath(new URL('../sous-modules.sh', import.meta.url));
|
|
41
45
|
export const RETIRER_COPIE = fileURLToPath(new URL('../retirer-copie.sh', import.meta.url));
|
|
@@ -59,6 +63,21 @@ function empreinteDesDependances(copie, verrou, dansCopie) {
|
|
|
59
63
|
return h.digest('hex');
|
|
60
64
|
}
|
|
61
65
|
|
|
66
|
+
/**
|
|
67
|
+
* The commands of the verification of the copy <copie>, in order, each `[commande, args]`: the
|
|
68
|
+
* preparation the module of its language describes, when it describes one, then `npm run
|
|
69
|
+
* verifier`.
|
|
70
|
+
* @param {string} copie the root of the copy
|
|
71
|
+
* @returns {[string, string[]][]}
|
|
72
|
+
*/
|
|
73
|
+
export function commandesDeVerification(copie) {
|
|
74
|
+
const preparer = langageDe(copie).commandes(copie).preparer;
|
|
75
|
+
return [
|
|
76
|
+
...(preparer ? [[process.execPath, [preparer.script, ...preparer.args]]] : []),
|
|
77
|
+
['npm', ['run', 'verifier']],
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
|
|
62
81
|
// The copy <copie> ready on <ref>, or `{ refus }`. `dire` writes a progress line. Returns the
|
|
63
82
|
// copy's tools: `dansCopie` (git in the copy), `monter` (the command line of a mounted command),
|
|
64
83
|
// `installer`, `tester`, and `tete`, the commit the copy was made ready on.
|
|
@@ -133,7 +152,17 @@ export function ouvrirCopie({ racine, copie, ref, dire }) {
|
|
|
133
152
|
if (refusOuverture) return { refus: refusOuverture };
|
|
134
153
|
dire(`✓ copie propre sur ${tete.slice(0, 7)}`);
|
|
135
154
|
|
|
136
|
-
// The checks of the copy:
|
|
137
|
-
|
|
155
|
+
// The checks of the copy: its preparation, then its verification; the first that is not green
|
|
156
|
+
// ends them.
|
|
157
|
+
const tester = () => {
|
|
158
|
+
let r;
|
|
159
|
+
for (const [commande, args] of commandesDeVerification(copie)) {
|
|
160
|
+
r = lancer(commande, args);
|
|
161
|
+
if (r.status !== 0) {
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return r;
|
|
166
|
+
};
|
|
138
167
|
return { dansCopie, monter, installer: accorder, tester, tete };
|
|
139
168
|
}
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
// The join of the languages: what the core asks of a module of language (docs/INTERFACE.md, « La
|
|
2
|
+
// jointure des langages »), the types of scripts/services-du-noyau.mjs (the join of scripts/langages.mjs and
|
|
3
|
+
// the services of the core to a module) and of scripts/conformite.mjs as the entries
|
|
4
|
+
// `@roomi-fields/grillhouse/jointure` and `@roomi-fields/grillhouse/conformite` publish them.
|
|
5
|
+
|
|
6
|
+
/** A component of the project: its folder (absolute), its name (the folder's), its package name. */
|
|
7
|
+
export interface Composant {
|
|
8
|
+
dossier: string;
|
|
9
|
+
nom: string;
|
|
10
|
+
paquet: string | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** A command a module describes: the absolute path of a Node script, and its arguments. */
|
|
14
|
+
export interface Commande {
|
|
15
|
+
script: string;
|
|
16
|
+
args: string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** A task of a run, as its runner reports it; `code` null for a task that did not run, `tests`
|
|
20
|
+
* true for the task that plays the tests of its component. */
|
|
21
|
+
export interface TacheJouee {
|
|
22
|
+
tache: string;
|
|
23
|
+
paquet: string;
|
|
24
|
+
dossier: string;
|
|
25
|
+
script: string;
|
|
26
|
+
tests: boolean;
|
|
27
|
+
code: number | null;
|
|
28
|
+
cache: string | null;
|
|
29
|
+
journal: string | null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A test file of a run, its absolute path, and each test of it. */
|
|
33
|
+
export interface RapportDeTest {
|
|
34
|
+
fichier: string;
|
|
35
|
+
etat: string;
|
|
36
|
+
message: string;
|
|
37
|
+
tests: { titre: string; nom: string; etat: string; message: string }[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A finding of a guard, as scripts/resultats.mjs reads it in SARIF. */
|
|
41
|
+
export interface Constat {
|
|
42
|
+
message: string;
|
|
43
|
+
garde?: string;
|
|
44
|
+
regle?: string | null;
|
|
45
|
+
fichier?: string | null;
|
|
46
|
+
ligne?: number | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** A file the module generates: what the circuit regenerates and judges (4.2 of the circuit). */
|
|
50
|
+
export interface FichierEngendre {
|
|
51
|
+
nom: string;
|
|
52
|
+
/** The command that writes it, a line of the shell. */
|
|
53
|
+
commande: string;
|
|
54
|
+
/** The patterns of its files, from the root. */
|
|
55
|
+
fichiers: string[];
|
|
56
|
+
/** The files of another generated file it reads. */
|
|
57
|
+
lit: string[];
|
|
58
|
+
/** The names its findings carry (their guard or their rule). */
|
|
59
|
+
gardes: string[];
|
|
60
|
+
/** The files of `fichiers` its command writes in full. */
|
|
61
|
+
entiers: string[];
|
|
62
|
+
/** The findings of its check on the repository at `racine`: none when it is up to date. */
|
|
63
|
+
verifier(racine: string): Constat[];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** What the testwriter writes in a file: a test the runner plays (`joue`), a test file or a file of
|
|
67
|
+
* a folder of tests (`test`), a file of the shared test material (`matiere`); null for a file it
|
|
68
|
+
* does not write. */
|
|
69
|
+
export type ClasseDeTest = { joue: boolean; test: boolean; matiere: boolean } | null;
|
|
70
|
+
|
|
71
|
+
/** The readers, by the code, of the elements a ticket names (composants-affectes). */
|
|
72
|
+
export interface Lecteurs {
|
|
73
|
+
elements: {
|
|
74
|
+
nom: string;
|
|
75
|
+
fournisseur: Composant;
|
|
76
|
+
lecteurs: { composant: Composant; par: string[] }[];
|
|
77
|
+
}[];
|
|
78
|
+
sansFournisseur: string[];
|
|
79
|
+
types: {
|
|
80
|
+
etat: string;
|
|
81
|
+
raison: string | null;
|
|
82
|
+
elements: {
|
|
83
|
+
nom: string;
|
|
84
|
+
declarations: { composant: Composant; publie: boolean }[];
|
|
85
|
+
lecteurs: Map<Composant, Set<string>>;
|
|
86
|
+
}[];
|
|
87
|
+
};
|
|
88
|
+
lit: Map<Composant, Set<Composant>>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The elements a lot adds, changes or removes between two commits, each with its place. */
|
|
92
|
+
export interface ElementsDuLot {
|
|
93
|
+
etat: 'fait' | 'impossible';
|
|
94
|
+
raison: string | null;
|
|
95
|
+
elements: {
|
|
96
|
+
id: string;
|
|
97
|
+
nom: string;
|
|
98
|
+
genre: string;
|
|
99
|
+
statut: string;
|
|
100
|
+
paquet: string | null;
|
|
101
|
+
fichier: string;
|
|
102
|
+
ligne: number;
|
|
103
|
+
exporte: boolean;
|
|
104
|
+
}[];
|
|
105
|
+
/** The changed sources the module reads no element of: the reviewer surveys them himself. */
|
|
106
|
+
horsDuService: string[];
|
|
107
|
+
/** Every file the lot changes, a source or not. */
|
|
108
|
+
fichiers: string[];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A migration of a project from one version of the frame to the next (scripts/migrations.mjs). */
|
|
112
|
+
export interface Migration {
|
|
113
|
+
version: string;
|
|
114
|
+
nom: string;
|
|
115
|
+
migrer(projet: string): (string | { aFaire: string })[];
|
|
116
|
+
restes?(projet: string): string[];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** A generator of the frame the update runs in a project, by the project's command
|
|
120
|
+
* (`grillhouse <commande> <args>`). */
|
|
121
|
+
export interface Generateur {
|
|
122
|
+
commande: string;
|
|
123
|
+
args: string[];
|
|
124
|
+
/** The file it writes, from the root: it runs where the project holds that file (every one for a
|
|
125
|
+
* project `grillhouse init` creates); null, it runs in every project whose package.json declares
|
|
126
|
+
* `workspaces`. */
|
|
127
|
+
sortie: string | null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** What the module brings to the update of a project (`grillhouse maj`), as each plugin of Nx
|
|
131
|
+
* brings its `init` generator. */
|
|
132
|
+
export interface MiseAJour {
|
|
133
|
+
/** The directory of the frame's template of a project of the language, from the frame's files:
|
|
134
|
+
* its package.json gives the frame's scripts and the versions of the tools. */
|
|
135
|
+
gabarit: string;
|
|
136
|
+
/** Brings the project at `projet` to the form the module asks: its root package.json `p`, which
|
|
137
|
+
* the core writes after, and its other files, from the frame's files at `source` (its template's
|
|
138
|
+
* package.json `modele`; `version`, the frame's). Its share of the update: `bilan`, the changes by
|
|
139
|
+
* name, each null when nothing changes; `lignes`, the lines of the report; `installer`, whether
|
|
140
|
+
* `npm install` comes before the verification; `sansVerifier`, the line that says why the project
|
|
141
|
+
* has no script `verifier`, null for the core's. */
|
|
142
|
+
appliquer(
|
|
143
|
+
projet: string,
|
|
144
|
+
o: {
|
|
145
|
+
p: Record<string, unknown>;
|
|
146
|
+
modele: Record<string, unknown>;
|
|
147
|
+
source: string;
|
|
148
|
+
version: string;
|
|
149
|
+
}
|
|
150
|
+
): {
|
|
151
|
+
bilan: Record<string, unknown>;
|
|
152
|
+
lignes: string[];
|
|
153
|
+
installer: boolean;
|
|
154
|
+
sansVerifier: string | null;
|
|
155
|
+
};
|
|
156
|
+
/** The generators the update runs after the package.json. */
|
|
157
|
+
generateurs: Generateur[];
|
|
158
|
+
/** How the binaries of the language (`binaires`) are installed, null without any: `liste`, the
|
|
159
|
+
* command that writes on its standard output the binaries installed, `{ <nom>: <version> }` in
|
|
160
|
+
* JSON; `installer`, the command that installs one at its version. The core runs them, each by
|
|
161
|
+
* Node, and reports the error stream of a failure. */
|
|
162
|
+
installation: {
|
|
163
|
+
liste: Commande;
|
|
164
|
+
installer(nom: string, version: string): Commande;
|
|
165
|
+
} | null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** A module of language, the default export of `scripts/langages/<nom>/index.mjs`. */
|
|
169
|
+
export interface Langage {
|
|
170
|
+
nom: string;
|
|
171
|
+
/** Whether the repository at `racine` holds code of this language, which the update declares. */
|
|
172
|
+
trouve(racine: string): boolean;
|
|
173
|
+
/** What `trouve` looks for, in words: the refusal of the update names it. */
|
|
174
|
+
signe: string;
|
|
175
|
+
/** The tools a project of this language installs, optional peers of the package. */
|
|
176
|
+
outils: string[];
|
|
177
|
+
/** The binaries a project of this language installs on the machine, each at its exact version:
|
|
178
|
+
* the update installs each one missing or at another version (`miseAJour.installation`). */
|
|
179
|
+
binaires: Record<string, string>;
|
|
180
|
+
/** The directories the language's tools write in a project, by name: the source files leave them
|
|
181
|
+
* out, and the update writes them in the project's `.gitignore`. */
|
|
182
|
+
ignorer: string[];
|
|
183
|
+
/** Where a run of the language's tools writes, which the envelope opens to a session. */
|
|
184
|
+
sorties: {
|
|
185
|
+
/** Opened in writing: from the root of the copy, from the home (`~/…`), or from the main
|
|
186
|
+
* tree (`//…`), a store shared by every copy; each created before the session, a directory
|
|
187
|
+
* when it ends with `/`, else an empty file. */
|
|
188
|
+
ecrites: string[];
|
|
189
|
+
/** Proper to the session: from the root of the copy and of each component of the shared test
|
|
190
|
+
* material, where the session does not write them, an empty directory. */
|
|
191
|
+
propres: string[];
|
|
192
|
+
/** Read by the tools, from the home (`~/…`) or the main tree (`//…`), mounted read-only
|
|
193
|
+
* before what is written inside them; one absent is not mounted. */
|
|
194
|
+
lues: string[];
|
|
195
|
+
};
|
|
196
|
+
/** The rules of Claude Code that refuse a role that writes the test tool run directly (charter,
|
|
197
|
+
* « Aucun agent ne lance l'outil de test directement »). */
|
|
198
|
+
droits: string[];
|
|
199
|
+
composants(racine: string): Composant[];
|
|
200
|
+
composantDe(racine: string, fichier: string): Composant | null;
|
|
201
|
+
matieres(racine: string): Composant[];
|
|
202
|
+
/** Whether the component plays tests: the runner of the language has tests to play in it. */
|
|
203
|
+
joueDesTests(racine: string, composant: Composant): boolean;
|
|
204
|
+
lecteurs(
|
|
205
|
+
racine: string,
|
|
206
|
+
o: { composants: Composant[]; noms: string[]; texte: string; nommes: Composant[] }
|
|
207
|
+
): Lecteurs;
|
|
208
|
+
touches(
|
|
209
|
+
racine: string,
|
|
210
|
+
o: { depuis: string }
|
|
211
|
+
): { touches: Composant[]; dependants: Composant[]; horsGraphe: string[] };
|
|
212
|
+
elementsDuLot(racine: string, o: { avant: string; apres: string }): ElementsDuLot;
|
|
213
|
+
commandes(
|
|
214
|
+
racine: string
|
|
215
|
+
): { tester: Commande; verifier: Commande; typer: Commande } & Record<string, Commande>;
|
|
216
|
+
verdict(dossier: string): { rapports: RapportDeTest[]; taches: TacheJouee[] };
|
|
217
|
+
estUnTest(chemin: string, racine: string): ClasseDeTest;
|
|
218
|
+
fichiersEngendres(racine: string): FichierEngendre[];
|
|
219
|
+
gardes(racine: string): string[][];
|
|
220
|
+
migrations: Migration[];
|
|
221
|
+
miseAJour: MiseAJour;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** The frame's languages, each its module. */
|
|
225
|
+
export const LANGAGES: Record<string, string>;
|
|
226
|
+
/** The languages the project at `racine` declares (`grillhouse.langages`), empty for none. */
|
|
227
|
+
export function langagesDeclares(racine: string): string[];
|
|
228
|
+
/** The languages of the frame whose module finds its code in the repository at `racine`. */
|
|
229
|
+
export function langagesTrouves(racine: string): string[];
|
|
230
|
+
/** The module of the language that serves the project at `racine`; throws when it declares none. */
|
|
231
|
+
export function langageDe(racine: string): Langage;
|
|
232
|
+
|
|
233
|
+
// The services of the core to a module of language, which imports of the core its published
|
|
234
|
+
// entries alone (.dependency-cruiser.projet.cjs of the frame's repository).
|
|
235
|
+
|
|
236
|
+
/** The plan of the envelope of an agent, its packages (scripts/enveloppe/paquets-du-plan.mjs). */
|
|
237
|
+
export function paquetsDeLEnveloppe(env?: NodeJS.ProcessEnv): string[] | null;
|
|
238
|
+
/** The packages of a plan written by `ecrireLaListe`. */
|
|
239
|
+
export function lireLaListe(texte: string): string[];
|
|
240
|
+
/** The variable naming the directory of the progress of a pass (scripts/mesure/avancement.mjs). */
|
|
241
|
+
export const AVANCEMENT: string;
|
|
242
|
+
/** Writes the progress of the task `nom` in the directory `dossier`. */
|
|
243
|
+
export function ecrireTache(
|
|
244
|
+
dossier: string,
|
|
245
|
+
nom: string,
|
|
246
|
+
o: { hash?: string | null; faits: number; prevus: number }
|
|
247
|
+
): void;
|
|
248
|
+
/** Opens the progress of a pass (scripts/avancement.mjs): its directory. */
|
|
249
|
+
export function ouvrirAvancement(o: {
|
|
250
|
+
racine: string;
|
|
251
|
+
genre?: string | null;
|
|
252
|
+
dans?: string;
|
|
253
|
+
debut?: number;
|
|
254
|
+
}): string;
|
|
255
|
+
/** Writes the plan of the tasks of a pass in its progress. */
|
|
256
|
+
export function inscrireLePlan(dossier: string, o: { racine: string; taches: unknown[] }): void;
|
|
257
|
+
/** Keeps the total of a pass that ended, for the next one's measure. */
|
|
258
|
+
export function garderLeTotal(dossier: string, racine: string): void;
|
|
259
|
+
/** Writes the measure of a pass. */
|
|
260
|
+
export function ecrireLaMesure(o: {
|
|
261
|
+
env?: NodeJS.ProcessEnv;
|
|
262
|
+
depot: string;
|
|
263
|
+
commande: string;
|
|
264
|
+
dossier: string;
|
|
265
|
+
}): void;
|
|
266
|
+
/** Opens the base of a pass of the kind `genre` (scripts/mesure/base-de-passe.mjs). */
|
|
267
|
+
export function ouvrirBase(genre: string, o?: { dans?: string }): unknown;
|
|
268
|
+
/** The line of the guard of a pass of tests, what its tests left in their temporary directory
|
|
269
|
+
* named; null when they left nothing. */
|
|
270
|
+
export function ligneDesRestes(restes: string[]): string | null;
|
|
271
|
+
/** Runs `retirer` when the process is interrupted, then lets the signal end it; the removal of
|
|
272
|
+
* the handlers. */
|
|
273
|
+
export function retirerALInterruption(retirer: () => void): () => void;
|
|
274
|
+
/** The pressure of the processor above which a pass is « à repasser » (scripts/mesure/pression.mjs). */
|
|
275
|
+
export const SEUIL_PRESSION: number;
|
|
276
|
+
/** The exit code of a pass « à repasser ». */
|
|
277
|
+
export const A_REPASSER: number;
|
|
278
|
+
/** The longest wait for the rest of the machine, in milliseconds. */
|
|
279
|
+
export const BORNE_ATTENTE_MS: number;
|
|
280
|
+
/** The pressure of the processor, in percent, or null when it cannot be read. */
|
|
281
|
+
export function lirePression(fichier?: string): number | null;
|
|
282
|
+
/** The pressure `p` as a line says it. */
|
|
283
|
+
export function ecrirePression(p: number | null): string;
|
|
284
|
+
/** Waits for the rest of the machine, within its bound. */
|
|
285
|
+
export function attendreLeRepos(o?: Record<string, unknown>): unknown;
|
|
286
|
+
/** The variable naming the files changed since the last green (scripts/dernier-vert.mjs). */
|
|
287
|
+
export const CHANGEMENTS: string;
|
|
288
|
+
/** The variable naming the commit of the last green a run measures itself from. */
|
|
289
|
+
export const DEPUIS_LE_VERT: string;
|
|
290
|
+
/** Keeps the green of a pass, which the next one measures itself from. */
|
|
291
|
+
export function garderLeVert(etat: unknown): void;
|
|
292
|
+
/** The measure of the repository at `racine` against its last green. */
|
|
293
|
+
export function mesure(racine: string, o?: { tout?: boolean; dans?: string }): unknown;
|
|
294
|
+
/** The wait for the lock of the machine, ended without it (scripts/verrou-de-machine.mjs). */
|
|
295
|
+
export class AttenteDeLaMachine extends Error {}
|
|
296
|
+
/** Runs `faire` under the lock of the machine. */
|
|
297
|
+
export function avecLaMachine(...args: unknown[]): unknown;
|
|
298
|
+
/** The source files of the project at `racine` under `dossier`, as paths from `racine`, what the
|
|
299
|
+
* tools of its language write left out (scripts/sources.mjs). */
|
|
300
|
+
export function sources(racine: string, dossier?: string): string[];
|
|
301
|
+
/** True when the text of a ticket's comment is an arbitrage (scripts/arbitrages.mjs). */
|
|
302
|
+
export function estArbitrage(text: string | null | undefined): boolean;
|
|
303
|
+
/** True when the arbitrage `a` of `comments` is settled. */
|
|
304
|
+
export function arbitrageTranche(comments: { text: string }[], a: { text: string }): boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The installation of the binaries of the module cargo (./binaires.json), the commands its share
|
|
3
|
+
// of the update describes (`miseAJour.installation`, scripts/jointure.d.ts), which the core runs.
|
|
4
|
+
//
|
|
5
|
+
// node binaires.mjs liste the binaries installed, JSON on the standard output
|
|
6
|
+
// node binaires.mjs installer <nom>@<version> installs one binary at its version
|
|
7
|
+
//
|
|
8
|
+
// - `liste`: what `cargo install --list` lists, `{ <nom>: <version> }` (its lines `<nom> v<version>:`,
|
|
9
|
+
// which cargo-binstall's installations also write). Cargo absent or failing: a line on the error
|
|
10
|
+
// stream, named, and the code 1.
|
|
11
|
+
// - `installer`: `cargo binstall --no-confirm --locked <nom>@<version>`, its output this process's
|
|
12
|
+
// error stream, its code this process's; a failure names on the error stream the command to type
|
|
13
|
+
// and how cargo-binstall installs itself.
|
|
14
|
+
import { spawnSync } from 'node:child_process';
|
|
15
|
+
import { pathToFileURL } from 'node:url';
|
|
16
|
+
|
|
17
|
+
/** The binaries cargo lists as installed: `{ <nom>: <version> }`; throws, named, on a failure. */
|
|
18
|
+
export function installes() {
|
|
19
|
+
const r = spawnSync('cargo', ['install', '--list'], { encoding: 'utf8' });
|
|
20
|
+
if (r.error || r.status !== 0) {
|
|
21
|
+
const cause = r.error ? r.error.message : (r.stderr ?? '').trim() || `code ${r.status}`;
|
|
22
|
+
throw new Error(
|
|
23
|
+
`⛔ \`cargo install --list\` échoue (${cause}) ; installe Rust (rustup), puis relance \`npx grillhouse maj\`.`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return Object.fromEntries(
|
|
27
|
+
[...r.stdout.matchAll(/^(\S+) v(\S+):/gm)].map(([, nom, version]) => [nom, version])
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Installs <cible> (`<nom>@<version>`): the exit code of cargo binstall. */
|
|
32
|
+
export function installer(cible) {
|
|
33
|
+
const args = ['binstall', '--no-confirm', '--locked', cible];
|
|
34
|
+
const r = spawnSync('cargo', args, { stdio: ['ignore', 2, 2] });
|
|
35
|
+
const code = r.error ? 127 : (r.status ?? 1);
|
|
36
|
+
if (code !== 0) {
|
|
37
|
+
const cause = r.error ? r.error.message : `code ${code}`;
|
|
38
|
+
process.stderr.write(
|
|
39
|
+
`⛔ \`cargo ${args.join(' ')}\` échoue (${cause}) ; lance-la (cargo-binstall s'installe par \`cargo install cargo-binstall\`).\n`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return code;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
46
|
+
const [nom, cible] = process.argv.slice(2);
|
|
47
|
+
if (nom === 'liste') {
|
|
48
|
+
try {
|
|
49
|
+
process.stdout.write(`${JSON.stringify(installes())}\n`);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
process.stderr.write(`${e.message}\n`);
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
}
|
|
54
|
+
} else if (nom === 'installer' && cible) {
|
|
55
|
+
process.exitCode = installer(cible);
|
|
56
|
+
} else {
|
|
57
|
+
process.stderr.write('usage: binaires.mjs liste | installer <nom>@<version>\n');
|
|
58
|
+
process.exitCode = 2;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The guard clippy of the module cargo: the lints of clippy on every target of the workspace,
|
|
3
|
+
// each a finding the project's debt counts (../../dette.mjs), as the module typescript's guards.
|
|
4
|
+
//
|
|
5
|
+
// node clippy.mjs in the root of the workspace; 0 green, 1 a finding refused
|
|
6
|
+
//
|
|
7
|
+
// - It runs `cargo clippy --all-targets --message-format=json -- -D warnings`: every target, the
|
|
8
|
+
// tests of `tests/` included, which clippy reads only with `--all-targets`; every warning denied.
|
|
9
|
+
// - Each diagnostic of the compiler that carries a code is a finding: its file, the primary span's
|
|
10
|
+
// from the root, its line, its message the compiler's. A lint (`clippy::needless_return`, a lint
|
|
11
|
+
// of rustc such as `unused_variables`) is its rule, which the debt keys; an error of compilation
|
|
12
|
+
// (`E0308`) carries none: it refuses, named, never inscribed. A message without code
|
|
13
|
+
// (« aborting due to … ») and a line that is no diagnostic are not read. The same diagnostic
|
|
14
|
+
// found by two targets (the library and its tests) counts once, as cargo prints it once.
|
|
15
|
+
// - The findings are judged by the debt, keyed by file and lint (`GRILLHOUSE_DETTE=inscrire`
|
|
16
|
+
// writes them, a lint more refuses, a lint less is pruned), and written in SARIF under the
|
|
17
|
+
// results directory (../../resultats.mjs). Clippy red without any diagnostic (a manifest cargo
|
|
18
|
+
// cannot read, a missing tool) refuses, named, never inscribed.
|
|
19
|
+
import { spawnSync } from 'node:child_process';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
import { pathToFileURL } from 'node:url';
|
|
22
|
+
import { MODE, trancher } from '../../dette.mjs';
|
|
23
|
+
|
|
24
|
+
export const GARDE = 'clippy';
|
|
25
|
+
export const ARGS = ['clippy', '--all-targets', '--message-format=json', '--', '-D', 'warnings'];
|
|
26
|
+
|
|
27
|
+
// The code of an error of compilation, which is no lint.
|
|
28
|
+
const ERREUR = /^E\d{4}$/;
|
|
29
|
+
|
|
30
|
+
const lireLigne = l => {
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(l);
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The findings of the output <sortie> of `cargo clippy --message-format=json` in the workspace at
|
|
40
|
+
* <racine>, in their order: each `{ fichier, ligne, regle, message }`.
|
|
41
|
+
* @param {string} sortie the JSON lines cargo printed
|
|
42
|
+
* @param {string} racine the root of the workspace
|
|
43
|
+
*/
|
|
44
|
+
export function constatsDeClippy(sortie, racine) {
|
|
45
|
+
const vus = new Set();
|
|
46
|
+
const out = [];
|
|
47
|
+
for (const l of sortie.split('\n')) {
|
|
48
|
+
const m = lireLigne(l.trim());
|
|
49
|
+
const d = m?.reason === 'compiler-message' ? m.message : null;
|
|
50
|
+
if (!d?.code?.code) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const span = d.spans?.find(s => s.is_primary) ?? d.spans?.[0];
|
|
54
|
+
const fichier = span
|
|
55
|
+
? path.relative(racine, path.resolve(racine, span.file_name)).split(path.sep).join('/')
|
|
56
|
+
: undefined;
|
|
57
|
+
const c = {
|
|
58
|
+
...(fichier ? { fichier } : {}),
|
|
59
|
+
...(span ? { ligne: span.line_start } : {}),
|
|
60
|
+
...(ERREUR.test(d.code.code) ? {} : { regle: d.code.code }),
|
|
61
|
+
message: `${d.code.code} : ${d.message}`,
|
|
62
|
+
};
|
|
63
|
+
const cle = JSON.stringify([c.fichier, c.ligne, span?.column_start, c.message]);
|
|
64
|
+
if (vus.has(cle)) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
vus.add(cle);
|
|
68
|
+
out.push(c);
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Runs the guard in the workspace at <racine>: its exit code, its refusals printed.
|
|
75
|
+
* @param {string} racine the root of the workspace
|
|
76
|
+
* @param {{ env?: NodeJS.ProcessEnv }} [o] the environment (the results directory, the debt's mode)
|
|
77
|
+
*/
|
|
78
|
+
export function commande(racine, { env = process.env } = {}) {
|
|
79
|
+
const r = spawnSync('cargo', ARGS, {
|
|
80
|
+
cwd: racine,
|
|
81
|
+
env,
|
|
82
|
+
encoding: 'utf8',
|
|
83
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
84
|
+
});
|
|
85
|
+
const constats = r.error ? [] : constatsDeClippy(r.stdout ?? '', racine);
|
|
86
|
+
if (r.error || (r.status !== 0 && constats.length === 0)) {
|
|
87
|
+
const fin = r.error?.message ?? (r.stderr ?? '').trim().split('\n').at(-1) ?? '';
|
|
88
|
+
constats.push({ message: `cargo clippy rouge (code ${r.status ?? r.signal}) : ${fin}` });
|
|
89
|
+
}
|
|
90
|
+
const { refus, lignes } = trancher(racine, GARDE, constats, env[MODE] || undefined, env);
|
|
91
|
+
for (const c of refus) {
|
|
92
|
+
const lieu = c.fichier ? `${c.fichier}${c.ligne ? `:${c.ligne}` : ''} — ` : '';
|
|
93
|
+
process.stderr.write(`⛔ clippy : ${lieu}${c.message}\n`);
|
|
94
|
+
}
|
|
95
|
+
for (const l of lignes) {
|
|
96
|
+
process.stderr.write(`${l}\n`);
|
|
97
|
+
}
|
|
98
|
+
return refus.length ? 1 : 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
102
|
+
process.exitCode = commande(process.cwd());
|
|
103
|
+
}
|