@astryxdesign/cli 0.7.2-canary.4787e3f → 0.7.2-canary.4a2f608

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 (247) hide show
  1. package/README.md +74 -73
  2. package/api/build/help/help.mjs +1 -1
  3. package/api/discover/_adapter.d.mts +119 -12
  4. package/api/discover/_adapter.mjs +449 -10
  5. package/api/discover/_adapter.test.mjs +599 -17
  6. package/api/discover/_catalog-view.d.mts +16 -5
  7. package/api/discover/_catalog-view.mjs +32 -8
  8. package/api/discover/discover.d.mts +11 -0
  9. package/api/discover/discover.doc.mjs +7 -6
  10. package/api/discover/discover.mjs +107 -19
  11. package/api/discover/discover.type.d.mts +18 -7
  12. package/api/discover/discover.type.mjs +15 -7
  13. package/api/discover/list/list.d.mts +4 -3
  14. package/api/discover/list/list.mjs +17 -10
  15. package/api/docs/_adapter.d.mts +11 -0
  16. package/api/docs/_adapter.mjs +244 -1
  17. package/api/docs/integrationDocs.test.mjs +124 -0
  18. package/api/doctor/doctor.mjs +27 -3
  19. package/api/doctor/doctor.test.mjs +43 -0
  20. package/api/doctor/theme-checks.mjs +1 -1
  21. package/api/doctor/theme-checks.test.mjs +136 -0
  22. package/api/gap-report/gap-report.d.mts +3 -0
  23. package/api/gap-report/gap-report.doc.mjs +11 -3
  24. package/api/gap-report/gap-report.mjs +152 -48
  25. package/api/gap-report/gap-report.test.mjs +233 -0
  26. package/api/gap-report/gap-report.type.d.mts +41 -0
  27. package/api/gap-report/gap-report.type.mjs +18 -0
  28. package/api/index.d.mts +2 -0
  29. package/api/index.mjs +2 -0
  30. package/api/init/run/run.mjs +2 -2
  31. package/api/integration/_adapter.d.mts +32 -0
  32. package/api/integration/_adapter.mjs +80 -0
  33. package/api/integration/add-contribution.mjs +1 -1
  34. package/api/integration/add-contribution.test.mjs +4 -2
  35. package/api/integration/authoring-checks.mjs +44 -4
  36. package/api/integration/authoring-checks.test.mjs +515 -0
  37. package/api/integration/authoring-checks.type.d.mts +95 -0
  38. package/api/integration/authoring-checks.type.mjs +53 -2
  39. package/api/integration/check/check.d.mts +96 -0
  40. package/api/integration/check/check.mjs +357 -0
  41. package/api/integration/check/check.test.mjs +489 -0
  42. package/api/integration/integration-check.type.d.mts +118 -0
  43. package/api/integration/integration-check.type.mjs +84 -0
  44. package/api/integration/integrationCheck.doc.d.mts +10 -0
  45. package/api/integration/integrationCheck.doc.mjs +73 -0
  46. package/api/integration/integrationComponentConflicts.doc.mjs +43 -6
  47. package/api/integration/integrationDocConflicts.doc.mjs +19 -5
  48. package/api/integration/pack-check.mjs +292 -7
  49. package/api/integration/pack-check.test.mjs +341 -0
  50. package/api/integration/validate-integration.mjs +8 -0
  51. package/api/integration/validate-integration.test.mjs +11 -0
  52. package/api/integration/validate-integration.type.d.mts +8 -0
  53. package/api/integration/validate-integration.type.mjs +12 -1
  54. package/api/integration/validateIntegration.doc.mjs +19 -3
  55. package/api/search/search.d.mts +72 -12
  56. package/api/search/search.domain-priority.test.mjs +108 -18
  57. package/api/search/search.integration-check.test.mjs +24 -0
  58. package/api/search/search.mjs +501 -37
  59. package/api/search/search.test.mjs +139 -0
  60. package/api/theme/build/build.family.test.mjs +54 -6
  61. package/api/theme/build/build.mjs +114 -17
  62. package/api/theme/themeBuild.doc.mjs +4 -4
  63. package/api/upgrade/_adapter.d.mts +40 -2
  64. package/api/upgrade/_adapter.mjs +117 -4
  65. package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
  66. package/api/upgrade/run/run.mjs +30 -1
  67. package/api/upgrade/status/status.d.mts +21 -5
  68. package/api/upgrade/status/status.mjs +45 -8
  69. package/api/upgrade/upgrade.doc.mjs +5 -3
  70. package/api/upgrade/upgrade.type.d.mts +23 -0
  71. package/api/upgrade/upgrade.type.mjs +16 -1
  72. package/assets/codemods/runner.mjs +7 -1
  73. package/assets/discover/official-packages.json +367 -0
  74. package/assets/docs/README.md +10 -0
  75. package/assets/docs/author-a-theme.doc.mjs +3 -3
  76. package/assets/docs/browser-support.doc.mjs +1 -1
  77. package/assets/docs/getting-started.doc.mjs +3 -3
  78. package/assets/docs/styling-overview.doc.mjs +1 -1
  79. package/assets/docs/theme.doc.dense.mjs +1 -1
  80. package/assets/docs/theme.doc.mjs +2 -2
  81. package/assets/docs/theme.doc.zh.mjs +1 -1
  82. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  83. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  84. package/assets/docs/tree/add-a-topic.doc.mjs +11 -8
  85. package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
  86. package/assets/docs/tree/block-template.doc.mjs +8 -20
  87. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  88. package/assets/docs/tree/check-the-props.doc.mjs +196 -0
  89. package/assets/docs/tree/check-your-docs.doc.mjs +61 -7
  90. package/assets/docs/tree/checks.doc.mjs +25 -17
  91. package/assets/docs/tree/codemods.doc.mjs +4 -4
  92. package/assets/docs/tree/component-family.doc.mjs +3 -5
  93. package/assets/docs/tree/component-imports.doc.mjs +2 -2
  94. package/assets/docs/tree/components.doc.mjs +1 -1
  95. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +30 -21
  96. package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
  97. package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
  98. package/assets/docs/tree/docs.doc.mjs +3 -3
  99. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  100. package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
  101. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  102. package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
  103. package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
  104. package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
  105. package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
  106. package/assets/docs/tree/integrations.doc.mjs +8 -0
  107. package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
  108. package/assets/docs/tree/layout.doc.mjs +6 -6
  109. package/assets/docs/tree/links.doc.mjs +6 -5
  110. package/assets/docs/tree/migration-setup.doc.mjs +3 -2
  111. package/assets/docs/tree/migration-verification.doc.mjs +0 -1
  112. package/assets/docs/tree/migration.doc.mjs +0 -1
  113. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  114. package/assets/docs/tree/page-template.doc.mjs +4 -8
  115. package/assets/docs/tree/publishing.doc.mjs +4 -4
  116. package/assets/docs/tree/quick-start.doc.mjs +38 -22
  117. package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
  118. package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
  119. package/assets/docs/tree/sections-and-placement.doc.mjs +6 -8
  120. package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
  121. package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
  122. package/assets/docs/tree/single-component.doc.mjs +14 -5
  123. package/assets/docs/tree/start-a-template.doc.mjs +3 -3
  124. package/assets/docs/tree/subcomponent.doc.mjs +6 -6
  125. package/assets/docs/tree/template-assets.doc.mjs +2 -2
  126. package/assets/docs/tree/template-doc-overview.doc.mjs +5 -16
  127. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  128. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  129. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  130. package/assets/docs/tree/template-styles.doc.mjs +2 -2
  131. package/assets/docs/tree/templates.doc.mjs +1 -1
  132. package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
  133. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  134. package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
  135. package/assets/docs/tree/troubleshooting.doc.mjs +8 -8
  136. package/assets/docs/tree/type-scale.doc.mjs +3 -3
  137. package/assets/docs/tree/upgrading.doc.mjs +4 -4
  138. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
  139. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  140. package/assets/docs/tree/versioning.doc.mjs +6 -6
  141. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
  142. package/assets/docs/use-a-theme.doc.mjs +2 -2
  143. package/assets/theme.template.ts +1 -1
  144. package/authoring/codemod/codemod.doc.mjs +7 -3
  145. package/authoring/config/config.doc.mjs +9 -6
  146. package/authoring/config/type.ts +4 -2
  147. package/authoring/discover/discover.doc.mjs +1 -1
  148. package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
  149. package/authoring/doctypes/command/command.doc.mjs +14 -12
  150. package/authoring/doctypes/component/component.doc.mjs +29 -26
  151. package/authoring/doctypes/component/type.ts +7 -5
  152. package/authoring/doctypes/enum/enum.doc.mjs +7 -4
  153. package/authoring/doctypes/function/function.doc.mjs +9 -8
  154. package/authoring/doctypes/hook/hook.doc.mjs +5 -4
  155. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
  156. package/authoring/doctypes/reference/reference.doc.mjs +11 -10
  157. package/authoring/doctypes/schema/schema.doc.mjs +9 -9
  158. package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
  159. package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
  160. package/authoring/doctypes/template/parse.d.mts +6 -2
  161. package/authoring/doctypes/template/parse.mjs +3 -1
  162. package/authoring/doctypes/template/template.doc.mjs +3 -3
  163. package/authoring/doctypes/template/type.ts +22 -0
  164. package/authoring/doctypes/theme/theme.doc.mjs +2 -2
  165. package/authoring/gap-report/gap-report.doc.mjs +2 -2
  166. package/authoring/identity/identity.doc.mjs +3 -3
  167. package/authoring/index.d.ts +1 -0
  168. package/authoring/integration/integration.doc.mjs +12 -4
  169. package/authoring/integration/parse.test.mjs +10 -0
  170. package/authoring/integration/schema.d.mts +2 -0
  171. package/authoring/integration/schema.mjs +1 -0
  172. package/authoring/integration/type.ts +4 -0
  173. package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
  174. package/clients/cli/commands/build-theme.mjs +1 -1
  175. package/clients/cli/commands/build-theme.path-safety.test.mjs +155 -21
  176. package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
  177. package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
  178. package/clients/cli/commands/discover.doc.mjs +1 -1
  179. package/clients/cli/commands/discover.mjs +144 -93
  180. package/clients/cli/commands/discover.no-source.test.mjs +447 -33
  181. package/clients/cli/commands/discover.sources.test.mjs +20 -1
  182. package/clients/cli/commands/doctor-integration-components.doc.mjs +17 -4
  183. package/clients/cli/commands/doctor-integration-docs.doc.mjs +18 -5
  184. package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
  185. package/clients/cli/commands/doctor-integration.test.mjs +837 -0
  186. package/clients/cli/commands/doctor.mjs +250 -3
  187. package/clients/cli/commands/gap-report.doc.mjs +14 -2
  188. package/clients/cli/commands/gap-report.mjs +24 -2
  189. package/clients/cli/commands/gap-report.test.mjs +79 -0
  190. package/clients/cli/commands/integration-check.doc.mjs +85 -0
  191. package/clients/cli/commands/integration-check.test.mjs +370 -0
  192. package/clients/cli/commands/integration.doc.mjs +6 -2
  193. package/clients/cli/commands/integration.mjs +106 -1
  194. package/clients/cli/commands/json-contract.test.mjs +5 -1
  195. package/clients/cli/commands/setup-nudge.test.mjs +79 -1
  196. package/clients/cli/commands/swizzle.mjs +5 -3
  197. package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
  198. package/clients/cli/commands/text-json-parity.test.mjs +5 -0
  199. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  200. package/clients/cli/commands/upgrade.doc.mjs +14 -0
  201. package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
  202. package/clients/cli/index.mjs +30 -5
  203. package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
  204. package/foundation/agent-docs/agent-doc-state.mjs +38 -0
  205. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  206. package/foundation/agent-docs/agent-docs.mjs +8 -6
  207. package/foundation/config/project.mjs +82 -0
  208. package/foundation/discovery/authoring-self-docs.mjs +2 -1
  209. package/foundation/discovery/component-discovery.d.mts +18 -0
  210. package/foundation/discovery/component-discovery.mjs +2 -2
  211. package/foundation/discovery/copied-passages.d.mts +216 -0
  212. package/foundation/discovery/copied-passages.mjs +720 -0
  213. package/foundation/discovery/copied-passages.test.mjs +124 -0
  214. package/foundation/discovery/doc-fluff.d.mts +112 -0
  215. package/foundation/discovery/doc-fluff.mjs +328 -0
  216. package/foundation/discovery/doc-fluff.test.mjs +142 -0
  217. package/foundation/discovery/doc-types.d.mts +157 -0
  218. package/foundation/discovery/doc-types.mjs +1224 -0
  219. package/foundation/discovery/doc-types.test.mjs +700 -0
  220. package/foundation/discovery/docs-discovery.d.mts +88 -0
  221. package/foundation/discovery/docs-discovery.mjs +83 -2
  222. package/foundation/discovery/integration-doc-files.d.mts +22 -0
  223. package/foundation/discovery/integration-doc-files.mjs +231 -0
  224. package/foundation/discovery/integration-doc-files.test.mjs +246 -0
  225. package/foundation/discovery/project-typescript.d.mts +11 -2
  226. package/foundation/discovery/project-typescript.mjs +32 -4
  227. package/foundation/discovery/prop-drift.d.mts +116 -3
  228. package/foundation/discovery/prop-drift.mjs +883 -41
  229. package/foundation/discovery/prop-drift.test.mjs +1738 -20
  230. package/foundation/discovery/type-match.d.mts +53 -0
  231. package/foundation/discovery/type-match.mjs +660 -0
  232. package/foundation/discovery/type-match.test.mjs +169 -0
  233. package/foundation/discovery/type-text.d.mts +68 -0
  234. package/foundation/discovery/type-text.mjs +658 -0
  235. package/foundation/discovery/type-text.test.mjs +196 -0
  236. package/foundation/doc-compiler/doc-loads.test.mjs +16 -2
  237. package/foundation/doc-compiler/links.d.mts +9 -5
  238. package/foundation/doc-compiler/links.mjs +4 -2
  239. package/foundation/env/package-manager.d.mts +32 -0
  240. package/foundation/env/package-manager.mjs +47 -0
  241. package/foundation/env/package-manager.test.mjs +194 -7
  242. package/foundation/fs/module-loader.d.mts +2 -1
  243. package/foundation/fs/module-loader.mjs +60 -4
  244. package/foundation/fs/module-loader.test.mjs +194 -0
  245. package/foundation/response/response-types.doc.mjs +14 -8
  246. package/package.json +11 -11
  247. package/scripts/postinstall.mjs +3 -3
