@astryxdesign/cli 0.7.2-canary.020e1fe → 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 (133) hide show
  1. package/README.md +62 -62
  2. package/api/component/_adapter.d.mts +31 -0
  3. package/api/component/_adapter.mjs +116 -0
  4. package/api/component/component.mjs +60 -10
  5. package/api/component/doc-links.test.mjs +386 -0
  6. package/api/discover/_adapter.d.mts +119 -12
  7. package/api/discover/_adapter.mjs +449 -10
  8. package/api/discover/_adapter.test.mjs +599 -17
  9. package/api/discover/_catalog-view.d.mts +16 -5
  10. package/api/discover/_catalog-view.mjs +32 -8
  11. package/api/discover/detail/doc/doc.mjs +9 -1
  12. package/api/discover/discover.d.mts +11 -0
  13. package/api/discover/discover.doc.mjs +7 -6
  14. package/api/discover/discover.mjs +107 -19
  15. package/api/discover/discover.type.d.mts +18 -7
  16. package/api/discover/discover.type.mjs +15 -7
  17. package/api/discover/list/list.d.mts +4 -3
  18. package/api/discover/list/list.mjs +17 -10
  19. package/api/docs/_adapter.d.mts +63 -0
  20. package/api/docs/_adapter.mjs +309 -16
  21. package/api/docs/integration-tree.test.mjs +22 -0
  22. package/api/docs/list/list.mjs +12 -2
  23. package/api/doctor/theme-checks.test.mjs +136 -0
  24. package/api/gap-report/gap-report.d.mts +3 -0
  25. package/api/gap-report/gap-report.doc.mjs +11 -3
  26. package/api/gap-report/gap-report.mjs +152 -48
  27. package/api/gap-report/gap-report.test.mjs +233 -0
  28. package/api/gap-report/gap-report.type.d.mts +41 -0
  29. package/api/gap-report/gap-report.type.mjs +18 -0
  30. package/api/integration/_adapter.d.mts +33 -0
  31. package/api/integration/_adapter.mjs +58 -0
  32. package/api/integration/authoring-checks.mjs +98 -3
  33. package/api/integration/authoring-checks.test.mjs +769 -0
  34. package/api/integration/authoring-checks.type.d.mts +134 -0
  35. package/api/integration/authoring-checks.type.mjs +60 -1
  36. package/api/integration/integrationComponentConflicts.doc.mjs +3 -1
  37. package/api/integration/integrationDocConflicts.doc.mjs +22 -5
  38. package/api/integration/pack-check.mjs +296 -7
  39. package/api/integration/pack-check.test.mjs +367 -0
  40. package/api/integration/validate-integration-fixes.test.mjs +67 -0
  41. package/api/integration/validate-integration.mjs +28 -3
  42. package/api/integration/validate-integration.test.mjs +77 -8
  43. package/api/integration/validateIntegration.doc.mjs +1 -1
  44. package/api/search/search.mjs +2 -1
  45. package/api/upgrade/_adapter.d.mts +40 -2
  46. package/api/upgrade/_adapter.mjs +117 -4
  47. package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
  48. package/api/upgrade/run/run.mjs +30 -1
  49. package/api/upgrade/status/status.d.mts +21 -5
  50. package/api/upgrade/status/status.mjs +45 -8
  51. package/api/upgrade/upgrade.doc.mjs +5 -3
  52. package/api/upgrade/upgrade.type.d.mts +23 -0
  53. package/api/upgrade/upgrade.type.mjs +16 -1
  54. package/assets/codemods/runner.mjs +7 -1
  55. package/assets/discover/official-packages.json +367 -0
  56. package/assets/docs/author-a-theme.doc.mjs +2 -2
  57. package/assets/docs/browser-support.doc.mjs +1 -1
  58. package/assets/docs/styling-overview.doc.mjs +1 -1
  59. package/assets/docs/theme.doc.mjs +1 -1
  60. package/assets/docs/tree/add-a-topic.doc.mjs +3 -3
  61. package/assets/docs/tree/check-the-props.doc.mjs +7 -2
  62. package/assets/docs/tree/check-your-docs.doc.mjs +15 -3
  63. package/assets/docs/tree/checks.doc.mjs +5 -5
  64. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +25 -5
  65. package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
  66. package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
  67. package/assets/docs/tree/layout.doc.mjs +6 -6
  68. package/assets/docs/tree/migration-setup.doc.mjs +2 -2
  69. package/assets/docs/tree/publishing.doc.mjs +3 -3
  70. package/assets/docs/tree/quick-start.doc.mjs +2 -2
  71. package/assets/docs/tree/sections-and-placement.doc.mjs +2 -2
  72. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  73. package/assets/docs/tree/troubleshooting.doc.mjs +5 -5
  74. package/assets/docs/tree/upgrading.doc.mjs +1 -1
  75. package/authoring/discover/discover.doc.mjs +1 -1
  76. package/authoring/doctypes/component/component.doc.mjs +1 -1
  77. package/authoring/doctypes/component/type.ts +8 -0
  78. package/authoring/doctypes/hook/type.ts +4 -0
  79. package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
  80. package/clients/cli/commands/discover.doc.mjs +1 -1
  81. package/clients/cli/commands/discover.mjs +144 -93
  82. package/clients/cli/commands/discover.no-source.test.mjs +447 -33
  83. package/clients/cli/commands/discover.sources.test.mjs +20 -1
  84. package/clients/cli/commands/doctor-integration-components.doc.mjs +3 -2
  85. package/clients/cli/commands/doctor-integration-docs.doc.mjs +19 -5
  86. package/clients/cli/commands/doctor-integration.test.mjs +48 -1
  87. package/clients/cli/commands/doctor.mjs +91 -5
  88. package/clients/cli/commands/gap-report.doc.mjs +14 -2
  89. package/clients/cli/commands/gap-report.mjs +24 -2
  90. package/clients/cli/commands/gap-report.test.mjs +79 -0
  91. package/clients/cli/commands/integration-authoring.test.mjs +46 -0
  92. package/clients/cli/commands/integration-check.test.mjs +144 -0
  93. package/clients/cli/commands/integration.mjs +12 -7
  94. package/clients/cli/commands/json-contract.test.mjs +5 -1
  95. package/clients/cli/commands/upgrade.doc.mjs +14 -0
  96. package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
  97. package/foundation/discovery/copied-passages.d.mts +216 -0
  98. package/foundation/discovery/copied-passages.mjs +720 -0
  99. package/foundation/discovery/copied-passages.test.mjs +124 -0
  100. package/foundation/discovery/doc-consistency.d.mts +34 -0
  101. package/foundation/discovery/doc-consistency.mjs +513 -0
  102. package/foundation/discovery/doc-consistency.test.mjs +347 -0
  103. package/foundation/discovery/doc-fluff.d.mts +112 -0
  104. package/foundation/discovery/doc-fluff.mjs +328 -0
  105. package/foundation/discovery/doc-fluff.test.mjs +142 -0
  106. package/foundation/discovery/doc-types.mjs +12 -5
  107. package/foundation/discovery/doc-types.test.mjs +46 -2
  108. package/foundation/discovery/docs-discovery.d.mts +7 -0
  109. package/foundation/discovery/docs-discovery.mjs +26 -2
  110. package/foundation/discovery/prop-drift.d.mts +25 -6
  111. package/foundation/discovery/prop-drift.mjs +171 -6
  112. package/foundation/discovery/prop-drift.test.mjs +65 -0
  113. package/foundation/discovery/stray-pointers.d.mts +52 -0
  114. package/foundation/discovery/stray-pointers.mjs +293 -0
  115. package/foundation/discovery/stray-pointers.test.mjs +86 -0
  116. package/foundation/doc-compiler/doc-loads.test.mjs +16 -0
  117. package/foundation/doc-compiler/links.d.mts +32 -0
  118. package/foundation/doc-compiler/links.mjs +163 -26
  119. package/foundation/doc-compiler/links.test.mjs +97 -4
  120. package/foundation/doc-compiler/tree.mjs +30 -1
  121. package/foundation/doc-compiler/tree.test.mjs +7 -0
  122. package/foundation/env/package-manager.d.mts +32 -0
  123. package/foundation/env/package-manager.mjs +47 -0
  124. package/foundation/env/package-manager.test.mjs +194 -7
  125. package/foundation/fs/module-loader.d.mts +2 -1
  126. package/foundation/fs/module-loader.mjs +60 -4
  127. package/foundation/fs/module-loader.test.mjs +194 -0
  128. package/foundation/integrations/contribution-inventory.d.mts +11 -0
  129. package/foundation/integrations/contribution-inventory.mjs +50 -2
  130. package/foundation/integrations/issue.ts +6 -0
  131. package/foundation/integrations/validate-contributions.mjs +30 -1
  132. package/foundation/response/response-types.doc.mjs +10 -9
  133. package/package.json +11 -11
