@ucm-kit/cli 0.1.151 → 0.2.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/README.md CHANGED
@@ -16,7 +16,7 @@ matches them.
16
16
  Requires Node 20 or later. At the root of the repository:
17
17
 
18
18
  ```sh
19
- npx --yes @ucm-kit/cli@0.1.151 init
19
+ npx --yes @ucm-kit/cli@0.2.0 init
20
20
  ```
21
21
 
22
22
  1. Commit and push the files `init` wrote.
@@ -27,7 +27,7 @@ npx --yes @ucm-kit/cli@0.1.151 init
27
27
  To run the check locally:
28
28
 
29
29
  ```sh
30
- npx --yes @ucm-kit/cli@0.1.151 check --report ci-report.md
30
+ npx --yes @ucm-kit/cli@0.2.0 check --report ci-report.md
31
31
  ```
32
32
 
33
33
  `--yes` skips the npx confirmation prompt. Pin an exact version, without `^`:
@@ -37,7 +37,9 @@ a range lets npx install a build this project has not tested.
37
37
  writes needs no `package.json`, so an iOS or Android repository, or a plain
38
38
  folder of contracts, can have its exports checked. When a `package-lock.json`
39
39
  exists, the workflow runs `npm ci` first, so `ucm check` finds a stack adapter
40
- the repository installed.
40
+ the repository installed. It runs the CLI installed in `node_modules`, so
41
+ updating the dependency does not require a second version edit in the workflow.
42
+ Without a Node manifest, the portable check uses the CLI served by npm.
41
43
 
42
44
  ## Commands
43
45
 
@@ -78,7 +80,7 @@ contract would resolve to the same file. A repository that does not write React
78
80
  states its own extension:
79
81
 
80
82
  ```sh
81
- npx --yes @ucm-kit/cli@0.1.151 init --components Sources/DesignSystem --implementation '{dir}/{id}.swift'
83
+ npx --yes @ucm-kit/cli@0.2.0 init --components Sources/DesignSystem --implementation '{dir}/{id}.swift'
82
84
  ```
83
85
 
84
86
  The three path options act only on a first install. `ucm init` never overwrites
@@ -188,7 +190,7 @@ directory. It writes a minimal report when the check stopped before writing
188
190
  one, then posts the report:
189
191
 
190
192
  ```sh
191
- npx --yes @ucm-kit/cli@0.1.151 rapport-gitlab --projet "$CI_PROJECT_ID" --merge-request "$CI_MERGE_REQUEST_IID" --fichier "$CI_PROJECT_DIR/ci-report.md" --api "$CI_API_V4_URL"
193
+ npx --yes @ucm-kit/cli@0.2.0 rapport-gitlab --projet "$CI_PROJECT_ID" --merge-request "$CI_MERGE_REQUEST_IID" --fichier "$CI_PROJECT_DIR/ci-report.md" --api "$CI_API_V4_URL"
192
194
  ```
193
195
 
194
196
  | Option | Effect |
@@ -243,9 +245,19 @@ the code or at the token file.
243
245
  | Composition: every nested component has its own contract, the lists agree, no cycles | Blocks |
244
246
  | Typography tokens have the expected type | Blocks |
245
247
  | Every `{token.path}` cited exists in the token file | Warns, but a missing or unreadable token file blocks |
246
- | The code exposes the props the contract declares, with a stack adapter installed | Warns |
248
+ | The code exposes the props the contract declares, with a stack adapter installed | Blocks a pull request that touches the code or a contract with a gap; otherwise reports the lag |
247
249
  | Each text, icon, border or ring colour reaches its contrast against its background | Information, never blocks |
248
250
 
