@astryxdesign/cli 0.6.4-canary.f0355e3 → 0.6.4
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 +96 -99
- package/api/build/build.doc.mjs +1 -6
- package/api/build/build.test.mjs +0 -22
- package/api/build/kit/kit.mjs +5 -44
- package/api/component/_adapter.d.mts +0 -25
- package/api/component/_adapter.mjs +5 -59
- package/api/component/component.d.mts +3 -6
- package/api/component/component.doc.mjs +17 -37
- package/api/component/component.mjs +9 -249
- package/api/component/component.type.d.mts +0 -25
- package/api/component/component.type.mjs +0 -44
- package/api/discover/_adapter.d.mts +6 -114
- package/api/discover/_adapter.mjs +17 -372
- package/api/discover/detail/detail.d.mts +6 -18
- package/api/discover/detail/detail.mjs +13 -67
- package/api/discover/detail/detail.test.mjs +0 -85
- package/api/discover/discover.d.mts +9 -3
- package/api/discover/discover.doc.mjs +18 -61
- package/api/discover/discover.mjs +36 -220
- package/api/discover/discover.test.mjs +2 -11
- package/api/discover/discover.type.d.mts +8 -147
- package/api/discover/discover.type.mjs +12 -102
- package/api/discover/list/list.d.mts +6 -20
- package/api/discover/list/list.mjs +12 -45
- package/api/discover/list/list.test.mjs +0 -46
- package/api/discover/search/search.d.mts +16 -18
- package/api/discover/search/search.mjs +56 -102
- package/api/discover/search/search.test.mjs +10 -144
- package/api/docs/_adapter.d.mts +3 -8
- package/api/docs/_adapter.mjs +6 -14
- package/api/docs/docOverlays.test.mjs +1 -27
- package/api/docs/docs.doc.mjs +2 -2
- package/api/docs/docs.test.mjs +243 -0
- package/api/docs/integration-tree.test.mjs +555 -0
- package/api/docs/integrationDocs.test.mjs +314 -0
- package/api/doctor/doctor.d.mts +3 -8
- package/api/doctor/doctor.doc.mjs +8 -17
- package/api/doctor/doctor.mjs +9 -90
- package/api/doctor/doctor.test.mjs +10 -122
- package/api/doctor/doctor.type.d.mts +1 -1
- package/api/doctor/doctor.type.mjs +1 -1
- package/api/gap-report/gap-report.doc.mjs +10 -19
- package/api/hook/hook.doc.mjs +3 -6
- package/api/index.d.mts +2 -1
- package/api/index.mjs +5 -5
- package/api/init/init.doc.mjs +12 -17
- package/api/integration/add-helpers.d.mts +2 -5
- package/api/integration/add-helpers.mjs +9 -36
- package/api/integration/add-theme.mjs +1 -22
- package/api/integration/add-theme.test.mjs +0 -34
- package/api/integration/authoring-checks.mjs +2 -2
- package/api/integration/integrationPackCheck.doc.mjs +3 -3
- package/api/integration/pack-check.mjs +9 -82
- package/api/integration/pack-check.test.mjs +0 -90
- package/api/integration/pack-check.type.mjs +1 -1
- package/api/json/assertResponse.doc.mjs +1 -1
- package/api/json/index.ts +1 -0
- package/api/json/isError.doc.mjs +1 -1
- package/api/layout/_adapter.d.mts +34 -0
- package/api/layout/_adapter.mjs +148 -0
- package/api/layout/check/check.d.mts +16 -0
- package/api/layout/check/check.mjs +40 -0
- package/api/layout/expand/expand.d.mts +22 -0
- package/api/layout/expand/expand.mjs +155 -0
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.d.mts +13 -0
- package/api/layout/grammar/grammar.mjs +87 -0
- package/api/layout/layout.d.mts +6 -0
- package/api/layout/layout.mjs +17 -0
- package/api/layout/layout.test.mjs +297 -0
- package/api/layout/layout.type.d.mts +89 -0
- package/api/layout/layout.type.mjs +103 -0
- package/api/layout/layoutCheck.doc.d.mts +11 -0
- package/api/layout/layoutCheck.doc.mjs +85 -0
- package/api/layout/layoutExpand.doc.d.mts +11 -0
- package/api/layout/layoutExpand.doc.mjs +107 -0
- package/api/layout/layoutGrammar.doc.d.mts +11 -0
- package/api/layout/layoutGrammar.doc.mjs +57 -0
- package/api/search/search.d.mts +1 -27
- package/api/search/search.doc.mjs +2 -2
- package/api/search/search.mjs +16 -228
- package/api/search/search.test.mjs +512 -0
- package/api/swizzle/swizzle.doc.mjs +5 -7
- package/api/template/copy/copy.mjs +1 -1
- package/api/template/copy/copy.test.mjs +0 -9
- package/api/template/template-integration.test.mjs +65 -1
- package/api/template/template.doc.mjs +1 -2
- package/api/template/template.mjs +1 -1
- package/api/theme/add/add.mjs +25 -17
- package/api/theme/add/add.staging.test.mjs +23 -40
- package/api/theme/build/build.family.test.mjs +12 -7
- package/api/theme/build/build.mjs +18 -8
- package/api/theme/generateTonalPalette.doc.mjs +2 -1
- package/api/theme/listThemes.doc.mjs +1 -1
- package/api/theme/themeAdd.doc.mjs +10 -9
- package/api/theme/themeBuild.doc.mjs +13 -13
- package/api/theme/themeList.doc.mjs +1 -1
- package/api/theme/themeListAvailable.doc.mjs +1 -2
- package/api/theme/themePaletteGenerate.doc.mjs +8 -15
- package/api/theme/themeTargets.doc.mjs +2 -3
- package/api/theme/themeTemplate.doc.mjs +1 -2
- package/api/upgrade/run/run.mjs +4 -6
- package/api/upgrade/upgrade.doc.mjs +22 -24
- package/api/upgrade/upgrade.type.mjs +2 -2
- package/assets/codemods/__tests__/runner.test.mjs +1 -3
- package/assets/codemods/integration-runner.mjs +3 -3
- package/assets/codemods/runner.mjs +4 -5
- package/assets/docs/README.md +2 -4
- package/assets/docs/browser-support.doc.mjs +11 -11
- package/assets/docs/color.doc.mjs +2 -8
- package/assets/docs/elevation.doc.mjs +4 -6
- package/assets/docs/getting-started.doc.mjs +16 -5
- package/assets/docs/icons.doc.mjs +21 -2
- package/assets/docs/illustrations.doc.mjs +15 -7
- package/assets/docs/internationalization.doc.mjs +5 -7
- package/assets/docs/layout.doc.dense.mjs +82 -130
- package/assets/docs/layout.doc.mjs +77 -133
- package/assets/docs/migration.doc.mjs +21 -19
- package/assets/docs/motion.doc.mjs +3 -16
- package/assets/docs/principles.doc.dense.mjs +5 -5
- package/assets/docs/principles.doc.mjs +0 -8
- package/assets/docs/principles.doc.zh.mjs +6 -6
- package/assets/docs/shape.doc.mjs +3 -8
- package/assets/docs/spacing.doc.mjs +2 -7
- package/assets/docs/styling-libraries.doc.mjs +2 -6
- package/assets/docs/styling.doc.mjs +23 -19
- package/assets/docs/theme.doc.dense.mjs +18 -58
- package/assets/docs/theme.doc.mjs +46 -56
- package/assets/docs/theme.doc.zh.mjs +8 -9
- package/assets/docs/tokens.doc.dense.mjs +2 -2
- package/assets/docs/tokens.doc.mjs +8 -389
- package/assets/docs/tokens.doc.zh.mjs +2 -2
- package/assets/docs/tree/integrations.doc.mjs +451 -25
- package/assets/docs/tree/integrations.test.mjs +62 -0
- package/assets/docs/tree/writing-docs.doc.mjs +286 -0
- package/assets/docs/typography.doc.mjs +4 -24
- package/assets/docs/working-with-ai.doc.mjs +22 -30
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
- package/authoring/config/config.doc.mjs +2 -10
- package/authoring/config/parse.d.mts +0 -2
- package/authoring/config/parse.mjs +0 -19
- package/authoring/config/parse.test.mjs +0 -8
- package/authoring/config/type.ts +2 -13
- package/authoring/doctypes/_schema.d.mts +2 -3
- package/authoring/doctypes/_schema.mjs +0 -6
- package/authoring/doctypes/base/graph-fields.doc.mjs +3 -3
- package/authoring/doctypes/base/type.ts +2 -4
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/command/type.ts +1 -1
- package/authoring/doctypes/component/component.doc.mjs +0 -6
- package/authoring/doctypes/component/type.ts +0 -8
- package/authoring/doctypes/reference/reference.doc.mjs +0 -7
- package/authoring/doctypes/reference/type.ts +0 -5
- package/authoring/doctypes/schema/schema.doc.mjs +2 -2
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +2 -2
- package/authoring/index.d.mts +0 -1
- package/authoring/index.d.ts +0 -10
- package/authoring/index.mjs +0 -1
- package/authoring/integration/integration.doc.mjs +10 -12
- package/clients/cli/command-result-coverage.test.mjs +7 -7
- package/clients/cli/commands/component/index.mjs +55 -152
- package/clients/cli/commands/component-ownership.test.mjs +0 -89
- package/clients/cli/commands/component.doc.mjs +9 -27
- package/clients/cli/commands/debug-result-summary.test.mjs +2 -2
- package/clients/cli/commands/discover.doc.mjs +9 -53
- package/clients/cli/commands/discover.mjs +118 -393
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/docs.mjs +17 -60
- package/clients/cli/commands/docs.test.mjs +294 -0
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -3
- package/clients/cli/commands/doctor-integration.test.mjs +0 -53
- package/clients/cli/commands/doctor.doc.mjs +1 -3
- package/clients/cli/commands/doctor.mjs +5 -49
- package/clients/cli/commands/gap-report.doc.mjs +9 -10
- package/clients/cli/commands/init.doc.mjs +6 -9
- package/clients/cli/commands/integration-add.doc.mjs +9 -9
- package/clients/cli/commands/integration-authoring.test.mjs +10 -61
- package/clients/cli/commands/integration-pack.doc.mjs +9 -5
- package/clients/cli/commands/integration-real-world.test.mjs +1 -1
- package/clients/cli/commands/integration.doc.mjs +4 -4
- package/clients/cli/commands/integration.mjs +43 -74
- package/clients/cli/commands/layout-check.doc.mjs +65 -0
- package/clients/cli/commands/layout-expand.doc.mjs +83 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +30 -0
- package/clients/cli/commands/layout.doc.mjs +34 -0
- package/clients/cli/commands/layout.error-codes.test.mjs +66 -0
- package/clients/cli/commands/layout.exit-parity.test.mjs +41 -0
- package/clients/cli/commands/layout.mjs +275 -0
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/search.doc.mjs +3 -10
- package/clients/cli/commands/search.mjs +2 -21
- package/clients/cli/commands/search.test.mjs +4 -21
- package/clients/cli/commands/swizzle.doc.mjs +1 -1
- package/clients/cli/commands/template.doc.mjs +1 -1
- package/clients/cli/commands/text-json-parity.test.mjs +16 -5
- package/clients/cli/commands/theme-add.doc.mjs +1 -1
- package/clients/cli/commands/theme-palette-generate.doc.mjs +2 -3
- package/clients/cli/commands/theme-palette.doc.mjs +2 -1
- package/clients/cli/commands/theme-targets.doc.mjs +2 -2
- package/clients/cli/commands/theme.doc.mjs +1 -2
- package/clients/cli/commands/upgrade.doc.mjs +3 -62
- package/clients/cli/index.mjs +10 -28
- package/clients/cli/lib/define-command.mjs +4 -28
- package/clients/cli/lib/define-command.test.mjs +0 -54
- package/clients/cli/lib/exit-codes.test.mjs +9 -18
- package/clients/cli/lib/json-shim.mjs +14 -24
- package/clients/cli/lib/json-shim.test.mjs +20 -6
- package/clients/cli/lib/manifest.mjs +13 -18
- package/clients/cli/lib/manifest.test.mjs +2 -5
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/agent-docs/agent-docs.test.mjs +1159 -0
- package/foundation/discovery/authoring-self-docs.mjs +0 -1
- package/foundation/discovery/authoring-self-docs.test.mjs +2 -6
- package/foundation/discovery/cli-self-docs.mjs +2 -16
- package/foundation/discovery/cli-self-docs.test.mjs +0 -20
- package/foundation/discovery/docs-discovery.mjs +1 -5
- package/foundation/discovery/docs-discovery.test.mjs +0 -21
- package/foundation/discovery/docs-section-key.d.mts +1 -1
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/template-adapter.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +14 -3
- package/foundation/doc-compiler/tree.d.mts +0 -4
- package/foundation/doc-compiler/tree.mjs +1 -6
- package/foundation/doc-compiler/tree.test.mjs +598 -0
- package/foundation/integrations/cli-requirement.d.mts +6 -26
- package/foundation/integrations/cli-requirement.mjs +11 -46
- package/foundation/integrations/cli-requirement.test.mjs +2 -7
- package/foundation/integrations/contribution-inventory.mjs +1 -1
- package/foundation/integrations/integrations.d.mts +1 -14
- package/foundation/integrations/integrations.mjs +1 -41
- package/foundation/integrations/integrations.test.mjs +0 -31
- package/foundation/response/error-codes.doc.mjs +8 -6
- package/foundation/response/error-codes.test.mjs +5 -30
- package/foundation/response/response-types.doc.d.mts +3 -4
- package/foundation/response/response-types.doc.mjs +27 -40
- package/foundation/response/response-types.doc.test.mjs +0 -23
- package/foundation/response/response.doc.mjs +10 -11
- package/foundation/xle/browser.d.mts +3 -3
- package/foundation/xle/browser.mjs +3 -3
- package/foundation/xle/expand.mjs +2 -2
- package/foundation/xle/parse.mjs +1 -1
- package/foundation/xle/print.mjs +2 -2
- package/foundation/xle/splice.mjs +1 -1
- package/package.json +9 -9
- package/api/discover/_adapter.test.mjs +0 -215
- package/api/discover/_catalog-view.d.mts +0 -115
- package/api/discover/_catalog-view.mjs +0 -203
- package/api/discover/_catalog-view.test.mjs +0 -128
- package/api/discover/detail/item/item.d.mts +0 -26
- package/api/discover/detail/item/item.mjs +0 -78
- package/api/discover/detail/item/item.test.mjs +0 -73
- package/api/integration/pack-check.lifecycle-output.test.mjs +0 -107
- package/api/theme/add/add.rollback.test.mjs +0 -158
- package/api/theme/build/build.rollback.test.mjs +0 -148
- package/api/upgrade/run/files-changed.test.mjs +0 -111
- package/assets/codemods/file-count.test.mjs +0 -163
- package/assets/docs/tree/add-a-component.doc.mjs +0 -75
- package/assets/docs/tree/add-a-theme.doc.mjs +0 -85
- package/assets/docs/tree/add-a-topic.doc.mjs +0 -144
- package/assets/docs/tree/agent-guidance.doc.mjs +0 -138
- package/assets/docs/tree/block-template.doc.mjs +0 -130
- package/assets/docs/tree/build-the-template.doc.mjs +0 -28
- package/assets/docs/tree/building-blocks.doc.mjs +0 -46
- package/assets/docs/tree/check-your-docs.doc.mjs +0 -137
- package/assets/docs/tree/checks.doc.mjs +0 -119
- package/assets/docs/tree/codemods.doc.mjs +0 -147
- package/assets/docs/tree/component-family.doc.mjs +0 -113
- package/assets/docs/tree/component-imports.doc.mjs +0 -69
- package/assets/docs/tree/component-lookups.doc.mjs +0 -149
- package/assets/docs/tree/components.doc.mjs +0 -23
- package/assets/docs/tree/configuration.doc.mjs +0 -23
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +0 -182
- package/assets/docs/tree/define-the-theme.doc.mjs +0 -118
- package/assets/docs/tree/describe-the-component.doc.mjs +0 -57
- package/assets/docs/tree/docs.doc.mjs +0 -21
- package/assets/docs/tree/document-the-template.doc.mjs +0 -28
- package/assets/docs/tree/document-the-theme.doc.mjs +0 -68
- package/assets/docs/tree/export-template-assets.doc.mjs +0 -147
- package/assets/docs/tree/extend-or-replace.doc.mjs +0 -103
- package/assets/docs/tree/fonts-and-assets.doc.mjs +0 -106
- package/assets/docs/tree/generate-a-palette.doc.mjs +0 -66
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +0 -105
- package/assets/docs/tree/help.doc.mjs +0 -16
- package/assets/docs/tree/links.doc.mjs +0 -98
- package/assets/docs/tree/package-and-test.doc.mjs +0 -32
- package/assets/docs/tree/page-template.doc.mjs +0 -71
- package/assets/docs/tree/publishing.doc.mjs +0 -111
- package/assets/docs/tree/quick-start.doc.mjs +0 -272
- package/assets/docs/tree/replace-a-core-component.doc.mjs +0 -104
- package/assets/docs/tree/replace-a-core-template.doc.mjs +0 -172
- package/assets/docs/tree/sections-and-placement.doc.mjs +0 -108
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +0 -59
- package/assets/docs/tree/ship.doc.mjs +0 -16
- package/assets/docs/tree/short-and-findable.doc.mjs +0 -108
- package/assets/docs/tree/single-component.doc.mjs +0 -165
- package/assets/docs/tree/start-a-template.doc.mjs +0 -143
- package/assets/docs/tree/subcomponent.doc.mjs +0 -115
- package/assets/docs/tree/template-assets.doc.mjs +0 -64
- package/assets/docs/tree/template-doc-overview.doc.mjs +0 -109
- package/assets/docs/tree/template-fonts.doc.mjs +0 -102
- package/assets/docs/tree/template-grading-rubric.doc.mjs +0 -452
- package/assets/docs/tree/template-icons.doc.mjs +0 -97
- package/assets/docs/tree/template-images-media.doc.mjs +0 -127
- package/assets/docs/tree/template-styles.doc.mjs +0 -93
- package/assets/docs/tree/templates.doc.mjs +0 -34
- package/assets/docs/tree/test-in-an-app.doc.mjs +0 -115
- package/assets/docs/tree/test-template-in-app.doc.mjs +0 -128
- package/assets/docs/tree/themes.doc.mjs +0 -39
- package/assets/docs/tree/troubleshooting.doc.mjs +0 -149
- package/assets/docs/tree/upgrading.doc.mjs +0 -103
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +0 -51
- package/assets/docs/tree/verify-packed-template.doc.mjs +0 -77
- package/assets/docs/tree/versioning.doc.mjs +0 -161
- package/assets/docs/tree/write-good-templates.doc.mjs +0 -64
- package/assets/docs/tree/write-the-template-file.doc.mjs +0 -154
- package/authoring/discover/discover.doc.d.mts +0 -13
- package/authoring/discover/discover.doc.mjs +0 -138
- package/authoring/discover/parse.d.mts +0 -24
- package/authoring/discover/parse.mjs +0 -128
- package/authoring/discover/parse.test.mjs +0 -124
- package/authoring/discover/type.ts +0 -87
- package/clients/cli/commands/component-batch.test.mjs +0 -341
- package/clients/cli/commands/discover.sources.test.mjs +0 -267
- package/clients/cli/commands/integration-verify.doc.mjs +0 -22
- package/clients/cli/lib/parse-error-format.test.mjs +0 -81
- package/foundation/response/batch.type.d.mts +0 -33
- package/foundation/response/batch.type.mjs +0 -34
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file discover command —
|
|
4
|
+
* @file discover command — find external Astryx packages and components
|
|
5
5
|
*
|
|
6
6
|
* Usage:
|
|
7
|
-
* astryx discover List
|
|
8
|
-
* astryx discover @scope/name
|
|
9
|
-
* astryx discover @scope/name/Component Show docs for
|
|
10
|
-
* astryx discover
|
|
11
|
-
* astryx discover searchterm Search every item and package
|
|
7
|
+
* astryx discover List all packages
|
|
8
|
+
* astryx discover @scope/name List components in a package
|
|
9
|
+
* astryx discover @scope/name/Component Show docs for a component
|
|
10
|
+
* astryx discover searchterm Search across all packages
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
|
-
import {
|
|
15
|
-
formatFull,
|
|
16
|
-
formatBrief,
|
|
17
|
-
formatCompact,
|
|
18
|
-
} from '../lib/component-format.mjs';
|
|
13
|
+
import {formatFull, formatBrief, formatCompact} from '../lib/component-format.mjs';
|
|
19
14
|
import {jsonOut} from '../../../foundation/response/json.mjs';
|
|
20
|
-
import {
|
|
21
|
-
emit,
|
|
22
|
-
section,
|
|
23
|
-
text,
|
|
24
|
-
record,
|
|
25
|
-
records,
|
|
26
|
-
list,
|
|
27
|
-
code,
|
|
28
|
-
} from '../formatters/index.mjs';
|
|
15
|
+
import {emit, section, text, record, records, list, code} from '../formatters/index.mjs';
|
|
29
16
|
import {cliError} from '../lib/cli-error.mjs';
|
|
30
17
|
import {discover as discoverApi} from '../../../api/discover/discover.mjs';
|
|
31
18
|
import {Project} from '../../../foundation/config/project.mjs';
|
|
@@ -36,70 +23,25 @@ import {resultSet} from '../../../foundation/debug/index.mjs';
|
|
|
36
23
|
import {doc as discoverCommand} from './discover.doc.mjs';
|
|
37
24
|
import {doc as discoverFn} from '../../../api/discover/discover.doc.mjs';
|
|
38
25
|
|
|
39
|
-
// Max
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
/** @type {Record<string, string>} */
|
|
43
|
-
const KIND_PLURALS = {
|
|
44
|
-
component: 'components',
|
|
45
|
-
template: 'templates',
|
|
46
|
-
doc: 'docs',
|
|
47
|
-
theme: 'themes',
|
|
48
|
-
codemod: 'codemods',
|
|
49
|
-
'agent-doc': 'agent docs',
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// The list fields that hold item names, summarized in the package list.
|
|
53
|
-
const ITEM_FIELDS = [
|
|
54
|
-
'components',
|
|
55
|
-
'templates',
|
|
56
|
-
'docs',
|
|
57
|
-
'themes',
|
|
58
|
-
'codemods',
|
|
59
|
-
'agentDocs',
|
|
60
|
-
];
|
|
26
|
+
// Max components to list inline per package before summarizing with "+N more".
|
|
27
|
+
const MAX_COMPONENTS_SHOWN = 10;
|
|
61
28
|
|
|
62
29
|
/**
|
|
63
|
-
*
|
|
30
|
+
* What the run answered with. `discover` browses the integration packages a
|
|
31
|
+
* project has configured, so the top two views count PACKAGES; naming a
|
|
32
|
+
* component inside one answers with that component instead.
|
|
33
|
+
*
|
|
34
|
+
* @param {import('../../../api/discover/discover.type.mjs').DiscoverListResponse
|
|
64
35
|
* | import('../../../api/discover/discover.type.mjs').DiscoverDetailResponse
|
|
65
36
|
* | import('../../../api/discover/discover.type.mjs').DiscoverDetailDocResponse
|
|
66
|
-
* | import('../../../api/discover/discover.type.mjs').
|
|
67
|
-
* | import('../../../api/discover/discover.type.mjs').DiscoverSearchResponse} DiscoverResult
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
/** @type {Record<string, import('../../../foundation/debug/command-result.mjs').ResultSetKind>} */
|
|
71
|
-
const RESULT_KINDS = {
|
|
72
|
-
package: 'integration',
|
|
73
|
-
component: 'component',
|
|
74
|
-
template: 'template',
|
|
75
|
-
doc: 'doc',
|
|
76
|
-
theme: 'theme',
|
|
77
|
-
codemod: 'migration',
|
|
78
|
-
'agent-doc': 'doc',
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The run-log kind for a set of item kinds: the one kind, or `mixed`.
|
|
83
|
-
* @param {string[]} kinds
|
|
84
|
-
* @returns {import('../../../foundation/debug/command-result.mjs').ResultSetKind}
|
|
85
|
-
*/
|
|
86
|
-
function resultKindOf(kinds) {
|
|
87
|
-
const mapped = new Set(kinds.map(kind => RESULT_KINDS[kind] ?? 'mixed'));
|
|
88
|
-
return mapped.size === 1 ? [...mapped][0] : 'mixed';
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* What the run answered with. The list and package views count PACKAGES;
|
|
93
|
-
* naming a component or item answers with that item instead.
|
|
94
|
-
*
|
|
95
|
-
* @param {DiscoverResult} result
|
|
37
|
+
* | import('../../../api/discover/discover.type.mjs').DiscoverSearchResponse} result
|
|
96
38
|
* @returns {import('../../../foundation/debug/command-result.mjs').CommandResult}
|
|
97
39
|
*/
|
|
98
40
|
function summarize(result) {
|
|
99
41
|
switch (result.type) {
|
|
100
42
|
case 'discover.list':
|
|
101
43
|
return resultSet({
|
|
102
|
-
count: result.data.length
|
|
44
|
+
count: result.data.length,
|
|
103
45
|
resultKind: 'integration',
|
|
104
46
|
});
|
|
105
47
|
case 'discover.detail':
|
|
@@ -110,96 +52,14 @@ function summarize(result) {
|
|
|
110
52
|
});
|
|
111
53
|
case 'discover.detail.doc':
|
|
112
54
|
return resultSet({count: 1, resultKind: 'component', directMatch: true});
|
|
113
|
-
case 'discover.item':
|
|
114
|
-
return resultSet({
|
|
115
|
-
count: 1,
|
|
116
|
-
resultKind: resultKindOf([result.data.kind]),
|
|
117
|
-
directMatch: true,
|
|
118
|
-
});
|
|
119
55
|
case 'discover.search':
|
|
120
56
|
return resultSet({
|
|
121
|
-
count: result.data.
|
|
122
|
-
resultKind:
|
|
57
|
+
count: result.data.matches.length,
|
|
58
|
+
resultKind: 'component',
|
|
123
59
|
});
|
|
124
60
|
}
|
|
125
61
|
}
|
|
126
62
|
|
|
127
|
-
/**
|
|
128
|
-
* Record options that summarize each item list to its first names.
|
|
129
|
-
* @param {boolean} full print every name instead
|
|
130
|
-
* @returns {import('../formatters/index.mjs').RecordOptions}
|
|
131
|
-
*/
|
|
132
|
-
function itemListOptions(full) {
|
|
133
|
-
if (full) return {};
|
|
134
|
-
/** @param {string[]} names */
|
|
135
|
-
const summary = names => {
|
|
136
|
-
const shown = names.slice(0, MAX_ITEMS_SHOWN);
|
|
137
|
-
const remaining = names.length - MAX_ITEMS_SHOWN;
|
|
138
|
-
return remaining > 0
|
|
139
|
-
? `${shown.join(', ')}, +${remaining} more`
|
|
140
|
-
: shown.join(', ');
|
|
141
|
-
};
|
|
142
|
-
return {
|
|
143
|
-
format: Object.fromEntries(ITEM_FIELDS.map(field => [field, summary])),
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* One line per source that did not answer live.
|
|
149
|
-
* @param {import('../../../api/discover/discover.type.mjs').DiscoverSourceState[]} sources
|
|
150
|
-
*/
|
|
151
|
-
function sourceNotes(sources) {
|
|
152
|
-
return sources
|
|
153
|
-
.filter(s => s.status !== 'fresh')
|
|
154
|
-
.map(s =>
|
|
155
|
-
s.status === 'saved'
|
|
156
|
-
? text(
|
|
157
|
-
`The discover source from ${s.from} did not answer (${s.error}), so this uses the copy saved ${s.savedAt}.`,
|
|
158
|
-
)
|
|
159
|
-
: text(`The discover source from ${s.from} is unavailable: ${s.error}`),
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* @param {import('../../../api/discover/discover.type.mjs').DiscoverSourceState[]} sources
|
|
165
|
-
*/
|
|
166
|
-
function sourceSubtitle(sources) {
|
|
167
|
-
const answered = sources.filter(s => s.status !== 'failed');
|
|
168
|
-
if (answered.length === 0) return undefined;
|
|
169
|
-
return (
|
|
170
|
-
'from ' +
|
|
171
|
-
answered
|
|
172
|
-
.map(
|
|
173
|
-
s =>
|
|
174
|
-
`${s.name}${s.generatedAt ? ` (${s.generatedAt.slice(0, 10)})` : ''}`,
|
|
175
|
-
)
|
|
176
|
-
.join(', ')
|
|
177
|
-
);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @param {import('../../../authoring/discover/type').DiscoverVersion[]} versions
|
|
182
|
-
* @param {{shown?: string, installed?: string, latest?: string}} marks
|
|
183
|
-
*/
|
|
184
|
-
function versionLines(versions, marks) {
|
|
185
|
-
return versions
|
|
186
|
-
.filter(v => !v.prerelease || v.version === marks.shown)
|
|
187
|
-
.map(v => {
|
|
188
|
-
const tags = [
|
|
189
|
-
v.version === marks.latest ? 'latest' : '',
|
|
190
|
-
v.version === marks.installed ? 'installed' : '',
|
|
191
|
-
v.version === marks.shown &&
|
|
192
|
-
v.version !== marks.installed &&
|
|
193
|
-
v.version !== marks.latest
|
|
194
|
-
? 'shown'
|
|
195
|
-
: '',
|
|
196
|
-
v.status !== 'ok' ? v.status : '',
|
|
197
|
-
].filter(Boolean);
|
|
198
|
-
const date = v.publishedAt ? v.publishedAt.slice(0, 10) : 'date unknown';
|
|
199
|
-
return `${v.version} ${date}${tags.length ? ` ${tags.join(', ')}` : ''}`;
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
|
|
203
63
|
/**
|
|
204
64
|
* @param {import('commander').Command} program
|
|
205
65
|
*/
|
|
@@ -209,255 +69,120 @@ export function registerDiscover(program) {
|
|
|
209
69
|
action:
|
|
210
70
|
/**
|
|
211
71
|
* @param {string | undefined} query
|
|
212
|
-
* @param {{components?: boolean
|
|
72
|
+
* @param {{components?: boolean}} options
|
|
213
73
|
*/
|
|
214
74
|
async (query, options) => {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
return cliError(err.message, {
|
|
248
|
-
suggestions: err.suggestions,
|
|
249
|
-
code: err.code,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const answered = summarize(result);
|
|
254
|
-
if (json) {
|
|
255
|
-
// Forward optional meta (e.g. configured flag for discover.list) as a
|
|
256
|
-
// sibling of data via jsonOut, so the envelope still carries
|
|
257
|
-
// apiVersion and goes through the single sanctioned emit path.
|
|
258
|
-
jsonOut(result);
|
|
259
|
-
return answered;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
switch (result.type) {
|
|
263
|
-
case 'discover.list': {
|
|
264
|
-
const listOpts = itemListOptions(Boolean(options.components));
|
|
265
|
-
const available = result.meta?.available;
|
|
266
|
-
const sources = result.meta?.sources ?? [];
|
|
75
|
+
const detail = program.opts().detail || 'full';
|
|
76
|
+
const json = program.opts().json || false;
|
|
77
|
+
const lang = program.opts().lang || null;
|
|
78
|
+
const zh = program.opts().zh || false;
|
|
79
|
+
const run = getCliInvocation();
|
|
80
|
+
|
|
81
|
+
// Non-blocking nudge: if any configured integration has validation
|
|
82
|
+
// issues, print one compact line to stderr pointing at
|
|
83
|
+
// doctor integration validate. Best-effort; suppressed in --json mode.
|
|
84
|
+
try {
|
|
85
|
+
const project = await Project.load(process.cwd());
|
|
86
|
+
await warnOnIntegrationIssues(project, {json});
|
|
87
|
+
} catch {
|
|
88
|
+
// Never let the nudge break the command.
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let result;
|
|
92
|
+
try {
|
|
93
|
+
result = await discoverApi(query, {components: options.components, lang, zh});
|
|
94
|
+
} catch (e) {
|
|
95
|
+
const err = /** @type {import('../../../api/error.mjs').AstryxError} */ (e);
|
|
96
|
+
return cliError(err.message, {suggestions: err.suggestions, code: err.code});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const answered = summarize(result);
|
|
100
|
+
if (json) {
|
|
101
|
+
// Forward optional meta (e.g. configured flag for discover.list) as a
|
|
102
|
+
// sibling of data via jsonOut, so the envelope still carries
|
|
103
|
+
// apiVersion and goes through the single sanctioned emit path.
|
|
104
|
+
jsonOut(result);
|
|
105
|
+
return answered;
|
|
106
|
+
}
|
|
267
107
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
emit(
|
|
273
|
-
text('No integrations configured.'),
|
|
274
|
-
text('Add integration package names to astryx.config.mjs:'),
|
|
275
|
-
code(
|
|
276
|
-
"export default {\n integrations: ['@scope/your-integration'],\n};",
|
|
277
|
-
),
|
|
278
|
-
);
|
|
279
|
-
} else {
|
|
280
|
-
emit(
|
|
281
|
-
text(
|
|
282
|
-
'No external components found in configured integrations.',
|
|
283
|
-
),
|
|
284
|
-
);
|
|
285
|
-
}
|
|
286
|
-
break;
|
|
287
|
-
}
|
|
108
|
+
switch (result.type) {
|
|
109
|
+
case 'discover.list': {
|
|
110
|
+
if (result.data.length === 0) {
|
|
111
|
+
if (result.meta && result.meta.configured === false) {
|
|
288
112
|
emit(
|
|
289
|
-
|
|
290
|
-
text(
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
` ${run} discover <package> Browse a package`,
|
|
294
|
-
` ${run} discover <package>/Component View component docs`,
|
|
295
|
-
` ${run} discover <search> Search all packages`,
|
|
296
|
-
].join('\n'),
|
|
113
|
+
text('No integrations configured.'),
|
|
114
|
+
text('Add integration package names to astryx.config.mjs:'),
|
|
115
|
+
code(
|
|
116
|
+
"export default {\n integrations: ['@scope/your-integration'],\n};",
|
|
297
117
|
),
|
|
298
118
|
);
|
|
299
|
-
|
|
119
|
+
} else {
|
|
120
|
+
emit(text('No external components found in configured integrations.'));
|
|
300
121
|
}
|
|
301
|
-
|
|
302
|
-
const kind = options.type
|
|
303
|
-
? (KIND_PLURALS[options.type] ?? options.type)
|
|
304
|
-
: null;
|
|
305
|
-
/** @type {import('../formatters/index.mjs').Block[]} */
|
|
306
|
-
const blocks = [];
|
|
307
|
-
if (!options.available) {
|
|
308
|
-
blocks.push(section('Installed'));
|
|
309
|
-
blocks.push(
|
|
310
|
-
result.data.length > 0
|
|
311
|
-
? records(result.data, listOpts)
|
|
312
|
-
: text(
|
|
313
|
-
kind
|
|
314
|
-
? `None of this project's integrations add ${kind}.`
|
|
315
|
-
: 'None yet.',
|
|
316
|
-
),
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
if (!options.installed) {
|
|
320
|
-
blocks.push(section('Available', sourceSubtitle(sources)));
|
|
321
|
-
blocks.push(
|
|
322
|
-
available.length > 0
|
|
323
|
-
? records(available, listOpts)
|
|
324
|
-
: text(
|
|
325
|
-
!sources.some(s => s.status !== 'failed')
|
|
326
|
-
? 'No source answered, so there is nothing to list.'
|
|
327
|
-
: kind
|
|
328
|
-
? `No package you could add adds ${kind}.`
|
|
329
|
-
: 'Nothing new to add: this project has every integration its sources list.',
|
|
330
|
-
),
|
|
331
|
-
);
|
|
332
|
-
}
|
|
333
|
-
blocks.push(...sourceNotes(sources));
|
|
334
|
-
blocks.push(
|
|
335
|
-
text(
|
|
336
|
-
[
|
|
337
|
-
'Usage:',
|
|
338
|
-
` ${run} discover <package> Browse a package and its versions`,
|
|
339
|
-
` ${run} discover <package>/<item> View one item`,
|
|
340
|
-
` ${run} discover <search> Search every item and package`,
|
|
341
|
-
].join('\n'),
|
|
342
|
-
),
|
|
343
|
-
);
|
|
344
|
-
emit(...blocks);
|
|
345
122
|
break;
|
|
346
123
|
}
|
|
347
124
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
section(
|
|
364
|
-
'Versions',
|
|
365
|
-
`${d.versions.length} published, newest first`,
|
|
366
|
-
),
|
|
367
|
-
);
|
|
368
|
-
if (lines.length > 0) blocks.push(list(lines));
|
|
369
|
-
if (prereleases > 0) {
|
|
370
|
-
blocks.push(
|
|
371
|
-
text(
|
|
372
|
-
`${prereleases === 1 ? '1 prerelease is' : `${prereleases} prereleases are`} not listed. See any version: ${run} discover ${d.name}@<version>`,
|
|
373
|
-
),
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
if (d.install) {
|
|
378
|
-
blocks.push(
|
|
379
|
-
section('Add it'),
|
|
380
|
-
code(d.install),
|
|
381
|
-
text(
|
|
382
|
-
'Astryx loads an integration on the next command once it is a dependency.',
|
|
383
|
-
),
|
|
384
|
-
);
|
|
385
|
-
} else if (d.installedAs) {
|
|
386
|
-
blocks.push(
|
|
387
|
-
text(
|
|
388
|
-
`This project already has this integration as ${d.installedAs}.`,
|
|
389
|
-
),
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
blocks.push(
|
|
393
|
-
text(
|
|
394
|
-
d.installed
|
|
395
|
-
? `Usage: ${run} discover ${d.name}/<ComponentName>`
|
|
396
|
-
: `See one item: ${run} discover ${d.name}/<item>`,
|
|
397
|
-
),
|
|
398
|
-
);
|
|
399
|
-
emit(...blocks);
|
|
400
|
-
break;
|
|
125
|
+
// One record per package, every field of the JSON entry. The default
|
|
126
|
+
// view summarizes each package's components (first N + "+N more");
|
|
127
|
+
// --components lists them all (record comma-joins the full array).
|
|
128
|
+
/** @type {import('../formatters/index.mjs').RecordOptions} */
|
|
129
|
+
const listOpts = {};
|
|
130
|
+
if (!options.components) {
|
|
131
|
+
listOpts.format = {
|
|
132
|
+
components: (/** @type {string[]} */ comps) => {
|
|
133
|
+
const shown = comps.slice(0, MAX_COMPONENTS_SHOWN);
|
|
134
|
+
const remaining = comps.length - MAX_COMPONENTS_SHOWN;
|
|
135
|
+
return remaining > 0
|
|
136
|
+
? `${shown.join(', ')}, +${remaining} more`
|
|
137
|
+
: shown.join(', ');
|
|
138
|
+
},
|
|
139
|
+
};
|
|
401
140
|
}
|
|
141
|
+
emit(
|
|
142
|
+
records(result.data, listOpts),
|
|
143
|
+
text(
|
|
144
|
+
[
|
|
145
|
+
'Usage:',
|
|
146
|
+
` ${run} discover <package> Browse a package`,
|
|
147
|
+
` ${run} discover <package>/Component View component docs`,
|
|
148
|
+
` ${run} discover <search> Search all packages`,
|
|
149
|
+
].join('\n'),
|
|
150
|
+
),
|
|
151
|
+
);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
402
154
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
emit(code(md));
|
|
412
|
-
break;
|
|
413
|
-
}
|
|
155
|
+
case 'discover.detail': {
|
|
156
|
+
const d = result.data;
|
|
157
|
+
emit(
|
|
158
|
+
record(d),
|
|
159
|
+
text(`Usage: ${run} discover ${d.name}/<ComponentName>`),
|
|
160
|
+
);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
414
163
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
]
|
|
427
|
-
: []),
|
|
428
|
-
text(`Its package: ${run} discover ${d.package}`),
|
|
429
|
-
);
|
|
430
|
-
break;
|
|
431
|
-
}
|
|
164
|
+
case 'discover.detail.doc': {
|
|
165
|
+
const docs = result.data;
|
|
166
|
+
const md =
|
|
167
|
+
detail === 'brief'
|
|
168
|
+
? formatBrief(docs, docs.name, '')
|
|
169
|
+
: detail === 'compact'
|
|
170
|
+
? formatCompact(docs, docs.name, '')
|
|
171
|
+
: formatFull(docs);
|
|
172
|
+
emit(code(md));
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
432
175
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
? `showing the first ${matches.length}`
|
|
441
|
-
: undefined,
|
|
442
|
-
),
|
|
443
|
-
list(
|
|
444
|
-
matches.map(m => {
|
|
445
|
-
const target =
|
|
446
|
-
m.kind === 'package'
|
|
447
|
-
? m.package
|
|
448
|
-
: `${m.package}/${m.component}`;
|
|
449
|
-
const tags = [
|
|
450
|
-
m.kind && m.kind !== 'component' ? m.kind : '',
|
|
451
|
-
m.installed === false ? 'not installed' : '',
|
|
452
|
-
].filter(Boolean);
|
|
453
|
-
return `${run} discover ${target}${tags.length ? ` (${tags.join(', ')})` : ''}`;
|
|
454
|
-
}),
|
|
455
|
-
),
|
|
456
|
-
);
|
|
457
|
-
break;
|
|
458
|
-
}
|
|
176
|
+
case 'discover.search': {
|
|
177
|
+
const {query: q, matches} = result.data;
|
|
178
|
+
emit(
|
|
179
|
+
section(`Found ${matches.length} matches for "${q}"`),
|
|
180
|
+
list(matches.map(m => `${run} discover ${m.package}/${m.component}`)),
|
|
181
|
+
);
|
|
182
|
+
break;
|
|
459
183
|
}
|
|
460
|
-
|
|
461
|
-
|
|
184
|
+
}
|
|
185
|
+
return answered;
|
|
186
|
+
},
|
|
462
187
|
});
|
|
463
188
|
}
|
|
@@ -47,7 +47,7 @@ export const doc = {
|
|
|
47
47
|
{label: 'One section', cli: 'astryx docs theme quick-start'},
|
|
48
48
|
{label: 'The CLI docs tree', cli: 'astryx docs cli'},
|
|
49
49
|
{label: 'One API function', cli: 'astryx docs cli/api/functions/search'},
|
|
50
|
-
{label: 'A whole guide', cli: 'astryx docs cli/integrations
|
|
50
|
+
{label: 'A whole guide', cli: 'astryx docs cli/integrations --full'},
|
|
51
51
|
],
|
|
52
52
|
exitCodes: [
|
|
53
53
|
{code: 0, when: 'success'},
|