create-kerf-component 5.0.0-beta.53 → 5.0.0-beta.54
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 +11 -0
- package/catalog.js +30 -4
- package/component-catalog-v2.schema.json +2 -1
- package/component-metadata.schema.json +2 -1
- package/package.json +1 -1
- package/template/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,6 +59,17 @@ A ready-to-publish component package that encodes the rules from the kerf docs
|
|
|
59
59
|
`["@kerfjs/ui:toolbar-control-group"]`), so the `ui-composition` lint treats
|
|
60
60
|
it as that root. Every key must resolve to an entry generated in the same run
|
|
61
61
|
or to an installed package's catalog.
|
|
62
|
+
Each `publicExports` item names a `package.json#exports` subpath that maps to
|
|
63
|
+
the `src/` file exporting it. A private, bundled application
|
|
64
|
+
(`package.json#private: true`) has no per-file `dist/` entries and is never
|
|
65
|
+
imported by package name, so its items may omit `subpath`
|
|
66
|
+
(`{ "name": "DemandSegmentsControl" }`); the checker then verifies the name
|
|
67
|
+
against the component's `source` file, which is how the UI lint resolves the
|
|
68
|
+
wrapper. A subpath it does declare is still checked against `exports`.
|
|
69
|
+
`private: true` is the only opt-in: a `.kerf-ui-profile.json` `scope` does
|
|
70
|
+
not change this. An application that is published to npm (an app shell), or
|
|
71
|
+
whose manifest omits `private`, either declares a real `subpath` for each
|
|
72
|
+
item or sets `"private": true`.
|
|
62
73
|
|
|
63
74
|
## Layout produced
|
|
64
75
|
|
package/catalog.js
CHANGED
|
@@ -532,6 +532,11 @@ function validateComponent(
|
|
|
532
532
|
diagnostics.push(`${at}.source: file does not exist: ${component.source}`);
|
|
533
533
|
|
|
534
534
|
const exports = packageJson.exports ?? {};
|
|
535
|
+
// A private application (package.json#private) is bundled, never imported
|
|
536
|
+
// by package name, and has no per-file dist entries. Its exports may omit
|
|
537
|
+
// `subpath`; each name is then verified against the component's own
|
|
538
|
+
// `source` file, which is how the Kerf UI rules resolve its wrappers.
|
|
539
|
+
const privateApplication = packageJson.private === true;
|
|
535
540
|
if (
|
|
536
541
|
!Array.isArray(component.publicExports) ||
|
|
537
542
|
!component.publicExports.length
|
|
@@ -541,13 +546,34 @@ function validateComponent(
|
|
|
541
546
|
const seen = new Set();
|
|
542
547
|
for (const item of component.publicExports) {
|
|
543
548
|
const exportAt = `${at}.publicExports`;
|
|
544
|
-
|
|
545
|
-
|
|
549
|
+
const sourceOnly =
|
|
550
|
+
privateApplication &&
|
|
551
|
+
Boolean(item?.name) &&
|
|
552
|
+
!Object.hasOwn(item, 'subpath');
|
|
553
|
+
if (!item?.name || (!sourceOnly && typeof item?.subpath !== 'string')) {
|
|
554
|
+
diagnostics.push(
|
|
555
|
+
`${exportAt}: every export requires name and subpath (only a private application, package.json#private, may omit subpath)`,
|
|
556
|
+
);
|
|
546
557
|
continue;
|
|
547
558
|
}
|
|
548
|
-
const key =
|
|
549
|
-
|
|
559
|
+
const key = sourceOnly
|
|
560
|
+
? `source:${item.name}`
|
|
561
|
+
: `${item.subpath}:${item.name}`;
|
|
562
|
+
if (seen.has(key))
|
|
563
|
+
diagnostics.push(
|
|
564
|
+
`${exportAt}: duplicate ${sourceOnly ? item.name : key}`,
|
|
565
|
+
);
|
|
550
566
|
seen.add(key);
|
|
567
|
+
if (sourceOnly) {
|
|
568
|
+
if (
|
|
569
|
+
existsSync(sourcePath) &&
|
|
570
|
+
!exportedNamesFromFile(sourcePath).has(item.name)
|
|
571
|
+
)
|
|
572
|
+
diagnostics.push(
|
|
573
|
+
`${exportAt}: ${item.name} is not exported by ${component.source}`,
|
|
574
|
+
);
|
|
575
|
+
continue;
|
|
576
|
+
}
|
|
551
577
|
if (!(item.subpath in exports))
|
|
552
578
|
diagnostics.push(
|
|
553
579
|
`${exportAt}: package.json does not export subpath ${item.subpath}`,
|
|
@@ -137,10 +137,11 @@
|
|
|
137
137
|
"kind": { "enum": ["component", "composition", "recipe"] },
|
|
138
138
|
"purpose": { "type": "string", "minLength": 1 },
|
|
139
139
|
"publicExports": {
|
|
140
|
+
"description": "Each export's name and the package.json#exports subpath that serves it. An entry from a private application omits subpath: the application is bundled, never imported by package name, so the name resolves through the entry's source file.",
|
|
140
141
|
"type": "array",
|
|
141
142
|
"items": {
|
|
142
143
|
"type": "object",
|
|
143
|
-
"required": ["name"
|
|
144
|
+
"required": ["name"],
|
|
144
145
|
"properties": {
|
|
145
146
|
"name": { "type": "string", "minLength": 1 },
|
|
146
147
|
"subpath": { "type": "string", "pattern": "^\\." }
|
|
@@ -97,9 +97,10 @@
|
|
|
97
97
|
"publicExports": {
|
|
98
98
|
"type": "array",
|
|
99
99
|
"minItems": 1,
|
|
100
|
+
"description": "Each export's name and package.json#exports subpath. A private application (package.json#private) may omit subpath; the name is then verified against the component's source file.",
|
|
100
101
|
"items": {
|
|
101
102
|
"type": "object",
|
|
102
|
-
"required": ["name"
|
|
103
|
+
"required": ["name"],
|
|
103
104
|
"properties": {
|
|
104
105
|
"name": { "type": "string", "minLength": 1 },
|
|
105
106
|
"subpath": { "type": "string", "pattern": "^\\." }
|
package/package.json
CHANGED