251
+ A gap in the code now blocks the merge. This tightened verdict is class 6 of
252
+ `docs/format/COMPATIBILITE.md`: the format does not change, but a pipeline that
253
+ stayed green on a gap turns red. A component whose contract was exported after
254
+ its code is reported as behind its contract and does not block the designer's
255
+ export. A developer who accepts a precise gap writes it in
256
+ `.ucm/derogations.json`. Each entry names `composant`, `ecart` (its `genre` and
257
+ coordinates), `export` (the `meta.exportedAt` of the contract), `motif` and
258
+ `par`; an unknown field refuses the entry. An entry stops applying when the
259
+ next export changes `meta.exportedAt`. An agent never writes this file.
260
+
249
261
  The direction of a version gap names who fixes it. A contract that is too old
250
262
  is re-exported by the designer. A contract that is too new needs this package
251
263
  upgraded by a developer.
@@ -265,6 +277,17 @@ information that never blocks the merge. The contract does not say whether a
265
277
  text is large, where the threshold drops to 3:1: a false signal stays
266
278
  information. A colour outside sRGB, or translucent, is not measured.
267
279
 
280
+ The check also judges the architecture of `tokens.json`, with the two checks
281
+ UCM Architect runs on a Figma file: the theme's variables, the layers they
282
+ target, scopes, modes and the sizing scales. It applies without any option,
283
+ because every tool except the Exporter follows the UCM architecture. Its
284
+ findings are information and never block the merge, so a pull request that
285
+ carries only tokens stays green. The report groups them by kind, with the count
286
+ and three examples of each, in its last section, and only when the pull request
287
+ changes `tokens.json` (without `--base`, always). A file where no collection has
288
+ a UCM name gets one line saying the architecture is not judged. Composite tokens
289
+ (typography, shadow, curve) are not Figma variables and are not judged.
290
+
268
291
  A gap with the code warns: a developer closes it, and the merge goes through. A
269
292
  token removed from the design system warns too, so an older contract does not
270
293
  hold back the tokens. A contract may land before the code that implements it.
@@ -393,8 +416,9 @@ overwritten.
393
416
  writes to `<file>`:
394
417
 
395
418
  1. what to read again first: conventions anomalies, copied sections whose
396
- default writing changed, and `@ucm-kit/cli` pins that differ between the two
397
- relays, the workflow and `package.json`;
419
+ default writing changed, `@ucm-kit/cli` pins that differ between the two
420
+ relays, the workflow and `package.json`, and an `@ucm-kit/core` installed in
421
+ the repository at another version than the one this CLI runs with;
398
422
  2. the procedure, `procedure.md`;
399
423
  3. the text before the first section of the closest conventions file;
400
424
  4. the target contract's version, portable coverage and export diagnostics,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucm-kit/cli",
3
- "version": "0.1.151",
3
+ "version": "0.2.0",
4
4
  "description": "La ligne de commande UCM : initialiser un repository, lister ce qu'il doit couvrir.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  "test": "node scripts/run-tests.cjs"
30
30
  },
