@adobe/spectrum-tokens 12.24.0 → 12.25.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 (35) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/json/drover.json +1 -0
  3. package/dist/json/variables.json +12 -0
  4. package/index.js +52 -0
  5. package/moon.yml +3 -2
  6. package/package.json +10 -6
  7. package/schemas/token-types/alias.json +1 -0
  8. package/schemas/token-types/color-set.json +1 -0
  9. package/schemas/token-types/color.json +1 -0
  10. package/schemas/token-types/dimension.json +1 -0
  11. package/schemas/token-types/font-family.json +1 -0
  12. package/schemas/token-types/font-size.json +1 -0
  13. package/schemas/token-types/font-style.json +1 -0
  14. package/schemas/token-types/font-weight.json +1 -0
  15. package/schemas/token-types/multiplier.json +1 -0
  16. package/schemas/token-types/opacity.json +1 -0
  17. package/schemas/token-types/scale-set.json +1 -0
  18. package/schemas/token-types/system-set.json +1 -0
  19. package/schemas/token-types/text-transform.json +1 -0
  20. package/schemas/token-types/token.json +6 -1
  21. package/src/color-palette.json +426 -213
  22. package/src/layout-component.json +23 -3
  23. package/tasks/addPrivate.js +22 -0
  24. package/tasks/diff.js +2 -2
  25. package/test/checkComponentProps.js +25 -0
  26. package/test/checkId.test.js +24 -38
  27. package/test/checkManifest.test.js +1 -1
  28. package/test/checkPrivate.js +22 -0
  29. package/test/checkUniqueTokenNames.js +32 -0
  30. package/test/componentSchemaValidator.test.js +1 -1
  31. package/test/deprecateExpress.test.js +1 -1
  32. package/test/drover.test.js +1 -1
  33. package/test/schemaValidator.test.js +74 -0
  34. package/test/schemaValidators/alias.test.js +1 -1
  35. package/test/tokenSchemaValidator.test.js +1 -1
@@ -4820,12 +4820,16 @@
4820
4820
  "desktop": {
4821
4821
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/dimension.json",
4822
4822
  "value": "9px",
4823
- "uuid": "229fa20e-6d13-40b0-b19f-5cf6386f81ac"
4823
+ "uuid": "229fa20e-6d13-40b0-b19f-5cf6386f81ac",
4824
+ "deprecated": true,
4825
+ "deprecated_comment": "Introduced as an error. Use accordion-top-to-text-spacious-small instead"
4824
4826
  },
4825
4827
  "mobile": {
4826
4828
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/dimension.json",
4827
4829
  "value": "12px",
4828
- "uuid": "bef73b91-db4f-4532-9f4d-f5a81ead625d"
4830
+ "uuid": "bef73b91-db4f-4532-9f4d-f5a81ead625d",
4831
+ "deprecated": true,
4832
+ "deprecated_comment": "Introduced as an error. Use accordion-top-to-text-spacious-small instead"
4829
4833
  }
4830
4834
  }
4831
4835
  },
@@ -7518,5 +7522,21 @@
7518
7522
  "uuid": "979542c9-2328-495c-8abf-cb226b140f82"
7519
7523
  }
7520
7524
  }
7525
+ },
7526
+ "accordion-top-to-text-spacious-small": {
7527
+ "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
7528
+ "component": "accordion",
7529
+ "sets": {
7530
+ "desktop": {
7531
+ "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/dimension.json",
7532
+ "value": "9px",
7533
+ "uuid": "1f833f34-562b-4874-9f69-db74e80ffef1"
7534
+ },
7535
+ "mobile": {
7536
+ "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/dimension.json",
7537
+ "value": "12px",
7538
+ "uuid": "02e96927-9f33-4878-9ce0-bb825be84bcb"
7539
+ }
7540
+ }
7521
7541
  }
7522
- }
7542
+ }
@@ -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