@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
@@ -98,6 +98,85 @@ function issueBlocks(issues) {
98
98
  ];
99
99
  }
100
100
 
101
+ /**
102
+ * The docs checked against the authoring types: a visible line when it was
103
+ * skipped, the findings (all warnings), the files it could not check, or an
104
+ * [ok] (never after a failed check).
105
+ * @param {import('../../../api/integration/validate-integration.type.mjs').DocTypesReport | undefined} report
106
+ * @param {boolean} failed
107
+ */
108
+ function docTypesBlocks(report, failed) {
109
+ if (!report) return [];
110
+ if (
111
+ report.status === 'checked' &&
112
+ report.docs === 0 &&
113
+ report.findings.length === 0 &&
114
+ report.unchecked.length === 0
115
+ ) {
116
+ return [
117
+ text('[info] No doc files to type-check.'),
118
+ ...(report.fixtures
119
+ ? [text(`[info] ${report.fixtures} test fixture doc(s) not checked.`)]
120
+ : []),
121
+ ];
122
+ }
123
+ if (report.status === 'skipped') {
124
+ return [text(`[skip] Docs not type-checked: ${report.reason}`)];
125
+ }
126
+ const blocks = [
127
+ section(
128
+ `Checking ${report.docs} doc(s) against the authoring types${report.typescript ? ` (TypeScript ${report.typescript})` : ''}`,
129
+ ),
130
+ ];
131
+ if (report.findings.length > 0) {
132
+ const files = new Set(report.findings.map(f => f.doc)).size;
133
+ blocks.push(
134
+ records(report.findings, {
135
+ fields: [
136
+ 'severity',
137
+ 'doc',
138
+ 'line',
139
+ 'export',
140
+ 'type',
141
+ 'field',
142
+ 'problem',
143
+ 'message',
144
+ 'fix',
145
+ ],
146
+ format: {severity: statusToken},
147
+ }),
148
+ text(
149
+ `${report.findings.length} doc field(s) in ${files} file(s) do not match the authoring types. ` +
150
+ 'These are warnings; `astryx docs authoring` lists every field.',
151
+ ),
152
+ );
153
+ }
154
+ if (report.unchecked.length > 0) {
155
+ blocks.push(
156
+ text(`[info] Not type-checked: ${report.unchecked.length} doc file(s):`),
157
+ records(report.unchecked, {fields: ['doc', 'reason']}),
158
+ );
159
+ }
160
+ if (report.fixtures) {
161
+ blocks.push(
162
+ text(`[info] ${report.fixtures} test fixture doc(s) not checked.`),
163
+ );
164
+ }
165
+ if (report.findings.length === 0 && report.docs > 0) {
166
+ // After a failed check an [ok] reads as a pass, but the result still shows.
167
+ blocks.push(
168
+ text(
169
+ failed
170
+ ? `[info] No doc field differs from its authoring type (${report.docs} checked).`
171
+ : report.unchecked.length > 0
172
+ ? `[ok] Every doc that was checked matches its authoring type (${report.docs} checked).`
173
+ : `[ok] Every doc matches its authoring type (${report.docs} checked).`,
174
+ ),
175
+ );
176
+ }
177
+ return blocks;
178
+ }
179
+
101
180
  /**
102
181
  * @param {import('../../../api/integration/validate-integration.type.mjs').ValidateIntegrationResponse['data']} data
103
182
  */
@@ -119,6 +198,7 @@ function printIntegrationValidation(data) {
119
198
  `Summary: ${errors} error${errors === 1 ? '' : 's'}, ` +
120
199
  `${warnings} warning${warnings === 1 ? '' : 's'}`,
121
200
  ),
201
+ ...docTypesBlocks(data.docTypes, errors > 0),
122
202
  );
123
203
  }
124
204
 
@@ -173,6 +253,98 @@ function printTemplateConflicts(data) {
173
253
  emit(...output);
174
254
  }
175
255
 
