@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
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
* astryx --json component --category Form -> component.list (filtered)
|
|
19
19
|
* astryx --json component --list --detail compact -> component.list (data.detail='compact')
|
|
20
20
|
* astryx --json component --list --detail full -> component.list (data.detail='full')
|
|
21
|
-
* component([]) -> component.batch (data.count=0)
|
|
22
|
-
* component(['Button']) -> component.batch (data.count=1)
|
|
23
|
-
* astryx --json component Button Badge -> component.batch
|
|
24
21
|
* astryx --json component Button -> component.detail
|
|
25
22
|
* astryx --json component Button --props -> component.detail.props
|
|
26
23
|
* astryx --json component Button --source -> component.detail.source
|
|
@@ -52,47 +49,6 @@
|
|
|
52
49
|
* )} ComponentListData
|
|
53
50
|
*/
|
|
54
51
|
|
|
55
|
-
/**
|
|
56
|
-
* `component(string[])` always returns this type, including empty and one-item
|
|
57
|
-
* arrays. The CLI returns it for two or more positional selectors.
|
|
58
|
-
* @typedef {import('../../foundation/response/batch.type.mjs').BatchResponse<
|
|
59
|
-
* 'component.batch',
|
|
60
|
-
* ComponentSingleResponse,
|
|
61
|
-
* ComponentBatchCandidate
|
|
62
|
-
* >} ComponentBatchResponse
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* One installed component that makes an unqualified selector ambiguous.
|
|
67
|
-
* Keys match a component row in `discover.search` so a caller does not learn a
|
|
68
|
-
* second candidate shape.
|
|
69
|
-
* @typedef {object} ComponentBatchCandidate
|
|
70
|
-
* @property {string} package
|
|
71
|
-
* @property {string} component
|
|
72
|
-
* @property {'component'} kind
|
|
73
|
-
* @property {true} installed
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The response a successful single selector would have returned.
|
|
78
|
-
* @typedef {(
|
|
79
|
-
* | ComponentDetailResponse
|
|
80
|
-
* | ComponentDetailPropsResponse
|
|
81
|
-
* | ComponentDetailSourceResponse
|
|
82
|
-
* | ComponentDetailShowcaseResponse
|
|
83
|
-
* | ComponentDetailBlocksResponse
|
|
84
|
-
* )} ComponentSingleResponse
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* One row per requested selector, in argument order. Duplicate selectors keep
|
|
89
|
-
* duplicate rows.
|
|
90
|
-
* @typedef {import('../../foundation/response/batch.type.mjs').BatchRow<
|
|
91
|
-
* ComponentSingleResponse,
|
|
92
|
-
* ComponentBatchCandidate
|
|
93
|
-
* >} ComponentBatchResult
|
|
94
|
-
*/
|
|
95
|
-
|
|
96
52
|
/**
|
|
97
53
|
* A single entry in a `component.list` group at `detail: 'names'`. Pre-1.0 the
|
|
98
54
|
* list moved from bare strings to package-qualified objects so consumers can
|
|
@@ -12,78 +12,20 @@
|
|
|
12
12
|
* configured" (`false`) from "configured but nothing discovered" (`true`),
|
|
13
13
|
* which the list leaf surfaces as `meta`.
|
|
14
14
|
*
|
|
15
|
-
* @returns {Promise<{packages: ScannedPackage[], configured: boolean
|
|
15
|
+
* @returns {Promise<{packages: ScannedPackage[], configured: boolean}>}
|
|
16
16
|
*/
|
|
17
17
|
export function discoverPackages(): Promise<{
|
|
18
18
|
packages: ScannedPackage[];
|
|
19
19
|
configured: boolean;
|
|
20
|
-
project: Project;
|
|
21
20
|
}>;
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @param {Project | undefined} project
|
|
28
|
-
* @param {ScannedPackage[]} scanned the packages {@link discoverPackages} found
|
|
29
|
-
* @returns {Promise<InstalledPackage[]>}
|
|
30
|
-
*/
|
|
31
|
-
export function describeInstalled(project: Project | undefined, scanned: ScannedPackage[]): Promise<InstalledPackage[]>;
|
|
32
|
-
/**
|
|
33
|
-
* Whether the project has any discover source: its own `discover` config field,
|
|
34
|
-
* or an integration's `discover` named export (valid or not).
|
|
35
|
-
* @param {Project | undefined} project
|
|
36
|
-
* @returns {boolean}
|
|
37
|
-
*/
|
|
38
|
-
export function hasSources(project: Project | undefined): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Package names the project's package.json declares in any dependency field.
|
|
41
|
-
* @param {Project | undefined} project
|
|
42
|
-
* @returns {Set<string>}
|
|
43
|
-
*/
|
|
44
|
-
export function declaredDependencies(project: Project | undefined): Set<string>;
|
|
45
|
-
/**
|
|
46
|
-
* The command that adds a package with the project's package manager. Discover
|
|
47
|
-
* only prints it; it never runs it.
|
|
48
|
-
* @param {Project | undefined} project
|
|
49
|
-
* @returns {(name: string, version?: string) => string}
|
|
50
|
-
*/
|
|
51
|
-
export function addCommand(project: Project | undefined): (name: string, version?: string) => string;
|
|
52
|
-
/**
|
|
53
|
-
* The per-user cache directory the saved copies live in, never inside a
|
|
54
|
-
* project. Standard platform locations only.
|
|
55
|
-
* @returns {string}
|
|
56
|
-
*/
|
|
57
|
-
export function defaultCacheDir(): string;
|
|
58
|
-
/**
|
|
59
|
-
* Call every discover source — the project's `discover` first, then each
|
|
60
|
-
* integration's in load order — once per distinct function. A source that
|
|
61
|
-
* throws, times out, or returns an invalid catalog falls back to its saved copy;
|
|
62
|
-
* with none, it is reported and adds nothing. The others always count.
|
|
63
|
-
*
|
|
64
|
-
* @param {Project | undefined} project
|
|
65
|
-
* @param {{package?: string, version?: string}} [request] ask for one package,
|
|
66
|
-
* and optionally one version's contributions
|
|
67
|
-
* @param {{cacheDir?: string, timeoutMs?: number}} [options]
|
|
68
|
-
* @returns {Promise<CatalogResult>}
|
|
69
|
-
*/
|
|
70
|
-
export function callSources(project: Project | undefined, request?: {
|
|
71
|
-
package?: string;
|
|
72
|
-
version?: string;
|
|
73
|
-
}, options?: {
|
|
74
|
-
cacheDir?: string;
|
|
75
|
-
timeoutMs?: number;
|
|
76
|
-
}): Promise<CatalogResult>;
|
|
77
|
-
/**
|
|
78
|
-
* Project a scanned or installed package into the discover list/detail entry
|
|
79
|
-
* shape. Shared by the list and detail leaves so the entry keys (and their
|
|
80
|
-
* order) stay in one place. A kind list appears only when it is not empty.
|
|
81
|
-
* @param {InstalledPackage & {latest?: string}} pkg
|
|
22
|
+
* Project a scanned package into the discover list/detail entry shape. Shared
|
|
23
|
+
* by the list and detail leaves so the entry keys (and their order) stay in one
|
|
24
|
+
* place.
|
|
25
|
+
* @param {ScannedPackage} pkg
|
|
82
26
|
* @returns {import('./discover.type.mjs').DiscoverListEntry}
|
|
83
27
|
*/
|
|
84
|
-
export function toEntry(pkg:
|
|
85
|
-
latest?: string;
|
|
86
|
-
}): import("./discover.type.mjs").DiscoverListEntry;
|
|
28
|
+
export function toEntry(pkg: ScannedPackage): import("./discover.type.mjs").DiscoverListEntry;
|
|
87
29
|
/**
|
|
88
30
|
* Locate a component's doc file within the given packages (case-insensitive).
|
|
89
31
|
* @param {ScannedPackage[]} packages
|
|
@@ -104,56 +46,7 @@ export function loadValidatedDoc(result: ComponentResolution, { lang, zh }: {
|
|
|
104
46
|
lang?: string | null;
|
|
105
47
|
zh?: boolean;
|
|
106
48
|
}): Promise<import("./discover.type.mjs").DiscoverDetailDocResponse["data"]>;
|
|
107
|
-
/** The list and detail entry fields for each item kind, in display order. */
|
|
108
|
-
export const KIND_FIELDS: readonly [readonly ["component", "components"], readonly ["template", "templates"], readonly ["doc", "docs"], readonly ["theme", "themes"], readonly ["codemod", "codemods"], readonly ["agent-doc", "agentDocs"]];
|
|
109
49
|
export type ScannedPackage = import("./_package-scanner.mjs").ScannedPackage;
|
|
110
|
-
export type DiscoverPackage = import("../../authoring/discover/type").DiscoverPackage;
|
|
111
|
-
export type DiscoverSource = import("../../authoring/discover/type").DiscoverSource;
|
|
112
|
-
/**
|
|
113
|
-
* An installed integration with what it adds, per kind. `components` is the
|
|
114
|
-
* scanned component list the discover leaves have always used.
|
|
115
|
-
*/
|
|
116
|
-
export type InstalledPackage = ScannedPackage & {
|
|
117
|
-
templates?: string[];
|
|
118
|
-
docs?: string[];
|
|
119
|
-
themes?: string[];
|
|
120
|
-
codemods?: string[];
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* What one source did on this run.
|
|
124
|
-
*/
|
|
125
|
-
export type SourceState = {
|
|
126
|
-
/**
|
|
127
|
-
* the source's own name, or where it came from when it
|
|
128
|
-
* gave none
|
|
129
|
-
*/
|
|
130
|
-
name: string;
|
|
131
|
-
/**
|
|
132
|
-
* `astryx.config`, or the integration that exports it
|
|
133
|
-
*/
|
|
134
|
-
from: string;
|
|
135
|
-
status: "fresh" | "saved" | "failed";
|
|
136
|
-
generatedAt?: string | undefined;
|
|
137
|
-
complete?: boolean | undefined;
|
|
138
|
-
/**
|
|
139
|
-
* when the saved copy in use was written
|
|
140
|
-
*/
|
|
141
|
-
savedAt?: string | undefined;
|
|
142
|
-
/**
|
|
143
|
-
* why the live call failed
|
|
144
|
-
*/
|
|
145
|
-
error?: string | undefined;
|
|
146
|
-
};
|
|
147
|
-
/**
|
|
148
|
-
* Everything every source returned, merged. When two sources list the same
|
|
149
|
-
* package, the earlier source's entry is kept.
|
|
150
|
-
*/
|
|
151
|
-
export type CatalogResult = {
|
|
152
|
-
sources: SourceState[];
|
|
153
|
-
packages: Array<DiscoverPackage & {
|
|
154
|
-
source: string;
|
|
155
|
-
}>;
|
|
156
|
-
};
|
|
157
50
|
/**
|
|
158
51
|
* A located component doc within a scanned package — the shape returned by
|
|
159
52
|
* {@link findComponent}, consumed by {@link loadValidatedDoc}.
|
|
@@ -163,4 +56,3 @@ export type ComponentResolution = {
|
|
|
163
56
|
docPath: string;
|
|
164
57
|
componentName: string;
|
|
165
58
|
};
|
|
166
|
-
import { Project } from '../../foundation/config/project.mjs';
|
|
@@ -1,81 +1,31 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Shared adapter for the discover leaves
|
|
5
|
-
* the environment.
|
|
4
|
+
* @file Shared external-package adapter for the discover leaves.
|
|
6
5
|
*
|
|
7
6
|
* Every `discover.*` leaf projects already-resolved data into a typed response;
|
|
8
|
-
* none of them touch the integration system
|
|
9
|
-
* adapter does: it
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
7
|
+
* none of them touch the integration system or the filesystem directly. This
|
|
8
|
+
* adapter is the single place that does: it discovers the configured external
|
|
9
|
+
* packages, locates a component's doc file within them, and loads + validates a
|
|
10
|
+
* component's docs. Keeping that I/O here (rather than duplicated across leaves)
|
|
11
|
+
* is what lets `list`, `detail`, `detail/doc`, and `search` stay pure
|
|
12
|
+
* projections.
|
|
14
13
|
*
|
|
15
|
-
* @position api/discover — orchestration over
|
|
16
|
-
*
|
|
14
|
+
* @position api/discover — orchestration over lib/project, lib/package-scanner,
|
|
15
|
+
* and lib/component-loader; the discover dispatcher + leaves consume it.
|
|
17
16
|
*/
|
|
18
17
|
|
|
19
|
-
import {createHash} from 'node:crypto';
|
|
20
|
-
import * as fs from 'node:fs';
|
|
21
|
-
import * as os from 'node:os';
|
|
22
|
-
import * as path from 'node:path';
|
|
23
18
|
import {Project} from '../../foundation/config/project.mjs';
|
|
24
19
|
import {
|
|
25
20
|
scanAllPackages,
|
|
26
21
|
findComponentInPackages,
|
|
27
22
|
} from './_package-scanner.mjs';
|
|
28
23
|
import {loadDocs} from '../../foundation/discovery/component-loader.mjs';
|
|
29
|
-
import {collectIdentities} from '../../foundation/integrations/contribution-inventory.mjs';
|
|
30
|
-
import {detectPackageManager} from '../../foundation/env/package-manager.mjs';
|
|
31
|
-
import {assertWithin} from '../../foundation/fs/path-safety.mjs';
|
|
32
|
-
import {parseDiscoverCatalog} from '../../authoring/discover/parse.mjs';
|
|
33
24
|
import {AstryxError} from '../error.mjs';
|
|
34
25
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
35
26
|
|
|
36
|
-
const SOURCE_TIMEOUT_MS = 30_000;
|
|
37
|
-
|
|
38
|
-
const DEPENDENCY_FIELDS = [
|
|
39
|
-
'dependencies',
|
|
40
|
-
'devDependencies',
|
|
41
|
-
'optionalDependencies',
|
|
42
|
-
'peerDependencies',
|
|
43
|
-
];
|
|
44
|
-
|
|
45
27
|
/**
|
|
46
28
|
* @typedef {import('./_package-scanner.mjs').ScannedPackage} ScannedPackage
|
|
47
|
-
* @typedef {import('../../authoring/discover/type').DiscoverPackage} DiscoverPackage
|
|
48
|
-
* @typedef {import('../../authoring/discover/type').DiscoverSource} DiscoverSource
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* An installed integration with what it adds, per kind. `components` is the
|
|
53
|
-
* scanned component list the discover leaves have always used.
|
|
54
|
-
* @typedef {ScannedPackage & {
|
|
55
|
-
* templates?: string[],
|
|
56
|
-
* docs?: string[],
|
|
57
|
-
* themes?: string[],
|
|
58
|
-
* codemods?: string[],
|
|
59
|
-
* }} InstalledPackage
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* What one source did on this run.
|
|
64
|
-
* @typedef {object} SourceState
|
|
65
|
-
* @property {string} name the source's own name, or where it came from when it
|
|
66
|
-
* gave none
|
|
67
|
-
* @property {string} from `astryx.config`, or the integration that exports it
|
|
68
|
-
* @property {'fresh' | 'saved' | 'failed'} status
|
|
69
|
-
* @property {string} [generatedAt]
|
|
70
|
-
* @property {boolean} [complete]
|
|
71
|
-
* @property {string} [savedAt] when the saved copy in use was written
|
|
72
|
-
* @property {string} [error] why the live call failed
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Everything every source returned, merged. When two sources list the same
|
|
77
|
-
* package, the earlier source's entry is kept.
|
|
78
|
-
* @typedef {{sources: SourceState[], packages: Array<DiscoverPackage & {source: string}>}} CatalogResult
|
|
79
29
|
*/
|
|
80
30
|
|
|
81
31
|
/**
|
|
@@ -118,7 +68,7 @@ function validateDocs(docs) {
|
|
|
118
68
|
* configured" (`false`) from "configured but nothing discovered" (`true`),
|
|
119
69
|
* which the list leaf surfaces as `meta`.
|
|
120
70
|
*
|
|
121
|
-
* @returns {Promise<{packages: ScannedPackage[], configured: boolean
|
|
71
|
+
* @returns {Promise<{packages: ScannedPackage[], configured: boolean}>}
|
|
122
72
|
*/
|
|
123
73
|
export async function discoverPackages() {
|
|
124
74
|
const project = await Project.load();
|
|
@@ -136,323 +86,25 @@ export async function discoverPackages() {
|
|
|
136
86
|
docsDir: integration.components,
|
|
137
87
|
}));
|
|
138
88
|
if (explicitPackages.length === 0) {
|
|
139
|
-
return {packages: [], configured: loadedIntegrations.length > 0
|
|
89
|
+
return {packages: [], configured: loadedIntegrations.length > 0};
|
|
140
90
|
}
|
|
141
91
|
|
|
142
92
|
const packages = scanAllPackages(
|
|
143
93
|
[],
|
|
144
94
|
/** @type {ScannedPackage[]} */ (/** @type {unknown} */ (explicitPackages)),
|
|
145
95
|
);
|
|
146
|
-
return {packages, configured: true
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Every integration the project loads, with what it adds. An integration with
|
|
151
|
-
* no components root is included with `components: []`; one that failed to
|
|
152
|
-
* load is left out (the integration-issues nudge and Doctor report it).
|
|
153
|
-
*
|
|
154
|
-
* @param {Project | undefined} project
|
|
155
|
-
* @param {ScannedPackage[]} scanned the packages {@link discoverPackages} found
|
|
156
|
-
* @returns {Promise<InstalledPackage[]>}
|
|
157
|
-
*/
|
|
158
|
-
export async function describeInstalled(project, scanned) {
|
|
159
|
-
if (project == null) return scanned;
|
|
160
|
-
const byName = new Map(scanned.map(pkg => [pkg.name, pkg]));
|
|
161
|
-
/** @type {InstalledPackage[]} */
|
|
162
|
-
const installed = [];
|
|
163
|
-
for (const integration of project.loadedIntegrations) {
|
|
164
|
-
if (integration.__loadError) continue;
|
|
165
|
-
const base =
|
|
166
|
-
byName.get(integration.name) ??
|
|
167
|
-
/** @type {ScannedPackage} */ (
|
|
168
|
-
/** @type {unknown} */ ({
|
|
169
|
-
name: integration.name,
|
|
170
|
-
category: integration.name,
|
|
171
|
-
version: integration.version,
|
|
172
|
-
components: [],
|
|
173
|
-
})
|
|
174
|
-
);
|
|
175
|
-
// Components come from the scan above; loading every component doc again
|
|
176
|
-
// here would only slow the list down.
|
|
177
|
-
const {identities} = await collectIdentities({
|
|
178
|
-
...integration,
|
|
179
|
-
components: undefined,
|
|
180
|
-
});
|
|
181
|
-
installed.push({
|
|
182
|
-
...base,
|
|
183
|
-
templates: identities.templates.map(t => t.id),
|
|
184
|
-
docs: identities.docs,
|
|
185
|
-
themes: identities.themes.map(t => t.slug),
|
|
186
|
-
codemods: identities.codemods.map(c => `${c.version}/${c.id}`),
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
return installed;
|
|
96
|
+
return {packages, configured: true};
|
|
190
97
|
}
|
|
191
98
|
|
|
192
99
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* @
|
|
197
|
-
*/
|
|
198
|
-
export function hasSources(project) {
|
|
199
|
-
if (project == null) return false;
|
|
200
|
-
if (typeof project.config?.discover === 'function') return true;
|
|
201
|
-
return project.loadedIntegrations.some(
|
|
202
|
-
i => i.__discover != null || i.__discoverError != null,
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Package names the project's package.json declares in any dependency field.
|
|
208
|
-
* @param {Project | undefined} project
|
|
209
|
-
* @returns {Set<string>}
|
|
210
|
-
*/
|
|
211
|
-
export function declaredDependencies(project) {
|
|
212
|
-
/** @type {Set<string>} */
|
|
213
|
-
const names = new Set();
|
|
214
|
-
if (project == null) return names;
|
|
215
|
-
try {
|
|
216
|
-
const pkg = JSON.parse(
|
|
217
|
-
fs.readFileSync(path.join(project.cwd, 'package.json'), 'utf8'),
|
|
218
|
-
);
|
|
219
|
-
for (const field of DEPENDENCY_FIELDS) {
|
|
220
|
-
for (const name of Object.keys(pkg?.[field] ?? {})) names.add(name);
|
|
221
|
-
}
|
|
222
|
-
} catch {
|
|
223
|
-
// No readable package.json: nothing is declared.
|
|
224
|
-
}
|
|
225
|
-
return names;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* The command that adds a package with the project's package manager. Discover
|
|
230
|
-
* only prints it; it never runs it.
|
|
231
|
-
* @param {Project | undefined} project
|
|
232
|
-
* @returns {(name: string, version?: string) => string}
|
|
233
|
-
*/
|
|
234
|
-
export function addCommand(project) {
|
|
235
|
-
const pm = detectPackageManager(project?.cwd ?? process.cwd());
|
|
236
|
-
const verb =
|
|
237
|
-
pm === 'pnpm'
|
|
238
|
-
? 'pnpm add'
|
|
239
|
-
: pm === 'yarn'
|
|
240
|
-
? 'yarn add'
|
|
241
|
-
: pm === 'bun'
|
|
242
|
-
? 'bun add'
|
|
243
|
-
: 'npm install';
|
|
244
|
-
return (name, version) => `${verb} ${version ? `${name}@${version}` : name}`;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* The per-user cache directory the saved copies live in, never inside a
|
|
249
|
-
* project. Standard platform locations only.
|
|
250
|
-
* @returns {string}
|
|
251
|
-
*/
|
|
252
|
-
export function defaultCacheDir() {
|
|
253
|
-
const home = os.homedir();
|
|
254
|
-
if (process.platform === 'win32') {
|
|
255
|
-
return path.join(
|
|
256
|
-
process.env.LOCALAPPDATA || path.join(home, 'AppData', 'Local'),
|
|
257
|
-
'astryx',
|
|
258
|
-
'Cache',
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
if (process.platform === 'darwin') {
|
|
262
|
-
return path.join(home, 'Library', 'Caches', 'astryx');
|
|
263
|
-
}
|
|
264
|
-
return path.join(
|
|
265
|
-
process.env.XDG_CACHE_HOME || path.join(home, '.cache'),
|
|
266
|
-
'astryx',
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* @param {string} cacheDir
|
|
272
|
-
* @param {string} from
|
|
273
|
-
* @param {{package?: string, version?: string}} request
|
|
274
|
-
*/
|
|
275
|
-
function savedCopyPath(cacheDir, from, request) {
|
|
276
|
-
const key = createHash('sha256')
|
|
277
|
-
.update(`${from}\n${request.package ?? ''}\n${request.version ?? ''}`)
|
|
278
|
-
.digest('hex')
|
|
279
|
-
.slice(0, 32);
|
|
280
|
-
const dir = path.join(cacheDir, 'discover');
|
|
281
|
-
return assertWithin(`${key}.json`, dir, {label: 'discover saved copy'});
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* @param {string} file
|
|
286
|
-
* @param {string} label
|
|
287
|
-
*/
|
|
288
|
-
function readSavedCopy(file, label) {
|
|
289
|
-
try {
|
|
290
|
-
const saved = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
291
|
-
return {
|
|
292
|
-
savedAt: String(saved.savedAt),
|
|
293
|
-
catalog: parseDiscoverCatalog(saved.catalog, label),
|
|
294
|
-
};
|
|
295
|
-
} catch {
|
|
296
|
-
return null;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* @param {string} file
|
|
302
|
-
* @param {import('../../authoring/discover/type').DiscoverCatalog} catalog
|
|
303
|
-
*/
|
|
304
|
-
function writeSavedCopy(file, catalog) {
|
|
305
|
-
try {
|
|
306
|
-
fs.mkdirSync(path.dirname(file), {recursive: true});
|
|
307
|
-
const tmp = `${file}.${process.pid}.tmp`;
|
|
308
|
-
fs.writeFileSync(
|
|
309
|
-
tmp,
|
|
310
|
-
JSON.stringify({savedAt: new Date().toISOString(), catalog}),
|
|
311
|
-
);
|
|
312
|
-
fs.renameSync(tmp, file);
|
|
313
|
-
} catch {
|
|
314
|
-
// An unwritable cache only costs the offline copy.
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* @param {DiscoverSource} source
|
|
320
|
-
* @param {{package?: string, version?: string}} request
|
|
321
|
-
* @param {string} label
|
|
322
|
-
* @param {number} timeoutMs
|
|
323
|
-
*/
|
|
324
|
-
async function callSource(source, request, label, timeoutMs) {
|
|
325
|
-
const controller = new AbortController();
|
|
326
|
-
/** @type {ReturnType<typeof setTimeout> | undefined} */
|
|
327
|
-
let timer;
|
|
328
|
-
const timedOut = new Promise((_, reject) => {
|
|
329
|
-
timer = setTimeout(() => {
|
|
330
|
-
controller.abort();
|
|
331
|
-
reject(
|
|
332
|
-
new Error(`${label} did not answer within ${timeoutMs / 1000} seconds`),
|
|
333
|
-
);
|
|
334
|
-
}, timeoutMs);
|
|
335
|
-
});
|
|
336
|
-
try {
|
|
337
|
-
const answer = await Promise.race([
|
|
338
|
-
Promise.resolve().then(() =>
|
|
339
|
-
source({signal: controller.signal, ...request}),
|
|
340
|
-
),
|
|
341
|
-
timedOut,
|
|
342
|
-
]);
|
|
343
|
-
return parseDiscoverCatalog(answer, label);
|
|
344
|
-
} finally {
|
|
345
|
-
clearTimeout(timer);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Call every discover source — the project's `discover` first, then each
|
|
351
|
-
* integration's in load order — once per distinct function. A source that
|
|
352
|
-
* throws, times out, or returns an invalid catalog falls back to its saved copy;
|
|
353
|
-
* with none, it is reported and adds nothing. The others always count.
|
|
354
|
-
*
|
|
355
|
-
* @param {Project | undefined} project
|
|
356
|
-
* @param {{package?: string, version?: string}} [request] ask for one package,
|
|
357
|
-
* and optionally one version's contributions
|
|
358
|
-
* @param {{cacheDir?: string, timeoutMs?: number}} [options]
|
|
359
|
-
* @returns {Promise<CatalogResult>}
|
|
360
|
-
*/
|
|
361
|
-
export async function callSources(project, request = {}, options = {}) {
|
|
362
|
-
const {cacheDir = defaultCacheDir(), timeoutMs = SOURCE_TIMEOUT_MS} = options;
|
|
363
|
-
/** @type {CatalogResult} */
|
|
364
|
-
const result = {sources: [], packages: []};
|
|
365
|
-
if (project == null) return result;
|
|
366
|
-
|
|
367
|
-
/** @type {Array<{from: string, source?: DiscoverSource, error?: string}>} */
|
|
368
|
-
const origins = [];
|
|
369
|
-
if (typeof project.config?.discover === 'function') {
|
|
370
|
-
origins.push({from: 'astryx.config', source: project.config.discover});
|
|
371
|
-
}
|
|
372
|
-
for (const integration of project.loadedIntegrations) {
|
|
373
|
-
if (integration.__discoverError) {
|
|
374
|
-
origins.push({from: integration.name, error: integration.__discoverError});
|
|
375
|
-
} else if (integration.__discover) {
|
|
376
|
-
origins.push({from: integration.name, source: integration.__discover});
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/** @type {Set<unknown>} */
|
|
381
|
-
const called = new Set();
|
|
382
|
-
/** @type {Set<string>} */
|
|
383
|
-
const seen = new Set();
|
|
384
|
-
const ask = request.package
|
|
385
|
-
? {package: request.package, ...(request.version ? {version: request.version} : {})}
|
|
386
|
-
: {};
|
|
387
|
-
for (const {from, source, error} of origins) {
|
|
388
|
-
if (source == null) {
|
|
389
|
-
result.sources.push({name: from, from, status: 'failed', error});
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
if (called.has(source)) continue;
|
|
393
|
-
called.add(source);
|
|
394
|
-
|
|
395
|
-
const label = `the discover source from ${from}`;
|
|
396
|
-
const file = savedCopyPath(cacheDir, from, ask);
|
|
397
|
-
/** @type {import('../../authoring/discover/type').DiscoverCatalog} */
|
|
398
|
-
let catalog;
|
|
399
|
-
try {
|
|
400
|
-
catalog = await callSource(source, ask, label, timeoutMs);
|
|
401
|
-
writeSavedCopy(file, catalog);
|
|
402
|
-
result.sources.push({
|
|
403
|
-
name: catalog.source.name,
|
|
404
|
-
from,
|
|
405
|
-
status: 'fresh',
|
|
406
|
-
generatedAt: catalog.source.generatedAt,
|
|
407
|
-
complete: catalog.source.complete,
|
|
408
|
-
});
|
|
409
|
-
} catch (err) {
|
|
410
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
411
|
-
const saved = readSavedCopy(file, label);
|
|
412
|
-
if (saved == null) {
|
|
413
|
-
result.sources.push({name: from, from, status: 'failed', error: message});
|
|
414
|
-
continue;
|
|
415
|
-
}
|
|
416
|
-
catalog = saved.catalog;
|
|
417
|
-
result.sources.push({
|
|
418
|
-
name: catalog.source.name,
|
|
419
|
-
from,
|
|
420
|
-
status: 'saved',
|
|
421
|
-
generatedAt: catalog.source.generatedAt,
|
|
422
|
-
complete: catalog.source.complete,
|
|
423
|
-
savedAt: saved.savedAt,
|
|
424
|
-
error: message,
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
for (const pkg of catalog.packages) {
|
|
428
|
-
if (seen.has(pkg.package)) continue;
|
|
429
|
-
seen.add(pkg.package);
|
|
430
|
-
result.packages.push({...pkg, source: catalog.source.name});
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
return result;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
/** The list and detail entry fields for each item kind, in display order. */
|
|
437
|
-
export const KIND_FIELDS = /** @type {const} */ ([
|
|
438
|
-
['component', 'components'],
|
|
439
|
-
['template', 'templates'],
|
|
440
|
-
['doc', 'docs'],
|
|
441
|
-
['theme', 'themes'],
|
|
442
|
-
['codemod', 'codemods'],
|
|
443
|
-
['agent-doc', 'agentDocs'],
|
|
444
|
-
]);
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Project a scanned or installed package into the discover list/detail entry
|
|
448
|
-
* shape. Shared by the list and detail leaves so the entry keys (and their
|
|
449
|
-
* order) stay in one place. A kind list appears only when it is not empty.
|
|
450
|
-
* @param {InstalledPackage & {latest?: string}} pkg
|
|
100
|
+
* Project a scanned package into the discover list/detail entry shape. Shared
|
|
101
|
+
* by the list and detail leaves so the entry keys (and their order) stay in one
|
|
102
|
+
* place.
|
|
103
|
+
* @param {ScannedPackage} pkg
|
|
451
104
|
* @returns {import('./discover.type.mjs').DiscoverListEntry}
|
|
452
105
|
*/
|
|
453
106
|
export function toEntry(pkg) {
|
|
454
|
-
|
|
455
|
-
const entry = {
|
|
107
|
+
return {
|
|
456
108
|
name: pkg.name,
|
|
457
109
|
category: pkg.category,
|
|
458
110
|
components: pkg.components,
|
|
@@ -460,13 +112,6 @@ export function toEntry(pkg) {
|
|
|
460
112
|
description: pkg.description,
|
|
461
113
|
displayName: pkg.displayName,
|
|
462
114
|
};
|
|
463
|
-
for (const [, field] of KIND_FIELDS) {
|
|
464
|
-
if (field === 'components') continue;
|
|
465
|
-
const values = /** @type {Record<string, unknown>} */ (pkg)[field];
|
|
466
|
-
if (Array.isArray(values) && values.length > 0) entry[field] = values;
|
|
467
|
-
}
|
|
468
|
-
if (pkg.latest) entry.latest = pkg.latest;
|
|
469
|
-
return /** @type {import('./discover.type.mjs').DiscoverListEntry} */ (entry);
|
|
470
115
|
}
|
|
471
116
|
|
|
472
117
|
/**
|
|
@@ -2,24 +2,12 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Build the discover.detail response for
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* that adds it — printed, never run.
|
|
5
|
+
* Build the discover.detail response for a scoped package name. Throws
|
|
6
|
+
* AstryxError (ERR_UNKNOWN_PACKAGE) — with the available packages as
|
|
7
|
+
* suggestions — when no package matches.
|
|
9
8
|
*
|
|
10
|
-
* @param {import('../
|
|
11
|
-
* @param {string}
|
|
12
|
-
* @param {{
|
|
13
|
-
* catalog?: import('../_catalog-view.mjs').CatalogPackage,
|
|
14
|
-
* version?: string,
|
|
15
|
-
* add?: (name: string, version?: string) => string,
|
|
16
|
-
* installedAs?: string,
|
|
17
|
-
* }} [options]
|
|
9
|
+
* @param {import('../_package-scanner.mjs').ScannedPackage[]} packages
|
|
10
|
+
* @param {string} query scoped package name, e.g. `@scope/name`
|
|
18
11
|
* @returns {import('../discover.type.mjs').DiscoverDetailResponse}
|
|
19
12
|
*/
|
|
20
|
-
export function detail(packages: import("../
|
|
21
|
-
catalog?: import("../_catalog-view.mjs").CatalogPackage;
|
|
22
|
-
version?: string;
|
|
23
|
-
add?: (name: string, version?: string) => string;
|
|
24
|
-
installedAs?: string;
|
|
25
|
-
}): import("../discover.type.mjs").DiscoverDetailResponse;
|
|
13
|
+
export function detail(packages: import("../_package-scanner.mjs").ScannedPackage[], query: string): import("../discover.type.mjs").DiscoverDetailResponse;
|