@astryxdesign/cli 0.7.2-canary.4932317 → 0.7.2-canary.4a2f608

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +62 -62
  2. package/api/discover/_adapter.d.mts +119 -12
  3. package/api/discover/_adapter.mjs +449 -10
  4. package/api/discover/_adapter.test.mjs +599 -17
  5. package/api/discover/_catalog-view.d.mts +16 -5
  6. package/api/discover/_catalog-view.mjs +32 -8
  7. package/api/discover/discover.d.mts +11 -0
  8. package/api/discover/discover.doc.mjs +7 -6
  9. package/api/discover/discover.mjs +107 -19
  10. package/api/discover/discover.type.d.mts +18 -7
  11. package/api/discover/discover.type.mjs +15 -7
  12. package/api/discover/list/list.d.mts +4 -3
  13. package/api/discover/list/list.mjs +17 -10
  14. package/api/doctor/theme-checks.test.mjs +136 -0
  15. package/api/gap-report/gap-report.d.mts +3 -0
  16. package/api/gap-report/gap-report.doc.mjs +11 -3
  17. package/api/gap-report/gap-report.mjs +152 -48
  18. package/api/gap-report/gap-report.test.mjs +233 -0
  19. package/api/gap-report/gap-report.type.d.mts +41 -0
  20. package/api/gap-report/gap-report.type.mjs +18 -0
  21. package/api/integration/_adapter.d.mts +20 -0
  22. package/api/integration/_adapter.mjs +26 -0
  23. package/api/integration/authoring-checks.mjs +34 -3
  24. package/api/integration/authoring-checks.test.mjs +476 -0
  25. package/api/integration/authoring-checks.type.d.mts +86 -0
  26. package/api/integration/authoring-checks.type.mjs +39 -1
  27. package/api/integration/integrationComponentConflicts.doc.mjs +9 -3
  28. package/api/integration/integrationDocConflicts.doc.mjs +19 -5
  29. package/api/integration/pack-check.mjs +292 -7
  30. package/api/integration/pack-check.test.mjs +341 -0
  31. package/api/integration/validateIntegration.doc.mjs +3 -1
  32. package/api/search/search.d.mts +9 -7
  33. package/api/search/search.mjs +90 -42
  34. package/api/search/search.test.mjs +11 -0
  35. package/api/upgrade/_adapter.d.mts +40 -2
  36. package/api/upgrade/_adapter.mjs +117 -4
  37. package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
  38. package/api/upgrade/run/run.mjs +30 -1
  39. package/api/upgrade/status/status.d.mts +21 -5
  40. package/api/upgrade/status/status.mjs +45 -8
  41. package/api/upgrade/upgrade.doc.mjs +5 -3
  42. package/api/upgrade/upgrade.type.d.mts +23 -0
  43. package/api/upgrade/upgrade.type.mjs +16 -1
  44. package/assets/codemods/runner.mjs +7 -1
  45. package/assets/discover/official-packages.json +367 -0
  46. package/assets/docs/author-a-theme.doc.mjs +2 -2
  47. package/assets/docs/browser-support.doc.mjs +1 -1
  48. package/assets/docs/styling-overview.doc.mjs +1 -1
  49. package/assets/docs/theme.doc.mjs +1 -1
  50. package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
  51. package/assets/docs/tree/check-the-props.doc.mjs +2 -2
  52. package/assets/docs/tree/check-your-docs.doc.mjs +11 -3
  53. package/assets/docs/tree/checks.doc.mjs +4 -4
  54. package/assets/docs/tree/debug-and-gap-reports.doc.mjs +25 -5
  55. package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
  56. package/assets/docs/tree/layout.doc.mjs +6 -6
  57. package/assets/docs/tree/migration-setup.doc.mjs +2 -2
  58. package/assets/docs/tree/publishing.doc.mjs +3 -3
  59. package/assets/docs/tree/quick-start.doc.mjs +3 -3
  60. package/assets/docs/tree/sections-and-placement.doc.mjs +2 -2
  61. package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
  62. package/assets/docs/tree/troubleshooting.doc.mjs +5 -5
  63. package/assets/docs/tree/upgrading.doc.mjs +1 -1
  64. package/authoring/discover/discover.doc.mjs +1 -1
  65. package/authoring/doctypes/component/component.doc.mjs +1 -1
  66. package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
  67. package/clients/cli/commands/discover.doc.mjs +1 -1
  68. package/clients/cli/commands/discover.mjs +144 -93
  69. package/clients/cli/commands/discover.no-source.test.mjs +447 -33
  70. package/clients/cli/commands/discover.sources.test.mjs +20 -1
  71. package/clients/cli/commands/doctor-integration-components.doc.mjs +3 -1
  72. package/clients/cli/commands/doctor-integration-docs.doc.mjs +18 -5
  73. package/clients/cli/commands/doctor-integration-validate.doc.mjs +3 -1
  74. package/clients/cli/commands/doctor.mjs +60 -3
  75. package/clients/cli/commands/gap-report.doc.mjs +14 -2
  76. package/clients/cli/commands/gap-report.mjs +24 -2
  77. package/clients/cli/commands/gap-report.test.mjs +79 -0
  78. package/clients/cli/commands/integration-check.test.mjs +103 -0
  79. package/clients/cli/commands/integration.mjs +2 -3
  80. package/clients/cli/commands/json-contract.test.mjs +5 -1
  81. package/clients/cli/commands/upgrade.doc.mjs +14 -0
  82. package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
  83. package/foundation/discovery/copied-passages.d.mts +216 -0
  84. package/foundation/discovery/copied-passages.mjs +720 -0
  85. package/foundation/discovery/copied-passages.test.mjs +124 -0
  86. package/foundation/discovery/doc-fluff.d.mts +112 -0
  87. package/foundation/discovery/doc-fluff.mjs +328 -0
  88. package/foundation/discovery/doc-fluff.test.mjs +142 -0
  89. package/foundation/discovery/doc-types.d.mts +1 -1
  90. package/foundation/discovery/doc-types.mjs +3 -3
  91. package/foundation/discovery/doc-types.test.mjs +48 -0
  92. package/foundation/discovery/docs-discovery.d.mts +7 -0
  93. package/foundation/discovery/docs-discovery.mjs +26 -2
  94. package/foundation/discovery/project-typescript.d.mts +11 -2
  95. package/foundation/discovery/project-typescript.mjs +32 -4
  96. package/foundation/discovery/prop-drift.d.mts +1 -1
  97. package/foundation/discovery/prop-drift.mjs +2 -2
  98. package/foundation/discovery/prop-drift.test.mjs +55 -2
  99. package/foundation/discovery/type-text.mjs +1 -1
  100. package/foundation/discovery/type-text.test.mjs +1 -1
  101. package/foundation/doc-compiler/doc-loads.test.mjs +14 -2
  102. package/foundation/env/package-manager.d.mts +32 -0
  103. package/foundation/env/package-manager.mjs +47 -0
  104. package/foundation/env/package-manager.test.mjs +194 -7
  105. package/foundation/fs/module-loader.d.mts +2 -1
  106. package/foundation/fs/module-loader.mjs +60 -4
  107. package/foundation/fs/module-loader.test.mjs +194 -0
  108. package/foundation/response/response-types.doc.mjs +7 -6
  109. package/package.json +11 -11
