@astryxdesign/cli 0.7.2-canary.6d4f178 → 0.7.2-canary.7462c41

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.
Files changed (118) hide show
  1. package/README.md +9 -8
  2. package/api/build/help/help.mjs +1 -1
  3. package/api/docs/_adapter.d.mts +11 -0
  4. package/api/docs/_adapter.mjs +244 -1
  5. package/api/docs/integrationDocs.test.mjs +124 -0
  6. package/api/doctor/theme-checks.mjs +1 -1
  7. package/api/index.d.mts +2 -0
  8. package/api/index.mjs +2 -0
  9. package/api/init/run/run.mjs +2 -2
  10. package/api/integration/_adapter.d.mts +12 -0
  11. package/api/integration/_adapter.mjs +54 -0
  12. package/api/integration/add-contribution.mjs +1 -1
  13. package/api/integration/add-contribution.test.mjs +4 -2
  14. package/api/integration/authoring-checks.mjs +11 -2
  15. package/api/integration/authoring-checks.test.mjs +39 -0
  16. package/api/integration/authoring-checks.type.d.mts +9 -0
  17. package/api/integration/authoring-checks.type.mjs +14 -1
  18. package/api/integration/check/check.d.mts +96 -0
  19. package/api/integration/check/check.mjs +357 -0
  20. package/api/integration/check/check.test.mjs +489 -0
  21. package/api/integration/integration-check.type.d.mts +118 -0
  22. package/api/integration/integration-check.type.mjs +84 -0
  23. package/api/integration/integrationCheck.doc.d.mts +10 -0
  24. package/api/integration/integrationCheck.doc.mjs +73 -0
  25. package/api/integration/integrationComponentConflicts.doc.mjs +36 -5
  26. package/api/integration/validate-integration.mjs +8 -0
  27. package/api/integration/validate-integration.test.mjs +11 -0
  28. package/api/integration/validate-integration.type.d.mts +8 -0
  29. package/api/integration/validate-integration.type.mjs +12 -1
  30. package/api/integration/validateIntegration.doc.mjs +17 -3
  31. package/api/search/search.d.mts +13 -6
  32. package/api/search/search.domain-priority.test.mjs +93 -18
  33. package/api/search/search.integration-check.test.mjs +24 -0
  34. package/api/search/search.mjs +33 -9
  35. package/api/theme/build/build.family.test.mjs +54 -6
  36. package/api/theme/build/build.mjs +114 -17
  37. package/api/theme/themeBuild.doc.mjs +4 -4
  38. package/assets/docs/README.md +10 -0
  39. package/assets/docs/author-a-theme.doc.mjs +1 -1
  40. package/assets/docs/getting-started.doc.mjs +3 -3
  41. package/assets/docs/theme.doc.dense.mjs +1 -1
  42. package/assets/docs/theme.doc.mjs +1 -1
  43. package/assets/docs/theme.doc.zh.mjs +1 -1
  44. package/assets/docs/tree/block-template.doc.mjs +2 -2
  45. package/assets/docs/tree/check-the-props.doc.mjs +196 -0
  46. package/assets/docs/tree/check-your-docs.doc.mjs +44 -3
  47. package/assets/docs/tree/checks.doc.mjs +21 -13
  48. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  49. package/assets/docs/tree/integrations.doc.mjs +4 -0
  50. package/assets/docs/tree/links.doc.mjs +2 -2
  51. package/assets/docs/tree/page-template.doc.mjs +1 -1
  52. package/assets/docs/tree/quick-start.doc.mjs +33 -5
  53. package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
  54. package/assets/docs/tree/single-component.doc.mjs +2 -1
  55. package/assets/docs/tree/type-scale.doc.mjs +3 -3
  56. package/assets/docs/tree/write-the-template-file.doc.mjs +2 -1
  57. package/assets/docs/use-a-theme.doc.mjs +2 -2
  58. package/assets/theme.template.ts +1 -1
  59. package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
  60. package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
  61. package/authoring/doctypes/template/parse.d.mts +6 -2
  62. package/authoring/doctypes/template/parse.mjs +3 -1
  63. package/authoring/doctypes/template/template.doc.mjs +1 -1
  64. package/authoring/doctypes/template/type.ts +22 -0
  65. package/authoring/index.d.ts +1 -0
  66. package/authoring/integration/integration.doc.mjs +8 -1
  67. package/authoring/integration/parse.test.mjs +10 -0
  68. package/authoring/integration/schema.d.mts +2 -0
  69. package/authoring/integration/schema.mjs +1 -0
  70. package/authoring/integration/type.ts +4 -0
  71. package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
  72. package/clients/cli/commands/build-theme.mjs +1 -1
  73. package/clients/cli/commands/build-theme.path-safety.test.mjs +155 -21
  74. package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
  75. package/clients/cli/commands/doctor-integration-validate.doc.mjs +11 -2
  76. package/clients/cli/commands/doctor-integration.test.mjs +837 -0
  77. package/clients/cli/commands/doctor.mjs +190 -0
  78. package/clients/cli/commands/integration-check.doc.mjs +85 -0
  79. package/clients/cli/commands/integration-check.test.mjs +267 -0
  80. package/clients/cli/commands/integration.doc.mjs +6 -2
  81. package/clients/cli/commands/integration.mjs +107 -1
  82. package/clients/cli/commands/text-json-parity.test.mjs +5 -0
  83. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  84. package/clients/cli/index.mjs +1 -0
  85. package/foundation/config/project.mjs +82 -0
  86. package/foundation/discovery/authoring-self-docs.mjs +1 -0
  87. package/foundation/discovery/component-discovery.d.mts +18 -0
  88. package/foundation/discovery/component-discovery.mjs +2 -2
  89. package/foundation/discovery/doc-types.d.mts +157 -0
  90. package/foundation/discovery/doc-types.mjs +1224 -0
  91. package/foundation/discovery/doc-types.test.mjs +652 -0
  92. package/foundation/discovery/docs-discovery.d.mts +81 -0
  93. package/foundation/discovery/docs-discovery.mjs +57 -0
  94. package/foundation/discovery/integration-doc-files.d.mts +22 -0
  95. package/foundation/discovery/integration-doc-files.mjs +231 -0
  96. package/foundation/discovery/integration-doc-files.test.mjs +246 -0
  97. package/foundation/discovery/package-tsconfig.d.mts +14 -0
  98. package/foundation/discovery/package-tsconfig.mjs +228 -0
  99. package/foundation/discovery/package-tsconfig.test.mjs +210 -0
  100. package/foundation/discovery/project-typescript.d.mts +23 -0
  101. package/foundation/discovery/project-typescript.mjs +61 -0
  102. package/foundation/discovery/prop-drift.d.mts +278 -0
  103. package/foundation/discovery/prop-drift.mjs +2263 -0
  104. package/foundation/discovery/prop-drift.test.mjs +2219 -0
  105. package/foundation/discovery/type-match.d.mts +53 -0
  106. package/foundation/discovery/type-match.mjs +660 -0
  107. package/foundation/discovery/type-match.test.mjs +169 -0
  108. package/foundation/discovery/type-text.d.mts +68 -0
  109. package/foundation/discovery/type-text.mjs +658 -0
  110. package/foundation/discovery/type-text.test.mjs +196 -0
  111. package/foundation/discovery/unresolved-references.d.mts +62 -0
  112. package/foundation/discovery/unresolved-references.mjs +790 -0
  113. package/foundation/discovery/unresolved-references.test.mjs +567 -0
  114. package/foundation/doc-compiler/doc-loads.test.mjs +6 -0
  115. package/foundation/doc-compiler/links.d.mts +9 -5
  116. package/foundation/doc-compiler/links.mjs +4 -2
  117. package/foundation/response/response-types.doc.mjs +7 -2
  118. package/package.json +9 -9
