@astryxdesign/cli 0.7.4-canary.3f6ea7d → 0.7.4-canary.78641f8

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 (206) hide show
  1. package/README.md +63 -63
  2. package/api/component/_adapter.mjs +4 -3
  3. package/api/component/component.mjs +13 -6
  4. package/api/component/doc-links.test.mjs +33 -0
  5. package/api/docs/_adapter.d.mts +80 -0
  6. package/api/docs/_adapter.mjs +261 -11
  7. package/api/docs/detail/detail.mjs +8 -0
  8. package/api/docs/docOverlays.test.mjs +2 -1
  9. package/api/docs/docs.d.mts +16 -6
  10. package/api/docs/docs.doc.mjs +1 -1
  11. package/api/docs/docs.mjs +55 -6
  12. package/api/docs/docs.type.d.mts +28 -2
  13. package/api/docs/docs.type.mjs +13 -3
  14. package/api/docs/guide-route-targets.test.mjs +1002 -0
  15. package/api/docs/index/index.mjs +9 -0
  16. package/api/docs/integration-tree.test.mjs +22 -0
  17. package/api/docs/integrationDocs.test.mjs +85 -0
  18. package/api/docs/list/list.mjs +7 -1
  19. package/api/docs/node/node.mjs +9 -1
  20. package/api/docs/reference-blocks.test.mjs +1 -1
  21. package/api/doctor/built-checks.mjs +43 -13
  22. package/api/doctor/built-checks.test.mjs +29 -0
  23. package/api/doctor/doctor.doc.mjs +2 -2
  24. package/api/hook/list/list.d.mts +1 -1
  25. package/api/integration/_adapter.d.mts +11 -2
  26. package/api/integration/_adapter.mjs +30 -4
  27. package/api/integration/authoring-checks.mjs +29 -2
  28. package/api/integration/authoring-checks.test.mjs +131 -1
  29. package/api/integration/check/check.d.mts +4 -1
  30. package/api/integration/check/check.mjs +34 -4
  31. package/api/integration/check/check.test.mjs +49 -0
  32. package/api/integration/example-checks.no-npm.test.mjs +140 -0
  33. package/api/integration/example-checks.test.mjs +776 -0
  34. package/api/integration/integration-check.type.d.mts +8 -0
  35. package/api/integration/integration-check.type.mjs +4 -1
  36. package/api/integration/integrationCheck.doc.mjs +8 -1
  37. package/api/integration/integrationDocConflicts.doc.mjs +1 -1
  38. package/api/integration/pack-check.mjs +65 -1
  39. package/api/integration/pack-check.test.mjs +63 -0
  40. package/api/integration/validate-integration-case-disk.test.mjs +14 -2
  41. package/api/integration/validate-integration-gaps.test.mjs +43 -19
  42. package/api/integration/validate-integration.mjs +112 -14
  43. package/api/integration/validate-integration.type.d.mts +23 -4
  44. package/api/integration/validate-integration.type.mjs +14 -5
  45. package/api/integration/validateIntegration.doc.mjs +1 -1
  46. package/api/search/_candidate-score.d.mts +9 -3
  47. package/api/search/_candidate-score.mjs +90 -3
  48. package/api/search/_gather-components.mjs +48 -1
  49. package/api/search/_gather-docs.mjs +12 -2
  50. package/api/search/_lexical.d.mts +12 -0
  51. package/api/search/_lexical.mjs +3 -0
  52. package/api/search/_priority.mjs +5 -2
  53. package/api/search/_score.d.mts +2 -1
  54. package/api/search/_score.mjs +4 -3
  55. package/api/search/search.doc.mjs +1 -1
  56. package/api/search/search.family-members.test.mjs +124 -0
  57. package/api/search/search.family-word.test.mjs +146 -0
  58. package/api/search/search.mjs +28 -0
  59. package/api/template/template-suffix.test.mjs +26 -0
  60. package/api/theme/themeBuild.doc.mjs +1 -1
  61. package/api/theme/themeList.doc.mjs +1 -1
  62. package/api/theme/themeTargets.doc.mjs +1 -1
  63. package/assets/discover/official-packages.json +16 -0
  64. package/assets/docs/author-a-theme.doc.mjs +15 -15
  65. package/assets/docs/browser-support.doc.mjs +1 -1
  66. package/assets/docs/getting-started.doc.mjs +16 -16
  67. package/assets/docs/is-my-code-good.doc.mjs +6 -6
  68. package/assets/docs/styling-overview.doc.mjs +5 -5
  69. package/assets/docs/theme.doc.mjs +5 -5
  70. package/assets/docs/tree/add-a-component.doc.mjs +1 -1
  71. package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
  72. package/assets/docs/tree/add-a-topic.doc.mjs +6 -6
  73. package/assets/docs/tree/agent-guidance.doc.mjs +5 -5
  74. package/assets/docs/tree/authoring.doc.mjs +2 -2
  75. package/assets/docs/tree/block-template.doc.mjs +1 -1
  76. package/assets/docs/tree/check-the-props.doc.mjs +3 -3
  77. package/assets/docs/tree/check-your-docs.doc.mjs +6 -6
  78. package/assets/docs/tree/checks.doc.mjs +11 -11
  79. package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
  80. package/assets/docs/tree/cli-command.doc.mjs +6 -6
  81. package/assets/docs/tree/codemods.doc.mjs +7 -7
  82. package/assets/docs/tree/component-family.doc.mjs +1 -1
  83. package/assets/docs/tree/component-imports.doc.mjs +2 -2
  84. package/assets/docs/tree/component-lookups.doc.mjs +6 -5
  85. package/assets/docs/tree/computer-agent-guide.doc.mjs +7 -7
  86. package/assets/docs/tree/computer-integrations.doc.mjs +5 -5
  87. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +3 -3
  88. package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
  89. package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
  90. package/assets/docs/tree/doc-syntax.doc.mjs +219 -0
  91. package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
  92. package/assets/docs/tree/extend-or-replace.doc.mjs +39 -7
  93. package/assets/docs/tree/font-setup.doc.mjs +1 -1
  94. package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
  95. package/assets/docs/tree/global-integrations.doc.mjs +11 -11
  96. package/assets/docs/tree/global.doc.mjs +2 -2
  97. package/assets/docs/tree/host-entry.doc.mjs +1 -1
  98. package/assets/docs/tree/install-once.doc.mjs +4 -4
  99. package/assets/docs/tree/layout.doc.mjs +1 -1
  100. package/assets/docs/tree/links.doc.mjs +2 -2
  101. package/assets/docs/tree/migration-setup.doc.mjs +15 -15
  102. package/assets/docs/tree/migration.doc.mjs +2 -1
  103. package/assets/docs/tree/other-libraries.doc.mjs +1 -1
  104. package/assets/docs/tree/page-template.doc.mjs +2 -2
  105. package/assets/docs/tree/problems.doc.mjs +8 -8
  106. package/assets/docs/tree/project-global-or-both.doc.mjs +2 -2
  107. package/assets/docs/tree/publishing.doc.mjs +7 -7
  108. package/assets/docs/tree/quick-start.doc.mjs +9 -9
  109. package/assets/docs/tree/reference.doc.mjs +2 -2
  110. package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
  111. package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
  112. package/assets/docs/tree/scaffold.doc.mjs +1 -1
  113. package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
  114. package/assets/docs/tree/see-it-in-an-app.doc.mjs +3 -3
  115. package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
  116. package/assets/docs/tree/single-component.doc.mjs +4 -4
  117. package/assets/docs/tree/start-a-template.doc.mjs +5 -5
  118. package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
  119. package/assets/docs/tree/styling-libraries.doc.mjs +2 -1
  120. package/assets/docs/tree/styling.doc.mjs +1 -1
  121. package/assets/docs/tree/tailwind.doc.mjs +1 -1
  122. package/assets/docs/tree/test-in-an-app.doc.mjs +5 -5
  123. package/assets/docs/tree/test-template-in-app.doc.mjs +6 -6
  124. package/assets/docs/tree/tokens-and-setup.doc.mjs +1 -1
  125. package/assets/docs/tree/troubleshooting.doc.mjs +24 -20
  126. package/assets/docs/tree/uninstall.doc.mjs +2 -2
  127. package/assets/docs/tree/updates.doc.mjs +1 -1
  128. package/assets/docs/tree/upgrading.doc.mjs +3 -3
  129. package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
  130. package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
  131. package/assets/docs/tree/versioning.doc.mjs +4 -4
  132. package/assets/docs/tree/who-answers.doc.mjs +4 -4
  133. package/assets/docs/tree/write-the-template-file.doc.mjs +4 -4
  134. package/assets/docs/use-a-theme.doc.mjs +10 -10
  135. package/assets/docs/use-integrations.doc.mjs +1 -1
  136. package/assets/docs/working-with-ai.doc.mjs +15 -15
  137. package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
  138. package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
  139. package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
  140. package/assets/templates/themes/butter/butterTheme.ts +274 -234
  141. package/assets/templates/themes/butter/palette.config.json +484 -0
  142. package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
  143. package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
  144. package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
  145. package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
  146. package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
  147. package/assets/templates/themes/matcha/palette.config.json +448 -0
  148. package/assets/templates/themes/y2k/palette.config.json +166 -0
  149. package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
  150. package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
  151. package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
  152. package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
  153. package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
  154. package/authoring/codemod/codemod.doc.mjs +1 -1
  155. package/authoring/config/config.doc.mjs +4 -4
  156. package/authoring/debug/parse.d.mts +1 -1
  157. package/authoring/discover/discover.doc.mjs +1 -1
  158. package/authoring/doctypes/_schema.d.mts +4 -0
  159. package/authoring/doctypes/_schema.mjs +4 -0
  160. package/authoring/doctypes/reference/type.ts +14 -2
  161. package/authoring/gap-report/gap-report.doc.mjs +1 -1
  162. package/authoring/integration/integration.doc.mjs +6 -6
  163. package/clients/cli/commands/docs.doc.mjs +1 -1
  164. package/clients/cli/commands/docs.mjs +27 -2
  165. package/clients/cli/commands/docs.test.mjs +1 -1
  166. package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
  167. package/clients/cli/commands/doctor.doc.mjs +1 -1
  168. package/clients/cli/commands/doctor.mjs +12 -1
  169. package/clients/cli/commands/integration-check.doc.mjs +11 -0
  170. package/clients/cli/commands/integration-check.test.mjs +36 -3
  171. package/clients/cli/commands/integration-pack.doc.mjs +1 -1
  172. package/clients/cli/commands/integration-verify.doc.mjs +1 -1
  173. package/clients/cli/commands/integration.mjs +15 -3
  174. package/clients/cli/commands/theme-targets.doc.mjs +1 -1
  175. package/clients/cli/commands/upgrade.doc.mjs +2 -2
  176. package/clients/cli/lib/define-command.mjs +5 -3
  177. package/foundation/agent-docs/agent-docs.d.mts +14 -2
  178. package/foundation/agent-docs/agent-docs.mjs +65 -4
  179. package/foundation/agent-docs/agent-docs.test.mjs +107 -0
  180. package/foundation/discovery/docs-discovery.d.mts +93 -2
  181. package/foundation/discovery/docs-discovery.mjs +237 -8
  182. package/foundation/discovery/runner-allowlist.d.mts +2 -0
  183. package/foundation/discovery/runner-allowlist.mjs +4 -0
  184. package/foundation/discovery/runner-commands.d.mts +29 -13
  185. package/foundation/discovery/runner-commands.mjs +253 -17
  186. package/foundation/discovery/stray-pointers.mjs +11 -5
  187. package/foundation/discovery/stray-pointers.test.mjs +6 -0
  188. package/foundation/discovery/template-adapter.mjs +11 -0
  189. package/foundation/doc-compiler/compile.mjs +8 -1
  190. package/foundation/doc-compiler/doc-loads.test.mjs +7 -0
  191. package/foundation/doc-compiler/doc-syntax.d.mts +194 -0
  192. package/foundation/doc-compiler/doc-syntax.mjs +739 -0
  193. package/foundation/doc-compiler/doc-syntax.test.mjs +383 -0
  194. package/foundation/doc-compiler/links.d.mts +13 -16
  195. package/foundation/doc-compiler/links.mjs +40 -7
  196. package/foundation/doc-compiler/tree.d.mts +5 -0
  197. package/foundation/doc-compiler/tree.mjs +9 -0
  198. package/foundation/env/package-manager.d.mts +18 -0
  199. package/foundation/env/package-manager.mjs +40 -0
  200. package/foundation/integrations/cli-requirement.d.mts +29 -0
  201. package/foundation/integrations/cli-requirement.mjs +47 -0
  202. package/foundation/integrations/cli-requirement.test.mjs +23 -2
  203. package/foundation/integrations/validate-contributions.d.mts +53 -0
  204. package/foundation/integrations/validate-contributions.mjs +788 -0
  205. package/foundation/response/response-types.doc.mjs +6 -6
  206. package/package.json +9 -9