@@ -18,6 +18,11 @@ import {discoverCoreTemplates} from '../../foundation/discovery/template-adapter
18
18
  import {discoverOwnedComponents} from '../../foundation/discovery/component-discovery.mjs';
19
19
  import {discoverBuiltinTopics} from '../../foundation/discovery/docs-discovery.mjs';
20
20
  import {findCoreDir} from '../../foundation/fs/paths.mjs';
21
+ import {
22
+ builtinGuideFiles,
23
+ loadTopicModule,
24
+ } from '../../foundation/discovery/docs-discovery.mjs';
25
+ import {proseWords} from '../../foundation/discovery/copied-passages.mjs';
21
26
  import {
22
27
  integrationComponentConflicts,
23
28
  integrationDocConflicts,
@@ -99,6 +104,44 @@ function writeDocIntegration({name, replaces, extendsTopic}) {
99
104
  );
100
105
  }
101
106
 
107
+ /**
108
+ * A docs-only package with one generic topic per entry: its prose, and
109
+ * optionally a code block and the Core topic it replaces.
110
+ * @param {{name: string, text: string, code?: string, replaces?: string}[]} topics
111
+ */
112
+ function writeTopics(topics) {
113
+ fs.writeFileSync(
114
+ path.join(tmpDir, 'package.json'),
115
+ JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
116
+ );
117
+ fs.writeFileSync(
118
+ path.join(tmpDir, 'astryx.integration.mjs'),
119
+ `export default {docs: './docs'};\n`,
120
+ );
121
+ fs.mkdirSync(path.join(tmpDir, 'docs'), {recursive: true});
122
+ for (const {name, text, code, replaces, extendsTopic} of topics) {
123
+ const blocks = [{type: 'prose', text}];
124
+ if (code != null) blocks.push({type: 'code', lang: 'text', code});
125
+ const doc = {
126
+ type: 'generic',
127
+ name,
128
+ title: 'Fixture',
129
+ description: 'Fixture topic.',
130
+ ...(replaces == null ? {} : {replaces}),
131
+ ...(extendsTopic == null ? {} : {extends: extendsTopic}),
132
+ sections: [{title: 'Overview', content: blocks}],
133
+ };
134
+ fs.writeFileSync(
135
+ path.join(tmpDir, 'docs', `${name}.doc.mjs`),
136
+ `export default ${JSON.stringify(doc)};\n`,
137
+ );
138
+ }
139
+ }
140
+
141
+ const PASSAGE =
142
+ 'Themes cannot style the layer that holds a menu or a popover, so a menu ' +
143
+ 'keeps the default surface color until the next release adds a token for it.';
144
+
102
145
  beforeEach(() => {
103
146
  tmpDir = fs.mkdtempSync(
104
147
  path.join(process.cwd(), '.astryx-template-conflicts-'),
@@ -417,6 +460,45 @@ describe('integrationComponentConflicts', () => {
417
460
  expect(result.data.conflicts).toEqual([]);
418
461
  expect(result.data.issues).toEqual([]);
419
462
  });
463
+
464
+ it("compares each component doc's props with the component's TypeScript props, as warnings", async () => {
465
+ writeComponentIntegration('AcmeBadge');
466
+ fs.writeFileSync(
467
+ path.join(tmpDir, 'components', 'AcmeBadge.doc.mjs'),
468
+ `export default {type: 'component', name: 'AcmeBadge', displayName: 'AcmeBadge', description: 'Fixture component.', props: [{name: 'label', type: 'string', description: 'Text.', required: true}, {name: 'size', type: "'sm' | 'md'", description: 'Size.'}]};\n`,
469
+ );
470
+ fs.writeFileSync(
471
+ path.join(tmpDir, 'components', 'AcmeBadge.tsx'),
472
+ 'export function AcmeBadge(props: {label: string; count?: number}) { return null; }\n',
473
+ );
474
+
475
+ const result = await integrationComponentConflicts(undefined, {
476
+ cwd: tmpDir,
477
+ });
478
+
479
+ expect(result.data.issues).toEqual([]);
480
+ expect(result.data.propDrift).toMatchObject({
481
+ status: 'checked',
482
+ components: 1,
483
+ unchecked: [],
484
+ });
485
+ expect(
486
+ result.data.propDrift?.findings.map(f => [f.prop, f.kind, f.severity]),
487
+ ).toEqual([
488
+ ['count', 'not_in_doc', 'warning'],
489
+ ['size', 'not_in_code', 'warning'],
490
+ ]);
491
+ });
492
+
493
+ it('leaves propDrift out when the package has no components root', async () => {
494
+ writeDocIntegration({name: 'acme-setup'});
495
+
496
+ const result = await integrationComponentConflicts(undefined, {
497
+ cwd: tmpDir,
498
+ });
499
+
500
+ expect(result.data).not.toHaveProperty('propDrift');
501
+ });
420
502
  });
421
503
 
422
504
  describe('integrationDocConflicts', () => {
@@ -523,3 +605,436 @@ describe('integrationDocConflicts', () => {
523
605
  ]);
524
606
  });
525
607
  });
