@astryxdesign/cli 0.7.2-canary.5c75a75 → 0.7.2-canary.6a3ff0f
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 +19 -18
- package/api/build/help/help.mjs +1 -1
- package/api/component/_adapter.d.mts +41 -1
- package/api/component/_adapter.mjs +93 -7
- package/api/component/component.mjs +22 -5
- package/api/component/component.test.mjs +420 -167
- package/api/component/integration-export-name.test.mjs +644 -0
- package/api/component/list/list.mjs +42 -4
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +244 -1
- package/api/docs/integrationDocs.test.mjs +124 -0
- package/api/doctor/doctor.mjs +27 -3
- package/api/doctor/doctor.test.mjs +43 -0
- package/api/doctor/theme-checks.mjs +1 -1
- 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 +219 -52
- 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/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/init/run/run.mjs +2 -2
- package/api/integration/_adapter.d.mts +12 -0
- package/api/integration/_adapter.mjs +54 -0
- package/api/integration/add-contribution.component-names.test.mjs +66 -0
- package/api/integration/add-contribution.mjs +8 -4
- package/api/integration/add-contribution.test.mjs +4 -2
- package/api/integration/authoring-checks.mjs +11 -2
- package/api/integration/authoring-checks.test.mjs +39 -0
- package/api/integration/authoring-checks.type.d.mts +9 -0
- package/api/integration/authoring-checks.type.mjs +14 -1
- package/api/integration/check/check.d.mts +96 -0
- package/api/integration/check/check.mjs +357 -0
- package/api/integration/check/check.test.mjs +489 -0
- package/api/integration/integration-check.type.d.mts +118 -0
- package/api/integration/integration-check.type.mjs +84 -0
- package/api/integration/integrationCheck.doc.d.mts +10 -0
- package/api/integration/integrationCheck.doc.mjs +73 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +43 -6
- package/api/integration/pack-check.mjs +61 -107
- package/api/integration/pack-check.test.mjs +359 -0
- package/api/integration/validate-integration.mjs +8 -0
- package/api/integration/validate-integration.test.mjs +11 -0
- package/api/integration/validate-integration.type.d.mts +8 -0
- package/api/integration/validate-integration.type.mjs +12 -1
- package/api/integration/validateIntegration.doc.mjs +19 -3
- package/api/search/search.d.mts +81 -12
- package/api/search/search.domain-priority.test.mjs +108 -18
- package/api/search/search.integration-check.test.mjs +24 -0
- package/api/search/search.mjs +609 -53
- package/api/search/search.test.mjs +175 -0
- package/api/swizzle/copy/copy.mjs +28 -14
- package/api/template/template.test.mjs +120 -3
- package/api/theme/build/build.family.test.mjs +64 -0
- package/api/theme/build/build.mjs +180 -24
- package/api/theme/themeBuild.doc.mjs +4 -4
- 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/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
- package/assets/docs/README.md +10 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/add-a-component.doc.mjs +11 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +10 -7
- package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
- package/assets/docs/tree/block-template.doc.mjs +8 -20
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/check-the-props.doc.mjs +196 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +51 -5
- package/assets/docs/tree/checks.doc.mjs +24 -16
- package/assets/docs/tree/codemods.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +8 -6
- package/assets/docs/tree/component-imports.doc.mjs +10 -2
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +25 -16
- package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
- package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
- package/assets/docs/tree/docs.doc.mjs +3 -3
- package/assets/docs/tree/document-the-template.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
- package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
- package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
- package/assets/docs/tree/integrations.doc.mjs +8 -0
- package/assets/docs/tree/links.doc.mjs +6 -5
- package/assets/docs/tree/migration-setup.doc.mjs +1 -0
- package/assets/docs/tree/migration-verification.doc.mjs +0 -1
- package/assets/docs/tree/migration.doc.mjs +0 -1
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +4 -8
- package/assets/docs/tree/publishing.doc.mjs +1 -1
- package/assets/docs/tree/quick-start.doc.mjs +37 -21
- package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
- package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
- package/assets/docs/tree/sections-and-placement.doc.mjs +4 -6
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
- package/assets/docs/tree/single-component.doc.mjs +15 -6
- package/assets/docs/tree/start-a-template.doc.mjs +3 -3
- package/assets/docs/tree/subcomponent.doc.mjs +6 -6
- package/assets/docs/tree/template-assets.doc.mjs +2 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +4 -15
- package/assets/docs/tree/template-fonts.doc.mjs +1 -1
- package/assets/docs/tree/template-icons.doc.mjs +1 -1
- package/assets/docs/tree/template-images-media.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +2 -2
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
- package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
- package/assets/docs/tree/type-scale.doc.mjs +3 -3
- package/assets/docs/tree/upgrading.doc.mjs +3 -3
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +7 -6
- package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/docs/working-with-ai.doc.mjs +43 -4
- package/assets/templates/blocks/components/Drawer/DrawerForm.doc.mjs +24 -0
- package/assets/templates/blocks/components/Drawer/DrawerForm.tsx +62 -0
- package/assets/templates/blocks/components/Drawer/DrawerScrim.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerScrim.tsx +68 -0
- package/assets/templates/blocks/components/Drawer/DrawerShowcase.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerShowcase.tsx +41 -0
- package/assets/templates/blocks/components/Drawer/DrawerStart.doc.mjs +21 -0
- package/assets/templates/blocks/components/Drawer/DrawerStart.tsx +41 -0
- package/assets/templates/blocks/components/Drawer/DrawerWidths.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerWidths.tsx +54 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.tsx +73 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.doc.mjs +22 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.tsx +49 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.doc.mjs +21 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.tsx +42 -0
- package/assets/templates/pages/detail-page/page.tsx +3 -3
- package/assets/templates/pages/table-inbox/page.tsx +10 -8
- package/assets/theme.template.ts +1 -1
- package/authoring/codemod/codemod.doc.mjs +7 -3
- package/authoring/config/config.doc.mjs +9 -6
- package/authoring/config/type.ts +4 -2
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
- package/authoring/doctypes/base/type.ts +6 -0
- package/authoring/doctypes/command/command.doc.mjs +14 -12
- package/authoring/doctypes/component/component.doc.mjs +31 -28
- package/authoring/doctypes/component/type.ts +13 -8
- package/authoring/doctypes/enum/enum.doc.mjs +7 -4
- package/authoring/doctypes/function/function.doc.mjs +9 -8
- package/authoring/doctypes/hook/hook.doc.mjs +5 -4
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
- package/authoring/doctypes/reference/reference.doc.mjs +11 -10
- package/authoring/doctypes/schema/schema.doc.mjs +9 -9
- package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
- package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
- package/authoring/doctypes/template/parse.d.mts +6 -2
- package/authoring/doctypes/template/parse.mjs +3 -1
- package/authoring/doctypes/template/template.doc.mjs +3 -3
- package/authoring/doctypes/template/type.ts +22 -0
- package/authoring/doctypes/theme/theme.doc.mjs +2 -2
- package/authoring/gap-report/gap-report.doc.mjs +2 -2
- package/authoring/identity/identity.doc.mjs +3 -3
- package/authoring/index.d.ts +1 -0
- package/authoring/integration/integration.doc.mjs +12 -4
- package/authoring/integration/parse.test.mjs +10 -0
- package/authoring/integration/schema.d.mts +2 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +4 -0
- package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
- package/clients/cli/commands/build-theme.mjs +1 -1
- package/clients/cli/commands/build-theme.path-safety.test.mjs +224 -6
- package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
- package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
- package/clients/cli/commands/doctor-integration-components.doc.mjs +17 -4
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
- package/clients/cli/commands/doctor-integration.test.mjs +837 -0
- package/clients/cli/commands/doctor.mjs +190 -0
- 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-check.doc.mjs +85 -0
- package/clients/cli/commands/integration-check.test.mjs +284 -0
- package/clients/cli/commands/integration.doc.mjs +6 -2
- package/clients/cli/commands/integration.mjs +106 -1
- package/clients/cli/commands/setup-nudge.test.mjs +79 -1
- package/clients/cli/commands/swizzle.mjs +5 -3
- package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
- package/clients/cli/commands/text-json-parity.test.mjs +5 -0
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/upgrade.doc.mjs +14 -0
- package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
- package/clients/cli/index.mjs +30 -5
- package/clients/cli/lib/component-format.mjs +5 -1
- package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
- package/foundation/agent-docs/agent-doc-state.mjs +38 -0
- package/foundation/agent-docs/agent-docs.d.mts +2 -1
- package/foundation/agent-docs/agent-docs.mjs +8 -6
- package/foundation/config/project.mjs +82 -0
- package/foundation/discovery/authoring-self-docs.mjs +2 -1
- package/foundation/discovery/component-discovery.d.mts +190 -10
- package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
- package/foundation/discovery/component-discovery.mjs +864 -56
- package/foundation/discovery/component-discovery.test.mjs +96 -0
- package/foundation/discovery/component-replacement.mjs +18 -0
- package/foundation/discovery/component-replacement.test.mjs +40 -0
- package/foundation/discovery/doc-types.d.mts +157 -0
- package/foundation/discovery/doc-types.mjs +1224 -0
- package/foundation/discovery/doc-types.test.mjs +700 -0
- package/foundation/discovery/docs-discovery.d.mts +81 -0
- package/foundation/discovery/docs-discovery.mjs +57 -0
- package/foundation/discovery/integration-doc-files.d.mts +22 -0
- package/foundation/discovery/integration-doc-files.mjs +231 -0
- package/foundation/discovery/integration-doc-files.test.mjs +246 -0
- package/foundation/discovery/module-exports.d.mts +27 -0
- package/foundation/discovery/module-exports.mjs +356 -31
- package/foundation/discovery/module-exports.test.mjs +172 -0
- package/foundation/discovery/package-tsconfig.d.mts +14 -0
- package/foundation/discovery/package-tsconfig.mjs +228 -0
- package/foundation/discovery/package-tsconfig.test.mjs +210 -0
- package/foundation/discovery/project-typescript.d.mts +32 -0
- package/foundation/discovery/project-typescript.mjs +89 -0
- package/foundation/discovery/prop-drift.d.mts +278 -0
- package/foundation/discovery/prop-drift.mjs +2263 -0
- package/foundation/discovery/prop-drift.test.mjs +2272 -0
- package/foundation/discovery/template-adapter.mjs +74 -5
- package/foundation/discovery/type-match.d.mts +53 -0
- package/foundation/discovery/type-match.mjs +660 -0
- package/foundation/discovery/type-match.test.mjs +169 -0
- package/foundation/discovery/type-text.d.mts +68 -0
- package/foundation/discovery/type-text.mjs +658 -0
- package/foundation/discovery/type-text.test.mjs +196 -0
- package/foundation/discovery/unresolved-references.d.mts +62 -0
- package/foundation/discovery/unresolved-references.mjs +790 -0
- package/foundation/discovery/unresolved-references.test.mjs +567 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +15 -1
- package/foundation/doc-compiler/inputs.mjs +23 -0
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/links.d.mts +9 -5
- package/foundation/doc-compiler/links.mjs +4 -2
- 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/integrations/contribution-inventory.mjs +6 -1
- package/foundation/response/response-types.doc.mjs +12 -6
- package/foundation/xle/registry.mjs +4 -0
- package/foundation/xle/registry.test.mjs +28 -0
- package/package.json +10 -10
- package/scripts/postinstall.mjs +3 -3
|
@@ -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',
|
|
@@ -17,7 +17,18 @@
|
|
|
17
17
|
import {Worker} from 'node:worker_threads';
|
|
18
18
|
import {AstryxError} from '../error.mjs';
|
|
19
19
|
import {Project} from '../../foundation/config/project.mjs';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
CORE_PACKAGE,
|
|
22
|
+
discoverIntegrationComponents,
|
|
23
|
+
docStem,
|
|
24
|
+
findComponentReadme,
|
|
25
|
+
findIntegrationComponent,
|
|
26
|
+
integrationRecordHold,
|
|
27
|
+
isIntegrationMember,
|
|
28
|
+
unscopedComponentOwners,
|
|
29
|
+
} from '../../foundation/discovery/component-discovery.mjs';
|
|
30
|
+
import {legacyExternalKeeps} from '../component/_adapter.mjs';
|
|
31
|
+
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
21
32
|
import {captureEnv} from '../../foundation/debug/event.mjs';
|
|
22
33
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
23
34
|
import {parseGapReportReceipt} from '../../authoring/gap-report/parse.mjs';
|
|
@@ -44,6 +55,14 @@ export const GAP_REPORT_CATEGORIES = Object.freeze([
|
|
|
44
55
|
export const PUBLIC_CONFIRMATION_MESSAGE =
|
|
45
56
|
'Rerun with --confirm-public to file this report.';
|
|
46
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
|
+
|
|
47
66
|
/**
|
|
48
67
|
* @typedef {object} ReportTarget
|
|
49
68
|
* @property {string} package
|
|
@@ -178,13 +197,65 @@ async function selectTarget(project, component, packageName) {
|
|
|
178
197
|
coreName,
|
|
179
198
|
);
|
|
180
199
|
if (replacement) return targetForPackage(project, replacement.package);
|
|
200
|
+
// The owner rule runs over every owner discovery finds, loadable or not
|
|
201
|
+
// (a doc recorded under another export still answers to its file's name);
|
|
202
|
+
// then only owners whose docs load route a report.
|
|
203
|
+
const wanted = bareComponent.toLowerCase();
|
|
204
|
+
const loads = new Set(records.map(r => `${r.package}\0${r.docPath}`));
|
|
205
|
+
const recorded = project.loadedIntegrations.flatMap(integration =>
|
|
206
|
+
discoverIntegrationComponents(integration).flatMap(r =>
|
|
207
|
+
r.name.toLowerCase() === wanted
|
|
208
|
+
? [{...r, hold: integrationRecordHold(r)}]
|
|
209
|
+
: docStem(r.docPath).toLowerCase() === wanted && !isIntegrationMember(r)
|
|
210
|
+
? [{...r, hold: 'doc'}]
|
|
211
|
+
: [],
|
|
212
|
+
),
|
|
213
|
+
);
|
|
214
|
+
// The checks below find files by name, so they run on every spelling the
|
|
215
|
+
// case-blind match above found, as well as the one typed.
|
|
216
|
+
const spellings = new Set([
|
|
217
|
+
bareComponent,
|
|
218
|
+
...recorded.flatMap(r =>
|
|
219
|
+
[r.name, docStem(r.docPath)].filter(n => n.toLowerCase() === wanted),
|
|
220
|
+
),
|
|
221
|
+
]);
|
|
222
|
+
// Core also holds a name only its doc lookup finds, as in detail: a name a
|
|
223
|
+
// doc records yields to it, though it routes no report itself.
|
|
224
|
+
const coreDir = findCoreDir(project.cwd);
|
|
225
|
+
const coreDocs =
|
|
226
|
+
coreDir != null &&
|
|
227
|
+
[...spellings].some(name => findComponentReadme(coreDir, name) != null);
|
|
228
|
+
const ruled = unscopedComponentOwners([
|
|
229
|
+
...records
|
|
230
|
+
.filter(
|
|
231
|
+
r => r.package === CORE_PACKAGE && r.name.toLowerCase() === wanted,
|
|
232
|
+
)
|
|
233
|
+
.map(r => ({...r, hold: 'core'})),
|
|
234
|
+
...recorded,
|
|
235
|
+
// A hidden doc named after its file still holds that name, as the
|
|
236
|
+
// component lookup finds it; it routes no report.
|
|
237
|
+
...project.loadedIntegrations.flatMap(integration =>
|
|
238
|
+
[...spellings].flatMap(spelling => {
|
|
239
|
+
const found = findIntegrationComponent(integration, spelling);
|
|
240
|
+
return found?.hold === 'file'
|
|
241
|
+
? [{...found, package: integration.name}]
|
|
242
|
+
: [];
|
|
243
|
+
}),
|
|
244
|
+
),
|
|
245
|
+
]).filter(r => !coreDocs || r.hold !== 'doc');
|
|
246
|
+
// A legacy docs package keeps an export name a doc records, as in detail.
|
|
181
247
|
const owners = [
|
|
182
248
|
...new Set(
|
|
183
|
-
|
|
249
|
+
([...spellings].some(name =>
|
|
250
|
+
legacyExternalKeeps(project.cwd, name, ruled),
|
|
251
|
+
)
|
|
252
|
+
? []
|
|
253
|
+
: ruled
|
|
254
|
+
)
|
|
184
255
|
.filter(
|
|
185
|
-
|
|
256
|
+
r => r.hold === 'core' || loads.has(`${r.package}\0${r.docPath}`),
|
|
186
257
|
)
|
|
187
|
-
.map(
|
|
258
|
+
.map(r => r.package),
|
|
188
259
|
),
|
|
189
260
|
];
|
|
190
261
|
|
|
@@ -474,15 +545,14 @@ function githubRoute(issuesUrl) {
|
|
|
474
545
|
}
|
|
475
546
|
|
|
476
547
|
/**
|
|
477
|
-
*
|
|
478
|
-
* 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.
|
|
479
550
|
*
|
|
480
|
-
* @param {ReportTarget} target
|
|
481
551
|
* @param {{component: string, categoryLabel: string, intention: string, detail?: string, source: string, timestamp: string}} report
|
|
482
552
|
* @param {{repo: string}} github
|
|
483
553
|
* @returns {Promise<Pick<import('./gap-report.type.mjs').GapReportDelivery, 'status'|'url'|'message'>>}
|
|
484
554
|
*/
|
|
485
|
-
async function runGithubFallback(
|
|
555
|
+
async function runGithubFallback(report, github) {
|
|
486
556
|
const {execFile} = await import('node:child_process');
|
|
487
557
|
const title = `[gap] ${report.component}: ${report.intention.slice(0, 70)}`;
|
|
488
558
|
const body = [
|
|
@@ -544,6 +614,87 @@ async function runGithubFallback(target, report, github) {
|
|
|
544
614
|
}
|
|
545
615
|
}
|
|
546
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
|
+
|
|
547
698
|
/**
|
|
548
699
|
* Compute the aggregate status from the deliveries.
|
|
549
700
|
* @param {import('./gap-report.type.mjs').GapReportDelivery[]} deliveries
|
|
@@ -602,6 +753,7 @@ export async function gapReport(component, options = {}) {
|
|
|
602
753
|
options.detail ? '--additional-context' : null,
|
|
603
754
|
options.package ? '--package' : null,
|
|
604
755
|
options.confirmPublic ? '--confirm-public' : null,
|
|
756
|
+
options.to != null ? '--to' : null,
|
|
605
757
|
].filter(Boolean);
|
|
606
758
|
if (ignored.length > 0) {
|
|
607
759
|
throw new AstryxError(
|
|
@@ -610,9 +762,13 @@ export async function gapReport(component, options = {}) {
|
|
|
610
762
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
611
763
|
);
|
|
612
764
|
}
|
|
765
|
+
const destinations = await destinationsAt(options.cwd);
|
|
613
766
|
return {
|
|
614
767
|
type: 'gap-report.categories',
|
|
615
768
|
data: GAP_REPORT_CATEGORIES.map(category => ({...category})),
|
|
769
|
+
...(destinations.length > 1
|
|
770
|
+
? {meta: {destinations, ask: ASK_DESTINATION_MESSAGE}}
|
|
771
|
+
: {}),
|
|
616
772
|
};
|
|
617
773
|
}
|
|
618
774
|
|
|
@@ -641,7 +797,33 @@ export async function gapReport(component, options = {}) {
|
|
|
641
797
|
options.package,
|
|
642
798
|
);
|
|
643
799
|
|
|
644
|
-
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);
|
|
645
827
|
|
|
646
828
|
const timestamp = new Date().toISOString();
|
|
647
829
|
const source = captureEnv().invocationSource;
|
|
@@ -668,8 +850,24 @@ export async function gapReport(component, options = {}) {
|
|
|
668
850
|
|
|
669
851
|
/** @type {import('./gap-report.type.mjs').GapReportDelivery[]} */
|
|
670
852
|
const deliveries = [];
|
|
853
|
+
const routeReport = {
|
|
854
|
+
component: resolvedComponent,
|
|
855
|
+
categoryLabel: categoryEntry.label,
|
|
856
|
+
intention,
|
|
857
|
+
detail,
|
|
858
|
+
source,
|
|
859
|
+
timestamp,
|
|
860
|
+
};
|
|
671
861
|
|
|
672
|
-
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) {
|
|
673
871
|
deliveries.push(
|
|
674
872
|
...(await deliverGapReportHandlers(entries, report, {
|
|
675
873
|
confirmPublic: options.confirmPublic === true,
|
|
@@ -683,47 +881,13 @@ export async function gapReport(component, options = {}) {
|
|
|
683
881
|
ERROR_CODES.ERR_NOT_FOUND,
|
|
684
882
|
);
|
|
685
883
|
}
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
status: 'consent_required',
|
|
694
|
-
url: null,
|
|
695
|
-
message: PUBLIC_CONFIRMATION_MESSAGE,
|
|
696
|
-
});
|
|
697
|
-
} else if (github) {
|
|
698
|
-
const outcome = await runGithubFallback(
|
|
699
|
-
target,
|
|
700
|
-
{
|
|
701
|
-
component: resolvedComponent,
|
|
702
|
-
categoryLabel: categoryEntry.label,
|
|
703
|
-
intention,
|
|
704
|
-
detail,
|
|
705
|
-
source,
|
|
706
|
-
timestamp,
|
|
707
|
-
},
|
|
708
|
-
github,
|
|
709
|
-
);
|
|
710
|
-
deliveries.push({
|
|
711
|
-
handlerType: 'fallback',
|
|
712
|
-
handler: 'github',
|
|
713
|
-
audience: 'public',
|
|
714
|
-
...outcome,
|
|
715
|
-
});
|
|
716
|
-
} else {
|
|
717
|
-
deliveries.push({
|
|
718
|
-
handlerType: 'fallback',
|
|
719
|
-
handler: 'issuesUrl',
|
|
720
|
-
audience: null,
|
|
721
|
-
status: 'routed_only',
|
|
722
|
-
url: target.issuesUrl,
|
|
723
|
-
message:
|
|
724
|
-
'No automatic handler is available; open the routed URL to file this report.',
|
|
725
|
-
});
|
|
726
|
-
}
|
|
884
|
+
deliveries.push(
|
|
885
|
+
await deliverToIssuesUrl(
|
|
886
|
+
target.issuesUrl,
|
|
887
|
+
routeReport,
|
|
888
|
+
options.confirmPublic === true,
|
|
889
|
+
),
|
|
890
|
+
);
|
|
727
891
|
}
|
|
728
892
|
|
|
729
893
|
const filedCount = deliveries.filter(d => d.status === 'filed').length;
|
|
@@ -737,10 +901,13 @@ export async function gapReport(component, options = {}) {
|
|
|
737
901
|
data: {
|
|
738
902
|
status,
|
|
739
903
|
package: target.package,
|
|
740
|
-
issuesUrl: target.issuesUrl,
|
|
904
|
+
issuesUrl: chosen ? chosen.issuesUrl : target.issuesUrl,
|
|
741
905
|
deliveries,
|
|
742
906
|
filedCount,
|
|
743
907
|
routedOnlyCount,
|
|
908
|
+
...(!chosen && destinations.length > 1
|
|
909
|
+
? {destinations, ask: ASK_DESTINATION_MESSAGE}
|
|
910
|
+
: {}),
|
|
744
911
|
},
|
|
745
912
|
};
|
|
746
913
|
}
|
|
@@ -7,6 +7,7 @@ import * as path from 'node:path';
|
|
|
7
7
|
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
|
8
8
|
import {Project} from '../../foundation/config/project.mjs';
|
|
9
9
|
import {
|
|
10
|
+
ASK_DESTINATION_MESSAGE,
|
|
10
11
|
GAP_REPORT_CATEGORIES,
|
|
11
12
|
PUBLIC_CONFIRMATION_MESSAGE,
|
|
12
13
|
collectGapReportHandlers,
|
|
@@ -1022,6 +1023,238 @@ console.log('https://github.com/acme/widgets/issues/42');
|
|
|
1022
1023
|
});
|
|
1023
1024
|
});
|
|
1024
1025
|
|
|
1026
|
+
describe('gapReport destinations and --to', () => {
|
|
1027
|
+
/** A shared internal handler that records each call in a marker file. */
|
|
1028
|
+
function addSharedHandler() {
|
|
1029
|
+
const marker = path.join(projectDir, 'shared-called');
|
|
1030
|
+
addIntegration({
|
|
1031
|
+
name: '@test/shared',
|
|
1032
|
+
audience: 'internal',
|
|
1033
|
+
handleBody: `(await import('node:fs')).writeFileSync(${JSON.stringify(marker)}, 'x'); return {status: 'filed', message: 'shared'};`,
|
|
1034
|
+
});
|
|
1035
|
+
return marker;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
function addWidgets(issuesUrl = 'https://github.com/acme/widgets/issues') {
|
|
1039
|
+
addIntegration({name: '@test/widgets', handler: false, issuesUrl});
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
it('keeps the default route and lists the destinations with the ask line', async () => {
|
|
1043
|
+
const marker = addSharedHandler();
|
|
1044
|
+
addWidgets();
|
|
1045
|
+
configure(['@test/shared', '@test/widgets']);
|
|
1046
|
+
const argsFile = stubGh();
|
|
1047
|
+
|
|
1048
|
+
const result = await gapReport('General', {
|
|
1049
|
+
...reportOptions,
|
|
1050
|
+
confirmPublic: true,
|
|
1051
|
+
cwd: projectDir,
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
expect(result.data.deliveries).toEqual([
|
|
1055
|
+
expect.objectContaining({handler: '@test/shared', status: 'filed'}),
|
|
1056
|
+
]);
|
|
1057
|
+
expect(fs.existsSync(marker)).toBe(true);
|
|
1058
|
+
expect(fs.existsSync(argsFile)).toBe(false);
|
|
1059
|
+
expect(result.data.destinations).toEqual([
|
|
1060
|
+
{to: null, default: true, issuesUrl: null},
|
|
1061
|
+
{
|
|
1062
|
+
to: '@test/widgets',
|
|
1063
|
+
default: false,
|
|
1064
|
+
issuesUrl: 'https://github.com/acme/widgets/issues',
|
|
1065
|
+
},
|
|
1066
|
+
]);
|
|
1067
|
+
expect(result.data.ask).toBe(ASK_DESTINATION_MESSAGE);
|
|
1068
|
+
expect(ASK_DESTINATION_MESSAGE).toMatch(/ask the person/i);
|
|
1069
|
+
});
|
|
1070
|
+
|
|
1071
|
+
it('lists no destinations when no integration names an issuesUrl', async () => {
|
|
1072
|
+
addSharedHandler();
|
|
1073
|
+
configure(['@test/shared']);
|
|
1074
|
+
|
|
1075
|
+
const result = await gapReport('General', {
|
|
1076
|
+
...reportOptions,
|
|
1077
|
+
cwd: projectDir,
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
expect(result.data).not.toHaveProperty('destinations');
|
|
1081
|
+
expect(result.data).not.toHaveProperty('ask');
|
|
1082
|
+
});
|
|
1083
|
+
|
|
1084
|
+
it('files with the chosen integration GitHub issuesUrl only with consent, and runs no handler', async () => {
|
|
1085
|
+
const marker = addSharedHandler();
|
|
1086
|
+
addWidgets();
|
|
1087
|
+
configure(['@test/shared', '@test/widgets']);
|
|
1088
|
+
const argsFile = stubGh();
|
|
1089
|
+
|
|
1090
|
+
const pending = await gapReport('General', {
|
|
1091
|
+
...reportOptions,
|
|
1092
|
+
to: '@test/widgets',
|
|
1093
|
+
cwd: projectDir,
|
|
1094
|
+
});
|
|
1095
|
+
expect(pending.data.deliveries).toEqual([
|
|
1096
|
+
{
|
|
1097
|
+
handlerType: 'fallback',
|
|
1098
|
+
handler: 'github',
|
|
1099
|
+
audience: 'public',
|
|
1100
|
+
status: 'consent_required',
|
|
1101
|
+
url: null,
|
|
1102
|
+
message: PUBLIC_CONFIRMATION_MESSAGE,
|
|
1103
|
+
},
|
|
1104
|
+
]);
|
|
1105
|
+
expect(pending.data.issuesUrl).toBe(
|
|
1106
|
+
'https://github.com/acme/widgets/issues',
|
|
1107
|
+
);
|
|
1108
|
+
expect(pending.data).not.toHaveProperty('destinations');
|
|
1109
|
+
expect(fs.existsSync(argsFile)).toBe(false);
|
|
1110
|
+
|
|
1111
|
+
const filed = await gapReport('General', {
|
|
1112
|
+
...reportOptions,
|
|
1113
|
+
to: '@test/widgets',
|
|
1114
|
+
confirmPublic: true,
|
|
1115
|
+
cwd: projectDir,
|
|
1116
|
+
});
|
|
1117
|
+
expect(filed.data.deliveries).toHaveLength(1);
|
|
1118
|
+
expect(filed.data.deliveries[0]).toMatchObject({
|
|
1119
|
+
handlerType: 'fallback',
|
|
1120
|
+
handler: 'github',
|
|
1121
|
+
status: 'filed',
|
|
1122
|
+
});
|
|
1123
|
+
const args = JSON.parse(fs.readFileSync(argsFile, 'utf8'));
|
|
1124
|
+
expect(args.slice(0, 4)).toEqual([
|
|
1125
|
+
'issue',
|
|
1126
|
+
'create',
|
|
1127
|
+
'--repo',
|
|
1128
|
+
'acme/widgets',
|
|
1129
|
+
]);
|
|
1130
|
+
expect(fs.existsSync(marker)).toBe(false);
|
|
1131
|
+
});
|
|
1132
|
+
|
|
1133
|
+
it('routes a chosen non-GitHub issuesUrl as routed_only', async () => {
|
|
1134
|
+
addSharedHandler();
|
|
1135
|
+
addWidgets('https://tracker.example/widgets');
|
|
1136
|
+
configure(['@test/shared', '@test/widgets']);
|
|
1137
|
+
|
|
1138
|
+
const result = await gapReport('General', {
|
|
1139
|
+
...reportOptions,
|
|
1140
|
+
to: '@test/widgets',
|
|
1141
|
+
cwd: projectDir,
|
|
1142
|
+
});
|
|
1143
|
+
|
|
1144
|
+
expect(result.data.deliveries).toEqual([
|
|
1145
|
+
expect.objectContaining({
|
|
1146
|
+
handlerType: 'fallback',
|
|
1147
|
+
handler: 'issuesUrl',
|
|
1148
|
+
status: 'routed_only',
|
|
1149
|
+
url: 'https://tracker.example/widgets',
|
|
1150
|
+
}),
|
|
1151
|
+
]);
|
|
1152
|
+
expect(result.data.status).toBe('routed_only');
|
|
1153
|
+
});
|
|
1154
|
+
|
|
1155
|
+
it.each([
|
|
1156
|
+
['a package that is not loaded', '@test/nope'],
|
|
1157
|
+
['a loaded integration without an issuesUrl', '@test/shared'],
|
|
1158
|
+
])(
|
|
1159
|
+
'refuses --to naming %s, lists the choices, and sends nothing',
|
|
1160
|
+
async (_label, to) => {
|
|
1161
|
+
const marker = addSharedHandler();
|
|
1162
|
+
addWidgets();
|
|
1163
|
+
configure(['@test/shared', '@test/widgets']);
|
|
1164
|
+
|
|
1165
|
+
await expect(
|
|
1166
|
+
gapReport('General', {...reportOptions, to, cwd: projectDir}),
|
|
1167
|
+
).rejects.toMatchObject({
|
|
1168
|
+
code: 'ERR_UNKNOWN_PACKAGE',
|
|
1169
|
+
suggestions: [
|
|
1170
|
+
{
|
|
1171
|
+
name: '@test/widgets',
|
|
1172
|
+
reason: 'https://github.com/acme/widgets/issues',
|
|
1173
|
+
},
|
|
1174
|
+
],
|
|
1175
|
+
});
|
|
1176
|
+
expect(fs.existsSync(marker)).toBe(false);
|
|
1177
|
+
},
|
|
1178
|
+
);
|
|
1179
|
+
|
|
1180
|
+
it.each([
|
|
1181
|
+
['an empty value', ''],
|
|
1182
|
+
['a blank value', ' '],
|
|
1183
|
+
['an over-long value', `@test/${'a'.repeat(300)}`],
|
|
1184
|
+
])('refuses %s for --to with the destination list', async (_label, to) => {
|
|
1185
|
+
const marker = addSharedHandler();
|
|
1186
|
+
addWidgets();
|
|
1187
|
+
configure(['@test/shared', '@test/widgets']);
|
|
1188
|
+
|
|
1189
|
+
await expect(
|
|
1190
|
+
gapReport('General', {...reportOptions, to, cwd: projectDir}),
|
|
1191
|
+
).rejects.toMatchObject({
|
|
1192
|
+
code: 'ERR_UNKNOWN_PACKAGE',
|
|
1193
|
+
suggestions: [{name: '@test/widgets'}],
|
|
1194
|
+
});
|
|
1195
|
+
expect(fs.existsSync(marker)).toBe(false);
|
|
1196
|
+
});
|
|
1197
|
+
|
|
1198
|
+
it('treats to: null as absent', async () => {
|
|
1199
|
+
const marker = addSharedHandler();
|
|
1200
|
+
addWidgets();
|
|
1201
|
+
configure(['@test/shared', '@test/widgets']);
|
|
1202
|
+
|
|
1203
|
+
const result = await gapReport('General', {
|
|
1204
|
+
...reportOptions,
|
|
1205
|
+
to: /** @type {any} */ (null),
|
|
1206
|
+
cwd: projectDir,
|
|
1207
|
+
});
|
|
1208
|
+
|
|
1209
|
+
expect(result.data.deliveries).toHaveLength(1);
|
|
1210
|
+
expect(fs.existsSync(marker)).toBe(true);
|
|
1211
|
+
expect(result.data.destinations).toHaveLength(2);
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
it('lists the destinations with the categories', async () => {
|
|
1215
|
+
addSharedHandler();
|
|
1216
|
+
addWidgets();
|
|
1217
|
+
configure(['@test/shared', '@test/widgets']);
|
|
1218
|
+
|
|
1219
|
+
const listed = await gapReport(undefined, {
|
|
1220
|
+
listCategories: true,
|
|
1221
|
+
cwd: projectDir,
|
|
1222
|
+
});
|
|
1223
|
+
|
|
1224
|
+
expect(listed.data).toEqual(GAP_REPORT_CATEGORIES);
|
|
1225
|
+
expect(listed.meta).toEqual({
|
|
1226
|
+
destinations: [
|
|
1227
|
+
{to: null, default: true, issuesUrl: null},
|
|
1228
|
+
{
|
|
1229
|
+
to: '@test/widgets',
|
|
1230
|
+
default: false,
|
|
1231
|
+
issuesUrl: 'https://github.com/acme/widgets/issues',
|
|
1232
|
+
},
|
|
1233
|
+
],
|
|
1234
|
+
ask: ASK_DESTINATION_MESSAGE,
|
|
1235
|
+
});
|
|
1236
|
+
});
|
|
1237
|
+
|
|
1238
|
+
it('adds no meta to the categories when there is only the default', async () => {
|
|
1239
|
+
configure([]);
|
|
1240
|
+
const listed = await gapReport(undefined, {
|
|
1241
|
+
listCategories: true,
|
|
1242
|
+
cwd: projectDir,
|
|
1243
|
+
});
|
|
1244
|
+
expect(listed).not.toHaveProperty('meta');
|
|
1245
|
+
});
|
|
1246
|
+
|
|
1247
|
+
it('refuses --to with --list-categories', async () => {
|
|
1248
|
+
await expect(
|
|
1249
|
+
gapReport(undefined, {
|
|
1250
|
+
listCategories: true,
|
|
1251
|
+
to: '@test/widgets',
|
|
1252
|
+
cwd: projectDir,
|
|
1253
|
+
}),
|
|
1254
|
+
).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
|
|
1255
|
+
});
|
|
1256
|
+
});
|
|
1257
|
+
|
|
1025
1258
|
describe('gapReport target selection', () => {
|
|
1026
1259
|
it('routes to the unique component owner', async () => {
|
|
1027
1260
|
addIntegration({
|