@adobe/spectrum-tokens 12.24.1 → 12.26.0

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/json/variables.json +6 -2
  3. package/index.js +52 -0
  4. package/moon.yml +3 -2
  5. package/package.json +7 -6
  6. package/schemas/token-types/alias.json +1 -0
  7. package/schemas/token-types/color-set.json +7 -2
  8. package/schemas/token-types/color.json +1 -0
  9. package/schemas/token-types/dimension.json +1 -0
  10. package/schemas/token-types/font-family.json +1 -0
  11. package/schemas/token-types/font-size.json +1 -0
  12. package/schemas/token-types/font-style.json +1 -0
  13. package/schemas/token-types/font-weight.json +1 -0
  14. package/schemas/token-types/multiplier.json +1 -0
  15. package/schemas/token-types/opacity.json +1 -0
  16. package/schemas/token-types/scale-set.json +7 -2
  17. package/schemas/token-types/system-set.json +1 -0
  18. package/schemas/token-types/text-transform.json +1 -0
  19. package/schemas/token-types/token.json +6 -1
  20. package/src/color-aliases.json +136 -68
  21. package/src/color-component.json +2 -1
  22. package/src/color-palette.json +619 -213
  23. package/src/icons.json +109 -55
  24. package/src/layout-component.json +897 -448
  25. package/src/layout.json +277 -139
  26. package/src/semantic-color-palette.json +28 -14
  27. package/src/typography.json +40 -20
  28. package/tasks/addIds.js +2 -1
  29. package/tasks/addPrivate.js +22 -0
  30. package/tasks/diff.js +2 -2
  31. package/test/checkComponentProps.js +25 -0
  32. package/test/checkId.test.js +24 -38
  33. package/test/checkManifest.test.js +1 -1
  34. package/test/checkPrivate.js +22 -0
  35. package/test/checkUniqueTokenNames.js +32 -0
  36. package/test/componentSchemaValidator.test.js +1 -1
  37. package/test/deprecateExpress.test.js +1 -1
  38. package/test/drover.test.js +1 -1
  39. package/test/schemaValidator.test.js +74 -0
  40. package/test/schemaValidators/alias.test.js +1 -1
  41. package/test/tokenSchemaValidator.test.js +1 -1
@@ -14,7 +14,8 @@
14
14
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
15
15
  "uuid": "f9fc7606-b699-46e7-b139-aeefc287923c"
16
16
  }
17
- }
17
+ },
18
+ "uuid": "0dd9c008-b20f-4a51-be59-67d9530877ff"
18
19
  },
19
20
  "accent-color-200": {
20
21
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -31,7 +32,8 @@
31
32
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
32
33
  "uuid": "78e50d0b-78a0-46c4-8262-417143f00902"
33
34
  }
34
- }
35
+ },
36
+ "uuid": "d4850a3d-cce3-4cd5-ba44-27281cad5934"
35
37
  },
36
38
  "accent-color-300": {
37
39
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -48,7 +50,8 @@
48
50
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
49
51
  "uuid": "d014e1e8-a5f8-4169-8c43-d69afd07847a"
50
52
  }
51
- }
53
+ },
54
+ "uuid": "89c05b32-63f5-46ed-abe1-a36247bd9797"
52
55
  },
53
56
  "accent-color-400": {
54
57
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -65,7 +68,8 @@
65
68
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
66
69
  "uuid": "1b70bc67-7877-4f92-8ce4-1abd2665fab1"
67
70
  }
68
- }
71
+ },
72
+ "uuid": "794b3679-1bcf-4c64-a55b-99be3f7676e5"
69
73
  },
70
74
  "accent-color-500": {
71
75
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -82,7 +86,8 @@
82
86
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
83
87
  "uuid": "06246e8e-44da-49a3-8d65-7f3ce1ec8128"
84
88
  }
85
- }
89
+ },
90
+ "uuid": "6eee723c-d9dd-4b14-ab44-75779c44f59e"
86
91
  },
87
92
  "accent-color-600": {
88
93
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -99,7 +104,8 @@
99
104
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
100
105
  "uuid": "eaee7f34-1725-411e-9a23-2331167e08f5"
101
106
  }
102
- }
107
+ },
108
+ "uuid": "11e391f6-66f0-4ed0-b70a-3f3d3a0e2f90"
103
109
  },