608
+
609
+ describe('integrationDocConflicts copied passages', () => {
610
+ const copied = (/** @type {any} */ result) => result.data.copiedPassages;
611
+
612
+ it('lists a passage two of the package topics repeat, and warns about it', async () => {
613
+ writeTopics([
614
+ {name: 'acme-setup', text: `Read this first. ${PASSAGE}`},
615
+ {name: 'acme-menus', text: `${PASSAGE} See the theme guide.`},
616
+ ]);
617
+
618
+ const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
619
+ const [issue, ...rest] = copied(result);
620
+ expect(result.data.issues).toEqual([
621
+ {code: 'copied_passage', severity: 'warning', message: issue.message},
622
+ ]);
623
+
624
+ expect(rest).toEqual([]);
625
+ // The passage is about menus, so "acme-menus" keeps it.
626
+ expect(issue).toMatchObject({
627
+ topic: 'acme-setup',
628
+ otherTopic: 'acme-menus',
629
+ otherOwner: 'package',
630
+ owner: 'acme-menus',
631
+ section: 'Overview',
632
+ line: 1,
633
+ words: PASSAGE.split(' ').length,
634
+ passages: 1,
635
+ });
636
+ expect(issue.message).toContain(`${PASSAGE.split(' ').length} words`);
637
+ expect(issue.text).toBe(PASSAGE);
638
+ expect(issue.message).toContain(`"${PASSAGE}"`);
639
+ expect(issue.message).toContain(
640
+ '"acme-menus" keeps it: its name, title or section fits the passage.',
641
+ );
642
+ expect(issue.message).toContain(
643
+ 'In "acme-setup", replace that whole passage, from its first word to its last, code ticks included, with {@link generic:acme-menus}.',
644
+ );
645
+ });
646
+
647
+ it('reports a passage copied from a Core topic, except into the topic that replaces it', async () => {
648
+ const [file] = builtinGuideFiles();
649
+ const coreDoc = /** @type {any} */ (await loadTopicModule(file));
650
+ const coreText = proseWords(coreDoc)
651
+ .slice(0, 30)
652
+ .map(each => each.word)
653
+ .join(' ');
654
+
655
+ writeTopics([{name: 'acme-copy', text: coreText}]);
656
+ const [issue] = copied(
657
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
658
+ );
659
+ expect(issue.otherOwner).toBe('core');
660
+ expect(issue.message).toContain(`the Core topic "${coreDoc.name}"`);
661
+ expect(issue.owner).toBe(coreDoc.name);
662
+ expect(issue.message).toContain(
663
+ `code ticks included, with {@link @astryxdesign/cli:generic:${coreDoc.name}}.`,
664
+ );
665
+
666
+ fs.rmSync(path.join(tmpDir, 'docs'), {recursive: true, force: true});
667
+ writeTopics([{name: 'acme-own', text: coreText, replaces: coreDoc.name}]);
668
+ expect(
669
+ copied(await integrationDocConflicts(undefined, {cwd: tmpDir})).filter(
670
+ (/** @type {any} */ each) => each.message.includes(`"${coreDoc.name}"`),
671
+ ),
672
+ ).toEqual([]);
673
+ });
674
+
675
+ it('leaves out boilerplate that three topics share', async () => {
676
+ writeTopics([
677
+ {name: 'acme-fonts', text: PASSAGE},
678
+ {name: 'acme-icons', text: PASSAGE},
679
+ {name: 'acme-media', text: PASSAGE},
680
+ ]);
681
+
682
+ expect(
683
+ copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
684
+ ).toEqual([]);
685
+ });
686
+
687
+ it('leaves out a run of function words, which states no fact', async () => {
688
+ const glue = 'and it is in the way that you can do it for them';
689
+ writeTopics([
690
+ {name: 'acme-a', text: `Start here. ${glue} first.`},
691
+ {name: 'acme-b', text: `Then ${glue} again.`},
692
+ ]);
693
+
694
+ expect(
695
+ copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
696
+ ).toEqual([]);
697
+ });
698
+
699
+ it('leaves out a shared phrase under 10 words, and code', async () => {
700
+ const short = PASSAGE.split(' ').slice(0, 9).join(' ');
701
+ writeTopics([
702
+ {name: 'acme-a', text: PASSAGE},
703
+ {name: 'acme-b', text: short},
704
+ {name: 'acme-c', text: 'Run it.', code: PASSAGE},
705
+ ]);
706
+
707
+ expect(
708
+ copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
709
+ ).toEqual([]);
710
+ });
711
+ });
712
+
713
+ describe('integrationDocConflicts copied passages and extensions', () => {
714
+ const copied = (/** @type {any} */ result) => result.data.copiedPassages;
715
+
716
+ it('links to the page an extension shows on, not to the extension', async () => {
717
+ writeTopics([
718
+ {name: 'acme-menus', text: PASSAGE, extendsTopic: 'theme'},
719
+ {name: 'acme-setup', text: `${PASSAGE} Then run setup.`},
720
+ ]);
721
+
722
+ const [issue] = copied(
723
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
724
+ );
725
+
726
+ expect(issue).toMatchObject({topic: 'acme-setup', owner: 'acme-menus'});
727
+ expect(issue.message).toContain(
728
+ 'with {@link @astryxdesign/cli:generic:theme}.',
729
+ );
730
+ });
731
+
732
+ it('says to delete a copy in a topic that extends its owner', async () => {
733
+ writeTopics([
734
+ {name: 'acme-base', text: PASSAGE},
735
+ {name: 'acme-more', text: PASSAGE, extendsTopic: 'acme-base'},
736
+ ]);
737
+
738
+ const [issue] = copied(
739
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
740
+ );
741
+
742
+ expect(issue).toMatchObject({topic: 'acme-more', owner: 'acme-base'});
743
+ expect(issue.message).toContain(
744
+ '"acme-more" and "acme-base" show on the same page ("acme-base"): delete the passage from "acme-more"',
745
+ );
746
+ expect(issue.message).not.toContain('{@link');
747
+ });
748
+
749
+ it('compares pages without regard to case, and for two extensions of one page', async () => {
750
+ writeTopics([
751
+ {name: 'acme-colors', text: PASSAGE, extendsTopic: 'Theme'},
752
+ {name: 'acme-menus', text: PASSAGE, extendsTopic: 'theme'},
753
+ ]);
754
+
755
+ const [issue] = copied(
756
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
757
+ );
758
+
759
+ expect(issue.message).toContain('show on the same page ("theme")');
760
+ expect(issue.message).not.toContain('{@link');
761
+ });
762
+
763
+ it('finds the line of the string that holds the copy, whatever it opens with', async () => {
764
+ writeTopics([{name: 'acme-menus', text: PASSAGE}]);
765
+ fs.writeFileSync(
766
+ path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
767
+ [
768
+ 'export default {',
769
+ " type: 'generic',",
770
+ " name: 'acme-setup',",
771
+ " title: 'Fixture',",
772
+ " description: 'Fixture topic.',",
773
+ " sections: [{title: 'Overview', content: [",
774
+ " {type: 'prose', text: '`acme` (the CLI) opens here, as {@link generic:acme-menus} says.'},",
775
+ ` {type: 'prose', text: '\`acme\` (the CLI) opens here: ${PASSAGE}'},`,
776
+ ' ]}],',
777
+ '};',
778
+ '',
779
+ ].join('\n'),
780
+ );
781
+
782
+ const [issue] = copied(
783
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
784
+ );
785
+
786
+ expect(issue).toMatchObject({topic: 'acme-setup', line: 8});
787
+ });
788
+
789
+ it('does not list a 9-word sentence that ends in a link', async () => {
790
+ const sentence =
791
+ 'Theme tokens control every surface color, as explained in {@link generic:acme-theme}.';
792
+ writeTopics([
793
+ {name: 'acme-colors', text: `Colors first. ${sentence}`},
794
+ {name: 'acme-menus', text: `Menus next. ${sentence}`},
795
+ ]);
796
+
797
+ expect(
798
+ copied(await integrationDocConflicts(undefined, {cwd: tmpDir})),
799
+ ).toEqual([]);
800
+ });
801
+
802
+ it('counts no function word toward which topic a passage fits', async () => {
803
+ writeTopics([
804
+ {name: 'acme-getting-started', text: `${PASSAGE} Then run setup.`},
805
+ {name: 'acme-menus', text: PASSAGE},
806
+ ]);
807
+ // Titles that share only function words with the passage.
808
+ for (const [name, title] of [
809
+ ['acme-getting-started', 'Get started with the widgets'],
810
+ ['acme-menus', 'Menus'],
811
+ ]) {
812
+ const file = path.join(tmpDir, 'docs', `${name}.doc.mjs`);
813
+ fs.writeFileSync(
814
+ file,
815
+ fs
816
+ .readFileSync(file, 'utf8')
817
+ .replace('"title":"Fixture"', `"title":"${title}"`),
818
+ );
819
+ }
820
+
821
+ const [issue] = copied(
822
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
823
+ );
824
+
825
+ expect(issue).toMatchObject({
826
+ owner: 'acme-menus',
827
+ topic: 'acme-getting-started',
828
+ });
829
+ });
830
+
831
+ it('finds a copy after a lead-in three topics share', async () => {
832
+ const lead =
833
+ 'Every package ships its integration docs as plain modules the CLI reads';
834
+ writeTopics([
835
+ {name: 'acme-menus', text: `${lead}. ${PASSAGE}`},
836
+ {name: 'acme-setup', text: `${lead}. ${PASSAGE} Then run setup.`},
837
+ {name: 'acme-other', text: `${lead}. Nothing else here is shared.`},
838
+ ]);
839
+
840
+ const found = copied(
841
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
842
+ );
843
+
844
+ expect(found).toHaveLength(1);
845
+ expect(found[0].text).toBe(PASSAGE);
846
+ });
847
+
848
+ it("links to a package topic that replaces Core's by its own name", async () => {
849
+ writeTopics([
850
+ {name: 'theme', text: PASSAGE, replaces: 'theme'},
851
+ {name: 'acme-setup', text: `${PASSAGE} Then run setup.`},
852
+ ]);
853
+
854
+ const found = copied(
855
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
856
+ );
857
+
858
+ for (const each of found) {
859
+ expect(each.message).not.toContain('@astryxdesign/cli:generic:theme');
860
+ }
861
+ expect(
862
+ found.some((/** @type {any} */ each) =>
863
+ each.message.includes('with {@link generic:theme}.'),
864
+ ),
865
+ ).toBe(true);
866
+ });
867
+
868
+ it('prints no link to a Core topic one of the package topics replaces', async () => {
869
+ const [file] = builtinGuideFiles();
870
+ const coreDoc = /** @type {any} */ (await loadTopicModule(file));
871
+ const coreText = proseWords(coreDoc)
872
+ .slice(0, 30)
873
+ .map(each => each.word)
874
+ .join(' ');
875
+ writeTopics([
876
+ {name: 'acme-own', text: 'Our version.', replaces: coreDoc.name},
877
+ {name: 'acme-copy', text: coreText},
878
+ ]);
879
+
880
+ const found = copied(
881
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
882
+ ).filter((/** @type {any} */ each) => each.owner === coreDoc.name);
883
+
884
+ expect(found).toHaveLength(1);
885
+ expect(found[0].message).toContain(
886
+ `"acme-own" replaces the Core topic "${coreDoc.name}"`,
887
+ );
888
+ expect(found[0].message).not.toContain('{@link');
889
+ });
890
+ });
891
+
892
+ describe('integrationDocConflicts fluff', () => {
893
+ const fluff = (/** @type {any} */ result) => result.data.fluff;
894
+
895
+ it('lists each padding phrase with its line and what to write instead', async () => {
896
+ writeTopics([
897
+ {
898
+ name: 'acme-setup',
899
+ text: 'In order to start, run the setup command once.',
900
+ },
901
+ ]);
902
+
903
+ const result = await integrationDocConflicts(undefined, {cwd: tmpDir});
904
+ const [hit, ...rest] = fluff(result);
905
+
906
+ expect(rest).toEqual([]);
907
+ expect(result.data.issues).toEqual([
908
+ {code: 'doc_fluff', severity: 'warning', message: hit.message},
909
+ ]);
910
+ expect(hit).toMatchObject({
911
+ topic: 'acme-setup',
912
+ kind: 'phrase',
913
+ phrase: 'in order to',
914
+ section: 'Overview',
915
+ file: expect.stringMatching(/acme-setup\.doc\.mjs$/),
916
+ line: 1,
917
+ density: null,
918
+ });
919
+ expect(hit.message).toContain('Write "to" instead.');
920
+ });
921
+
922
+ it('finds each line within its own string, not in code or another field', async () => {
923
+ writeTopics([]);
924
+ fs.writeFileSync(
925
+ path.join(tmpDir, 'docs', 'acme-lines.doc.mjs'),
926
+ [
927
+ 'export default {',
928
+ " type: 'generic',",
929
+ " name: 'acme-lines',",
930
+ " title: 'Fixture',",
931
+ " description: 'Build the package in order to publish it.',",
932
+ " sections: [{title: 'Overview', content: [",
933
+ " {type: 'code', lang: 'text', code: 'in order to build'},",
934
+ " {type: 'prose', text: 'Note that the build runs once per package and writes its output.'},",
935
+ " {type: 'prose', text: 'Run the build in order to refresh the generated files for the docs.'},",
936
+ ' ]}],',
937
+ '};',
938
+ '',
939
+ ].join('\n'),
940
+ );
941
+
942
+ const found = fluff(
943
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
944
+ ).map((/** @type {any} */ each) => [each.phrase, each.line]);
945
+
946
+ expect(found).toEqual([
947
+ ['in order to', 5],
948
+ ['note that', 8],
949
+ ['in order to', 9],
950
+ ]);
951
+ });
952
+
953
+ it('gives each use its own line in multi-line and concatenated strings', async () => {
954
+ writeTopics([]);
955
+ fs.writeFileSync(
956
+ path.join(tmpDir, 'docs', 'acme-multi.doc.mjs'),
957
+ [
958
+ 'export default {',
959
+ " type: 'generic',",
960
+ " name: 'acme-multi',",
961
+ " title: 'Fixture',",
962
+ " description: 'Fixture topic.',",
963
+ " sections: [{title: 'Overview', content: [",
964
+ " {type: 'prose', text: `Build the package first.",
965
+ 'Run the build in order to refresh the files.',
966
+ 'Run it again in order to check them.`},',
967
+ " {type: 'prose', text: 'Publishing reads the built files ' +",
968
+ " 'in order to ship them, so build before you publish.'},",
969
+ ' ]}],',
970
+ '};',
971
+ '',
972
+ ].join('\n'),
973
+ );
974
+
975
+ const found = fluff(
976
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
977
+ ).map((/** @type {any} */ each) => each.line);
978
+
979
+ expect(found).toEqual([8, 9, 11]);
980
+ });
981
+
982
+ it('finds the line of strings that open or end with code, links, quotes or escapes', async () => {
983
+ writeTopics([]);
984
+ fs.writeFileSync(
985
+ path.join(tmpDir, 'docs', 'acme-shapes.doc.mjs'),
986
+ [
987
+ 'export default {',
988
+ " type: 'generic',",
989
+ " name: 'acme-shapes',",
990
+ " title: 'Fixture',",
991
+ " description: 'Fixture topic.',",
992
+ " sections: [{title: 'Overview', content: [",
993
+ " {type: 'prose', text: '`build` runs first, in order to check it.'},",
994
+ " {type: 'prose', text: '{@link generic:acme-shapes} runs it in order to ship.'},",
995
+ " {type: 'prose', text: '\"Build\" is a step you run in order to test (and ship).'},",
996
+ " {type: 'prose', text: '(Build) runs it once in order to publish the app\\'s files.'},",
997
+ " {type: 'prose', text: 'Run the build in order to check the files.'},",
998
+ " {type: 'prose', text: 'Run the build in order to publish the files.'},",
999
+ ' ]}],',
1000
+ '};',
1001
+ '',
1002
+ ].join('\n'),
1003
+ );
1004
+
1005
+ const found = fluff(
1006
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
1007
+ ).map((/** @type {any} */ each) => each.line);
1008
+
1009
+ expect(found).toEqual([7, 8, 9, 10, 11, 12]);
1010
+ });
1011
+
1012
+ it('lists a long topic that is mostly glue, and not a dense one', async () => {
1013
+ const glue = Array.from(
1014
+ {length: 12},
1015
+ () =>
1016
+ 'So that is why it is the one that you would want to use if you can.',
1017
+ ).join(' ');
1018
+ const dense = Array.from(
1019
+ {length: 8},
1020
+ (_, i) =>
1021
+ `Name codemod folder ${i} after the Core version whose upgrade runs it.`,
1022
+ ).join(' ');
1023
+ writeTopics([
1024
+ {name: 'acme-glue', text: glue},
1025
+ {name: 'acme-dense', text: dense},
1026
+ ]);
1027
+
1028
+ const found = fluff(
1029
+ await integrationDocConflicts(undefined, {cwd: tmpDir}),
1030
+ );
1031
+
1032
+ expect(found.map((/** @type {any} */ each) => each.topic)).toEqual([
1033
+ 'acme-glue',
1034
+ ]);
1035
+ expect(found[0]).toMatchObject({kind: 'density', phrase: null});
1036
+ expect(found[0].density).toBeLessThan(0.5);
1037
+ expect(found[0].message).toContain("Core's guides have a median of");
1038
+ expect(found[0].message).toContain('under the 50% floor');
1039
+ });
1040
+ });
@@ -32,6 +32,90 @@ export type IntegrationDocFinding = {
32
32
  coreTopic: string;
33
33
  message: string;
34
34
  };