@@ -27,8 +27,10 @@
27
27
  * files; an internal callback lets the CLI make only the process status fail.
28
28
  * Human progress is emitted through the shared `logger` (silent by default), so
29
29
  * the CLI keeps its exact output while a programmatic caller stays quiet.
30
- * Every output, explicit or beside the theme file, stays inside `cwd`
31
- * (`ERR_PATH_TRAVERSAL` otherwise), in check mode too.
30
+ * Every output a build writes, explicit or beside the theme file, stays inside
31
+ * `cwd` (`ERR_PATH_TRAVERSAL` otherwise). Check mode writes nothing, so it
32
+ * compares outputs outside `cwd` read-only; only a relative `out` path that
33
+ * escapes `cwd` is refused there too.
32
34
  *
33
35
  * The installed `@astryxdesign/core` is an independently versioned optional
34
36
  * peer, so it can be older than the CLI. A theme that uses only baseline
@@ -60,7 +62,10 @@ import {isBuiltin} from 'node:module';
60
62
  import {fileURLToPath, pathToFileURL} from 'node:url';
61
63
  import {parse} from '@babel/parser';
62
64
  import {createJiti} from 'jiti';
63
- import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
65
+ import {
66
+ formatCliCommand,
67
+ getCliInvocation,
68
+ } from '../../../foundation/env/package-manager.mjs';
64
69
  import {
65
70
  CLI_ROOT,
66
71
  findCoreDir,
@@ -568,6 +573,86 @@ function confineOutputs(writes, root, remedy) {
568
573
  for (const write of writes) confineOutput(write.dest, root, remedy);
569
574
  }
570
575
 
576
+ /** @param {string} dest absolute output path @param {string} root @returns {boolean} whether a build at `root` refuses to write `dest` */
577
+ function refusedOutput(dest, root) {
578
+ try {
579
+ confineOutput(dest, root, '');
580
+ return false;
581
+ } catch (err) {
582
+ if (
583
+ err instanceof AstryxError &&
584
+ err.code === ERROR_CODES.ERR_PATH_TRAVERSAL
585
+ )
586
+ return true;
587
+ throw err;
588
+ }
589
+ }
590
+
591
+ /** @param {string[]} dirs absolute directories @returns {string | null} the deepest directory containing all of them, or null across roots */
592
+ function commonDirectory(dirs) {
593
+ let common = dirs[0];
594
+ for (const dir of dirs.slice(1)) {
595
+ while (
596
+ path.relative(common, dir).startsWith('..') ||
597
+ path.isAbsolute(path.relative(common, dir))
598
+ ) {
599
+ const parent = path.dirname(common);
600
+ if (parent === common) return null;
601
+ common = parent;
602
+ }
603
+ }
604
+ return common;
605
+ }
606
+
607
+ /** @param {string} value @returns {string} `value` as one shell word */
608
+ function shellWord(value) {
609
+ if (/^[A-Za-z0-9@%+=:,./_-]+$/.test(value)) return value;
610
+ return `'${value.replace(/'/g, `'\\''`)}'`;
611
+ }
612
+
613
+ /**
614
+ * How a stale check report ends when outputs sit outside the write root. A
615
+ * build there refuses them, and each output's `Source:` header records the
616
+ * directory its build ran from, so the build and the check both run from the
617
+ * nearest directory that contains every theme file and output.
618
+ * @param {Array<{dest: string}>} writes
619
+ * @param {string[]} sources absolute theme files the build reads
620
+ * @param {string} root the directory a build here keeps its writes inside
621
+ * @param {(relative: (file: string) => string) => string[]} args the arguments after `theme build`, given each path relative to the directory to run from
622
+ * @returns {string[] | null} report lines, or null when every output is inside `root`
623
+ */
624
+ function outsideCheckRemedy(writes, sources, root, args) {
625
+ if (!writes.some(write => refusedOutput(write.dest, root))) return null;
626
+ const real = (/** @type {string} */ file) => realLocation(path.resolve(file));
627
+ const dir = commonDirectory([
628
+ ...sources.map(file => path.dirname(real(file))),
629
+ ...writes.map(write => path.dirname(real(write.dest))),
630
+ ]);
631
+ if (!dir) {
632
+ return [
633
+ 'These outputs are outside the working directory, so a build here refuses them. Build and check them from one directory that contains the theme files and the outputs.',
634
+ ];
635
+ }
636
+ const command = (/** @type {string[]} */ extra) =>
637
+ formatCliCommand(
638
+ [
639
+ 'theme',
640
+ 'build',
641
+ ...args(file => path.relative(dir, real(file))),
642
+ ...extra,
643
+ ]
644
+ .map(shellWord)
645
+ .join(' '),
646
+ dir,
647
+ );
648
+ return [
649
+ 'These outputs are outside the working directory, so a build here refuses them, and each output records the directory it was built from. Build and check them from a directory that contains them:',
650
+ ` cd ${shellWord(dir)}`,
651
+ ` ${command([])}`,
652
+ ` ${command(['--check'])}`,
653
+ ];
654
+ }
655
+
571
656
  /** @param {Array<{dest: string, content: string}>} writes */
572
657
  function writeBuildOutputs(writes) {
573
658
  if (writes.length === 0) return;
@@ -2859,9 +2944,13 @@ async function themeBuildInternal(
2859
2944
  const writeRoot = options.__writeRoot ?? cwd;
2860
2945
  let outPath;
2861
2946
  if (options.out) {
2862
- // Relative or absolute, the explicit output stays inside the write root.
2863
2947
  outPath = path.resolve(cwd, options.out);
2864
- confineOutput(outPath, writeRoot, OUT_REMEDY, options.out);
2948
+ // A build keeps the explicit output inside the write root, relative or
2949
+ // absolute. Check mode writes nothing, so it refuses only a relative path
2950
+ // that escapes cwd.
2951
+ if (!options.check || !path.isAbsolute(options.out)) {
2952
+ confineOutput(outPath, writeRoot, OUT_REMEDY, options.out);
2953
+ }
2865
2954
  } else {
2866
2955
  outPath = path.join(path.dirname(filePath), `${baseName}.css`);
2867
2956
  }
@@ -2957,10 +3046,12 @@ async function themeBuildInternal(
2957
3046
  writes.push({dest: variantDtsPath, content: variantContent});
2958
3047
  }
2959
3048
 
2960
- // Every output stays inside cwd, including the defaults beside the theme
2961
- // file. Check mode refuses the same paths, so it never passes outputs that a
2962
- // build would refuse to write.
2963
- confineOutputs(writes, writeRoot, options.out ? OUT_REMEDY : SOURCE_REMEDY);
3049
+ // Every output a build writes stays inside cwd, including the defaults
3050
+ // beside the theme file. Check mode writes nothing, so it compares outputs
3051
+ // outside cwd read-only.
3052
+ if (!options.check) {
3053
+ confineOutputs(writes, writeRoot, options.out ? OUT_REMEDY : SOURCE_REMEDY);
3054
+ }
2964
3055
 
2965
3056
  // Check mode: compare generated content against what's on disk instead of
2966
3057
  // writing. A file is "stale" if it's missing or its content differs once the
@@ -2980,7 +3071,10 @@ async function themeBuildInternal(
2980
3071
  ` ${s.reason === 'missing' ? 'missing' : 'stale'}: ${s.path}`,
2981
3072
  );
2982
3073
  }
2983
- logger.error(`\n Rebuild with: ${buildCommand}`);
3074
+ // prettier-ignore
3075
+ const remedy = outsideCheckRemedy(writes, [filePath], writeRoot, relative => [relative(filePath), ...(options.out ? ['--out', relative(outPath)] : []), ...(options.iconsSpecifier ? ['--icons-specifier', options.iconsSpecifier] : [])]);
3076
+ if (remedy) logger.error(`\n ${remedy.join('\n ')}`);
3077
+ else logger.error(`\n Rebuild with: ${buildCommand}`);
2984
3078
  }
2985
3079
  return {
2986
3080
  type: 'theme.build.check',
@@ -3093,7 +3187,7 @@ function printBuildTrailer(trailer) {
3093
3187
  logger.log(`
3094
3188
  Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
3095
3189
 
3096
- import { Theme } from '@astryxdesign/core';
3190
+ import { Theme } from '@astryxdesign/core/theme';
3097
3191
  import { ${trailer.exportName} } from '${trailer.jsImport}';
3098
3192
  import '${trailer.cssImport}';
3099
3193
 
@@ -3103,7 +3197,7 @@ Install in your app (paths are relative to a file in src/; adjust if yours lives
3103
3197
 
3104
3198
  Or with a <link> tag:
3105
3199
 
3106
- import { Theme } from '@astryxdesign/core';
3200
+ import { Theme } from '@astryxdesign/core/theme';
3107
3201
  import { ${trailer.exportName} } from '${trailer.jsImport}';
3108
3202
 
3109
3203
  <link rel="stylesheet" href="${trailer.cssImport}" />
@@ -3129,7 +3223,7 @@ export function printBatchTrailer(trailers) {
3129
3223
  logger.log(`
3130
3224
  Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
3131
3225
 
3132
- import { Theme } from '@astryxdesign/core';
3226
+ import { Theme } from '@astryxdesign/core/theme';
3133
3227
  import { ${first.exportName} } from '${first.jsImport}';
3134
3228
  import '${first.cssImport}';
3135
3229
 
@@ -3139,7 +3233,7 @@ Install in your app (paths are relative to a file in src/; adjust if yours lives
3139
3233
 
3140
3234
  Or with a <link> tag:
3141
3235
 
3142
- import { Theme } from '@astryxdesign/core';
3236
+ import { Theme } from '@astryxdesign/core/theme';
3143
3237
  import { ${first.exportName} } from '${first.jsImport}';
3144
3238
 
3145
3239
  <link rel="stylesheet" href="${first.cssImport}" />
@@ -3506,8 +3600,8 @@ export async function themeBuildFamily(
3506
3600
  js: path.relative(cwd, jsPath),
3507
3601
  dts: path.relative(cwd, dtsPath),
3508
3602
  };
3509
- // The family's outputs stay inside cwd too, in check mode as well.
3510
- confineOutputs(writes, cwd, FAMILY_REMEDY);
3603
+ // A family build's outputs stay inside cwd too; check mode only reads them.
3604
+ if (!options.check) confineOutputs(writes, cwd, FAMILY_REMEDY);
3511
3605
  if (options.check) {
3512
3606
  const stale = staleBuildOutputs(writes, cwd);
3513
3607
  const upToDate = stale.length === 0;
@@ -3524,7 +3618,10 @@ export async function themeBuildFamily(
3524
3618
  ` ${entry.reason === 'missing' ? 'missing' : 'stale'}: ${entry.path}`,
3525
3619
  );
3526
3620
  }
3527
- logger.error(`\n Rebuild with: ${buildCommand}`);
3621
+ // prettier-ignore
3622
+ const remedy = outsideCheckRemedy(writes, members.map(member => member.filePath), cwd, relative => ['--family', ...members.map(member => relative(member.filePath)), '--family-key', baseName, ...(options.iconsSpecifier ? ['--icons-specifier', options.iconsSpecifier] : [])]);
3623
+ if (remedy) logger.error(`\n ${remedy.join('\n ')}`);
3624
+ else logger.error(`\n Rebuild with: ${buildCommand}`);
3528
3625
  }
3529
3626
  return {
3530
3627
  type: 'theme.build.check',
@@ -58,13 +58,13 @@ export const doc = {
58
58
  name: 'options.out',
59
59
  type: 'string',
60
60
  description:
61
- 'Override the output CSS path, relative or absolute; it must resolve inside cwd. The .js, .d.ts and any .variants.d.ts are written in the same directory, named after the theme (<name>.js), not after the CSS file.',
61
+ 'Override the output CSS path, relative or absolute; a build refuses a path outside cwd, and check mode refuses only a relative path that escapes cwd. The .js, .d.ts and any .variants.d.ts are written in the same directory, named after the theme (<name>.js), not after the CSS file.',
62
62
  },
63
63
  {
64
64
  name: 'options.check',
65
65
  type: 'boolean',
66
66
  description:
67
- 'Compile in memory and compare each output against what is on disk instead of writing: the CI drift guard.',
67
+ 'Compile in memory and compare each output against what is on disk instead of writing: the CI drift guard. Because it writes nothing, it also compares outputs outside cwd; when those are stale, the report names the directory that contains them and the build and check commands to run from there, since a build refuses them and each output records the directory it was built from.',
68
68
  default: 'false',
69
69
  },
70
70
  {
@@ -77,7 +77,7 @@ export const doc = {
77
77
  name: 'ctx.cwd',
78
78
  type: 'string',
79
79
  description:
80
- 'Directory the theme file, a relative out path, and the returned output paths resolve against. Every output is written inside it, including the default outputs beside the theme file.',
80
+ 'Directory the theme file, a relative out path, and the returned output paths resolve against. Every output a build writes is inside it, including the default outputs beside the theme file.',
81
81
  default: 'process.cwd()',
82
82
  },
83
83
  ],
@@ -105,7 +105,7 @@ export const doc = {
105
105
  },
106
106
  {
107
107
  code: 'ERR_PATH_TRAVERSAL',
108
- when: 'the theme name contains a path separator or traversal marker, or an output resolves outside cwd (including through a symlink): an `out` path, relative or absolute, or the default outputs beside a theme file outside cwd (also rejected in check mode)',
108
+ when: 'the theme name contains a path separator or traversal marker, or a written output resolves outside cwd (including through a symlink): an `out` path, relative or absolute, or the default outputs beside a theme file outside cwd. Check mode writes nothing, so it refuses only a relative `out` path that escapes cwd',
109
109
  },
110
110
  {
111
111
  code: 'ERR_CORE_NOT_FOUND',
@@ -51,6 +51,16 @@ The material is usually good; the finding is placement, not quality. It goes in
51
51
 
52
52
  Worked example: a responsive-and-interaction readiness rubric is grading criteria → **Component-Audit-Rubric**, or **Component-Lifecycle** if it is a promotion gate.
53
53
 
54
+ ## Imports in code samples
55
+
56
+ Import each Core export from the path `astryx component <Name>` prints: the
57
+ component's own entry when Core has one (`@astryxdesign/core/VStack`,
58
+ `@astryxdesign/core/Heading`), and `@astryxdesign/core/theme` for `Theme`,
59
+ `defineTheme` and the rest of the theme API. A reader copies one sample and then
60
+ reads `astryx component`, and two paths for one export read as two different
61
+ things. The no-build CDN page is the exception: its import map names only the
62
+ package root.
63
+
54
64
  ## Sections are read one at a time
55
65
 
56
66
  `astryx docs <topic> --index` lists a topic's sections, and readers then open
@@ -120,7 +120,7 @@ export const docs = {
120
120
  ['ocean.variants.d.ts', "(Optional) Module augmentations for custom component prop values"],
121
121
  ]},
122
122
  {type: 'prose', text: 'The `__built: true` flag tells Theme to skip runtime `<style>` injection; the CSS file handles it. Load the generated CSS wherever you load the module.'},
123
- {type: 'code', lang: 'tsx', label: 'Using a custom built theme', code: "import {Theme} from '@astryxdesign/core';\nimport {oceanTheme} from './themes/ocean';\nimport './themes/ocean.css';\n\n<Theme theme={oceanTheme}>\n <App />\n</Theme>"},
123
+ {type: 'code', lang: 'tsx', label: 'Using a custom built theme', code: "import {Theme} from '@astryxdesign/core/theme';\nimport {oceanTheme} from './themes/ocean';\nimport './themes/ocean.css';\n\n<Theme theme={oceanTheme}>\n <App />\n</Theme>"},
124
124
  {type: 'prose', text: "After upgrading Astryx, rerun `astryx theme build` for every custom prebuilt theme. Deploy the regenerated files together. The runtime intentionally trusts `__built: true` and will not repair stale CSS from an older build. The build also warns when the theme names font families it does not load. See {@link generic:font-setup} for the full recipe."},
125
125
  {type: 'prose', text: 'For the runtime vs built tradeoff, see the Runtime vs Built section of {@link generic:use-a-theme}.'},
126
126
  ],
@@ -86,7 +86,7 @@ export const docs = {
86
86
  type: 'code',
87
87
  lang: 'tsx',
88
88
  label: 'App root',
89
- code: `import {Theme} from '@astryxdesign/core';
89
+ code: `import {Theme} from '@astryxdesign/core/theme';
90
90
  import {themes, defaultThemeSlug} from './astryx-themes';
91
91
 
92
92
  <Theme theme={themes[defaultThemeSlug]}><App /></Theme>`,
@@ -119,14 +119,14 @@ import {themes, defaultThemeSlug} from './astryx-themes';
119
119
  content: [
120
120
  {
121
121
  type: 'prose',
122
- text: 'Components are imported from per-category subpath entrypoints. This keeps bundles small and makes intent clear.',
122
+ text: 'Import each component from its own entry, the path `astryx component <Name>` prints. This keeps bundles small and makes intent clear.',
123
123
  },
124
124
  {
125
125
  type: 'code',
126
126
  lang: 'tsx',
127
127
  label: 'app/page.tsx',
128
128
  code: `import {Button} from '@astryxdesign/core/Button';
129
- import {VStack} from '@astryxdesign/core/Layout';
129
+ import {VStack} from '@astryxdesign/core/VStack';
130
130
 
131
131
  export default function Page() {
132
132
  return (
@@ -9,7 +9,7 @@ export const docsDense = {
9
9
  section: 'Wrap your app in a theme',
10
10
  title: 'Quick start',
11
11
  content: [
12
- {type: 'prose', text: "Install a theme, wrap in `<Theme>` (`import {Theme} from '@astryxdesign/core'`). {@link generic:use-a-theme} for full guide."},
12
+ {type: 'prose', text: "Install a theme, wrap in `<Theme>` (`import {Theme} from '@astryxdesign/core/theme'`). {@link generic:use-a-theme} for full guide."},
13
13
  ],
14
14
  },
15
15
  {
@@ -23,7 +23,7 @@ export const docs = {
23
23
  type: 'code',
24
24
  lang: 'tsx',
25
25
  label: 'Wire the generated module once',
26
- code: "import {Theme} from '@astryxdesign/core';\nimport {themes, defaultThemeSlug} from './astryx-themes';\n\nfunction App() {\n return (\n <Theme theme={themes[defaultThemeSlug]}>\n <YourApp />\n </Theme>\n );\n}",
26
+ code: "import {Theme} from '@astryxdesign/core/theme';\nimport {themes, defaultThemeSlug} from './astryx-themes';\n\nfunction App() {\n return (\n <Theme theme={themes[defaultThemeSlug]}>\n <YourApp />\n </Theme>\n );\n}",
27
27
  },
28
28
  ],
29
29
  },
@@ -11,7 +11,7 @@ export const docsZh = {
11
11
  content: [
12
12
  {
13
13
  type: 'prose',
14
- text: "安装主题包,用 `<Theme>`(`import {Theme} from '@astryxdesign/core'`)包裹应用,选择浅色或深色模式。完整指南——可用主题、集成主题、深色模式、嵌套主题和生产构建——请参阅 {@link generic:use-a-theme}。",
14
+ text: "安装主题包,用 `<Theme>`(`import {Theme} from '@astryxdesign/core/theme'`)包裹应用,选择浅色或深色模式。完整指南——可用主题、集成主题、深色模式、嵌套主题和生产构建——请参阅 {@link generic:use-a-theme}。",
15
15
  },
16
16
  ],
17
17
  },
@@ -31,7 +31,7 @@ export const docs = {
31
31
  type: 'code',
32
32
  lang: 'javascript',
33
33
  label: 'templates/acme-stat-card.doc.mjs',
34
- code: `/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
34
+ code: `/** @type {import('@astryxdesign/cli/authoring').IntegrationTemplateDoc} */
35
35
  export default {
36
36
  type: 'block',
37
37
  name: 'acme-stat-card',
@@ -75,7 +75,7 @@ export default {
75
75
  type: 'code',
76
76
  lang: 'javascript',
77
77
  label: 'templates/acme-status-card-showcase.doc.mjs',
78
- code: `/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
78
+ code: `/** @type {import('@astryxdesign/cli/authoring').IntegrationTemplateDoc} */
79
79
  export default {
80
80
  type: 'block',
81
81
  name: 'acme-status-card-showcase',
@@ -0,0 +1,196 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs cli/integrations/building-blocks/components/describe-the-component/check-the-props`:
5
+ * compare each component doc's props table with the component's TypeScript
6
+ * props, read each finding, and fix the doc or the code.
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
10
+ export const docs = {
11
+ type: 'generic',
12
+ name: 'check-the-props',
13
+ placement: {
14
+ parent: 'namespace:describe-the-component',
15
+ slot: 'guides',
16
+ order: 50,
17
+ },
18
+ title: 'Check the props table',
19
+ category: 'guide',
20
+ keywords: [
21
+ 'props table',
22
+ 'documented props',
23
+ 'prop drift',
24
+ 'props not compared',
25
+ ],
26
+ description:
27
+ "Compare each props table with the component's TypeScript props, then fix the doc or the code.",
28
+ sections: [
29
+ {
30
+ id: 'run-the-props-check',
31
+ title: 'Run the props check',
32
+ content: [
33
+ {
34
+ type: 'prose',
35
+ text: "`doctor integration components` compares every props table in your component docs, hidden docs and every family entry included, with the props the component's TypeScript declares. Run it in your package after you change a component or its doc.",
36
+ },
37
+ {
38
+ type: 'code',
39
+ lang: 'bash',
40
+ code: 'npx astryx doctor integration components',
41
+ },
42
+ {
43
+ type: 'code',
44
+ lang: 'text',
45
+ code: `severity: [warn]
46
+ component: AcmeCarousel
47
+ prop: loop
48
+ kind: not_in_code
49
+ message: "loop" is documented, but AcmeCarousel's props have no "loop".
50
+ doc: components/AcmeCarousel.doc.mjs
51
+ source: components/AcmeCarousel.tsx
52
+ docType: boolean
53
+
54
+ 1 prop(s) differ between the docs and the code in 1 of 1 component(s) compared (TypeScript 6.0.3). These are warnings: update the doc, or the code if the doc is right.`,
55
+ },
56
+ {
57
+ type: 'list',
58
+ style: 'unordered',
59
+ items: [
60
+ "A doc's own `props` describe the export its `name` names. In a family doc, each entry describes its own export. A hook entry documents parameters and returns, so it is not compared.",
61
+ "It reads props with the `typescript` your package installs, and reads your package's `tsconfig.json` the way `tsc -p` does. Without TypeScript it prints `[skip] Props not compared` and the reason.",
62
+ 'Every finding is a warning, so the exit code stays 0. Read them before you publish. With `--json`, they are in `data.propDrift.findings`.',
63
+ ],
64
+ },
65
+ ],
66
+ },
67
+ {
68
+ id: 'fix-each-finding',
69
+ title: 'Fix each finding',
70
+ content: [
71
+ {
72
+ type: 'prose',
73
+ text: "Each finding's `kind` says what differs. Fix the doc, or the code if the doc is right.",
74
+ },
75
+ {
76
+ type: 'table',
77
+ headers: ['Kind', 'Means', 'Fix'],
78
+ rows: [
79
+ [
80
+ '`not_in_code`',
81
+ "The doc lists a prop the component's props do not have",
82
+ 'Remove it from the doc, or add it to the code. A name an index signature takes, such as `data-*`, counts as present',
83
+ ],
84
+ [
85
+ '`not_in_doc`',
86
+ "Your package declares a prop the doc does not list, or builds one with a mapped type, such as `Partial<Record<'sm' | 'md', string>>`",
87
+ 'Document it. Props from React, the DOM, or another package are never asked for, and neither are props whose keys another package defines (`keyof CSSProperties`, behind an alias or not), `className`, `style`, `xstyle`, `data-testid`, `ref`, `key`, or a prop whose JSDoc has `@internal`. A deprecated prop is still a prop: document it until you remove it. A prop a mapped type builds from keys the check cannot trace (a template literal, say) is listed under `[info] Props not checked for a doc entry` instead',
88
+ ],
89
+ [
90
+ '`required_mismatch`',
91
+ '`required` disagrees with the code',
92
+ 'Set `required: true` exactly when every caller must pass the prop. One your `defaultProps` fills counts as optional, as it is to JSX callers, and so does one only some members of a union require, since a caller can leave it out: say in its description which variants need it. An entry that names several props (`value / onChange`) makes the same claim about each: give them separate entries when they differ',
93
+ ],
94
+ [
95
+ '`type_mismatch`',
96
+ "The documented `type` differs from the code's, where both read exactly",
97
+ 'Copy the type from the source, or fix the code. The next section says which types are judged',
98
+ ],
99
+ ],
100
+ },
101
+ ],
102
+ },
103
+ {
104
+ id: 'write-types-the-check-can-judge',
105
+ title: 'Write types the check can judge',
106
+ content: [
107
+ {
108
+ type: 'prose',
109
+ text: 'For a prop your package declares, the check also compares the documented `type`, but only where both sides read exactly. It never guesses, so a type it cannot judge is listed, not reported. It needs TypeScript 4.8 or later: with an older one it prints `[skip] Prop types not judged` and judges none.',
110
+ },
111
+ {
112
+ type: 'code',
113
+ lang: 'text',
114
+ code: `severity: [warn]
115
+ component: AcmeCarousel
116
+ prop: interval
117
+ kind: type_mismatch
118
+ message: "interval" is documented as string, but the code declares number.
119
+ doc: components/AcmeCarousel.doc.mjs
120
+ source: components/AcmeCarousel.tsx
121
+ docType: string
122
+ codeType: number`,
123
+ },
124
+ {
125
+ type: 'list',
126
+ style: 'unordered',
127
+ items: [
128
+ "Write the type as the source writes it, such as `ReactNode[]` or `(index: number) => void`. Parameter names, member order, quotes and whitespace may differ. Text that writes `readonly` must match exactly, parameter names included; only whitespace may differ. `React.X` names React's own `X` where the prop is declared, so it matches a bare `X` only where that name is React's: `React.KeyboardEvent` is not the DOM's `KeyboardEvent`.",
129
+ "Name a type as the file that declares the prop names it, so an import renamed there (`Item as BaseItem`) is written as that file writes it. A field (`cfg.level`) takes its prop's file, even when the field's own type is declared in another file.",
130
+ 'A type written another way is judged only when both sides are built from exact parts: primitives such as `string` and `number`, string, number and boolean literals, string enum members, arrays and unions of these, and type names that stand for them. Union members may come in any order, and a member another covers adds nothing, as TypeScript passes it there: `undefined` beside `void`, or `string[]` beside `(string | number)[]`.',
131
+ 'A mutable array type matches a readonly one, because callers can pass it. A readonly one documented for a mutable array is a mismatch.',
132
+ "When a prop's variants give a field different types, as `{value: string} | {value: number}` does, document every variant's type (`string | number`). The types of only some variants are listed: the prop's variants give this field different types. With more than six variant types, any other type is listed too.",
133
+ "To name an alias and show its values, write `AcmeSize = 'sm' | 'md'` or `AcmeSize ('sm' | 'md')`. Both parts must match.",
134
+ "An optional prop's `undefined` is set aside on both sides. With `exactOptionalPropertyTypes`, the doc shows `undefined` exactly when the code declares it.",
135
+ 'Anything else, such as an object, a tuple, a generic with arguments, `keyof`, an intersection, or a mapped or conditional type written another way, is not compared.',
136
+ ],
137
+ },
138
+ {
139
+ type: 'prose',
140
+ text: "The check prints how many documented types it judged, then lists the rest by reason: not a form the check judges exactly, a field the prop's variants give different types, a standard prop, or a prop declared outside the package. With `--json`, they are in `data.propDrift.typesNotCompared`.",
141
+ },
142
+ {
143
+ type: 'code',
144
+ lang: 'text',
145
+ code: '[info] Documented prop types judged: 2; not compared: 0. A type is judged when the doc writes it the same as the source (exactly, if it contains `readonly`), or when both are primitives, literals, arrays and unions of those, or names for them.',
146
+ },
147
+ ],
148
+ },
149
+ {
150
+ id: 'when-a-component-is-not-compared',
151
+ title: 'When a component is not compared',
152
+ content: [
153
+ {
154
+ type: 'prose',
155
+ text: "When the check cannot read a component's props exactly, it lists the component under `[info] Props not compared`, with the reason, instead of reporting findings that might be wrong.",
156
+ },
157
+ {
158
+ type: 'code',
159
+ lang: 'text',
160
+ code: `[info] Props not compared for 1 documented component(s):
161
+
162
+ component: AcmeCarousel
163
+ doc: components/AcmeCarousel.doc.mjs
164
+ reason: AcmeCarousel depends on \`@acme/motion\` (imported in AcmeCarousel.tsx), which the compiler could not resolve, usually a dependency that is not installed. Install the package's dependencies and run this check again`,
165
+ },
166
+ {
167
+ type: 'table',
168
+ headers: ['Reason', 'Fix'],
169
+ rows: [
170
+ [
171
+ 'It depends on a package or file the compiler could not resolve',
172
+ "Install the package's dependencies, then run the check again",
173
+ ],
174
+ [
175
+ "It depends on a type the compiler can't work out",
176
+ 'Make the types compile with `npx tsc --noEmit`, then run the check again',
177
+ ],
178
+ [
179
+ "The package's TypeScript config has an error",
180
+ 'Fix `tsconfig.json` until `npx tsc -p .` reads it',
181
+ ],
182
+ ['Its props are typed `any`', 'Give the component a props type'],
183
+ [
184
+ 'Some prop names come from a type parameter',
185
+ 'Nothing to fix: a component that renders an element the caller picks takes props known only where it is used',
186
+ ],
187
+ [
188
+ "The file has no export named by the doc's `name`",
189
+ 'Change `name` or the export so they agree',
190
+ ],
191
+ ],
192
+ },
193
+ ],
194
+ },
195
+ ],
196
+ };
@@ -2,8 +2,8 @@
2
2
 
3
3
  /**
4
4
  * @file `astryx docs cli/integrations/docs/check-your-docs`: what each check
5
- * proves about an integration's docs: the docs check, the read size, and the
6
- * CLI peer.
5
+ * proves about an integration's docs: the docs check, each doc's fields, the
6
+ * read size, and the CLI peer.
7
7
  */
8
8
 
9
9
  /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
@@ -13,7 +13,8 @@ export const docs = {
13
13
  placement: {parent: 'namespace:docs', slot: 'guides', order: 60},
14
14
  title: 'Check your docs',
15
15
  category: 'guide',
16
- description: 'Check the docs tree, links, overlaps, read size, and CLI peer.',
16
+ description:
17
+ 'Check the docs tree, links, overlaps, doc fields, read size, and CLI peer.',
17
18
  sections: [
18
19
  {
19
20
  id: 'run-the-docs-check',
@@ -80,6 +81,46 @@ export const docs = {
80
81
  },
81
82
  ],
82
83
  },
84
+ {
85
+ id: 'check-each-doc-against-its-type',
86
+ title: 'Check each doc against its type',
87
+ content: [
88
+ {
89
+ type: 'prose',
90
+ text: "`doctor integration validate` reads every doc your package ships against the type `@astryxdesign/cli/authoring` publishes for its kind, the way `tsc` would: a `hidden` doc and a second doc for one name too. Test fixtures under `__tests__` in the components or docs root, which those readers skip, are counted, not checked. It reports a field the type does not have (`unknown_field`), a missing required field (`missing_field`), and a value outside the field's type (`wrong_type`).",
91
+ },
92
+ {
93
+ type: 'code',
94
+ lang: 'bash',
95
+ code: 'npx astryx doctor integration validate',
96
+ },
97
+ {
98
+ type: 'code',
99
+ lang: 'text',
100
+ code: `Checking 1 doc(s) against the authoring types (TypeScript 6.0.3)
101
+
102
+ severity: [warn]
103
+ doc: components/AcmeCarousel.doc.mjs
104
+ line: 7
105
+ export: default
106
+ type: ComponentDoc
107
+ field: summary
108
+ problem: unknown_field
109
+ message: Object literal may only specify known properties, and 'summary' does not exist in type 'SingleComponentDoc'.
110
+ fix: Remove \`summary\`: SingleComponentDoc has no field \`summary\`.`,
111
+ },
112
+ {
113
+ type: 'list',
114
+ style: 'unordered',
115
+ items: [
116
+ "The folder decides the type: `ComponentDoc` in your components root, `IntegrationTemplateDoc` in your templates root, `ThemeDoc` in your themes root, and in your docs root the type the doc's `type` names. Keep the `@type` comment above each doc's export too, so your editor shows the same problems as you type.",
117
+ 'Every finding is a warning, so the exit code stays 0. With `--json`, they are in `data.docTypes.findings`.',
118
+ 'It uses the `typescript` your package installs. Without it, it prints `[skip] Docs not type-checked` and the reason.',
119
+ 'Every field of every doc type is in `astryx docs authoring`.',
120
+ ],
121
+ },
122
+ ],
123
+ },
83
124
  {
84
125
  id: 'check-read-size',
85
126
  title: 'Check read size',