@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.
Files changed (124) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/bin/grillhouse.mjs +40 -12
  3. package/cadre/templates/cargo/.config/nextest.toml +8 -0
  4. package/cadre/templates/cargo/deny.toml +36 -0
  5. package/cadre/templates/cargo/package.json +15 -0
  6. package/cadre/templates/cargo/rust-toolchain.toml +6 -0
  7. package/cadre/templates/projet/package.json +5 -1
  8. package/cadre/templates/turbo/paquets.json +1 -1
  9. package/cadre/templates/turbo/sans-paquets.json +1 -1
  10. package/charte.md +16 -0
  11. package/docs/ARCHITECTURE.md +157 -54
  12. package/docs/CADRE.md +47 -0
  13. package/docs/INTERFACE.md +168 -0
  14. package/package.json +62 -13
  15. package/scripts/arbitrages.mjs +23 -0
  16. package/scripts/avancement.mjs +15 -29
  17. package/scripts/circuit.mjs +89 -97
  18. package/scripts/commande-du-langage.mjs +56 -0
  19. package/scripts/composants-affectes.mjs +47 -170
  20. package/scripts/conformite.d.ts +27 -0
  21. package/scripts/conformite.mjs +226 -0
  22. package/scripts/demon.mjs +1 -1
  23. package/scripts/dernier-vert.mjs +11 -9
  24. package/scripts/droits.mjs +27 -21
  25. package/scripts/enveloppe/enveloppe.mjs +206 -64
  26. package/scripts/enveloppe/lancer.sh +20 -91
  27. package/scripts/enveloppe/paquets-du-plan.mjs +24 -2
  28. package/scripts/etapes.mjs +2 -2
  29. package/scripts/gardes-du-cadre.mjs +12 -18
  30. package/scripts/grillhouse-maj.mjs +246 -389
  31. package/scripts/init.mjs +2 -1
  32. package/scripts/integration/file.mjs +3 -3
  33. package/scripts/integration/integrer.mjs +13 -10
  34. package/scripts/integration/rejeu.mjs +36 -7
  35. package/scripts/jointure.d.ts +304 -0
  36. package/scripts/langages/cargo/binaires.json +4 -0
  37. package/scripts/langages/cargo/binaires.mjs +60 -0
  38. package/scripts/langages/cargo/clippy.mjs +103 -0
  39. package/scripts/langages/cargo/commandes.mjs +378 -0
  40. package/scripts/langages/cargo/composants.mjs +191 -0
  41. package/scripts/langages/cargo/elements-du-lot.mjs +139 -0
  42. package/scripts/langages/cargo/exemples.mjs +357 -0
  43. package/scripts/langages/cargo/frontieres.mjs +84 -0
  44. package/scripts/langages/cargo/index-interfaces.mjs +138 -0
  45. package/scripts/langages/cargo/index.mjs +115 -0
  46. package/scripts/langages/cargo/mise-a-jour.mjs +93 -0
  47. package/scripts/langages/cargo/nextest.toml +5 -0
  48. package/scripts/langages/cargo/touches.mjs +93 -0
  49. package/scripts/langages/cargo/verdict.mjs +85 -0
  50. package/scripts/langages/typescript/chemins-des-tests.mjs +68 -0
  51. package/scripts/{code-mort.mjs → langages/typescript/code-mort.mjs} +5 -5
  52. package/scripts/langages/typescript/composants.mjs +64 -0
  53. package/scripts/{consommateurs-arbitres.mjs → langages/typescript/consommateurs-arbitres.mjs} +6 -24
  54. package/scripts/{consommateurs.mjs → langages/typescript/consommateurs.mjs} +13 -71
  55. package/scripts/langages/typescript/construire.mjs +176 -0
  56. package/scripts/{elements-du-lot.mjs → langages/typescript/elements-du-lot.mjs} +2 -2
  57. package/scripts/langages/typescript/exemples.mjs +289 -0
  58. package/scripts/{frontieres.mjs → langages/typescript/frontieres.mjs} +3 -5
  59. package/scripts/{index-interfaces.mjs → langages/typescript/index-interfaces.mjs} +3 -3
  60. package/scripts/langages/typescript/index.mjs +335 -0
  61. package/scripts/{interfaces-contre-code.mjs → langages/typescript/interfaces-contre-code.mjs} +2 -2
  62. package/scripts/langages/typescript/lecteurs.mjs +179 -0
  63. package/scripts/{migrations → langages/typescript/migrations}/0.23.0-config-vitest.mjs +14 -29
  64. package/scripts/{migrations → langages/typescript/migrations}/0.24.4-noms-declares-inutilises.mjs +2 -2
  65. package/scripts/{migrations → langages/typescript/migrations}/0.24.6-lignes-mal-formees.mjs +2 -2
  66. package/scripts/{migrations → langages/typescript/migrations}/0.24.7-matiere-dans-les-tests.mjs +2 -2
  67. package/scripts/langages/typescript/migrations/0.25.0-chemins-des-tests.mjs +27 -0
  68. package/scripts/langages/typescript/migrations/0.25.0-tailles-des-tests.mjs +31 -0
  69. package/scripts/langages/typescript/mise-a-jour.mjs +320 -0
  70. package/scripts/{references-par-les-types.mjs → langages/typescript/references-par-les-types.mjs} +3 -3
  71. package/scripts/langages/typescript/regle-des-tests.mjs +39 -0
  72. package/scripts/{resumes.mjs → langages/typescript/resumes.mjs} +4 -4
  73. package/scripts/langages/typescript/script-des-tests.mjs +6 -0
  74. package/scripts/langages/typescript/tailles-des-tests.mjs +219 -0
  75. package/scripts/langages/typescript/tests-de-nuit.mjs +57 -0
  76. package/scripts/{tests.mjs → langages/typescript/tests.mjs} +41 -32
  77. package/scripts/{turbo-des-paquets.mjs → langages/typescript/turbo-des-paquets.mjs} +49 -23
  78. package/scripts/langages/typescript/verdict.mjs +105 -0
  79. package/scripts/{verifier.mjs → langages/typescript/verifier.mjs} +53 -34
  80. package/scripts/{vitest-config → langages/typescript/vitest-config}/avancement.reporter.mjs +10 -2
  81. package/scripts/{vitest-config → langages/typescript/vitest-config}/base.mjs +63 -9
  82. package/scripts/{vitest-config → langages/typescript/vitest-config}/changements.mjs +18 -11
  83. package/scripts/{vitest-config → langages/typescript/vitest-config}/cibles.mjs +7 -6
  84. package/scripts/{vitest-config → langages/typescript/vitest-config}/duree.reporter.mjs +6 -1
  85. package/scripts/langages/typescript/vitest-config/lances.mjs +473 -0
  86. package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.setup.mjs +1 -1
  87. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.mjs +5 -5
  88. package/scripts/{vitest-config → langages/typescript/vitest-config}/resultats.setup.mjs +4 -3
  89. package/scripts/{vitest.nuit.config.mjs → langages/typescript/vitest.nuit.config.mjs} +2 -2
  90. package/scripts/langages.mjs +85 -0
  91. package/scripts/{vitest-config → mesure}/avancement.mjs +4 -13
  92. package/scripts/{vitest-config → mesure}/base-de-passe.mjs +70 -33
  93. package/scripts/{vitest-config → mesure}/pression.mjs +5 -6
  94. package/scripts/migrations/0.23.2-copies-du-cadre.mjs +29 -6
  95. package/scripts/migrations/0.24.0-circuit-simplifie.mjs +13 -6
  96. package/scripts/migrations/0.25.0-script-des-tests.mjs +92 -0
  97. package/scripts/migrations.mjs +17 -13
  98. package/scripts/nuit.sh +59 -63
  99. package/scripts/paquets.d.ts +5 -0
  100. package/scripts/paquets.mjs +24 -2
  101. package/scripts/resultats.mjs +8 -82
  102. package/scripts/services-du-noyau.mjs +30 -0
  103. package/scripts/session-start.sh +17 -9
  104. package/scripts/sources.mjs +35 -13
  105. package/scripts/sous-commandes.mjs +57 -17
  106. package/scripts/superviseur.mjs +1 -1
  107. package/scripts/tableau.mjs +1 -1
  108. package/scripts/un-commit-par-ticket.mjs +48 -14
  109. package/scripts/verrou-de-fichier.mjs +1 -1
  110. package/scripts/verrou-de-machine.mjs +4 -4
  111. package/scripts/verrous/verrou.mjs +28 -37
  112. package/skills/developpeur/SKILL.md +2 -2
  113. package/skills/explorateur/SKILL.md +13 -5
  114. package/skills/grill/SKILL.md +2 -2
  115. package/skills/pitmaster/references/cadre.md +1 -1
  116. package/skills/pitmaster/references/consigne-agent.md +10 -3
  117. package/skills/redacteur/references/documents-d-un-composant.md +4 -4
  118. package/skills/relecteur/SKILL.md +4 -1
  119. package/skills/testwriter/SKILL.md +20 -6
  120. /package/scripts/{consommateurs.d.ts → langages/typescript/consommateurs.d.ts} +0 -0
  121. /package/scripts/{vitest-config → langages/typescript/vitest-config}/base.d.ts +0 -0
  122. /package/scripts/{vitest-config → langages/typescript/vitest-config}/machine.setup.mjs +0 -0
  123. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.d.ts +0 -0
  124. /package/scripts/{vitest-config → langages/typescript/vitest-config}/mesure.mjs +0 -0