256
+ /**
257
+ * The documented-props comparison, with every field its JSON carries: a
258
+ * visible line when it was skipped, the findings (all warnings), the
259
+ * components it could not read, and how many were compared with which
260
+ * TypeScript, as an [ok] when nothing differs (never after a failed check).
261
+ * Then how many documented prop types were judged and which were not.
262
+ * @param {import('../../../api/integration/authoring-checks.type.mjs').PropDriftReport | undefined} report
263
+ * @param {boolean} failed
264
+ */
265
+ function propDriftBlocks(report, failed) {
266
+ if (!report) return [];
267
+ if (report.status === 'skipped') {
268
+ return [text(`[skip] Props not compared: ${report.reason}`)];
269
+ }
270
+ const blocks = [];
271
+ if (report.findings.length > 0) {
272
+ // Two docs of one name are two components.
273
+ const components = new Set(
274
+ report.findings.map(f => `${f.doc}\0${f.component}`),
275
+ ).size;
276
+ blocks.push(
277
+ records(report.findings, {
278
+ fields: [
279
+ 'severity',
280
+ 'component',
281
+ 'prop',
282
+ 'kind',
283
+ 'message',
284
+ 'doc',
285
+ 'source',
286
+ 'docType',
287
+ 'codeType',
288
+ 'docRequired',
289
+ 'codeRequired',
290
+ ],
291
+ format: {severity: statusToken},
292
+ }),
293
+ text(
294
+ `${report.findings.length} prop(s) differ between the docs and the code in ${components} of ${report.components} component(s) compared (TypeScript ${report.typescript}). ` +
295
+ 'These are warnings: update the doc, or the code if the doc is right.',
296
+ ),
297
+ );
298
+ }
299
+ if (report.unchecked.length > 0) {
300
+ blocks.push(
301
+ text(
302
+ `[info] Props not compared for ${report.unchecked.length} documented component(s):`,
303
+ ),
304
+ records(report.unchecked, {fields: ['component', 'doc', 'reason']}),
305
+ );
306
+ }
307
+ const notChecked = report.propsNotChecked ?? [];
308
+ if (notChecked.length > 0) {
309
+ blocks.push(
310
+ text(
311
+ `[info] Props not checked for a doc entry in ${notChecked.length} component(s):`,
312
+ ),
313
+ records(notChecked, {fields: ['component', 'doc', 'reason', 'props']}),
314
+ );
315
+ }
316
+ if (report.findings.length === 0) {
317
+ const apart =
318
+ notChecked.length > 0 ? ', apart from the props not checked' : '';
319
+ blocks.push(
320
+ text(
321
+ !failed && report.components > 0
322
+ ? `[ok] Documented prop names and required flags match the code in ${report.components} component(s)${apart} (TypeScript ${report.typescript}).`
323
+ : `[info] Props compared in ${report.components} component(s) (TypeScript ${report.typescript}).`,
324
+ ),
325
+ );
326
+ }
327
+ if (report.typesSkipped) {
328
+ blocks.push(text(`[skip] Prop types not judged: ${report.typesSkipped}.`));
329
+ return blocks;
330
+ }
331
+ const notCompared = report.typesNotCompared.flatMap(entry => entry.props);
332
+ blocks.push(
333
+ text(
334
+ `[info] Documented prop types judged: ${report.typesCompared}; not compared: ${notCompared.length}. ` +
335
+ '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.',
336
+ ),
337
+ );
338
+ if (notCompared.length > 0) {
339
+ blocks.push(
340
+ records(report.typesNotCompared, {
341
+ fields: ['component', 'doc', 'reason', 'props'],
342
+ }),
343
+ );
344
+ }
345
+ return blocks;
346
+ }
347
+
176
348
  /**
177
349
  * @param {import('../../../api/integration/authoring-checks.type.mjs').IntegrationComponentConflictResponse['data']} data
178
350
  */
