@astryxdesign/cli 0.7.2-canary.6fddf4f → 0.7.2-canary.72db6f9
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.
- package/README.md +62 -62
- package/api/component/_adapter.d.mts +31 -0
- package/api/component/_adapter.mjs +116 -0
- package/api/component/component.mjs +60 -10
- package/api/component/doc-links.test.mjs +386 -0
- package/api/discover/_adapter.d.mts +119 -12
- package/api/discover/_adapter.mjs +449 -10
- package/api/discover/_adapter.test.mjs +599 -17
- package/api/discover/_catalog-view.d.mts +16 -5
- package/api/discover/_catalog-view.mjs +32 -8
- package/api/discover/detail/doc/doc.mjs +9 -1
- package/api/discover/discover.d.mts +11 -0
- package/api/discover/discover.doc.mjs +7 -6
- package/api/discover/discover.mjs +107 -19
- package/api/discover/discover.type.d.mts +18 -7
- package/api/discover/discover.type.mjs +15 -7
- package/api/discover/list/list.d.mts +4 -3
- package/api/discover/list/list.mjs +17 -10
- package/api/docs/_adapter.d.mts +63 -0
- package/api/docs/_adapter.mjs +309 -16
- package/api/docs/integration-tree.test.mjs +22 -0
- package/api/docs/list/list.mjs +12 -2
- package/api/doctor/theme-checks.test.mjs +136 -0
- package/api/gap-report/gap-report.d.mts +3 -0
- package/api/gap-report/gap-report.doc.mjs +11 -3
- package/api/gap-report/gap-report.mjs +152 -48
- package/api/gap-report/gap-report.test.mjs +233 -0
- package/api/gap-report/gap-report.type.d.mts +41 -0
- package/api/gap-report/gap-report.type.mjs +18 -0
- package/api/integration/_adapter.d.mts +33 -0
- package/api/integration/_adapter.mjs +58 -0
- package/api/integration/authoring-checks.mjs +98 -3
- package/api/integration/authoring-checks.test.mjs +769 -0
- package/api/integration/authoring-checks.type.d.mts +134 -0
- package/api/integration/authoring-checks.type.mjs +60 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +3 -1
- package/api/integration/integrationDocConflicts.doc.mjs +22 -5
- package/api/integration/pack-check.mjs +296 -7
- package/api/integration/pack-check.test.mjs +367 -0
- package/api/integration/validate-integration-fixes.test.mjs +67 -0
- package/api/integration/validate-integration.mjs +28 -3
- package/api/integration/validate-integration.test.mjs +77 -8
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/search.mjs +2 -1
- package/api/upgrade/_adapter.d.mts +40 -2
- package/api/upgrade/_adapter.mjs +117 -4
- package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
- package/api/upgrade/run/run.mjs +30 -1
- package/api/upgrade/status/status.d.mts +21 -5
- package/api/upgrade/status/status.mjs +45 -8
- package/api/upgrade/upgrade.doc.mjs +5 -3
- package/api/upgrade/upgrade.type.d.mts +23 -0
- package/api/upgrade/upgrade.type.mjs +16 -1
- package/assets/codemods/runner.mjs +7 -1
- package/assets/discover/official-packages.json +367 -0
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +3 -3
- package/assets/docs/tree/check-the-props.doc.mjs +7 -2
- package/assets/docs/tree/check-your-docs.doc.mjs +15 -3
- package/assets/docs/tree/checks.doc.mjs +5 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +25 -5
- package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
- package/assets/docs/tree/layout.doc.mjs +6 -6
- package/assets/docs/tree/migration-setup.doc.mjs +2 -2
- package/assets/docs/tree/publishing.doc.mjs +3 -3
- package/assets/docs/tree/quick-start.doc.mjs +2 -2
- package/assets/docs/tree/sections-and-placement.doc.mjs +2 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +5 -5
- package/assets/docs/tree/upgrading.doc.mjs +1 -1
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -0
- package/authoring/doctypes/hook/type.ts +4 -0
- package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
- package/clients/cli/commands/discover.doc.mjs +1 -1
- package/clients/cli/commands/discover.mjs +144 -93
- package/clients/cli/commands/discover.no-source.test.mjs +447 -33
- package/clients/cli/commands/discover.sources.test.mjs +20 -1
- package/clients/cli/commands/doctor-integration-components.doc.mjs +3 -2
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +19 -5
- package/clients/cli/commands/doctor-integration.test.mjs +48 -1
- package/clients/cli/commands/doctor.mjs +91 -5
- package/clients/cli/commands/gap-report.doc.mjs +14 -2
- package/clients/cli/commands/gap-report.mjs +24 -2
- package/clients/cli/commands/gap-report.test.mjs +79 -0
- package/clients/cli/commands/integration-authoring.test.mjs +46 -0
- package/clients/cli/commands/integration-check.test.mjs +144 -0
- package/clients/cli/commands/integration.mjs +12 -7
- package/clients/cli/commands/json-contract.test.mjs +5 -1
- package/clients/cli/commands/upgrade.doc.mjs +14 -0
- package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
- package/foundation/discovery/copied-passages.d.mts +216 -0
- package/foundation/discovery/copied-passages.mjs +720 -0
- package/foundation/discovery/copied-passages.test.mjs +124 -0
- package/foundation/discovery/doc-consistency.d.mts +34 -0
- package/foundation/discovery/doc-consistency.mjs +513 -0
- package/foundation/discovery/doc-consistency.test.mjs +347 -0
- package/foundation/discovery/doc-fluff.d.mts +112 -0
- package/foundation/discovery/doc-fluff.mjs +328 -0
- package/foundation/discovery/doc-fluff.test.mjs +142 -0
- package/foundation/discovery/doc-types.mjs +12 -5
- package/foundation/discovery/doc-types.test.mjs +46 -2
- package/foundation/discovery/docs-discovery.d.mts +7 -0
- package/foundation/discovery/docs-discovery.mjs +26 -2
- package/foundation/discovery/prop-drift.d.mts +25 -6
- package/foundation/discovery/prop-drift.mjs +171 -6
- package/foundation/discovery/prop-drift.test.mjs +65 -0
- package/foundation/discovery/stray-pointers.d.mts +52 -0
- package/foundation/discovery/stray-pointers.mjs +293 -0
- package/foundation/discovery/stray-pointers.test.mjs +86 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +16 -0
- package/foundation/doc-compiler/links.d.mts +32 -0
- package/foundation/doc-compiler/links.mjs +163 -26
- package/foundation/doc-compiler/links.test.mjs +97 -4
- package/foundation/doc-compiler/tree.mjs +30 -1
- package/foundation/doc-compiler/tree.test.mjs +7 -0
- package/foundation/env/package-manager.d.mts +32 -0
- package/foundation/env/package-manager.mjs +47 -0
- package/foundation/env/package-manager.test.mjs +194 -7
- package/foundation/fs/module-loader.d.mts +2 -1
- package/foundation/fs/module-loader.mjs +60 -4
- package/foundation/fs/module-loader.test.mjs +194 -0
- package/foundation/integrations/contribution-inventory.d.mts +11 -0
- package/foundation/integrations/contribution-inventory.mjs +50 -2
- package/foundation/integrations/issue.ts +6 -0
- package/foundation/integrations/validate-contributions.mjs +30 -1
- package/foundation/response/response-types.doc.mjs +10 -9
- 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
|
|
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
|
-
*
|
|
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(
|
|
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
|
|
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 (
|
|
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
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
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
|
}
|