@ucm-kit/cli 0.1.7 → 0.1.10
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/LICENSE +21 -0
- package/README.md +146 -0
- package/package.json +4 -3
- package/src/check.mjs +5 -36
- package/src/icons.mjs +2 -16
- package/src/init.mjs +2 -2
- package/src/ucm.mjs +67 -77
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 speckaina
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# @ucm-kit/cli
|
|
2
|
+
|
|
3
|
+
Check UCM contracts in any repository, and report the result to the person who
|
|
4
|
+
exported them.
|
|
5
|
+
|
|
6
|
+
A **UCM contract** is a JSON file describing a UI component exactly as it exists
|
|
7
|
+
in Figma: its variants, its structure, its design tokens, its usage rules. It is
|
|
8
|
+
written by the [Unified Component Exporter](https://github.com/Vassili-g/UCM-Exporter)
|
|
9
|
+
Figma plugin and committed next to the component's code. This command reads
|
|
10
|
+
those files and says whether they still hold together.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npx --yes @ucm-kit/cli@0.1.10 init
|
|
14
|
+
npx --yes @ucm-kit/cli@0.1.10 check --report ci-report.md
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Pin an exact version, without `^`. A range would let npx pick a build nobody
|
|
18
|
+
tested, and the check would change its verdict without a single file moving.
|
|
19
|
+
|
|
20
|
+
## Your repository does not have to be a Node project
|
|
21
|
+
|
|
22
|
+
`ucm init` writes a workflow that requires no `package.json`. An iOS repository,
|
|
23
|
+
an Android one, or a plain folder of contracts can have its exports checked. The
|
|
24
|
+
only requirement is Node, and in CI `setup-node` provides it.
|
|
25
|
+
|
|
26
|
+
If a `package-lock.json` happens to exist, the workflow runs `npm ci` first, so
|
|
27
|
+
that any optional stack adapter the repository installed becomes visible to
|
|
28
|
+
`ucm check`.
|
|
29
|
+
|
|
30
|
+
## Commands
|
|
31
|
+
|
|
32
|
+
| Command | What it does |
|
|
33
|
+
|---|---|
|
|
34
|
+
| `ucm init` | Installs what the repository is missing, never overwriting a file that already exists |
|
|
35
|
+
| `ucm check` | Checks every contract and renders the report |
|
|
36
|
+
| `ucm icons` | Lists the icons the contracts ask this repository to draw |
|
|
37
|
+
| `ucm --help` | Prints the above |
|
|
38
|
+
|
|
39
|
+
`ucm check` takes two options:
|
|
40
|
+
|
|
41
|
+
| Option | Effect |
|
|
42
|
+
|---|---|
|
|
43
|
+
| `--base <sha>` | Limits informational notices to contracts changed since that commit |
|
|
44
|
+
| `--report <path>` | Writes the markdown report to that path, in addition to the terminal |
|
|
45
|
+
|
|
46
|
+
### Exit codes
|
|
47
|
+
|
|
48
|
+
| Code | Meaning |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `0` | The command did what it was asked |
|
|
51
|
+
| `1` | Checks failed |
|
|
52
|
+
| `2` | The invocation or the configuration is at fault |
|
|
53
|
+
|
|
54
|
+
`1` and `2` never overlap. A typo in a flag must not read like a broken export.
|
|
55
|
+
|
|
56
|
+
## What `ucm init` writes
|
|
57
|
+
|
|
58
|
+
Five files, and it explains each one as it writes it. An existing file is kept
|
|
59
|
+
as it is, and the command tells you what it left alone.
|
|
60
|
+
|
|
61
|
+
| File | Why |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `ucm.config.json` | Where the contracts, the tokens and the implementations live |
|
|
64
|
+
| `.gitattributes` | Keeps contracts and tokens in LF, so a re-export from a Windows machine does not produce a whole-file diff |
|
|
65
|
+
| `.vscode/settings.json` | Binds `*.contract.json` to the JSON Schema of the installed package, so the editor validates as you read |
|
|
66
|
+
| `.gitignore` | Keeps `ci-report.md` out of the repository; it is regenerated on every run and describes only that run |
|
|
67
|
+
| `.github/workflows/ucm.yml` | Runs the check on every pull request and posts the report as a comment |
|
|
68
|
+
|
|
69
|
+
The workflow is yours once written. It will never be overwritten.
|
|
70
|
+
|
|
71
|
+
### `ucm.config.json`
|
|
72
|
+
|
|
73
|
+
Three paths, and nothing else. The file is optional: a repository with a single
|
|
74
|
+
`components/` folder works without writing a line.
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"components": "components",
|
|
79
|
+
"tokens": "tokens.json",
|
|
80
|
+
"implementation": "{dir}/{id}.tsx"
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`implementation` is a pattern with two tokens, `{dir}` for the contract's folder
|
|
85
|
+
and `{id}` for its identifier. The default shown here is a default, not an
|
|
86
|
+
assumption: replace it with your own.
|
|
87
|
+
|
|
88
|
+
No version number goes in this file. Which contract versions can be read belongs
|
|
89
|
+
to the installed package, and repeating it here would create a second authority
|
|
90
|
+
that drifts on the first update.
|
|
91
|
+
|
|
92
|
+
## What the report says
|
|
93
|
+
|
|
94
|
+
The report is written for the **designer** who validates the export, not for the
|
|
95
|
+
developer who reads CI logs. Every reason a pull request is refused appears in
|
|
96
|
+
it.
|
|
97
|
+
|
|
98
|
+
Six checks run on each contract. Four of them block a merge, two only warn, and
|
|
99
|
+
the split follows one rule: **a check blocks only if re-exporting from Figma can
|
|
100
|
+
fix it.**
|
|
101
|
+
|
|
102
|
+
| Check | Verdict |
|
|
103
|
+
|---|---|
|
|
104
|
+
| The contract is readable and complete | Blocks |
|
|
105
|
+
| This repository can read that contract version | Blocks |
|
|
106
|
+
| Composition: every nested component has its own contract, the lists agree, no cycles | Blocks |
|
|
107
|
+
| Typography tokens have the expected type | Blocks |
|
|
108
|
+
| Every `{token.path}` cited exists in the token file | Warns |
|
|
109
|
+
| The code exposes the props the contract declares | Warns |
|
|
110
|
+
|
|
111
|
+
A gap with the code needs a developer, so it warns and lets the merge through. A
|
|
112
|
+
token removed from the design system does too: tokens are the source of truth,
|
|
113
|
+
and an older contract does not hold back their evolution.
|
|
114
|
+
|
|
115
|
+
A contract may land before the code that implements it. A missing implementation
|
|
116
|
+
is an allowed state, not an error.
|
|
117
|
+
|
|
118
|
+
**So is a repository with no contract at all.** Right after `ucm init` nothing
|
|
119
|
+
has been exported: there is no token file, and usually no contract folder. From
|
|
120
|
+
`0.1.9` on, `ucm check` returns 0 there and reports what to do next. The number
|
|
121
|
+
of contracts decides: with one or more, a missing token file blocks the merge
|
|
122
|
+
again, because those contracts cite tokens nobody can resolve.
|
|
123
|
+
|
|
124
|
+
The report also relays two things it does not measure itself: the warnings the
|
|
125
|
+
export wrote into the contract, and the verdict of the repository's own tests
|
|
126
|
+
when an orchestrator passes it in through `UCM_ECHECS_DE_TESTS`.
|
|
127
|
+
|
|
128
|
+
## Optional stack adapters
|
|
129
|
+
|
|
130
|
+
The six checks above read contracts and tokens only, so they work whatever the
|
|
131
|
+
repository is written in. Comparing a contract to real code needs to read that
|
|
132
|
+
code, which is a stack adapter's job.
|
|
133
|
+
|
|
134
|
+
`ucm check` discovers an adapter installed **by the repository**, resolving from
|
|
135
|
+
the checked root rather than from the npx cache. Install
|
|
136
|
+
[`@ucm-kit/adapter-typescript`](https://www.npmjs.com/package/@ucm-kit/adapter-typescript)
|
|
137
|
+
to add static prop and composition parity for TypeScript projects. Without an
|
|
138
|
+
adapter, the report says the implementation was not read, and never that it is
|
|
139
|
+
conformant.
|
|
140
|
+
|
|
141
|
+
## Status
|
|
142
|
+
|
|
143
|
+
**0.x, the public surface is not frozen.** Pin an exact version.
|
|
144
|
+
|
|
145
|
+
- [Repository and issues](https://github.com/Vassili-g/UCM-Exporter)
|
|
146
|
+
- [MIT licensed](https://github.com/Vassili-g/UCM-Exporter/blob/main/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ucm-kit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
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",
|
|
@@ -20,12 +20,13 @@
|
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
22
22
|
"src",
|
|
23
|
-
"README.md"
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
24
25
|
],
|
|
25
26
|
"scripts": {
|
|
26
27
|
"test": "node scripts/run-tests.cjs"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@ucm-kit/core": "0.1.
|
|
30
|
+
"@ucm-kit/core": "0.1.14"
|
|
30
31
|
}
|
|
31
32
|
}
|
package/src/check.mjs
CHANGED
|
@@ -1,39 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* imprime, écrit un fichier si on le lui demande et choisit un code de sortie.
|
|
7
|
-
* C'était l'arbitrage de T3.3 : en écrire une seconde version ici produirait
|
|
8
|
-
* deux rapports qui divergeraient en silence — la maladie exacte que T2.7, T6.0
|
|
9
|
-
* et T2.6 ont soignée trois fois ailleurs dans ce projet. Le CONTENU du rapport
|
|
10
|
-
* est du format, sa PUBLICATION est de l'outil, et cette ligne-là est la seule
|
|
11
|
-
* que ce fichier a le droit de franchir.
|
|
12
|
-
*
|
|
13
|
-
* ## Les trois codes de sortie
|
|
14
|
-
*
|
|
15
|
-
* `0` tout est passé · `1` des contrôles ont échoué · `2` l'invocation ou la
|
|
16
|
-
* configuration est fautive. Le 1 et le 2 ne se confondent jamais : un workflow
|
|
17
|
-
* qui les mélangerait ferait lire « votre export est en défaut » à quelqu'un
|
|
18
|
-
* dont le seul tort est une faute de frappe dans un drapeau.
|
|
19
|
-
*
|
|
20
|
-
* ## Pourquoi `--report` et pas une variable d'environnement
|
|
21
|
-
*
|
|
22
|
-
* Le rapport ne s'écrivait que si `CI` était présente. Écrire toujours
|
|
23
|
-
* laisserait un fichier non versionné dans la copie de travail après chaque
|
|
24
|
-
* exécution — le risque n'est pas de le commiter mais de faire croire à un
|
|
25
|
-
* rapport frais. Ne l'écrire que sous `CI` empêche un développeur de
|
|
26
|
-
* prévisualiser ce que le designer lira, ce qui est précisément ce qu'on veut
|
|
27
|
-
* faire quand on modifie ces messages. Un drapeau explicite règle les deux, et
|
|
28
|
-
* supprime une variable d'environnement magique.
|
|
29
|
-
*
|
|
30
|
-
* ## Pourquoi `--base <sha>` et pas un calcul de CI
|
|
31
|
-
*
|
|
32
|
-
* Le périmètre des états informatifs se limite aux contrats que la pull request
|
|
33
|
-
* modifie, sans quoi un export de tokens reparle indéfiniment d'un composant
|
|
34
|
-
* qu'il ne touche pas. Savoir QUEL sha est la base demande de connaître un
|
|
35
|
-
* système de CI (`pull_request.base.sha`, `fetch-depth: 0`) ; faire le diff, non.
|
|
36
|
-
* Le workflow trouve le sha, cette commande fait le diff.
|
|
2
|
+
* Publie le contrôle défini par `@ucm-kit/core/lecteurs` : cette commande ne
|
|
3
|
+
* redéfinit ni le contrôle ni le rapport. `--report` commande explicitement
|
|
4
|
+
* l'écriture ; `--base` reçoit de la CI le SHA qui borne la pull request.
|
|
5
|
+
* Codes : 0 succès, 1 contrôles rouges, 2 invocation ou configuration fautive.
|
|
37
6
|
*/
|
|
38
7
|
import { execFileSync } from "node:child_process";
|
|
39
8
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
@@ -136,7 +105,7 @@ export function check(arguments_, {
|
|
|
136
105
|
if (erreurConfiguration) {
|
|
137
106
|
// Pas de rapport écrit ici, et c'est délibéré : formuler un diagnostic de
|
|
138
107
|
// designer dans le CLI remettrait du vocabulaire de rapport dans l'outil,
|
|
139
|
-
// ce que
|
|
108
|
+
// ce que la scission en a sorti. Le filet du workflow publie déjà un
|
|
140
109
|
// message quand le rapport manque — c'est exactement le cas qu'il couvre.
|
|
141
110
|
alerter(erreurConfiguration);
|
|
142
111
|
return 2;
|
package/src/icons.mjs
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* Un contrat publie le `figmaName` d'une icône, et **rien d'autre** : ni kit, ni
|
|
5
|
-
* correspondance, ni taille de glyphe. Traduire ce nom vers un jeu d'icônes
|
|
6
|
-
* appartient au repo consommateur — c'est la décision de T3.1, qui a écarté un
|
|
7
|
-
* champ `icons` de la configuration pour cette raison.
|
|
8
|
-
*
|
|
9
|
-
* Mais une responsabilité qu'on confie sans la rendre visible est une
|
|
10
|
-
* responsabilité aveugle. Cette commande est la contrepartie de cette décision :
|
|
11
|
-
* elle dit au repo ce qu'il a à couvrir, sans rien décider pour lui.
|
|
12
|
-
*
|
|
13
|
-
* *Elle ne juge pas, et c'est délibéré.* Qu'un nom soit ou non résolu par le
|
|
14
|
-
* repo, cette commande l'ignore : elle n'a aucune idée de ce qu'est un jeu
|
|
15
|
-
* d'icônes ici. Elle liste. Un jour où un `icons` existera dans la
|
|
16
|
-
* configuration, elle pourra comparer — pas avant, sinon elle inventerait la
|
|
17
|
-
* règle qu'elle prétend vérifier.
|
|
2
|
+
* Liste les icônes réclamées par les contrats, sans choisir de bibliothèque ni
|
|
3
|
+
* juger leur couverture : cette correspondance appartient au consommateur.
|
|
18
4
|
*/
|
|
19
5
|
import { readFileSync } from "node:fs";
|
|
20
6
|
import { join, relative } from "node:path";
|
package/src/init.mjs
CHANGED
|
@@ -27,7 +27,7 @@ function versionDuPaquet() {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Le pin est
|
|
30
|
+
* Le pin est exact, sans `^` ni `~`.
|
|
31
31
|
*
|
|
32
32
|
* Une plage laisserait npm choisir une version que personne n'a essayée, et le
|
|
33
33
|
* jour où elle changerait de verdict, la CI d'un designer basculerait sans
|
|
@@ -114,7 +114,7 @@ function fichiers(version) {
|
|
|
114
114
|
* la règle vaut même quand la valeur vient de GitHub et pas d'un humain,
|
|
115
115
|
* puisque c'est l'habitude qui protège, pas le cas particulier.
|
|
116
116
|
*
|
|
117
|
-
* **Un filet, et un seul, parce que l'autre n'est pas portable
|
|
117
|
+
* **Un filet, et un seul, parce que l'autre n'est pas portable.** Le
|
|
118
118
|
* repository de démonstration en porte deux : « la construction a échoué » et
|
|
119
119
|
* « le rapport manque ». Le premier décrit SA chaîne de construction et n'a
|
|
120
120
|
* aucun sens ici — un repo Swift ne compile pas du TypeScript. Le second est
|
package/src/ucm.mjs
CHANGED
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Le code de sortie est la seule chose qu'un workflow lise sans ambiguïté : 0
|
|
12
|
-
* quand la commande a fait ce qu'on lui demandait, 1 quand des contrôles ont
|
|
13
|
-
* échoué, 2 quand l'invocation ou la configuration est fautive. Le 1 et le 2 ne
|
|
14
|
-
* se confondent jamais, sinon une faute de frappe dans un drapeau se lirait
|
|
15
|
-
* comme un export en défaut.
|
|
16
|
-
*/
|
|
17
|
-
import { realpathSync } from "node:fs";
|
|
18
|
-
import process from "node:process";
|
|
19
|
-
import { pathToFileURL } from "node:url";
|
|
20
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Aiguille la ligne de commande vers le kit et ses adaptateurs. Les commandes
|
|
4
|
+
* publient les décisions du noyau sans dupliquer son orchestration.
|
|
5
|
+
* Codes : 0 succès, 1 contrôles rouges, 2 invocation ou configuration fautive.
|
|
6
|
+
*/
|
|
7
|
+
import { realpathSync } from "node:fs";
|
|
8
|
+
import process from "node:process";
|
|
9
|
+
import { pathToFileURL } from "node:url";
|
|
10
|
+
|
|
21
11
|
import { lireConfiguration } from "@ucm-kit/core/lecteurs";
|
|
22
12
|
|
|
23
13
|
import { chargerAdaptateur, NOM_ADAPTATEUR_TYPESCRIPT } from "./adaptateur.mjs";
|
|
24
14
|
import { check } from "./check.mjs";
|
|
25
|
-
import { iconesDuRepository, rendreIcones } from "./icons.mjs";
|
|
15
|
+
import { iconesDuRepository, rendreIcones } from "./icons.mjs";
|
|
26
16
|
import { init, rendreInit } from "./init.mjs";
|
|
27
17
|
|
|
28
18
|
/** Le verdict de tests qu'un orchestrateur de stack peut transmettre au CLI. */
|
|
@@ -42,44 +32,44 @@ function echecsDeTestsDepuis(env) {
|
|
|
42
32
|
};
|
|
43
33
|
}
|
|
44
34
|
}
|
|
45
|
-
|
|
46
|
-
const AIDE = `ucm — la ligne de commande UCM
|
|
47
|
-
|
|
48
|
-
ucm init installe ce qui manque à ce repository, sans rien écraser
|
|
49
|
-
ucm check contrôle les contrats et rend le rapport du designer
|
|
50
|
-
ucm icons liste les icônes que les contrats réclament
|
|
51
|
-
ucm --help affiche cette aide
|
|
52
|
-
|
|
53
|
-
ucm check [--base <sha>] [--report <chemin>]
|
|
54
|
-
--base limite les états informatifs aux contrats modifiés depuis ce sha
|
|
55
|
-
--report écrit le rapport markdown à ce chemin, en plus du terminal
|
|
56
|
-
|
|
57
|
-
Codes de sortie : 0 tout est passé, 1 des contrôles ont échoué, 2 l'invocation
|
|
58
|
-
ou la configuration est fautive.`;
|
|
59
|
-
|
|
60
|
-
/** Le corps de la commande, séparé du processus pour être testable. */
|
|
35
|
+
|
|
36
|
+
const AIDE = `ucm — la ligne de commande UCM
|
|
37
|
+
|
|
38
|
+
ucm init installe ce qui manque à ce repository, sans rien écraser
|
|
39
|
+
ucm check contrôle les contrats et rend le rapport du designer
|
|
40
|
+
ucm icons liste les icônes que les contrats réclament
|
|
41
|
+
ucm --help affiche cette aide
|
|
42
|
+
|
|
43
|
+
ucm check [--base <sha>] [--report <chemin>]
|
|
44
|
+
--base limite les états informatifs aux contrats modifiés depuis ce sha
|
|
45
|
+
--report écrit le rapport markdown à ce chemin, en plus du terminal
|
|
46
|
+
|
|
47
|
+
Codes de sortie : 0 tout est passé, 1 des contrôles ont échoué, 2 l'invocation
|
|
48
|
+
ou la configuration est fautive.`;
|
|
49
|
+
|
|
50
|
+
/** Le corps de la commande, séparé du processus pour être testable. */
|
|
61
51
|
export function executer(arguments_, {
|
|
62
52
|
racine = process.cwd(),
|
|
63
53
|
env = process.env,
|
|
64
54
|
ecrire = console.log,
|
|
65
55
|
...sorties
|
|
66
56
|
} = {}) {
|
|
67
|
-
const [commande] = arguments_;
|
|
68
|
-
|
|
69
|
-
if (commande === undefined || commande === "--help" || commande === "-h") {
|
|
70
|
-
ecrire(AIDE);
|
|
71
|
-
return 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (commande === "init") {
|
|
75
|
-
ecrire(rendreInit(init(racine)));
|
|
76
|
-
return 0;
|
|
77
|
-
}
|
|
78
|
-
|
|
57
|
+
const [commande] = arguments_;
|
|
58
|
+
|
|
59
|
+
if (commande === undefined || commande === "--help" || commande === "-h") {
|
|
60
|
+
ecrire(AIDE);
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (commande === "init") {
|
|
65
|
+
ecrire(rendreInit(init(racine)));
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
79
69
|
if (commande === "check") {
|
|
80
|
-
// Le contrôle écrit sur trois canaux distincts, et le terminal en dépend :
|
|
81
|
-
// un écart de parité en ⚠ et un contrat cassé en ✗ ne doivent pas se lire
|
|
82
|
-
// sur le même flux. Le défaut de `check` les branche sur la console.
|
|
70
|
+
// Le contrôle écrit sur trois canaux distincts, et le terminal en dépend :
|
|
71
|
+
// un écart de parité en ⚠ et un contrat cassé en ✗ ne doivent pas se lire
|
|
72
|
+
// sur le même flux. Le défaut de `check` les branche sur la console.
|
|
83
73
|
const tests = echecsDeTestsDepuis(env);
|
|
84
74
|
if (tests.erreur) {
|
|
85
75
|
const alerter = sorties.alerter ?? console.error;
|
|
@@ -103,32 +93,32 @@ export function executer(arguments_, {
|
|
|
103
93
|
);
|
|
104
94
|
return 2;
|
|
105
95
|
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (commande === "icons") {
|
|
109
|
-
const { configuration, erreur } = lireConfiguration(racine);
|
|
110
|
-
if (erreur) {
|
|
111
|
-
// La configuration est refusée ici comme ailleurs : retomber sur les
|
|
112
|
-
// défauts ferait chercher les contrats dans un autre dossier et rendre
|
|
113
|
-
// une liste vide, qui se lit comme « aucune icône » alors qu'elle veut
|
|
114
|
-
// dire « je n'ai rien regardé ».
|
|
115
|
-
ecrire(erreur);
|
|
116
|
-
return 2;
|
|
117
|
-
}
|
|
118
|
-
ecrire(rendreIcones(iconesDuRepository(racine, configuration.components)));
|
|
119
|
-
return 0;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
ecrire(`Commande inconnue : ${commande}\n\n${AIDE}`);
|
|
123
|
-
return 2;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Le module s'exporte ET s'exécute : les tests appellent `executer`, le binaire
|
|
127
|
-
// passe par ici. Sans cette garde, importer le module lancerait la commande.
|
|
128
|
-
//
|
|
129
|
-
// La comparaison passe par `realpathSync` parce que npm installe le binaire
|
|
130
|
-
// comme un lien : sans résolution, le chemin lancé et celui du module diffèrent,
|
|
131
|
-
// et `ucm` se contenterait de ne rien faire — en sortant 0.
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (commande === "icons") {
|
|
99
|
+
const { configuration, erreur } = lireConfiguration(racine);
|
|
100
|
+
if (erreur) {
|
|
101
|
+
// La configuration est refusée ici comme ailleurs : retomber sur les
|
|
102
|
+
// défauts ferait chercher les contrats dans un autre dossier et rendre
|
|
103
|
+
// une liste vide, qui se lit comme « aucune icône » alors qu'elle veut
|
|
104
|
+
// dire « je n'ai rien regardé ».
|
|
105
|
+
ecrire(erreur);
|
|
106
|
+
return 2;
|
|
107
|
+
}
|
|
108
|
+
ecrire(rendreIcones(iconesDuRepository(racine, configuration.components)));
|
|
109
|
+
return 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
ecrire(`Commande inconnue : ${commande}\n\n${AIDE}`);
|
|
113
|
+
return 2;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Le module s'exporte ET s'exécute : les tests appellent `executer`, le binaire
|
|
117
|
+
// passe par ici. Sans cette garde, importer le module lancerait la commande.
|
|
118
|
+
//
|
|
119
|
+
// La comparaison passe par `realpathSync` parce que npm installe le binaire
|
|
120
|
+
// comme un lien : sans résolution, le chemin lancé et celui du module diffèrent,
|
|
121
|
+
// et `ucm` se contenterait de ne rien faire — en sortant 0.
|
|
132
122
|
if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href) {
|
|
133
123
|
process.exit(await executer(process.argv.slice(2)));
|
|
134
124
|
}
|