104
110
  "accent-color-700": {
105
111
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -116,7 +122,8 @@
116
122
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
117
123
  "uuid": "5c7ac5cc-4fe4-4392-a5c3-4274cd15a48e"
118
124
  }
119
- }
125
+ },
126
+ "uuid": "fc2868a8-1b1b-4da7-a51f-7faa6e7f7d4d"
120
127
  },
121
128
  "accent-color-800": {
122
129
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -133,7 +140,8 @@
133
140
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
134
141
  "uuid": "3cf62c35-1e2e-4400-886f-473de9e8a958"
135
142
  }
136
- }
143
+ },
144
+ "uuid": "85bd13e9-ff5a-419d-bc33-97fd44cf1789"
137
145
  },
138
146
  "accent-color-900": {
139
147
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -150,7 +158,8 @@
150
158
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
151
159
  "uuid": "42d37753-8b78-4328-a895-7b74d9a7aa86"
152
160
  }
153
- }
161
+ },
162
+ "uuid": "23cb9c14-f3cf-430b-9d0c-4749160542d8"
154
163
  },
155
164
  "accent-color-1000": {
156
165
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -167,7 +176,8 @@
167
176
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
168
177
  "uuid": "b848c6ce-f921-4303-b298-20e359a1aa2e"
169
178
  }
170
- }
179
+ },
180
+ "uuid": "203cf947-661e-4e96-8d13-5f0d3e9237bf"
171
181
  },
172
182
  "accent-color-1100": {
173
183
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -184,7 +194,8 @@
184
194
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
185
195
  "uuid": "46991cf0-e4e5-4c32-a140-4589e2456523"
186
196
  }
187
- }
197
+ },
198
+ "uuid": "80493b68-bdd4-4478-8ec1-2049922382be"
188
199
  },
189
200
  "accent-color-1200": {
190
201
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -201,7 +212,8 @@
201
212
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
202
213
  "uuid": "7de1e3f0-a5b3-4a09-955b-242ff78dbaa9"
203
214
  }
204
- }
215
+ },
216
+ "uuid": "eeed3404-3bde-4bb6-975f-556ec92297bd"
205
217
  },
206
218
  "accent-color-1300": {
207
219
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -218,7 +230,8 @@
218
230
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
219
231
  "uuid": "a598813b-347f-4528-aa35-94b6642985db"
220
232
  }
221
- }
233
+ },
234
+ "uuid": "0083814f-7761-4a52-97e3-ca154d7b8603"
222
235
  },
223
236
  "accent-color-1400": {
224
237
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/system-set.json",
@@ -235,7 +248,8 @@
235
248
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
236
249
  "uuid": "12c250df-6088-4c20-8b04-59814d53ed7a"
237
250
  }
238
- }
251
+ },
252
+ "uuid": "1124ea0a-6ba1-4b7e-852e-db760d182a97"
239
253
  },
240
254
  "informative-color-100": {
241
255
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/alias.json",
@@ -72,7 +72,8 @@
72
72
  "value": "13px",
73
73
  "uuid": "b7561ce1-e12e-4aed-9766-181f7eca309e"
74
74
  }
75
- }
75
+ },
76
+ "uuid": "daa864c1-e91e-4357-bcfc-02f3a5037f9c"
76
77
  },
77
78
  "font-size-75": {
78
79
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -87,7 +88,8 @@
87
88
  "value": "15px",
88
89
  "uuid": "07e1c2a8-3925-4d71-8fae-3486483ff44c"
89
90
  }
90
- }
91
+ },
92
+ "uuid": "5cf4dd2a-2a85-4eb6-b163-fa6737e4f838"
91
93
  },
92
94
  "font-size-100": {
93
95
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -102,7 +104,8 @@
102
104
  "value": "17px",
103
105
  "uuid": "2f9ee3cf-ccb1-4f0b-aed6-96e472fb7411"
104
106
  }
105
- }
107
+ },
108
+ "uuid": "86103cc9-4510-45af-8139-a81ea3b69da7"
106
109
  },
107
110
  "font-size-200": {
108
111
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -117,7 +120,8 @@
117
120
  "value": "19px",
118
121
  "uuid": "7e51ff4e-2749-49d1-b9ed-75de92a73991"
119
122
  }