@@ -186,7 +358,8 @@ function printComponentConflicts(data) {
186
358
  // An [ok] after a failed check reads as a pass: say nothing it could not check.
187
359
  const failed = data.issues.some(issue => issue.severity === 'error');
188
360
  if (data.conflicts.length === 0) {
189
- if (!failed) output.push(text('[ok] No component names conflict with Core.'));
361
+ if (!failed)
362
+ output.push(text('[ok] No component names conflict with Core.'));
190
363
  } else {
191
364
  output.push(
192
365
  records(data.conflicts, {
@@ -205,6 +378,7 @@ function printComponentConflicts(data) {
205
378
  ),
206
379
  );
207
380
  }
381
+ output.push(...propDriftBlocks(data.propDrift, failed));
208
382
  emit(...output);
209
383
  }
210
384
 
@@ -216,7 +390,13 @@ function printDocConflicts(data) {
216
390
  section(
217
391
  `Checking integration docs: ${integrationLabel(data) ?? '(local package)'}`,
218
392
  ),
219
- ...issueBlocks(data.issues),
393
+ // A copied passage or fluff is listed below with its detail, so its
394
+ // issue is not printed twice.
395
+ ...issueBlocks(
396
+ data.issues.filter(
397
+ issue => issue.code !== 'copied_passage' && issue.code !== 'doc_fluff',
398
+ ),
399
+ ),
220
400
  ];
221
401
  if (
222
402
  !data.issues.some(
@@ -239,9 +419,76 @@ function printDocConflicts(data) {
239
419
  }),
240
420
  );
241
421
  }
422
+ const copied = data.copiedPassages ?? [];
423
+ if (copied.length === 0) {
424
+ if (!data.issues.some(issue => issue.severity === 'error')) {
425
+ output.push(text('[ok] No topic copies a passage from another.'));
426
+ }
427
+ } else {
428
+ output.push(
429
+ text(
430
+ `[warn] ${copied.length} copied passage(s) (copied_passage): two topics say the same thing word for word. Keep the text in one and link to it from the other.`,
431
+ ),
432
+ records(copied, {
433
+ fields: [
434
+ 'topic',
435
+ 'section',
436
+ 'line',
437
+ 'otherTopic',
438
+ 'otherOwner',
439
+ 'owner',
440
+ 'text',
441
+ 'words',
442
+ 'passages',
443
+ 'message',
444
+ ],
445
+ }),
446
+ );
447
+ }
448
+ const fluff = data.fluff ?? [];
449
+ if (fluff.length === 0) {
450
+ if (!data.issues.some(issue => issue.severity === 'error')) {
451
+ output.push(text('[ok] No filler phrases or low-density topics.'));
452
+ }
453
+ } else {
454
+ output.push(
455
+ text(
456
+ `[warn] ${fluff.length} fluff finding(s) (doc_fluff): words that add length, not meaning. Cut each one.`,
457
+ ),
458
+ records(fluff, {
459
+ fields: [
460
+ 'topic',
461
+ 'kind',
462
+ 'phrase',
463
+ 'section',
464
+ 'file',
465
+ 'line',
466
+ 'density',
467
+ 'message',
468
+ ],
469
+ }),
470
+ );
471
+ }
242
472
  emit(...output);
243
473
  }
244
474
 
475
+ /**
476
+ * Print one `doctor integration` check's result as its own subcommand prints
477
+ * it. `astryx integration check` prints each check it runs through this.
478
+ * @param {import('../../../api/integration/integration-check.type.mjs').IntegrationCheckResponse} response
479
+ */
480
+ export function printIntegrationCheckResponse(response) {
481
+ if (response.type === 'integration.validate') {
482
+ printIntegrationValidation(response.data);
483
+ } else if (response.type === 'integration.component-conflicts') {
484
+ printComponentConflicts(response.data);
485
+ } else if (response.type === 'integration.template-conflicts') {
486
+ printTemplateConflicts(response.data);
487
+ } else {
488
+ printDocConflicts(response.data);
489
+ }
490
+ }
491
+
245
492
  /** @param {import('commander').Command} program */
246
493
  async function runProjectDoctor(program) {
247
494
  const report = await runChecks();
@@ -265,7 +512,7 @@ async function runIntegrationValidation(program, pkg) {
265
512
  noPackage
266
513
  ? 'Nothing was validated: no package.json found. Run this command inside a package directory.'
267
514
  : 'Nothing was validated: no astryx.integration.* found next to package.json. ' +
268
- 'To validate an installed integration: astryx doctor integration validate <package>',
515
+ 'To validate an installed integration: astryx doctor integration validate <package>',
269
516
  ),
270
517
  );
271
518
  } else printIntegrationValidation(result.data);
