@ucm-kit/cli 0.1.37 → 0.1.38

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
@@ -11,8 +11,8 @@ next to the component's code. This command reads those files and says whether
11
11
  they still hold together.
12
12
 
13
13
  ```sh
14
- npx --yes @ucm-kit/cli@0.1.37 init
15
- npx --yes @ucm-kit/cli@0.1.37 check --report ci-report.md
14
+ npx --yes @ucm-kit/cli@0.1.38 init
15
+ npx --yes @ucm-kit/cli@0.1.38 check --report ci-report.md
16
16
  ```
17
17
 
18
18
  Pin an exact version, without `^`. A range would let npx install a build this
@@ -62,7 +62,7 @@ not write React states its own extension here, rather than carrying a `.tsx`
62
62
  that was wrong the day it was installed:
63
63
 
64
64
  ```sh
65
- npx --yes @ucm-kit/cli@0.1.37 init --components Sources/DesignSystem --implementation '{dir}/{id}.swift'
65
+ npx --yes @ucm-kit/cli@0.1.38 init --components Sources/DesignSystem --implementation '{dir}/{id}.swift'
66
66
  ```
67
67
 
68
68
  All three act only on a first install: `ucm init` never overwrites an existing
@@ -76,6 +76,10 @@ has one.
76
76
  | `--base <sha>` | Limits informational notices to contracts changed since that commit |
77
77
  | `--report <path>` | Writes the markdown report to that path, in addition to the terminal |
78
78
 
79
+ The report stops before 65,536 characters, the size of a GitHub comment, and
80
+ says so in its last line. The verdict opens the report and is never cut; the
81
+ terminal output keeps every detail.
82
+
79
83
  ### Exit codes
80
84
 
81
85
  | Code | Meaning |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucm-kit/cli",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
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,6 +29,6 @@
29
29
  "test": "node scripts/run-tests.cjs"
30
30
  },
31
31
  "dependencies": {
32
- "@ucm-kit/core": "0.1.33"
32
+ "@ucm-kit/core": "0.1.34"
33
33
  }
34
34
  }
package/src/check.mjs CHANGED
@@ -9,6 +9,9 @@ import { mkdirSync, writeFileSync } from "node:fs";
9
9
  import { dirname, resolve } from "node:path";
10
10
 
11
11
  import { controlerRepository, lireConfiguration } from "@ucm-kit/core/lecteurs";
12
+ import { NOM_CONFIGURATION } from "@ucm-kit/core/format";
13
+ import { contratsDuDossier } from "./contrats.mjs";
14
+ import { memeFichier } from "./tokens-css.mjs";
12
15
 
13
16
  /**
14
17
  * Lit les arguments de `ucm check`.
@@ -111,6 +114,19 @@ export function check(arguments_, {
111
114
  return 2;
112
115
  }
113
116
 
117
+ if (options.report) {
118
+ const cible = resolve(racine, options.report);
119
+ const entrees = [
120
+ resolve(racine, NOM_CONFIGURATION),
121
+ resolve(racine, configuration.tokens),
122
+ ...contratsDuDossier(resolve(racine, configuration.components)),
123
+ ];
124
+ if (cible.toLowerCase().endsWith('.contract.json') || entrees.some((entree) => memeFichier(cible, entree))) {
125
+ alerter('--report désigne une entrée du contrôle. Choisissez un fichier Markdown séparé.');
126
+ return 2;
127
+ }
128
+ }
129
+
114
130
  let perimetre = {};
115
131
  if (options.base) {
116
132
  const releve = releveDuDiff(racine, options.base, configuration.tokens, executerGit);
package/src/ucm.mjs CHANGED
@@ -78,8 +78,23 @@ const AIDE = `ucm — la ligne de commande UCM
78
78
  Codes de sortie : 0 tout est passé, 1 des contrôles ont échoué, 2 l'invocation
79
79
  ou la configuration est fautive.`;
80
80
 
81
- /** Le corps de la commande, séparé du processus pour être testable. */
82
- export function executer(arguments_, {
81
+ /** Rapporte aussi les pannes synchrones et les rejets des commandes asynchrones. */
82
+ export function executer(arguments_, options = {}) {
83
+ const signaler = (erreur) => {
84
+ const alerter = options.alerter ?? console.error;
85
+ alerter(`La commande ucm ${arguments_[0]} n'a pas pu aboutir : ${erreur?.message ?? erreur}\n`
86
+ + "Un développeur doit corriger l'erreur signalée, puis relancer la commande.");
87
+ return 2;
88
+ };
89
+ try {
90
+ const resultat = executerCommande(arguments_, options);
91
+ return resultat instanceof Promise ? resultat.catch(signaler) : resultat;
92
+ } catch (erreur) {
93
+ return signaler(erreur);
94
+ }
95
+ }
96
+
97
+ function executerCommande(arguments_, {
83
98
  racine = process.cwd(),
84
99
  env = process.env,
85
100
  ecrire = console.log,
@@ -126,8 +141,7 @@ export function executer(arguments_, {
126
141
  echecsDeTests: tests.valeur,
127
142
  ecrire,
128
143
  ...sorties,
129
- }))
130
- .catch((erreur) => {
144
+ }), (erreur) => {
131
145
  const alerter = sorties.alerter ?? console.error;
132
146
  alerter(
133
147
  `L'adaptateur ${NOM_ADAPTATEUR_TYPESCRIPT} est installé mais n'a pas pu être chargé : `