120
- }
123
+ },
124
+ "uuid": "0cfbf6f7-7e79-44bb-af03-6355f412f590"
121
125
  },
122
126
  "font-size-300": {
123
127
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -132,7 +136,8 @@
132
136
  "value": "22px",
133
137
  "uuid": "9b9a7175-dcca-43aa-98ce-f1c3e4eefda7"
134
138
  }
135
- }
139
+ },
140
+ "uuid": "cd34b2cb-e7fa-41dd-bd1e-cb1e8113554a"
136
141
  },
137
142
  "font-size-400": {
138
143
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -147,7 +152,8 @@
147
152
  "value": "24px",
148
153
  "uuid": "d5ed0e8d-01ac-495f-bd15-fecc30af17c4"
149
154
  }
150
- }
155
+ },
156
+ "uuid": "c5ae539c-9b16-489a-a39b-c9cee1a1701b"
151
157
  },
152
158
  "font-size-500": {
153
159
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -162,7 +168,8 @@
162
168
  "value": "27px",
163
169
  "uuid": "a69a5079-1b5b-4ccf-946f-8b6e3fae4d7e"
164
170
  }
165
- }
171
+ },
172
+ "uuid": "ff5914d7-5d19-4b21-b633-c742d95942db"
166
173
  },
167
174
  "font-size-600": {
168
175
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -177,7 +184,8 @@
177
184
  "value": "31px",
178
185
  "uuid": "ac892307-2559-48f5-9e2c-98dabbb0abc2"
179
186
  }
180
- }
187
+ },
188
+ "uuid": "ed0c86e1-f062-405e-a1c4-ce74f62c0ea7"
181
189
  },
182
190
  "font-size-700": {
183
191
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -192,7 +200,8 @@
192
200
  "value": "34px",
193
201
  "uuid": "6bd6456c-b73b-4926-8e67-7b942e32bbc2"
194
202
  }
195
- }
203
+ },
204
+ "uuid": "b2b59d6e-50f8-4e72-a5c5-993a87971e3d"
196
205
  },
197
206
  "font-size-800": {
198
207
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -207,7 +216,8 @@
207
216
  "value": "39px",
208
217
  "uuid": "bdfae93d-ae49-456b-af54-8620ea976ca8"
209
218
  }
210
- }
219
+ },
220
+ "uuid": "3b3711a6-44fd-44b5-b273-e2c775a15986"
211
221
  },
212
222
  "font-size-900": {
213
223
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -222,7 +232,8 @@
222
232
  "value": "44px",
223
233
  "uuid": "5296e771-6d04-4e9a-b1fe-ab22d4dfd92b"
224
234
  }
225
- }
235
+ },
236
+ "uuid": "b164fd8e-2d83-45fc-b636-dba832faad37"
226
237
  },
227
238
  "font-size-1000": {
228
239
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -237,7 +248,8 @@
237
248
  "value": "49px",
238
249
  "uuid": "8b158ab0-7e82-4dab-a4d9-84cf7a71fa0a"
239
250
  }
240
- }
251
+ },
252
+ "uuid": "db55c6a2-c72d-4e63-838c-5f30d467bb66"
241
253
  },
242
254
  "font-size-1100": {
243
255
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -252,7 +264,8 @@
252
264
  "value": "55px",
253
265
  "uuid": "5eb96c78-c8f6-4e31-9bc8-fa62794ac4db"
254
266
  }
255
- }
267
+ },
268
+ "uuid": "56149ad7-84a7-4067-bad8-c5b143dd0561"
256
269
  },
257
270
  "font-size-1200": {
258
271
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -267,7 +280,8 @@
267
280
  "value": "62px",
268
281
  "uuid": "0ab38fb2-0de9-4be0-8967-8241379706be"
269
282
  }
270
- }
283
+ },
284
+ "uuid": "164b0eae-cd17-4e2c-8f30-436c0df7d4c9"
271
285
  },
272
286
  "font-size-1300": {
273
287
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
@@ -282,7 +296,8 @@
282
296
  "value": "70px",
283
297
  "uuid": "bd880141-81f6-47fe-a421-01124fe66b67"
284
298
  }
285
- }
299
+ },
300
+ "uuid": "db26e411-a118-4bef-a413-eeb383e85f37"
286
301
  },