@@ -16,6 +16,8 @@ export const doc = {
16
16
  'Reports a missing component, variant, layout, styling, accessibility, API, or documentation capability to the package that owns it: the --package you name, else the integration whose component replaces it, else the one package that provides the component, else Core. ' +
17
17
  'Every configured handler receives the report: the project config handler first, then each integration handler in config order. Public handlers run only with --confirm-public; internal handlers always run. A failing handler does not stop the others. ' +
18
18
  "With no handler it files a GitHub issue for the owning package, only with --confirm-public (without it nothing is sent), or returns the package's issues URL when that is not on GitHub. " +
19
+ "With --to <package>, the report goes only to that integration's issues URL instead, under the same --confirm-public rule. " +
20
+ 'When loaded integrations name their own issues URLs, the output lists every destination: an agent asks the person where to file and passes their choice with --to; it never picks a package itself, and without a choice the default is used. ' +
19
21
  'The report records whether an agent or a person ran it.',
20
22
  fn: 'gapReport',
21
23
  args: [
@@ -55,13 +57,19 @@ export const doc = {
55
57
  flag: '--confirm-public',
56
58
  param: 'options.confirmPublic',
57
59
  description:
58
- 'Allow public delivery: public handlers run, and with no handler it files a GitHub issue with your gh login',
60
+ 'Allow public delivery: public handlers run, and a GitHub issues URL gets an issue filed with your gh login',
61
+ },
62
+ {
63
+ flag: '--to <package>',
64
+ param: 'options.to',
65
+ description:
66
+ "Send the report only to this loaded integration's issues URL, as the person chose; the destinations the output lists are the choices",
59
67
  },
60
68
  {
61
69
  flag: '--list-categories',
62
70
  param: 'options.listCategories',
63
71
  description:
64
- 'List valid report categories without filing; the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',
72
+ 'List valid report categories, and the destinations when there is more than one, without filing; the component and the other gap-report options are refused with ERR_INVALID_ARGUMENT',
65
73
  },
66
74
  ],
67
75
  examples: [
@@ -70,6 +78,10 @@ export const doc = {
70
78
  label: 'Prepare a report (nothing public happens without --confirm-public)',
71
79
  cli: "astryx gap-report Button --category missing_variant --reason 'Need a compact size'",
72
80
  },
81
+ {
82
+ label: 'File where the person chose',
83
+ cli: "astryx gap-report Button --category missing_variant --reason 'Need a compact size' --to @acme/widgets",
84
+ },
73
85
  ],
74
86
  exitCodes: [
75
87
  {
@@ -7,7 +7,7 @@
7
7
  import {gapReport as gapReportApi} from '../../../api/gap-report/gap-report.mjs';
8
8
  import {NO_RESULT_SET, resultSet} from '../../../foundation/debug/index.mjs';
9
9
  import {jsonOut} from '../../../foundation/response/json.mjs';
10
- import {emit, record, records, section} from '../formatters/index.mjs';
10
+ import {emit, record, records, section, text} from '../formatters/index.mjs';
11
11
  import {cliError} from '../lib/cli-error.mjs';
12
12
  import {defineCommand} from '../lib/define-command.mjs';
13
13
  import {doc as gapReportCommand} from './gap-report.doc.mjs';
@@ -19,7 +19,7 @@ export function registerGapReport(program) {
19
19
  fn: gapReportFn,
20
20
  action: async (
21
21
  /** @type {string|undefined} */ component,
22
- /** @type {{category?: string, reason?: string, additionalContext?: string, package?: string, confirmPublic?: boolean, listCategories?: boolean}} */ options,
22
+ /** @type {{category?: string, reason?: string, additionalContext?: string, package?: string, confirmPublic?: boolean, listCategories?: boolean, to?: string}} */ options,
23
23
  ) => {
24
24
  /** @type {Awaited<ReturnType<typeof gapReportApi>>} */
25
25
  let result;
@@ -35,6 +35,7 @@ export function registerGapReport(program) {
35
35
  package: options.package,
36
36
  confirmPublic: options.confirmPublic,
37
37
  listCategories: options.listCategories,
38
+ to: options.to,
38
39
  });
39
40
  } catch (error) {
40
41
  const err =
@@ -78,6 +79,9 @@ export function registerGapReport(program) {
78
79
  section('Gap report categories'),
79
80
  records(result.data, {fields: ['value', 'label']}),
80
81
  );
82
+ if (result.meta) {
83
+ emit(...destinationBlocks(result.meta.destinations, result.meta.ask));
84
+ }
81
85
  return answered;
82
86
  }
83
87
 
@@ -119,8 +123,26 @@ export function registerGapReport(program) {
119
123
  );
120
124
  }
121
125
 
126
+ if (result.data.destinations && result.data.ask) {
127
+ emit(...destinationBlocks(result.data.destinations, result.data.ask));
128
+ }
129
+
122
130
  if (isFailure) process.exitCode = 1;
123
131
  return answered;
124
132
  },
125
133
  });