@@ -210,6 +210,51 @@ describe('doctor integration — command', () => {
210
210
  expect(process.exitCode).toBeUndefined();
211
211
  });
212
212
 
213
+ it('validate prints the fix and the file an issue carries, and JSON carries the same issue', async () => {
214
+ writeDocIntegration({name: 'deploying'});
215
+ fs.writeFileSync(
216
+ path.join(tmpDir, 'docs', 'ghost.doc.zh.mjs'),
217
+ "export default {title: 'ghost'};\n",
218
+ );
219
+ process.chdir(tmpDir);
220
+
221
+ await createProgram().parseAsync([
222
+ 'node',
223
+ 'astryx',
224
+ 'doctor',
225
+ 'integration',
226
+ 'validate',
227
+ ]);
228
+ const output = logCalls.join('\n');
229
+ expect(output).toContain('orphan_doc_overlay');
230
+ expect(output).toMatch(
231
+ /fix:\s+Delete docs\/ghost\.doc\.zh\.mjs, or add the topic it translates/,
232
+ );
233
+ expect(output).toMatch(/file:\s+docs\/ghost\.doc\.zh\.mjs/);
234
+ expect(output).toMatch(/line:\s+1\b/);
235
+
236
+ logCalls = [];
237
+ await createProgram().parseAsync([
238
+ 'node',
239
+ 'astryx',
240
+ '--json',
241
+ 'doctor',
242
+ 'integration',
243
+ 'validate',
244
+ ]);
245
+ const parsed = JSON.parse(logCalls.join('\n'));
246
+ expect(parsed.data.issues).toEqual([
247
+ {
248
+ code: 'orphan_doc_overlay',
249
+ severity: 'warning',
250
+ message: expect.stringContaining('docs/ghost.doc.zh.mjs'),
251
+ fix: expect.stringContaining('Delete docs/ghost.doc.zh.mjs'),
252
+ file: 'docs/ghost.doc.zh.mjs',
253
+ line: 1,
254
+ },
255
+ ]);
256
+ });
257
+
213
258
  it('validate warns about each doc field that does not match its authoring type, and still exits 0', async () => {
214
259
  writeIntegration({id: 'hero', name: 'Hero', type: 'block'});
215
260
  process.chdir(tmpDir);
@@ -1060,12 +1105,13 @@ describe('doctor integration — command', () => {
1060
1105
  "{name: 'elevation', type: 'number', description: 'Shadow.'}",
1061
1106
  "{name: 'size', type: 'string', description: 'Size.'}",
1062
1107
  "{name: 'meta', type: '{id: string; extra?: number}', description: 'Data.'}",
1108
+ "{name: 'gap', type: 'number', description: 'Gap.', default: '8'}",
1063
1109
  ].join(', ')}]};\n`,
1064
1110
  );
1065
1111
  // `key` is a prop a doc never needs, though the component declares it.
1066
1112
  fs.writeFileSync(
1067
1113
  path.join(tmpDir, 'components', 'AcmeBadge.tsx'),
1068
- "export function AcmeBadge(props: {label: string; tone?: 'neutral' | 'info'; size?: number; meta?: {id: string}; key?: string}) { return null; }\n",
1114
+ "export function AcmeBadge({gap = 4}: {label: string; tone?: 'neutral' | 'info'; size?: number; meta?: {id: string}; gap?: number; key?: string}) { return null; }\n",
1069
1115
  );
1070
1116
  fs.writeFileSync(
1071
1117
  path.join(tmpDir, 'components', 'AcmeLonely.doc.mjs'),
@@ -1094,6 +1140,7 @@ describe('doctor integration — command', () => {
1094
1140
 
1095
1141
  expect(report.findings.map(f => `${f.prop} ${f.kind}`)).toEqual([
1096
1142
  'elevation not_in_code',
1143
+ 'gap default_mismatch',
1097
1144
  'label required_mismatch',
1098
1145
  'size type_mismatch',
1099
1146
  'tone not_in_doc',
@@ -92,7 +92,7 @@ function issueBlocks(issues) {
92
92
  return [
93
93
  section('Integration issues'),
94
94
  records(issues, {
95
- fields: ['severity', 'code', 'message'],
95
+ fields: ['severity', 'code', 'message', 'fix', 'file', 'line'],
96
96
  format: {severity: statusToken},
97
97
  }),
98
98
  ];
@@ -189,7 +189,7 @@ function printIntegrationValidation(data) {
189
189
  ...(data.issues.length > 0
190
190
  ? [
191
191
  records(data.issues, {
192
- fields: ['severity', 'code', 'message'],
192
+ fields: ['severity', 'code', 'message', 'fix', 'file', 'line'],
193
193
  format: {severity: statusToken},
194
194
  }),
195
195
  ]
@@ -287,6 +287,9 @@ function propDriftBlocks(report, failed) {
287
287
  'codeType',
288
288
  'docRequired',
289
289
  'codeRequired',
290
+ 'docDefault',
291
+ 'codeDefault',
292
+ 'fix',
290
293
  ],
291
294
  format: {severity: statusToken},
292
295
  }),
@@ -358,7 +361,8 @@ function printComponentConflicts(data) {
358
361
  // An [ok] after a failed check reads as a pass: say nothing it could not check.
359
362
  const failed = data.issues.some(issue => issue.severity === 'error');
360
363
  if (data.conflicts.length === 0) {
361
- if (!failed) output.push(text('[ok] No component names conflict with Core.'));
364
+ if (!failed)
365
+ output.push(text('[ok] No component names conflict with Core.'));
362
366
  } else {
363
367
  output.push(
364
368
  records(data.conflicts, {
@@ -389,7 +393,16 @@ function printDocConflicts(data) {
389
393
  section(
390
394
  `Checking integration docs: ${integrationLabel(data) ?? '(local package)'}`,
391
395
  ),
392
- ...issueBlocks(data.issues),
396
+ // A copied passage or fluff is listed below with its detail, so its
397
+ // issue is not printed twice.
398
+ ...issueBlocks(
399
+ data.issues.filter(
400
+ issue =>
401
+ issue.code !== 'copied_passage' &&
402
+ issue.code !== 'doc_fluff' &&
403
+ issue.code !== 'stray_doc_pointer',
404
+ ),
405
+ ),
393
406
  ];
394
407
  if (
395
408
  !data.issues.some(
@@ -412,6 +425,79 @@ function printDocConflicts(data) {
412
425
  }),
413
426
  );
414
427
  }
428
+ const copied = data.copiedPassages ?? [];
429
+ if (copied.length === 0) {
430
+ if (!data.issues.some(issue => issue.severity === 'error')) {
431
+ output.push(text('[ok] No topic copies a passage from another.'));
432
+ }
433
+ } else {
434
+ output.push(
435
+ text(
436
+ `[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.`,
437
+ ),
438
+ records(copied, {
439
+ fields: [
440
+ 'topic',
441
+ 'section',
442
+ 'line',
443
+ 'otherTopic',
444
+ 'otherOwner',
445
+ 'owner',
446
+ 'text',
447
+ 'words',
448
+ 'passages',
449
+ 'message',
450
+ ],
451
+ }),
452
+ );
453
+ }
454
+ const fluff = data.fluff ?? [];
455
+ if (fluff.length === 0) {
456
+ if (!data.issues.some(issue => issue.severity === 'error')) {
457
+ output.push(text('[ok] No filler phrases or low-density topics.'));
458
+ }
459
+ } else {
460
+ output.push(
461
+ text(
462
+ `[warn] ${fluff.length} fluff finding(s) (doc_fluff): words that add length, not meaning. Cut each one.`,
463
+ ),
464
+ records(fluff, {
465
+ fields: [
466
+ 'topic',
467
+ 'kind',
468
+ 'phrase',
469
+ 'section',
470
+ 'file',
471
+ 'line',
472
+ 'density',
473
+ 'message',
474
+ ],
475
+ }),
476
+ );
477
+ }
478
+ const stray = data.strayPointers ?? [];
479
+ if (stray.length === 0) {
480
+ if (!data.issues.some(issue => issue.severity === 'error')) {
481
+ output.push(text('[ok] Every pointer to a doc is a link.'));
482
+ }
483
+ } else {
484
+ output.push(
485
+ text(
486
+ `[warn] ${stray.length} stray doc pointer(s) (stray_doc_pointer): a written \`astryx docs <name>\` where a link would be checked. Replace each with the link shown.`,
487
+ ),
488
+ records(stray, {
489
+ fields: [
490
+ 'topic',
491
+ 'section',
492
+ 'file',
493
+ 'line',
494
+ 'pointer',
495
+ 'link',
496
+ 'message',
497
+ ],
498
+ }),
499
+ );
500
+ }
415
501
  emit(...output);
