@ucm-kit/cli 0.1.70 → 0.1.75
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/check.mjs +14 -6
- package/src/tokens-css.mjs +20 -2
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.75 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.70 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.75 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.75 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.75 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.75",
|
|
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.11.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"yaml": "^2.9.1"
|
package/src/check.mjs
CHANGED
|
@@ -72,18 +72,26 @@ export function releveDuDiff(racine, base, sourceTokens, executer = execFileSync
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
// `git diff --quiet` sort en 1 quand il y a une différence
|
|
76
|
-
//
|
|
75
|
+
// `git diff --quiet` sort en 1 quand il y a une différence, et en 0 quand
|
|
76
|
+
// rien n'a bougé. Tout autre statut (128 pour un sha inconnu, par exemple)
|
|
77
|
+
// et un échec de lancement sans statut ne disent rien des tokens : c'est un
|
|
78
|
+
// relevé raté, pas une différence.
|
|
77
79
|
//
|
|
78
80
|
// La question reste posée à git, et non déduite de la liste ci-dessus : lui
|
|
79
81
|
// seul normalise le `./` d'un chemin de configuration, la casse selon
|
|
80
82
|
// `core.ignorecase` et le dossier passé en pathspec.
|
|
81
|
-
let tokensModifies =
|
|
83
|
+
let tokensModifies = false;
|
|
82
84
|
try {
|
|
83
85
|
git(["diff", "--quiet", base, "HEAD", "--", sourceTokens]);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
} catch (erreur) {
|
|
87
|
+
if (erreur?.status === 1) {
|
|
88
|
+
tokensModifies = true;
|
|
89
|
+
} else {
|
|
90
|
+
return {
|
|
91
|
+
erreur: `Le relevé des tokens « ${sourceTokens} » depuis « ${base} » a échoué : ${erreur?.message ?? erreur}.\n`
|
|
92
|
+
+ "Sans ce relevé, le rapport ne peut pas dire si les tokens ont changé.",
|
|
93
|
+
};
|
|
94
|
+
}
|
|
87
95
|
}
|
|
88
96
|
|
|
89
97
|
return { cheminsModifies: cheminsModifies.replaceAll("\0", "\n"), tokensModifies };
|
package/src/tokens-css.mjs
CHANGED
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
lireConfiguration,
|
|
33
33
|
sansEchantillon,
|
|
34
34
|
} from "@ucm-kit/core/lecteurs";
|
|
35
|
+
import { FORMES_ANCIENNES_DES_COLLECTIONS } from "@ucm-kit/core/referentiel";
|
|
35
36
|
|
|
36
37
|
import { contratsDuDossier } from "./contrats.mjs";
|
|
37
38
|
|
|
@@ -100,20 +101,37 @@ function litteral(type, valeur, repliDeFamille) {
|
|
|
100
101
|
* un attribut quand leurs ensembles de modes sont égaux ; leurs défauts peuvent
|
|
101
102
|
* différer, et `notes` le dit. Une clé de `modes` qui ne nomme aucun axe, et
|
|
102
103
|
* deux ensembles de modes différents sous un même attribut, vont dans `erreurs`.
|
|
104
|
+
* Une clé qui reprend l'ancien nom d'une collection UCM (`color-brands`) est lue
|
|
105
|
+
* sous le nom courant (`brands`) quand le fichier de tokens porte l'axe courant
|
|
106
|
+
* et non l'ancien : `notes` demande de la renommer.
|
|
103
107
|
*/
|
|
104
108
|
export function attributsDesAxes(axes, modes = {}) {
|
|
105
109
|
const erreurs = [];
|
|
106
110
|
const notes = [];
|
|
111
|
+
const nomsDAxes = new Set(axes.map((axe) => axe.nom));
|
|
112
|
+
const effectifs = {};
|
|
107
113
|
for (const cle of Object.keys(modes)) {
|
|
108
|
-
if (
|
|
114
|
+
if (nomsDAxes.has(cle)) {
|
|
115
|
+
effectifs[cle] = modes[cle];
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const courante = possede(FORMES_ANCIENNES_DES_COLLECTIONS, cle) ? FORMES_ANCIENNES_DES_COLLECTIONS[cle] : undefined;
|
|
119
|
+
if (courante === undefined || !nomsDAxes.has(courante)) {
|
|
109
120
|
erreurs.push(`${NOM_CONFIGURATION}, modes.${cle} : aucun axe du fichier de tokens ne porte ce nom.`);
|
|
121
|
+
} else if (possede(modes, courante)) {
|
|
122
|
+
notes.push(`${NOM_CONFIGURATION}, modes.${cle} : ${NOM_CONFIGURATION} porte aussi modes.${courante}, qui l'emporte. `
|
|
123
|
+
+ `Supprimez modes.${cle}.`);
|
|
124
|
+
} else {
|
|
125
|
+
effectifs[courante] = modes[cle];
|
|
126
|
+
notes.push(`${NOM_CONFIGURATION}, modes.${cle} : l'axe s'appelle maintenant « ${courante} », et la clé est lue sous ce nom. `
|
|
127
|
+
+ `Renommez-la modes.${courante}.`);
|
|
110
128
|
}
|
|
111
129
|
}
|
|
112
130
|
|
|
113
131
|
const attributs = new Map();
|
|
114
132
|
const parAttribut = new Map();
|
|
115
133
|
for (const axe of axes) {
|
|
116
|
-
const attribut = possede(
|
|
134
|
+
const attribut = possede(effectifs, axe.nom) ? effectifs[axe.nom] : attributDeMode(axe.nom);
|
|
117
135
|
attributs.set(axe.nom, attribut);
|
|
118
136
|
parAttribut.set(attribut, [...(parAttribut.get(attribut) ?? []), axe]);
|
|
119
137
|
}
|