126
134
  }
135
+
136
+ /**
137
+ * The destinations a report can go to, then the line telling an agent to ask
138
+ * the person (architecture:cli-surface INV36).
139
+ * @param {import('../../../api/gap-report/gap-report.type.mjs').GapReportDestination[]} destinations
140
+ * @param {string} ask
141
+ */
142
+ function destinationBlocks(destinations, ask) {
143
+ return [
144
+ section('Destinations'),
145
+ records(destinations, {fields: ['to', 'default', 'issuesUrl']}),
146
+ text(ask),
147
+ ];
148
+ }
@@ -331,3 +331,82 @@ describe('gap-report control docs', () => {
331
331
  ).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
332
332
  });
333
333
  });
334
+
335
+ describe('gap-report destinations in text', () => {
336
+ it('lists the destinations and tells the agent to ask the person', async () => {
337
+ const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-gap-dest-'));
338
+ try {
339
+ fs.writeFileSync(
340
+ path.join(cwd, 'package.json'),
341
+ JSON.stringify({name: 'fixture-app'}),
342
+ );
343
+ const pkg = path.join(cwd, 'node_modules', '@test', 'widgets');
344
+ fs.mkdirSync(pkg, {recursive: true});
345
+ fs.writeFileSync(
346
+ path.join(pkg, 'package.json'),
347
+ JSON.stringify({name: '@test/widgets', version: '1.0.0'}),
348
+ );
349
+ fs.writeFileSync(
350
+ path.join(pkg, 'astryx.integration.mjs'),
351
+ "export default {issuesUrl: 'https://tracker.example/widgets'};\n",
352
+ );
353
+ fs.writeFileSync(
354
+ path.join(cwd, 'astryx.config.mjs'),
355
+ `export default {
356
+ integrations: ['@test/widgets'],
357
+ gapReport: {audience: 'internal', handle: () => ({status: 'filed', message: 'shared'})},
358
+ };\n`,
359
+ );
360
+
361
+ const listed = await runCli(['gap-report', '--list-categories'], {cwd});
362
+ expect(listed.status).toBe(0);
363
+ expect(listed.stdout).toContain('Destinations');
364
+ expect(listed.stdout).toMatch(/^default:\s+true$/m);
365
+ expect(listed.stdout).toMatch(/^to:\s+@test\/widgets$/m);
366
+ expect(listed.stdout).toMatch(
367
+ /^issuesUrl:\s+https:\/\/tracker\.example\/widgets$/m,
368
+ );
369
+ expect(listed.stdout).toMatch(/ask the person/i);
370
+
371
+ const filed = await runCli(
372
+ [
373
+ 'gap-report',
374
+ 'Button',
375
+ '--category',
376
+ 'docs_gap',
377
+ '--reason',
378
+ 'Need a keyboard example',
379
+ ],
380
+ {cwd},
381
+ );
382
+ expect(filed.status).toBe(0);
383
+ expect(filed.stdout).toContain('Destinations');
384
+ expect(filed.stdout).toMatch(/ask the person/i);
385
+
386
+ const chosen = await runCli(
387
+ [
388
+ 'gap-report',
389
+ 'Button',
390
+ '--category',
391
+ 'docs_gap',
392
+ '--reason',
393
+ 'Need a keyboard example',
394
+ '--to',
395
+ '@test/widgets',
396
+ '--json',
397
+ ],
398
+ {cwd},
399
+ );
400
+ expect(chosen.status).toBe(0);
401
+ expect(JSON.parse(chosen.stdout).data.deliveries).toEqual([
402
+ expect.objectContaining({
403
+ handler: 'issuesUrl',
404
+ status: 'routed_only',
405
+ url: 'https://tracker.example/widgets',
406
+ }),
407
+ ]);
408
+ } finally {
409
+ fs.rmSync(cwd, {recursive: true, force: true});
410
+ }
411
+ });
412
+ });
@@ -0,0 +1,85 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file CommandDoc for `astryx integration check`.
5
+ */
6
+
7
+ /** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
8
+ export const doc = {
9
+ type: 'command',
10
+ name: 'integration check',
11
+ displayName: 'astryx integration check',
12
+ namespace: 'cli/commands',
13
+ summary:
14
+ "The CI check for an integration package's own build: every source check, run in continuous integration or a typecheck script, against the package in the current folder",
15
+ description:
16
+ 'Takes no package argument: it runs the four `doctor integration` checks, ' +
17
+ '`validate`, `components`, `templates`, and `docs`, against the integration ' +
18
+ 'package in the current folder, which is where its own build runs it. It prints ' +
19
+ 'each result as that check ' +
20
+ 'prints it, then a summary with the errors, warnings, and skipped work of each, ' +
21
+ 'and exits 1 when any of the four would exit 1 on its own. With `--strict` it ' +
22
+ 'also exits 1 on any warning and on any check, or comparison within a check, ' +
23
+ 'that did not run, such as a package with no `astryx.integration.*` or a ' +
24
+ 'comparison skipped because the project has no TypeScript, or prop types not ' +
25
+ 'judged because its TypeScript is older than 4.8: it adds no check, ' +
26
+ 'and lists each of those again as an error, after the checks, in their own ' +
27
+ 'issue format. That is the line ' +
28
+ "for the package's own build, so its docs, types, and links stay in sync: run " +
29
+ 'it as a `ci` step, or add ' +
30
+ '`"typecheck": "tsc --noEmit && astryx integration check --strict"` to the ' +
31
+ 'scripts in package.json. Its exit codes and JSON are a contract for the builds ' +
32
+ 'that run it: a new check, or a new failure code, joins only in a minor release ' +
33
+ 'that names it in the release notes. A patch can still ship a Core component, ' +
34
+ 'template, or CLI topic whose name conflicts with one of yours. Run ' +
35
+ '`integration check` on every build; run ' +
36
+ '`integration verify` before you publish, to check that the packed package ' +
37
+ 'works in an app. To check an installed integration by name, run the ' +
38
+ '`doctor integration` subcommands with its package name.',
39
+ fn: 'integrationCheck',
40
+ options: [
41
+ {
42
+ flag: '--strict',
43
+ param: 'options.strict',
44
+ description:
45
+ 'Also exit 1 on any warning and on any check that did not run. A new check or failure code joins only in a minor release, named in the release notes.',
46
+ },
47
+ ],
48
+ examples: [
49
+ {
50
+ label:
51
+ 'In CI, as the typecheck script: add "typecheck": "tsc --noEmit && astryx integration check --strict" to package.json',
52
+ cli: 'integration check --strict',
53
+ },
54
+ {
55
+ label: 'Errors only, while you fix the warnings a package already has',
56
+ cli: 'integration check',
57
+ },
58
+ {
59
+ label: 'Read the result as JSON',
60
+ cli: 'integration check --strict --json',
61
+ },
62
+ {
63
+ label:
64
+ 'Before you publish: check that the packed package works in an app',
65
+ cli: 'integration verify',
66
+ },
67
+ ],
68
+ exitCodes: [
69
+ {
70
+ code: 0,
71
+ when: 'no check fails on its own; with --strict, also no warning, and every check ran',
72
+ },
73
+ {
74
+ code: 1,
75
+ when: 'a check fails on its own (an error); with --strict, also any warning, or a check that did not run',
76
+ },
77
+ ],
78
+ related: [
79
+ 'integration verify',
80
+ 'doctor integration validate',
81
+ 'doctor integration components',
82
+ 'doctor integration templates',
83
+ 'doctor integration docs',
84
+ ],
85
+ };