@designos/compiler-cli 0.2.0 → 0.3.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/README.md CHANGED
@@ -8,6 +8,8 @@ pnpm --filter @designos/compiler-cli exec designos compile --target vue --config
8
8
  pnpm --filter @designos/compiler-cli exec designos kit validate --root docs/specifications/examples/component-kit
9
9
  ```
10
10
 
11
+ Component-kit validation supports schema versions 1 and 2. Schema v2 also validates the referenced kit-owned design manifest, including its tokens and presets.
12
+
11
13
  `designos kit validate` applies the root Draft 2020-12 kit schema before resolving manifest references, then checks package metadata agreement, SemVer and compatibility ranges, safe file and symlink resolution, normalized and unique output paths (including file/directory conflicts), kit inventory/compiler-project correspondence, component manifests, declared styles/assets and local imports, and editor catalog references. Compatibility-range mismatches for versions available to the validator are reported as warnings; the editor range is parsed but is not compared because this CLI does not resolve an editor version. Schema or semantic errors return a nonzero exit code. The command is read-only: it does not compile targets, write artifacts, publish packages, or claim target semantic parity. The `--root` option defaults to the current directory.
12
14
 
13
15
  The command defaults to `designos.project.json` and `dist/designos/<target>`. `--out-dir` must be a dedicated subdirectory under the project’s `dist` directory. Existing generated files at matching paths are replaced; unrelated output files are left untouched. For version-1 projects, component `outputDirectory` values are relative to the target output root and default to `components`. For version-2 source projects, the default generated module directory follows the source file's relative directory, preserving relative imports. Declared asset `outputPath` values are relative to the target output root and default to their project-relative `source` path.
package/dist/cli.js CHANGED
@@ -1478,10 +1478,415 @@ var designos_kit_schema_default = {
1478
1478
  }
1479
1479
  };
1480
1480
 
1481
+ // ../../schemas/designos.kit.schema.v2.json
1482
+ var designos_kit_schema_v2_default = {
1483
+ $schema: "https://json-schema.org/draft/2020-12/schema",
1484
+ $id: "https://raw.githubusercontent.com/relacloud/design-os/main/schemas/designos.kit.schema.v2.json",
1485
+ title: "DesignOS Component Kit Manifest (Version 2)",
1486
+ description: "Root manifest for a version 2 DesignOS component kit.",
1487
+ type: "object",
1488
+ additionalProperties: false,
1489
+ required: [
1490
+ "schemaVersion",
1491
+ "id",
1492
+ "name",
1493
+ "version",
1494
+ "compilerProject",
1495
+ "designos",
1496
+ "components",
1497
+ "design"
1498
+ ],
1499
+ properties: {
1500
+ $schema: {
1501
+ type: "string",
1502
+ format: "uri"
1503
+ },
1504
+ schemaVersion: {
1505
+ const: "2",
1506
+ description: "Version of this kit-manifest contract; independent from compiler project schemaVersion."
1507
+ },
1508
+ id: {
1509
+ type: "string",
1510
+ minLength: 1,
1511
+ maxLength: 214,
1512
+ pattern: "^(?:@[a-z0-9][a-z0-9._-]*/)?[a-z0-9][a-z0-9._-]*$",
1513
+ description: "Exact package identifier; semantic validation checks equality with package.json.name."
1514
+ },
1515
+ name: {
1516
+ type: "string",
1517
+ minLength: 1,
1518
+ maxLength: 160
1519
+ },
1520
+ version: {
1521
+ $ref: "#/$defs/semver",
1522
+ description: "Strict SemVer 2.0.0 package version; this value is not a compatibility range."
1523
+ },
1524
+ description: {
1525
+ type: "string",
1526
+ maxLength: 2e3
1527
+ },
1528
+ license: {
1529
+ type: "string",
1530
+ minLength: 1,
1531
+ maxLength: 128
1532
+ },
1533
+ compilerProject: {
1534
+ $ref: "#/$defs/packageRelativePath",
1535
+ description: "Package-relative path to the compiler project; existence and real-path containment are semantic checks."
1536
+ },
1537
+ design: {
1538
+ type: "object",
1539
+ additionalProperties: false,
1540
+ required: [
1541
+ "manifest"
1542
+ ],
1543
+ properties: {
1544
+ manifest: {
1545
+ $ref: "#/$defs/packageRelativePath",
1546
+ description: "Package-relative path to the kit design manifest."
1547
+ }
1548
+ },
1549
+ minProperties: 1
1550
+ },
1551
+ designos: {
1552
+ type: "object",
1553
+ additionalProperties: false,
1554
+ required: [
1555
+ "kit"
1556
+ ],
1557
+ properties: {
1558
+ kit: {
1559
+ type: "string",
1560
+ minLength: 1,
1561
+ description: "Non-empty SemVer range for the kit contract. Schema validation checks only the string; semantic validation parses the range."
1562
+ },
1563
+ core: {
1564
+ type: "string",
1565
+ minLength: 1,
1566
+ description: "Optional non-empty SemVer range for DesignOS core; semantic validation parses the range."
1567
+ },
1568
+ compiler: {
1569
+ type: "string",
1570
+ minLength: 1,
1571
+ description: "Optional non-empty SemVer range for the compiler; semantic validation parses the range."
1572
+ },
1573
+ editor: {
1574
+ type: "string",
1575
+ minLength: 1,
1576
+ description: "Optional non-empty SemVer range for the editor; semantic validation parses the range."
1577
+ }
1578
+ }
1579
+ },
1580
+ components: {
1581
+ type: "array",
1582
+ minItems: 1,
1583
+ items: {
1584
+ $ref: "#/$defs/component"
1585
+ }
1586
+ },
1587
+ editor: {
1588
+ type: "object",
1589
+ additionalProperties: false,
1590
+ properties: {
1591
+ catalog: {
1592
+ $ref: "#/$defs/packageRelativePath"
1593
+ },
1594
+ previews: {
1595
+ type: "object",
1596
+ description: "Optional editor host adapters keyed by stable component type.",
1597
+ propertyNames: {
1598
+ minLength: 1
1599
+ },
1600
+ additionalProperties: {
1601
+ $ref: "#/$defs/packageRelativePath"
1602
+ }
1603
+ }
1604
+ },
1605
+ minProperties: 1
1606
+ },
1607
+ metadata: {
1608
+ type: "object",
1609
+ description: "Reserved for non-normative publisher-specific metadata.",
1610
+ additionalProperties: true
1611
+ }
1612
+ },
1613
+ $defs: {
1614
+ component: {
1615
+ type: "object",
1616
+ additionalProperties: false,
1617
+ required: [
1618
+ "type",
1619
+ "source",
1620
+ "exportName",
1621
+ "manifest"
1622
+ ],
1623
+ properties: {
1624
+ type: {
1625
+ type: "string",
1626
+ minLength: 1,
1627
+ maxLength: 128,
1628
+ description: "Stable public component type; uniqueness and manifest agreement are semantic checks."
1629
+ },
1630
+ source: {
1631
+ $ref: "#/$defs/packageRelativePath"
1632
+ },
1633
+ exportName: {
1634
+ type: "string",
1635
+ pattern: "^[A-Za-z_$][A-Za-z0-9_$]*$",
1636
+ description: "Compiler export identifier; agreement with the compiler-project entry is a semantic check."
1637
+ },
1638
+ manifest: {
1639
+ $ref: "#/$defs/packageRelativePath"
1640
+ }
1641
+ }
1642
+ },
1643
+ packageRelativePath: {
1644
+ type: "string",
1645
+ minLength: 1,
1646
+ maxLength: 1024,
1647
+ pattern: "^(?!/)(?![A-Za-z]:)(?!.*(?:^|/)\\.\\.?/)(?!.*(?:^|/)\\.\\.?$)[^\\\\\\u0000]+$",
1648
+ description: "Package-relative path with basic lexical restrictions. Semantic validation must check normalized segments, existence, and real-path containment after symlink resolution."
1649
+ },
1650
+ semver: {
1651
+ type: "string",
1652
+ pattern: "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-((?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\\+([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?$",
1653
+ description: "Strict SemVer 2.0.0 version syntax, excluding compatibility ranges."
1654
+ }
1655
+ }
1656
+ };
1657
+
1658
+ // ../../schemas/designos.design.schema.json
1659
+ var designos_design_schema_default = {
1660
+ $schema: "https://json-schema.org/draft/2020-12/schema",
1661
+ $id: "https://raw.githubusercontent.com/relacloud/design-os/main/schemas/designos.design.schema.json",
1662
+ title: "DesignOS Kit Design Manifest",
1663
+ description: "Declarative design tokens, defaults, and presets owned by a component kit.",
1664
+ type: "object",
1665
+ additionalProperties: false,
1666
+ required: ["schemaVersion", "name", "tokens", "presets"],
1667
+ properties: {
1668
+ $schema: {
1669
+ type: "string",
1670
+ format: "uri"
1671
+ },
1672
+ schemaVersion: {
1673
+ const: "1",
1674
+ description: "Version of the design-manifest format; independent from the kit-manifest and kit package versions."
1675
+ },
1676
+ name: {
1677
+ type: "string",
1678
+ minLength: 1,
1679
+ maxLength: 160
1680
+ },
1681
+ description: {
1682
+ type: "string",
1683
+ maxLength: 2e3
1684
+ },
1685
+ tokens: {
1686
+ type: "array",
1687
+ minItems: 1,
1688
+ items: {
1689
+ $ref: "#/$defs/token"
1690
+ }
1691
+ },
1692
+ presets: {
1693
+ type: "array",
1694
+ minItems: 1,
1695
+ items: {
1696
+ $ref: "#/$defs/preset"
1697
+ }
1698
+ }
1699
+ },
1700
+ $defs: {
1701
+ token: {
1702
+ type: "object",
1703
+ additionalProperties: false,
1704
+ required: ["id", "label", "type", "default", "cssVariable"],
1705
+ properties: {
1706
+ id: {
1707
+ type: "string",
1708
+ minLength: 1,
1709
+ maxLength: 128,
1710
+ pattern: "^[A-Za-z][A-Za-z0-9._-]*$",
1711
+ description: "Stable identifier used as the key in saved design values and preset values."
1712
+ },
1713
+ label: {
1714
+ type: "string",
1715
+ minLength: 1,
1716
+ maxLength: 160
1717
+ },
1718
+ description: {
1719
+ type: "string",
1720
+ maxLength: 1e3
1721
+ },
1722
+ group: {
1723
+ type: "string",
1724
+ minLength: 1,
1725
+ maxLength: 100
1726
+ },
1727
+ type: {
1728
+ enum: ["color", "font-family", "number", "select"]
1729
+ },
1730
+ default: {
1731
+ anyOf: [{ type: "string" }, { type: "number" }]
1732
+ },
1733
+ cssVariable: {
1734
+ type: "string",
1735
+ pattern: "^--[A-Za-z_][A-Za-z0-9_-]*$",
1736
+ description: "CSS custom property used when projecting the saved design into preview or runtime styles."
1737
+ },
1738
+ options: {
1739
+ type: "array",
1740
+ minItems: 1,
1741
+ items: {
1742
+ $ref: "#/$defs/option"
1743
+ }
1744
+ },
1745
+ min: {
1746
+ type: "number"
1747
+ },
1748
+ max: {
1749
+ type: "number"
1750
+ },
1751
+ step: {
1752
+ type: "number",
1753
+ exclusiveMinimum: 0
1754
+ },
1755
+ unit: {
1756
+ enum: ["", "px", "rem", "em", "%"]
1757
+ }
1758
+ },
1759
+ allOf: [
1760
+ {
1761
+ if: {
1762
+ properties: { type: { const: "color" } },
1763
+ required: ["type"]
1764
+ },
1765
+ then: {
1766
+ properties: {
1767
+ default: { $ref: "#/$defs/colorValue" }
1768
+ }
1769
+ }
1770
+ },
1771
+ {
1772
+ if: {
1773
+ properties: { type: { const: "font-family" } },
1774
+ required: ["type"]
1775
+ },
1776
+ then: {
1777
+ required: ["options"],
1778
+ properties: {
1779
+ default: { $ref: "#/$defs/fontFamilyValue" },
1780
+ options: {
1781
+ type: "array",
1782
+ minItems: 1,
1783
+ items: { $ref: "#/$defs/option" }
1784
+ }
1785
+ }
1786
+ }
1787
+ },
1788
+ {
1789
+ if: {
1790
+ properties: { type: { const: "number" } },
1791
+ required: ["type"]
1792
+ },
1793
+ then: {
1794
+ required: ["min", "max", "step"],
1795
+ properties: {
1796
+ default: { type: "number" },
1797
+ min: { type: "number" },
1798
+ max: { type: "number" },
1799
+ step: { type: "number", exclusiveMinimum: 0 }
1800
+ }
1801
+ }
1802
+ },
1803
+ {
1804
+ if: {
1805
+ properties: { type: { const: "select" } },
1806
+ required: ["type"]
1807
+ },
1808
+ then: {
1809
+ required: ["options"],
1810
+ properties: {
1811
+ default: { $ref: "#/$defs/optionValue" },
1812
+ options: {
1813
+ type: "array",
1814
+ minItems: 1,
1815
+ items: { $ref: "#/$defs/option" }
1816
+ }
1817
+ }
1818
+ }
1819
+ }
1820
+ ]
1821
+ },
1822
+ option: {
1823
+ type: "object",
1824
+ additionalProperties: false,
1825
+ required: ["value", "label"],
1826
+ properties: {
1827
+ value: {
1828
+ $ref: "#/$defs/optionValue"
1829
+ },
1830
+ label: {
1831
+ type: "string",
1832
+ minLength: 1,
1833
+ maxLength: 160
1834
+ }
1835
+ }
1836
+ },
1837
+ preset: {
1838
+ type: "object",
1839
+ additionalProperties: false,
1840
+ required: ["id", "name", "values"],
1841
+ properties: {
1842
+ id: {
1843
+ type: "string",
1844
+ minLength: 1,
1845
+ maxLength: 128,
1846
+ pattern: "^[A-Za-z][A-Za-z0-9._-]*$"
1847
+ },
1848
+ name: {
1849
+ type: "string",
1850
+ minLength: 1,
1851
+ maxLength: 160
1852
+ },
1853
+ description: {
1854
+ type: "string",
1855
+ maxLength: 1e3
1856
+ },
1857
+ values: {
1858
+ type: "object",
1859
+ minProperties: 1,
1860
+ additionalProperties: {
1861
+ anyOf: [{ type: "string" }, { type: "number" }]
1862
+ },
1863
+ description: "Values keyed by token ID. Semantic validation checks completeness and token compatibility."
1864
+ }
1865
+ }
1866
+ },
1867
+ colorValue: {
1868
+ type: "string",
1869
+ pattern: "^#(?:[A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$"
1870
+ },
1871
+ fontFamilyValue: {
1872
+ type: "string",
1873
+ minLength: 1,
1874
+ maxLength: 160,
1875
+ pattern: "^[A-Za-z0-9][A-Za-z0-9 _.,'-]*$"
1876
+ },
1877
+ optionValue: {
1878
+ type: "string",
1879
+ minLength: 1,
1880
+ maxLength: 160,
1881
+ pattern: "^[A-Za-z0-9][A-Za-z0-9 _.,'-]*$"
1882
+ }
1883
+ }
1884
+ };
1885
+
1481
1886
  // ../core/package.json
1482
1887
  var package_default = {
1483
1888
  name: "@designos/core",
1484
- version: "0.1.0",
1889
+ version: "0.2.0",
1485
1890
  private: false,
1486
1891
  type: "module",
1487
1892
  exports: {
@@ -1524,7 +1929,7 @@ var package_default = {
1524
1929
  // package.json
1525
1930
  var package_default2 = {
1526
1931
  name: "@designos/compiler-cli",
1527
- version: "0.2.0",
1932
+ version: "0.3.0",
1528
1933
  private: false,
1529
1934
  type: "module",
1530
1935
  bin: {
@@ -1571,14 +1976,16 @@ var package_default2 = {
1571
1976
  };
1572
1977
 
1573
1978
  // src/kit-validator.ts
1574
- var schemaValidator = (() => {
1979
+ var schemaValidators = (() => {
1575
1980
  const ajv = new Ajv2020({ allErrors: true, strict: true });
1576
1981
  addFormats(ajv);
1577
- return ajv.compile(designos_kit_schema_default);
1982
+ return {
1983
+ "1": ajv.compile(designos_kit_schema_default),
1984
+ "2": ajv.compile(designos_kit_schema_v2_default),
1985
+ design: ajv.compile(designos_design_schema_default)
1986
+ };
1578
1987
  })();
1579
- var CURRENT_KIT_CONTRACT_VERSION = "1.0.0";
1580
1988
  var CURRENT_TOOL_VERSIONS = {
1581
- kit: CURRENT_KIT_CONTRACT_VERSION,
1582
1989
  core: package_default.version,
1583
1990
  compiler: package_default2.version
1584
1991
  };
@@ -1772,7 +2179,7 @@ function validateCompatibility(manifest, diagnostics) {
1772
2179
  );
1773
2180
  continue;
1774
2181
  }
1775
- const currentVersion = CURRENT_TOOL_VERSIONS[name];
2182
+ const currentVersion = name === "kit" ? manifest.schemaVersion === "2" ? "2.0.0" : "1.0.0" : CURRENT_TOOL_VERSIONS[name];
1776
2183
  if (!currentVersion && name === "editor") {
1777
2184
  diagnostics.push({
1778
2185
  severity: "info",
@@ -1973,6 +2380,148 @@ async function validateEditorAdapters(rootRealPath, manifest, components, diagno
1973
2380
  }
1974
2381
  }
1975
2382
  }
2383
+ function isValidDesignValue(token, value) {
2384
+ switch (token.type) {
2385
+ case "color":
2386
+ return typeof value === "string" && /^#(?:[A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(
2387
+ value
2388
+ );
2389
+ case "font-family":
2390
+ case "select":
2391
+ return typeof value === "string" && (token.options ?? []).some((option) => option.value === value);
2392
+ case "number":
2393
+ return typeof value === "number" && Number.isFinite(value) && token.min !== void 0 && token.max !== void 0 && token.step !== void 0 && token.step > 0 && value >= token.min && value <= token.max && Math.abs(
2394
+ (value - token.min) / token.step - Math.round((value - token.min) / token.step)
2395
+ ) < 1e-9;
2396
+ }
2397
+ }
2398
+ function validateDesignSemantics(design, diagnostics) {
2399
+ const tokensById = /* @__PURE__ */ new Map();
2400
+ const tokenIds = /* @__PURE__ */ new Set();
2401
+ const cssVariables = /* @__PURE__ */ new Set();
2402
+ for (const [index, token] of design.tokens.entries()) {
2403
+ const path = `design.tokens[${index}]`;
2404
+ if (tokenIds.has(token.id)) {
2405
+ addError(
2406
+ diagnostics,
2407
+ "KIT_DESIGN_TOKEN_ID_DUPLICATE",
2408
+ `Duplicate design token ID ${JSON.stringify(token.id)}.`,
2409
+ `${path}.id`
2410
+ );
2411
+ } else {
2412
+ tokenIds.add(token.id);
2413
+ tokensById.set(token.id, token);
2414
+ }
2415
+ if (cssVariables.has(token.cssVariable)) {
2416
+ addError(
2417
+ diagnostics,
2418
+ "KIT_DESIGN_CSS_VARIABLE_DUPLICATE",
2419
+ `CSS variable ${JSON.stringify(token.cssVariable)} is assigned to more than one design token.`,
2420
+ `${path}.cssVariable`
2421
+ );
2422
+ }
2423
+ cssVariables.add(token.cssVariable);
2424
+ if (token.type === "number" && token.min > token.max) {
2425
+ addError(
2426
+ diagnostics,
2427
+ "KIT_DESIGN_NUMBER_RANGE_INVALID",
2428
+ "Numeric token minimum must not exceed its maximum.",
2429
+ `${path}.min`
2430
+ );
2431
+ }
2432
+ const optionValues = /* @__PURE__ */ new Set();
2433
+ for (const [optionIndex, option] of (token.options ?? []).entries()) {
2434
+ if (optionValues.has(option.value)) {
2435
+ addError(
2436
+ diagnostics,
2437
+ "KIT_DESIGN_OPTION_VALUE_DUPLICATE",
2438
+ `Duplicate option value ${JSON.stringify(option.value)} for token ${JSON.stringify(token.id)}.`,
2439
+ `${path}.options[${optionIndex}].value`
2440
+ );
2441
+ }
2442
+ optionValues.add(option.value);
2443
+ }
2444
+ if (!isValidDesignValue(token, token.default)) {
2445
+ addError(
2446
+ diagnostics,
2447
+ "KIT_DESIGN_DEFAULT_INVALID",
2448
+ `Default value is not valid for ${token.type} token ${JSON.stringify(token.id)}.`,
2449
+ `${path}.default`
2450
+ );
2451
+ }
2452
+ }
2453
+ const presetIds = /* @__PURE__ */ new Set();
2454
+ for (const [index, preset] of design.presets.entries()) {
2455
+ const path = `design.presets[${index}]`;
2456
+ if (presetIds.has(preset.id)) {
2457
+ addError(
2458
+ diagnostics,
2459
+ "KIT_DESIGN_PRESET_ID_DUPLICATE",
2460
+ `Duplicate design preset ID ${JSON.stringify(preset.id)}.`,
2461
+ `${path}.id`
2462
+ );
2463
+ }
2464
+ presetIds.add(preset.id);
2465
+ for (const token of tokensById.values()) {
2466
+ if (!Object.hasOwn(preset.values, token.id)) {
2467
+ addError(
2468
+ diagnostics,
2469
+ "KIT_DESIGN_PRESET_VALUE_MISSING",
2470
+ `Preset ${JSON.stringify(preset.id)} must define a value for token ${JSON.stringify(token.id)}.`,
2471
+ `${path}.values.${token.id}`
2472
+ );
2473
+ } else if (!isValidDesignValue(token, preset.values[token.id])) {
2474
+ addError(
2475
+ diagnostics,
2476
+ "KIT_DESIGN_PRESET_VALUE_INVALID",
2477
+ `Preset value is not valid for ${token.type} token ${JSON.stringify(token.id)}.`,
2478
+ `${path}.values.${token.id}`
2479
+ );
2480
+ }
2481
+ }
2482
+ for (const tokenId of Object.keys(preset.values)) {
2483
+ if (!tokensById.has(tokenId)) {
2484
+ addError(
2485
+ diagnostics,
2486
+ "KIT_DESIGN_PRESET_VALUE_UNKNOWN",
2487
+ `Preset ${JSON.stringify(preset.id)} references unknown token ${JSON.stringify(tokenId)}.`,
2488
+ `${path}.values.${tokenId}`
2489
+ );
2490
+ }
2491
+ }
2492
+ }
2493
+ }
2494
+ async function validateDesignManifest(rootRealPath, manifest, diagnostics) {
2495
+ if (manifest.schemaVersion !== "2" || !manifest.design) return;
2496
+ const designPath = await resolveRootFile(
2497
+ rootRealPath,
2498
+ manifest.design.manifest,
2499
+ "design.manifest",
2500
+ diagnostics
2501
+ );
2502
+ if (!designPath) return;
2503
+ const designValue = await readJsonFile(
2504
+ designPath,
2505
+ manifest.design.manifest,
2506
+ diagnostics
2507
+ );
2508
+ if (designValue === void 0) return;
2509
+ if (!schemaValidators.design(designValue)) {
2510
+ for (const error of schemaValidators.design.errors ?? []) {
2511
+ diagnostics.push({
2512
+ severity: "error",
2513
+ code: "KIT_DESIGN_MANIFEST_SCHEMA_INVALID",
2514
+ path: `design.manifest${error.instancePath || ""}`,
2515
+ message: `${error.message ?? "Schema constraint failed"}${error.params ? ` (${JSON.stringify(error.params)})` : ""}`
2516
+ });
2517
+ }
2518
+ return;
2519
+ }
2520
+ validateDesignSemantics(
2521
+ designValue,
2522
+ diagnostics
2523
+ );
2524
+ }
1976
2525
  async function validateComponentKit(kitRoot) {
1977
2526
  const diagnostics = [];
1978
2527
  let rootRealPath;
@@ -2003,6 +2552,17 @@ async function validateComponentKit(kitRoot) {
2003
2552
  diagnostics
2004
2553
  );
2005
2554
  if (rawManifest === void 0) return { valid: false, diagnostics };
2555
+ const rawSchemaVersion = isRecord(rawManifest) ? rawManifest.schemaVersion : void 0;
2556
+ if (typeof rawSchemaVersion === "string" && rawSchemaVersion !== "1" && rawSchemaVersion !== "2") {
2557
+ addError(
2558
+ diagnostics,
2559
+ "KIT_SCHEMA_VERSION_UNSUPPORTED",
2560
+ `Unsupported kit schemaVersion ${JSON.stringify(rawSchemaVersion)}; supported versions are "1" and "2".`,
2561
+ "schemaVersion"
2562
+ );
2563
+ return { valid: false, diagnostics };
2564
+ }
2565
+ const schemaValidator = rawSchemaVersion === "2" ? schemaValidators["2"] : schemaValidators["1"];
2006
2566
  if (!schemaValidator(rawManifest)) {
2007
2567
  for (const error of schemaValidator.errors ?? []) {
2008
2568
  diagnostics.push({
@@ -2016,6 +2576,7 @@ async function validateComponentKit(kitRoot) {
2016
2576
  }
2017
2577
  const manifest = rawManifest;
2018
2578
  validateCompatibility(manifest, diagnostics);
2579
+ await validateDesignManifest(rootRealPath, manifest, diagnostics);
2019
2580
  const packageCandidate = resolve(rootRealPath, "package.json");
2020
2581
  const packagePath = await resolveExistingFile(
2021
2582
  rootRealPath,