@@ -1401,7 +1401,7 @@ describe('validateIntegration runner-command notes', () => {
1401
1401
  line: 1,
1402
1402
  command: 'pnpm exec astryx doctor',
1403
1403
  });
1404
- expect(hit.message).toContain('Write `astryx doctor`');
1404
+ expect(hit.message).toContain('Write the token `{@command doctor}`');
1405
1405
  // A note only: no issue, so no exit changes on it.
1406
1406
  expect(
1407
1407
  data.issues.map((/** @type {any} */ issue) => issue.code),
@@ -1544,6 +1544,136 @@ describe('validateIntegration runner-command notes', () => {
1544
1544
  );
1545
1545
  });
1546
1546
 
1547
+ it('lists package-manager commands, bare commands and broken tokens with the token to write, all for the next minor', async () => {
1548
+ writeTopic(
1549
+ 'Add it with `npm install -D @acme/widgets`, run `astryx search acme`, then {@pm add x} and {@cmd docs}. Only npm: `npm pkg set name=x`.',
1550
+ );
1551
+
1552
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1553
+ const notes = (data.notes ?? []).filter(
1554
+ (/** @type {any} */ note) => note.code !== 'runner_command',
1555
+ );
1556
+
1557
+ expect(
1558
+ notes.map((/** @type {any} */ note) => [note.code, note.next]),
1559
+ ).toEqual([
1560
+ ['package_manager_command', true],
1561
+ ['plain_command', true],
1562
+ ['doc_token', true],
1563
+ ['doc_token', true],
1564
+ ['package_manager_command', true],
1565
+ // The fixture's install step, in its bash block.
1566
+ ['package_manager_command', true],
1567
+ ]);
1568
+ const messages = notes.map((/** @type {any} */ note) => note.message);
1569
+ expect(messages[0]).toContain('{@pm install @acme/widgets --dev}');
1570
+ expect(messages[1]).toContain('{@command search acme}');
1571
+ expect(messages[2]).toContain('{@pm}` starts with a verb');
1572
+ expect(messages[3]).toContain('Doc tokens are');
1573
+ expect(messages[4]).toContain(
1574
+ '{@pm-only npm "<why only npm>" pkg set name=x}',
1575
+ );
1576
+ expect(messages[5]).toContain('{@pm dlx @astryxdesign/cli init}');
1577
+ expect(data.issues.map((/** @type {any} */ issue) => issue.code)).toEqual(
1578
+ [],
1579
+ );
1580
+ });
1581
+
1582
+ it('reads a verb named alone as a mention, and TSDoc tags in a TypeScript sample as code', async () => {
1583
+ writeTopic(
1584
+ 'Scripts run with `npm run`, `pnpm dlx` fetches a package, and `npm i -g`, `yarn global add` and `npm pkg set` each take one.',
1585
+ );
1586
+ const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');
1587
+ fs.writeFileSync(
1588
+ file,
1589
+ fs.readFileSync(file, 'utf8').replace(
1590
+ /\{"type":"code"[^}]*\}/,
1591
+ JSON.stringify({
1592
+ type: 'code',
1593
+ lang: 'ts',
1594
+ code: '/** {@inheritDoc Base.render} */\nexport const x = 1;',
1595
+ }),
1596
+ ),
1597
+ );
1598
+
1599
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1600
+ expect(
1601
+ (data.notes ?? []).filter((/** @type {any} */ note) =>
1602
+ ['package_manager_command', 'doc_token'].includes(note.code),
1603
+ ),
1604
+ ).toEqual([]);
1605
+ });
1606
+
1607
+ it('lists a token that never closes, in prose and in any code block', async () => {
1608
+ writeTopic(
1609
+ 'Install with {@pm install @acme/widgets --dev before you start.',
1610
+ );
1611
+ const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');
1612
+ fs.writeFileSync(
1613
+ file,
1614
+ fs.readFileSync(file, 'utf8').replace(
1615
+ /\{"type":"code"[^}]*\}/,
1616
+ JSON.stringify({
1617
+ type: 'code',
1618
+ lang: 'tsx',
1619
+ code: '// {@pm install @acme/widgets --dev\nexport const x = 1;',
1620
+ }),
1621
+ ),
1622
+ );
1623
+
1624
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1625
+ const tokens = (data.notes ?? []).filter(
1626
+ (/** @type {any} */ note) => note.code === 'doc_token',
1627
+ );
1628
+ expect(tokens).toHaveLength(2);
1629
+ expect(tokens[0].message).toContain('never closes');
1630
+ });
1631
+
1632
+ it('lists a {@command} token that names no Astryx command', async () => {
1633
+ writeTopic('Run {@command dcotor} before you ship.');
1634
+
1635
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1636
+ const tokens = (data.notes ?? []).filter(
1637
+ (/** @type {any} */ note) => note.code === 'doc_token',
1638
+ );
1639
+ expect(tokens).toHaveLength(1);
1640
+ expect(tokens[0].message).toContain('`dcotor` is not an Astryx command');
1641
+ });
1642
+
1643
+ it('reads the command after leading global flags in a {@command} token', async () => {
1644
+ writeTopic(
1645
+ 'Read it as data with {@command --json component Button} or {@command --detail full docs acme}, not {@command --json dcotor}, {@command --json nosuch docs} or {@command --detail full nosuch}. Check the version with {@command --version}; {@command --json} alone names nothing.',
1646
+ );
1647
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1648
+ const tokens = (data.notes ?? []).filter(
1649
+ (/** @type {any} */ note) => note.code === 'doc_token',
1650
+ );
1651
+ expect(
1652
+ tokens.map(note => note.message.match(/`(\w+)` is not/)?.[1]),
1653
+ ).toEqual(['dcotor', 'nosuch', 'nosuch', undefined]);
1654
+ expect(tokens[3].message).toContain('names no Astryx command');
1655
+ });
1656
+
1657
+ it('lists nothing for a topic written in the doc syntax', async () => {
1658
+ writeTopic(
1659
+ 'Add it with {@pm install @acme/widgets --dev}, run {@command docs acme}, and {@pm-only npm "only npm has pkg" pkg set name=x}. Show the syntax: {@@pm install x}.',
1660
+ );
1661
+ // The fixture's bash block holds a scoped install step; write it as a token.
1662
+ const file = path.join(tmpDir, 'docs', 'acme-setup.doc.mjs');
1663
+ fs.writeFileSync(
1664
+ file,
1665
+ fs
1666
+ .readFileSync(file, 'utf8')
1667
+ .replace(
1668
+ 'npx @astryxdesign/cli init',
1669
+ '{@pm dlx @astryxdesign/cli init}',
1670
+ ),
1671
+ );
1672
+
1673
+ const {data} = await validateIntegration(undefined, {cwd: tmpDir});
1674
+ expect(data.notes ?? []).toEqual([]);
1675
+ });
1676
+
1547
1677
  it('lists nothing for bare commands and the scoped install step', async () => {
1548
1678
  writeTopic('Check it with `astryx doctor` first.');
1549
1679
 
@@ -60,13 +60,16 @@ export function integrationCheck(options?: IntegrationCheckOptions): Promise<Int
60
60
  * on its own, so two findings with one message stay two.
61
61
  * @param {IntegrationCheckResponse[]} responses validate first
62
62
  * @param {boolean} strict
63
+ * @param {boolean} [next] count validate's notes marked `next`, the findings
64
+ * the next minor release turns into warnings, as warnings now
63
65
  */
64
- export function combineChecks(responses: IntegrationCheckResponse[], strict: boolean): {
66
+ export function combineChecks(responses: IntegrationCheckResponse[], strict: boolean, next?: boolean): {
65
67
  checks: import("../integration-check.type.mjs").IntegrationCheckResult[];
66
68
  errors: number;
67
69
  warnings: number;
68
70
  skipped: string[];
69
71
  unchecked: number;
72
+ upcoming: number;
70
73
  failures: import("../integration-check.type.mjs").IntegrationCheckFailure[];
71
74
  failed: boolean;
72
75
  };
@@ -11,7 +11,10 @@
11
11
  * any warning and on any check, or comparison a check carries, that did not
12
12
  * run, so a package can gate its build on its docs staying in sync. `--strict`
13
13
  * adds no check: it reports the same warnings and skipped work again, as
14
- * errors in the checks' own issue format, and fails on them.
14
+ * errors in the checks' own issue format, and fails on them. `--next` counts
15
+ * the findings the next minor release turns into warnings (validate's notes
16
+ * marked `next`) as warnings now, so a package can fix them ahead of the
17
+ * release; every run reports how many there are.
15
18
  *
16
19
  * What fails it is a contract for the builds that run it: a new check, or a
17
20
  * new failure code, joins only in a minor release that names it.
@@ -236,7 +239,7 @@ export function summarizeCheck(response, context = {}) {
236
239
  * @returns {Promise<IntegrationCheckCommandResponse>}
237
240
  */
238
241
  export async function integrationCheck(options = {}) {
239
- const {cwd = process.cwd(), strict = false} = options;
242
+ const {cwd = process.cwd(), strict = false, next = false} = options;
240
243
  // One after another: each loads the package through the same discovery.
241
244
  /** @type {IntegrationCheckResponse[]} */
242
245
  const responses = [];
@@ -253,7 +256,8 @@ export async function integrationCheck(options = {}) {
253
256
  name: validation.data.name,
254
257
  version: validation.data.version,
255
258
  strict,
256
- ...combineChecks(responses, strict),
259
+ next,
260
+ ...combineChecks(responses, strict, next),
257
261
  },
258
262
  };
259
263
  }
@@ -265,8 +269,10 @@ export async function integrationCheck(options = {}) {
265
269
  * on its own, so two findings with one message stay two.
266
270
  * @param {IntegrationCheckResponse[]} responses validate first
267
271
  * @param {boolean} strict
272
+ * @param {boolean} [next] count validate's notes marked `next`, the findings
273
+ * the next minor release turns into warnings, as warnings now
268
274
  */
269
- export function combineChecks(responses, strict) {
275
+ export function combineChecks(responses, strict, next = false) {
270
276
  const [validation] = responses;
271
277
  // Only validate reports a missing package.json; the other checks read it
272
278
  // from there instead of each naming a missing manifest.
@@ -345,12 +351,36 @@ export function combineChecks(responses, strict) {
345
351
  if (strict) failures.push({check, severity: 'error', ...issue});
346
352
  }
347
353
  });
354
+ // The findings the next minor release turns into warnings: always counted,
355
+ // so the default run can say how many there are, and with `next` counted
356
+ // as warnings now.
357
+ const notes =
358
+ /** @type {{notes?: Array<{code: string, message: string, next?: boolean}>}} */ (
359
+ validation.data
360
+ ).notes ?? [];
361
+ const upcoming = notes.filter(note => note.next === true);
362
+ if (next) {
363
+ warnings += upcoming.length;
364
+ // validate's own row counts them too, so the summary shows what fails.
365
+ checks[0].warnings += upcoming.length;
366
+ if (strict) {
367
+ for (const note of upcoming) {
368
+ failures.push({
369
+ check: 'validate',
370
+ severity: 'error',
371
+ code: note.code,
372
+ message: note.message,
373
+ });
374
+ }
375
+ }
376
+ }
348
377
  return {
349
378
  checks,
350
379
  errors,
351
380
  warnings,
352
381
  skipped,
353
382
  unchecked,
383
+ upcoming: upcoming.length,
354
384
  failures,
355
385
  failed: checks.some(check => check.failed) || failures.length > 0,
356
386
  };
@@ -276,6 +276,55 @@ describe('combineChecks', () => {
276
276
  respond('integration.doc-conflicts', {}),
277
277
  ];
278
278
 
279
+ it('counts the findings the next minor release fails as upcoming, and fails on them only with strict and next', () => {
280
+ const withNotes = [
281
+ respond('integration.validate', {
282
+ notes: [
283
+ {
284
+ code: 'duplicate_component_doc',
285
+ message: 'Two docs. Fix: one.',
286
+ next: true,
287
+ },
288
+ {code: 'invalid_cli_command', message: 'Not a command.'},
289
+ ],
290
+ }),
291
+ respond('integration.component-conflicts', {}),
292
+ respond('integration.template-conflicts', {}),
293
+ respond('integration.doc-conflicts', {}),
294
+ ];
295
+ // The default run, strict included, fails on none: the next minor does.
296
+ for (const strict of [false, true]) {
297
+ expect(combineChecks(withNotes, strict)).toMatchObject({
298
+ upcoming: 1,
299
+ warnings: 0,
300
+ failures: [],
301
+ failed: false,
302
+ });
303
+ }
304
+ expect(combineChecks(withNotes, false, true)).toMatchObject({
305
+ upcoming: 1,
306
+ warnings: 1,
307
+ failures: [],
308
+ failed: false,
309
+ });
310
+ // validate's own summary row shows the note it now counts.
311
+ expect(combineChecks(withNotes, false, true).checks[0].warnings).toBe(1);
312
+ expect(combineChecks(withNotes, false).checks[0].warnings).toBe(0);
313
+ expect(combineChecks(withNotes, true, true)).toMatchObject({
314
+ upcoming: 1,
315
+ warnings: 1,
316
+ failures: [
317
+ {
318
+ check: 'validate',
319
+ severity: 'error',
320
+ code: 'duplicate_component_doc',
321
+ message: 'Two docs. Fix: one.',
322
+ },
323
+ ],
324
+ failed: true,
325
+ });
326
+ });
327
+
279
328
  it('counts a package-level issue once, and two findings with one message twice, naming each component', () => {
280
329
  const loose = combineChecks(responses, false);
281
330
  const strict = combineChecks(responses, true);
@@ -0,0 +1,140 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * When npm cannot list a package's files, `template_asset_not_packed` still
5
+ * reports an asset no `files` entry can reach and lists every other asset as
6
+ * not checked (architecture:cli-surface INV35), never passing it silently.
7
+ */
8
+
9
+ import * as fs from 'node:fs';
10
+ import * as os from 'node:os';
11
+ import * as path from 'node:path';
12
+ import {Command} from 'commander';
13
+ import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
14
+
15
+ vi.mock('../../foundation/release/cache.mjs', () => ({
16
+ npmCommand: () => {
17
+ throw new Error('npm is not installed');
18
+ },
19
+ }));
20
+
21
+ const {validateIntegration} = await import('./validate-integration.mjs');
22
+ const {integrationCheck} = await import('./check/check.mjs');
23
+ const {registerDoctor} = await import('../../clients/cli/commands/doctor.mjs');
24
+
25
+ /** @type {string} */
26
+ let dir;
27
+
28
+ /** @param {Record<string, string>} files */
29
+ function write(files) {
30
+ for (const [rel, text] of Object.entries(files)) {
31
+ const file = path.join(dir, rel);
32
+ fs.mkdirSync(path.dirname(file), {recursive: true});
33
+ fs.writeFileSync(file, text);
34
+ }
35
+ }
36
+
37
+ /** @param {string[]} files */
38
+ function packageWith(files) {
39
+ write({
40
+ 'package.json': JSON.stringify({
41
+ name: '@acme/kit',
42
+ version: '1.0.0',
43
+ files,
44
+ }),
45
+ 'astryx.integration.mjs': "export default {templates: './templates'};\n",
46
+ 'templates/img/hero.png': 'png',
47
+ 'assets/cat.png': 'png',
48
+ 'templates/card.doc.mjs':
49
+ "export default {type: 'block', name: 'card', displayName: 'Card', description: 'A block.'};\n",
50
+ 'templates/card.tsx': [
51
+ "const hero = new URL('./img/hero.png', import.meta.url);",
52
+ "const cat = new URL('../assets/cat.png', import.meta.url);",
53
+ 'export default () => null;',
54
+ '',
55
+ ].join('\n'),
56
+ });
57
+ }
58
+
59
+ beforeEach(() => {
60
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-no-npm-'));
61
+ });
62
+
63
+ afterEach(() => {
64
+ fs.rmSync(dir, {recursive: true, force: true});
65
+ });
66
+
67
+ describe('template assets when npm gives no answer', () => {
68
+ it('reports an asset no entry can reach and lists the others as not checked', async () => {
69
+ packageWith(['templates', '!templates/img']);
70
+ const {data} = await validateIntegration(undefined, {cwd: dir});
71
+ const notes = (data.notes ?? []).filter(
72
+ note => note.code === 'template_asset_not_packed',
73
+ );
74
+ expect(notes).toHaveLength(1);
75
+ expect(notes[0].message).toContain('loads assets/cat.png');
76
+ expect(data.exampleAssets).toEqual({
77
+ status: 'checked',
78
+ findings: [],
79
+ unchecked: [
80
+ {
81
+ file: 'templates/card.tsx',
82
+ asset: 'templates/img/hero.png',
83
+ reason: 'npm was not found, and a `files` entry may reach it',
84
+ },
85
+ ],
86
+ });
87
+
88
+ const check = await integrationCheck({cwd: dir});
89
+ expect(check.data.unchecked).toBeGreaterThanOrEqual(1);
90
+ });
91
+
92
+ it('lists an asset not checked when there is no files field but an ignore file', async () => {
93
+ packageWith(['templates']);
94
+ const pkg = JSON.parse(
95
+ fs.readFileSync(path.join(dir, 'package.json'), 'utf8'),
96
+ );
97
+ delete pkg.files;
98
+ fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify(pkg));
99
+ fs.writeFileSync(path.join(dir, '.npmignore'), 'templates/img\n');
100
+ const {data} = await validateIntegration(undefined, {cwd: dir});
101
+ expect(
102
+ data.exampleAssets?.unchecked.map(each => each.asset).sort(),
103
+ ).toEqual(['assets/cat.png', 'templates/img/hero.png']);
104
+ expect(
105
+ data.exampleAssets?.unchecked.every(each =>
106
+ each.reason.includes('.npmignore may drop it'),
107
+ ),
108
+ ).toBe(true);
109
+ });
110
+
111
+ it('shows the assets it could not check in text output', async () => {
112
+ packageWith(['templates', '!templates/img']);
113
+ /** @type {string[]} */
114
+ const lines = [];
115
+ vi.spyOn(console, 'log').mockImplementation((...args) => {
116
+ lines.push(args.join(' '));
117
+ });
118
+ const previous = process.cwd();
119
+ process.chdir(dir);
120
+ try {
121
+ const program = new Command();
122
+ program.exitOverride();
123
+ program.option('--json', 'Output as typed JSON');
124
+ registerDoctor(program);
125
+ await program.parseAsync([
126
+ 'node',
127
+ 'astryx',
128
+ 'doctor',
129
+ 'integration',
130
+ 'validate',
131
+ ]);
132
+ } finally {
133
+ process.chdir(previous);
134
+ vi.restoreAllMocks();
135
+ }
136
+ const out = lines.join('\n');
137
+ expect(out).toContain('Template assets not checked: 1');
138
+ expect(out).toContain('templates/img/hero.png');
139
+ });
140
+ });