@ucm-kit/cli 0.1.149 → 0.1.151
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 +4 -4
- package/package.json +2 -2
- 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.151 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.149 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.151 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.151 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.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"
|
|
192
192
|
```
|
|
193
193
|
|
|
194
194
|
| Option | Effect |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ucm-kit/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.151",
|
|
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.16.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"yaml": "^2.9.1"
|
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 = {}) {
|