31
31
  "dependencies": {
32
- "@ucm-kit/core": "0.16.0"
32
+ "@ucm-kit/core": "0.17.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "yaml": "^2.9.1"
package/procedure.md CHANGED
@@ -41,6 +41,8 @@ partie concernée. L'écriture ne l'emporte jamais sur le sens.
41
41
  - Fusionner deux vues, déduire une propriété d'un nom, produire un produit
42
42
  cartésien, combler une clé absente.
43
43
  - Modifier le contrat, les tokens, un fichier généré ou un contrôle.
44
+ - Écrire dans `.ucm/derogations.json`. Seul un développeur y pose une exception, avec son motif et son nom.
45
+ - Rattraper un composant en retard sur son contrat. Ce n'est pas la tâche de l'agent, sauf demande explicite du développeur.
44
46
 
45
47
  ## Vérifier
46
48
 
@@ -1,10 +1,21 @@
1
1
  /** Découverte optionnelle des adaptateurs officiels depuis le repository contrôlé. */
2
2
  import { createRequire } from "node:module";
3
- import { join } from "node:path";
3
+ import { existsSync } from "node:fs";
4
+ import { extname, join } from "node:path";
4
5
  import { pathToFileURL } from "node:url";
5
6
 
6
7
  export const NOM_ADAPTATEUR_TYPESCRIPT = "@ucm-kit/adapter-typescript";
7
8
 
9
+ /** Les seules extensions qu'un adaptateur officiel sait lire. Le noyau reçoit le fait, sans connaître ces technologies. */
10
+ export const EXTENSIONS_PAR_ADAPTATEUR = Object.freeze({ [NOM_ADAPTATEUR_TYPESCRIPT]: [".ts", ".tsx"] });
11
+
12
+ /** État du lecteur attendu par le motif d'implémentation du repository. */
13
+ export function etatDeLAdaptateur(motif, { adaptateur, erreurAdaptateur } = {}) {
14
+ const attendu = Object.values(EXTENSIONS_PAR_ADAPTATEUR).some((extensions) => extensions.includes(extname(motif).toLowerCase()));
15
+ if (!attendu) return "sans-adaptateur";
16
+ return erreurAdaptateur ? "casse" : adaptateur ? "present" : "absent";
17
+ }
18
+
8
19
  /**
9
20
  * Charge l'adaptateur TypeScript s'il est installé par le repository.
10
21
  *
@@ -18,7 +29,8 @@ export async function chargerAdaptateur(racine) {
18
29
  try {
19
30
  chemin = depuisLeRepository.resolve(NOM_ADAPTATEUR_TYPESCRIPT);
20
31
  } catch (erreur) {
21
- if (erreur?.code === "MODULE_NOT_FOUND") return null;
32
+ const installe = depuisLeRepository.resolve.paths(NOM_ADAPTATEUR_TYPESCRIPT)?.some((dossier) => existsSync(join(dossier, NOM_ADAPTATEUR_TYPESCRIPT, "package.json")));
33
+ if (erreur?.code === "MODULE_NOT_FOUND" && !installe) return null;
22
34
  throw erreur;
23
35
  }
24
36
 
package/src/check.mjs CHANGED
@@ -12,6 +12,8 @@ import { controlerRepository, lireConfiguration } from "@ucm-kit/core/lecteurs";
12
12
  import { NOM_CONFIGURATION } from "@ucm-kit/core/format";
13
13
  import { contratsDuDossier } from "./contrats.mjs";
14
14
  import { memeFichier } from "./tokens-css.mjs";
15
+ import { etatDeLAdaptateur } from "./adaptateur.mjs";
16
+ import { mesurerLesRangs } from "./rangs.mjs";
15
17
 
16
18
  /**
17
19
  * Lit les arguments de `ucm check`.
@@ -63,7 +65,7 @@ export function releveDuDiff(racine, base, sourceTokens, executer = execFileSync
63
65
  // et aucune extension de fichier ne s'écrit ici.
64
66
  let cheminsModifies;
65
67
  try {
66
- cheminsModifies = git(["diff", "--name-only", "-z", base, "HEAD"]);
68
+ cheminsModifies = git(["diff", "--name-only", "-z", "--relative", base, "HEAD"]);
67
69
  } catch (erreur) {
68
70
  return {
69
71
  erreur: `Le diff depuis « ${base} » a échoué : ${erreur?.message ?? erreur}.\n`
@@ -106,7 +108,9 @@ export function releveDuDiff(racine, base, sourceTokens, executer = execFileSync
106
108
  export function check(arguments_, {
107
109
  racine = process.cwd(),
108
110
  adaptateur,
111
+ erreurAdaptateur,
109
112
  echecsDeTests,
113
+ maintenant = new Date(),
110
114
  ecrire = console.log,
111
115
  avertir = console.warn,
112
116
  alerter = console.error,
@@ -152,10 +156,25 @@ export function check(arguments_, {
152
156
  perimetre = releve;
153
157
  }
154
158
 
159
+ let mesures;
160
+ try {
161
+ mesures = mesurerLesRangs(racine, configuration, contratsDuDossier(resolve(racine, configuration.components)), {
162
+ base: options.base,
163
+ modifies: (perimetre.cheminsModifies ?? "").split("\n").filter(Boolean),
164
+ executer: executerGit,
165
+ maintenant,
166
+ });
167
+ } catch (erreur) {
168
+ alerter(erreur?.message ?? String(erreur));
169
+ return 2;
170
+ }
155
171
  const verdict = controlerRepository(racine, {
156
172
  configuration,
157
173
  adaptateur,
158
174
  echecsDeTests,
175
+ maintenant,
176
+ adaptateurAttendu: etatDeLAdaptateur(configuration.implementation, { adaptateur, erreurAdaptateur }),
177
+ ...mesures,
159
178
  ...perimetre,
160
179
  });
161
180
 
@@ -170,5 +189,5 @@ export function check(arguments_, {
170
189
  ecrireFichier(cible, `${verdict.rapport}\n`, "utf8");
171
190
  }
172
191
 
173
- return verdict.bloquant ? 1 : 0;
192
+ return verdict.erreurDInvocation ? 2 : verdict.bloquant ? 1 : 0;
174
193
  }
package/src/guide.mjs CHANGED
@@ -12,6 +12,7 @@
12
12
  * incohérent, 2 invocation, configuration ou contrat illisible.
13
13
  */
14
14
  import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
15
+ import { createRequire } from "node:module";
15
16
  import { dirname, join, relative, resolve } from "node:path";
16
17
 
17
18
  import { NOM_CONFIGURATION, etatDuFormatDeTokens } from "@ucm-kit/core/format";
@@ -227,6 +228,30 @@ export function pinsEnDesaccord(racine) {
227
228
  ];
228
229
  }
