@roomi-fields/grillhouse 0.28.2 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/bin/grillhouse.mjs +55 -14
- package/cadre/templates/projet/CLAUDE.md +1 -1
- package/cadre/templates/projet/README.md +11 -11
- package/cadre/templates/projet/_gitignore +2 -5
- package/charte.md +24 -3
- package/docs/ARCHITECTURE.md +279 -31
- package/docs/INTERFACE.md +59 -11
- package/package.json +1 -1
- package/scripts/aiguillage.mjs +324 -0
- package/scripts/avancement.mjs +33 -50
- package/scripts/circuit.mjs +558 -146
- package/scripts/composition-des-langages.mjs +16 -1
- package/scripts/conformite.mjs +16 -0
- package/scripts/copies-finies.mjs +181 -29
- package/scripts/demon.mjs +134 -21
- package/scripts/enveloppe/enveloppe.mjs +8 -5
- package/scripts/enveloppe/lancer.sh +24 -15
- package/scripts/enveloppe/travail-de-la-copie.mjs +94 -11
- package/scripts/etapes.mjs +1 -1
- package/scripts/fusion-du-changelog.mjs +0 -1
- package/scripts/grillhouse-maj.mjs +16 -7
- package/scripts/integration/file.mjs +3 -3
- package/scripts/integration/integrer.mjs +3 -3
- package/scripts/jointure.d.ts +53 -17
- package/scripts/langages/cargo/commandes.mjs +152 -25
- package/scripts/langages/cargo/composants.mjs +94 -2
- package/scripts/langages/cargo/exemples.mjs +68 -1
- package/scripts/langages/cargo/index.mjs +21 -10
- package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
- package/scripts/langages/cargo/sccache.mjs +89 -6
- package/scripts/langages/cargo/squelette.mjs +72 -3
- package/scripts/langages/cargo/tailles-des-tests.mjs +195 -0
- package/scripts/langages/cargo/tests-de-head.mjs +159 -0
- package/scripts/langages/python/commandes.mjs +53 -9
- package/scripts/langages/python/composants.mjs +33 -3
- package/scripts/langages/python/exemples.mjs +19 -0
- package/scripts/langages/python/index.mjs +7 -2
- package/scripts/langages/python/squelette.mjs +119 -17
- package/scripts/langages/typescript/exemples.mjs +16 -0
- package/scripts/langages/typescript/index.mjs +6 -3
- package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
- package/scripts/langages/typescript/squelette.mjs +18 -2
- package/scripts/langages/typescript/tests-de-nuit.mjs +50 -20
- package/scripts/langages/typescript/verifier.mjs +82 -288
- package/scripts/langages/typescript/vitest-config/base.mjs +8 -9
- package/scripts/langages/typescript/vitest-config/cibles.mjs +92 -53
- package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +11 -5
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +6 -1
- package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
- package/scripts/langages/typescript/vitest.nuit.config.mjs +18 -13
- package/scripts/lecture-unique.mjs +51 -0
- package/scripts/mesure/base-de-passe.mjs +202 -9
- package/scripts/mesure/pression.mjs +9 -7
- package/scripts/nuit.sh +19 -12
- package/scripts/outil.mjs +72 -0
- package/scripts/paquet.mjs +39 -10
- package/scripts/resultats.mjs +22 -5
- package/scripts/services-du-noyau.mjs +16 -10
- package/scripts/session-start.sh +10 -1
- package/scripts/sortie.mjs +20 -1
- package/scripts/sources.mjs +3 -3
- package/scripts/sous-commandes.mjs +2 -0
- package/scripts/superviseur.mjs +369 -14
- package/scripts/tableau.mjs +219 -58
- package/scripts/verrou-de-machine.mjs +425 -37
- package/skills/developpeur/SKILL.md +11 -3
- package/skills/pitmaster/SKILL.md +64 -23
- package/skills/pitmaster/references/consigne-agent.md +4 -0
- package/skills/relecteur/SKILL.md +18 -6
- package/skills/testwriter/SKILL.md +11 -15
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
// The published version that leads the frame's repository, as rustc is built by its stage0 (a
|
|
2
|
+
// published compiler, fixed in src/stage0, downloaded into a cache) and Bazel by a released Bazel:
|
|
3
|
+
// the tool that orchestrates is a published version; the code the tickets change is the code that
|
|
4
|
+
// is built and tested.
|
|
5
|
+
//
|
|
6
|
+
// The command (bin/grillhouse.mjs) imports this module, and `grillhouse outil` (scripts/outil.mjs)
|
|
7
|
+
// installs a version by it.
|
|
8
|
+
//
|
|
9
|
+
// - The key `grillhouse.outil` of the project's package.json (the working directory) names the
|
|
10
|
+
// version, `x.y.z`; absent or null, the project has none: an ordinary project, whose command is
|
|
11
|
+
// already the version it installed. Any other value is refused by its name.
|
|
12
|
+
// - A version is installed under ~/.cache/grillhouse/outil/<version>/ (`dossierDeLOutil`), by
|
|
13
|
+
// `npm install` of the published package @roomi-fields/grillhouse@<version>, then of the peer
|
|
14
|
+
// dependencies it declares, at their ranges, the optional ones included (TypeScript, Turborepo,
|
|
15
|
+
// API Extractor…): the tool stands alone, as a stage0 brings its library. It installs in a folder
|
|
16
|
+
// of its own beside it (`<version>.installation-<pid>`), renamed once complete: a version half
|
|
17
|
+
// installed is never taken for one there, the folder of a process that died is swept at the
|
|
18
|
+
// next installation, and a folder another launch completed meanwhile is taken. npm writes on
|
|
19
|
+
// the error stream alone, so that the output of a hook of Claude Code stays the command's. A
|
|
20
|
+
// failure is written in the state file of the tool (`<version>.echec`, its date and its reason),
|
|
21
|
+
// removed at the first installation that succeeds: within 5 minutes of it, a launch runs no npm
|
|
22
|
+
// again, and while it stands the session's start (`node aiguillage.mjs --echec`) and the board
|
|
23
|
+
// (`echecDeLOutil`) say that the orchestration runs on the code of the repository.
|
|
24
|
+
// - The switch (`aiguillage`), which the command (bin/grillhouse.mjs) asks before any subcommand:
|
|
25
|
+
// a subcommand of the orchestration (REDIRIGEES) in a project that names its version runs by the
|
|
26
|
+
// command of that version, installed at its first launch; a version that cannot be installed is
|
|
27
|
+
// said in one line, and the code that runs takes its place. Every other subcommand runs the code
|
|
28
|
+
// that runs, the ticket's copy for a session of the circuit: those of the copy (DU_CODE_EN_COURS,
|
|
29
|
+
// and the commands of the modules of language) and the tools of the repository
|
|
30
|
+
// (OUTILS_DU_DEPOT). Each subcommand of the core is in one of the three lists, which a test
|
|
31
|
+
// holds. The code that runs is the version installed when their paths are the same: it runs in
|
|
32
|
+
// place.
|
|
33
|
+
import { spawnSync } from 'node:child_process';
|
|
34
|
+
import {
|
|
35
|
+
existsSync,
|
|
36
|
+
mkdirSync,
|
|
37
|
+
readdirSync,
|
|
38
|
+
readFileSync,
|
|
39
|
+
realpathSync,
|
|
40
|
+
renameSync,
|
|
41
|
+
rmSync,
|
|
42
|
+
writeFileSync,
|
|
43
|
+
} from 'node:fs';
|
|
44
|
+
import os from 'node:os';
|
|
45
|
+
import path from 'node:path';
|
|
46
|
+
import { pathToFileURL } from 'node:url';
|
|
47
|
+
|
|
48
|
+
export const CLE = 'grillhouse.outil';
|
|
49
|
+
export const NOM_DU_PAQUET = '@roomi-fields/grillhouse';
|
|
50
|
+
export const X_Y_Z = /^\d+\.\d+\.\d+$/;
|
|
51
|
+
// The package that runs: this script's.
|
|
52
|
+
const PAQUET_QUI_TOURNE = path.resolve(import.meta.dirname, '..');
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The subcommands of the orchestration, which the published version runs: the circuit, the
|
|
56
|
+
* supervisor, the night, the board and the status line, the hooks of Claude Code, the locks and
|
|
57
|
+
* the rights of the sessions, the envelope and its launcher, the integration and the queue, the
|
|
58
|
+
* results, the removal of a copy and the balance, even when the supervisor runs one by hand.
|
|
59
|
+
*/
|
|
60
|
+
export const REDIRIGEES = new Set([
|
|
61
|
+
'bilan',
|
|
62
|
+
'circuit',
|
|
63
|
+
'commande',
|
|
64
|
+
'droits',
|
|
65
|
+
'enveloppe',
|
|
66
|
+
'file',
|
|
67
|
+
'integrer',
|
|
68
|
+
'lancer',
|
|
69
|
+
'ligne-etat',
|
|
70
|
+
'nuit',
|
|
71
|
+
'registre',
|
|
72
|
+
'resultats',
|
|
73
|
+
'retirer-copie',
|
|
74
|
+
'session-start',
|
|
75
|
+
'structure-guard',
|
|
76
|
+
'superviseur',
|
|
77
|
+
'tableau',
|
|
78
|
+
'ticket-du-sous-agent',
|
|
79
|
+
'verrou',
|
|
80
|
+
]);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The subcommands that play the code of the copy: the tests, the verification, the guards, the
|
|
84
|
+
* temporary folder, the git hooks and the merge driver, the affected components; the commands of
|
|
85
|
+
* the modules of language too, which are no subcommand of the core.
|
|
86
|
+
*/
|
|
87
|
+
export const DU_CODE_EN_COURS = new Set([
|
|
88
|
+
'composants-affectes',
|
|
89
|
+
'fusion-du-changelog',
|
|
90
|
+
'gardes-du-cadre',
|
|
91
|
+
'hook',
|
|
92
|
+
'hooks',
|
|
93
|
+
'langages-des-paquets',
|
|
94
|
+
'temporaire',
|
|
95
|
+
'tests',
|
|
96
|
+
'verifier',
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
/** The tools of the repository, which run its code: creation, update, release, installation. */
|
|
100
|
+
export const OUTILS_DU_DEPOT = new Set([
|
|
101
|
+
'greffons',
|
|
102
|
+
'init',
|
|
103
|
+
'maj',
|
|
104
|
+
'outil',
|
|
105
|
+
'paquet',
|
|
106
|
+
'pression',
|
|
107
|
+
'sortie',
|
|
108
|
+
'sous-modules',
|
|
109
|
+
'ticket',
|
|
110
|
+
]);
|
|
111
|
+
|
|
112
|
+
// How long a failed installation is kept: within it, a launch runs no npm again.
|
|
113
|
+
const RETENUE_MS = 5 * 60 * 1000;
|
|
114
|
+
|
|
115
|
+
// The cache of the published versions: ~/.cache/grillhouse/outil.
|
|
116
|
+
const cacheDesOutils = () => path.join(os.homedir(), '.cache', 'grillhouse', 'outil');
|
|
117
|
+
|
|
118
|
+
/** The folder of the version <version> under <cache>. */
|
|
119
|
+
export const dossierDeLOutil = (version, cache = cacheDesOutils()) => path.join(cache, version);
|
|
120
|
+
|
|
121
|
+
// The command of the version installed in <dossier>.
|
|
122
|
+
const commandeDans = dossier =>
|
|
123
|
+
path.join(dossier, 'node_modules', NOM_DU_PAQUET, 'bin', 'grillhouse.mjs');
|
|
124
|
+
|
|
125
|
+
const realpath = p => {
|
|
126
|
+
try {
|
|
127
|
+
return realpathSync(p);
|
|
128
|
+
} catch {
|
|
129
|
+
return p;
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The version the project at <racine> names (`grillhouse.outil` of its package.json), or null.
|
|
135
|
+
* @param {string} [racine]
|
|
136
|
+
* @returns {string | null}
|
|
137
|
+
* @throws {Error} a value that is no version x.y.z, named by its key
|
|
138
|
+
*/
|
|
139
|
+
export function versionDeLOutil(racine = process.cwd()) {
|
|
140
|
+
let pkg;
|
|
141
|
+
try {
|
|
142
|
+
pkg = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8'));
|
|
143
|
+
} catch {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
const v = pkg?.grillhouse?.outil;
|
|
147
|
+
if (v === undefined || v === null) return null;
|
|
148
|
+
if (typeof v !== 'string' || !X_Y_Z.test(v)) {
|
|
149
|
+
throw new Error(`la clé ${CLE} vaut ${JSON.stringify(v)}, pas une version x.y.z.`);
|
|
150
|
+
}
|
|
151
|
+
return v;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Where the subcommand <nom> runs in the project at <racine>: `{ version, dossier, commande }`, the
|
|
156
|
+
* version of the key and its command under <cache>, for a subcommand of the orchestration that the
|
|
157
|
+
* package <paquet> (the one that runs) is not; null otherwise (see the header).
|
|
158
|
+
* @param {string} nom
|
|
159
|
+
* @param {{ racine?: string, cache?: string, paquet?: string }} [options]
|
|
160
|
+
* @returns {{ version: string, dossier: string, commande: string } | null}
|
|
161
|
+
*/
|
|
162
|
+
export function aiguillage(
|
|
163
|
+
nom,
|
|
164
|
+
{ racine = process.cwd(), cache = cacheDesOutils(), paquet = PAQUET_QUI_TOURNE } = {}
|
|
165
|
+
) {
|
|
166
|
+
if (!REDIRIGEES.has(nom)) return null;
|
|
167
|
+
const version = versionDeLOutil(racine);
|
|
168
|
+
if (version === null) return null;
|
|
169
|
+
const dossier = dossierDeLOutil(version, cache);
|
|
170
|
+
const commande = commandeDans(dossier);
|
|
171
|
+
if (realpath(paquet) === realpath(path.resolve(path.dirname(commande), '..'))) return null;
|
|
172
|
+
return { version, dossier, commande };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// The state file of the failed installation of <version> under <cache>.
|
|
176
|
+
const fichierDEchec = (version, cache) => `${dossierDeLOutil(version, cache)}.echec`;
|
|
177
|
+
|
|
178
|
+
// The failure the state file <f> holds, `{ date, raison }`, or null.
|
|
179
|
+
function lireLEchec(f) {
|
|
180
|
+
try {
|
|
181
|
+
const e = JSON.parse(readFileSync(f, 'utf8'));
|
|
182
|
+
return typeof e?.raison === 'string' && !Number.isNaN(Date.parse(e?.date)) ? e : null;
|
|
183
|
+
} catch {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The failed installation of the version the project at <racine> names: `{ version, raison, date }`
|
|
190
|
+
* while its state file stands (written at each failure, removed at the first installation that
|
|
191
|
+
* succeeds), which the session's start and the board say; null otherwise, or without the key. A
|
|
192
|
+
* state file beside the version installed (a failure written after another launch succeeded) is
|
|
193
|
+
* removed, and gives null.
|
|
194
|
+
* @param {string} [racine]
|
|
195
|
+
* @param {{ cache?: string }} [options]
|
|
196
|
+
* @returns {{ version: string, raison: string, date: string } | null}
|
|
197
|
+
*/
|
|
198
|
+
export function echecDeLOutil(racine = process.cwd(), { cache = cacheDesOutils() } = {}) {
|
|
199
|
+
let version;
|
|
200
|
+
try {
|
|
201
|
+
version = versionDeLOutil(racine);
|
|
202
|
+
} catch {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
if (version === null) return null;
|
|
206
|
+
const f = fichierDEchec(version, cache);
|
|
207
|
+
// A failure written after another launch installed the version: the version stands.
|
|
208
|
+
if (existsSync(commandeDans(dossierDeLOutil(version, cache)))) {
|
|
209
|
+
rmSync(f, { force: true });
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
const e = lireLEchec(f);
|
|
213
|
+
return e && { version, raison: e.raison, date: e.date };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// The pids of the folders of installation (`<version>.installation-<pid>`) under <cache>, each of a
|
|
217
|
+
// process that has ended removed.
|
|
218
|
+
function balayer(cache) {
|
|
219
|
+
let entrees = [];
|
|
220
|
+
try {
|
|
221
|
+
entrees = readdirSync(cache);
|
|
222
|
+
} catch {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
for (const e of entrees) {
|
|
226
|
+
const pid = Number(/\.installation-(\d+)$/.exec(e)?.[1]);
|
|
227
|
+
if (pid && !vivant(pid)) rmSync(path.join(cache, e), { recursive: true, force: true });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const vivant = pid => {
|
|
232
|
+
try {
|
|
233
|
+
process.kill(pid, 0);
|
|
234
|
+
return true;
|
|
235
|
+
} catch (e) {
|
|
236
|
+
return e.code === 'EPERM';
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// Runs npm install of <specs> under <prefixe>, its output on the error stream; throws the reason
|
|
241
|
+
// of a failure: npm's last line, or its code.
|
|
242
|
+
function npmInstall(npm, prefixe, specs) {
|
|
243
|
+
const r = spawnSync(
|
|
244
|
+
npm,
|
|
245
|
+
['install', '--prefix', prefixe, '--no-audit', '--no-fund', '--save-exact', ...specs],
|
|
246
|
+
{ stdio: ['ignore', 2, 'pipe'], encoding: 'utf8' }
|
|
247
|
+
);
|
|
248
|
+
process.stderr.write(r.stderr ?? '');
|
|
249
|
+
if (r.status === 0) return;
|
|
250
|
+
const ligne = String(r.stderr ?? '')
|
|
251
|
+
.trim()
|
|
252
|
+
.split('\n')
|
|
253
|
+
.at(-1);
|
|
254
|
+
throw new Error(
|
|
255
|
+
`npm install ${specs.join(' ')} : ${r.error?.message || ligne || `code ${r.status}`}`
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Installs the published version <version> under <cache> (see the header), by the command <npm>:
|
|
261
|
+
* the package, then the peer dependencies it declares, at their ranges, the optional ones
|
|
262
|
+
* included, so that the tool stands alone, as a stage0 brings its library. A failure is kept
|
|
263
|
+
* <retenue> ms, within which a call runs no npm and throws it again.
|
|
264
|
+
* @param {string} version
|
|
265
|
+
* @param {{ cache?: string, npm?: string, retenue?: number }} [options]
|
|
266
|
+
* @returns {{ dossier: string, installe: boolean }} installe false when it was there
|
|
267
|
+
* @throws {Error} npm failing, the version named
|
|
268
|
+
*/
|
|
269
|
+
export function installer(
|
|
270
|
+
version,
|
|
271
|
+
{ cache = cacheDesOutils(), npm = 'npm', retenue = RETENUE_MS } = {}
|
|
272
|
+
) {
|
|
273
|
+
const dossier = dossierDeLOutil(version, cache);
|
|
274
|
+
if (existsSync(commandeDans(dossier))) return { dossier, installe: false };
|
|
275
|
+
const echec = fichierDEchec(version, cache);
|
|
276
|
+
const garde = lireLEchec(echec);
|
|
277
|
+
if (garde && Date.now() - Date.parse(garde.date) < retenue) throw new Error(garde.raison);
|
|
278
|
+
mkdirSync(cache, { recursive: true });
|
|
279
|
+
balayer(cache);
|
|
280
|
+
const chantier = `${dossier}.installation-${process.pid}`;
|
|
281
|
+
rmSync(chantier, { recursive: true, force: true });
|
|
282
|
+
mkdirSync(chantier, { recursive: true });
|
|
283
|
+
try {
|
|
284
|
+
try {
|
|
285
|
+
npmInstall(npm, chantier, [`${NOM_DU_PAQUET}@${version}`]);
|
|
286
|
+
const pkg = JSON.parse(
|
|
287
|
+
readFileSync(path.join(chantier, 'node_modules', NOM_DU_PAQUET, 'package.json'), 'utf8')
|
|
288
|
+
);
|
|
289
|
+
const pairs = Object.entries(pkg.peerDependencies ?? {}).map(([n, r]) => `${n}@${r}`);
|
|
290
|
+
if (pairs.length) npmInstall(npm, chantier, pairs);
|
|
291
|
+
if (!existsSync(commandeDans(chantier))) {
|
|
292
|
+
throw new Error(`npm n'a pas posé la commande de ${NOM_DU_PAQUET}@${version}`);
|
|
293
|
+
}
|
|
294
|
+
} catch (e) {
|
|
295
|
+
const raison = `${NOM_DU_PAQUET}@${version} : ${e.message}`;
|
|
296
|
+
writeFileSync(echec, JSON.stringify({ date: new Date().toISOString(), raison }));
|
|
297
|
+
throw new Error(raison);
|
|
298
|
+
}
|
|
299
|
+
rmSync(echec, { force: true });
|
|
300
|
+
try {
|
|
301
|
+
renameSync(chantier, dossier);
|
|
302
|
+
} catch (e) {
|
|
303
|
+
// Another launch installed it meanwhile: its folder stands.
|
|
304
|
+
if (!existsSync(commandeDans(dossier))) throw e;
|
|
305
|
+
}
|
|
306
|
+
return { dossier, installe: true };
|
|
307
|
+
} finally {
|
|
308
|
+
rmSync(chantier, { recursive: true, force: true });
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// `node aiguillage.mjs --echec [<racine>]`, which the session's start runs: the line that says the
|
|
313
|
+
// failed installation of the version of the key, nothing without one.
|
|
314
|
+
if (
|
|
315
|
+
import.meta.url === pathToFileURL(process.argv[1] ?? '').href &&
|
|
316
|
+
process.argv[2] === '--echec'
|
|
317
|
+
) {
|
|
318
|
+
const e = echecDeLOutil(process.argv[3] ?? process.cwd());
|
|
319
|
+
if (e) {
|
|
320
|
+
process.stdout.write(
|
|
321
|
+
`⚠️ Version publiée ${e.version} non installable (${e.raison}) : l'orchestration tourne sur le code du dépôt. \`npx grillhouse outil\` la réinstalle.\n`
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
}
|
package/scripts/avancement.mjs
CHANGED
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
// copies included, beside the last green (scripts/dernier-vert.mjs): `{ passes, taches }`, the
|
|
23
23
|
// total of the last pass of each kind and the files planned of each task by its hash (the
|
|
24
24
|
// latest TACHES_GARDEES); each pass keeps its own at its end (`garderLeTotal`).
|
|
25
|
-
// -
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
25
|
+
// - The holder of the lock of the machine (scripts/verrou-de-machine.mjs: a measure out of a
|
|
26
|
+
// ticket, `npm run verifier` of a supervisor or of an integration, or a heavy pass of the
|
|
27
|
+
// circuit of a ticket) names its progress directory beside the lock (`nommerLAvancement`); the
|
|
28
|
+
// board reads the holder with its progress, and the waits for the lock or for room
|
|
29
|
+
// (`lireLaMesure`).
|
|
30
30
|
import { spawnSync } from 'node:child_process';
|
|
31
|
-
import {
|
|
31
|
+
import { mkdtempSync, readdirSync, readFileSync } from 'node:fs';
|
|
32
32
|
import { tmpdir } from 'node:os';
|
|
33
33
|
import path from 'node:path';
|
|
34
34
|
import { ecrireAtomique, TACHES } from './mesure/avancement.mjs';
|
|
35
|
-
import {
|
|
35
|
+
import { lireLeVerrou } from './verrou-de-machine.mjs';
|
|
36
36
|
|
|
37
37
|
const PASSE = 'passe.json';
|
|
38
38
|
const PLAN = 'plan';
|
|
@@ -180,51 +180,34 @@ export function garderLeTotal(dossier, racine) {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
// The file of the measure out of a ticket under <env>: beside the lock of the machine.
|
|
184
|
-
function fichierDeLaMesure(env = process.env) {
|
|
185
|
-
const verrou = verrouDeMachine(env);
|
|
186
|
-
return { verrou, fichier: `${verrou}.avancement.json` };
|
|
187
|
-
}
|
|
188
|
-
|
|
189
183
|
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const { fichier } = fichierDeLaMesure(env);
|
|
198
|
-
try {
|
|
199
|
-
mkdirSync(path.dirname(fichier), { recursive: true });
|
|
200
|
-
ecrireAtomique(fichier, { depot, commande, dossier, pid: process.pid });
|
|
201
|
-
} catch {
|
|
202
|
-
return () => {};
|
|
203
|
-
}
|
|
204
|
-
return () => {
|
|
205
|
-
if (lireJson(fichier)?.pid === process.pid) rmSync(fichier, { force: true });
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const vivant = pid => {
|
|
210
|
-
try {
|
|
211
|
-
process.kill(pid, 0);
|
|
212
|
-
return true;
|
|
213
|
-
} catch (e) {
|
|
214
|
-
return e.code === 'EPERM';
|
|
215
|
-
}
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* The measure out of a ticket that holds the lock of the machine under <env>: its repository, its
|
|
220
|
-
* command and its progress; null without one, or when its process is gone or the lock is not held.
|
|
184
|
+
* Who holds the lock of the machine under <env> and who waits for it, as the board shows them
|
|
185
|
+
* (scripts/tableau.mjs): `detenteur`, its repository (`depot`, the root of its main tree, and
|
|
186
|
+
* `projet`, its folder), ticket, kind, since when and progress
|
|
187
|
+
* (`avancement`, its files done and planned and its last sign; null while it names no progress
|
|
188
|
+
* directory, or that directory does not read), null when the lock is free or its process gone;
|
|
189
|
+
* `attentes`, each live wait, the oldest first, its project, ticket, kind, what it waits for
|
|
190
|
+
* (`quoi`) and since when (`lireLeVerrou` of scripts/verrou-de-machine.mjs).
|
|
221
191
|
* @param {Record<string, string | undefined>} [env]
|
|
222
192
|
*/
|
|
223
193
|
export function lireLaMesure(env = process.env) {
|
|
224
|
-
const {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
194
|
+
const { detenteur: d, attentes } = lireLeVerrou(env);
|
|
195
|
+
return {
|
|
196
|
+
detenteur: d && {
|
|
197
|
+
depot: d.depot,
|
|
198
|
+
projet: d.projet,
|
|
199
|
+
ticket: d.ticket,
|
|
200
|
+
sorte: d.sorte,
|
|
201
|
+
depuis: d.depuis,
|
|
202
|
+
avancement: typeof d.dossier === 'string' ? lireAvancement(d.dossier) : null,
|
|
203
|
+
},
|
|
204
|
+
attentes: attentes.map(({ depot, projet, ticket, sorte, quoi, depuis }) => ({
|
|
205
|
+
depot,
|
|
206
|
+
projet,
|
|
207
|
+
ticket,
|
|
208
|
+
sorte,
|
|
209
|
+
quoi,
|
|
210
|
+
depuis,
|
|
211
|
+
})),
|
|
212
|
+
};
|
|
230
213
|
}
|