@adobe/spectrum-tokens 13.0.0-beta.27 → 13.0.0-beta.28

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @adobe/spectrum-tokens
2
2
 
3
+ ## 13.0.0-beta.28
4
+
5
+ ### Patch Changes
6
+
7
+ - 1150331: Removed duplicate tokens from src files.
8
+
3
9
  ## 13.0.0-beta.27
4
10
 
5
11
  ### Minor Changes
package/index.js ADDED
@@ -0,0 +1,52 @@
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 { glob } from "glob";
14
+
15
+ import { resolve } from "path";
16
+ import { readFile } from "fs/promises";
17
+ import * as url from "url";
18
+ import { writeFile } from "fs/promises";
19
+ import { format } from "prettier";
20
+
21
+ export const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
22
+
23
+ export const tokenFileNames = await glob(
24
+ `${resolve(__dirname, "./src")}/**/*.json`,
25
+ );
26
+
27
+ export const readJson = async (fileName) =>
28
+ JSON.parse(await readFile(fileName, "utf8"));
29
+
30
+ export const writeJson = async (fileName, jsonData) => {
31
+ await writeFile(
32
+ fileName,
33
+ await format(JSON.stringify(jsonData), { parser: "json-stringify" }),
34
+ );
35
+ };
36
+
37
+ export const getFileTokens = async (tokenFileName) =>
38
+ await readJson(resolve(__dirname, "src", tokenFileName));
39
+
40
+ export const getAllTokens = async () => {
41
+ return await Promise.all(tokenFileNames.map(getFileTokens)).then(
42
+ (tokenFileDataAr) => {
43
+ return tokenFileDataAr.reduce(
44
+ (tokenDataAcc, tokenFileData) => ({
45
+ ...tokenDataAcc,
46
+ ...tokenFileData,
47
+ }),
48
+ {},
49
+ );
50
+ },
51
+ );
52
+ };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@adobe/spectrum-tokens",
3
- "version": "13.0.0-beta.27",
3
+ "version": "13.0.0-beta.28",
4
4
  "description": "Design tokens for Spectrum, Adobe's design system",
5
5
  "type": "module",
6
- "main": "tasks/buildSpectrumTokens.js",
6
+ "main": "index.js",
7
7
  "tokens": "dist/json/variables.json",
8
8
  "repository": {
9
9
  "type": "git",
@@ -25,6 +25,7 @@
25
25
  "ajv": "^8.12.0",
26
26
  "ajv-formats": "^2.1.1",
27
27
  "deep-object-diff": "^1.1.9",
28
+ "find-duplicated-property-keys": "^1.2.9",
28
29
  "glob": "^10.3.10",
29
30
  "style-dictionary": "^3.9.2",
30
31
  "style-dictionary-sets": "^2.3.0",
@@ -7603,21 +7603,6 @@
7603
7603
  }
7604
7604
  }
7605
7605
  },
7606
- "combo-box-visual-to-field-button": {
7607
- "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/dimension.json",
7608
- "value": "0px",
7609
- "uuid": "6c3c7201-2f5b-455a-bcbf-5e3d783887bf"
7610
- },
7611
- "in-field-button-edge-to-fill-medium": {
7612
- "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/dimension.json",
7613
- "value": "6px",
7614
- "uuid": "86f41898-b794-4f7e-ae41-9eb84c2c7a5b"
7615
- },
7616
- "in-field-button-edge-to-fill-large": {
7617
- "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/dimension.json",
7618
- "value": "8px",
7619
- "uuid": "44e97486-53ce-4bb0-a778-0f9262dfe27e"
7620
- },
7621
7606
  "alert-dialog-description-font-size": {
7622
7607
  "$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
7623
7608
  "sets": {
@@ -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
+ });