229
230
 
231
+ /** La version de `@ucm-kit/core` que cette CLI embarque : celle qui juge le repository avec elle. */
232
+ const versionDuNoyauDeLaCli = () => createRequire(import.meta.url)("@ucm-kit/core/package.json").version;
233
+
234
+ /**
235
+ * Le `@ucm-kit/core` installé dans le repository, nommé quand sa version n'est
236
+ * pas celle de la CLI : deux kits peuvent juger le même contrat autrement, et
237
+ * le module qui appelle l'un laisse `ucm check` appeler l'autre. Rend une
238
+ * ligne, ou rien si le repository n'installe pas le kit ou s'il le tient à la
239
+ * même version.
240
+ */
241
+ export function noyauEnDesaccord(racine, versionDeLaCli = versionDuNoyauDeLaCli()) {
242
+ let installee;
243
+ try {
244
+ installee = lireJson(join(racine, "node_modules", "@ucm-kit", "core", "package.json")).version;
245
+ } catch {
246
+ return [];
247
+ }
248
+ if (typeof installee !== "string" || installee === versionDeLaCli) return [];
249
+ return [
250
+ `${GLYPHES.corriger.brut} Le @ucm-kit/core installé dans ce repository (${installee}) n'est pas celui de cette CLI (${versionDeLaCli}) : `
251
+ + "épinglez le même numéro des deux côtés.",
252
+ ];
253
+ }
254
+
230
255
  /**
231
256
  * Les modes qui touchent le contrat : un refus quand le fichier de tokens est
232
257
  * incohérent, sinon le texte de la section.
@@ -374,6 +399,7 @@ export function guide(arguments_, {
374
399
  alerter = console.error,
375
400
  ecrireFichier = writeFileSync,
376
401
  catalogue = catalogueDesAides(),
402
+ versionDuNoyau = versionDuNoyauDeLaCli(),
377
403
  } = {}) {
378
404
  const { options, erreur } = lireArgumentsGuide(arguments_);
379
405
  if (erreur) {
@@ -439,7 +465,7 @@ export function guide(arguments_, {
439
465
  const caracteristiques = caracteristiquesDuContrat(contrat, contratsParNom, modes.cones);
440
466
  const { aides, nonTranches } = aidesDuContrat(caracteristiques, catalogue, conventions);
441
467
 
442
- const aRelire = [...avertissements(conventions, cheminConventions, racine, catalogue), ...pinsEnDesaccord(racine)];
468
+ const aRelire = [...avertissements(conventions, cheminConventions, racine, catalogue), ...pinsEnDesaccord(racine), ...noyauEnDesaccord(racine, versionDuNoyau)];
443
469
  const icones = entreesCitees(contrat.icons, iconesUtilisees(contrat));
444
470
  const parties = [
445
471
  ["à relire", aRelire.length === 0 ? "" : ["## À relire avant de commencer", "", ...aRelire, ""].join("\n")],
package/src/init.mjs CHANGED
@@ -11,8 +11,8 @@
11
11
  *
12
12
  * **Elle n'écrit aucune version du format**, nulle part : la configuration
13
13
  * n'en porte aucune (voir `configuration.mjs` du kit), et le paquet installé
14
- * dit ce qu'il lit. Le seul numéro écrit est le pin de la CLI, dans le workflow
15
- * et dans les deux relais d'agent.
14
+ * dit ce qu'il lit. Les deux relais d'agent épinglent la CLI ; le workflow
15
+ * lance celle que le repository installe.
16
16
  *
17
17
  * **`--components`, `--tokens` et `--implementation` décident une seule fois.** Le
18
18
  * `ucm.config.json` écrit ici est la seule autorité sur l'endroit où les
@@ -261,7 +261,7 @@ function fichiers(version, chemins, { agents = true, gabarits = [], forge = "git
261
261
  },
262
262
  ...(forge === "gitlab"
263
263
  ? [
264
- { chemin: CHEMIN_CI_GITLAB, contenu: workflowGitlab(version) },
264
+ { chemin: CHEMIN_CI_GITLAB, contenu: workflowGitlab() },
265
265
  {
266
266
  chemin: ".gitlab-ci.yml",
267
267
  contenu: `include:\n - local: ${CHEMIN_CI_GITLAB}\n`,
@@ -269,7 +269,7 @@ function fichiers(version, chemins, { agents = true, gabarits = [], forge = "git
269
269
  rappel: `ajoutez \`- local: ${CHEMIN_CI_GITLAB}\` à sa liste \`include:\`. Sans cette ligne, le job ucm ne tourne jamais et aucune merge request n'est contrôlée.`,
270
270
  },
271
271
  ]
272
- : [{ chemin: ".github/workflows/ucm.yml", contenu: workflow(version) }]),
272
+ : [{ chemin: ".github/workflows/ucm.yml", contenu: workflow() }]),
273
273
  ...(agents
274
274
  ? [
275
275
  { chemin: ".agents/skills/ucm-implementer/SKILL.md", contenu: relais(version) },
@@ -389,6 +389,19 @@ function lignesRestantes(racine, version, configuration) {
389
389
  return lignes;
390
390
  }
391
391
 
392
+ /** Un repository Node utilise sa CLI installée ; un dossier sans stack Node garde le contrôle portable par npm. */
393
+ function lancementUcm(marge) {
394
+ return [
395
+ 'ucm() {',
396
+ ' if [ -f package.json ]; then',
397
+ ' node node_modules/@ucm-kit/cli/src/ucm.mjs "$@"',
398
+ ' else',
399
+ ' npx --yes @ucm-kit/cli "$@"',
400
+ ' fi',
401
+ '}',
402
+ ].map((ligne) => marge + ligne);
403
+ }
404
+
392
405
  /**
393
406
  * Le workflow de contrôle, écrit pour un repository quelconque.
394
407
  *
@@ -417,8 +430,8 @@ function lignesRestantes(racine, version, configuration) {
417
430
  * la séparation ne borne que ce qu'une dépendance obtient. Une fourche reçoit
418
431
  * de GitHub un jeton en lecture seule, et son commentaire échoue.
419
432
  */
