Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: refactor component-schemas into package #353

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
acb7cc0
chore: refactor component-schemas into package
karstens Jun 7, 2024
5946a63
fix: used correct parameter in schema getFile function
GarthDB Jun 13, 2024
0e882f5
ci: testing automated snapshot release
GarthDB Jun 3, 2024
4b8d625
fix: addressed spectrum-component-api-schemas package name
GarthDB Jun 13, 2024
cdd1511
ci: refactored moon tasks for schema pacakge
GarthDB Jun 13, 2024
6ff5ad7
chore: added changeset
GarthDB Jun 13, 2024
0727a14
chore: snapshot release schema
GarthDB Jun 13, 2024
58dfd16
test: added tests to index.js file
GarthDB Jun 14, 2024
9805167
chore: added changeset
GarthDB Jun 14, 2024
c85b576
chore: snapshot release schema
GarthDB Jun 14, 2024
8017382
ci: fixed snapshot release workflow
GarthDB Jun 15, 2024
f4ec282
refactor: changed getAllSchemas format to include component slugs
GarthDB Jun 15, 2024
9034673
refactor: removed unused component-size type
GarthDB Jun 15, 2024
7a42c4d
feat: initial release
GarthDB Jun 18, 2024
b5c1579
chore: added changeset
GarthDB Jun 18, 2024
3bbc12b
chore: snapshot release schema
GarthDB Jun 18, 2024
8d4e05b
feat: added missing search-field schema
GarthDB Jun 18, 2024
c2cfa56
fix: schema path checks
karstens Jun 18, 2024
ebe6186
test: resolved some absolute path bugs in the tests
GarthDB Jun 20, 2024
64379eb
chore: added changeset
GarthDB Jun 20, 2024
d3c609f
chore: snapshot release schema
GarthDB Jun 20, 2024
672d2d0
fix: tabs and tab-item jsonSchema
karstens Aug 20, 2024
93b6799
fix: size property for action-button jsonSchema
karstens Aug 20, 2024
dfd67f5
fix: image property for avatar jsonSchema
karstens Aug 20, 2024
f1ac034
fix: static color property description
karstens Aug 20, 2024
e08891d
fix: integer as property value type
karstens Aug 20, 2024
0787706
Merge branch 'main' into karstens/DTT-2140--component-api-schemas
karstens Aug 20, 2024
fdb7cf6
fix: pnpm-lock.yaml
karstens Aug 20, 2024
2811d29
fix: add tab-item as children to tabs json schema
karstens Aug 20, 2024
1f2fc6d
fix: run build to publish changed json schemas to docs/site/public
karstens Aug 21, 2024
13ce53a
fix: remove children from tabs.json and remove tab-item-json
karstens Aug 21, 2024
dc2d6c6
chore: added changeset
GarthDB Aug 21, 2024
cf73cf1
chore: snapshot release schema
GarthDB Aug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .moon/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
$schema: "https://moonrepo.dev/schemas/workspace.json"
projects:
tokens: "packages/tokens"
componentSchemas: "packages/component-schemas"
visualizer: "docs/visualizer"
site: "docs/site"
root: "."
Expand Down
10 changes: 9 additions & 1 deletion docs/site/lib/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,16 @@ export async function getAllComponentSlugs() {
}