@@ -0,0 +1,139 @@
1
+ // The elements of a lot of a workspace of cargo, the demand `elementsDuLot` of the join
2
+ // (scripts/jointure.d.ts): one element per crate the lot adds, changes or removes, as a review of
3
+ // a Cargo workspace reads a change crate by crate.
4
+ //
5
+ // - The lot is the difference between two commits (`git diff --name-status -z --no-renames`).
6
+ // - The crates of a commit: each Cargo.toml it holds whose section `[package]` names a crate,
7
+ // read in git (`git ls-tree`, `git show`), so that a removed crate is read where it was; the
8
+ // folder of the manifest is the crate's.
9
+ // - A crate is new when its manifest is in the commit after alone, removed when it is in the
10
+ // commit before alone, and changed when a file the lot changes lies in its folder, the longest
11
+ // one; its element `<dossier>/Cargo.toml#<crate>`, kind `crate`, its manifest's line of its name.
12
+ // - The module reads no element of a Rust source: each `.rs` the lot changes is named in
13
+ // `horsDuService`, and the reviewer surveys its items himself (`service` says why).
14
+ // - Every file the lot changes is named in `fichiers`.
15
+ import { spawnSync } from 'node:child_process';
16
+ import path from 'node:path';
17
+
18
+ const MANIFESTE = 'Cargo.toml';
19
+ const SERVICE = 'le module cargo relève les crates du lot, pas les éléments de ses sources Rust';
20
+
21
+ const git = (racine, ...a) =>
22
+ spawnSync('git', ['-C', racine, ...a], { encoding: 'utf8', maxBuffer: 256 * 1024 * 1024 });
23
+
24
+ // The name of the crate the manifest <texte> declares, and the line of it; null without
25
+ // `[package]`.
26
+ function nomDuCrate(texte) {
27
+ let section = null;
28
+ for (const [i, l] of texte.split('\n').entries()) {
29
+ const s = /^\s*\[([^\]]+)\]\s*(?:#.*)?$/.exec(l);
30
+ if (s) {
31
+ section = s[1].trim();
32
+ }
33
+ const n = /^\s*name\s*=\s*"([^"]+)"/.exec(l);
34
+ if (section === 'package' && n) {
35
+ return { nom: n[1], ligne: i + 1 };
36
+ }
37
+ }
38
+ return null;
39
+ }
40
+
41
+ // The crates of the commit <rev> of <racine>: Map dossier (from the root, '' for it) → `{ nom,
42
+ // ligne, fichier }`.
43
+ function cratesA(racine, rev) {
44
+ const r = git(racine, 'ls-tree', '-r', '-z', '--name-only', rev);
45
+ if (r.status !== 0) {
46
+ throw new Error(`git ls-tree ${rev} : ${r.stderr.trim()}`);
47
+ }
48
+ const out = new Map();
49
+ for (const f of r.stdout.split('\0').filter(Boolean)) {
50
+ if (path.posix.basename(f) !== MANIFESTE) {
51
+ continue;
52
+ }
53
+ const t = git(racine, 'show', `${rev}:${f}`);
54
+ const c = t.status === 0 ? nomDuCrate(t.stdout) : null;
55
+ const dossier = path.posix.dirname(f);
56
+ if (c) {
57
+ out.set(dossier === '.' ? '' : dossier, { ...c, fichier: f });
58
+ }
59
+ }
60
+ return out;
61
+ }
62
+
63
+ // The folder of <crates> that holds <fichier>, the longest; undefined for none.
64
+ const dossierDe = (crates, fichier) =>
65
+ [...crates.keys()]
66
+ .filter(d => d === '' || fichier.startsWith(`${d}/`))
67
+ .sort((a, b) => b.length - a.length)[0];
68
+
69
+ /**
70
+ * The elements the lot of <racine> adds, changes or removes between <avant> and <apres>.
71
+ * @param {string} racine the root of the workspace
72
+ * @param {{ avant: string, apres: string }} o the two commits
73
+ */
74
+ export function elementsDuLot(racine, { avant, apres }) {
75
+ try {
76
+ const r = git(racine, 'diff', '--name-status', '-z', '--no-renames', avant, apres);
77
+ if (r.status !== 0) {
78
+ throw new Error(`git diff : ${r.stderr.trim()}`);
79
+ }
80
+ const morceaux = r.stdout.split('\0').filter(Boolean);
81
+ const changes = [];
82
+ for (let i = 0; i + 1 < morceaux.length; i += 2) {
83
+ changes.push({ statut: morceaux[i], fichier: morceaux[i + 1] });
84
+ }
85
+ const crAvant = cratesA(racine, avant);
86
+ const crApres = cratesA(racine, apres);
87
+ const elements = [];
88
+ const vus = new Set();
89
+ const element = (dossier, c, statut) => {
90
+ if (vus.has(dossier)) {
91
+ return;
92
+ }
93
+ vus.add(dossier);
94
+ elements.push({
95
+ id: `${c.fichier}#${c.nom}`,
96
+ nom: c.nom,
97
+ genre: 'crate',
98
+ statut,
99
+ paquet: c.nom,
100
+ fichier: c.fichier,
101
+ ligne: c.ligne,
102
+ exporte: true,
103
+ });
104
+ };
105
+ for (const { fichier } of changes) {
106
+ const da = dossierDe(crApres, fichier);
107
+ const dv = dossierDe(crAvant, fichier);
108
+ if (da !== undefined && !crAvant.has(da)) {
109
+ element(da, crApres.get(da), 'neuf');
110
+ } else if (da !== undefined) {
111
+ element(da, crApres.get(da), 'changé');
112
+ }
113
+ if (dv !== undefined && !crApres.has(dv)) {
114
+ element(dv, crAvant.get(dv), 'supprimé');
115
+ } else if (dv !== undefined && da === undefined) {
116
+ element(dv, crApres.get(dv), 'changé');
117
+ }
118
+ }
119
+ elements.sort((x, y) => x.fichier.localeCompare(y.fichier) || x.nom.localeCompare(y.nom));
120
+ const fichiers = [...new Set(changes.map(c => c.fichier))].sort();
121
+ const horsDuService = fichiers.filter(f => f.endsWith('.rs'));
122
+ return {
123
+ etat: 'fait',
124
+ raison: null,
125
+ elements,
126
+ horsDuService,
127
+ fichiers,
128
+ service: horsDuService.length ? SERVICE : null,
129
+ };
130
+ } catch (e) {
131
+ return {
132
+ etat: 'impossible',
133
+ raison: `erreur : ${String(e.message).split('\n')[0]}`,
134
+ elements: [],
135
+ horsDuService: [],
136
+ fichiers: [],
137
+ };
138
+ }
139
+ }
@@ -0,0 +1,357 @@
1
+ // The entries of the suite of conformity (scripts/conformite.mjs) for the module cargo, as the
2
+ // valid and invalid cases a rule of ESLint gives its RuleTester: each a trial, built under the
3
+ // directory the suite gives, with what a sound module answers on it. Each manifest is one the real
4
+ // cargo reads (the night plays them with it), in the subset of TOML the tests' fake cargo reads.
5
+ //
6
+ // - A virtual workspace of four crates under `crates/`: `ws-core`, with its tests (`tests/t.rs`)
7
+ // and their helpers (`tests/common/`); `ws-app`, which depends on `ws-core` and has its tests;
8
+ // `ws-outil`, which depends on `ws-app` for its tests (`dev`) and on `ws-core` for its build
9
+ // script (`build`); `ws-matiere`, the shared test material (`[package.metadata.grillhouse]
10
+ // matiere = true`); the interfaces of `ws-core`, of `ws-app` and of the root, and the index of the
11
+ // interfaces they give, up to date (grillhouse-pkl.6). Committed: `espace`; the same, a source of `ws-core` then changed and a file
12
+ // out of every crate added: `change`, measured from its commit; the same with a second commit
13
+ // that changes `ws-core`, adds the crate `ws-neuf` and removes `ws-outil`: `lot`; the same, the
14
+ // interface of `ws-core` then changed, its index late: `enRetard`.
15
+ // - A crate at the root, its workspace `members = ["."]`, with its tests, as OSC Bridge: `seul`;
16
+ // a crate at the root holding a second crate, `crates/aide`, none with tests: `imbrique`.
17
+ // - A directory without Cargo.toml: `vide`; one with a tsconfig.json alone: `typescript`.
18
+ // - Two results directories of a run: every task and test green (`vert`); `ws-core` at 75,
19
+ // `ws-app` red with a test of `integ` failed, `ws-outil` not played (`defaut`).
20
+ // - `depots`: the repositories, for the tests of the module beside the suite.
21
+ import { execFileSync } from 'node:child_process';
22
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
23
+ import path from 'node:path';
24
+
25
+ const ecrireDans = racine => (rel, texte) => {
26
+ mkdirSync(path.dirname(path.join(racine, rel)), { recursive: true });
27
+ writeFileSync(path.join(racine, rel), texte);
28
+ };
29
+ const git = (racine, ...args) => execFileSync('git', ['-C', racine, ...args], { stdio: 'pipe' });
30
+ const tete = racine =>
31
+ execFileSync('git', ['-C', racine, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
32
+
33
+ // The manifest of the crate <nom>, its tables <tables> after `[package]`.
34
+ const manifeste = (nom, tables = '') =>
35
+ `[package]\nname = "${nom}"\nversion = "0.1.0"\nedition = "2021"\npublish = false\n${tables}`;
36
+
37
+ // Commits every file of <racine>, a new repository.
38
+ function engager(racine) {
39
+ git(racine, 'init', '-q', '-b', 'main');
40
+ git(racine, 'config', 'user.email', 'essai@example.com');
41
+ git(racine, 'config', 'user.name', 'essai');
42
+ git(racine, 'config', 'commit.gpgsign', 'false');
43
+ git(racine, 'add', '-A');
44
+ git(racine, 'commit', '-q', '-m', 'essai');
45
+ return racine;
46
+ }
47
+
48
+ const CRATES = {
49
+ core: manifeste('ws-core'),
50
+ app: manifeste('ws-app', '\n[dependencies]\nws-core = { path = "../core" }\n'),
51
+ outil: manifeste(
52
+ 'ws-outil',
53
+ '\n[dev-dependencies]\nws-app = { path = "../app" }\n\n[build-dependencies]\nws-core = { path = "../core" }\n'
54
+ ),
55
+ matiere: manifeste('ws-matiere', '\n[package.metadata.grillhouse]\nmatiere = true\n'),
56
+ };
57
+ // The interfaces of the workspace, and the index of the interfaces they give
58
+ // (./index-interfaces.mjs).
59
+ const INTERFACES = {
60
+ 'crates/core/docs/INTERFACE.md':
61
+ '# ws-core — interface\n\n`ws-core` offre le cœur. Une seconde phrase.\n\n## Consommateurs\n\n- `ws-app`: `core`\n',
62
+ 'crates/app/docs/INTERFACE.md': "# L'application\n\nL'application lit le cœur.\n",
63
+ 'docs/INTERFACE.md': "# L'espace d'essai\n\nQuatre crates sous `crates/`.\n",
64
+ };
65
+ export const INDEX = [
66
+ '# Index des interfaces',
67
+ '',
68
+ 'Généré depuis les `INTERFACE.md` des crates ; ne pas éditer.',
69
+ "Une ligne par composant ; l'interface donne le détail.",
70
+ '',
71
+ "## ws-app — L'application",
72
+ '',
73
+ "L'application lit le cœur. (`crates/app/docs/INTERFACE.md`)",
74
+ '',
75
+ '## ws-core — interface',
76
+ '',
77
+ '`ws-core` offre le cœur. (`crates/core/docs/INTERFACE.md`)',
78
+ '',
79
+ "## (racine) — L'espace d'essai",
80
+ '',
81
+ 'Quatre crates sous `crates/`. (`docs/INTERFACE.md`)',
82
+ '',
83
+ ].join('\n');
84
+
85
+ const membres = noms =>
86
+ `[workspace]\nresolver = "2"\nmembers = [${noms.map(n => `"crates/${n}"`).join(', ')}]\n`;
87
+
88
+ // The virtual workspace of the four crates in a new directory under <dans>, committed.
89
+ function espace(dans) {
90
+ const racine = mkdtempSync(path.join(dans, 'espace-'));
91
+ const ecrire = ecrireDans(racine);
92
+ ecrire('Cargo.toml', membres(Object.keys(CRATES)));
93
+ ecrire('.gitignore', '/target\n');
94
+ ecrire('README.md', "# L'espace d'essai\n");
95
+ for (const [n, m] of Object.entries(CRATES)) {
96
+ ecrire(`crates/${n}/Cargo.toml`, m);
97
+ ecrire(`crates/${n}/src/lib.rs`, `pub fn ${n}() -> i32 {\n 1\n}\n`);
98
+ }
99
+ ecrire('crates/outil/build.rs', 'fn main() {}\n');
100
+ for (const [f, t] of Object.entries(INTERFACES)) {
101
+ ecrire(f, t);
102
+ }
103
+ ecrire('docs/agents/index-des-interfaces.md', INDEX);
104
+ ecrire(
105
+ 'crates/core/tests/t.rs',
106
+ 'mod common;\n\n#[test]\nfn passe() {\n common::aide();\n}\n'
107
+ );
108
+ ecrire('crates/core/tests/common/mod.rs', 'pub fn aide() {}\n');
109
+ ecrire(
110
+ 'crates/app/tests/integ.rs',
111
+ '#[test]\nfn lit() {\n assert_eq!(ws_app::app(), 1);\n}\n'
112
+ );
113
+ return engager(racine);
114
+ }
115
+
116
+ // A crate at the root under <dans>, its workspace <membres>, committed.
117
+ function aLaRacine(dans, nom, membresEnPlus, fichiers) {
118
+ const racine = mkdtempSync(path.join(dans, `${nom}-`));
119
+ const ecrire = ecrireDans(racine);
120
+ ecrire(
121
+ 'Cargo.toml',
122
+ `[workspace]\nmembers = [${['.', ...membresEnPlus].map(m => `"${m}"`).join(', ')}]\n\n${manifeste(nom)}`
123
+ );
124
+ ecrire('.gitignore', '/target\n');
125
+ for (const [f, t] of Object.entries(fichiers)) {
126
+ ecrire(f, t);
127
+ }
128
+ return engager(racine);
129
+ }
130
+
131
+ // A results directory under <dans>: the tasks <taches> (`[crate, script, code]`), and the JUnit
132
+ // report of <crate> (`[crate, [[binaire, test, echoue]…]]`), the files of the binaries <cibles>.
133
+ function resultats(dans, taches, rapports, cibles) {
134
+ const dossier = mkdtempSync(path.join(dans, 'resultats-'));
135
+ const ecrire = ecrireDans(dossier);
136
+ ecrire(
137
+ 'cargo/1-1.json',
138
+ `${JSON.stringify({
139
+ taches: taches.map(([paquet, script, code]) => ({
140
+ tache: `${paquet}#${script}`,
141
+ paquet,
142
+ dossier: paquet === '//' ? '.' : `crates/${paquet.slice(3)}`,
143
+ script,
144
+ tests: script === 'nextest' || script === 'doctest',
145
+ code,
146
+ cache: null,
147
+ journal: null,
148
+ })),
149
+ cibles,
150
+ })}\n`
151
+ );
152
+ for (const [crate, suites] of rapports) {
153
+ const corps = suites
154
+ .map(
155
+ ([binaire, test, echoue]) =>
156
+ `<testsuite name="${binaire}" tests="1"><testcase name="${test}" classname="${binaire}">${
157
+ echoue ? '<failure message="assertion &apos;a &lt; b&apos;">a &lt; b</failure>' : ''
158
+ }</testcase></testsuite>`
159
+ )
160
+ .join('');
161
+ ecrire(`nextest/1-1-${crate}.xml`, `<?xml version="1.0"?><testsuites>${corps}</testsuites>`);
162
+ }
163
+ return dossier;
164
+ }
165
+
166
+ export default {
167
+ // The trials under <dans>.
168
+ preparer(dans) {
169
+ const aJour = espace(dans);
170
+ const vide = mkdtempSync(path.join(dans, 'vide-'));
171
+ writeFileSync(path.join(vide, 'README.md'), 'aucun crate\n');
172
+ const typescript = mkdtempSync(path.join(dans, 'typescript-'));
173
+ writeFileSync(path.join(typescript, 'tsconfig.json'), '{}\n');
174
+ const seul = aLaRacine(dans, 'seul', [], {
175
+ 'src/main.rs': 'fn main() {}\n',
176
+ 'src/lib.rs': 'pub fn un() -> i32 {\n 1\n}\n',
177
+ 'tests/bout.rs': '#[test]\nfn passe() {}\n',
178
+ 'tests/common/mod.rs': 'pub fn aide() {}\n',
179
+ 'README.md': '# Un crate à la racine\n',
180
+ });
181
+ const imbrique = aLaRacine(dans, 'imbrique', ['crates/aide'], {
182
+ 'src/lib.rs': 'pub fn un() -> i32 {\n 1\n}\n',
183
+ 'crates/aide/Cargo.toml': manifeste('aide'),
184
+ 'crates/aide/src/lib.rs': 'pub fn aide() {}\n',
185
+ });
186
+ const change = espace(dans);
187
+ const depuis = tete(change);
188
+ writeFileSync(
189
+ path.join(change, 'crates/core/src/lib.rs'),
190
+ 'pub fn core() -> i32 {\n 2\n}\n'
191
+ );
192
+ writeFileSync(path.join(change, 'notes.txt'), 'hors des crates\n');
193
+ const lot = espace(dans);
194
+ const avantLeLot = tete(lot);
195
+ const ecrireLot = ecrireDans(lot);
196
+ ecrireLot('crates/core/src/lib.rs', 'pub fn core() -> i32 {\n 3\n}\n');
197
+ ecrireLot('crates/neuf/Cargo.toml', manifeste('ws-neuf'));
198
+ ecrireLot('crates/neuf/src/lib.rs', 'pub fn neuf() {}\n');
199
+ ecrireLot('Cargo.toml', membres(['core', 'app', 'matiere', 'neuf']));
200
+ rmSync(path.join(lot, 'crates/outil'), { recursive: true, force: true });
201
+ git(lot, 'add', '-A');
202
+ git(lot, 'commit', '-q', '-m', 'lot');
203
+ const enRetard = espace(dans);
204
+ writeFileSync(
205
+ path.join(enRetard, 'crates/core/docs/INTERFACE.md'),
206
+ '# ws-core — interface\n\n`ws-core` offre un autre cœur.\n'
207
+ );
208
+ const cibles = {
209
+ 'ws-core': path.join(aJour, 'crates/core/src/lib.rs'),
210
+ 'ws-core::t': path.join(aJour, 'crates/core/tests/t.rs'),
211
+ 'ws-app': path.join(aJour, 'crates/app/src/lib.rs'),
212
+ 'ws-app::integ': path.join(aJour, 'crates/app/tests/integ.rs'),
213
+ };
214
+ return {
215
+ racine: aJour,
216
+ depots: {
217
+ espace: aJour,
218
+ seul,
219
+ imbrique,
220
+ change,
221
+ depuis,
222
+ lot,
223
+ avantLeLot,
224
+ enRetard,
225
+ vide,
226
+ typescript,
227
+ },
228
+ composants: {
229
+ valide: vide,
230
+ invalide: aJour,
231
+ attendu: [
232
+ 'ws-app (ws-app)',
233
+ 'ws-core (ws-core)',
234
+ 'ws-matiere (ws-matiere)',
235
+ 'ws-outil (ws-outil)',
236
+ ],
237
+ },
238
+ composantDe: {
239
+ valide: [
240
+ { fichier: 'crates/core/src/lib.rs', composant: 'ws-core' },
241
+ { fichier: 'crates/app/tests/integ.rs', composant: 'ws-app' },
242
+ { fichier: path.join(aJour, 'crates/outil/Cargo.toml'), composant: 'ws-outil' },
243
+ ],
244
+ invalide: [{ fichier: 'Cargo.toml' }, { fichier: 'README.md' }],
245
+ attendu: ['Cargo.toml : hors de tout composant', 'README.md : hors de tout composant'],
246
+ },
247
+ lecteurs: {
248
+ valide: { racine: seul, noms: [] },
249
+ invalide: { racine: aJour, noms: ['ws-core', 'ws-absent'] },
250
+ attendu: [
251
+ 'ws-app lit ws-core',
252
+ 'ws-outil lit ws-app',
253
+ 'ws-outil lit ws-core',
254
+ 'ws-absent : sans fournisseur',
255
+ ],
256
+ },
257
+ touches: {
258
+ valide: { racine: aJour, depuis: 'HEAD' },
259
+ invalide: { racine: change, depuis },
260
+ attendu: ['touché ws-core', 'dépendant ws-app', 'dépendant ws-outil', 'hors notes.txt'],
261
+ },
262
+ commandes: {
263
+ valide: ['tester', 'verifier', 'typer', 'preparer'],
264
+ invalide: ['tester', 'deployer'],
265
+ attendu: ['deployer : absente'],
266
+ },
267
+ verdict: {
268
+ valide: resultats(
269
+ dans,
270
+ [
271
+ ['ws-core', 'nextest', 0],
272
+ ['ws-core', 'doctest', 0],
273
+ ['//', 'deny', 0],
274
+ ],
275
+ [['ws-core', [['ws-core::t', 'passe', false]]]],
276
+ cibles
277
+ ),
278
+ invalide: resultats(
279
+ dans,
280
+ [
281
+ ['ws-core', 'nextest', 75],
282
+ ['ws-app', 'nextest', 100],
283
+ ['ws-outil', 'nextest', null],
284
+ ['//', 'deny', 4],
285
+ ],
286
+ [
287
+ ['ws-core', [['ws-core::t', 'passe', false]]],
288
+ ['ws-app', [['ws-app::integ', 'lit', true]]],
289
+ ],
290
+ cibles
291
+ ),
292
+ attendu: [
293
+ 'ws-core#nextest à repasser, tests',
294
+ 'ws-app#nextest rouge (100), tests',
295
+ '//#deny rouge (4)',
296
+ 'test integ.rs › lit',
297
+ ],
298
+ },
299
+ estUnTest: {
300
+ valide: ['crates/core/src/lib.rs', 'crates/app/Cargo.toml', 'Cargo.toml', 'README.md'],
301
+ invalide: [
302
+ 'crates/core/tests/t.rs',
303
+ 'crates/core/tests/common/mod.rs',
304
+ 'crates/matiere/src/lib.rs',
305
+ ],
306
+ attendu: [
307
+ 'crates/core/tests/t.rs : joue, test',
308
+ 'crates/core/tests/common/mod.rs : test, matiere',
309
+ 'crates/matiere/src/lib.rs : matiere',
310
+ ],
311
+ },
312
+ fichiersEngendres: {
313
+ valide: aJour,
314
+ invalide: enRetard,
315
+ attendu: ["l'index des interfaces : en retard"],
316
+ },
317
+ gardes: { valide: ['clippy', 'frontieres', 'index-interfaces'] },
318
+ elementsDuLot: {
319
+ valide: { racine: aJour, avant: 'HEAD', apres: 'HEAD' },
320
+ invalide: { racine: lot, avant: avantLeLot, apres: 'HEAD' },
321
+ attendu: [
322
+ 'fichier Cargo.toml',
323
+ 'fichier crates/core/src/lib.rs',
324
+ 'fichier crates/neuf/Cargo.toml',
325
+ 'fichier crates/neuf/src/lib.rs',
326
+ 'fichier crates/outil/Cargo.toml',
327
+ 'fichier crates/outil/build.rs',
328
+ 'fichier crates/outil/src/lib.rs',
329
+ 'hors du service crates/core/src/lib.rs',
330
+ 'hors du service crates/neuf/src/lib.rs',
331
+ 'hors du service crates/outil/build.rs',
332
+ 'hors du service crates/outil/src/lib.rs',
333
+ 'changé crates/core/Cargo.toml#ws-core',
334
+ 'neuf crates/neuf/Cargo.toml#ws-neuf',
335
+ 'supprimé crates/outil/Cargo.toml#ws-outil',
336
+ ],
337
+ },
338
+ matieres: { valide: seul, invalide: aJour, attendu: ['ws-matiere (ws-matiere)'] },
339
+ joueDesTests: {
340
+ valide: imbrique,
341
+ invalide: aJour,
342
+ attendu: ['ws-app (ws-app) : joue des tests', 'ws-core (ws-core) : joue des tests'],
343
+ },
344
+ trouve: {
345
+ valide: [
346
+ { nom: 'vide', racine: vide },
347
+ { nom: 'typescript', racine: typescript },
348
+ ],
349
+ invalide: [
350
+ { nom: 'espace', racine: aJour },
351
+ { nom: 'crate à la racine', racine: seul },
352
+ ],
353
+ attendu: ['espace : trouvé', 'crate à la racine : trouvé'],
354
+ },
355
+ };
356
+ },
357
+ };
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+ // The guard of the boundaries between the crates of a workspace of cargo: who may depend on whom,
3
+ // written once in the workspace's manifest, as Nx's `depConstraints` in one configuration, and
4
+ // held against what cargo itself says of each member (`cargo metadata --no-deps`, ./composants.mjs).
5
+ //
6
+ // node frontieres.mjs in the root of the workspace; 0 green, 1 a finding refused
7
+ //
8
+ // - The list permitted: `[workspace.metadata.grillhouse.frontieres]` of the root Cargo.toml, the
9
+ // table cargo keeps for its tools (`metadata` of `cargo metadata`); each key a crate, its value
10
+ // the crates it may depend on (`ws-app = ["ws-core"]`). A crate the list does not name, or a
11
+ // workspace without list, may depend on no other crate.
12
+ // - A dependency between crates is one a member declares by its path on another member, of any
13
+ // kind (`normal`, `dev`, `build`); a crate out of the workspace (crates.io, a git source) is
14
+ // cargo-deny's (`bans`), not this guard's.
15
+ // - Each dependency absent from the list is a finding: the manifest of the crate that declares it,
16
+ // the rule `dependance-non-permise`, a message naming both crates and the kind. The findings are
17
+ // judged by the debt (../../dette.mjs) and written in SARIF (../../resultats.mjs); cargo unable
18
+ // to answer refuses, named, never inscribed.
19
+ import path from 'node:path';
20
+ import { pathToFileURL } from 'node:url';
21
+ import { MODE, trancher } from '../../dette.mjs';
22
+ import { crates, metadonnees } from './composants.mjs';
23
+
24
+ export const GARDE = 'frontieres';
25
+ export const REGLE = 'dependance-non-permise';
26
+ const TABLE = '[workspace.metadata.grillhouse.frontieres]';
27
+
28
+ /**
29
+ * The dependencies between the crates of the workspace at <racine> that its list does not
30
+ * permit, each a finding `{ fichier, regle, message }`, by crate then by dependency.
31
+ * @param {string} racine the root of the workspace
32
+ */
33
+ export function constatsDesFrontieres(racine) {
34
+ const permises = metadonnees(racine)?.metadata?.grillhouse?.frontieres ?? {};
35
+ const liste = crates(racine);
36
+ const parDossier = new Map(liste.map(c => [c.composant.dossier, c.composant]));
37
+ const out = [];
38
+ for (const c of liste) {
39
+ const nom = c.composant.nom;
40
+ const permis = new Set(Array.isArray(permises[nom]) ? permises[nom] : []);
41
+ const manifeste = path
42
+ .relative(racine, path.join(c.composant.dossier, 'Cargo.toml'))
43
+ .split(path.sep)
44
+ .join('/');
45
+ const deps = c.deps
46
+ .map(d => ({ lu: parDossier.get(d.dossier), genre: d.genre }))
47
+ .filter(d => d.lu && d.lu !== c.composant && !permis.has(d.lu.nom))
48
+ .sort((a, b) => a.lu.nom.localeCompare(b.lu.nom) || a.genre.localeCompare(b.genre));
49
+ for (const { lu, genre } of deps) {
50
+ out.push({
51
+ fichier: manifeste,
52
+ regle: REGLE,
53
+ message: `${nom} dépend de ${lu.nom} (${genre}) : absent de la liste permise ${TABLE} du Cargo.toml.`,
54
+ });
55
+ }
56
+ }
57
+ return out;
58
+ }
59
+
60
+ /**
61
+ * Runs the guard in the workspace at <racine>: its exit code, its refusals printed.
62
+ * @param {string} racine the root of the workspace
63
+ * @param {{ env?: NodeJS.ProcessEnv }} [o] the environment (the results directory, the debt's mode)
64
+ */
65
+ export function commande(racine, { env = process.env } = {}) {
66
+ let constats;
67
+ try {
68
+ constats = constatsDesFrontieres(racine);
69
+ } catch (e) {
70
+ constats = [{ message: e.message }];
71
+ }
72
+ const { refus, lignes } = trancher(racine, GARDE, constats, env[MODE] || undefined, env);
73
+ for (const c of refus) {
74
+ process.stderr.write(`⛔ frontieres : ${c.fichier ? `${c.fichier} — ` : ''}${c.message}\n`);
75
+ }
76
+ for (const l of lignes) {
77
+ process.stderr.write(`${l}\n`);
78
+ }
79
+ return refus.length ? 1 : 0;
80
+ }
81
+
82
+ if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
83
+ process.exitCode = commande(process.cwd());
84
+ }