@adobe/spectrum-tokens 12.24.1 → 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.
- package/CHANGELOG.md +6 -0
- package/index.js +52 -0
- package/moon.yml +3 -2
- package/package.json +7 -6
- package/schemas/token-types/alias.json +1 -0
- package/schemas/token-types/color-set.json +1 -0
- package/schemas/token-types/color.json +1 -0
- package/schemas/token-types/dimension.json +1 -0
- package/schemas/token-types/font-family.json +1 -0
- package/schemas/token-types/font-size.json +1 -0
- package/schemas/token-types/font-style.json +1 -0
- package/schemas/token-types/font-weight.json +1 -0
- package/schemas/token-types/multiplier.json +1 -0
- package/schemas/token-types/opacity.json +1 -0
- package/schemas/token-types/scale-set.json +1 -0
- package/schemas/token-types/system-set.json +1 -0
- package/schemas/token-types/text-transform.json +1 -0
- package/schemas/token-types/token.json +6 -1
- package/src/color-palette.json +426 -213
- package/src/layout-component.json +1 -0
- package/tasks/addPrivate.js +22 -0
- package/tasks/diff.js +2 -2
- package/test/checkComponentProps.js +25 -0
- package/test/checkId.test.js +24 -38
- package/test/checkManifest.test.js +1 -1
- package/test/checkPrivate.js +22 -0
- package/test/checkUniqueTokenNames.js +32 -0
- package/test/componentSchemaValidator.test.js +1 -1
- package/test/deprecateExpress.test.js +1 -1
- package/test/drover.test.js +1 -1
- package/test/schemaValidator.test.js +74 -0
- package/test/schemaValidators/alias.test.js +1 -1
- package/test/tokenSchemaValidator.test.js +1 -1
|
@@ -7525,6 +7525,7 @@
|
|
|
7525
7525
|
},
|
|
7526
7526
|
"accordion-top-to-text-spacious-small": {
|
|
7527
7527
|
"$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/scale-set.json",
|
|
7528
|
+
"component": "accordion",
|
|
7528
7529
|
"sets": {
|
|
7529
7530
|
"desktop": {
|
|
7530
7531
|
"$schema": "https://opensource.adobe.com/spectrum-tokens/schemas/token-types/dimension.json",
|
|
@@ -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
|
|
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
|
|
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
|
+
});
|
package/test/checkId.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright
|
|
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
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
46
|
+
allTokens = { ...allTokens, ...file };
|
|
62
47
|
}
|
|
63
|
-
|
|
48
|
+
const duplicateUUIDs = findDuplicateUUIDs(allTokens);
|
|
49
|
+
t.deepEqual(duplicateUUIDs, [], "duplicate uuids found");
|
|
64
50
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright
|
|
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
|
|
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
|
|
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
|
package/test/drover.test.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright
|
|
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
|
|
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
|
|
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
|