@@ -340,6 +340,142 @@ describe('app-theme doctor checks', () => {
340
340
  expect(result.message).not.toMatch(/\n\s+at /u);
341
341
  });
342
342
 
343
+ it('passes theme-owners when a built module imports its stylesheet', async () => {
344
+ const {dir, packageDir} = await fixture();
345
+ write(
346
+ path.join(packageDir, 'dist/ocean.js'),
347
+ "import './ocean.css';\nimport '@acme/themes/themes/ocean.css';\nexport const oceanTheme = {name: 'ocean', tokens: {}};\n",
348
+ );
349
+
350
+ const checks = await checkAppThemes(dir);
351
+
352
+ expect(checks.map(item => item.status)).toEqual(Array(10).fill('pass'));
353
+ expect(check(checks, 'theme-owners').message).toContain(
354
+ 'every built module loads',
355
+ );
356
+ const cli = runDoctor(dir);
357
+ expect(cli.status).toBe(0);
358
+ expect(cli.stdout).not.toContain('could not load its built module');
359
+ }, 30_000);
360
+
361
+ it('passes every check for an entry that loads its fonts and stylesheet and re-exports the built module', async () => {
362
+ const {dir, packageDir} = await fixture([
363
+ {
364
+ slug: 'ocean',
365
+ fontFamily: 'Ocean Sans',
366
+ fontCss:
367
+ "@font-face { font-family: 'Ocean Sans'; src: local('Ocean Sans'); }\n",
368
+ },
369
+ ]);
370
+ write(
371
+ path.join(packageDir, 'dist/ocean.built.js'),
372
+ "export const oceanTheme = {name: 'ocean', tokens: {}, fontFamily: 'Ocean Sans'};\n",
373
+ );
374
+ write(
375
+ path.join(packageDir, 'dist/ocean.js'),
376
+ "import './ocean.fonts.css';\nimport '@acme/themes/themes/ocean.css';\nexport {oceanTheme} from './ocean.built.js';\n",
377
+ );
378
+
379
+ const checks = await checkAppThemes(dir);
380
+
381
+ expect(checks.map(item => [item.id, item.status])).toEqual(
382
+ checks.map(item => [item.id, 'pass']),
383
+ );
384
+ expect(checks).toHaveLength(10);
385
+ const cli = runDoctor(dir);
386
+ expect(cli.status).toBe(0);
387
+ expect(cli.stdout).not.toContain('could not load its built module');
388
+ }, 30_000);
389
+
390
+ it('passes every check for an entry that re-exports a theme whose own name differs from its slug', async () => {
391
+ const {dir, packageDir} = await fixture([
392
+ {
393
+ slug: 'ocean',
394
+ css: '[data-astryx-theme="deep-sea"] { --color-text: black; }\n',
395
+ fontFamily: 'Ocean Sans',
396
+ fontCss:
397
+ "@font-face { font-family: 'Ocean Sans'; src: local('Ocean Sans'); }\n",
398
+ },
399
+ ]);
400
+ write(
401
+ path.join(packageDir, 'dist/deep-sea.js'),
402
+ "export const deepSeaTheme = {name: 'deep-sea', tokens: {}, fontFamily: 'Ocean Sans'};\n",
403
+ );
404
+ write(
405
+ path.join(packageDir, 'dist/ocean.js'),
406
+ "import './ocean.fonts.css';\nimport './ocean.css';\nexport {deepSeaTheme as oceanTheme} from './deep-sea.js';\n",
407
+ );
408
+
409
+ const checks = await checkAppThemes(dir);
410
+
411
+ expect(checks.map(item => [item.id, item.status])).toEqual(
412
+ checks.map(item => [item.id, 'pass']),
413
+ );
414
+ expect(checks).toHaveLength(10);
415
+ }, 30_000);
416
+
417
+ it.each([
418
+ [
419
+ 'a missing dependency',
420
+ "import '@acme/definitely-missing-dep';\nexport const oceanTheme = {name: 'ocean', tokens: {}};\n",
421
+ '@acme/definitely-missing-dep',
422
+ ],
423
+ [
424
+ 'a throwing module',
425
+ "throw new Error('broken theme module');\nexport const oceanTheme = {name: 'ocean', tokens: {}};\n",
426
+ 'broken theme module',
427
+ ],
428
+ ])(
429
+ 'still fails theme-owners when a built module imports its stylesheet and has %s',
430
+ async (_label, rest, detail) => {
431
+ const {dir, packageDir} = await fixture();
432
+ write(
433
+ path.join(packageDir, 'dist/ocean.js'),
434
+ `import './ocean.css';\n${rest}`,
435
+ );
436
+
437
+ const result = check(await checkAppThemes(dir), 'theme-owners');
438
+
439
+ expect(result).toMatchObject({id: 'theme-owners', status: 'fail'});
440
+ expect(result.message).toContain(
441
+ 'Theme "ocean" from @acme/themes could not load its built module',
442
+ );
443
+ expect(result.message).toContain(detail);
444
+ },
445
+ );
446
+
447
+ it("still fails theme-owners when the theme's stylesheet export is missing", async () => {
448
+ const {dir, packageDir} = await fixture();
449
+ write(
450
+ path.join(packageDir, 'dist/ocean.js'),
451
+ "import './ocean.css';\nexport const oceanTheme = {name: 'ocean', tokens: {}};\n",
452
+ );
453
+ fs.rmSync(path.join(packageDir, 'dist/ocean.css'));
454
+
455
+ const result = check(await checkAppThemes(dir), 'theme-owners');
456
+
457
+ expect(result).toMatchObject({id: 'theme-owners', status: 'fail'});
458
+ expect(result.message).toContain(
459
+ 'Missing stylesheet export @acme/themes/themes/ocean.css',
460
+ );
461
+ });
462
+
463
+ it('still fails theme-owners when another stylesheet the built module imports is missing', async () => {
464
+ const {dir, packageDir} = await fixture();
465
+ write(
466
+ path.join(packageDir, 'dist/ocean.js'),
467
+ "import './ocean.css';\nimport './fonts.css';\nexport const oceanTheme = {name: 'ocean', tokens: {}};\n",
468
+ );
469
+
470
+ const result = check(await checkAppThemes(dir), 'theme-owners');
471
+
472
+ expect(result).toMatchObject({id: 'theme-owners', status: 'fail'});
473
+ expect(result.message).toContain(
474
+ 'Theme "ocean" from @acme/themes could not load its built module',
475
+ );
476
+ expect(result.message).toContain('fonts.css');
477
+ });
478
+
343
479
  it('fails theme-owners for an ambiguous multi-theme record', async () => {
344
480
  const {dir, packageDir} = await fixture([{slug: 'ocean'}, {slug: 'reef'}]);
345
481
  const packageFile = path.join(packageDir, 'package.json');
@@ -60,6 +60,9 @@ export const GAP_REPORT_CATEGORIES: readonly (Readonly<{
60
60
  label: "Other";
61
61
  }>)[];
62
62
  export const PUBLIC_CONFIRMATION_MESSAGE: "Rerun with --confirm-public to file this report.";
63
+ /** What an agent does when more than one destination exists. */
64
+ export const ASK_DESTINATION_MESSAGE: "Ask the person where to file this report, then pass their choice with --to <package>. Never pick a package destination yourself; leave --to out to use the default.";
65
+ export type GapReportDestination = import("./gap-report.type.mjs").GapReportDestination;
63
66
  export type ReportTarget = {
64
67
  package: string;
65
68
  version: string | null;
@@ -19,6 +19,8 @@ export const doc = {
19
19
  'Sends a gap report to every configured handler: the project config handler first, then each integration handler in config order. ' +
20
20
  'Each handler has 30 s to finish, and its output goes to stderr. Public handlers run only with confirmPublic; internal handlers always run. ' +
21
21
  "With no handler, it files a GitHub issue for the owning package only with confirmPublic (without it nothing is sent), or returns the package's issues URL when that is not on GitHub. " +
22
+ "With options.to, the report goes only to that integration's issues URL instead, under the same confirmPublic rule. " +
23
+ 'When loaded integrations name their own issues URLs, the response lists every destination with a line telling an agent to ask the person where to file; pass their choice as options.to, never a package the agent picked itself. ' +
22
24
  'The report records whether an agent or a person ran it, and the response lists each handler outcome in order.',
23
25
  importPath: '@astryxdesign/cli/api',
24
26
  signature:
@@ -67,14 +69,20 @@ export const doc = {
67
69
  name: 'options.confirmPublic',
68
70
  type: 'boolean',
69
71
  description:
70
- 'Allow public delivery: public handlers run, and with no handler a GitHub issue is filed through the gh CLI.',
72
+ 'Allow public delivery: public handlers run, and a GitHub issues URL gets an issue filed through the gh CLI.',
71
73
  default: 'false',
72
74
  },
75
+ {
76
+ name: 'options.to',
77
+ type: 'string',
78
+ description:
79
+ 'A destination the person chose: a loaded integration whose manifest names an issues URL. The report goes only to that issues URL; handlers do not run.',
80
+ },
73
81
  {
74
82
  name: 'options.listCategories',
75
83
  type: 'boolean',
76
84
  description:
77
- 'Return categories without resolving a route or writing; the component and every other option are refused with ERR_INVALID_ARGUMENT.',
85
+ 'Return categories, and the destinations in meta when there is more than one, without resolving a route or writing; the component and every other option are refused with ERR_INVALID_ARGUMENT.',
78
86
  default: 'false',
79
87
  },
80
88
  {
@@ -115,7 +123,7 @@ export const doc = {
115
123
  },
116
124
  {
117
125
  code: 'ERR_UNKNOWN_PACKAGE',
118
- when: 'the explicitly selected package is not loaded',
126
+ when: 'the explicitly selected package is not loaded, or options.to names no destination (the error lists the destinations)',
119
127
  },
120
128
  {
121
129
  code: 'ERR_NOT_FOUND',
@@ -55,6 +55,14 @@ export const GAP_REPORT_CATEGORIES = Object.freeze([
55
55
  export const PUBLIC_CONFIRMATION_MESSAGE =
56
56
  'Rerun with --confirm-public to file this report.';
57
57
 
58
+ /** What an agent does when more than one destination exists. */
59
+ export const ASK_DESTINATION_MESSAGE =
60
+ 'Ask the person where to file this report, then pass their choice with --to <package>. Never pick a package destination yourself; leave --to out to use the default.';
61
+
62
+ /**
63
+ * @typedef {import('./gap-report.type.mjs').GapReportDestination} GapReportDestination
64
+ */
65
+
58
66
  /**
59
67
  * @typedef {object} ReportTarget
60
68
  * @property {string} package
@@ -537,15 +545,14 @@ function githubRoute(issuesUrl) {
537
545
  }
538
546
 
539
547
  /**
540
- * Built-in GitHub fallback — runs only when the effective handler set is empty.
541
- * Requires confirmPublic.
548
+ * File a report on GitHub with `gh` — for the zero-handler fallback and for a
549
+ * destination the caller names. Requires confirmPublic.
542
550
  *
543
- * @param {ReportTarget} target
544
551
  * @param {{component: string, categoryLabel: string, intention: string, detail?: string, source: string, timestamp: string}} report
545
552
  * @param {{repo: string}} github
546
553
  * @returns {Promise<Pick<import('./gap-report.type.mjs').GapReportDelivery, 'status'|'url'|'message'>>}
547
554
  */
548
- async function runGithubFallback(target, report, github) {
555
+ async function runGithubFallback(report, github) {
549
556
  const {execFile} = await import('node:child_process');
550
557
  const title = `[gap] ${report.component}: ${report.intention.slice(0, 70)}`;
551
558
  const body = [
@@ -607,6 +614,87 @@ async function runGithubFallback(target, report, github) {
607
614
  }
608
615
  }
609
616
 
617
+ /**
618
+ * Send a report to an issues URL: a GitHub issues URL is filed with `gh` only
619
+ * with consent; any other URL comes back as routed_only. Serves the
620
+ * zero-handler fallback (spec:AST-031/FR8) and a destination named with `to`
621
+ * (architecture:cli-surface INV36).
622
+ *
623
+ * @param {string} issuesUrl
624
+ * @param {{component: string, categoryLabel: string, intention: string, detail?: string, source: string, timestamp: string}} report
625
+ * @param {boolean} confirmPublic
626
+ * @returns {Promise<import('./gap-report.type.mjs').GapReportDelivery>}
627
+ */
628
+ async function deliverToIssuesUrl(issuesUrl, report, confirmPublic) {
629
+ const github = githubRoute(issuesUrl);
630
+ if (github != null && !confirmPublic) {
631
+ return {
632
+ handlerType: 'fallback',
633
+ handler: 'github',
634
+ audience: 'public',
635
+ status: 'consent_required',
636
+ url: null,
637
+ message: PUBLIC_CONFIRMATION_MESSAGE,
638
+ };
639
+ }
640
+ if (github) {
641
+ return {
642
+ handlerType: 'fallback',
643
+ handler: 'github',
644
+ audience: 'public',
645
+ ...(await runGithubFallback(report, github)),
646
+ };
647
+ }
648
+ return {
649
+ handlerType: 'fallback',
650
+ handler: 'issuesUrl',
651
+ audience: null,
652
+ status: 'routed_only',
653
+ url: issuesUrl,
654
+ message:
655
+ 'No automatic handler is available; open the routed URL to file this report.',
656
+ };
657
+ }
658
+
659
+ /**
660
+ * Where a report can go: the default (the handlers, or with none the owning
661
+ * package's issues URL), then each loaded integration that names its own
662
+ * issues URL (architecture:cli-surface INV36).
663
+ *
664
+ * @param {Project} project
665
+ * @returns {GapReportDestination[]}
666
+ */
667
+ function listDestinations(project) {
668
+ /** @type {GapReportDestination[]} */
669
+ const destinations = [{to: null, default: true, issuesUrl: null}];
670
+ for (const integration of project.loadedIntegrations) {
671
+ if (integration.__loadError || !integration.issuesUrl) continue;
672
+ if (destinations.some(destination => destination.to === integration.name))
673
+ continue;
674
+ destinations.push({
675
+ to: integration.name,
676
+ default: false,
677
+ issuesUrl: integration.issuesUrl,
678
+ });
679
+ }
680
+ return destinations;
681
+ }
682
+
683
+ /**
684
+ * The destinations of the project at `cwd`, or only the default when no
685
+ * project loads there.
686
+ * @param {string|undefined} cwd
687
+ * @returns {Promise<GapReportDestination[]>}
688
+ */
689
+ async function destinationsAt(cwd) {
690
+ try {
691
+ const {resolve} = await import('node:path');
692
+ return listDestinations(await Project.load(resolve(cwd ?? process.cwd())));
693
+ } catch {
694
+ return [{to: null, default: true, issuesUrl: null}];
695
+ }
696
+ }
697
+
610
698
  /**
611
699
  * Compute the aggregate status from the deliveries.
612
700
  * @param {import('./gap-report.type.mjs').GapReportDelivery[]} deliveries
@@ -665,6 +753,7 @@ export async function gapReport(component, options = {}) {
665
753
  options.detail ? '--additional-context' : null,
666
754
  options.package ? '--package' : null,
667
755
  options.confirmPublic ? '--confirm-public' : null,
756
+ options.to != null ? '--to' : null,
668
757
  ].filter(Boolean);
669
758
  if (ignored.length > 0) {
670
759
  throw new AstryxError(
@@ -673,9 +762,13 @@ export async function gapReport(component, options = {}) {
673
762
  ERROR_CODES.ERR_INVALID_ARGUMENT,
674
763
  );
675
764
  }
765
+ const destinations = await destinationsAt(options.cwd);
676
766
  return {
677
767
  type: 'gap-report.categories',
678
768
  data: GAP_REPORT_CATEGORIES.map(category => ({...category})),
769
+ ...(destinations.length > 1
770
+ ? {meta: {destinations, ask: ASK_DESTINATION_MESSAGE}}
771
+ : {}),
679
772
  };
680
773
  }
681
774
 
@@ -704,7 +797,33 @@ export async function gapReport(component, options = {}) {
704
797
  options.package,
705
798
  );
706
799
 
707
- const entries = collectGapReportHandlers(project);
800
+ const destinations = listDestinations(project);
801
+ /** @type {GapReportDestination | undefined} */
802
+ let chosen;
803
+ // `to: null` is absent, like `package: null`; any other value is matched
804
+ // against the destinations as given, so an empty or unknown one lists them.
805
+ if (options.to != null) {
806
+ const to = options.to;
807
+ chosen = destinations.find(
808
+ destination => !destination.default && destination.to === to,
809
+ );
810
+ if (!chosen) {
811
+ const choices = destinations.filter(destination => !destination.default);
812
+ const named = JSON.stringify(String(to).slice(0, 214));
813
+ throw new AstryxError(
814
+ choices.length > 0
815
+ ? `No gap-report destination ${named}. Choose one of: ${choices.map(destination => destination.to).join(', ')}; or leave out --to for the default.`
816
+ : `No gap-report destination ${named}: no loaded integration names an issues URL. Leave out --to for the default.`,
817
+ choices.map(destination => ({
818
+ name: /** @type {string} */ (destination.to),
819
+ reason: /** @type {string} */ (destination.issuesUrl),
820
+ })),
821
+ ERROR_CODES.ERR_UNKNOWN_PACKAGE,
822
+ );
823
+ }
824
+ }
825
+
826
+ const entries = chosen ? [] : collectGapReportHandlers(project);
708
827
 
709
828
  const timestamp = new Date().toISOString();
710
829
  const source = captureEnv().invocationSource;
@@ -731,8 +850,24 @@ export async function gapReport(component, options = {}) {
731
850
 
732
851
  /** @type {import('./gap-report.type.mjs').GapReportDelivery[]} */
733
852
  const deliveries = [];
853
+ const routeReport = {
854
+ component: resolvedComponent,
855
+ categoryLabel: categoryEntry.label,
856
+ intention,
857
+ detail,
858
+ source,
859
+ timestamp,
860
+ };
734
861
 
735
- if (entries.length > 0) {
862
+ if (chosen) {
863
+ deliveries.push(
864
+ await deliverToIssuesUrl(
865
+ /** @type {string} */ (chosen.issuesUrl),
866
+ routeReport,
867
+ options.confirmPublic === true,
868
+ ),
869
+ );
870
+ } else if (entries.length > 0) {
736
871
  deliveries.push(
737
872
  ...(await deliverGapReportHandlers(entries, report, {
738
873
  confirmPublic: options.confirmPublic === true,
@@ -746,47 +881,13 @@ export async function gapReport(component, options = {}) {
746
881
  ERROR_CODES.ERR_NOT_FOUND,
747
882
  );
748
883
  }
749
-
750
- const github = githubRoute(target.issuesUrl);
751
- if (github != null && options.confirmPublic !== true) {
752
- deliveries.push({
753
- handlerType: 'fallback',
754
- handler: 'github',
755
- audience: 'public',
756
- status: 'consent_required',
757
- url: null,
758
- message: PUBLIC_CONFIRMATION_MESSAGE,
759
- });
760
- } else if (github) {
761
- const outcome = await runGithubFallback(
762
- target,
763
- {
764
- component: resolvedComponent,
765
- categoryLabel: categoryEntry.label,
766
- intention,
767
- detail,
768
- source,
769
- timestamp,
770
- },
771
- github,
772
- );
773
- deliveries.push({
774
- handlerType: 'fallback',
775
- handler: 'github',
776
- audience: 'public',
777
- ...outcome,
778
- });
779
- } else {
780
- deliveries.push({
781
- handlerType: 'fallback',
782
- handler: 'issuesUrl',
783
- audience: null,
784
- status: 'routed_only',
785
- url: target.issuesUrl,
786
- message:
787
- 'No automatic handler is available; open the routed URL to file this report.',
788
- });
789
- }
884
+ deliveries.push(
885
+ await deliverToIssuesUrl(
886
+ target.issuesUrl,
887
+ routeReport,
888
+ options.confirmPublic === true,
889
+ ),
890
+ );
790
891
  }
791
892
 
792
893
  const filedCount = deliveries.filter(d => d.status === 'filed').length;
@@ -800,10 +901,13 @@ export async function gapReport(component, options = {}) {
800
901
  data: {
801
902
  status,
802
903
  package: target.package,
803
- issuesUrl: target.issuesUrl,
904
+ issuesUrl: chosen ? chosen.issuesUrl : target.issuesUrl,
804
905
  deliveries,
805
906
  filedCount,
806
907
  routedOnlyCount,
908
+ ...(!chosen && destinations.length > 1
909
+ ? {destinations, ask: ASK_DESTINATION_MESSAGE}
910
+ : {}),
807
911
  },
808
912
  };
809
913
  }