@roomi-fields/grillhouse 0.28.3 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +739 -0
- package/bin/grillhouse.mjs +128 -26
- package/cadre/templates/projet/.github/workflows/ci.yml +2 -13
- package/cadre/templates/projet/CLAUDE.md +5 -1
- package/cadre/templates/projet/README.md +11 -11
- package/cadre/templates/projet/_gitignore +2 -5
- package/cadre/templates/projet/docs/agents/issue-tracker.md +1 -1
- package/cadre/templates/projet/package.json +2 -2
- package/charte.md +37 -4
- package/dist/temporal/acte.d.ts +24 -0
- package/dist/temporal/acte.js +139 -0
- package/dist/temporal/acte.js.map +1 -0
- package/dist/temporal/attributs.d.ts +6 -0
- package/dist/temporal/attributs.js +15 -0
- package/dist/temporal/attributs.js.map +1 -0
- package/dist/temporal/circuit/activites.d.ts +13 -0
- package/dist/temporal/circuit/activites.js +33 -0
- package/dist/temporal/circuit/activites.js.map +1 -0
- package/dist/temporal/circuit/client.d.ts +72 -0
- package/dist/temporal/circuit/client.js +247 -0
- package/dist/temporal/circuit/client.js.map +1 -0
- package/dist/temporal/circuit/commande.d.ts +2 -0
- package/dist/temporal/circuit/commande.js +238 -0
- package/dist/temporal/circuit/commande.js.map +1 -0
- package/dist/temporal/circuit/contrat.d.ts +305 -0
- package/dist/temporal/circuit/contrat.js +24 -0
- package/dist/temporal/circuit/contrat.js.map +1 -0
- package/dist/temporal/circuit/deroule.d.ts +3 -0
- package/dist/temporal/circuit/deroule.js +540 -0
- package/dist/temporal/circuit/deroule.js.map +1 -0
- package/dist/temporal/client.d.ts +47 -0
- package/dist/temporal/client.js +69 -0
- package/dist/temporal/client.js.map +1 -0
- package/dist/temporal/commande.d.ts +2 -0
- package/dist/temporal/commande.js +95 -0
- package/dist/temporal/commande.js.map +1 -0
- package/dist/temporal/deroules.d.ts +5 -0
- package/dist/temporal/deroules.js +10 -0
- package/dist/temporal/deroules.js.map +1 -0
- package/dist/temporal/etat.d.ts +33 -0
- package/dist/temporal/etat.js +59 -0
- package/dist/temporal/etat.js.map +1 -0
- package/dist/temporal/file/activites.d.ts +10 -0
- package/dist/temporal/file/activites.js +25 -0
- package/dist/temporal/file/activites.js.map +1 -0
- package/dist/temporal/file/client.d.ts +4 -0
- package/dist/temporal/file/client.js +6 -0
- package/dist/temporal/file/client.js.map +1 -0
- package/dist/temporal/file/contrat.d.ts +158 -0
- package/dist/temporal/file/contrat.js +14 -0
- package/dist/temporal/file/contrat.js.map +1 -0
- package/dist/temporal/file/deroule.d.ts +15 -0
- package/dist/temporal/file/deroule.js +235 -0
- package/dist/temporal/file/deroule.js.map +1 -0
- package/dist/temporal/installation.d.ts +124 -0
- package/dist/temporal/installation.js +408 -0
- package/dist/temporal/installation.js.map +1 -0
- package/dist/temporal/places/activites.d.ts +8 -0
- package/dist/temporal/places/activites.js +13 -0
- package/dist/temporal/places/activites.js.map +1 -0
- package/dist/temporal/places/client.d.ts +28 -0
- package/dist/temporal/places/client.js +64 -0
- package/dist/temporal/places/client.js.map +1 -0
- package/dist/temporal/places/contrat.d.ts +106 -0
- package/dist/temporal/places/contrat.js +21 -0
- package/dist/temporal/places/contrat.js.map +1 -0
- package/dist/temporal/places/deroule.d.ts +3 -0
- package/dist/temporal/places/deroule.js +198 -0
- package/dist/temporal/places/deroule.js.map +1 -0
- package/dist/temporal/sonde/activites.d.ts +6 -0
- package/dist/temporal/sonde/activites.js +52 -0
- package/dist/temporal/sonde/activites.js.map +1 -0
- package/dist/temporal/sonde/contrat.d.ts +35 -0
- package/dist/temporal/sonde/contrat.js +10 -0
- package/dist/temporal/sonde/contrat.js.map +1 -0
- package/dist/temporal/sonde/deroule.d.ts +3 -0
- package/dist/temporal/sonde/deroule.js +39 -0
- package/dist/temporal/sonde/deroule.js.map +1 -0
- package/dist/temporal/tickets/activites.d.ts +7 -0
- package/dist/temporal/tickets/activites.js +81 -0
- package/dist/temporal/tickets/activites.js.map +1 -0
- package/dist/temporal/tickets/client.d.ts +10 -0
- package/dist/temporal/tickets/client.js +31 -0
- package/dist/temporal/tickets/client.js.map +1 -0
- package/dist/temporal/tickets/contrat.d.ts +56 -0
- package/dist/temporal/tickets/contrat.js +13 -0
- package/dist/temporal/tickets/contrat.js.map +1 -0
- package/dist/temporal/tickets/deroule.d.ts +3 -0
- package/dist/temporal/tickets/deroule.js +94 -0
- package/dist/temporal/tickets/deroule.js.map +1 -0
- package/dist/temporal/travailleur.d.ts +2 -0
- package/dist/temporal/travailleur.js +69 -0
- package/dist/temporal/travailleur.js.map +1 -0
- package/docs/ARCHITECTURE.md +813 -53
- package/docs/CADRE.md +17 -0
- package/docs/INTERFACE.md +161 -30
- package/hooks/crochet.mjs +19 -2
- package/hooks/hooks.json +11 -0
- package/package.json +16 -4
- package/scripts/activites.mjs +2182 -0
- package/scripts/aiguillage.d.mts +37 -0
- package/scripts/aiguillage.mjs +328 -0
- package/scripts/avancement.mjs +159 -64
- package/scripts/bilan.mjs +37 -19
- package/scripts/cadre.mjs +11 -2
- package/scripts/circuit.mjs +888 -3654
- package/scripts/circuits-cles.d.mts +4 -0
- package/scripts/circuits-cles.mjs +21 -0
- package/scripts/circuits-du-serveur.mjs +105 -0
- package/scripts/codes-de-sortie.mjs +9 -0
- package/scripts/commandes-composees.mjs +45 -41
- package/scripts/commandes-du-path.d.mts +7 -0
- package/scripts/commandes-du-path.mjs +25 -0
- package/scripts/composition-des-langages.mjs +30 -11
- package/scripts/conformite.mjs +19 -10
- package/scripts/copies-finies.mjs +188 -42
- package/scripts/depart-du-ticket.d.mts +53 -0
- package/scripts/depart-du-ticket.mjs +124 -0
- package/scripts/dependances-internes.mjs +115 -0
- package/scripts/dernier-vert.mjs +7 -15
- package/scripts/donnees-cles.mjs +228 -0
- package/scripts/droits.mjs +11 -1
- package/scripts/effets.mjs +352 -0
- package/scripts/enveloppe/enveloppe.mjs +119 -8
- package/scripts/enveloppe/lancer.sh +27 -32
- package/scripts/enveloppe/paquets-du-plan.mjs +2 -2
- package/scripts/enveloppe/travail-de-la-copie.mjs +99 -12
- package/scripts/etapes.mjs +6 -3
- package/scripts/faits-du-circuit.mjs +493 -0
- package/scripts/file-des-tickets.d.mts +21 -0
- package/scripts/file-des-tickets.mjs +58 -0
- package/scripts/flux-des-paquets.mjs +187 -0
- package/scripts/fusion-du-changelog.mjs +0 -1
- package/scripts/gardes-du-cadre.mjs +12 -2
- package/scripts/grillhouse-maj.mjs +16 -7
- package/scripts/integration/file.mjs +477 -422
- package/scripts/integration/integrer.mjs +20 -22
- package/scripts/integration/rejeu.mjs +19 -4
- package/scripts/jointure.d.ts +168 -28
- package/scripts/langages/cargo/commandes.mjs +426 -119
- package/scripts/langages/cargo/composants.mjs +187 -3
- package/scripts/langages/cargo/exemples.mjs +75 -17
- package/scripts/langages/cargo/index.mjs +32 -13
- package/scripts/langages/cargo/migrations/0.28.4-tailles-des-tests.mjs +35 -0
- package/scripts/langages/cargo/sccache.mjs +62 -16
- 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 +232 -79
- package/scripts/langages/python/composants.mjs +65 -3
- package/scripts/langages/python/exemples.mjs +21 -12
- package/scripts/langages/python/index.mjs +25 -5
- package/scripts/langages/python/lot.mjs +1 -36
- package/scripts/langages/python/squelette.mjs +119 -17
- package/scripts/langages/typescript/construire.mjs +6 -163
- package/scripts/langages/typescript/exemples.mjs +19 -11
- package/scripts/langages/typescript/frontieres.mjs +1 -1
- package/scripts/langages/typescript/index.mjs +48 -63
- package/scripts/langages/typescript/interfaces-contre-code.mjs +4 -4
- package/scripts/langages/typescript/migrations/0.30.0-prefixe-des-tickets.mjs +63 -0
- package/scripts/langages/typescript/migrations/0.30.0-tailles-des-outils-lourds.mjs +31 -0
- package/scripts/langages/typescript/migrations/0.30.0-titres-nommant-un-ticket.mjs +40 -0
- package/scripts/langages/typescript/mise-a-jour.mjs +1 -2
- package/scripts/langages/typescript/regle-des-tests.mjs +13 -0
- package/scripts/langages/typescript/squelette.mjs +18 -2
- package/scripts/langages/typescript/tailles-des-tests.mjs +40 -9
- package/scripts/langages/typescript/tests-de-nuit.mjs +44 -21
- package/scripts/langages/typescript/tests.mjs +17 -8
- package/scripts/langages/typescript/titres-de-tests.mjs +297 -0
- package/scripts/langages/typescript/turbo-des-paquets.mjs +183 -38
- package/scripts/langages/typescript/verdict.mjs +1 -1
- package/scripts/langages/typescript/verifier.mjs +110 -296
- package/scripts/langages/typescript/vitest-config/base.mjs +30 -10
- package/scripts/langages/typescript/vitest-config/bornes.mjs +13 -0
- package/scripts/langages/typescript/vitest-config/cibles.mjs +123 -62
- package/scripts/langages/typescript/vitest-config/delais.mjs +54 -0
- package/scripts/langages/typescript/vitest-config/delais.setup.mjs +11 -0
- package/scripts/langages/typescript/vitest-config/duree.classement.mjs +100 -0
- package/scripts/langages/typescript/vitest-config/duree.reporter.mjs +56 -64
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +7 -2
- package/scripts/langages/typescript/vitest-config/mesure.mjs +3 -2
- package/scripts/langages/typescript/vitest.nuit.config.mjs +22 -13
- package/scripts/lecture-unique.mjs +51 -0
- package/scripts/mesure/pression.mjs +11 -9
- package/scripts/mesure-de-la-machine.d.mts +21 -0
- package/scripts/mesure-de-la-machine.mjs +76 -0
- package/scripts/migrations/0.23.2-copies-du-cadre.mjs +8 -2
- package/scripts/migrations/0.30.0-ci-appelle-la-verification.mjs +120 -0
- package/scripts/migrations/0.31.0-paquets-dans-le-graphe.mjs +81 -0
- package/scripts/migrations.mjs +5 -0
- package/scripts/nuit.sh +29 -15
- package/scripts/outil.mjs +72 -0
- package/scripts/outils-cles.d.mts +24 -0
- package/scripts/outils-cles.mjs +0 -1
- package/scripts/paquet-npm.mjs +147 -0
- package/scripts/paquet.mjs +112 -14
- package/scripts/paquets.mjs +34 -6
- package/scripts/passe-de-la-machine.mjs +66 -0
- package/scripts/places-de-la-machine.mjs +360 -0
- package/scripts/places-du-serveur.mjs +170 -0
- package/scripts/prefixe-des-tickets.mjs +68 -0
- package/scripts/preparation.mjs +10 -3
- package/scripts/registre.mjs +3 -2
- package/scripts/regles-des-places.d.mts +36 -0
- package/scripts/regles-des-places.mjs +70 -0
- package/scripts/reponses-du-circuit.d.mts +6 -0
- package/scripts/reponses-du-circuit.mjs +28 -0
- package/scripts/resultats.mjs +29 -14
- package/scripts/retirer-les-copies-finies.mjs +25 -0
- package/scripts/sans-reponse.d.mts +4 -0
- package/scripts/sans-reponse.mjs +13 -0
- package/scripts/seances.mjs +918 -0
- package/scripts/services-du-noyau.mjs +28 -11
- package/scripts/session-start.sh +10 -1
- package/scripts/sortie.mjs +23 -4
- package/scripts/sources.mjs +3 -3
- package/scripts/sous-commandes.mjs +39 -9
- package/scripts/style-a-l-ecriture.mjs +229 -0
- package/scripts/superviseur.mjs +382 -16
- package/scripts/tableau.mjs +329 -130
- package/scripts/taches-du-graphe.mjs +328 -0
- package/scripts/ticket-du-circuit.mjs +206 -0
- package/scripts/transitions.d.mts +148 -0
- package/scripts/transitions.mjs +901 -0
- package/scripts/verrou-de-fichier.mjs +2 -2
- package/scripts/verrou-de-machine.mjs +322 -62
- package/skills/developpeur/SKILL.md +11 -3
- package/skills/explorateur/SKILL.md +2 -1
- package/skills/pitmaster/SKILL.md +62 -28
- package/skills/pitmaster/references/consigne-agent.md +5 -1
- package/skills/release/SKILL.md +3 -3
- package/skills/relecteur/SKILL.md +22 -8
- package/skills/testwriter/SKILL.md +47 -39
- package/scripts/demon.mjs +0 -138
- package/scripts/integration/file-attente.mjs +0 -61
- package/scripts/langages/cargo/touches.mjs +0 -93
- package/scripts/langages/typescript/script-des-tests.mjs +0 -6
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The types of ./aiguillage.mjs, for the frame's TypeScript (src/temporal/installation.ts) and its
|
|
2
|
+
// tests.
|
|
3
|
+
|
|
4
|
+
/** The key of the project's package.json that names its version of the frame. */
|
|
5
|
+
export const CLE: string;
|
|
6
|
+
/** The name of the frame's package. */
|
|
7
|
+
export const NOM_DU_PAQUET: string;
|
|
8
|
+
/** A version x.y.z. */
|
|
9
|
+
export const X_Y_Z: RegExp;
|
|
10
|
+
/** The subcommands of the orchestration, which the published version runs. */
|
|
11
|
+
export const REDIRIGEES: Set<string>;
|
|
12
|
+
/** The subcommands of the code that runs, the ticket's copy for a session of the circuit. */
|
|
13
|
+
export const DU_CODE_EN_COURS: Set<string>;
|
|
14
|
+
/** The tools of the repository. */
|
|
15
|
+
export const OUTILS_DU_DEPOT: Set<string>;
|
|
16
|
+
|
|
17
|
+
/** The cache of the versions installed under the home <maison>, ~/.cache/grillhouse/outil by default. */
|
|
18
|
+
export function cacheDesOutils(maison?: string): string;
|
|
19
|
+
/** The folder of the version <version> under <cache>. */
|
|
20
|
+
export function dossierDeLOutil(version: string, cache?: string): string;
|
|
21
|
+
/** The version the project at <racine> names, or null; throws on a value that is no version. */
|
|
22
|
+
export function versionDeLOutil(racine?: string): string | null;
|
|
23
|
+
/** Where the subcommand <nom> runs in the project at <racine>, or null for the code that runs. */
|
|
24
|
+
export function aiguillage(
|
|
25
|
+
nom: string,
|
|
26
|
+
options?: { racine?: string; cache?: string; paquet?: string }
|
|
27
|
+
): { version: string; dossier: string; commande: string } | null;
|
|
28
|
+
/** The failed installation of the version the project at <racine> names, or null. */
|
|
29
|
+
export function echecDeLOutil(
|
|
30
|
+
racine?: string,
|
|
31
|
+
options?: { cache?: string }
|
|
32
|
+
): { version: string; raison: string; date: string } | null;
|
|
33
|
+
/** Installs the published version <version> under <cache>: its folder, and whether it laid it down. */
|
|
34
|
+
export function installer(
|
|
35
|
+
version: string,
|
|
36
|
+
options?: { cache?: string; npm?: string; retenue?: number }
|
|
37
|
+
): { dossier: string; installe: boolean };
|
|
@@ -0,0 +1,328 @@
|
|
|
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, 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
|
+
'integrer',
|
|
67
|
+
'lancer',
|
|
68
|
+
'ligne-etat',
|
|
69
|
+
'nuit',
|
|
70
|
+
'registre',
|
|
71
|
+
'resultats',
|
|
72
|
+
'retirer-copie',
|
|
73
|
+
'session-start',
|
|
74
|
+
'structure-guard',
|
|
75
|
+
'superviseur',
|
|
76
|
+
'tableau',
|
|
77
|
+
'ticket-du-sous-agent',
|
|
78
|
+
'verrou',
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The subcommands that play the code of the copy: the tests, the verification, the guards, the
|
|
83
|
+
* temporary folder, the git hooks and the merge driver, the affected components; the commands of
|
|
84
|
+
* the modules of language too, which are no subcommand of the core.
|
|
85
|
+
*/
|
|
86
|
+
export const DU_CODE_EN_COURS = new Set([
|
|
87
|
+
'composants-affectes',
|
|
88
|
+
'dependances-internes',
|
|
89
|
+
'flux-des-paquets',
|
|
90
|
+
'fusion-du-changelog',
|
|
91
|
+
'gardes-du-cadre',
|
|
92
|
+
'hook',
|
|
93
|
+
'hooks',
|
|
94
|
+
'langages-des-paquets',
|
|
95
|
+
'style-a-l-ecriture',
|
|
96
|
+
'temporaire',
|
|
97
|
+
'tests',
|
|
98
|
+
'verifier',
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
/** The tools of the repository, which run its code: creation, update, release, installation. */
|
|
102
|
+
export const OUTILS_DU_DEPOT = new Set([
|
|
103
|
+
'greffons',
|
|
104
|
+
'init',
|
|
105
|
+
'maj',
|
|
106
|
+
'outil',
|
|
107
|
+
'paquet',
|
|
108
|
+
'pression',
|
|
109
|
+
'sortie',
|
|
110
|
+
'sous-modules',
|
|
111
|
+
'temporal',
|
|
112
|
+
'ticket',
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
// How long a failed installation is kept: within it, a launch runs no npm again.
|
|
116
|
+
const RETENUE_MS = 5 * 60 * 1000;
|
|
117
|
+
|
|
118
|
+
// The cache of the published versions: ~/.cache/grillhouse/outil.
|
|
119
|
+
export const cacheDesOutils = (maison = os.homedir()) =>
|
|
120
|
+
path.join(maison, '.cache', 'grillhouse', 'outil');
|
|
121
|
+
|
|
122
|
+
/** The folder of the version <version> under <cache>. */
|
|
123
|
+
export const dossierDeLOutil = (version, cache = cacheDesOutils()) => path.join(cache, version);
|
|
124
|
+
|
|
125
|
+
// The command of the version installed in <dossier>.
|
|
126
|
+
const commandeDans = dossier =>
|
|
127
|
+
path.join(dossier, 'node_modules', NOM_DU_PAQUET, 'bin', 'grillhouse.mjs');
|
|
128
|
+
|
|
129
|
+
const realpath = p => {
|
|
130
|
+
try {
|
|
131
|
+
return realpathSync(p);
|
|
132
|
+
} catch {
|
|
133
|
+
return p;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* The version the project at <racine> names (`grillhouse.outil` of its package.json), or null.
|
|
139
|
+
* @param {string} [racine]
|
|
140
|
+
* @returns {string | null}
|
|
141
|
+
* @throws {Error} a value that is no version x.y.z, named by its key
|
|
142
|
+
*/
|
|
143
|
+
export function versionDeLOutil(racine = process.cwd()) {
|
|
144
|
+
let pkg;
|
|
145
|
+
try {
|
|
146
|
+
pkg = JSON.parse(readFileSync(path.join(racine, 'package.json'), 'utf8'));
|
|
147
|
+
} catch {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const v = pkg?.grillhouse?.outil;
|
|
151
|
+
if (v === undefined || v === null) return null;
|
|
152
|
+
if (typeof v !== 'string' || !X_Y_Z.test(v)) {
|
|
153
|
+
throw new Error(`la clé ${CLE} vaut ${JSON.stringify(v)}, pas une version x.y.z.`);
|
|
154
|
+
}
|
|
155
|
+
return v;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Where the subcommand <nom> runs in the project at <racine>: `{ version, dossier, commande }`, the
|
|
160
|
+
* version of the key and its command under <cache>, for a subcommand of the orchestration that the
|
|
161
|
+
* package <paquet> (the one that runs) is not; null otherwise (see the header).
|
|
162
|
+
* @param {string} nom
|
|
163
|
+
* @param {{ racine?: string, cache?: string, paquet?: string }} [options]
|
|
164
|
+
* @returns {{ version: string, dossier: string, commande: string } | null}
|
|
165
|
+
*/
|
|
166
|
+
export function aiguillage(
|
|
167
|
+
nom,
|
|
168
|
+
{ racine = process.cwd(), cache = cacheDesOutils(), paquet = PAQUET_QUI_TOURNE } = {}
|
|
169
|
+
) {
|
|
170
|
+
if (!REDIRIGEES.has(nom)) return null;
|
|
171
|
+
const version = versionDeLOutil(racine);
|
|
172
|
+
if (version === null) return null;
|
|
173
|
+
const dossier = dossierDeLOutil(version, cache);
|
|
174
|
+
const commande = commandeDans(dossier);
|
|
175
|
+
if (realpath(paquet) === realpath(path.resolve(path.dirname(commande), '..'))) return null;
|
|
176
|
+
return { version, dossier, commande };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// The state file of the failed installation of <version> under <cache>.
|
|
180
|
+
const fichierDEchec = (version, cache) => `${dossierDeLOutil(version, cache)}.echec`;
|
|
181
|
+
|
|
182
|
+
// The failure the state file <f> holds, `{ date, raison }`, or null.
|
|
183
|
+
function lireLEchec(f) {
|
|
184
|
+
try {
|
|
185
|
+
const e = JSON.parse(readFileSync(f, 'utf8'));
|
|
186
|
+
return typeof e?.raison === 'string' && !Number.isNaN(Date.parse(e?.date)) ? e : null;
|
|
187
|
+
} catch {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The failed installation of the version the project at <racine> names: `{ version, raison, date }`
|
|
194
|
+
* while its state file stands (written at each failure, removed at the first installation that
|
|
195
|
+
* succeeds), which the session's start and the board say; null otherwise, or without the key. A
|
|
196
|
+
* state file beside the version installed (a failure written after another launch succeeded) is
|
|
197
|
+
* removed, and gives null.
|
|
198
|
+
* @param {string} [racine]
|
|
199
|
+
* @param {{ cache?: string }} [options]
|
|
200
|
+
* @returns {{ version: string, raison: string, date: string } | null}
|
|
201
|
+
*/
|
|
202
|
+
export function echecDeLOutil(racine = process.cwd(), { cache = cacheDesOutils() } = {}) {
|
|
203
|
+
let version;
|
|
204
|
+
try {
|
|
205
|
+
version = versionDeLOutil(racine);
|
|
206
|
+
} catch {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
if (version === null) return null;
|
|
210
|
+
const f = fichierDEchec(version, cache);
|
|
211
|
+
// A failure written after another launch installed the version: the version stands.
|
|
212
|
+
if (existsSync(commandeDans(dossierDeLOutil(version, cache)))) {
|
|
213
|
+
rmSync(f, { force: true });
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
const e = lireLEchec(f);
|
|
217
|
+
return e && { version, raison: e.raison, date: e.date };
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// The pids of the folders of installation (`<version>.installation-<pid>`) under <cache>, each of a
|
|
221
|
+
// process that has ended removed.
|
|
222
|
+
function balayer(cache) {
|
|
223
|
+
let entrees = [];
|
|
224
|
+
try {
|
|
225
|
+
entrees = readdirSync(cache);
|
|
226
|
+
} catch {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
for (const e of entrees) {
|
|
230
|
+
const pid = Number(/\.installation-(\d+)$/.exec(e)?.[1]);
|
|
231
|
+
if (pid && !vivant(pid)) rmSync(path.join(cache, e), { recursive: true, force: true });
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const vivant = pid => {
|
|
236
|
+
try {
|
|
237
|
+
process.kill(pid, 0);
|
|
238
|
+
return true;
|
|
239
|
+
} catch (e) {
|
|
240
|
+
return e.code === 'EPERM';
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
// Runs npm install of <specs> under <prefixe>, its output on the error stream; throws the reason
|
|
245
|
+
// of a failure: npm's last line, or its code.
|
|
246
|
+
function npmInstall(npm, prefixe, specs) {
|
|
247
|
+
const r = spawnSync(
|
|
248
|
+
npm,
|
|
249
|
+
['install', '--prefix', prefixe, '--no-audit', '--no-fund', '--save-exact', ...specs],
|
|
250
|
+
{ stdio: ['ignore', 2, 'pipe'], encoding: 'utf8' }
|
|
251
|
+
);
|
|
252
|
+
process.stderr.write(r.stderr ?? '');
|
|
253
|
+
if (r.status === 0) return;
|
|
254
|
+
const ligne = String(r.stderr ?? '')
|
|
255
|
+
.trim()
|
|
256
|
+
.split('\n')
|
|
257
|
+
.at(-1);
|
|
258
|
+
throw new Error(
|
|
259
|
+
`npm install ${specs.join(' ')} : ${r.error?.message || ligne || `code ${r.status}`}`
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Installs the published version <version> under <cache> (see the header), by the command <npm>:
|
|
265
|
+
* the package, then the peer dependencies it declares, at their ranges, the optional ones
|
|
266
|
+
* included, so that the tool stands alone, as a stage0 brings its library. A failure is kept
|
|
267
|
+
* <retenue> ms, within which a call runs no npm and throws it again.
|
|
268
|
+
* @param {string} version
|
|
269
|
+
* @param {{ cache?: string, npm?: string, retenue?: number }} [options]
|
|
270
|
+
* @returns {{ dossier: string, installe: boolean }} installe false when it was there
|
|
271
|
+
* @throws {Error} npm failing, the version named
|
|
272
|
+
*/
|
|
273
|
+
export function installer(
|
|
274
|
+
version,
|
|
275
|
+
{ cache = cacheDesOutils(), npm = 'npm', retenue = RETENUE_MS } = {}
|
|
276
|
+
) {
|
|
277
|
+
const dossier = dossierDeLOutil(version, cache);
|
|
278
|
+
if (existsSync(commandeDans(dossier))) return { dossier, installe: false };
|
|
279
|
+
const echec = fichierDEchec(version, cache);
|
|
280
|
+
const garde = lireLEchec(echec);
|
|
281
|
+
if (garde && Date.now() - Date.parse(garde.date) < retenue) throw new Error(garde.raison);
|
|
282
|
+
mkdirSync(cache, { recursive: true });
|
|
283
|
+
balayer(cache);
|
|
284
|
+
const chantier = `${dossier}.installation-${process.pid}`;
|
|
285
|
+
rmSync(chantier, { recursive: true, force: true });
|
|
286
|
+
mkdirSync(chantier, { recursive: true });
|
|
287
|
+
try {
|
|
288
|
+
try {
|
|
289
|
+
npmInstall(npm, chantier, [`${NOM_DU_PAQUET}@${version}`]);
|
|
290
|
+
const pkg = JSON.parse(
|
|
291
|
+
readFileSync(path.join(chantier, 'node_modules', NOM_DU_PAQUET, 'package.json'), 'utf8')
|
|
292
|
+
);
|
|
293
|
+
const pairs = Object.entries(pkg.peerDependencies ?? {}).map(([n, r]) => `${n}@${r}`);
|
|
294
|
+
if (pairs.length) npmInstall(npm, chantier, pairs);
|
|
295
|
+
if (!existsSync(commandeDans(chantier))) {
|
|
296
|
+
throw new Error(`npm n'a pas posé la commande de ${NOM_DU_PAQUET}@${version}`);
|
|
297
|
+
}
|
|
298
|
+
} catch (e) {
|
|
299
|
+
const raison = `${NOM_DU_PAQUET}@${version} : ${e.message}`;
|
|
300
|
+
writeFileSync(echec, JSON.stringify({ date: new Date().toISOString(), raison }));
|
|
301
|
+
throw new Error(raison);
|
|
302
|
+
}
|
|
303
|
+
rmSync(echec, { force: true });
|
|
304
|
+
try {
|
|
305
|
+
renameSync(chantier, dossier);
|
|
306
|
+
} catch (e) {
|
|
307
|
+
// Another launch installed it meanwhile: its folder stands.
|
|
308
|
+
if (!existsSync(commandeDans(dossier))) throw e;
|
|
309
|
+
}
|
|
310
|
+
return { dossier, installe: true };
|
|
311
|
+
} finally {
|
|
312
|
+
rmSync(chantier, { recursive: true, force: true });
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// `node aiguillage.mjs --echec [<racine>]`, which the session's start runs: the line that says the
|
|
317
|
+
// failed installation of the version of the key, nothing without one.
|
|
318
|
+
if (
|
|
319
|
+
import.meta.url === pathToFileURL(process.argv[1] ?? '').href &&
|
|
320
|
+
process.argv[2] === '--echec'
|
|
321
|
+
) {
|
|
322
|
+
const e = echecDeLOutil(process.argv[3] ?? process.cwd());
|
|
323
|
+
if (e) {
|
|
324
|
+
process.stdout.write(
|
|
325
|
+
`⚠️ 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`
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
}
|
package/scripts/avancement.mjs
CHANGED
|
@@ -4,12 +4,19 @@
|
|
|
4
4
|
//
|
|
5
5
|
// - A pass has its progress directory, which the variable GRILLHOUSE_AVANCEMENT (AVANCEMENT of
|
|
6
6
|
// scripts/mesure/avancement.mjs) names to its commands: the circuit opens one for each
|
|
7
|
-
// automatic pass
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
7
|
+
// automatic pass in its working directory, `<copie>.travail`, where the board reads it
|
|
8
|
+
// (`avancementDuTravail`), `npm run verifier` opens its own when it receives none
|
|
9
|
+
// (scripts/langages/typescript/verifier.mjs). The directory holds `passe.json` (`{ genre, debut,
|
|
10
|
+
// precedent, totaux }`: its kind, its start, the total of the previous pass of that kind, and
|
|
11
|
+
// the file of the totals where its end keeps its own), the records of its tasks (`taches/`, written by the reporter of progress of the base configuration, one
|
|
11
12
|
// per run of Vitest, and by the queue for the steps of its CI, scripts/integration/file.mjs),
|
|
12
13
|
// and the plans of its runs of Turborepo (`plan/`).
|
|
14
|
+
// - The CI of a ticket's commit is read by one act at a time, each a process of its own: its
|
|
15
|
+
// readings share one progress directory in the working directory of the ticket,
|
|
16
|
+
// `avancement-ci` (`avancementDeLaCI`), opened by the first and emptied when a reading looks
|
|
17
|
+
// for a run again (another CI, after a reopening), where the board reads the steps
|
|
18
|
+
// of the run done over planned while the circuit waits for it; the next pass of the circuit
|
|
19
|
+
// removes it with the others (`avecLAvancementDuTravail`).
|
|
13
20
|
// - The reading adds the records: the files done, and the files planned of the tasks started;
|
|
14
21
|
// while every task the plans name has not started, the total of the previous pass of the same
|
|
15
22
|
// kind stands when it is greater (a pass without a plan never knows all its tasks started).
|
|
@@ -22,20 +29,22 @@
|
|
|
22
29
|
// copies included, beside the last green (scripts/dernier-vert.mjs): `{ passes, taches }`, the
|
|
23
30
|
// total of the last pass of each kind and the files planned of each task by its hash (the
|
|
24
31
|
// latest TACHES_GARDEES); each pass keeps its own at its end (`garderLeTotal`).
|
|
25
|
-
// -
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
32
|
+
// - The holder of the lock of the machine (scripts/verrou-de-machine.mjs: a measure out of a
|
|
33
|
+
// ticket, `npm run verifier` of a supervisor or of an integration, or a heavy pass of the
|
|
34
|
+
// circuit of a ticket) names its progress directory beside the lock (`nommerLAvancement`); the
|
|
35
|
+
// board reads the holder with its progress, and the waits for the lock or for room
|
|
36
|
+
// (`lireLaMesure`).
|
|
30
37
|
import { spawnSync } from 'node:child_process';
|
|
31
38
|
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync } from 'node:fs';
|
|
32
39
|
import { tmpdir } from 'node:os';
|
|
33
40
|
import path from 'node:path';
|
|
34
|
-
import { ecrireAtomique, TACHES } from './mesure/avancement.mjs';
|
|
35
|
-
import {
|
|
41
|
+
import { AVANCEMENT, ecrireAtomique, TACHES } from './mesure/avancement.mjs';
|
|
42
|
+
import { lireLeVerrou } from './verrou-de-machine.mjs';
|
|
36
43
|
|
|
37
44
|
const PASSE = 'passe.json';
|
|
38
45
|
const PLAN = 'plan';
|
|
46
|
+
// The name of a progress directory starts so (`ouvrirAvancement`).
|
|
47
|
+
const PREFIXE = 'avancement-';
|
|
39
48
|
const TACHES_GARDEES = 2_000;
|
|
40
49
|
|
|
41
50
|
const lireJson = f => {
|
|
@@ -64,21 +73,26 @@ function fichierDesTotaux(racine) {
|
|
|
64
73
|
);
|
|
65
74
|
return r.status === 0 ? path.join(r.stdout.trim(), 'grillhouse', 'avancement.json') : null;
|
|
66
75
|
}
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
// The totals read in the file <f>, empty without one.
|
|
77
|
+
const totauxDe = f => {
|
|
69
78
|
const t = f ? lireJson(f) : null;
|
|
70
79
|
return { fichier: f, passes: t?.passes ?? {}, taches: t?.taches ?? {} };
|
|
71
80
|
};
|
|
81
|
+
// The totals of the repository at <racine>.
|
|
82
|
+
const lireLesTotaux = racine => totauxDe(fichierDesTotaux(racine));
|
|
72
83
|
|
|
73
84
|
/**
|
|
74
85
|
* Opens the progress directory of a pass of kind <genre> (null: a pass whose total is not kept)
|
|
75
|
-
* in the repository at <racine>, made under <dans>, its start <debut>; its path.
|
|
86
|
+
* in the repository at <racine>, made under <dans>, its start <debut>; its path. The file of the
|
|
87
|
+
* totals is resolved now and kept in `passe.json` (`totaux`): the integration removes the ticket's
|
|
88
|
+
* copy before its pass ends, and its total goes to the same repository.
|
|
76
89
|
* @param {{ racine: string, genre?: string | null, dans?: string, debut?: number }} o
|
|
77
90
|
*/
|
|
78
91
|
export function ouvrirAvancement({ racine, genre = null, dans = tmpdir(), debut = Date.now() }) {
|
|
79
|
-
const dossier = mkdtempSync(path.join(dans,
|
|
80
|
-
const
|
|
81
|
-
|
|
92
|
+
const dossier = mkdtempSync(path.join(dans, PREFIXE));
|
|
93
|
+
const totaux = lireLesTotaux(racine);
|
|
94
|
+
const precedent = genre ? (totaux.passes[genre] ?? null) : null;
|
|
95
|
+
ecrireAtomique(path.join(dossier, PASSE), { genre, debut, precedent, totaux: totaux.fichier });
|
|
82
96
|
return dossier;
|
|
83
97
|
}
|
|
84
98
|
|
|
@@ -154,16 +168,114 @@ export function lireAvancement(dossier) {
|
|
|
154
168
|
return { faits, prevus, debut, dernier };
|
|
155
169
|
}
|
|
156
170
|
|
|
171
|
+
/**
|
|
172
|
+
* The progress of the pass under way in the working directory <travail> of a circuit, where each
|
|
173
|
+
* automatic pass of the circuit opens its progress directory (`avecLAvancementDuTravail`, one
|
|
174
|
+
* pass at a time): the latest started that reads, null without one.
|
|
175
|
+
* @param {string} travail
|
|
176
|
+
* @returns {{ faits: number, prevus: number, debut: number, dernier: number } | null}
|
|
177
|
+
*/
|
|
178
|
+
export function avancementDuTravail(travail) {
|
|
179
|
+
let noms = [];
|
|
180
|
+
try {
|
|
181
|
+
noms = readdirSync(travail).filter(f => f.startsWith(PREFIXE));
|
|
182
|
+
} catch {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
return (
|
|
186
|
+
noms
|
|
187
|
+
.map(f => lireAvancement(path.join(travail, f)))
|
|
188
|
+
.filter(Boolean)
|
|
189
|
+
.sort((a, b) => b.debut - a.debut)[0] ?? null
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The progress directory of the readings of the CI of a ticket's commit, in the working directory
|
|
195
|
+
* <travail> of its circuit, where the board reads it (`avancementDuTravail`): one for all its
|
|
196
|
+
* readings, opened by the first, emptied when <nouvelle> (a reading that looks for its run, the
|
|
197
|
+
* records of another run gone); null when the circuit has no working directory.
|
|
198
|
+
* @param {string} travail
|
|
199
|
+
* @param {{ nouvelle?: boolean, debut?: number }} [o]
|
|
200
|
+
* @returns {string | null}
|
|
201
|
+
*/
|
|
202
|
+
export function avancementDeLaCI(travail, { nouvelle = false, debut = Date.now() } = {}) {
|
|
203
|
+
if (!existsSync(travail)) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
const dossier = path.join(travail, `${PREFIXE}ci`);
|
|
207
|
+
try {
|
|
208
|
+
if (nouvelle) {
|
|
209
|
+
rmSync(dossier, { recursive: true, force: true });
|
|
210
|
+
}
|
|
211
|
+
if (!existsSync(path.join(dossier, PASSE))) {
|
|
212
|
+
mkdirSync(dossier, { recursive: true });
|
|
213
|
+
ecrireAtomique(path.join(dossier, PASSE), { genre: null, debut, precedent: null });
|
|
214
|
+
}
|
|
215
|
+
} catch {
|
|
216
|
+
// A directory that does not write leaves the queue going, without its progress.
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
return dossier;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Runs <passe> under a progress directory of the kind <genre> (null: none kept) opened in the
|
|
224
|
+
* working directory <travail> of a ticket's circuit, where the board reads it
|
|
225
|
+
* (`avancementDuTravail`): each automatic pass of the circuit (scripts/activites.mjs) and the
|
|
226
|
+
* replay of the ticket's branch by the queue (scripts/faits-du-circuit.mjs `avancer`), one pass at
|
|
227
|
+
* a time. The directories a killed pass left there go first, a lot that goes through the queue
|
|
228
|
+
* again included. The directory is given to <passe> and named to it and its children by
|
|
229
|
+
* GRILLHOUSE_AVANCEMENT (`AVANCEMENT`); then its total is kept in the repository at <racine> and
|
|
230
|
+
* it is removed, unless <garder> holds for what <passe> returns: a lot entered on main keeps it
|
|
231
|
+
* until the queue is done with the ticket closed, which removes the working directory whole
|
|
232
|
+
* (`retirerLeTravail` of scripts/integration/file.mjs), as the circuit kept its progress for its
|
|
233
|
+
* whole step of the queue. Without the working directory, <passe> runs without one (null).
|
|
234
|
+
* Returns what <passe> returns.
|
|
235
|
+
* @template T
|
|
236
|
+
* @param {string} travail
|
|
237
|
+
* @param {{ racine: string, genre: string | null, garder?: (valeur: T) => boolean }} o
|
|
238
|
+
* @param {(dossier: string | null) => T} passe
|
|
239
|
+
* @returns {T}
|
|
240
|
+
*/
|
|
241
|
+
export function avecLAvancementDuTravail(travail, { racine, genre, garder = () => false }, passe) {
|
|
242
|
+
if (!existsSync(travail)) {
|
|
243
|
+
return passe(null);
|
|
244
|
+
}
|
|
245
|
+
for (const f of readdirSync(travail).filter(n => n.startsWith(PREFIXE))) {
|
|
246
|
+
rmSync(path.join(travail, f), { recursive: true, force: true });
|
|
247
|
+
}
|
|
248
|
+
const dossier = ouvrirAvancement({ racine, genre, dans: travail });
|
|
249
|
+
const avant = process.env[AVANCEMENT];
|
|
250
|
+
process.env[AVANCEMENT] = dossier;
|
|
251
|
+
let garde = false;
|
|
252
|
+
try {
|
|
253
|
+
const valeur = passe(dossier);
|
|
254
|
+
garde = garder(valeur);
|
|
255
|
+
return valeur;
|
|
256
|
+
} finally {
|
|
257
|
+
if (avant === undefined) {
|
|
258
|
+
delete process.env[AVANCEMENT];
|
|
259
|
+
} else {
|
|
260
|
+
process.env[AVANCEMENT] = avant;
|
|
261
|
+
}
|
|
262
|
+
garderLeTotal(dossier);
|
|
263
|
+
if (!garde) {
|
|
264
|
+
rmSync(dossier, { recursive: true, force: true });
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
157
269
|
/**
|
|
158
270
|
* Keeps, at the end of the pass whose directory is <dossier>, its total under its kind and the
|
|
159
|
-
* files planned of each task it played, in the totals
|
|
271
|
+
* files planned of each task it played, in the totals its opening named (`totaux` of its
|
|
272
|
+
* `passe.json`); none out of git.
|
|
160
273
|
* @param {string} dossier
|
|
161
|
-
* @param {string} racine
|
|
162
274
|
*/
|
|
163
|
-
export function garderLeTotal(dossier
|
|
275
|
+
export function garderLeTotal(dossier) {
|
|
164
276
|
const passe = lireJson(path.join(dossier, PASSE));
|
|
165
277
|
if (!passe) return;
|
|
166
|
-
const t =
|
|
278
|
+
const t = totauxDe(passe.totaux ?? null);
|
|
167
279
|
if (!t.fichier) return;
|
|
168
280
|
const liste = enregistrements(dossier);
|
|
169
281
|
if (passe.genre && liste.length) t.passes[passe.genre] = liste.reduce((s, e) => s + e.prevus, 0);
|
|
@@ -180,51 +292,34 @@ export function garderLeTotal(dossier, racine) {
|
|
|
180
292
|
}
|
|
181
293
|
}
|
|
182
294
|
|
|
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
295
|
/**
|
|
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.
|
|
296
|
+
* Who holds the lock of the machine under <env> and who waits for it, as the board shows them
|
|
297
|
+
* (scripts/tableau.mjs): `detenteur`, its repository (`depot`, the root of its main tree, and
|
|
298
|
+
* `projet`, its folder), ticket, kind, since when and progress
|
|
299
|
+
* (`avancement`, its files done and planned and its last sign; null while it names no progress
|
|
300
|
+
* directory, or that directory does not read), null when the lock is free or its process gone;
|
|
301
|
+
* `attentes`, each live wait, the oldest first, its project, ticket, kind, what it waits for
|
|
302
|
+
* (`quoi`) and since when (`lireLeVerrou` of scripts/verrou-de-machine.mjs).
|
|
221
303
|
* @param {Record<string, string | undefined>} [env]
|
|
222
304
|
*/
|
|
223
305
|
export function lireLaMesure(env = process.env) {
|
|
224
|
-
const {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
306
|
+
const { detenteur: d, attentes } = lireLeVerrou(env);
|
|
307
|
+
return {
|
|
308
|
+
detenteur: d && {
|
|
309
|
+
depot: d.depot,
|
|
310
|
+
projet: d.projet,
|
|
311
|
+
ticket: d.ticket,
|
|
312
|
+
sorte: d.sorte,
|
|
313
|
+
depuis: d.depuis,
|
|
314
|
+
avancement: typeof d.dossier === 'string' ? lireAvancement(d.dossier) : null,
|
|
315
|
+
},
|
|
316
|
+
attentes: attentes.map(({ depot, projet, ticket, sorte, quoi, depuis }) => ({
|
|
317
|
+
depot,
|
|
318
|
+
projet,
|
|
319
|
+
ticket,
|
|
320
|
+
sorte,
|
|
321
|
+
quoi,
|
|
322
|
+
depuis,
|
|
323
|
+
})),
|
|
324
|
+
};
|
|
230
325
|
}
|