416
502
  }
417
503
 
@@ -455,7 +541,7 @@ async function runIntegrationValidation(program, pkg) {
455
541
  noPackage
456
542
  ? 'Nothing was validated: no package.json found. Run this command inside a package directory.'
457
543
  : 'Nothing was validated: no astryx.integration.* found next to package.json. ' +
458
- 'To validate an installed integration: astryx doctor integration validate <package>',
544
+ 'To validate an installed integration: astryx doctor integration validate <package>',
459
545
  ),
460
546
  );
461
547
  } 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
+ });
@@ -147,6 +147,52 @@ describe('integration authoring CLI', () => {
147
147
  );
148
148
  });
149
149
 
150
+ it("verify carries each issue's fix, file, and line in JSON and prints them in text", async () => {
151
+ fs.writeFileSync(
152
+ path.join(tmpDir, 'package.json'),
153
+ `${JSON.stringify({
154
+ name: '@acme/widgets',
155
+ version: '1.0.0',
156
+ files: ['astryx.integration.mjs', 'docs'],
157
+ })}\n`,
158
+ );
159
+ fs.writeFileSync(
160
+ path.join(tmpDir, 'astryx.integration.mjs'),
161
+ "export default {docs: './docs'};\n",
162
+ );
163
+ fs.mkdirSync(path.join(tmpDir, 'docs'));
164
+ fs.writeFileSync(
165
+ path.join(tmpDir, 'docs', 'deploying.doc.mjs'),
166
+ "export const docs = {type: 'generic', name: 'deploying', title: 'Deploying', description: 'How to deploy.', sections: [{title: 'Overview', content: [{type: 'prose', text: 'Ship it.'}]}]};\n",
167
+ );
168
+ fs.writeFileSync(
169
+ path.join(tmpDir, 'docs', 'ghost.doc.zh.mjs'),
170
+ "export default {title: 'ghost'};\n",
171
+ );
172
+
173
+ const json = parseEnvelope(
174
+ (await runCli(['integration', 'verify', '--json'], tmpDir)).stdout,
175
+ );
176
+ const orphans = json.data.issues.filter(issue =>
177
+ issue.code.endsWith('orphan_doc_overlay'),
178
+ );
179
+ expect(orphans.map(issue => issue.code).sort()).toEqual([
180
+ 'orphan_doc_overlay',
181
+ 'packed_orphan_doc_overlay',
182
+ ]);
183
+ for (const issue of orphans) {
184
+ expect(issue).toMatchObject({
185
+ file: 'docs/ghost.doc.zh.mjs',
186
+ line: 1,
187
+ fix: expect.stringContaining('Delete docs/ghost.doc.zh.mjs'),
188
+ });
189
+ }
190
+
191
+ const text = (await runCli(['integration', 'verify'], tmpDir)).stdout;
192
+ expect(text).toContain('file: docs/ghost.doc.zh.mjs:1');
193
+ expect(text).toContain(`fix: ${orphans[0].fix}`);
194
+ });
195
+
150
196
  it('keeps `integration pack --check` as a deprecated alias of `integration verify`', async () => {
151
197
  // The old spelling runs the same check: the same JSON, the same exit code.
152
198
  const verify = await runCli(['integration', 'verify', '--json'], tmpDir);
@@ -117,6 +117,23 @@ describe('astryx integration check', () => {
117
117
  expect(run.status).toBe(1);
118
118
  });
119
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
+
120
137
  it('--json carries each check with its own envelope, the --strict failures, and exits as the text does', async () => {
121
138
  const id = await coreTemplateId();
122
139
  writePackage({id});
@@ -265,3 +282,130 @@ describe('astryx integration check', () => {
265
282
  expect(run.status).toBe(1);
266
283
  });
267
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
+ });
@@ -79,10 +79,16 @@ async function verifyPackage(program) {
79
79
  if (issues.length > 0) {
80
80
  blocks.push(
81
81
  list(
82
- issues.map(
83
- issue =>
84
- `[${issue.severity === 'error' ? 'fail' : 'warn'}] ${issue.message}`,
85
- ),
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
+ ]),
86
92
  ),
87
93
  );
88
94
  }
@@ -155,7 +161,8 @@ async function checkPackage(program, options) {
155
161
  : data.name;
156
162
  emit(
157
163
  // --strict lists each warning and each skipped check again, as the
158
- // error it now is, in the issue format the checks use.
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.
159
166
  ...(data.failures.length > 0
160
167
  ? [
161
168
  section('Failing under --strict'),
@@ -166,8 +173,6 @@ async function checkPackage(program, options) {
166
173
  'code',
167
174
  'component',
168
175
  'prop',
169
- 'message',
170
- 'fix',
171
176
  'file',
172
177
  'line',
173
178
  ],
@@ -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 () => {