@astryxdesign/cli 0.7.2-canary.07f97c6 → 0.7.2-canary.081ccea

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 (299) hide show
  1. package/README.md +74 -73
  2. package/api/build/help/help.mjs +1 -1
  3. package/api/component/_adapter.d.mts +72 -1
  4. package/api/component/_adapter.mjs +209 -7
  5. package/api/component/component.mjs +82 -15
  6. package/api/component/component.test.mjs +80 -0
  7. package/api/component/doc-links.test.mjs +386 -0
  8. package/api/component/integration-export-name.test.mjs +644 -0
  9. package/api/component/list/list.mjs +42 -4
  10. package/api/discover/_adapter.d.mts +119 -12
  11. package/api/discover/_adapter.mjs +449 -10
  12. package/api/discover/_adapter.test.mjs +599 -17
  13. package/api/discover/_catalog-view.d.mts +16 -5
  14. package/api/discover/_catalog-view.mjs +32 -8
  15. package/api/discover/detail/doc/doc.mjs +9 -1
  16. package/api/discover/discover.d.mts +11 -0
  17. package/api/discover/discover.doc.mjs +7 -6
  18. package/api/discover/discover.mjs +107 -19
  19. package/api/discover/discover.type.d.mts +18 -7
  20. package/api/discover/discover.type.mjs +15 -7
  21. package/api/discover/list/list.d.mts +4 -3
  22. package/api/discover/list/list.mjs +17 -10
  23. package/api/docs/_adapter.d.mts +74 -0
  24. package/api/docs/_adapter.mjs +550 -14
  25. package/api/docs/integration-tree.test.mjs +22 -0
  26. package/api/docs/integrationDocs.test.mjs +124 -0
  27. package/api/docs/list/list.mjs +12 -2
  28. package/api/doctor/doctor.mjs +27 -3
  29. package/api/doctor/doctor.test.mjs +43 -0
  30. package/api/doctor/theme-checks.mjs +1 -1
  31. package/api/doctor/theme-checks.test.mjs +136 -0
  32. package/api/gap-report/gap-report.d.mts +3 -0
  33. package/api/gap-report/gap-report.doc.mjs +11 -3
  34. package/api/gap-report/gap-report.mjs +219 -52
  35. package/api/gap-report/gap-report.test.mjs +233 -0
  36. package/api/gap-report/gap-report.type.d.mts +41 -0
  37. package/api/gap-report/gap-report.type.mjs +18 -0
  38. package/api/index.d.mts +2 -0
  39. package/api/index.mjs +2 -0
  40. package/api/init/run/run.mjs +2 -2
  41. package/api/integration/_adapter.d.mts +45 -0
  42. package/api/integration/_adapter.mjs +112 -0
  43. package/api/integration/add-contribution.component-names.test.mjs +66 -0
  44. package/api/integration/add-contribution.mjs +8 -4
  45. package/api/integration/add-contribution.test.mjs +4 -2
  46. package/api/integration/authoring-checks.mjs +108 -4
  47. package/api/integration/authoring-checks.test.mjs +808 -0
  48. package/api/integration/authoring-checks.type.d.mts +143 -0
  49. package/api/integration/authoring-checks.type.mjs +74 -2
  50. package/api/integration/check/check.d.mts +96 -0
  51. package/api/integration/check/check.mjs +357 -0
  52. package/api/integration/check/check.test.mjs +489 -0
  53. package/api/integration/integration-check.type.d.mts +118 -0
  54. package/api/integration/integration-check.type.mjs +84 -0
  55. package/api/integration/integrationCheck.doc.d.mts +10 -0
  56. package/api/integration/integrationCheck.doc.mjs +73 -0
  57. package/api/integration/integrationComponentConflicts.doc.mjs +45 -6
  58. package/api/integration/integrationDocConflicts.doc.mjs +22 -5
  59. package/api/integration/pack-check.mjs +357 -114
  60. package/api/integration/pack-check.test.mjs +726 -0
  61. package/api/integration/validate-integration-fixes.test.mjs +67 -0
  62. package/api/integration/validate-integration.mjs +36 -3
  63. package/api/integration/validate-integration.test.mjs +88 -8
  64. package/api/integration/validate-integration.type.d.mts +8 -0
  65. package/api/integration/validate-integration.type.mjs +12 -1
  66. package/api/integration/validateIntegration.doc.mjs +19 -3
  67. package/api/search/search.d.mts +81 -12
  68. package/api/search/search.domain-priority.test.mjs +108 -18
  69. package/api/search/search.integration-check.test.mjs +24 -0
  70. package/api/search/search.mjs +611 -54
  71. package/api/search/search.test.mjs +175 -0
  72. package/api/swizzle/copy/copy.mjs +28 -14
  73. package/api/template/template.test.mjs +120 -3
  74. package/api/theme/build/build.family.test.mjs +64 -0
  75. package/api/theme/build/build.mjs +180 -24
  76. package/api/theme/themeBuild.doc.mjs +4 -4
  77. package/api/upgrade/_adapter.d.mts +40 -2
  78. package/api/upgrade/_adapter.mjs +117 -4
  79. package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
  80. package/api/upgrade/run/run.mjs +30 -1
  81. package/api/upgrade/status/status.d.mts +21 -5
  82. package/api/upgrade/status/status.mjs +45 -8
  83. package/api/upgrade/upgrade.doc.mjs +5 -3
  84. package/api/upgrade/upgrade.type.d.mts +23 -0
  85. package/api/upgrade/upgrade.type.mjs +16 -1
  86. package/assets/codemods/runner.mjs +7 -1
  87. package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
  88. package/assets/codemods/transforms/next/index.mjs +11 -1
  89. package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
  90. package/assets/discover/official-packages.json +367 -0
  91. package/assets/docs/README.md +10 -0
  92. package/assets/docs/author-a-theme.doc.mjs +3 -3
  93. package/assets/docs/browser-support.doc.mjs +1 -1
  94. package/assets/docs/getting-started.doc.mjs +3 -3
  95. package/assets/docs/styling-overview.doc.mjs +1 -1
  96. package/assets/docs/theme.doc.dense.mjs +1 -1
  97. package/assets/docs/theme.doc.mjs +2 -2
  98. package/assets/docs/theme.doc.zh.mjs +1 -1
  99. package/assets/docs/tree/add-a-component.doc.mjs +11 -1
  100. package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
  101. package/assets/docs/tree/add-a-topic.doc.mjs +11 -8
  102. package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
  103. package/assets/docs/tree/block-template.doc.mjs +8 -20
  104. package/assets/docs/tree/build-the-template.doc.mjs +1 -1
  105. package/assets/docs/tree/check-the-props.doc.mjs +201 -0
  106. package/assets/docs/tree/check-your-docs.doc.mjs +65 -7
  107. package/assets/docs/tree/checks.doc.mjs +26 -18
  108. package/assets/docs/tree/codemods.doc.mjs +4 -4
  109. package/assets/docs/tree/component-family.doc.mjs +8 -6
  110. package/assets/docs/tree/component-imports.doc.mjs +10 -2
  111. package/assets/docs/tree/components.doc.mjs +1 -1
  112. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +30 -21
  113. package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
  114. package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
  115. package/assets/docs/tree/docs.doc.mjs +3 -3
  116. package/assets/docs/tree/document-the-template.doc.mjs +1 -1
  117. package/assets/docs/tree/document-the-theme.doc.mjs +3 -3
  118. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  119. package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
  120. package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
  121. package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
  122. package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
  123. package/assets/docs/tree/integrations.doc.mjs +8 -0
  124. package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
  125. package/assets/docs/tree/layout.doc.mjs +6 -6
  126. package/assets/docs/tree/links.doc.mjs +6 -5
  127. package/assets/docs/tree/migration-setup.doc.mjs +3 -2
  128. package/assets/docs/tree/migration-verification.doc.mjs +0 -1
  129. package/assets/docs/tree/migration.doc.mjs +0 -1
  130. package/assets/docs/tree/package-and-test.doc.mjs +1 -1
  131. package/assets/docs/tree/page-template.doc.mjs +4 -8
  132. package/assets/docs/tree/publishing.doc.mjs +4 -4
  133. package/assets/docs/tree/quick-start.doc.mjs +38 -22
  134. package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
  135. package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
  136. package/assets/docs/tree/sections-and-placement.doc.mjs +6 -8
  137. package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
  138. package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
  139. package/assets/docs/tree/single-component.doc.mjs +15 -6
  140. package/assets/docs/tree/start-a-template.doc.mjs +3 -3
  141. package/assets/docs/tree/subcomponent.doc.mjs +6 -6
  142. package/assets/docs/tree/template-assets.doc.mjs +2 -2
  143. package/assets/docs/tree/template-doc-overview.doc.mjs +5 -16
  144. package/assets/docs/tree/template-fonts.doc.mjs +1 -1
  145. package/assets/docs/tree/template-icons.doc.mjs +1 -1
  146. package/assets/docs/tree/template-images-media.doc.mjs +1 -1
  147. package/assets/docs/tree/template-styles.doc.mjs +2 -2
  148. package/assets/docs/tree/templates.doc.mjs +1 -1
  149. package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
  150. package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
  151. package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
  152. package/assets/docs/tree/troubleshooting.doc.mjs +16 -8
  153. package/assets/docs/tree/type-scale.doc.mjs +3 -3
  154. package/assets/docs/tree/upgrading.doc.mjs +4 -4
  155. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
  156. package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
  157. package/assets/docs/tree/versioning.doc.mjs +7 -6
  158. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
  159. package/assets/docs/use-a-theme.doc.mjs +2 -2
  160. package/assets/docs/working-with-ai.doc.mjs +43 -4
  161. package/assets/theme.template.ts +1 -1
  162. package/authoring/codemod/codemod.doc.mjs +7 -3
  163. package/authoring/config/config.doc.mjs +9 -6
  164. package/authoring/config/type.ts +4 -2
  165. package/authoring/discover/discover.doc.mjs +1 -1
  166. package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
  167. package/authoring/doctypes/command/command.doc.mjs +14 -12
  168. package/authoring/doctypes/component/component.doc.mjs +30 -27
  169. package/authoring/doctypes/component/type.ts +21 -8
  170. package/authoring/doctypes/enum/enum.doc.mjs +7 -4
  171. package/authoring/doctypes/function/function.doc.mjs +9 -8
  172. package/authoring/doctypes/hook/hook.doc.mjs +5 -4
  173. package/authoring/doctypes/hook/type.ts +4 -0
  174. package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
  175. package/authoring/doctypes/reference/reference.doc.mjs +11 -10
  176. package/authoring/doctypes/schema/schema.doc.mjs +9 -9
  177. package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
  178. package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
  179. package/authoring/doctypes/template/parse.d.mts +6 -2
  180. package/authoring/doctypes/template/parse.mjs +3 -1
  181. package/authoring/doctypes/template/template.doc.mjs +3 -3
  182. package/authoring/doctypes/template/type.ts +22 -0
  183. package/authoring/doctypes/theme/theme.doc.mjs +2 -2
  184. package/authoring/gap-report/gap-report.doc.mjs +2 -2
  185. package/authoring/identity/identity.doc.mjs +3 -3
  186. package/authoring/index.d.ts +1 -0
  187. package/authoring/integration/integration.doc.mjs +12 -4
  188. package/authoring/integration/parse.test.mjs +10 -0
  189. package/authoring/integration/schema.d.mts +2 -0
  190. package/authoring/integration/schema.mjs +1 -0
  191. package/authoring/integration/type.ts +4 -0
  192. package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
  193. package/clients/cli/commands/build-theme.mjs +1 -1
  194. package/clients/cli/commands/build-theme.path-safety.test.mjs +224 -6
  195. package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
  196. package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
  197. package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
  198. package/clients/cli/commands/discover.doc.mjs +1 -1
  199. package/clients/cli/commands/discover.mjs +144 -93
  200. package/clients/cli/commands/discover.no-source.test.mjs +447 -33
  201. package/clients/cli/commands/discover.sources.test.mjs +20 -1
  202. package/clients/cli/commands/doctor-integration-components.doc.mjs +18 -4
  203. package/clients/cli/commands/doctor-integration-docs.doc.mjs +19 -5
  204. package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
  205. package/clients/cli/commands/doctor-integration.test.mjs +884 -0
  206. package/clients/cli/commands/doctor.mjs +281 -5
  207. package/clients/cli/commands/gap-report.doc.mjs +14 -2
  208. package/clients/cli/commands/gap-report.mjs +24 -2
  209. package/clients/cli/commands/gap-report.test.mjs +79 -0
  210. package/clients/cli/commands/integration-authoring.test.mjs +46 -0
  211. package/clients/cli/commands/integration-check.doc.mjs +85 -0
  212. package/clients/cli/commands/integration-check.test.mjs +411 -0
  213. package/clients/cli/commands/integration.doc.mjs +6 -2
  214. package/clients/cli/commands/integration.mjs +116 -5
  215. package/clients/cli/commands/json-contract.test.mjs +5 -1
  216. package/clients/cli/commands/setup-nudge.test.mjs +79 -1
  217. package/clients/cli/commands/swizzle.mjs +5 -3
  218. package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
  219. package/clients/cli/commands/text-json-parity.test.mjs +5 -0
  220. package/clients/cli/commands/theme-build.doc.mjs +2 -2
  221. package/clients/cli/commands/upgrade.doc.mjs +14 -0
  222. package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
  223. package/clients/cli/index.mjs +30 -5
  224. package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
  225. package/foundation/agent-docs/agent-doc-state.mjs +38 -0
  226. package/foundation/agent-docs/agent-docs.d.mts +2 -1
  227. package/foundation/agent-docs/agent-docs.mjs +8 -6
  228. package/foundation/config/project.mjs +82 -0
  229. package/foundation/discovery/authoring-self-docs.mjs +2 -1
  230. package/foundation/discovery/component-discovery.d.mts +190 -10
  231. package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
  232. package/foundation/discovery/component-discovery.mjs +864 -56
  233. package/foundation/discovery/component-discovery.test.mjs +96 -0
  234. package/foundation/discovery/component-replacement.mjs +18 -0
  235. package/foundation/discovery/component-replacement.test.mjs +40 -0
  236. package/foundation/discovery/copied-passages.d.mts +216 -0
  237. package/foundation/discovery/copied-passages.mjs +720 -0
  238. package/foundation/discovery/copied-passages.test.mjs +124 -0
  239. package/foundation/discovery/doc-consistency.d.mts +34 -0
  240. package/foundation/discovery/doc-consistency.mjs +513 -0
  241. package/foundation/discovery/doc-consistency.test.mjs +347 -0
  242. package/foundation/discovery/doc-fluff.d.mts +112 -0
  243. package/foundation/discovery/doc-fluff.mjs +328 -0
  244. package/foundation/discovery/doc-fluff.test.mjs +142 -0
  245. package/foundation/discovery/doc-types.d.mts +157 -0
  246. package/foundation/discovery/doc-types.mjs +1231 -0
  247. package/foundation/discovery/doc-types.test.mjs +744 -0
  248. package/foundation/discovery/docs-discovery.d.mts +88 -0
  249. package/foundation/discovery/docs-discovery.mjs +83 -2
  250. package/foundation/discovery/integration-doc-files.d.mts +22 -0
  251. package/foundation/discovery/integration-doc-files.mjs +231 -0
  252. package/foundation/discovery/integration-doc-files.test.mjs +246 -0
  253. package/foundation/discovery/module-exports.d.mts +27 -0
  254. package/foundation/discovery/module-exports.mjs +356 -31
  255. package/foundation/discovery/module-exports.test.mjs +172 -0
  256. package/foundation/discovery/package-tsconfig.d.mts +14 -0
  257. package/foundation/discovery/package-tsconfig.mjs +228 -0
  258. package/foundation/discovery/package-tsconfig.test.mjs +210 -0
  259. package/foundation/discovery/project-typescript.d.mts +32 -0
  260. package/foundation/discovery/project-typescript.mjs +89 -0
  261. package/foundation/discovery/prop-drift.d.mts +297 -0
  262. package/foundation/discovery/prop-drift.mjs +2428 -0
  263. package/foundation/discovery/prop-drift.test.mjs +2337 -0
  264. package/foundation/discovery/stray-pointers.d.mts +52 -0
  265. package/foundation/discovery/stray-pointers.mjs +293 -0
  266. package/foundation/discovery/stray-pointers.test.mjs +86 -0
  267. package/foundation/discovery/template-adapter.mjs +74 -5
  268. package/foundation/discovery/type-match.d.mts +53 -0
  269. package/foundation/discovery/type-match.mjs +660 -0
  270. package/foundation/discovery/type-match.test.mjs +169 -0
  271. package/foundation/discovery/type-text.d.mts +68 -0
  272. package/foundation/discovery/type-text.mjs +658 -0
  273. package/foundation/discovery/type-text.test.mjs +196 -0
  274. package/foundation/discovery/unresolved-references.d.mts +62 -0
  275. package/foundation/discovery/unresolved-references.mjs +790 -0
  276. package/foundation/discovery/unresolved-references.test.mjs +567 -0
  277. package/foundation/doc-compiler/doc-loads.test.mjs +31 -1
  278. package/foundation/doc-compiler/inputs.mjs +23 -0
  279. package/foundation/doc-compiler/inputs.test.mjs +0 -1
  280. package/foundation/doc-compiler/links.d.mts +41 -5
  281. package/foundation/doc-compiler/links.mjs +167 -28
  282. package/foundation/doc-compiler/links.test.mjs +97 -4
  283. package/foundation/doc-compiler/tree.mjs +30 -1
  284. package/foundation/doc-compiler/tree.test.mjs +7 -0
  285. package/foundation/env/package-manager.d.mts +32 -0
  286. package/foundation/env/package-manager.mjs +47 -0
  287. package/foundation/env/package-manager.test.mjs +194 -7
  288. package/foundation/fs/module-loader.d.mts +2 -1
  289. package/foundation/fs/module-loader.mjs +60 -4
  290. package/foundation/fs/module-loader.test.mjs +194 -0
  291. package/foundation/integrations/contribution-inventory.d.mts +11 -0
  292. package/foundation/integrations/contribution-inventory.mjs +56 -3
  293. package/foundation/integrations/issue.ts +6 -0
  294. package/foundation/integrations/validate-contributions.mjs +30 -1
  295. package/foundation/response/response-types.doc.mjs +15 -9
  296. package/foundation/xle/registry.mjs +4 -0
  297. package/foundation/xle/registry.test.mjs +28 -0
  298. package/package.json +11 -11
  299. package/scripts/postinstall.mjs +3 -3
