@ucm-kit/cli 0.1.150 → 0.1.152
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 +18 -6
- package/package.json +2 -2
- package/src/guide.mjs +27 -1
- package/src/ucm.mjs +91 -53
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.
|
|
19
|
+
npx --yes @ucm-kit/cli@0.1.152 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.150 init
|
|
|
27
27
|
To run the check locally:
|
|
28
28
|
|
|
29
29
|
```sh
|
|
30
|
-
npx --yes @ucm-kit/cli@0.1.
|
|
30
|
+
npx --yes @ucm-kit/cli@0.1.152 check --report ci-report.md
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
`--yes` skips the npx confirmation prompt. Pin an exact version, without `^`:
|
|
@@ -78,7 +78,7 @@ contract would resolve to the same file. A repository that does not write React
|
|
|
78
78
|
states its own extension:
|
|
79
79
|
|
|
80
80
|
```sh
|
|
81
|
-
npx --yes @ucm-kit/cli@0.1.
|
|
81
|
+
npx --yes @ucm-kit/cli@0.1.152 init --components Sources/DesignSystem --implementation '{dir}/{id}.swift'
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
The three path options act only on a first install. `ucm init` never overwrites
|
|
@@ -188,7 +188,7 @@ directory. It writes a minimal report when the check stopped before writing
|
|
|
188
188
|
one, then posts the report:
|
|
189
189
|
|
|
190
190
|
```sh
|
|
191
|
-
npx --yes @ucm-kit/cli@0.1.
|
|
191
|
+
npx --yes @ucm-kit/cli@0.1.152 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
192
|
```
|
|
193
193
|
|
|
194
194
|
| Option | Effect |
|
|
@@ -265,6 +265,17 @@ information that never blocks the merge. The contract does not say whether a
|
|
|
265
265
|
text is large, where the threshold drops to 3:1: a false signal stays
|
|
266
266
|
information. A colour outside sRGB, or translucent, is not measured.
|
|
267
267
|
|
|
268
|
+
The check also judges the architecture of `tokens.json`, with the two checks
|
|
269
|
+
UCM Architect runs on a Figma file: the theme's variables, the layers they
|
|
270
|
+
target, scopes, modes and the sizing scales. It applies without any option,
|
|
271
|
+
because every tool except the Exporter follows the UCM architecture. Its
|
|
272
|
+
findings are information and never block the merge, so a pull request that
|
|
273
|
+
carries only tokens stays green. The report groups them by kind, with the count
|
|
274
|
+
and three examples of each, in its last section, and only when the pull request
|
|
275
|
+
changes `tokens.json` (without `--base`, always). A file where no collection has
|
|
276
|
+
a UCM name gets one line saying the architecture is not judged. Composite tokens
|
|
277
|
+
(typography, shadow, curve) are not Figma variables and are not judged.
|
|
278
|
+
|
|
268
279
|
A gap with the code warns: a developer closes it, and the merge goes through. A
|
|
269
280
|
token removed from the design system warns too, so an older contract does not
|
|
270
281
|
hold back the tokens. A contract may land before the code that implements it.
|
|
@@ -393,8 +404,9 @@ overwritten.
|
|
|
393
404
|
writes to `<file>`:
|
|
394
405
|
|
|
395
406
|
1. what to read again first: conventions anomalies, copied sections whose
|
|
396
|
-
default writing changed,
|
|
397
|
-
relays, the workflow and `package.json
|
|
407
|
+
default writing changed, `@ucm-kit/cli` pins that differ between the two
|
|
408
|
+
relays, the workflow and `package.json`, and an `@ucm-kit/core` installed in
|
|
409
|
+
the repository at another version than the one this CLI runs with;
|
|
398
410
|
2. the procedure, `procedure.md`;
|
|
399
411
|
3. the text before the first section of the closest conventions file;
|
|
400
412
|
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.
|
|
3
|
+
"version": "0.1.152",
|
|
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.
|
|
32
|
+
"@ucm-kit/core": "0.17.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"yaml": "^2.9.1"
|
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/ucm.mjs
CHANGED
|
@@ -38,59 +38,97 @@ function echecsDeTestsDepuis(env) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
--
|
|
54
|
-
--
|
|
55
|
-
--
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
--
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Les commandes de `ucm`, dans l'ordre de l'aide : le nom que le développeur tape, son usage, son rôle en une phrase et ses options.
|
|
43
|
+
* `ucm --help` se construit depuis cette liste et d'elle seule : une commande ajoutée ici apparaît dans l'aide.
|
|
44
|
+
* Un retour à la ligne dans un `role` ou une `note` est celui de l'aide imprimée ; remplacé par une espace, le texte est la phrase.
|
|
45
|
+
*/
|
|
46
|
+
export const COMMANDES = [
|
|
47
|
+
{
|
|
48
|
+
nom: "init",
|
|
49
|
+
usage: "ucm init [--components <dossier>] [--tokens <dossier>] [--implementation <motif>] [--sans-agents] [--forge github|gitlab]",
|
|
50
|
+
role: "installe ce qui manque à ce repository, sans rien écraser",
|
|
51
|
+
options: [
|
|
52
|
+
{ nom: "--components", role: "dossier sous lequel les contrats sont rangés" },
|
|
53
|
+
{ nom: "--tokens", role: "dossier qui reçoit tokens.json" },
|
|
54
|
+
{ nom: "--implementation", role: "où vit l'implémentation d'un contrat, {dir} et {id}\npour son dossier et son identifiant" },
|
|
55
|
+
{ nom: "--sans-agents", role: "n'écrit ni les relais d'agent, ni .ucm/conventions.md,\nni les gabarits" },
|
|
56
|
+
{
|
|
57
|
+
nom: "--forge",
|
|
58
|
+
role: "la forge dont la CI est écrite ; sans elle, l'hôte du\nremote origin, puis la présence de .gitlab-ci.yml\ndécident, et GitHub sinon",
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
note: "Les trois n'agissent qu'à la première installation : ucm init n'écrase\njamais un ucm.config.json existant.",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
nom: "check",
|
|
65
|
+
usage: "ucm check [--base <sha>] [--report <chemin>]",
|
|
66
|
+
role: "contrôle les contrats et rend le rapport du designer",
|
|
67
|
+
options: [
|
|
68
|
+
{ nom: "--base", role: "limite les états informatifs aux contrats modifiés depuis ce sha" },
|
|
69
|
+
{ nom: "--report", role: "écrit le rapport markdown à ce chemin, en plus du terminal" },
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
{ nom: "icons", usage: "ucm icons", role: "liste les icônes que les contrats réclament", options: [] },
|
|
73
|
+
{
|
|
74
|
+
nom: "tokens css",
|
|
75
|
+
usage: "ucm tokens css --out <fichier> [--sans-modes]",
|
|
76
|
+
role: "écrit la feuille CSS des tokens et de leurs modes",
|
|
77
|
+
options: [
|
|
78
|
+
{ nom: "--out", role: "la feuille à écrire, remplacée seulement si le fichier de\ntokens donne une feuille" },
|
|
79
|
+
{ nom: "--sans-modes", role: "écrit la valeur par défaut de chaque token, pour un\nfichier exporté avant la déclaration des axes" },
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
nom: "aides",
|
|
84
|
+
usage: "ucm aides [<aide> [--personnaliser [<chemin>]]]",
|
|
85
|
+
role: "liste les aides à l'implémentation et leur origine",
|
|
86
|
+
options: [
|
|
87
|
+
{ nom: "<aide>", role: "imprime son sens, son écriture par défaut et sa preuve" },
|
|
88
|
+
{ nom: "--personnaliser", role: "ajoute la section de l'aide au .ucm/conventions.md le\nplus proche du chemin, à éditer, sans rien écraser" },
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
nom: "guide",
|
|
93
|
+
usage: "ucm guide <contrat> [--out <fichier>]",
|
|
94
|
+
role: "imprime ce qu'un agent lit avant d'implémenter un contrat",
|
|
95
|
+
options: [
|
|
96
|
+
{ nom: "<contrat>", role: "le fichier .contract.json à implémenter" },
|
|
97
|
+
{ nom: "--out", role: "écrit le guide dans ce fichier plutôt que dans le terminal" },
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
nom: "rapport-gitlab",
|
|
102
|
+
usage: "ucm rapport-gitlab --projet <id> --merge-request <iid> --fichier <chemin> [--api <url>]",
|
|
103
|
+
role: "publie le rapport en note d'une merge request GitLab",
|
|
104
|
+
options: [
|
|
105
|
+
{ nom: "--projet", role: "l'identifiant ou le chemin du projet GitLab" },
|
|
106
|
+
{ nom: "--merge-request", role: "le numéro de la merge request dans ce projet" },
|
|
107
|
+
{ nom: "--fichier", role: "le rapport écrit par ucm check --report" },
|
|
108
|
+
{ nom: "--api", role: "l'API GitLab, https://gitlab.com/api/v4 par défaut" },
|
|
109
|
+
],
|
|
110
|
+
note: "Le jeton se lit dans UCM_GITLAB_TOKEN. Sans lui, la commande le dit et\nsort en 0.",
|
|
111
|
+
},
|
|
112
|
+
{ nom: "--help", usage: "ucm --help", role: "affiche cette aide", options: [] },
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
/** Pose une marge devant chaque ligne d'un texte sauf la première, que sa tête précède déjà. */
|
|
116
|
+
const sousLaMarge = (texte, marge) => texte.split("\n").join(`\n${marge}`);
|
|
117
|
+
|
|
118
|
+
/** Le bloc d'une commande : son usage, ses options alignées sur la plus longue, puis sa note. */
|
|
119
|
+
function blocDeLAide({ usage, options, note }) {
|
|
120
|
+
const largeur = Math.max(...options.map(({ nom }) => nom.length));
|
|
121
|
+
const lignes = options.map(({ nom, role }) => ` ${nom.padEnd(largeur)} ${sousLaMarge(role, " ".repeat(8 + largeur))}`);
|
|
122
|
+
if (note) lignes.push(` ${sousLaMarge(note, " ")}`);
|
|
123
|
+
return [` ${usage}`, ...lignes].join("\n");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const AIDE = [
|
|
127
|
+
"ucm — la ligne de commande UCM",
|
|
128
|
+
COMMANDES.map(({ nom, role }) => ` ucm ${nom.padEnd(14)} ${role}`).join("\n"),
|
|
129
|
+
...COMMANDES.filter(({ options }) => options.length > 0).map(blocDeLAide),
|
|
130
|
+
"Codes de sortie : 0 tout est passé, 1 des contrôles ont échoué, 2 l'invocation\nou la configuration est fautive.",
|
|
131
|
+
].join("\n\n");
|
|
94
132
|
|
|
95
133
|
/** Rapporte aussi les pannes synchrones et les rejets des commandes asynchrones. */
|
|
96
134
|
export function executer(arguments_, options = {}) {
|