create-kerf-component 5.0.0-beta.93 → 5.0.0-beta.94
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/README.md +6 -2
- package/catalog.js +254 -36
- package/component-catalog-extension.schema.json +104 -0
- package/component-metadata.schema.json +68 -2
- package/index.js +1 -0
- package/package.json +2 -1
- package/template/package.json +2 -2
package/README.md
CHANGED
|
@@ -101,7 +101,8 @@ my-widgets/
|
|
|
101
101
|
├── scripts/
|
|
102
102
|
│ ├── kerf-component-catalog.mjs # local generator + check mode
|
|
103
103
|
│ ├── component-metadata.schema.json # author-source schema used by the checker
|
|
104
|
-
│
|
|
104
|
+
│ ├── component-composition.schema.json # emitted-catalog schema used by the checker
|
|
105
|
+
│ └── component-catalog-extension.schema.json # optional selection-catalog schema
|
|
105
106
|
├── LICENSE # MIT license with the package contributor notice
|
|
106
107
|
├── .gitignore
|
|
107
108
|
├── README.md
|
|
@@ -119,7 +120,10 @@ for its authoring checks.
|
|
|
119
120
|
The package also exposes `kerf-component-catalog`. It accepts `--write` (the
|
|
120
121
|
default), `--check`, and `--root <path>`. A root package with npm `workspaces`
|
|
121
122
|
generates every child package that declares `package.json#kerfComponentCatalog`,
|
|
122
|
-
in deterministic package and component order.
|
|
123
|
+
in deterministic package and component order. Set
|
|
124
|
+
`kerfComponentCatalog.selectionOutput` and give each component a `selection`
|
|
125
|
+
block (`useWhen`, `avoidWhen`, …) to also generate and check the `@kerfjs/ui`
|
|
126
|
+
selection catalog extension from the same `kerf.components.json`.
|
|
123
127
|
|
|
124
128
|
Application projects do not need this package scaffold. `npx kerfjs setup
|
|
125
129
|
--ui` creates an empty, schema-valid author metadata file, wires this catalog
|
package/catalog.js
CHANGED
|
@@ -22,6 +22,12 @@ const metadataSchema = JSON.parse(
|
|
|
22
22
|
const catalogSchema = JSON.parse(
|
|
23
23
|
readFileSync(join(scriptRoot, 'component-composition.schema.json'), 'utf8'),
|
|
24
24
|
);
|
|
25
|
+
const selectionSchema = JSON.parse(
|
|
26
|
+
readFileSync(
|
|
27
|
+
join(scriptRoot, 'component-catalog-extension.schema.json'),
|
|
28
|
+
'utf8',
|
|
29
|
+
),
|
|
30
|
+
);
|
|
25
31
|
|
|
26
32
|
export class CatalogError extends Error {
|
|
27
33
|
constructor(diagnostics) {
|
|
@@ -772,6 +778,192 @@ function validateRendersAs(results, diagnostics) {
|
|
|
772
778
|
}
|
|
773
779
|
}
|
|
774
780
|
|
|
781
|
+
// The selection catalog (the @kerfjs/ui component-catalog extension) shares
|
|
782
|
+
// identity, purpose, boundaries, and geometry with the composition metadata,
|
|
783
|
+
// so only the selection-only facts live in each component's `selection` block.
|
|
784
|
+
function selectionGeometry(component) {
|
|
785
|
+
if (component.selection?.geometry) return component.selection.geometry;
|
|
786
|
+
const { notes, ...owners } = component.composition.layout.geometry;
|
|
787
|
+
return notes?.length ? { ...owners, notes } : owners;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
function toSelectionEntry(component) {
|
|
791
|
+
const { selection, boundaries } = component;
|
|
792
|
+
return {
|
|
793
|
+
id: component.id,
|
|
794
|
+
name: component.name,
|
|
795
|
+
kind: component.kind,
|
|
796
|
+
purpose: component.purpose,
|
|
797
|
+
useWhen: selection.useWhen,
|
|
798
|
+
avoidWhen: selection.avoidWhen,
|
|
799
|
+
publicClasses: boundaries.publicClasses,
|
|
800
|
+
publicTokens: boundaries.publicTokens,
|
|
801
|
+
...(selection.uses ? { uses: selection.uses } : {}),
|
|
802
|
+
source: component.source,
|
|
803
|
+
...(selection.styleSources ? { styleSources: selection.styleSources } : {}),
|
|
804
|
+
...(selection.demoSource ? { demoSource: selection.demoSource } : {}),
|
|
805
|
+
geometry: selectionGeometry(component),
|
|
806
|
+
...(selection.documentation
|
|
807
|
+
? { documentation: selection.documentation }
|
|
808
|
+
: {}),
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
// The @kerfjs/ui selection catalog ids an installed copy ships, which a
|
|
813
|
+
// selection entry's `uses` may name alongside the package's own ids.
|
|
814
|
+
function kerfSelectionIds(packageRoot) {
|
|
815
|
+
for (let dir = packageRoot; ; dir = dirname(dir)) {
|
|
816
|
+
const catalogPath = join(
|
|
817
|
+
dir,
|
|
818
|
+
'node_modules',
|
|
819
|
+
'@kerfjs',
|
|
820
|
+
'ui',
|
|
821
|
+
'ai',
|
|
822
|
+
'component-catalog.json',
|
|
823
|
+
);
|
|
824
|
+
if (existsSync(catalogPath)) {
|
|
825
|
+
try {
|
|
826
|
+
const catalog = JSON.parse(readFileSync(catalogPath, 'utf8'));
|
|
827
|
+
return new Set((catalog.entries ?? []).map((entry) => entry.id));
|
|
828
|
+
} catch {
|
|
829
|
+
return null;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
if (dirname(dir) === dir) return null;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
function localPathExists(packageRoot, link) {
|
|
837
|
+
if (/^[a-z]+:/i.test(link)) return true;
|
|
838
|
+
const localPath = link.split('#')[0];
|
|
839
|
+
return !localPath || existsSync(resolve(packageRoot, localPath));
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
function posixRelative(from, to) {
|
|
843
|
+
const path = relative(from, to).split(sep).join('/');
|
|
844
|
+
return path.startsWith('.') ? path : `./${path}`;
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
function buildSelectionCatalog({
|
|
848
|
+
packageRoot,
|
|
849
|
+
packageJson,
|
|
850
|
+
metadata,
|
|
851
|
+
metadataPath,
|
|
852
|
+
outputPath,
|
|
853
|
+
selectionOutputPath,
|
|
854
|
+
diagnostics,
|
|
855
|
+
}) {
|
|
856
|
+
const at = metadataPath;
|
|
857
|
+
const selected = metadata.components.filter(
|
|
858
|
+
(component) => component.kind !== 'recipe',
|
|
859
|
+
);
|
|
860
|
+
if (!selectionOutputPath) {
|
|
861
|
+
if (metadata.description !== undefined)
|
|
862
|
+
diagnostics.push(
|
|
863
|
+
`${at}: description is emitted only to a selection catalog; configure package.json#${CONFIG_KEY}.selectionOutput or remove it`,
|
|
864
|
+
);
|
|
865
|
+
for (const component of metadata.components)
|
|
866
|
+
if (component.selection)
|
|
867
|
+
diagnostics.push(
|
|
868
|
+
`${at}: components.${component.id}.selection is emitted only to a selection catalog; configure package.json#${CONFIG_KEY}.selectionOutput or remove it`,
|
|
869
|
+
);
|
|
870
|
+
return null;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
if (!metadata.description)
|
|
874
|
+
diagnostics.push(
|
|
875
|
+
`${at}.description: author decision required; the selection catalog needs a package description`,
|
|
876
|
+
);
|
|
877
|
+
const derived = posixRelative(dirname(outputPath), selectionOutputPath);
|
|
878
|
+
if (
|
|
879
|
+
metadata.componentCatalog !== undefined &&
|
|
880
|
+
metadata.componentCatalog !== 'not-applicable' &&
|
|
881
|
+
metadata.componentCatalog !== derived
|
|
882
|
+
)
|
|
883
|
+
diagnostics.push(
|
|
884
|
+
`${at}.componentCatalog: ${metadata.componentCatalog} disagrees with the configured selectionOutput (${derived}); remove it or set it to "not-applicable"`,
|
|
885
|
+
);
|
|
886
|
+
|
|
887
|
+
const ownIds = new Set(selected.map((component) => component.id));
|
|
888
|
+
let kerfIds;
|
|
889
|
+
for (const component of metadata.components) {
|
|
890
|
+
const componentAt = `${at}: components.${component.id}.selection`;
|
|
891
|
+
if (component.kind === 'recipe') {
|
|
892
|
+
if (component.selection)
|
|
893
|
+
diagnostics.push(
|
|
894
|
+
`${componentAt}: recipes are not selection catalog entries; remove it`,
|
|
895
|
+
);
|
|
896
|
+
continue;
|
|
897
|
+
}
|
|
898
|
+
if (!component.selection) {
|
|
899
|
+
diagnostics.push(
|
|
900
|
+
`${componentAt}: author decision required; selectionOutput is configured, so every component and composition needs useWhen and avoidWhen`,
|
|
901
|
+
);
|
|
902
|
+
continue;
|
|
903
|
+
}
|
|
904
|
+
const { selection } = component;
|
|
905
|
+
if (
|
|
906
|
+
!selection.geometry &&
|
|
907
|
+
Object.values(component.composition.layout.geometry).includes('composed')
|
|
908
|
+
)
|
|
909
|
+
diagnostics.push(
|
|
910
|
+
`${componentAt}.geometry: required because composition.layout.geometry uses "composed", which the selection catalog cannot express`,
|
|
911
|
+
);
|
|
912
|
+
for (const path of [
|
|
913
|
+
...(selection.styleSources ?? []),
|
|
914
|
+
...(selection.demoSource ? [selection.demoSource] : []),
|
|
915
|
+
...(selection.documentation ? [selection.documentation] : []),
|
|
916
|
+
])
|
|
917
|
+
if (!localPathExists(packageRoot, path))
|
|
918
|
+
diagnostics.push(`${componentAt}: local path does not exist: ${path}`);
|
|
919
|
+
for (const use of selection.uses ?? []) {
|
|
920
|
+
if (use === component.id)
|
|
921
|
+
diagnostics.push(
|
|
922
|
+
`${componentAt}.uses: ${use} names the component itself`,
|
|
923
|
+
);
|
|
924
|
+
else if (!ownIds.has(use)) {
|
|
925
|
+
kerfIds ??= kerfSelectionIds(packageRoot);
|
|
926
|
+
if (!kerfIds)
|
|
927
|
+
diagnostics.push(
|
|
928
|
+
`${componentAt}.uses: cannot resolve ${use}; install @kerfjs/ui so its selection catalog ids can be checked`,
|
|
929
|
+
);
|
|
930
|
+
else if (!kerfIds.has(use))
|
|
931
|
+
diagnostics.push(
|
|
932
|
+
`${componentAt}.uses: ${use} is neither a component in this package nor a @kerfjs/ui catalog entry`,
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
if (ownIds.size) {
|
|
938
|
+
kerfIds ??= kerfSelectionIds(packageRoot);
|
|
939
|
+
for (const id of ownIds)
|
|
940
|
+
if (kerfIds?.has(id))
|
|
941
|
+
diagnostics.push(
|
|
942
|
+
`${at}: components.${id}.id duplicates a @kerfjs/ui catalog id, which the selection catalog cannot disambiguate`,
|
|
943
|
+
);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
const catalog = {
|
|
947
|
+
$schema:
|
|
948
|
+
'https://raw.githubusercontent.com/brianwestphal/kerf/main/ui/ai/component-catalog-extension.schema.json',
|
|
949
|
+
schemaVersion: 1,
|
|
950
|
+
package: packageJson.name,
|
|
951
|
+
description: metadata.description,
|
|
952
|
+
entries: selected
|
|
953
|
+
.filter((component) => component.selection)
|
|
954
|
+
.sort((a, b) => a.id.localeCompare(b.id))
|
|
955
|
+
.map(toSelectionEntry),
|
|
956
|
+
};
|
|
957
|
+
diagnostics.push(
|
|
958
|
+
...validateDocumentAgainstSchema(
|
|
959
|
+
catalog,
|
|
960
|
+
selectionSchema,
|
|
961
|
+
selectionOutputPath,
|
|
962
|
+
),
|
|
963
|
+
);
|
|
964
|
+
return catalog;
|
|
965
|
+
}
|
|
966
|
+
|
|
775
967
|
export function generateCatalogs(root = process.cwd()) {
|
|
776
968
|
const diagnostics = [];
|
|
777
969
|
const packages = configuredPackages(resolve(root), diagnostics);
|
|
@@ -796,6 +988,16 @@ export function generateCatalogs(root = process.cwd()) {
|
|
|
796
988
|
for (const key of ['source', 'output'])
|
|
797
989
|
if (!config?.[key])
|
|
798
990
|
diagnostics.push(`${packagePath}#${CONFIG_KEY}.${key}: is required`);
|
|
991
|
+
if (
|
|
992
|
+
config?.selectionOutput !== undefined &&
|
|
993
|
+
(typeof config.selectionOutput !== 'string' ||
|
|
994
|
+
!config.selectionOutput ||
|
|
995
|
+
resolve(packageRoot, config.selectionOutput) ===
|
|
996
|
+
resolve(packageRoot, config.output ?? ''))
|
|
997
|
+
)
|
|
998
|
+
diagnostics.push(
|
|
999
|
+
`${packagePath}#${CONFIG_KEY}.selectionOutput: expected a path distinct from output`,
|
|
1000
|
+
);
|
|
799
1001
|
if (!config?.source || !config?.output) continue;
|
|
800
1002
|
const metadataPath = resolve(packageRoot, config.source);
|
|
801
1003
|
const metadata = readJson(metadataPath, metadataPath, diagnostics);
|
|
@@ -823,29 +1025,43 @@ export function generateCatalogs(root = process.cwd()) {
|
|
|
823
1025
|
const entries = [...metadata.components]
|
|
824
1026
|
.sort((a, b) => a.id.localeCompare(b.id))
|
|
825
1027
|
.map((component) => toEntry(packageJson.name, component));
|
|
1028
|
+
const outputPath = resolve(packageRoot, config.output);
|
|
1029
|
+
const selectionOutputPath =
|
|
1030
|
+
typeof config.selectionOutput === 'string' && config.selectionOutput
|
|
1031
|
+
? resolve(packageRoot, config.selectionOutput)
|
|
1032
|
+
: null;
|
|
1033
|
+
const selection = buildSelectionCatalog({
|
|
1034
|
+
packageRoot,
|
|
1035
|
+
packageJson,
|
|
1036
|
+
metadata,
|
|
1037
|
+
metadataPath,
|
|
1038
|
+
outputPath,
|
|
1039
|
+
selectionOutputPath,
|
|
1040
|
+
diagnostics,
|
|
1041
|
+
});
|
|
1042
|
+
const componentCatalog = selectionOutputPath
|
|
1043
|
+
? posixRelative(dirname(outputPath), selectionOutputPath)
|
|
1044
|
+
: (metadata.componentCatalog ?? 'not-applicable');
|
|
826
1045
|
const catalog = {
|
|
827
1046
|
$schema:
|
|
828
1047
|
'https://raw.githubusercontent.com/brianwestphal/kerf/main/ui/ai/component-composition-extension.schema.json',
|
|
829
1048
|
schemaVersion: 1,
|
|
830
1049
|
package: packageJson.name,
|
|
831
1050
|
compatibility: {
|
|
832
|
-
componentCatalog
|
|
1051
|
+
componentCatalog,
|
|
833
1052
|
identity: 'package:id',
|
|
834
1053
|
},
|
|
835
1054
|
entries,
|
|
836
1055
|
};
|
|
837
1056
|
diagnostics.push(
|
|
838
|
-
...validateDocumentAgainstSchema(
|
|
839
|
-
catalog,
|
|
840
|
-
catalogSchema,
|
|
841
|
-
resolve(packageRoot, config.output),
|
|
842
|
-
),
|
|
1057
|
+
...validateDocumentAgainstSchema(catalog, catalogSchema, outputPath),
|
|
843
1058
|
);
|
|
844
1059
|
results.push({
|
|
845
1060
|
packageRoot,
|
|
846
1061
|
metadataPath,
|
|
847
|
-
outputPath
|
|
1062
|
+
outputPath,
|
|
848
1063
|
catalog,
|
|
1064
|
+
...(selection ? { selectionOutputPath, selection } : {}),
|
|
849
1065
|
});
|
|
850
1066
|
}
|
|
851
1067
|
validateRendersAs(results, diagnostics);
|
|
@@ -857,6 +1073,21 @@ export function formatCatalog(catalog) {
|
|
|
857
1073
|
return `${JSON.stringify(catalog, null, 2)}\n`;
|
|
858
1074
|
}
|
|
859
1075
|
|
|
1076
|
+
function checkOutput(path, catalog, schema, label, diagnostics) {
|
|
1077
|
+
if (!existsSync(path)) {
|
|
1078
|
+
diagnostics.push(`${path}: generated ${label} is missing`);
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1081
|
+
const actualSource = readFileSync(path, 'utf8');
|
|
1082
|
+
const actual = readJson(path, path, diagnostics);
|
|
1083
|
+
if (actual)
|
|
1084
|
+
diagnostics.push(...validateDocumentAgainstSchema(actual, schema, path));
|
|
1085
|
+
if (actualSource !== formatCatalog(catalog))
|
|
1086
|
+
diagnostics.push(
|
|
1087
|
+
`${path}: generated ${label} is stale; run catalog:generate`,
|
|
1088
|
+
);
|
|
1089
|
+
}
|
|
1090
|
+
|
|
860
1091
|
export function runCatalogCommand({
|
|
861
1092
|
root = process.cwd(),
|
|
862
1093
|
check = false,
|
|
@@ -864,32 +1095,19 @@ export function runCatalogCommand({
|
|
|
864
1095
|
const results = generateCatalogs(root);
|
|
865
1096
|
const diagnostics = [];
|
|
866
1097
|
for (const result of results) {
|
|
867
|
-
const
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
...validateDocumentAgainstSchema(
|
|
881
|
-
actual,
|
|
882
|
-
catalogSchema,
|
|
883
|
-
result.outputPath,
|
|
884
|
-
),
|
|
885
|
-
);
|
|
886
|
-
if (actualSource !== expected)
|
|
887
|
-
diagnostics.push(
|
|
888
|
-
`${result.outputPath}: generated catalog is stale; run catalog:generate`,
|
|
889
|
-
);
|
|
890
|
-
}
|
|
891
|
-
} else {
|
|
892
|
-
writeFileSync(result.outputPath, expected);
|
|
1098
|
+
const outputs = [
|
|
1099
|
+
[result.outputPath, result.catalog, catalogSchema, 'catalog'],
|
|
1100
|
+
];
|
|
1101
|
+
if (result.selection)
|
|
1102
|
+
outputs.push([
|
|
1103
|
+
result.selectionOutputPath,
|
|
1104
|
+
result.selection,
|
|
1105
|
+
selectionSchema,
|
|
1106
|
+
'selection catalog',
|
|
1107
|
+
]);
|
|
1108
|
+
for (const [path, catalog, schema, label] of outputs) {
|
|
1109
|
+
if (check) checkOutput(path, catalog, schema, label, diagnostics);
|
|
1110
|
+
else writeFileSync(path, formatCatalog(catalog));
|
|
893
1111
|
}
|
|
894
1112
|
}
|
|
895
1113
|
if (diagnostics.length) throw new CatalogError(diagnostics);
|
|
@@ -924,9 +1142,9 @@ if (isMain) {
|
|
|
924
1142
|
const results = runCatalogCommand(options);
|
|
925
1143
|
const verb = options.check ? 'verified' : 'wrote';
|
|
926
1144
|
for (const result of results)
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1145
|
+
for (const path of [result.outputPath, result.selectionOutputPath])
|
|
1146
|
+
if (path)
|
|
1147
|
+
process.stdout.write(`${verb} ${relative(options.root, path)}\n`);
|
|
930
1148
|
} catch (error) {
|
|
931
1149
|
const diagnostics =
|
|
932
1150
|
error instanceof CatalogError ? error.diagnostics : [error.message];
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/brianwestphal/kerf/main/ui/ai/component-catalog-extension.schema.json",
|
|
4
|
+
"title": "Kerf UI consumer component catalog extension",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"required": ["schemaVersion", "package", "description", "entries"],
|
|
7
|
+
"properties": {
|
|
8
|
+
"$schema": { "type": "string" },
|
|
9
|
+
"schemaVersion": { "const": 1 },
|
|
10
|
+
"package": { "type": "string", "minLength": 1 },
|
|
11
|
+
"description": { "type": "string", "minLength": 1 },
|
|
12
|
+
"entries": {
|
|
13
|
+
"type": "array",
|
|
14
|
+
"items": { "$ref": "#/$defs/entry" }
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"additionalProperties": false,
|
|
18
|
+
"$defs": {
|
|
19
|
+
"entry": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"required": [
|
|
22
|
+
"id",
|
|
23
|
+
"name",
|
|
24
|
+
"kind",
|
|
25
|
+
"purpose",
|
|
26
|
+
"useWhen",
|
|
27
|
+
"avoidWhen",
|
|
28
|
+
"geometry"
|
|
29
|
+
],
|
|
30
|
+
"properties": {
|
|
31
|
+
"id": { "type": "string", "minLength": 1 },
|
|
32
|
+
"name": { "type": "string", "minLength": 1 },
|
|
33
|
+
"kind": { "enum": ["component", "composition"] },
|
|
34
|
+
"purpose": { "type": "string", "minLength": 1 },
|
|
35
|
+
"useWhen": {
|
|
36
|
+
"type": "array",
|
|
37
|
+
"items": { "type": "string" },
|
|
38
|
+
"minItems": 1
|
|
39
|
+
},
|
|
40
|
+
"avoidWhen": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"items": { "type": "string" },
|
|
43
|
+
"minItems": 1
|
|
44
|
+
},
|
|
45
|
+
"publicClasses": {
|
|
46
|
+
"type": "array",
|
|
47
|
+
"items": { "type": "string" },
|
|
48
|
+
"uniqueItems": true
|
|
49
|
+
},
|
|
50
|
+
"publicTokens": {
|
|
51
|
+
"type": "array",
|
|
52
|
+
"items": { "type": "string" },
|
|
53
|
+
"uniqueItems": true
|
|
54
|
+
},
|
|
55
|
+
"uses": {
|
|
56
|
+
"description": "Directly composed Kerf or consumer catalog entry ids.",
|
|
57
|
+
"type": "array",
|
|
58
|
+
"items": { "type": "string", "minLength": 1 },
|
|
59
|
+
"uniqueItems": true
|
|
60
|
+
},
|
|
61
|
+
"source": { "$ref": "#/$defs/repositoryPath" },
|
|
62
|
+
"styleSources": {
|
|
63
|
+
"description": "Stylesheets owned by this component, relative to the consumer package root. Used by Doctor's opt-in component ownership mode.",
|
|
64
|
+
"type": "array",
|
|
65
|
+
"items": {
|
|
66
|
+
"allOf": [
|
|
67
|
+
{ "$ref": "#/$defs/repositoryPath" },
|
|
68
|
+
{ "pattern": "\\.css$" }
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"minItems": 1,
|
|
72
|
+
"uniqueItems": true
|
|
73
|
+
},
|
|
74
|
+
"demoSource": { "$ref": "#/$defs/repositoryPath" },
|
|
75
|
+
"geometry": { "$ref": "#/$defs/geometry" },
|
|
76
|
+
"documentation": { "type": "string", "minLength": 1 }
|
|
77
|
+
},
|
|
78
|
+
"additionalProperties": false
|
|
79
|
+
},
|
|
80
|
+
"geometry": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"required": ["margin", "border", "padding"],
|
|
83
|
+
"properties": {
|
|
84
|
+
"margin": { "$ref": "#/$defs/geometryOwner" },
|
|
85
|
+
"border": { "$ref": "#/$defs/geometryOwner" },
|
|
86
|
+
"padding": { "$ref": "#/$defs/geometryOwner" },
|
|
87
|
+
"notes": {
|
|
88
|
+
"type": "array",
|
|
89
|
+
"items": { "type": "string", "minLength": 1 },
|
|
90
|
+
"minItems": 1
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"additionalProperties": false
|
|
94
|
+
},
|
|
95
|
+
"geometryOwner": {
|
|
96
|
+
"enum": ["self", "parent", "child", "none", "conditional"]
|
|
97
|
+
},
|
|
98
|
+
"repositoryPath": {
|
|
99
|
+
"description": "A repository-relative POSIX path without traversal or empty segments.",
|
|
100
|
+
"type": "string",
|
|
101
|
+
"pattern": "^(?!.*(?:^|/)\\.{1,2}(?:/|$))[A-Za-z0-9._-]+(?:/[A-Za-z0-9._-]+)*$"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -10,7 +10,12 @@
|
|
|
10
10
|
"componentCatalog": {
|
|
11
11
|
"type": "string",
|
|
12
12
|
"minLength": 1,
|
|
13
|
-
"description": "Relative path to the package's component (selection) catalog, copied into the generated composition catalog's compatibility.componentCatalog; defaults to \"not-applicable\"."
|
|
13
|
+
"description": "Relative path to the package's component (selection) catalog, copied into the generated composition catalog's compatibility.componentCatalog. When package.json#kerfComponentCatalog.selectionOutput is configured and this is absent or \"not-applicable\", the generator derives it from that output path; otherwise it defaults to \"not-applicable\"."
|
|
14
|
+
},
|
|
15
|
+
"description": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"minLength": 1,
|
|
18
|
+
"description": "One-line description of the package's components, emitted as the selection catalog's description. Required when package.json#kerfComponentCatalog.selectionOutput is configured."
|
|
14
19
|
},
|
|
15
20
|
"components": {
|
|
16
21
|
"type": "array",
|
|
@@ -46,6 +51,66 @@
|
|
|
46
51
|
},
|
|
47
52
|
"additionalProperties": false
|
|
48
53
|
},
|
|
54
|
+
"repositoryPath": {
|
|
55
|
+
"description": "A package-relative POSIX path without traversal or empty segments.",
|
|
56
|
+
"type": "string",
|
|
57
|
+
"pattern": "^(?!.*(?:^|/)\\.{1,2}(?:/|$))[A-Za-z0-9._-]+(?:/[A-Za-z0-9._-]+)*$"
|
|
58
|
+
},
|
|
59
|
+
"selection": {
|
|
60
|
+
"description": "Selection facts for the generated selection catalog (package.json#kerfComponentCatalog.selectionOutput). name, kind, purpose, source, publicClasses, publicTokens, and geometry are derived from the component; only the facts the composition metadata cannot express live here. Required on every component and composition when selectionOutput is configured; recipes are not selection entries.",
|
|
61
|
+
"type": "object",
|
|
62
|
+
"required": ["useWhen", "avoidWhen"],
|
|
63
|
+
"properties": {
|
|
64
|
+
"useWhen": {
|
|
65
|
+
"type": "array",
|
|
66
|
+
"items": { "type": "string", "minLength": 1 },
|
|
67
|
+
"minItems": 1
|
|
68
|
+
},
|
|
69
|
+
"avoidWhen": {
|
|
70
|
+
"type": "array",
|
|
71
|
+
"items": { "type": "string", "minLength": 1 },
|
|
72
|
+
"minItems": 1
|
|
73
|
+
},
|
|
74
|
+
"uses": {
|
|
75
|
+
"description": "Directly composed catalog entry ids: this package's own component ids or @kerfjs/ui selection catalog ids.",
|
|
76
|
+
"$ref": "#/$defs/stringList"
|
|
77
|
+
},
|
|
78
|
+
"styleSources": {
|
|
79
|
+
"description": "Stylesheets this component owns, relative to the package root.",
|
|
80
|
+
"type": "array",
|
|
81
|
+
"items": {
|
|
82
|
+
"allOf": [
|
|
83
|
+
{ "$ref": "#/$defs/repositoryPath" },
|
|
84
|
+
{ "pattern": "\\.css$" }
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"minItems": 1,
|
|
88
|
+
"uniqueItems": true
|
|
89
|
+
},
|
|
90
|
+
"demoSource": { "$ref": "#/$defs/repositoryPath" },
|
|
91
|
+
"documentation": { "type": "string", "minLength": 1 },
|
|
92
|
+
"geometry": {
|
|
93
|
+
"description": "Overrides composition.layout.geometry in the selection catalog. Required when that geometry uses the composition-only owner \"composed\".",
|
|
94
|
+
"type": "object",
|
|
95
|
+
"required": ["margin", "border", "padding"],
|
|
96
|
+
"properties": {
|
|
97
|
+
"margin": { "$ref": "#/$defs/selectionGeometryOwner" },
|
|
98
|
+
"border": { "$ref": "#/$defs/selectionGeometryOwner" },
|
|
99
|
+
"padding": { "$ref": "#/$defs/selectionGeometryOwner" },
|
|
100
|
+
"notes": {
|
|
101
|
+
"type": "array",
|
|
102
|
+
"items": { "type": "string", "minLength": 1 },
|
|
103
|
+
"minItems": 1
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"additionalProperties": false
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
"additionalProperties": false
|
|
110
|
+
},
|
|
111
|
+
"selectionGeometryOwner": {
|
|
112
|
+
"enum": ["self", "parent", "child", "none", "conditional"]
|
|
113
|
+
},
|
|
49
114
|
"stringList": {
|
|
50
115
|
"type": "array",
|
|
51
116
|
"items": { "type": "string", "minLength": 1 },
|
|
@@ -156,7 +221,8 @@
|
|
|
156
221
|
"composition": { "type": "string", "minLength": 1 }
|
|
157
222
|
},
|
|
158
223
|
"additionalProperties": false
|
|
159
|
-
}
|
|
224
|
+
},
|
|
225
|
+
"selection": { "$ref": "#/$defs/selection" }
|
|
160
226
|
},
|
|
161
227
|
"additionalProperties": false
|
|
162
228
|
},
|
package/index.js
CHANGED
|
@@ -137,6 +137,7 @@ async function main(argv) {
|
|
|
137
137
|
for (const schema of [
|
|
138
138
|
'component-metadata.schema.json',
|
|
139
139
|
'component-composition.schema.json',
|
|
140
|
+
'component-catalog-extension.schema.json',
|
|
140
141
|
])
|
|
141
142
|
copyFileSync(
|
|
142
143
|
join(dirname(fileURLToPath(import.meta.url)), schema),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-kerf-component",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.94",
|
|
4
4
|
"description": "Scaffold a publishable kerf component package that already follows kerf's hard packaging rules.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"catalog.js",
|
|
35
35
|
"component-metadata.schema.json",
|
|
36
36
|
"component-composition.schema.json",
|
|
37
|
+
"component-catalog-extension.schema.json",
|
|
37
38
|
"template",
|
|
38
39
|
"README.md",
|
|
39
40
|
"LICENSE"
|
package/template/package.json
CHANGED