@@ -0,0 +1,411 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx integration check`: every source check in one command, the
5
+ * summary, exit codes with and without `--strict`, and the `--strict`
6
+ * failures, in text and JSON alike.
7
+ */
8
+
9
+ import {afterEach, beforeEach, describe, expect, it} from 'vitest';
10
+ import * as fs from 'node:fs';
11
+ import * as os from 'node:os';
12
+ import * as path from 'node:path';
13
+ import {runCli} from '../../../test-utils/run-cli.mjs';
14
+ import {discoverCoreTemplates} from '../../../foundation/discovery/template-adapter.mjs';
15
+
16
+ /** @type {string} */
17
+ let tmpDir;
18
+
19
+ beforeEach(() => {
20
+ // Under the repository, so the components check resolves Core.
21
+ tmpDir = fs.mkdtempSync(
22
+ path.join(process.cwd(), '.astryx-integration-check-cli-'),
23
+ );
24
+ });
25
+
26
+ afterEach(() => {
27
+ fs.rmSync(tmpDir, {recursive: true, force: true});
28
+ });
29
+
30
+ /**
31
+ * A package whose one page template takes a Core template's id: one warning
32
+ * (`templates` conflict). The doc matches TemplateDoc, so no other check
33
+ * warns about it.
34
+ * @param {{id: string, replaces?: string, extraManifest?: string, dir?: string}} options
35
+ */
36
+ function writePackage({id, replaces, extraManifest = '', dir = tmpDir}) {
37
+ fs.writeFileSync(
38
+ path.join(dir, 'package.json'),
39
+ JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
40
+ );
41
+ fs.writeFileSync(
42
+ path.join(dir, 'astryx.integration.mjs'),
43
+ `export default {templates: './templates'${extraManifest}};\n`,
44
+ );
45
+ fs.mkdirSync(path.join(dir, 'templates'), {recursive: true});
46
+ fs.writeFileSync(
47
+ path.join(dir, 'templates', `${id}.doc.mjs`),
48
+ `export default {type: 'page', name: 'Integration template', displayName: 'Integration template', description: 'fixture'${replaces == null ? '' : `, replaces: ${JSON.stringify(replaces)}`}};\n`,
49
+ );
50
+ fs.writeFileSync(
51
+ path.join(dir, 'templates', `${id}.tsx`),
52
+ 'export default function Fixture() { return null; }\n',
53
+ );
54
+ }
55
+
56
+ async function coreTemplateId() {
57
+ const core = (await discoverCoreTemplates()).find(
58
+ template => template.type === 'page',
59
+ );
60
+ expect(core).toBeDefined();
61
+ return /** @type {{dirName: string}} */ (core).dirName;
62
+ }
63
+
64
+ describe('astryx integration check', () => {
65
+ it('runs validate, components, templates, and docs in order, then a summary, and exits 0 on a warning', async () => {
66
+ writePackage({id: await coreTemplateId()});
67
+
68
+ const run = await runCli(['integration', 'check'], tmpDir);
69
+
70
+ const order = [
71
+ 'Validating integration: @acme/widgets@1.2.3',
72
+ 'Checking integration components: @acme/widgets@1.2.3',
73
+ 'Checking integration templates: @acme/widgets@1.2.3',
74
+ 'Checking integration docs: @acme/widgets@1.2.3',
75
+ 'Integration check: @acme/widgets@1.2.3',
76
+ ].map(line => run.stdout.indexOf(line));
77
+ expect(order.every(index => index >= 0)).toBe(true);
78
+ expect([...order].sort((a, b) => a - b)).toEqual(order);
79
+ expect(run.stdout).toContain('Consider renaming');
80
+ expect(run.stdout).not.toContain('Failing under --strict');
81
+ expect(run.stdout).toContain(
82
+ '[ok] 0 errors, 1 warning, 0 skipped. No check failed;',
83
+ );
84
+ // Each check's output stands apart from the next.
85
+ const lines = run.stdout.split('\n');
86
+ for (const header of [
87
+ 'Checking integration components:',
88
+ 'Checking integration templates:',
89
+ 'Checking integration docs:',
90
+ ]) {
91
+ expect(lines[lines.findIndex(line => line.includes(header)) - 1]).toBe(
92
+ '',
93
+ );
94
+ }
95
+ expect(run.status).toBe(0);
96
+ });
97
+
98
+ it('--strict lists the warning again as an error, after the checks, and exits 1', async () => {
99
+ const id = await coreTemplateId();
100
+ writePackage({id});
101
+
102
+ const run = await runCli(['integration', 'check', '--strict'], tmpDir);
103
+
104
+ expect(run.stdout).toContain(
105
+ 'Integration check: @acme/widgets@1.2.3 (strict)',
106
+ );
107
+ const block = run.stdout.indexOf('Failing under --strict');
108
+ expect(block).toBeGreaterThan(
109
+ run.stdout.indexOf('Checking integration docs:'),
110
+ );
111
+ expect(run.stdout.slice(block)).toMatch(
112
+ /severity: \[fail\]\ncheck: +templates\ncode: +template_id_conflict\n/,
113
+ );
114
+ expect(run.stdout).toContain(
115
+ '[fail] 0 errors, 1 warning, 0 skipped. --strict fails on every warning and on skipped work;',
116
+ );
117
+ expect(run.status).toBe(1);
118
+ });
119
+
120
+ it('--strict prints each finding once: its message above, its code in the failing list', async () => {
121
+ const id = await coreTemplateId();
122
+ writePackage({id});
123
+
124
+ const run = await runCli(['integration', 'check', '--strict'], tmpDir);
125
+ const json = await runCli(
126
+ ['integration', 'check', '--strict', '--json'],
127
+ tmpDir,
128
+ );
129
+ const [failure] = JSON.parse(json.stdout.trim()).data.failures;
130
+
131
+ expect(run.stdout.split(failure.message).length - 1).toBe(1);
132
+ expect(
133
+ run.stdout.slice(run.stdout.indexOf('Failing under --strict')),
134
+ ).toContain('template_id_conflict');
135
+ });
136
+
137
+ it('--json carries each check with its own envelope, the --strict failures, and exits as the text does', async () => {
138
+ const id = await coreTemplateId();
139
+ writePackage({id});
140
+
141
+ const run = await runCli(
142
+ ['integration', 'check', '--strict', '--json'],
143
+ tmpDir,
144
+ );
145
+
146
+ const parsed = JSON.parse(run.stdout.trim());
147
+ expect(parsed.type).toBe('integration.check');
148
+ expect(parsed.data).toMatchObject({
149
+ validated: true,
150
+ name: '@acme/widgets',
151
+ version: '1.2.3',
152
+ strict: true,
153
+ errors: 0,
154
+ warnings: 1,
155
+ skipped: [],
156
+ failed: true,
157
+ });
158
+ expect(parsed.data.checks.map(check => check.check)).toEqual([
159
+ 'validate',
160
+ 'components',
161
+ 'templates',
162
+ 'docs',
163
+ ]);
164
+ const templates = parsed.data.checks[2];
165
+ expect(templates).toMatchObject({
166
+ check: 'templates',
167
+ errors: 0,
168
+ warnings: 1,
169
+ skipped: [],
170
+ failed: false,
171
+ response: {
172
+ type: 'integration.template-conflicts',
173
+ data: {conflicts: [expect.objectContaining({id, severity: 'warning'})]},
174
+ },
175
+ });
176
+ expect(parsed.data.failures).toEqual([
177
+ {
178
+ check: 'templates',
179
+ severity: 'error',
180
+ code: 'template_id_conflict',
181
+ message: templates.response.data.conflicts[0].message,
182
+ },
183
+ ]);
184
+ expect(run.status).toBe(1);
185
+ });
186
+
187
+ it('exits 1 without --strict when one check fails on its own, and lists no failures', async () => {
188
+ writePackage({id: 'acme-app-shell', replaces: 'missing-core-shell'});
189
+
190
+ const text = await runCli(['integration', 'check'], tmpDir);
191
+ const json = await runCli(['integration', 'check', '--json'], tmpDir);
192
+
193
+ expect(text.stdout).toContain('missing_template_replacement_target');
194
+ expect(text.stdout).toMatch(
195
+ /\[fail\] [1-9]\d* errors?, .*Address the items marked \[fail\] above\./,
196
+ );
197
+ expect(text.stdout).not.toContain('Failing under --strict');
198
+ expect(JSON.parse(json.stdout.trim()).data).toMatchObject({
199
+ strict: false,
200
+ failures: [],
201
+ failed: true,
202
+ });
203
+ expect(text.status).toBe(1);
204
+ expect(json.status).toBe(1);
205
+ });
206
+
207
+ it('counts a package with no manifest as skipped work: exit 0, and 1 with --strict', async () => {
208
+ fs.writeFileSync(
209
+ path.join(tmpDir, 'package.json'),
210
+ JSON.stringify({name: '@acme/plain', version: '1.0.0'}),
211
+ );
212
+
213
+ const loose = await runCli(['integration', 'check'], tmpDir);
214
+ expect(loose.stdout).toContain(
215
+ "Nothing was checked: no astryx.integration.* found next to package.json. Run this command in an integration package's folder.",
216
+ );
217
+ // One cause, however many checks it stops: counted once.
218
+ expect(loose.stdout).toContain('[ok] 0 errors, 0 warnings, 1 skipped.');
219
+ expect(loose.status).toBe(0);
220
+
221
+ const strict = await runCli(
222
+ ['integration', 'check', '--strict', '--json'],
223
+ tmpDir,
224
+ );
225
+ const {data} = JSON.parse(strict.stdout.trim());
226
+ expect(data).toMatchObject({validated: false, errors: 0, failed: true});
227
+ // One cause, however many checks it stops: listed once.
228
+ expect(data.failures).toEqual([
229
+ {
230
+ check: 'validate',
231
+ severity: 'error',
232
+ code: 'missing_manifest',
233
+ message:
234
+ 'No astryx.integration.* found next to package.json, so nothing was checked.',
235
+ },
236
+ ]);
237
+ expect(strict.status).toBe(1);
238
+ });
239
+
240
+ it('exits 1 for no package.json, as validate does', async () => {
241
+ const empty = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-no-pkg-'));
242
+ try {
243
+ const run = await runCli(['integration', 'check'], empty);
244
+ expect(run.stdout).toContain(
245
+ 'Nothing was checked: no package.json found.',
246
+ );
247
+ expect(run.stdout).toContain('Integration check: (no package.json)');
248
+ expect(run.stdout).toContain(
249
+ '[fail] 1 error, 0 warnings, 0 skipped. No package.json was found here, so nothing was checked.',
250
+ );
251
+ expect(run.stdout).not.toContain('marked [fail] above');
252
+ expect(run.status).toBe(1);
253
+ } finally {
254
+ fs.rmSync(empty, {recursive: true, force: true});
255
+ }
256
+ });
257
+
258
+ it('states in its help that it is the CI check, the line to add, and what --strict promises', async () => {
259
+ const run = await runCli(['integration', 'check', '--help'], tmpDir);
260
+
261
+ expect(run.stdout).toContain(
262
+ "The CI check for an integration package's own build",
263
+ );
264
+ expect(run.stdout).toContain(
265
+ '"typecheck": "tsc --noEmit && astryx integration check --strict"',
266
+ );
267
+ expect(run.stdout).toContain(
268
+ 'A new check or failure code joins only in a minor release, named in the release notes.',
269
+ );
270
+ expect(run.stdout).toContain('integration verify');
271
+ expect(run.stdout).toContain('against the package in the current folder');
272
+ expect(run.stdout).not.toContain('[package]');
273
+ });
274
+
275
+ it('takes no package name: one passed is an error, not a check of the current folder', async () => {
276
+ writePackage({id: 'acme-page'});
277
+
278
+ const run = await runCli(['integration', 'check', '@acme/widgets'], tmpDir);
279
+
280
+ expect(run.stderr).toContain('too many arguments');
281
+ expect(run.stdout).not.toContain('Integration check:');
282
+ expect(run.status).toBe(1);
283
+ });
284
+ });
285
+
286
+ describe('a copied passage', () => {
287
+ const passage =
288
+ 'Themes cannot style the layer that holds a menu or a popover, so a menu ' +
289
+ 'keeps the default surface color until the next release adds a token for it.';
290
+
291
+ function writeCopiedDocs() {
292
+ fs.writeFileSync(
293
+ path.join(tmpDir, 'package.json'),
294
+ JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
295
+ );
296
+ fs.writeFileSync(
297
+ path.join(tmpDir, 'astryx.integration.mjs'),
298
+ `export default {docs: './docs'};\n`,
299
+ );
300
+ fs.mkdirSync(path.join(tmpDir, 'docs'));
301
+ for (const name of ['acme-setup', 'acme-menus']) {
302
+ const doc = {
303
+ type: 'generic',
304
+ name,
305
+ title: 'Fixture',
306
+ description: 'Fixture topic.',
307
+ sections: [
308
+ {title: 'Overview', content: [{type: 'prose', text: passage}]},
309
+ ],
310
+ };
311
+ fs.writeFileSync(
312
+ path.join(tmpDir, 'docs', `${name}.doc.mjs`),
313
+ `export default ${JSON.stringify(doc)};\n`,
314
+ );
315
+ }
316
+ }
317
+
318
+ it('keeps doctor integration docs at exit 0, and fails integration check --strict', async () => {
319
+ writeCopiedDocs();
320
+
321
+ const doctor = await runCli(['doctor', 'integration', 'docs'], tmpDir);
322
+ expect(doctor.status).toBe(0);
323
+ expect(doctor.stdout).toContain('1 copied passage(s)');
324
+
325
+ const loose = await runCli(['integration', 'check'], tmpDir);
326
+ expect(loose.status).toBe(0);
327
+
328
+ const strict = await runCli(['integration', 'check', '--strict'], tmpDir);
329
+ expect(strict.status).toBe(1);
330
+ expect(strict.stdout).toContain('copied_passage');
331
+ });
332
+ });
333
+
334
+ describe('a padding phrase', () => {
335
+ it('keeps doctor integration docs at exit 0, and fails integration check --strict', async () => {
336
+ fs.writeFileSync(
337
+ path.join(tmpDir, 'package.json'),
338
+ JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
339
+ );
340
+ fs.writeFileSync(
341
+ path.join(tmpDir, 'astryx.integration.mjs'),
342
+ `export default {docs: './docs'};\n`,
343
+ );
344
+ fs.mkdirSync(path.join(tmpDir, 'docs'));
345
+ const doc = {
346
+ type: 'generic',
347
+ name: 'acme-setup',
348
+ title: 'Fixture',
349
+ description: 'Fixture topic.',
350
+ sections: [
351
+ {
352
+ title: 'Overview',
353
+ content: [{type: 'prose', text: 'In order to start, run the setup.'}],
354
+ },
355
+ ],
356
+ };
357
+ fs.writeFileSync(
358
+ path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
359
+ `export default ${JSON.stringify(doc)};\n`,
360
+ );
361
+
362
+ const doctor = await runCli(['doctor', 'integration', 'docs'], tmpDir);
363
+ expect(doctor.status).toBe(0);
364
+ expect(doctor.stdout).toContain('1 fluff finding(s)');
365
+
366
+ const strict = await runCli(['integration', 'check', '--strict'], tmpDir);
367
+ expect(strict.status).toBe(1);
368
+ expect(strict.stdout).toContain('doc_fluff');
369
+ });
370
+ });
371
+
372
+ describe('a stray doc pointer', () => {
373
+ it('keeps doctor integration docs at exit 0, and fails integration check --strict', async () => {
374
+ fs.writeFileSync(
375
+ path.join(tmpDir, 'package.json'),
376
+ JSON.stringify({name: '@acme/widgets', version: '1.2.3'}),
377
+ );
378
+ fs.writeFileSync(
379
+ path.join(tmpDir, 'astryx.integration.mjs'),
380
+ `export default {docs: './docs'};\n`,
381
+ );
382
+ fs.mkdirSync(path.join(tmpDir, 'docs'));
383
+ const doc = {
384
+ type: 'generic',
385
+ name: 'acme-setup',
386
+ title: 'Fixture',
387
+ description: 'Fixture topic.',
388
+ sections: [
389
+ {
390
+ title: 'Overview',
391
+ content: [
392
+ {type: 'prose', text: 'The theme is in `astryx docs theme`.'},
393
+ ],
394
+ },
395
+ ],
396
+ };
397
+ fs.writeFileSync(
398
+ path.join(tmpDir, 'docs', 'acme-setup.doc.mjs'),
399
+ `export default ${JSON.stringify(doc)};\n`,
400
+ );
401
+
402
+ const doctor = await runCli(['doctor', 'integration', 'docs'], tmpDir);
403
+ expect(doctor.status).toBe(0);
404
+ expect(doctor.stdout).toContain('1 stray doc pointer(s)');
405
+ expect(doctor.stdout).toContain('{@link @astryxdesign/cli:generic:theme}');
406
+
407
+ const strict = await runCli(['integration', 'check', '--strict'], tmpDir);
408
+ expect(strict.status).toBe(1);
409
+ expect(strict.stdout).toContain('stray_doc_pointer');
410
+ });
411
+ });
@@ -8,13 +8,17 @@ export const doc = {
8
8
  namespace: 'cli/commands',
9
9
  summary: 'Author and verify an Astryx integration package',
10
10
  description:
11
- 'Add contributions to your package, then check the packed package the way an app receives it. The guides start at {@link namespace:integrations}.',
12
- subcommands: ['add', 'verify', 'pack'],
11
+ 'Add contributions to your package, check them on every build with `integration check --strict`, then check the packed package the way an app receives it. The guides start at {@link namespace:integrations}.',
12
+ subcommands: ['add', 'check', 'verify', 'pack'],
13
13
  examples: [
14
14
  {
15
15
  label: 'Add a component',
16
16
  cli: 'astryx integration add component AcmeWidget',
17
17
  },
18
+ {
19
+ label: 'Check the package in CI, as part of its build',
20
+ cli: 'astryx integration check --strict',
21
+ },
18
22
  {
19
23
  label: 'Check the package before publishing',
20
24
  cli: 'astryx integration verify',
@@ -3,18 +3,22 @@
3
3
  /** @file CLI bindings for integration authoring and package verification. */
4
4
 
5
5
  import {integrationAdd} from '../../../api/integration/add-contribution.mjs';
6
+ import {integrationCheck} from '../../../api/integration/check/check.mjs';
6
7
  import {integrationPackCheck} from '../../../api/integration/pack-check.mjs';
7
8
  import {jsonOut} from '../../../foundation/response/json.mjs';
8
9
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
9
10
  import {NO_RESULT_SET} from '../../../foundation/debug/index.mjs';
10
- import {emit, list, section, text} from '../formatters/index.mjs';
11
+ import {emit, list, records, section, text} from '../formatters/index.mjs';
11
12
  import {cliError} from '../lib/cli-error.mjs';
12
13
  import {defineCommand} from '../lib/define-command.mjs';
13
14
  import {doc as integrationGroup} from './integration.doc.mjs';
14
15
  import {doc as integrationAddCommand} from './integration-add.doc.mjs';
16
+ import {doc as integrationCheckCommand} from './integration-check.doc.mjs';
15
17
  import {doc as integrationVerifyCommand} from './integration-verify.doc.mjs';
16
18
  import {doc as integrationPackCommand} from './integration-pack.doc.mjs';
17
19
  import {doc as integrationAddFn} from '../../../api/integration/integrationAdd.doc.mjs';
20
+ import {doc as integrationCheckFn} from '../../../api/integration/integrationCheck.doc.mjs';
21
+ import {printIntegrationCheckResponse} from './doctor.mjs';
18
22
  import {doc as integrationPackCheckFn} from '../../../api/integration/integrationPackCheck.doc.mjs';
19
23
 
20
24
  /**
@@ -75,10 +79,16 @@ async function verifyPackage(program) {
75
79
  if (issues.length > 0) {
76
80
  blocks.push(
77
81
  list(
78
- issues.map(
79
- issue =>
80
- `[${issue.severity === 'error' ? 'fail' : 'warn'}] ${issue.message}`,
81
- ),
82
+ issues.map(issue => [
83
+ `[${issue.severity === 'error' ? 'fail' : 'warn'}] ${issue.message}`,
84
+ // Every field the JSON issue carries.
85
+ ...(issue.file != null
86
+ ? [
87
+ `file: ${issue.file}${issue.line != null ? `:${issue.line}` : ''}`,
88
+ ]
89
+ : []),
90
+ ...(issue.fix != null ? [`fix: ${issue.fix}`] : []),
91
+ ]),
82
92
  ),
83
93
  );
84
94
  }
@@ -88,6 +98,101 @@ async function verifyPackage(program) {
88
98
  return NO_RESULT_SET;
89
99
  }
90
100
 
101
+ /**
102
+ * Run `integration check` and print each check as its own subcommand prints
103
+ * it, then one summary: each check's errors, warnings and skipped work, and
104
+ * what decided the exit code.
105
+ * @param {import('commander').Command} program
106
+ * @param {{strict?: boolean}} options
107
+ */
108
+ async function checkPackage(program, options) {
109
+ const result = await integrationCheck({strict: options.strict === true});
110
+ if (program.opts().json) {
111
+ jsonOut(result);
112
+ } else {
113
+ const {data} = result;
114
+ const noPackage = data.checks[0]?.response.data.issues.some(
115
+ issue => issue.code === 'no_package',
116
+ );
117
+ if (noPackage) {
118
+ emit(
119
+ text(
120
+ 'Nothing was checked: no package.json found. Run this command inside a package directory.',
121
+ ),
122
+ );
123
+ } else if (!data.validated) {
124
+ emit(
125
+ text(
126
+ 'Nothing was checked: no astryx.integration.* found next to package.json. ' +
127
+ "Run this command in an integration package's folder.",
128
+ ),
129
+ );
130
+ } else {
131
+ data.checks.forEach((check, index) => {
132
+ // A blank line keeps each check's output apart from the next.
133
+ if (index > 0) emit(text(''));
134
+ printIntegrationCheckResponse(check.response);
135
+ });
136
+ }
137
+ const plural = (/** @type {number} */ n, /** @type {string} */ word) =>
138
+ `${n} ${word}${n === 1 ? '' : 's'}`;
139
+ const counts =
140
+ `${plural(data.errors, 'error')}, ${plural(data.warnings, 'warning')}, ` +
141
+ `${data.skipped.length} skipped`;
142
+ const notCompared =
143
+ data.unchecked > 0
144
+ ? ` ${plural(data.unchecked, 'item')} could not be compared; the checks above list them.`
145
+ : '';
146
+ const closing = noPackage
147
+ ? `[fail] ${counts}. No package.json was found here, so nothing was checked.`
148
+ : data.checks.some(check => check.failed)
149
+ ? `[fail] ${counts}. Address the items marked [fail] above.`
150
+ : data.failed
151
+ ? `[fail] ${counts}. --strict fails on every warning and on skipped work; fix them, or drop --strict to fail only on errors.`
152
+ : data.warnings > 0 || data.skipped.length > 0
153
+ ? `[ok] ${counts}. No check failed; review the warnings and skipped work above (--strict fails on them).${notCompared}`
154
+ : notCompared
155
+ ? `[ok] ${counts}. No check failed.${notCompared}`
156
+ : `[ok] ${counts}. Every check passed.`;
157
+ const identity = noPackage
158
+ ? '(no package.json)'
159
+ : data.version != null
160
+ ? `${data.name}@${data.version}`
161
+ : data.name;
162
+ emit(
163
+ // --strict lists each warning and each skipped check again, as the
164
+ // error it now is: by check, code and place only, since the check's own
165
+ // output above already printed its message and fix once.
166
+ ...(data.failures.length > 0
167
+ ? [
168
+ section('Failing under --strict'),
169
+ records(data.failures, {
170
+ fields: [
171
+ 'severity',
172
+ 'check',
173
+ 'code',
174
+ 'component',
175
+ 'prop',
176
+ 'file',
177
+ 'line',
178
+ ],
179
+ format: {severity: () => '[fail]'},
180
+ }),
181
+ ]
182
+ : []),
183
+ section(
184
+ `Integration check: ${identity ?? '(local package)'}${data.strict ? ' (strict)' : ''}`,
185
+ ),
186
+ records(data.checks, {
187
+ fields: ['check', 'failed', 'errors', 'warnings', 'skipped'],
188
+ }),
189
+ text(closing),
190
+ );
191
+ }
192
+ if (result.data.failed) process.exitCode = 1;
193
+ return NO_RESULT_SET;
194
+ }
195
+
91
196
  /** @param {import('commander').Command} program */
92
197
  export function registerIntegration(program) {
93
198
  /** @type {import('commander').Command} */
@@ -159,6 +264,12 @@ export function registerIntegration(program) {
159
264
  });
160
265
  addCmd.allowExcessArguments(false);
161
266
 
267
+ // It takes no package name, so a name passed by mistake is an error, not a
268
+ // silent check of the current folder.
269
+ defineCommand(integration, integrationCheckCommand, {
270
+ fn: integrationCheckFn,
271
+ action: async options => checkPackage(program, options),
272
+ }).allowExcessArguments(false);
162
273
  defineCommand(integration, integrationVerifyCommand, {
163
274
  fn: integrationPackCheckFn,
164
275
  action: async () => verifyPackage(program),
@@ -143,7 +143,11 @@ describe('--json contract: supported commands emit valid envelopes', () => {
143
143
  const parsed = parseJson(stdout);
144
144
  expect(parsed.type).toBe('discover.list');
145
145
  expect(parsed.data).toEqual([]);
146
- expect(parsed.meta).toEqual({configured: false});
146
+ expect(parsed.meta.configured).toBe(false);
147
+ // The official list the CLI carries is always a source.
148
+ expect(parsed.meta.sources).toEqual([
149
+ expect.objectContaining({name: 'Astryx', status: 'fresh'}),
150
+ ]);
147
151
  });
148
152
 
149
153
  it('astryx template --json emits a typed envelope', async () => {