35
+ /**
36
+ * A passage two topics repeat word for word: two of the package's own topics,
37
+ * or one of them and a Core topic (never the Core topic it replaces). Only
38
+ * prose counts, and only a run of 10 or more identical words, so each entry
39
+ * is a real copy. Each is also a `copied_passage` warning, so
40
+ * `integration check --strict` fails on it (architecture:cli-surface DEC-8).
41
+ */
42
+ export type CopiedPassage = {
43
+ /**
44
+ * the package topic to change: it repeats the passage
45
+ */
46
+ topic: string;
47
+ /**
48
+ * the title of the section the passage starts in
49
+ */
50
+ section: string | null;
51
+ /**
52
+ * the file line where the passage starts in `topic`, or null
53
+ */
54
+ line: number | null;
55
+ /**
56
+ * the topic that also has it
57
+ */
58
+ otherTopic: string;
59
+ /**
60
+ * the topic that should keep the text: a Core topic, or of two package topics the one it fits
61
+ */
62
+ owner: string;
63
+ /**
64
+ * the passage as `topic` writes it: what to replace
65
+ */
66
+ text: string;
67
+ /**
68
+ * whether that topic is the package's own or Core's
69
+ */
70
+ otherOwner: "package" | "core";
71
+ /**
72
+ * the length of the longest shared run, in words
73
+ */
74
+ words: number;
75
+ /**
76
+ * how many separate runs the two topics share
77
+ */
78
+ passages: number;
79
+ /**
80
+ * what is repeated, and the exact fix: the passage in `topic` replaced by a link to `owner`
81
+ */
82
+ message: string;
83
+ };
84
+ /**
85
+ * Fluff in a topic's prose: a padding phrase (`kind: 'phrase'`, with the
86
+ * phrase, its section, and the file line where it was found), or a topic of
87
+ * 80 or more prose words of which fewer than half are content words
88
+ * (`kind: 'density'`, with the share). Each is also a `doc_fluff` warning, so
89
+ * `integration check --strict` fails on it (architecture:cli-surface DEC-8).
90
+ */
91
+ export type DocFluff = {
92
+ topic: string;
93
+ kind: "phrase" | "density";
94
+ /**
95
+ * the padding phrase, for `kind: 'phrase'`
96
+ */
97
+ phrase: string | null;
98
+ /**
99
+ * the title of the section it is in
100
+ */
101
+ section: string | null;
102
+ /**
103
+ * the doc file
104
+ */
105
+ file: string;
106
+ /**
107
+ * the file line that holds the phrase, when one line does
108
+ */
109
+ line: number | null;
110
+ /**
111
+ * the share of content words, for `kind: 'density'`
112
+ */
113
+ density: number | null;
114
+ /**
115
+ * what to cut or write instead
116
+ */
117
+ message: string;
118
+ };
35
119
  /**
36
120
  * Each of the three authoring checks reports `validated`: false means no
37
121
  * integration manifest was found, so nothing was inspected and the empty
@@ -47,6 +131,14 @@ export type IntegrationTemplateConflictResponse = {
47
131
  issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
48
132
  };
49
133
  };
134
+ /**
135
+ * Documented props compared with the component's TypeScript props. Present
136
+ * when the manifest loads and declares a components root. `status: 'skipped'`
137
+ * means nothing was compared (no TypeScript in the project) and `reason` says
138
+ * why. Every finding is a warning.
139
+ */
140
+ export type PropDriftReport = import("../../foundation/discovery/prop-drift.mjs").PropDriftReport;
141
+ export type PropDriftFinding = import("../../foundation/discovery/prop-drift.mjs").PropDriftFinding;
50
142
  export type IntegrationComponentConflictResponse = {
51
143
  type: "integration.component-conflicts";
52
144
  data: {
@@ -55,6 +147,7 @@ export type IntegrationComponentConflictResponse = {
55
147
  version: string | null;
56
148
  conflicts: IntegrationComponentConflict[];
57
149
  issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
150
+ propDrift?: PropDriftReport;
58
151
  };
59
152
  };
60
153
  export type IntegrationDocConflictResponse = {
@@ -64,6 +157,8 @@ export type IntegrationDocConflictResponse = {
64
157
  name: string | null;
65
158
  version: string | null;
66
159
  findings: IntegrationDocFinding[];
160
+ copiedPassages: CopiedPassage[];
161
+ fluff: DocFluff[];
67
162
  issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
68
163
  };
69
164
  };