export async function getComponentData(slug) {
// not sure, if this should use the public/schemas folder, like getAllComponentSlugs()
const schemaDir = path.resolve(
path.join(process.cwd(), "..", "..", "packages", "tokens", "schemas"),
path.join(
process.cwd(),
"..",
"..",
"packages",
"component-schemas",
"schemas",
),
);
const file = await readJSON(
path.join(schemaDir, "components", `${slug}.json`),
Expand Down
16 changes: 14 additions & 2 deletions docs/site/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,18 @@ fileGroups:
target:
- "/site/[!visualizer]"
tasks:
copySchema:
copyComponentSchema:
command:
- cp
- -r
- ../../packages/component-schemas/schemas
- public/
platform: system
inputs:
- /packages/component-schemas/schemas/**/*.json
outputs:
- public/schemas
copyTokenTypeSchema:
command:
- cp
- -r
Expand All @@ -33,7 +44,8 @@ tasks:
- build
platform: node
deps:
- ~:copySchema
- ~:copyComponentSchema
- ~:copyTokenTypeSchema
outputs:
- "/site/"
clean:
Expand Down
8 changes: 6 additions & 2 deletions docs/site/public/schemas/token-types/color-set.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@
"private": {},
"deprecated": {},
"deprecated_comment": {},
"uuid": {}
"uuid": {
"type": "string",
"pattern": "^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$",
"format": "uuid"
}
},
"required": ["sets"]
"required": ["sets", "uuid"]
}
8 changes: 6 additions & 2 deletions docs/site/public/schemas/token-types/scale-set.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@
"private": {},
"deprecated": {},
"deprecated_comment": {},
"uuid": {}
"uuid": {
"type": "string",
"pattern": "^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$",
"format": "uuid"
}
},
"required": ["sets"]
"required": ["sets", "uuid"]
}
52 changes: 52 additions & 0 deletions packages/component-schemas/index.js
karstens marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

import { glob } from "glob";

import { resolve } from "path";
import { readFile } from "fs/promises";
import * as url from "url";
import { writeFile } from "fs/promises";
import { format } from "prettier";

const readJson = async (fileName) =>
JSON.parse(await readFile(fileName, "utf8"));

const writeJson = async (fileName, jsonData) => {
await writeFile(
fileName,
await format(JSON.stringify(jsonData), { parser: "json-stringify" }),
);
};

const __dirname = url.fileURLToPath(new URL(".", import.meta.url));

export const schemaFileNames = await glob(
`${resolve(__dirname, "./schemas")}/**/*.json`,
);

export const getFile = async (schemaFileName) =>
await readJson(resolve(__dirname, "src", tokenFileName));

export const getAllSchemas = async () => {
return await Promise.all(schemaFileNames.map(getFileTokens)).then(
karstens marked this conversation as resolved.
Show resolved Hide resolved
(tokenFileDataAr) => {
return tokenFileDataAr.reduce(
(tokenDataAcc, tokenFileData) => ({
...tokenDataAcc,
...tokenFileData,
}),
{},
);
},
);
};
56 changes: 56 additions & 0 deletions packages/component-schemas/moon.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2024 Adobe. All rights reserved.
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. You may obtain a copy
# of the License at http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software distributed under
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
# OF ANY KIND, either express or implied. See the License for the specific language
# governing permissions and limitations under the License.
$schema: "https://moonrepo.dev/schemas/project.json"
type: library
fileGroups:
schemas:
- "schemas/**/*.{yaml,yml,json}"
tests:
- "test/**/*"
tasks:
build:
deps:
- ~:make
- ~:buildSchemas
buildSchemas:
command:
karstens marked this conversation as resolved.
Show resolved Hide resolved
- cp
- -R
- schemas/
- dist/v1
platform: node
make:
command:
- mkdir
- -p
- dist/v1
platform: node
clean:
command:
- rm
- -rf
- dist
platform: node
test:
command:
- pnpm
- ava
inputs:
- "@globs(schemas)"
- "@globs(tests)"
deps:
- ~:buildSchemas
platform: node
test-watch:
command:
- ava
- --watch
local: true
platform: node
26 changes: 26 additions & 0 deletions packages/component-schemas/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "spectrum-component-api-schemas",
"version": "1.0.0",
"description": "",
"type": "module",
"main": "index.js",
"scripts": {},
"repository": {
"type": "git",
"url": "git+https://github.com/adobe/spectrum-tokens.git"
},
"author": "Garth Braithwaite <[email protected]> (https://garthdb.com/)",
"bugs": {
"url": "https://github.com/adobe/spectrum-tokens/issues"
},
"publishConfig": {
"provenance": true
},
"homepage": "https://github.com/adobe/spectrum-tokens/tree/main/packages/component-schemas#readme",
"license": "Apache-2.0",
"devDependencies": {
"ajv": "^8.12.0",
"ajv-formats": "^3.0.1",
"glob": "^10.3.12"
}
}
karstens marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
74 changes: 0 additions & 74 deletions packages/tokens/test/schemaValidator.test.js

This file was deleted.

Loading