287
302
  "line-height-100": {
288
303
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/multiplier.json",
@@ -379,7 +394,8 @@
379
394
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
380
395
  "uuid": "e5bfbd82-a8e6-43dc-b2b6-dc1e171f48aa"
381
396
  }
382
- }
397
+ },
398
+ "uuid": "2094ec97-c8de-46d7-93a4-1f49988bfbf2"
383
399
  },
384
400
  "heading-sans-serif-font-style": {
385
401
  "component": "heading",
@@ -403,7 +419,8 @@
403
419
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
404
420
  "uuid": "36bea3bb-06b8-4c66-87ad-ffc86be18243"
405
421
  }
406
- }
422
+ },
423
+ "uuid": "2e852baa-60a2-4e7e-9e30-99c14d7e4fef"
407
424
  },
408
425
  "heading-serif-font-style": {
409
426
  "component": "heading",
@@ -427,7 +444,8 @@
427
444
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
428
445
  "uuid": "21643fcd-b1da-4057-8fb5-e75167c0d89f"
429
446
  }
430
- }
447
+ },
448
+ "uuid": "203b2652-aa62-47f7-b4b5-52e22532de80"
431
449
  },
432
450
  "heading-cjk-font-style": {
433
451
  "component": "heading",
@@ -631,7 +649,8 @@
631
649
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
632
650
  "uuid": "723c8306-12fb-4cb5-9fd2-3ad40d57bb25"
633
651
  }
634
- }
652
+ },
653
+ "uuid": "445edecf-360c-4c42-aaf2-3b7380678365"
635
654
  },
636
655
  "heading-sans-serif-emphasized-font-style": {
637
656
  "component": "heading",
@@ -655,7 +674,8 @@
655
674
  "deprecated_comment": "Express will merge with Spectrum with the release of Spectrum 2.",
656
675
  "uuid": "e9b3a7b0-ae46-48be-a143-f26463860d3f"
657
676
  }
658
- }
677
+ },
678
+ "uuid": "aa539366-543c-4cf5-b326-8c6e8a09f846"
659
679
  },
