@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,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The installation of the published version that leads the frame's repository
|
|
3
|
+
// (scripts/aiguillage.mjs, the key `grillhouse.outil`, the cache, the switch).
|
|
4
|
+
//
|
|
5
|
+
// npx grillhouse outil installs the version the key names, nothing when it is there
|
|
6
|
+
// npx grillhouse outil <x.y.z> writes the key, then installs that version
|
|
7
|
+
//
|
|
8
|
+
// - The key is written in the package.json of the working directory, its other fields and its
|
|
9
|
+
// indentation kept; a version is installed under ~/.cache/grillhouse/outil/<version>/.
|
|
10
|
+
// - Without the key and without a version, the command says so, exit 2; a faulty key or argument
|
|
11
|
+
// too; a failed installation, exit 1. Changing the published version is this one gesture, which
|
|
12
|
+
// the release proposes (`grillhouse sortie --etiqueter`).
|
|
13
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import { pathToFileURL } from 'node:url';
|
|
16
|
+
import { CLE, installer, NOM_DU_PAQUET, versionDeLOutil, X_Y_Z } from './aiguillage.mjs';
|
|
17
|
+
|
|
18
|
+
// Writes <version> as the key of the package.json at <racine>, its other fields and its
|
|
19
|
+
// indentation kept.
|
|
20
|
+
function ecrireLaCle(racine, version) {
|
|
21
|
+
const f = path.join(racine, 'package.json');
|
|
22
|
+
const texte = readFileSync(f, 'utf8');
|
|
23
|
+
const pkg = JSON.parse(texte);
|
|
24
|
+
pkg.grillhouse = { ...(pkg.grillhouse ?? {}), outil: version };
|
|
25
|
+
const retrait = /^\{\n([ \t]+)/.exec(texte)?.[1] ?? ' ';
|
|
26
|
+
writeFileSync(f, `${JSON.stringify(pkg, null, retrait)}\n`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const USAGE = 'Usage : npx grillhouse outil [<x.y.z>]\n';
|
|
30
|
+
|
|
31
|
+
// The version to install in <racine>: <args>[0] written as the key, else the key's; the exit code
|
|
32
|
+
// 2 and its message for a faulty argument or key, or a key absent.
|
|
33
|
+
function versionAInstaller(racine, args) {
|
|
34
|
+
if (args.length > 1 || (args[0] !== undefined && !X_Y_Z.test(args[0]))) {
|
|
35
|
+
return { refus: USAGE };
|
|
36
|
+
}
|
|
37
|
+
if (!existsSync(path.join(racine, 'package.json'))) {
|
|
38
|
+
return {
|
|
39
|
+
refus: `⛔ grillhouse outil : aucun package.json dans ${racine} ; la clé ${CLE} s'écrit au package.json racine du dépôt.\n`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (args[0] !== undefined) ecrireLaCle(racine, args[0]);
|
|
43
|
+
try {
|
|
44
|
+
const version = versionDeLOutil(racine);
|
|
45
|
+
return version === null
|
|
46
|
+
? {
|
|
47
|
+
refus: `⛔ la clé ${CLE} manque au package.json : \`npx grillhouse outil <x.y.z>\` l'écrit et installe la version.\n`,
|
|
48
|
+
}
|
|
49
|
+
: { version };
|
|
50
|
+
} catch (e) {
|
|
51
|
+
return { refus: `⛔ grillhouse outil : ${e.message}\n` };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
|
|
56
|
+
const { version, refus } = versionAInstaller(process.cwd(), process.argv.slice(2));
|
|
57
|
+
if (refus) {
|
|
58
|
+
process.stderr.write(refus);
|
|
59
|
+
process.exitCode = 2;
|
|
60
|
+
} else {
|
|
61
|
+
try {
|
|
62
|
+
// Asked by hand: a failure kept by a launch does not stop it.
|
|
63
|
+
const r = installer(version, { retenue: 0 });
|
|
64
|
+
process.stdout.write(
|
|
65
|
+
`✓ ${NOM_DU_PAQUET}@${version} ${r.installe ? 'installé' : 'déjà installé'} sous ${r.dossier}.\n`
|
|
66
|
+
);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
process.stderr.write(`⛔ grillhouse outil : ${e.message}\n`);
|
|
69
|
+
process.exitCode = 1;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// The types of ./outils-cles.mjs, for the frame's TypeScript (src/temporal/installation.ts) and
|
|
2
|
+
// its tests.
|
|
3
|
+
|
|
4
|
+
/** The tools of the package.json <pkg> (`grillhouse.outils`), each path resolved, and its faults. */
|
|
5
|
+
export function lireOutils(
|
|
6
|
+
pkg: unknown,
|
|
7
|
+
options?: {
|
|
8
|
+
maison?: string;
|
|
9
|
+
existe?: (p: string) => boolean;
|
|
10
|
+
reel?: (p: string) => string;
|
|
11
|
+
montages?: string[];
|
|
12
|
+
}
|
|
13
|
+
): { outils: Record<string, string>; fautes: string[] };
|
|
14
|
+
/** The main tree of the repository that holds <dir>. */
|
|
15
|
+
export function arbrePrincipal(dir: string): string;
|
|
16
|
+
/** The tools of the project that holds <dir>; throws the faults of the key. */
|
|
17
|
+
export function outilsDe(dir: string, options?: { montages?: string[] }): Record<string, string>;
|
|
18
|
+
/** The environment <env> of a pass with the tools <outils>, the tools winning. */
|
|
19
|
+
export function avecLesOutils<T extends Record<string, string | undefined>>(
|
|
20
|
+
outils: Record<string, string>,
|
|
21
|
+
env: T
|
|
22
|
+
): T & Record<string, string>;
|
|
23
|
+
/** The shell's text that exports the tools <outils>, one line each. */
|
|
24
|
+
export function exportsDesOutils(outils: Record<string, string>): string;
|
package/scripts/outils-cles.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
1
|
// The reading of the `grillhouse.outils` key of a package.json, the tools of the project, as Bazel
|
|
3
2
|
// declares what an action sees out of its sandbox (--sandbox_add_mount_pair) and the environment
|
|
4
3
|
// it gets (--action_env): `{ "<VARIABLE>": "<chemin>" }`, each path absolute or under `~`. The
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// The package.json of a package of a language other than TypeScript (a crate, a project of Python):
|
|
2
|
+
// the entry by which it enters the graph of Turborepo, which reads a `package.json` beside each
|
|
3
|
+
// project that is no JavaScript (node_modules/turbo/docs/guides/multi-language.mdx:191), as Turborepo's
|
|
4
|
+
// own example of Rust writes one beside the crate. `grillhouse paquet` writes it with the package
|
|
5
|
+
// (./paquet.mjs), and the migration of 0.31.0 for the packages of an existing project
|
|
6
|
+
// (./migrations/0.31.0-paquets-dans-le-graphe.mjs).
|
|
7
|
+
//
|
|
8
|
+
// - Its name is the manifest's: the `name` of the `[package]` of a Cargo.toml, of the `[project]`
|
|
9
|
+
// of a pyproject.toml.
|
|
10
|
+
// - Its scripts call the commands of the package's module on its path, from the root of the
|
|
11
|
+
// project, where the module plays: `build` the module's `construire`, `test:unit` its
|
|
12
|
+
// `tests-du-paquet` (the body of the task, which never runs Turborepo: its `tests` does, and
|
|
13
|
+
// would loop), `typecheck` its `typer`.
|
|
14
|
+
// - The entry of its folder in the `workspaces` of the root package.json: none for a folder the
|
|
15
|
+
// patterns already select; else its path, after the pattern `!` that takes it out when one does.
|
|
16
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
17
|
+
import path from 'node:path';
|
|
18
|
+
import { LANGAGES, langage, langagesDeclares } from './langages.mjs';
|
|
19
|
+
import { selectionne } from './paquets.mjs';
|
|
20
|
+
import { hors } from './sources.mjs';
|
|
21
|
+
import {
|
|
22
|
+
colonneDesNoms,
|
|
23
|
+
langageDeLaCellule,
|
|
24
|
+
nomme,
|
|
25
|
+
nomsDe,
|
|
26
|
+
tableauxDesComposants,
|
|
27
|
+
} from './tableau-des-composants.mjs';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The languages of the frame whose package has no package.json of its own, the ones whose manifest
|
|
31
|
+
* is another file: the package.json is written beside that manifest.
|
|
32
|
+
*/
|
|
33
|
+
export const sansPackageJson = () =>
|
|
34
|
+
Object.keys(LANGAGES).filter(n => langage(n).manifeste !== 'package.json');
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The name the manifest <texte> of the language <langageNom> gives its package; null for none
|
|
38
|
+
* (the module of the language reads it).
|
|
39
|
+
* @param {string} langageNom
|
|
40
|
+
* @param {string} texte
|
|
41
|
+
*/
|
|
42
|
+
export const nomDuManifeste = (langageNom, texte) => langage(langageNom).nomDuManifeste(texte);
|
|
43
|
+
|
|
44
|
+
// The folders under <dossier> that hold <manifeste>, as `{ dossier, nom, paquet }` (the component
|
|
45
|
+
// shape of the tables), <dossier> itself left out; hidden folders and the ones the sources of the
|
|
46
|
+
// project leave out are not walked.
|
|
47
|
+
function avecManifeste(dossier, manifeste, langageNom, exclus) {
|
|
48
|
+
const out = [];
|
|
49
|
+
for (const e of readdirSync(dossier, { withFileTypes: true })) {
|
|
50
|
+
if (!e.isDirectory() || e.name.startsWith('.') || exclus.has(e.name)) continue;
|
|
51
|
+
const d = path.join(dossier, e.name);
|
|
52
|
+
const f = path.join(d, manifeste);
|
|
53
|
+
const paquet = existsSync(f) ? nomDuManifeste(langageNom, readFileSync(f, 'utf8')) : null;
|
|
54
|
+
if (paquet !== null) out.push({ dossier: d, nom: e.name, paquet });
|
|
55
|
+
out.push(...avecManifeste(d, manifeste, langageNom, exclus));
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The packages of a language without package.json of its own (`sansPackageJson`) the tables of the
|
|
62
|
+
* components of docs/ARCHITECTURE.md declare in the project at <racine>: `{ langage, chemin, nom }`,
|
|
63
|
+
* `chemin` from the root, `nom` the manifest's name, sorted by language then path. A package is a
|
|
64
|
+
* folder under the root that holds the manifest of its language with a package name (a
|
|
65
|
+
* `Cargo.toml` of a virtual workspace names none) and that a row of the language names, by its
|
|
66
|
+
* path, its folder's name or its manifest's name, as the guard of the languages reads a component.
|
|
67
|
+
* @param {string} racine
|
|
68
|
+
*/
|
|
69
|
+
export function paquetsSansPackageJson(racine) {
|
|
70
|
+
const sortie = [];
|
|
71
|
+
const declares = langagesDeclares(racine);
|
|
72
|
+
for (const langageNom of sansPackageJson().filter(n => declares.includes(n))) {
|
|
73
|
+
const candidats = avecManifeste(
|
|
74
|
+
racine,
|
|
75
|
+
langage(langageNom).manifeste,
|
|
76
|
+
langageNom,
|
|
77
|
+
hors(racine)
|
|
78
|
+
);
|
|
79
|
+
const trouves = new Set();
|
|
80
|
+
for (const t of tableauxDesComposants(racine)) {
|
|
81
|
+
const colonne = colonneDesNoms(t.lignes, candidats, racine, t.colonne);
|
|
82
|
+
if (colonne < 0) continue;
|
|
83
|
+
for (const l of t.lignes) {
|
|
84
|
+
if (langageDeLaCellule(l.cellules[t.colonne]) !== langageNom) continue;
|
|
85
|
+
for (const c of candidats) {
|
|
86
|
+
if (nomme(nomsDe(l.cellules[colonne]), c, racine)) trouves.add(c);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
sortie.push(
|
|
91
|
+
...[...trouves]
|
|
92
|
+
.map(c => ({
|
|
93
|
+
langage: langageNom,
|
|
94
|
+
chemin: path.relative(racine, c.dossier).split(path.sep).join('/'),
|
|
95
|
+
nom: c.paquet,
|
|
96
|
+
}))
|
|
97
|
+
.sort((a, b) => (a.chemin < b.chemin ? -1 : 1))
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
return sortie;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The text of the package.json of the package <nom> in <chemin> (from the root of the project).
|
|
105
|
+
* @param {string} nom
|
|
106
|
+
* @param {string} chemin
|
|
107
|
+
*/
|
|
108
|
+
export function packageJsonDuPaquet(nom, chemin) {
|
|
109
|
+
const racine = chemin
|
|
110
|
+
.split('/')
|
|
111
|
+
.map(() => '..')
|
|
112
|
+
.join('/');
|
|
113
|
+
const appel = commande => `cd ${racine} && grillhouse ${commande} ${chemin}`;
|
|
114
|
+
const p = {
|
|
115
|
+
name: nom,
|
|
116
|
+
private: true,
|
|
117
|
+
scripts: {
|
|
118
|
+
build: appel('construire'),
|
|
119
|
+
'test:unit': appel('tests-du-paquet'),
|
|
120
|
+
typecheck: appel('typer'),
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
return `${JSON.stringify(p, null, 2)}\n`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The text of the root package.json <texte> with <chemin> entered in its `workspaces`; null when
|
|
128
|
+
* its patterns select the folder already.
|
|
129
|
+
* @param {string} texte
|
|
130
|
+
* @param {string} chemin
|
|
131
|
+
*/
|
|
132
|
+
export function inscrireAuxEspaces(texte, chemin) {
|
|
133
|
+
const p = JSON.parse(texte);
|
|
134
|
+
if (selectionne(p, chemin)) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const indent = /^([ \t]+)"/m.exec(texte)?.[1] ?? 2;
|
|
138
|
+
const fin = texte.endsWith('\n') ? '\n' : '';
|
|
139
|
+
if (Array.isArray(p.workspaces)) {
|
|
140
|
+
p.workspaces = [...p.workspaces, chemin];
|
|
141
|
+
} else if (Array.isArray(p.workspaces?.packages)) {
|
|
142
|
+
p.workspaces = { ...p.workspaces, packages: [...p.workspaces.packages, chemin] };
|
|
143
|
+
} else {
|
|
144
|
+
p.workspaces = [chemin];
|
|
145
|
+
}
|
|
146
|
+
return `${JSON.stringify(p, null, indent)}${fin}`;
|
|
147
|
+
}
|
package/scripts/paquet.mjs
CHANGED
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
// names; a row whose cell of the column « Langage » is empty; a language out of the frame's
|
|
16
16
|
// list; a folder that already holds the manifest of its language (`manifeste` of its module). A
|
|
17
17
|
// folder that holds docs/ alone, the documents of the second time, is accepted, as `cargo init`
|
|
18
|
-
// takes a folder without its Cargo.toml
|
|
18
|
+
// takes a folder without its Cargo.toml; a folder that already holds code is given to the
|
|
19
|
+
// module with its files (`existants`), which takes them as they are, or refuses, by its name,
|
|
20
|
+
// what it cannot take.
|
|
19
21
|
// - The skeleton: the module of the row's language gives the files of the package and the entry
|
|
20
22
|
// of the workspace (`squelette`, scripts/jointure.d.ts), the versions of its tools from its
|
|
21
23
|
// template (`miseAJour.gabarit`); the documents of the package, docs/CADRE.md and
|
|
@@ -23,18 +25,23 @@
|
|
|
23
25
|
// and its language written in. Each file absent is written, a file present stays; the manifest
|
|
24
26
|
// of the workspace receives the entry. The command commits nothing: the second and the third
|
|
25
27
|
// times enter one commit, after a green verification.
|
|
28
|
+
// - The entry into the Turborepo graph: a crate or a Python project, whose manifest is not a
|
|
29
|
+
// package.json, receives one beside it (./paquet-npm.mjs: the `name` of its manifest, `private`,
|
|
30
|
+
// the scripts build, test:unit and typecheck that call the module's commands on its path) and
|
|
31
|
+
// its path in the `workspaces` of the root when no pattern selects it (after the `!` pattern
|
|
32
|
+
// that excludes it). A package.json already there is never rewritten: a different name is refused.
|
|
26
33
|
// - The tools of the language, as `nx add` installs them before the first generator: the share
|
|
27
34
|
// of the update of each declared language (`mettreAJour` of ./grillhouse-maj.mjs: its tools at
|
|
28
35
|
// its template's versions, its scripts, its files, `turbo.json` for typescript), then `npm
|
|
29
|
-
// install` when the update asks it, the module's
|
|
30
|
-
// package (`verrouiller`), the binaries of the declared languages (`installerBinaires`), and the
|
|
36
|
+
// install` when the update asks it, the module's commands that lock the versions of the new
|
|
37
|
+
// package (`verrouiller`), in their order, the binaries of the declared languages (`installerBinaires`), and the
|
|
31
38
|
// generators (`regenerer`), those of the package's language whatever files the project holds:
|
|
32
39
|
// the first package of a language receives its boundaries' configuration and its index.
|
|
33
40
|
// - The report: each file written, then the lines of the update; on the error stream, each
|
|
34
41
|
// command that fails, named with its output. The exit code: 0; 1 for a refusal (⛔ and its
|
|
35
42
|
// reason) or a command that fails; 2 for the usage.
|
|
36
43
|
import { spawnSync } from 'node:child_process';
|
|
37
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
44
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
38
45
|
import path from 'node:path';
|
|
39
46
|
import { pathToFileURL } from 'node:url';
|
|
40
47
|
import { CADRE } from './cadre.mjs';
|
|
@@ -46,6 +53,14 @@ import {
|
|
|
46
53
|
regenerer,
|
|
47
54
|
} from './grillhouse-maj.mjs';
|
|
48
55
|
import { LANGAGES, langage } from './langages.mjs';
|
|
56
|
+
import {
|
|
57
|
+
inscrireAuxEspaces,
|
|
58
|
+
nomDuManifeste,
|
|
59
|
+
packageJsonDuPaquet,
|
|
60
|
+
sansPackageJson,
|
|
61
|
+
} from './paquet-npm.mjs';
|
|
62
|
+
import { paquets } from './paquets.mjs';
|
|
63
|
+
import { hors } from './sources.mjs';
|
|
49
64
|
import {
|
|
50
65
|
ARCHITECTURE,
|
|
51
66
|
colonneDesNoms,
|
|
@@ -100,13 +115,86 @@ export function ligneDuPaquet(racine, rel) {
|
|
|
100
115
|
|
|
101
116
|
const lireJson = f => (existsSync(f) ? JSON.parse(readFileSync(f, 'utf8')) : {});
|
|
102
117
|
|
|
118
|
+
// The files the folder <dossier> of the project at <racine> already holds, from it, in the order of
|
|
119
|
+
// their path: its docs/ (the documents of the second time), its hidden entries and the folders the
|
|
120
|
+
// sources of the project leave out (`hors` of ./sources.mjs: the frame's, node_modules and dist,
|
|
121
|
+
// and what the tools of its languages write, cargo's target, Python's .venv and
|
|
122
|
+
// __pycache__) left out.
|
|
123
|
+
function existants(racine, dossier) {
|
|
124
|
+
const exclus = hors(racine);
|
|
125
|
+
if (!existsSync(dossier)) {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
return readdirSync(dossier, { recursive: true, withFileTypes: true })
|
|
129
|
+
.filter(e => e.isFile())
|
|
130
|
+
.map(e => path.relative(dossier, path.join(e.parentPath, e.name)).split(path.sep).join('/'))
|
|
131
|
+
.filter(
|
|
132
|
+
f => !f.startsWith('docs/') && !f.split('/').some(p => p.startsWith('.') || exclus.has(p))
|
|
133
|
+
)
|
|
134
|
+
.sort();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// The package.json of the package at <rel> when its language has none of its own (a crate, a
|
|
138
|
+
// project of Python; ./paquet-npm.mjs): `{ fichiers, espace }`, its text when it lacks, and the
|
|
139
|
+
// root package.json with the entry of <rel> in its `workspaces` (null when its patterns select
|
|
140
|
+
// it). A package.json present is never rewritten: refused, by its name, when its `name` is not the
|
|
141
|
+
// manifest's or is already another package's of the workspaces. Nothing for the other languages.
|
|
142
|
+
/**
|
|
143
|
+
* @param {string} racine
|
|
144
|
+
* @param {string} rel
|
|
145
|
+
* @param {string} langage
|
|
146
|
+
* @param {{ manifeste: string }} m
|
|
147
|
+
* @param {{ fichiers: Record<string, string> }} squelette
|
|
148
|
+
* @returns {{ fichiers: Record<string, string>, espace: { fichier: string, texte: string } | null }}
|
|
149
|
+
*/
|
|
150
|
+
function packageJsonDuPaquetNonJs(racine, rel, langage, m, squelette) {
|
|
151
|
+
if (!sansPackageJson().includes(langage)) {
|
|
152
|
+
return { fichiers: {}, espace: null };
|
|
153
|
+
}
|
|
154
|
+
const manifeste = squelette.fichiers[`${rel}/${m.manifeste}`];
|
|
155
|
+
const nom = manifeste === undefined ? null : nomDuManifeste(langage, manifeste);
|
|
156
|
+
if (nom === null) {
|
|
157
|
+
throw new Refus(`${rel}/${m.manifeste} : le squelette du module n'écrit aucun nom de paquet.`);
|
|
158
|
+
}
|
|
159
|
+
const f = `${rel}/package.json`;
|
|
160
|
+
const abs = path.join(racine, f);
|
|
161
|
+
/** @type {Record<string, string>} */
|
|
162
|
+
const fichiers = {};
|
|
163
|
+
if (existsSync(abs)) {
|
|
164
|
+
let present;
|
|
165
|
+
try {
|
|
166
|
+
present = JSON.parse(readFileSync(abs, 'utf8')).name;
|
|
167
|
+
} catch (e) {
|
|
168
|
+
throw new Refus(`${f} : ${e.message} ; la commande ne réécrit pas un package.json.`);
|
|
169
|
+
}
|
|
170
|
+
if (present !== nom) {
|
|
171
|
+
throw new Refus(
|
|
172
|
+
`${f} : son nom est ${JSON.stringify(present)}, celui de ${m.manifeste} est ${JSON.stringify(nom)} ; la commande ne réécrit pas un package.json, le nom s'accorde au manifeste.`
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
fichiers[f] = packageJsonDuPaquet(nom, rel);
|
|
177
|
+
}
|
|
178
|
+
const autre = paquets(racine).find(p => p.pkg.name === nom && p.dossier !== rel);
|
|
179
|
+
if (autre) {
|
|
180
|
+
throw new Refus(
|
|
181
|
+
`${f} : le nom ${JSON.stringify(nom)} est déjà celui de ${autre.dossier}/package.json, un paquet des workspaces ; un nom ne désigne qu'un paquet.`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
const fr = path.join(racine, 'package.json');
|
|
185
|
+
const texte = existsSync(fr) ? inscrireAuxEspaces(readFileSync(fr, 'utf8'), rel) : null;
|
|
186
|
+
return { fichiers, espace: texte === null ? null : { fichier: 'package.json', texte } };
|
|
187
|
+
}
|
|
188
|
+
|
|
103
189
|
/**
|
|
104
190
|
* The plan of the package at <chemin> of the project at <racine>, nothing written: `{ chemin,
|
|
105
191
|
* langage, fichiers, espace, verrouiller }`, `fichiers` the skeleton of its language and its
|
|
106
192
|
* documents (path from the root → text), `espace` the manifest of the workspace with its entry
|
|
107
|
-
* (null when it holds it), `verrouiller` the
|
|
108
|
-
* its name, for a path no row names, a row without language, a language
|
|
109
|
-
*
|
|
193
|
+
* (null when it holds it), `verrouiller` the commands that lock its versions, played in their
|
|
194
|
+
* order. Throws a Refus, by its name, for a path no row names, a row without language, a language
|
|
195
|
+
* out of the frame's list, a folder that holds the manifest of its language, and a folder whose
|
|
196
|
+
* code the module cannot take (a manifest of Python it does not read, Rust or TypeScript out of
|
|
197
|
+
* its layout), what is missing named.
|
|
110
198
|
* @param {string} racine the root of the project
|
|
111
199
|
* @param {string} chemin the package's folder, from the root
|
|
112
200
|
* @param {{ source?: string }} [o] the frame's files (CADRE)
|
|
@@ -139,11 +227,17 @@ export function planDuPaquet(racine, chemin, { source = CADRE } = {}) {
|
|
|
139
227
|
const modele = lireJson(path.join(source, m.miseAJour.gabarit, 'package.json'));
|
|
140
228
|
let s;
|
|
141
229
|
try {
|
|
142
|
-
s = m.squelette(racine, {
|
|
230
|
+
s = m.squelette(racine, {
|
|
231
|
+
chemin: rel,
|
|
232
|
+
modele,
|
|
233
|
+
existants: existants(racine, path.join(racine, rel)),
|
|
234
|
+
});
|
|
143
235
|
} catch (e) {
|
|
144
236
|
throw new Refus(e.message);
|
|
145
237
|
}
|
|
238
|
+
const npm = packageJsonDuPaquetNonJs(racine, rel, l.langage, m, s);
|
|
146
239
|
const nom = path.posix.basename(rel);
|
|
240
|
+
/** @type {Record<string, string>} */
|
|
147
241
|
const documents = Object.fromEntries(
|
|
148
242
|
DOCUMENTS.map(d => [
|
|
149
243
|
`${rel}/${d}`,
|
|
@@ -155,8 +249,9 @@ export function planDuPaquet(racine, chemin, { source = CADRE } = {}) {
|
|
|
155
249
|
return {
|
|
156
250
|
chemin: rel,
|
|
157
251
|
langage: m,
|
|
158
|
-
fichiers: { ...s.fichiers, ...documents },
|
|
252
|
+
fichiers: { ...s.fichiers, ...npm.fichiers, ...documents },
|
|
159
253
|
espace: s.espace,
|
|
254
|
+
espaceNpm: npm.espace,
|
|
160
255
|
verrouiller: s.verrouiller,
|
|
161
256
|
};
|
|
162
257
|
}
|
|
@@ -178,9 +273,11 @@ export function ecrireLePaquet(racine, plan) {
|
|
|
178
273
|
writeFileSync(abs, texte);
|
|
179
274
|
ecrits.push(f);
|
|
180
275
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
276
|
+
for (const espace of [plan.espace, plan.espaceNpm]) {
|
|
277
|
+
if (espace) {
|
|
278
|
+
writeFileSync(path.join(racine, espace.fichier), espace.texte);
|
|
279
|
+
ecrits.push(espace.fichier);
|
|
280
|
+
}
|
|
184
281
|
}
|
|
185
282
|
return ecrits;
|
|
186
283
|
}
|
|
@@ -219,8 +316,9 @@ export function creerPaquet(racine, chemin, { source = CADRE, executer = lancer
|
|
|
219
316
|
if (aInstaller(b)) {
|
|
220
317
|
jouer('npm', ['install'], '.');
|
|
221
318
|
}
|
|
222
|
-
const v
|
|
223
|
-
|
|
319
|
+
for (const v of plan.verrouiller) {
|
|
320
|
+
jouer(v.commande, v.args, v.dossier);
|
|
321
|
+
}
|
|
224
322
|
const binaires = installerBinaires(racine);
|
|
225
323
|
echecs.push(...binaires.lignes, ...regenerer(racine, { langage: plan.langage.nom }));
|
|
226
324
|
const lignes = rapport(b)
|
package/scripts/paquets.mjs
CHANGED
|
@@ -65,14 +65,19 @@ const lireJson = f => {
|
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
/**
|
|
69
|
+
* The patterns of the `workspaces` of the root `package.json` <p> (an array, or its `packages` key):
|
|
70
|
+
* `{ declares, motifs, nies }`, the patterns as written, those that select, and those that take out
|
|
71
|
+
* what the others select, none put back by a later pattern.
|
|
72
|
+
* @param {Record<string, any> | null} p
|
|
73
|
+
*/
|
|
74
|
+
export function motifsDesEspaces(p) {
|
|
75
|
+
const declares = (
|
|
76
|
+
Array.isArray(p?.workspaces) ? p.workspaces : (p?.workspaces?.packages ?? [])
|
|
77
|
+
).map(String);
|
|
73
78
|
const motifs = [];
|
|
74
79
|
let nies = [];
|
|
75
|
-
for (const brut of declares
|
|
80
|
+
for (const brut of declares) {
|
|
76
81
|
const excl = /^!+/.exec(brut)?.[0] ?? '';
|
|
77
82
|
const motif = brut
|
|
78
83
|
.slice(excl.length)
|
|
@@ -86,6 +91,29 @@ export function paquets(racine) {
|
|
|
86
91
|
motifs.push(motif);
|
|
87
92
|
}
|
|
88
93
|
}
|
|
94
|
+
return { declares, motifs, nies };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Whether the `workspaces` of the root `package.json` <p> select the directory <dossier> (from the
|
|
99
|
+
* root), as `paquets` maps them, whether or not it holds its package.json yet.
|
|
100
|
+
* @param {Record<string, any> | null} p
|
|
101
|
+
* @param {string} dossier
|
|
102
|
+
*/
|
|
103
|
+
export function selectionne(p, dossier) {
|
|
104
|
+
const { motifs, nies } = motifsDesEspaces(p);
|
|
105
|
+
return (
|
|
106
|
+
!dossier.split('/').includes('node_modules') &&
|
|
107
|
+
motifs.some(m => path.matchesGlob(dossier, m)) &&
|
|
108
|
+
!nies.some(n => path.matchesGlob(dossier, n))
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// The packages of the repository at <racine>: [{ dossier, pkg, hors }], sorted by directory;
|
|
113
|
+
// `hors` whether `docs/agents/hors-cadre.txt` lists it (a directory under `packages/` or `src/`).
|
|
114
|
+
export function paquets(racine) {
|
|
115
|
+
const p = lireJson(path.join(racine, 'package.json'));
|
|
116
|
+
const { motifs, nies } = motifsDesEspaces(p);
|
|
89
117
|
const dossiers = new Set();
|
|
90
118
|
for (const motif of motifs) {
|
|
91
119
|
for (const f of globSync(`${motif}/package.json`, { cwd: racine })) {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// A pass of the circuit on the machine: each takes a place of the machine, like a session of an
|
|
2
|
+
// agent (scripts/places-de-la-machine.mjs); a heavy pass (the final pass, `npm run verifier`)
|
|
3
|
+
// holds besides the exclusive lock of the machine (scripts/verrou-de-machine.mjs), once its place
|
|
4
|
+
// is given (`avecLaMachineEtUnePlace`). A targeted pass (the proof of the red and the checks,
|
|
5
|
+
// which play the tests of the ticket only) starts while a heavy one holds the lock.
|
|
6
|
+
import { sousNiceEtIonice } from './enveloppe/enveloppe.mjs';
|
|
7
|
+
import {
|
|
8
|
+
VARIABLE_TRAVAILLEURS,
|
|
9
|
+
avecLaMachineEtUnePlace,
|
|
10
|
+
avecUnePlace,
|
|
11
|
+
travailleursDe,
|
|
12
|
+
} from './places-de-la-machine.mjs';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Whether the npm command of a step is a heavy pass: `npm run verifier`, whatever its step.
|
|
16
|
+
* @param {{ etape: string, args: string[] }} o
|
|
17
|
+
*/
|
|
18
|
+
export function passeLourde({ args }) {
|
|
19
|
+
return args.includes('verifier');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* What a pass or a session out of the envelope launches: a heavy pass runs its command as it is,
|
|
24
|
+
* every core kept (no GRILLHOUSE_TRAVAILLEURS, even inherited); any other runs under `nice` and
|
|
25
|
+
* `ionice`, GRILLHOUSE_TRAVAILLEURS set to max(1, cores ÷ places).
|
|
26
|
+
* @param {{ lourde: boolean, cmd: string, args: string[], env: Record<string, string | undefined> }} o
|
|
27
|
+
* @returns {{ cmd: string, args: string[], env: Record<string, string | undefined> }}
|
|
28
|
+
*/
|
|
29
|
+
export function lancementDeLaPasse({ lourde, cmd, args, env }) {
|
|
30
|
+
const { [VARIABLE_TRAVAILLEURS]: _herite, ...sansTravailleurs } = env;
|
|
31
|
+
if (lourde) return { cmd, args, env: sansTravailleurs };
|
|
32
|
+
const [commande, ...arguments_] = sousNiceEtIonice([cmd, ...args]);
|
|
33
|
+
return {
|
|
34
|
+
cmd: commande,
|
|
35
|
+
args: arguments_,
|
|
36
|
+
env: { ...sansTravailleurs, [VARIABLE_TRAVAILLEURS]: String(travailleursDe({ env })) },
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Plays <mesure> on a place of the machine, and under its lock besides when it is <lourde>, the
|
|
42
|
+
* environment it receives being the pass's own. The wait of either says its reason and stops at
|
|
43
|
+
* the bound (75).
|
|
44
|
+
* @template T
|
|
45
|
+
* @param {(env: Record<string, string | undefined>) => T} mesure
|
|
46
|
+
* @param {{ lourde: boolean, env?: Record<string, string | undefined>, racine?: string,
|
|
47
|
+
* ticket?: string, sorte?: string, rang?: number, dire?: (l: string) => void,
|
|
48
|
+
* borneMs?: number, rappelMs?: number } & Record<string, unknown>} options
|
|
49
|
+
* @returns {T}
|
|
50
|
+
*/
|
|
51
|
+
export function avecLaPasse(mesure, { lourde, env = process.env, racine, ticket, sorte, ...options }) {
|
|
52
|
+
if (lourde) {
|
|
53
|
+
const { dire, borneMs, rappelMs, rang } = options;
|
|
54
|
+
return avecLaMachineEtUnePlace(mesure, {
|
|
55
|
+
env,
|
|
56
|
+
racine,
|
|
57
|
+
ticket,
|
|
58
|
+
sorte,
|
|
59
|
+
...(rang !== undefined ? { rang } : {}),
|
|
60
|
+
...(dire ? { dire } : {}),
|
|
61
|
+
...(borneMs !== undefined ? { borneMs } : {}),
|
|
62
|
+
...(rappelMs !== undefined ? { rappelMs } : {}),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return avecUnePlace(place => mesure(place.env), { ...options, env, ticket });
|
|
66
|
+
}
|