420
- function workflow(version) {
421
- const commande = `npx --yes @ucm-kit/cli@${version} check --report ci-report.md`;
433
+ function workflow() {
434
+ const commande = 'ucm check --report ci-report.md';
422
435
  return [
423
436
  "# Contrôle des contrats UCM.",
424
437
  "#",
@@ -467,6 +480,7 @@ function workflow(version) {
467
480
  " env:",
468
481
  " BASE_SHA: ${{ github.event.pull_request.base.sha }}",
469
482
  " run: |",
483
+ ...lancementUcm(' '),
470
484
  ' if [ -n "$BASE_SHA" ]; then',
471
485
  ` ${commande} --base "$BASE_SHA"`,
472
486
  " else",
@@ -581,8 +595,8 @@ function workflow(version) {
581
595
  * de `ucm`, et `allow_failure` garde le pipeline de la couleur du contrôle
582
596
  * quand GitLab refuse le jeton : le rapport reste dans les artefacts.
583
597
  */
584
- function workflowGitlab(version) {
585
- const cli = `npx --yes @ucm-kit/cli@${version}`;
598
+ function workflowGitlab() {
599
+ const cli = 'ucm';
586
600
  return [
587
601
  "# Contrôle des contrats UCM, inclus par .gitlab-ci.yml.",
588
602
  "#",
@@ -619,6 +633,7 @@ function workflowGitlab(version) {
619
633
  " # noyau portable reste seul.",
620
634
  " - if [ -f package-lock.json ]; then npm ci; fi",
621
635
  " - |",
636
+ ...lancementUcm(' '),
622
637
  ' if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then',
623
638
  ` ${cli} check --report ci-report.md --base "$CI_MERGE_REQUEST_DIFF_BASE_SHA"`,
624
639
  " else",
@@ -660,7 +675,7 @@ function workflowGitlab(version) {
660
675
  " # Depuis un dossier vide, npx ne lit ni configuration ni paquet laissés",
661
676
  " # par un job précédent sur le runner.",
662
677
  " - cd \"$(mktemp -d)\"",
663
- ` - ${cli} rapport-gitlab --projet "$CI_PROJECT_ID" --merge-request "$CI_MERGE_REQUEST_IID" --fichier "$CI_PROJECT_DIR/ci-report.md" --api "$CI_API_V4_URL"`,
678
+ ' - npx --yes @ucm-kit/cli rapport-gitlab --projet "$CI_PROJECT_ID" --merge-request "$CI_MERGE_REQUEST_IID" --fichier "$CI_PROJECT_DIR/ci-report.md" --api "$CI_API_V4_URL"',
664
679
  "",
665
680
  ].join("\n");
666
681
  }
package/src/rangs.mjs ADDED
@@ -0,0 +1,55 @@
1
+ /** Mesure les rangs des contrats, de leur implémentation et des tokens sur le premier parent de Git. Le kit juge ces mesures. */
2
+ import { execFileSync } from "node:child_process";
3
+ import { relative, resolve } from "node:path";
4
+ import { cheminImplementation, identifiantDuContrat } from "@ucm-kit/core/lecteurs";
5
+
6
+ /** Un chemin relatif au dossier contrôlé, avec les séparateurs que Git rend. */
7
+ const relatif = (racine, chemin) => relative(racine, resolve(racine, chemin)).replaceAll("\\", "/");
8
+ const cheminsDe = (texte) => texte.split("\0").filter(Boolean);
9
+
10
+ /**
11
+ * Sans dépôt Git, rend `historique: aucun`. Un clone superficiel se rend au kit sans rangs pour son diagnostic d'invocation.
12
+ * Avec base, les changements viennent du diff de la demande ; sans base, ils viennent de la copie de travail, index compris.
13
+ * Un fichier absent de la ligne principale reçoit `null`, jamais un rang qui inventerait son ancienneté.
14
+ */
15
+ export function mesurerLesRangs(racine, configuration, contrats, { base = null, modifies = [], executer = execFileSync, maintenant = new Date() } = {}) {
16
+ const git = (arguments_) => executer("git", arguments_, { cwd: racine, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
17
+ try { git(["rev-parse", "--show-toplevel"]); } catch (erreur) {
18
+ if (/not a git repository/i.test(String(erreur?.stderr))) return { historique: "aucun", rangs: {} };
19
+ throw erreur;
20
+ }
21
+ if (git(["rev-parse", "--is-shallow-repository"]).trim() === "true") return { historique: "superficiel", rangs: {} };
22
+
23
+ const reference = base ?? "HEAD";
24
+ let commits;
25
+ try { commits = git(["rev-list", "--first-parent", reference]).trim().split("\n").filter(Boolean); } catch (erreur) {
26
+ // Un dépôt initialisé, sans premier commit, n'a encore aucun rang. Une base donnée qui n'existe pas reste une erreur.
27
+ if (!base && /bad revision|unknown revision|ambiguous argument/i.test(String(erreur?.stderr))) return { historique: "aucun", rangs: {} };
28
+ throw erreur;
29
+ }
30
+ const rangParCommit = new Map(commits.map((commit, rang) => [commit, rang + 1]));
31
+ const modifiesDuDossier = new Set(modifies.map((chemin) => relatif(racine, chemin)));
32
+ if (!base) {
33
+ for (const chemin of cheminsDe(git(["diff", "--name-only", "-z", "--relative", "HEAD"]))) modifiesDuDossier.add(chemin);
34
+ for (const chemin of cheminsDe(git(["ls-files", "--others", "--exclude-standard", "-z"]))) modifiesDuDossier.add(chemin);
35
+ }
36
+ const mesures = new Map();
37
+ const mesurer = (chemin) => {
38
+ const nom = relatif(racine, chemin);
39
+ if (mesures.has(nom)) return mesures.get(nom);
40
+ let mesure;
41
+ if (modifiesDuDossier.has(nom)) mesure = { rang: 0, depuis: new Date(maintenant).toISOString() };
42
+ else {
43
+ const dernier = git(["log", "--first-parent", "--diff-merges=first-parent", "-1", "--format=%H%x00%cI", reference, "--", `:(literal)${nom}`]).trim();
44
+ const [commit, depuis] = dernier.split("\0");
45
+ mesure = { rang: rangParCommit.get(commit) ?? null, ...(depuis ? { depuis } : {}) };
46
+ }
47
+ mesures.set(nom, mesure);
48
+ return mesure;
49
+ };
50
+ const composants = Object.fromEntries(contrats.map((contrat) => {
51
+ const contratMesure = mesurer(contrat);
52
+ return [identifiantDuContrat(contrat), { contrat: contratMesure.rang, code: mesurer(cheminImplementation(contrat, configuration.implementation)).rang, depuis: contratMesure.depuis }];
53
+ }));
54
+ return { historique: "complet", rangs: { tokens: mesurer(configuration.tokens).rang, composants } };
55
+ }
package/src/ucm.mjs CHANGED
@@ -11,7 +11,7 @@ import { pathToFileURL } from "node:url";
11
11
 
12
12
  import { lireConfiguration } from "@ucm-kit/core/lecteurs";
13
13
 
14
- import { chargerAdaptateur, NOM_ADAPTATEUR_TYPESCRIPT } from "./adaptateur.mjs";
14
+ import { chargerAdaptateur } from "./adaptateur.mjs";
15
15
  import { aides } from "./aides.mjs";
16
16
  import { check } from "./check.mjs";
17
17
  import { guide } from "./guide.mjs";
@@ -205,15 +205,13 @@ function executerCommande(arguments_, {
205
205
  echecsDeTests: tests.valeur,
206
206
  ecrire,
207
207
  ...sorties,
208
- }), (erreur) => {
209
- const alerter = sorties.alerter ?? console.error;
210
- alerter(
211
- `L'adaptateur ${NOM_ADAPTATEUR_TYPESCRIPT} est installé mais n'a pas pu être chargé : `
212
- + `${erreur?.message ?? erreur}\n`
213
- + "Un développeur doit corriger son installation ou son tsconfig.json.",
214
- );
215
- return 2;
216
- });
208
+ }), (erreurAdaptateur) => check(arguments_.slice(1), {
209
+ racine,
210
+ erreurAdaptateur,
211
+ echecsDeTests: tests.valeur,
212
+ ecrire,
213
+ ...sorties,
214
+ }));
217
215
  }
218
216
 
219
217
  if (commande === "tokens") {