660
680
  "heading-serif-emphasized-font-style": {
661
681
  "component": "heading",
package/tasks/addIds.js CHANGED
@@ -19,6 +19,7 @@ console.log(files);
19
19
 
20
20
  const VALUE = "value";
21
21
  const UUID = "uuid";
22
+ const SETS = "sets";
22
23
  const uuids = [];
23
24
 
24
25
  // dumb function to check if something is an object
@@ -46,7 +47,7 @@ function findUUIDs(json) {
46
47
  // check for and add uuids
47
48
  function addUUIDs(json) {
48
49
  // if it is in want of uuid, give it one
49
- if (json[VALUE] && !json[UUID]) {
50
+ if (!json[UUID] && (json[VALUE] || json[SETS])) {
50
51
  while (!json[UUID] || uuids.includes(json[UUID])) {
51
52
  json[UUID] = crypto.randomUUID(); // https://stackoverflow.com/questions/105034/how-do-i-create-a-guid-uuid#2117523
52
53
  }
@@ -0,0 +1,22 @@
1
+ /*
2
+ Copyright 2024 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+ import { getFileTokens, writeJson, __dirname } from "../index.js";
13
+ import { resolve } from "path";
14
+
15
+ const tokenData = await getFileTokens("color-palette.json");
16
+ const result = {};
17
+
18
+ for (const [key, value] of Object.entries(tokenData)) {
19
+ result[key] = { ...value, ...{ private: true } };
20
+ }
21
+
22
+ writeJson(`${resolve(__dirname, "./src")}/color-palette.json`, result);
package/tasks/diff.js CHANGED
@@ -16,7 +16,7 @@ import { fileURLToPath } from "url";
16
16
  import { detailedDiff, diff } from "deep-object-diff";
17
17
  import { exec } from "node:child_process";
18
18
  import { promisify } from "util";
19
- import tar from "tar";
19
+ import { x } from "tar";
20
20
  import tmp from "tmp-promise";
21
21
 
22
22
  const execP = promisify(exec);
@@ -65,7 +65,7 @@ async function getOldTokens() {
65
65
  const { stdout, stderr } = await execP(
66
66
  `npm pack @adobe/spectrum-tokens@${tag} --pack-destination ${tmpDir.path}`,
67
67
  );
68
- await tar.x({
68
+ await x({
69
69
  cwd: tmpDir.path,
70
70
  file: join(tmpDir.path, stdout.trim()),
71
71
  });
@@ -0,0 +1,25 @@
1
+ /*
2
+ Copyright 2024 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+
13
+ import test from "ava";
14
+ import { getFileTokens } from "../index.js";
15
+
16
+ test("ensure all component tokens are have component data", async (t) => {
17
+ const tokenData = {
18
+ ...(await getFileTokens("color-component.json")),
19
+ ...(await getFileTokens("layout-component.json")),
20
+ };
21
+ const result = Object.keys(tokenData).filter(
22
+ (tokenName) => !Object.hasOwn(tokenData[tokenName], "component"),
23
+ );
24
+ t.deepEqual(result, []);
25
+ });
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2023 Adobe. All rights reserved.
2
+ Copyright 2024 Adobe. All rights reserved.
3
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License. You may obtain a copy
5
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -20,45 +20,31 @@ const files = await Promise.all(
20
20
  ),
21
21
  );
22
22
 
23
- const uuids = [];
24
- const missingUUIDs = [];
25
- const VALUE = "value";
26
- const UUID = "uuid";
27
-
28
- function isObject(a) {
29
- return (
30
- !!a &&
31
- a.constructor &&
32
- (a.constructor === Object || a.constructor.name === "Object")
33
- );
34
- }
35
-
36
- // check for and add uuids
37
- function checkUUID(json, name) {
38
- // if it is in want of uuid, give it one
39
- if (json[VALUE] && !json[UUID]) {
40
- if (!json[UUID] || uuids.includes(json[UUID])) {
41
- if (name) {
42
- missingUUIDs.push(name);
43
- } else {
44
- missingUUIDs.push(json[VALUE]);
23
+ const findDuplicateUUIDs = (json) => {
24
+ const uuids = [];
25
+ const duplicateUUIDs = [];
26
+ const gather = (json, name) => {
27
+ if (json.uuid) {
28
+ if (uuids.includes(json.uuid)) {
29
+ duplicateUUIDs.push({ uuid: json.uuid, name });
45
30
  }
31
+ uuids.push(json.uuid);
46
32
  }
47
-
48
- uuids.push(json[UUID]);
49
- }
50
-
51
- // handle the json's children
52
- Object.keys(json).forEach((key) => {
53
- if (isObject(json[key])) {
54
- checkUUID(json[key], key);
55
- }
56
- });
57
- }
58
-
59
- test("check for uuids", async (t) => {
33
+ Object.keys(json).forEach((key) => {
34
+ if (typeof json[key] === "object") {
35
+ gather(json[key], key);
36
+ }
37
+ });
38
+ };
39
+ gather(json);
40
+ return duplicateUUIDs;
41
+ };
42
+
43
+ test("ensure uuids are unique", async (t) => {
44
+ let allTokens = {};
60
45
  for (const file of files) {
61
- checkUUID(file);
46
+ allTokens = { ...allTokens, ...file };
62
47
  }
63
- t.deepEqual(missingUUIDs, []);
48
+ const duplicateUUIDs = findDuplicateUUIDs(allTokens);
49
+ t.deepEqual(duplicateUUIDs, [], "duplicate uuids found");
64
50
  });
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2023 Adobe. All rights reserved.
2
+ Copyright 2024 Adobe. All rights reserved.
3
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License. You may obtain a copy
5
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1,22 @@
1
+ /*
2
+ Copyright 2024 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+
13
+ import test from "ava";
14
+ import { getFileTokens } from "../index.js";
15
+
16
+ test("ensure all color-palette.json tokens are private", async (t) => {
17
+ const tokenData = await getFileTokens("color-palette.json");
18
+ const result = Object.keys(tokenData).filter(
19
+ (tokenName) => !Object.hasOwn(tokenData[tokenName], "private"),
20
+ );
21
+ t.deepEqual(result, []);
22
+ });
@@ -0,0 +1,32 @@
1
+ /*
2
+ Copyright 2024 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+
13
+ import test from "ava";
14
+ import { readFile } from "fs/promises";
15
+ import { tokenFileNames } from "../index.js";
16
+ import findDuplicatedPropertyKeys from "find-duplicated-property-keys";
17
+
18
+ test("check for duplicate token names across all token files", async (t) => {
19
+ const result = await Promise.all(
20
+ tokenFileNames.map(async (tokenFileName) => {
21
+ const tokenDataString = await readFile(tokenFileName, "utf8");
22
+ return tokenDataString.substring(
23
+ tokenDataString.indexOf("{") + 1,
24
+ tokenDataString.lastIndexOf("}"),
25
+ );
26
+ }),
27
+ ).then((tokenDataArray) => {
28
+ return findDuplicatedPropertyKeys(`{${tokenDataArray.join(",")}}`);
29
+ });
30
+ // t.pass();
31
+ t.deepEqual(result, []);
32
+ });
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2023 Adobe. All rights reserved.
2
+ Copyright 2024 Adobe. All rights reserved.
3
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License. You may obtain a copy
5
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2023 Adobe. All rights reserved.
2
+ Copyright 2024 Adobe. All rights reserved.
3
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License. You may obtain a copy
5
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2023 Adobe. All rights reserved.
2
+ Copyright 2024 Adobe. All rights reserved.
3
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License. You may obtain a copy
5
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1,74 @@
1
+ /*
2
+ Copyright 2024 Adobe. All rights reserved.
3
+ This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License. You may obtain a copy
5
+ of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software distributed under
8
+ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ OF ANY KIND, either express or implied. See the License for the specific language
10
+ governing permissions and limitations under the License.
11
+ */
12
+
13
+ import test from "ava";
14
+ import Ajv from "ajv/dist/2020.js";
15
+ import addFormats from "ajv-formats";
16
+ import { glob } from "glob";
17
+ import { readFile } from "fs/promises";
18
+
19
+ const readJSON = async (filePath) =>
20
+ JSON.parse(await readFile(filePath, "utf8"));
21
+ const componentSchema = await readJSON("schemas/component.json");
22
+
23
+ const fileNames = await glob("schemas/components/*.json");
24
+ const files = await Promise.all(
25
+ fileNames.map(async (fileName) => {
26
+ return { fileName, json: await readJSON(fileName) };
27
+ }),
28
+ );
29
+
30
+ const ajv = new Ajv();
31
+ addFormats(ajv);
32
+ ajv.addMetaSchema(componentSchema);
33
+ const schemaFiles = await glob("schemas/types/*.json");
34
+ for (const schemaFile of schemaFiles) {
35
+ const schema = await readJSON(schemaFile);
36
+ ajv.addSchema(schema);
37
+ }
38
+
39
+ for (const keyword of Object.keys(componentSchema.properties)) {
40
+ ajv.addKeyword({ keyword, metaSchema: componentSchema.properties[keyword] });
41
+ }
42
+
43
+ test("component schema should be valid", async (t) => {
44
+ const valid = ajv.validateSchema(componentSchema);
45
+ t.true(valid);
46
+ });
47
+
48
+ test("Every component schema should validate against the definition", (t) => {
49
+ let valid = true;
50
+ for (const file of files) {
51
+ if (!ajv.validateSchema(file.json)) {
52
+ valid = false;
53
+ console.log(`${file.fileName} failed validation`);
54
+ console.log(ajv.errors);
55
+ }
56
+ }
57
+ t.true(valid);
58
+ });
59
+
60
+ test("component examples should validate against the definition", (t) => {
61
+ let valid = true;
62
+ for (const file of files) {
63
+ const validate = ajv.compile(file.json);
64
+ if (!Object.hasOwn(file.json, "examples")) file.json.examples = [];
65
+ for (const example of file.json.examples) {
66
+ if (!validate(example)) {
67
+ valid = false;
68
+ console.log(`${file.fileName} failed validation`);
69
+ console.log(validate.errors);
70
+ }
71
+ }
72
+ }
73
+ t.true(valid);
74
+ });
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2023 Adobe. All rights reserved.
2
+ Copyright 2024 Adobe. All rights reserved.
3
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License. You may obtain a copy
5
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2023 Adobe. All rights reserved.
2
+ Copyright 2024 Adobe. All rights reserved.
3
3
  This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License. You may obtain a copy
5
5
  of the License at http://www.apache.org/licenses/LICENSE-2.0