@roomi-fields/grillhouse 0.52.0 → 0.53.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 +48 -0
- package/agents/direct.md +1 -1
- package/cadre/templates/projet/vitest.config.cjs +45 -0
- package/charte/superviseur.md +36 -37
- package/charte.md +1 -1
- package/dist/temporal/circuit/appel.d.ts +2 -0
- package/dist/temporal/circuit/appel.js +24 -2
- package/dist/temporal/circuit/appel.js.map +1 -1
- package/dist/temporal/circuit/client.d.ts +14 -5
- package/dist/temporal/circuit/client.js +41 -9
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/commande.js +17 -6
- package/dist/temporal/circuit/commande.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +9 -0
- package/dist/temporal/circuit/contrat.js +6 -0
- package/dist/temporal/circuit/contrat.js.map +1 -1
- package/dist/temporal/circuit/deroule.js +25 -4
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/client.d.ts +35 -1
- package/dist/temporal/client.js +144 -1
- package/dist/temporal/client.js.map +1 -1
- package/dist/temporal/commande.js +31 -13
- package/dist/temporal/commande.js.map +1 -1
- package/dist/temporal/etat.d.ts +3 -1
- package/dist/temporal/etat.js +31 -17
- package/dist/temporal/etat.js.map +1 -1
- package/dist/temporal/file/activites.js +1 -1
- package/dist/temporal/file/activites.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +4 -5
- package/dist/temporal/file/contrat.js +2 -2
- package/dist/temporal/file/contrat.js.map +1 -1
- package/dist/temporal/file/deroule.js +7 -5
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +103 -53
- package/dist/temporal/installation.js +842 -237
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/nuits/deroule.js +3 -1
- package/dist/temporal/nuits/deroule.js.map +1 -1
- package/dist/temporal/places/deroule.js +2 -1
- package/dist/temporal/places/deroule.js.map +1 -1
- package/dist/temporal/sonde/deroule.js +2 -1
- package/dist/temporal/sonde/deroule.js.map +1 -1
- package/dist/temporal/tickets/deroule.js +4 -3
- package/dist/temporal/tickets/deroule.js.map +1 -1
- package/dist/temporal/travailleur.d.ts +7 -1
- package/dist/temporal/travailleur.js +49 -25
- package/dist/temporal/travailleur.js.map +1 -1
- package/docs/INTERFACE.md +17 -12
- package/docs/architecture/circuit.md +18 -15
- package/docs/architecture/entree.md +7 -8
- package/docs/architecture/greffon.md +30 -21
- package/docs/architecture/installation.md +87 -58
- package/docs/architecture/machine.md +1 -1
- package/docs/architecture/tests.md +14 -5
- package/docs/lexique.md +2 -2
- package/hooks/hooks.json +10 -0
- package/hooks/register.tsx +19 -25
- package/package.json +3 -2
- package/scripts/activites.mjs +5 -4
- package/scripts/aiguillage.mjs +1 -0
- package/scripts/circuit.mjs +254 -42
- package/scripts/circuits-du-serveur.mjs +3 -2
- package/scripts/circuits-tenus.d.mts +7 -0
- package/scripts/circuits-tenus.mjs +17 -0
- package/scripts/copie-de-montee.mjs +354 -0
- package/scripts/copies-du-depot.d.mts +13 -0
- package/scripts/copies-du-depot.mjs +66 -0
- package/scripts/copies-finies.mjs +6 -40
- package/scripts/crochets.mjs +16 -2
- package/scripts/direct.mjs +2 -2
- package/scripts/droits.mjs +2 -2
- package/scripts/engendres.mjs +5 -3
- package/scripts/enveloppe/travail-de-la-copie.mjs +77 -0
- package/scripts/etapes.mjs +11 -3
- package/scripts/faits-du-circuit.mjs +12 -5
- package/scripts/file-des-tickets.d.mts +13 -2
- package/scripts/file-des-tickets.mjs +44 -12
- package/scripts/greffons.mjs +42 -27
- package/scripts/grillhouse-maj.mjs +105 -85
- package/scripts/init.mjs +1 -1
- package/scripts/integration/file.mjs +5 -2
- package/scripts/integration/integrer.mjs +14 -4
- package/scripts/jointure.d.ts +16 -0
- package/scripts/langages/c/commandes.mjs +17 -7
- package/scripts/langages/cargo/commandes.mjs +87 -34
- package/scripts/langages/cargo/index.mjs +6 -3
- package/scripts/langages/cargo/sccache.mjs +15 -12
- package/scripts/langages/python/commandes.mjs +18 -8
- package/scripts/langages/python/squelette.mjs +2 -2
- package/scripts/langages/typescript/configurations-de-vitest.mjs +118 -0
- package/scripts/langages/typescript/index.mjs +2 -0
- package/scripts/langages/typescript/migrations/configurations-en-commonjs.mjs +299 -0
- package/scripts/langages/typescript/squelette.mjs +20 -17
- package/scripts/langages/typescript/tests-de-nuit.mjs +3 -3
- package/scripts/langages/typescript/turbo-des-paquets.mjs +24 -37
- package/scripts/langages/typescript/vitest-config/base.mjs +1 -1
- package/scripts/langages/typescript/vitest-config/bornes.mjs +1 -1
- package/scripts/langages/typescript/vitest-config/cibles.mjs +2 -2
- package/scripts/langages/typescript/{vitest.nuit.config.mjs → vitest.nuit.config.cjs} +61 -50
- package/scripts/mesure/pression.mjs +5 -3
- package/scripts/montee.mjs +524 -0
- package/scripts/outil.mjs +5 -3
- package/scripts/paquet-npm.mjs +22 -0
- package/scripts/paquet.mjs +5 -5
- package/scripts/pre-compact.mjs +25 -0
- package/scripts/reponses-du-circuit.d.mts +17 -2
- package/scripts/reponses-du-circuit.mjs +78 -20
- package/scripts/resultats.mjs +40 -12
- package/scripts/retirer-les-copies-finies.mjs +4 -7
- package/scripts/seances.mjs +28 -3
- package/scripts/services-du-noyau.mjs +7 -2
- package/scripts/session-start.sh +18 -11
- package/scripts/sortie.mjs +4 -7
- package/scripts/sous-commandes.mjs +1 -0
- package/scripts/superviseur.mjs +110 -70
- package/scripts/tableau.mjs +127 -108
- package/scripts/ticket-du-circuit.mjs +22 -0
- package/scripts/transitions.d.mts +6 -9
- package/scripts/transitions.mjs +123 -36
- package/scripts/verrou-de-fichier.d.mts +11 -0
- package/skills/direct/SKILL.md +21 -11
- package/skills/explorateur/SKILL.md +6 -1
- package/skills/grill/SKILL.md +9 -7
- package/skills/grill/references/paquets.md +4 -4
- package/skills/pitmaster/SKILL.md +45 -33
- package/skills/pitmaster/references/consigne-agent.md +1 -1
- package/skills/relecteur/SKILL.md +8 -1
- package/skills/testwriter/SKILL.md +1 -1
- package/cadre/templates/projet/vitest.config.ts +0 -44
|
@@ -28,59 +28,70 @@
|
|
|
28
28
|
// it leaves out; this configuration takes it out of the environment once read, as the plugin of
|
|
29
29
|
// the night does its choice and its tranche: the unit is the run's own, and a Vitest that a night
|
|
30
30
|
// test starts itself, in another package, plays under no configuration but its own. Node (>= 26)
|
|
31
|
-
// reads the package's configuration itself, TypeScript included
|
|
32
|
-
// function is called
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
// reads the package's configuration itself, TypeScript included, and takes what it exports as Vite
|
|
32
|
+
// does: a function is called for a test run, and a promise, exported or returned, is awaited.
|
|
33
|
+
//
|
|
34
|
+
// CommonJS, exporting a promise: Vite loads it without writing beside it, and the frame's package
|
|
35
|
+
// is read-only where its tests load it (./turbo-des-paquets.mjs asks the same of a project). No
|
|
36
|
+
// `require`: a configuration in ESM that imports this one has it bundled as ESM, where Node gives
|
|
37
|
+
// none.
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
async function charger() {
|
|
40
|
+
const { pathToFileURL } = await import('node:url');
|
|
41
|
+
const { mergeConfig } = await import('vitest/config');
|
|
42
|
+
const { default: base } = await import('./vitest-config/base.mjs');
|
|
43
|
+
const { HORS_DU_JOUR, nuit, NUIT_PAQUET } = await import('./vitest-config/cibles.mjs');
|
|
44
|
+
const { DELAI_NUIT_MS } = await import('./vitest-config/bornes.mjs');
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
config(config) {
|
|
49
|
-
const test = (config.test ??= {});
|
|
50
|
-
test.exclude = ['**/node_modules/**', '**/dist/**', '**/.git/**', ...exclus];
|
|
51
|
-
test.reporters = base.test.reporters;
|
|
52
|
-
test.setupFiles = [...new Set([...(test.setupFiles ?? []), ...base.test.setupFiles])];
|
|
53
|
-
},
|
|
54
|
-
};
|
|
46
|
+
const { config: fichier, exclus = [] } = process.env[NUIT_PAQUET]
|
|
47
|
+
? JSON.parse(process.env[NUIT_PAQUET])
|
|
48
|
+
: {};
|
|
49
|
+
delete process.env[NUIT_PAQUET];
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
passWithNoTests: true,
|
|
68
|
-
// The large delay of Bazel for a night test: 900 s (./vitest-config/delais.mjs).
|
|
69
|
-
testTimeout: DELAI_NUIT_MS,
|
|
70
|
-
hookTimeout: DELAI_NUIT_MS,
|
|
71
|
-
watch: false,
|
|
72
|
-
},
|
|
73
|
-
};
|
|
51
|
+
// What the night sets wins over the configuration of a package, whose plugins have run first: the
|
|
52
|
+
// exclusions of its unit, the reporters, and the setup files, the package's before the base's.
|
|
53
|
+
const nuitGagne = {
|
|
54
|
+
name: 'grillhouse:nuit-gagne',
|
|
55
|
+
config(config) {
|
|
56
|
+
const test = (config.test ??= {});
|
|
57
|
+
test.exclude = ['**/node_modules/**', '**/dist/**', '**/.git/**', ...exclus];
|
|
58
|
+
test.reporters = base.test.reporters;
|
|
59
|
+
test.setupFiles = [...new Set([...(test.setupFiles ?? []), ...base.test.setupFiles])];
|
|
60
|
+
},
|
|
61
|
+
};
|
|
74
62
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
63
|
+
const cadre = {
|
|
64
|
+
plugins: [nuitGagne, nuit()],
|
|
65
|
+
cacheDir: base.cacheDir,
|
|
66
|
+
test: {
|
|
67
|
+
env: base.test.env,
|
|
68
|
+
environment: base.test.environment,
|
|
69
|
+
reporters: base.test.reporters,
|
|
70
|
+
setupFiles: base.test.setupFiles,
|
|
71
|
+
include: HORS_DU_JOUR,
|
|
72
|
+
exclude: ['**/node_modules/**', '**/dist/**', '**/.git/**'],
|
|
73
|
+
// A unit may hold none of the files the run chooses.
|
|
74
|
+
passWithNoTests: true,
|
|
75
|
+
// The large delay of Bazel for a night test: 900 s (./vitest-config/delais.mjs).
|
|
76
|
+
testTimeout: DELAI_NUIT_MS,
|
|
77
|
+
hookTimeout: DELAI_NUIT_MS,
|
|
78
|
+
watch: false,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
const
|
|
82
|
+
async function dePaquet(f) {
|
|
83
|
+
const { default: exporte } = await import(pathToFileURL(f).href);
|
|
84
|
+
// Awaited before the test: the promise a CommonJS configuration exports may give a function.
|
|
85
|
+
const attendu = await exporte;
|
|
86
|
+
const paquet = await (typeof attendu === 'function'
|
|
87
|
+
? attendu({ command: 'serve', mode: 'test' })
|
|
88
|
+
: attendu);
|
|
89
|
+
// The environment and the setup files of the package are its own to set.
|
|
90
|
+
const { environment: _e, setupFiles: _s, ...test } = cadre.test;
|
|
91
|
+
return mergeConfig(paquet ?? {}, { ...cadre, test });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return fichier ? await dePaquet(fichier) : cadre;
|
|
95
|
+
}
|
|
85
96
|
|
|
86
|
-
|
|
97
|
+
module.exports = charger();
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
// - A_REPASSER (scripts/codes-de-sortie.mjs), 75, is the exit code of « à repasser » (EX_TEMPFAIL
|
|
13
13
|
// of sysexits.h: try again later), neither green nor red: the measure of time of each module of language gives it
|
|
14
14
|
// (scripts/langages/typescript/vitest-config/duree.reporter.mjs, the benches of the module cargo),
|
|
15
|
-
// and the night reads it (scripts/nuit.sh). The
|
|
16
|
-
//
|
|
15
|
+
// and the night reads it (scripts/nuit.sh). The module cargo also waits for rest, one minute at
|
|
16
|
+
// most, before it plays each time budget bench (scripts/langages/cargo/commandes.mjs). A day pass
|
|
17
|
+
// plays no measure of time: `npm run verifier` takes a task at 75 for a red
|
|
18
|
+
// (scripts/langages/typescript/verifier.mjs).
|
|
17
19
|
//
|
|
18
20
|
// npx grillhouse pression attendre
|
|
19
21
|
//
|
|
@@ -60,7 +62,7 @@ export function attendreLeRepos({
|
|
|
60
62
|
for (;;) {
|
|
61
63
|
const p = lire();
|
|
62
64
|
if (p === null) {
|
|
63
|
-
dire('⏳ pression CPU illisible : la
|
|
65
|
+
dire('⏳ pression CPU illisible : la mesure part sans attendre, verdict des tests.');
|
|
64
66
|
return true;
|
|
65
67
|
}
|
|
66
68
|
if (p < SEUIL_PRESSION) {
|
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
// The montée of a project by one command, `grillhouse maj [<x.y.z>]`, as `nx migrate` and
|
|
2
|
+
// `brew upgrade` bring everything to the version wanted. The mechanism is installation.md §5.2 and
|
|
3
|
+
// §5.3, under packages/grillhouse/docs/architecture/.
|
|
4
|
+
//
|
|
5
|
+
// - Launched in the main tree (`monter`), it lays the copy of the montée on the tip of main
|
|
6
|
+
// (scripts/copie-de-montee.mjs), installs there the package at the version wanted (`npm install -D`;
|
|
7
|
+
// the repository of the frame, which holds the package's sources, installs its dependencies
|
|
8
|
+
// alone), then hands the rest (`suivre`) to the command of the package so installed, or plays it
|
|
9
|
+
// itself in the repository of the frame. Without a version, the one the tip of main holds is kept
|
|
10
|
+
// (the key `grillhouse.outil` in the repository of the frame). The child learns it plays the
|
|
11
|
+
// rest from the variable `GRILLHOUSE_MONTEE`.
|
|
12
|
+
// - The rest, up to five passes: the files the frame writes (scripts/grillhouse-maj.mjs), the
|
|
13
|
+
// machine's part once (the published tool, the plugins, the binaries, the units and workers, the
|
|
14
|
+
// schedule of the nights), the verification of the sort « Montée » on the content of the commit
|
|
15
|
+
// alone; green, the commit, its tree kept as judged (scripts/arbres-juges.mjs), main advanced by
|
|
16
|
+
// fast-forward and pushed; main advanced meanwhile, the next pass writes everything again from
|
|
17
|
+
// its tip. Main advanced, the main tree installs its dependencies and the plugins the lot adds.
|
|
18
|
+
// - Exit code: 0; 1 for a failure, a refusal or a montée not entered; 75 for a verification to play
|
|
19
|
+
// again; 2 for the usage (scripts/grillhouse-maj.mjs).
|
|
20
|
+
import { spawnSync } from 'node:child_process';
|
|
21
|
+
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
import { installer, NOM_DU_PAQUET, versionDeLOutil } from './aiguillage.mjs';
|
|
24
|
+
import { garderLArbreJuge } from './arbres-juges.mjs';
|
|
25
|
+
import { installerBinaires } from './binaires.mjs';
|
|
26
|
+
import { poserCrochets } from './crochets.mjs';
|
|
27
|
+
import {
|
|
28
|
+
arbreDe,
|
|
29
|
+
brancheDeLaMontee,
|
|
30
|
+
changements,
|
|
31
|
+
conflits,
|
|
32
|
+
fichiersEcrits,
|
|
33
|
+
garderLEtat,
|
|
34
|
+
git,
|
|
35
|
+
preparerLaCopie,
|
|
36
|
+
remettreSur,
|
|
37
|
+
restaurer,
|
|
38
|
+
retirerLaCopie,
|
|
39
|
+
} from './copie-de-montee.mjs';
|
|
40
|
+
import { greffonsDuProjet, installerGreffons } from './greffons.mjs';
|
|
41
|
+
import { paquets } from './paquets.mjs';
|
|
42
|
+
|
|
43
|
+
/** The variable by which the command of the package installed in the copy plays the rest. */
|
|
44
|
+
export const VARIABLE_DE_LA_MONTEE = 'GRILLHOUSE_MONTEE';
|
|
45
|
+
const PASSES_MAX = 5;
|
|
46
|
+
// The root of the package that runs: this script's.
|
|
47
|
+
const PAQUET = path.resolve(import.meta.dirname, '..');
|
|
48
|
+
const CHAMPS = ['dependencies', 'devDependencies', 'optionalDependencies'];
|
|
49
|
+
|
|
50
|
+
const dire = l => process.stdout.write(`${l}\n`);
|
|
51
|
+
const signaler = l => process.stderr.write(`${l}\n`);
|
|
52
|
+
|
|
53
|
+
const lireJson = f => {
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(readFileSync(f, 'utf8'));
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const resultatDeGit = (racine, args) =>
|
|
62
|
+
spawnSync('git', ['-C', racine, ...args], { encoding: 'utf8' });
|
|
63
|
+
|
|
64
|
+
// The JSON of the file `f` at the commit `commit`, or null.
|
|
65
|
+
function auCommit(racine, commit, f) {
|
|
66
|
+
const r = resultatDeGit(racine, ['show', `${commit}:${f}`]);
|
|
67
|
+
try {
|
|
68
|
+
return r.status === 0 ? JSON.parse(r.stdout) : null;
|
|
69
|
+
} catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The main tree `cwd` is the root of, its branch: `{ principal, branche }`; `{ refus }` in a copy,
|
|
76
|
+
* out of git, in a folder that is no root, or on a detached HEAD.
|
|
77
|
+
*/
|
|
78
|
+
export function arbreDeLaMontee(cwd) {
|
|
79
|
+
const r = resultatDeGit(cwd, [
|
|
80
|
+
'rev-parse',
|
|
81
|
+
'--path-format=absolute',
|
|
82
|
+
'--git-dir',
|
|
83
|
+
'--git-common-dir',
|
|
84
|
+
'--show-toplevel',
|
|
85
|
+
]);
|
|
86
|
+
const refus = raison => ({
|
|
87
|
+
refus: `⛔ grillhouse maj se lance à la racine de l'arbre principal d'un dépôt git : ${raison}. Rien n'est fait.`,
|
|
88
|
+
});
|
|
89
|
+
if (r.status !== 0) {
|
|
90
|
+
return refus(`${cwd} n'est pas dans un dépôt git`);
|
|
91
|
+
}
|
|
92
|
+
const [dossier, commun, racine] = r.stdout.trim().split('\n');
|
|
93
|
+
if (dossier !== commun) {
|
|
94
|
+
return refus(`${racine} est une copie`);
|
|
95
|
+
}
|
|
96
|
+
if (realpathSync(cwd) !== realpathSync(racine)) {
|
|
97
|
+
return refus(`la racine du dépôt est ${racine}, pas ${cwd}`);
|
|
98
|
+
}
|
|
99
|
+
if (!existsSync(path.join(racine, 'package.json'))) {
|
|
100
|
+
return refus(`${racine} n'a pas de package.json`);
|
|
101
|
+
}
|
|
102
|
+
const branche = resultatDeGit(racine, ['symbolic-ref', '--quiet', '--short', 'HEAD']);
|
|
103
|
+
if (branche.status !== 0) {
|
|
104
|
+
return refus('aucune branche n’y est extraite (HEAD détaché)');
|
|
105
|
+
}
|
|
106
|
+
return { principal: realpathSync(racine), branche: branche.stdout.trim() };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// The folder of the package's sources in the repository at `racine`, or null: the repository of
|
|
110
|
+
// the frame.
|
|
111
|
+
function sourcesDuCadre(racine) {
|
|
112
|
+
return paquets(racine).find(p => p.pkg.name === NOM_DU_PAQUET)?.dossier ?? null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const declareLePaquet = pkg => CHAMPS.some(c => pkg?.[c]?.[NOM_DU_PAQUET] !== undefined);
|
|
116
|
+
const versionVerrouillee = verrou =>
|
|
117
|
+
verrou?.packages?.[`node_modules/${NOM_DU_PAQUET}`]?.version ?? null;
|
|
118
|
+
const versionInstallee = racine =>
|
|
119
|
+
lireJson(path.join(racine, 'node_modules', NOM_DU_PAQUET, 'package.json'))?.version ?? null;
|
|
120
|
+
|
|
121
|
+
// The version the tip of main holds, which `maj` without argument keeps.
|
|
122
|
+
function versionDeLaPointe(principal, pointe, sources) {
|
|
123
|
+
const pkg = auCommit(principal, pointe, 'package.json');
|
|
124
|
+
if (sources !== null) {
|
|
125
|
+
return (
|
|
126
|
+
pkg?.grillhouse?.outil ?? auCommit(principal, pointe, `${sources}/package.json`)?.version
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
if (!declareLePaquet(pkg)) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const declaree = CHAMPS.map(c => pkg[c]?.[NOM_DU_PAQUET]).find(Boolean);
|
|
133
|
+
return (
|
|
134
|
+
versionVerrouillee(auCommit(principal, pointe, 'package-lock.json')) ??
|
|
135
|
+
versionInstallee(principal) ??
|
|
136
|
+
/\d+\.\d+\.\d+/.exec(declaree)?.[0] ??
|
|
137
|
+
null
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// npm in `dossier`, its output the command's; whether it succeeded, its failure said.
|
|
142
|
+
function npm(dossier, args) {
|
|
143
|
+
const r = spawnSync('npm', args, { cwd: dossier, stdio: 'inherit' });
|
|
144
|
+
if (r.status === 0) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
signaler(
|
|
148
|
+
`⛔ \`npm ${args.join(' ')}\` dans ${dossier} échoue (${r.error?.message ?? `code ${r.status}`}).`
|
|
149
|
+
);
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// The installation of a montée in its copy: the package at `version` when the tip does not hold it
|
|
154
|
+
// there, else the declared dependencies alone.
|
|
155
|
+
function installerDansLaCopie({ copie, version, duCadre }) {
|
|
156
|
+
const aJour =
|
|
157
|
+
duCadre ||
|
|
158
|
+
(declareLePaquet(lireJson(path.join(copie, 'package.json'))) &&
|
|
159
|
+
versionVerrouillee(lireJson(path.join(copie, 'package-lock.json'))) === version);
|
|
160
|
+
return npm(copie, aJour ? ['install'] : ['install', '-D', `${NOM_DU_PAQUET}@${version}`]);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// What the report says of a montée that did not enter main: its copy, the versions, the commands.
|
|
164
|
+
function nonEntree({ copie, version, principal, pointe, duCadre }, poste) {
|
|
165
|
+
const sources = duCadre ? sourcesDuCadre(principal) : null;
|
|
166
|
+
const duProjet = versionDeLaPointe(principal, pointe, sources) ?? 'inconnue';
|
|
167
|
+
signaler(
|
|
168
|
+
`Montée non entrée : main reste tel quel, sa copie reste, ${copie} (branche ${brancheDeLaMontee(version)}).`
|
|
169
|
+
);
|
|
170
|
+
signaler(
|
|
171
|
+
`${
|
|
172
|
+
poste
|
|
173
|
+
? `Le poste est mené par ${version} (sa part est jouée)`
|
|
174
|
+
: 'La part du poste n’est pas jouée'
|
|
175
|
+
}, le projet est en ${duProjet} : \`npx grillhouse maj ${version}\` reprend la montée, \`npx grillhouse maj\` revient à la version du projet.`
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* What the montée receives of the files the frame writes (scripts/grillhouse-maj.mjs, which calls
|
|
181
|
+
* it): `ecrireLeProjet` and `verifier`.
|
|
182
|
+
* @typedef {{
|
|
183
|
+
* ecrireLeProjet: (copie: string, o: { version: string, duCadre: boolean,
|
|
184
|
+
* noterSansVerifier?: (ligne: string | null) => void }) => boolean,
|
|
185
|
+
* verifier: (copie: string, o: { fichiersAFinir: boolean, installer: boolean,
|
|
186
|
+
* sansVerifier?: string | null }) => { code: number | null, ligne: string, erreur: boolean }
|
|
187
|
+
* }} Fichiers
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* `grillhouse maj [<voulue>]` launched in `cwd` (see the header): the exit code.
|
|
192
|
+
* @param {string | null} voulue the version x.y.z wanted, null to keep the tip's
|
|
193
|
+
* @param {Fichiers} deLaMaj
|
|
194
|
+
* @param {string} [cwd]
|
|
195
|
+
*/
|
|
196
|
+
export function monter(voulue, deLaMaj, cwd = process.cwd()) {
|
|
197
|
+
const arbre = arbreDeLaMontee(cwd);
|
|
198
|
+
if (arbre.refus) {
|
|
199
|
+
signaler(arbre.refus);
|
|
200
|
+
return 1;
|
|
201
|
+
}
|
|
202
|
+
const { principal, branche } = arbre;
|
|
203
|
+
const pointe = git(principal, 'rev-parse', 'HEAD');
|
|
204
|
+
const sources = sourcesDuCadre(principal);
|
|
205
|
+
const duCadre = sources !== null;
|
|
206
|
+
const tenue = versionDeLaPointe(principal, pointe, sources);
|
|
207
|
+
const version = voulue ?? tenue;
|
|
208
|
+
if (!version) {
|
|
209
|
+
signaler(
|
|
210
|
+
`⛔ la pointe de ${branche} ne déclare pas ${NOM_DU_PAQUET} : nomme la version, \`npx grillhouse maj <x.y.z>\`.`
|
|
211
|
+
);
|
|
212
|
+
return 1;
|
|
213
|
+
}
|
|
214
|
+
let copie;
|
|
215
|
+
try {
|
|
216
|
+
({ copie } = preparerLaCopie(principal, version, pointe));
|
|
217
|
+
} catch (e) {
|
|
218
|
+
signaler(`⛔ Montée ${version} : ${e.message}`);
|
|
219
|
+
return 1;
|
|
220
|
+
}
|
|
221
|
+
const montee = { principal, branche, copie, version, pointe, duCadre };
|
|
222
|
+
const abandonner = () => {
|
|
223
|
+
restaurer(copie, version);
|
|
224
|
+
nonEntree(montee, false);
|
|
225
|
+
return 1;
|
|
226
|
+
};
|
|
227
|
+
if (existsSync(path.join(copie, '.gitmodules'))) {
|
|
228
|
+
const r = spawnSync('bash', [path.join(PAQUET, 'scripts', 'sous-modules.sh'), 'pose', copie], {
|
|
229
|
+
cwd: principal,
|
|
230
|
+
stdio: 'inherit',
|
|
231
|
+
});
|
|
232
|
+
if (r.status !== 0) {
|
|
233
|
+
return abandonner();
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (!installerDansLaCopie(montee)) {
|
|
237
|
+
signaler(`⛔ Montée ${version} : l'installation échoue ; aucun autre geste, aucun commit.`);
|
|
238
|
+
return abandonner();
|
|
239
|
+
}
|
|
240
|
+
if (duCadre) {
|
|
241
|
+
return suivre(montee, deLaMaj);
|
|
242
|
+
}
|
|
243
|
+
const paquet = path.join(copie, 'node_modules', NOM_DU_PAQUET);
|
|
244
|
+
if (existsSync(path.join(paquet, 'scripts', 'montee.mjs'))) {
|
|
245
|
+
const r = spawnSync(
|
|
246
|
+
process.execPath,
|
|
247
|
+
[path.join(paquet, 'bin', 'grillhouse.mjs'), 'maj', version],
|
|
248
|
+
{
|
|
249
|
+
cwd: copie,
|
|
250
|
+
stdio: 'inherit',
|
|
251
|
+
env: { ...process.env, [VARIABLE_DE_LA_MONTEE]: JSON.stringify(montee) },
|
|
252
|
+
}
|
|
253
|
+
);
|
|
254
|
+
return r.status ?? 1;
|
|
255
|
+
}
|
|
256
|
+
// A version from before the montée in one command: the machine alone goes back to the project's.
|
|
257
|
+
restaurer(copie, version);
|
|
258
|
+
if (version !== tenue) {
|
|
259
|
+
signaler(
|
|
260
|
+
`⛔ ${NOM_DU_PAQUET}@${version} ne connaît pas la montée en une commande : rien n'est écrit.`
|
|
261
|
+
);
|
|
262
|
+
nonEntree(montee, false);
|
|
263
|
+
return 1;
|
|
264
|
+
}
|
|
265
|
+
const echecs = jouerLePoste(montee);
|
|
266
|
+
echecs.push(...apresLAvance(montee, false));
|
|
267
|
+
retirerOuDire(montee);
|
|
268
|
+
return echecs.length > 0 ? 1 : 0;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Runs a command of the frame in the main tree; the line of its failure, which names `geste`.
|
|
272
|
+
function duPoste(principal, geste, script, args) {
|
|
273
|
+
const r = spawnSync(process.execPath, [path.join(PAQUET, script), ...args], {
|
|
274
|
+
cwd: principal,
|
|
275
|
+
encoding: 'utf8',
|
|
276
|
+
});
|
|
277
|
+
if (r.status === 0) {
|
|
278
|
+
dire(`Part du poste : ${r.stdout.trim()}`);
|
|
279
|
+
return [];
|
|
280
|
+
}
|
|
281
|
+
return [
|
|
282
|
+
`Part du poste : \`${geste}\` échoue : ${`${r.stdout ?? ''}${r.stderr ?? ''}`.trim() || r.error?.message || `code ${r.status}`}`,
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// The machine's part (installation.md §5.3), at the version and by the declarations the copy
|
|
287
|
+
// holds, with the paths and names of the main tree: the lines of failure, each said.
|
|
288
|
+
function jouerLePoste({ principal, copie, version }) {
|
|
289
|
+
const echecs = [];
|
|
290
|
+
const essayer = (geste, jouer) => {
|
|
291
|
+
try {
|
|
292
|
+
echecs.push(...jouer());
|
|
293
|
+
} catch (e) {
|
|
294
|
+
echecs.push(`Part du poste : \`${geste}\` échoue : ${e.message}`);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
essayer('npx grillhouse outil', () => {
|
|
298
|
+
const publiee = versionDeLOutil(copie) ?? version;
|
|
299
|
+
const r = installer(publiee, { retenue: 0 });
|
|
300
|
+
dire(`Part du poste : outil publié ${publiee} ${r.installe ? 'installé' : 'déjà là'}.`);
|
|
301
|
+
return [];
|
|
302
|
+
});
|
|
303
|
+
essayer('npx grillhouse greffons', () =>
|
|
304
|
+
installerGreffons(principal, {
|
|
305
|
+
declarations: copie,
|
|
306
|
+
seulement: greffonsDuProjet(principal),
|
|
307
|
+
version,
|
|
308
|
+
})
|
|
309
|
+
);
|
|
310
|
+
essayer('npx grillhouse binaires', () => {
|
|
311
|
+
const r = installerBinaires(copie);
|
|
312
|
+
if (r.installes.length > 0) {
|
|
313
|
+
dire(`Binaires installés : ${r.installes.join(', ')}.`);
|
|
314
|
+
}
|
|
315
|
+
return r.lignes;
|
|
316
|
+
});
|
|
317
|
+
essayer('npx grillhouse temporal installer', () =>
|
|
318
|
+
duPoste(principal, 'npx grillhouse temporal installer', 'dist/temporal/commande.js', [
|
|
319
|
+
'installer',
|
|
320
|
+
'--racine',
|
|
321
|
+
principal,
|
|
322
|
+
'--declarations',
|
|
323
|
+
copie,
|
|
324
|
+
])
|
|
325
|
+
);
|
|
326
|
+
essayer('npx grillhouse nuit --planifier', () =>
|
|
327
|
+
duPoste(principal, 'npx grillhouse nuit --planifier', 'dist/temporal/nuits/commande.js', [
|
|
328
|
+
'--planifier',
|
|
329
|
+
])
|
|
330
|
+
);
|
|
331
|
+
echecs.forEach(signaler);
|
|
332
|
+
if (echecs.length > 0) {
|
|
333
|
+
signaler(
|
|
334
|
+
`Part du poste en échec : \`npx grillhouse maj ${version}\` la rejoue, \`npx grillhouse maj\` revient à la version du projet.`
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
return echecs;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Whether a dependency of the main tree is not installed, or the frame's package not at the version
|
|
341
|
+
// its lock names.
|
|
342
|
+
function perime(principal) {
|
|
343
|
+
const pkg = lireJson(path.join(principal, 'package.json'));
|
|
344
|
+
const noms = CHAMPS.filter(c => c !== 'optionalDependencies').flatMap(c =>
|
|
345
|
+
Object.keys(pkg?.[c] ?? {})
|
|
346
|
+
);
|
|
347
|
+
const verrou = versionVerrouillee(lireJson(path.join(principal, 'package-lock.json')));
|
|
348
|
+
return (
|
|
349
|
+
noms.some(n => !existsSync(path.join(principal, 'node_modules', n, 'package.json'))) ||
|
|
350
|
+
(verrou !== null && declareLePaquet(pkg) && versionInstallee(principal) !== verrou)
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// What follows the advance of main (`avance`) in the main tree: its dependencies, then the plugins
|
|
355
|
+
// it declares; the lines of failure, each said.
|
|
356
|
+
function apresLAvance({ principal, version }, avance) {
|
|
357
|
+
const echecs = [];
|
|
358
|
+
if ((avance || perime(principal)) && !npm(principal, ['install'])) {
|
|
359
|
+
echecs.push(
|
|
360
|
+
`Arbre principal : \`npm install\` reste à jouer ; \`npx grillhouse maj ${version}\` le rejoue.`
|
|
361
|
+
);
|
|
362
|
+
signaler(echecs[0]);
|
|
363
|
+
}
|
|
364
|
+
poserCrochets(principal);
|
|
365
|
+
const greffons = installerGreffons(principal, { version });
|
|
366
|
+
greffons.forEach(signaler);
|
|
367
|
+
return [...echecs, ...greffons];
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Removes the copy, or says why it stays.
|
|
371
|
+
function retirerOuDire({ principal, copie, version }) {
|
|
372
|
+
if (!retirerLaCopie(principal, copie, version)) {
|
|
373
|
+
dire(
|
|
374
|
+
`La copie de la montée reste, ${copie} : elle porte un changement non commité d'un autre (${changements(copie).join(', ')}).`
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Main advanced to `commit` by fast-forward in the main tree: `{ avance }`, `{ bouge }` when main
|
|
380
|
+
// moved off `base`, else the files that hold it.
|
|
381
|
+
function avancer({ principal, branche }, base, commit, fichiers) {
|
|
382
|
+
const pointe = () => git(principal, 'rev-parse', `refs/heads/${branche}`);
|
|
383
|
+
if (pointe() !== base) {
|
|
384
|
+
return { bouge: true };
|
|
385
|
+
}
|
|
386
|
+
const r = resultatDeGit(principal, ['merge', '-q', '--ff-only', commit]);
|
|
387
|
+
if (r.status === 0) {
|
|
388
|
+
return { avance: true };
|
|
389
|
+
}
|
|
390
|
+
if (pointe() !== base) {
|
|
391
|
+
return { bouge: true };
|
|
392
|
+
}
|
|
393
|
+
const retenus = changements(principal).filter(f => fichiers.includes(f));
|
|
394
|
+
return { retenus, raison: r.stderr.trim() };
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* The rest of the montée `montee`, its copy installed (see the header): the exit code.
|
|
399
|
+
* @param {{ principal: string, branche: string, copie: string, version: string, pointe: string,
|
|
400
|
+
* duCadre: boolean }} montee
|
|
401
|
+
* @param {Fichiers} deLaMaj
|
|
402
|
+
*/
|
|
403
|
+
export function suivre(montee, { ecrireLeProjet, verifier }) {
|
|
404
|
+
const { principal, branche, copie, version, duCadre } = montee;
|
|
405
|
+
let { pointe } = montee;
|
|
406
|
+
let echecs = null;
|
|
407
|
+
let entree = false;
|
|
408
|
+
// Lays back what was set aside, says the montée did not enter, and gives the exit code.
|
|
409
|
+
const arreter = (cause, code = 1) => {
|
|
410
|
+
const enConflit = restaurer(copie, version);
|
|
411
|
+
if (cause) {
|
|
412
|
+
signaler(cause);
|
|
413
|
+
}
|
|
414
|
+
if (enConflit.length > 0) {
|
|
415
|
+
signaler(`Le changement d'un autre reste tel quel dans la copie : ${enConflit.join(', ')}.`);
|
|
416
|
+
}
|
|
417
|
+
if (!entree) {
|
|
418
|
+
nonEntree({ ...montee, pointe }, echecs !== null);
|
|
419
|
+
}
|
|
420
|
+
return code;
|
|
421
|
+
};
|
|
422
|
+
try {
|
|
423
|
+
for (let passe = 1; passe <= PASSES_MAX; passe++) {
|
|
424
|
+
if (passe > 1) {
|
|
425
|
+
pointe = git(principal, 'rev-parse', `refs/heads/${branche}`);
|
|
426
|
+
dire(`main a avancé : la montée se réécrit depuis ${pointe.slice(0, 7)} (passe ${passe}).`);
|
|
427
|
+
remettreSur(copie, pointe);
|
|
428
|
+
if (!installerDansLaCopie(montee)) {
|
|
429
|
+
return arreter(`⛔ Montée ${version} : l'installation échoue ; aucun commit.`);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
let sansVerifier = null;
|
|
433
|
+
const aFaire = ecrireLeProjet(copie, {
|
|
434
|
+
version,
|
|
435
|
+
duCadre,
|
|
436
|
+
noterSansVerifier: ligne => {
|
|
437
|
+
sansVerifier = ligne;
|
|
438
|
+
},
|
|
439
|
+
});
|
|
440
|
+
const fichiers = fichiersEcrits(copie);
|
|
441
|
+
garderLEtat(copie, version, fichiers);
|
|
442
|
+
echecs ??= jouerLePoste(montee);
|
|
443
|
+
const enConflit = conflits(copie, version);
|
|
444
|
+
if (aFaire || enConflit.length > 0) {
|
|
445
|
+
const v = aFaire
|
|
446
|
+
? verifier(copie, { fichiersAFinir: true, installer: false })
|
|
447
|
+
: {
|
|
448
|
+
ligne: `⛔ Conflit avec un changement non commité d'un autre : ${enConflit.join(', ')}.`,
|
|
449
|
+
};
|
|
450
|
+
return arreter(`${v.ligne}\nAucun commit.`);
|
|
451
|
+
}
|
|
452
|
+
if (fichiers.length === 0) {
|
|
453
|
+
dire(`Montée ${version} : rien à commiter, le projet est à jour ; aucun commit.`);
|
|
454
|
+
restaurer(copie, version);
|
|
455
|
+
const apres = apresLAvance(montee, false);
|
|
456
|
+
retirerOuDire(montee);
|
|
457
|
+
return echecs.length + apres.length > 0 ? 1 : 0;
|
|
458
|
+
}
|
|
459
|
+
const arbre = arbreDe(copie, pointe, fichiers);
|
|
460
|
+
const v = verifier(copie, { fichiersAFinir: false, installer: false, sansVerifier });
|
|
461
|
+
// What the verification wrote besides the montée's files goes.
|
|
462
|
+
const deLaVerification = changements(copie).filter(f => !fichiers.includes(f));
|
|
463
|
+
for (const f of deLaVerification) {
|
|
464
|
+
if (resultatDeGit(copie, ['checkout', '-q', 'HEAD', '--', f]).status !== 0) {
|
|
465
|
+
resultatDeGit(copie, ['clean', '-q', '-f', '--', f]);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
(v.erreur ? signaler : dire)(v.ligne);
|
|
469
|
+
if (v.code !== 0) {
|
|
470
|
+
return arreter('Aucun commit.', v.code === 75 ? 75 : 1);
|
|
471
|
+
}
|
|
472
|
+
const commit = git(
|
|
473
|
+
copie,
|
|
474
|
+
'commit-tree',
|
|
475
|
+
arbre,
|
|
476
|
+
'-p',
|
|
477
|
+
pointe,
|
|
478
|
+
'-m',
|
|
479
|
+
`Montée du cadre à ${version}`
|
|
480
|
+
);
|
|
481
|
+
garderLArbreJuge(copie, arbre);
|
|
482
|
+
garderLEtat(copie, version, fichiers, commit);
|
|
483
|
+
git(copie, 'reset', '-q', '--soft', commit);
|
|
484
|
+
git(copie, 'reset', '-q');
|
|
485
|
+
const a = avancer(montee, pointe, commit, fichiers);
|
|
486
|
+
if (a.bouge) {
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
if (!a.avance) {
|
|
490
|
+
return arreter(
|
|
491
|
+
`⛔ main n'avance pas : l'arbre principal porte un changement non commité sur un fichier du lot (${a.retenus.join(', ')}). ${a.raison}`
|
|
492
|
+
);
|
|
493
|
+
}
|
|
494
|
+
entree = true;
|
|
495
|
+
dire(
|
|
496
|
+
`Commit ${commit.slice(0, 7)} « Montée du cadre à ${version} » : ${fichiers.join(', ')} ; ${branche} avancée.`
|
|
497
|
+
);
|
|
498
|
+
const apres = [];
|
|
499
|
+
if (resultatDeGit(principal, ['remote', 'get-url', 'origin']).status === 0) {
|
|
500
|
+
const p = resultatDeGit(principal, ['push', '-q', 'origin', branche]);
|
|
501
|
+
if (p.status !== 0) {
|
|
502
|
+
apres.push(`⛔ \`git push origin ${branche}\` échoue : ${p.stderr.trim()}`);
|
|
503
|
+
signaler(apres[0]);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
apres.push(...apresLAvance(montee, true));
|
|
507
|
+
restaurer(copie, version);
|
|
508
|
+
retirerOuDire(montee);
|
|
509
|
+
return echecs.length + apres.length > 0 ? 1 : 0;
|
|
510
|
+
}
|
|
511
|
+
return arreter(
|
|
512
|
+
`⛔ main a avancé à chacune des ${PASSES_MAX} passes : la montée s'arrête sans avancer main.`
|
|
513
|
+
);
|
|
514
|
+
} catch (e) {
|
|
515
|
+
return arreter(`⛔ Montée ${version} : ${e.message}`);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/** The montée this process plays the rest of, from the variable of the launching command, or null. */
|
|
520
|
+
export function monteeRecue(env = process.env) {
|
|
521
|
+
const recue = env[VARIABLE_DE_LA_MONTEE];
|
|
522
|
+
delete env[VARIABLE_DE_LA_MONTEE];
|
|
523
|
+
return recue ? JSON.parse(recue) : null;
|
|
524
|
+
}
|
package/scripts/outil.mjs
CHANGED
|
@@ -16,9 +16,11 @@ import path from 'node:path';
|
|
|
16
16
|
import { pathToFileURL } from 'node:url';
|
|
17
17
|
import { CLE, installer, NOM_DU_PAQUET, versionDeLOutil, X_Y_Z } from './aiguillage.mjs';
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Writes `version` as the key of the package.json at `racine`, its other fields and its
|
|
21
|
+
* indentation kept.
|
|
22
|
+
*/
|
|
23
|
+
export function ecrireLaCle(racine, version) {
|
|
22
24
|
const f = path.join(racine, 'package.json');
|
|
23
25
|
const texte = readFileSync(f, 'utf8');
|
|
24
26
|
const pkg = JSON.parse(texte);
|