@astryxdesign/cli 0.7.2-canary.6a3ff0f → 0.7.2-canary.6c792d8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -62
- package/api/component/_adapter.d.mts +31 -0
- package/api/component/_adapter.mjs +116 -0
- package/api/component/component.mjs +60 -10
- package/api/component/doc-links.test.mjs +386 -0
- package/api/discover/_adapter.d.mts +119 -12
- package/api/discover/_adapter.mjs +449 -10
- package/api/discover/_adapter.test.mjs +599 -17
- package/api/discover/_catalog-view.d.mts +16 -5
- package/api/discover/_catalog-view.mjs +32 -8
- package/api/discover/detail/doc/doc.mjs +9 -1
- package/api/discover/discover.d.mts +11 -0
- package/api/discover/discover.doc.mjs +7 -6
- package/api/discover/discover.mjs +107 -19
- package/api/discover/discover.type.d.mts +18 -7
- package/api/discover/discover.type.mjs +15 -7
- package/api/discover/list/list.d.mts +4 -3
- package/api/discover/list/list.mjs +17 -10
- package/api/docs/_adapter.d.mts +63 -0
- package/api/docs/_adapter.mjs +309 -16
- package/api/docs/integration-tree.test.mjs +22 -0
- package/api/docs/list/list.mjs +12 -2
- package/api/doctor/theme-checks.test.mjs +136 -0
- package/api/integration/_adapter.d.mts +33 -0
- package/api/integration/_adapter.mjs +58 -0
- package/api/integration/authoring-checks.mjs +98 -3
- package/api/integration/authoring-checks.test.mjs +769 -0
- package/api/integration/authoring-checks.type.d.mts +134 -0
- package/api/integration/authoring-checks.type.mjs +60 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +3 -1
- package/api/integration/integrationDocConflicts.doc.mjs +22 -5
- package/api/integration/pack-check.mjs +296 -7
- package/api/integration/pack-check.test.mjs +367 -0
- package/api/integration/validate-integration-fixes.test.mjs +67 -0
- package/api/integration/validate-integration.mjs +28 -3
- package/api/integration/validate-integration.test.mjs +77 -8
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/search.mjs +2 -1
- package/assets/discover/official-packages.json +367 -0
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +3 -3
- package/assets/docs/tree/check-the-props.doc.mjs +7 -2
- package/assets/docs/tree/check-your-docs.doc.mjs +15 -3
- package/assets/docs/tree/checks.doc.mjs +5 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +7 -7
- package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
- package/assets/docs/tree/layout.doc.mjs +6 -6
- package/assets/docs/tree/migration-setup.doc.mjs +2 -2
- package/assets/docs/tree/publishing.doc.mjs +3 -3
- package/assets/docs/tree/quick-start.doc.mjs +2 -2
- package/assets/docs/tree/sections-and-placement.doc.mjs +2 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +5 -5
- package/assets/docs/tree/upgrading.doc.mjs +1 -1
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -0
- package/authoring/doctypes/hook/type.ts +4 -0
- package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
- package/clients/cli/commands/discover.doc.mjs +1 -1
- package/clients/cli/commands/discover.mjs +144 -93
- package/clients/cli/commands/discover.no-source.test.mjs +447 -33
- package/clients/cli/commands/discover.sources.test.mjs +20 -1
- package/clients/cli/commands/doctor-integration-components.doc.mjs +3 -2
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +19 -5
- package/clients/cli/commands/doctor-integration.test.mjs +48 -1
- package/clients/cli/commands/doctor.mjs +91 -5
- package/clients/cli/commands/integration-authoring.test.mjs +46 -0
- package/clients/cli/commands/integration-check.test.mjs +127 -0
- package/clients/cli/commands/integration.mjs +10 -4
- package/clients/cli/commands/json-contract.test.mjs +5 -1
- package/foundation/discovery/copied-passages.d.mts +216 -0
- package/foundation/discovery/copied-passages.mjs +720 -0
- package/foundation/discovery/copied-passages.test.mjs +124 -0
- package/foundation/discovery/doc-consistency.d.mts +34 -0
- package/foundation/discovery/doc-consistency.mjs +513 -0
- package/foundation/discovery/doc-consistency.test.mjs +347 -0
- package/foundation/discovery/doc-fluff.d.mts +112 -0
- package/foundation/discovery/doc-fluff.mjs +328 -0
- package/foundation/discovery/doc-fluff.test.mjs +142 -0
- package/foundation/discovery/doc-types.mjs +12 -5
- package/foundation/discovery/doc-types.test.mjs +46 -2
- package/foundation/discovery/docs-discovery.d.mts +7 -0
- package/foundation/discovery/docs-discovery.mjs +26 -2
- package/foundation/discovery/prop-drift.d.mts +25 -6
- package/foundation/discovery/prop-drift.mjs +171 -6
- package/foundation/discovery/prop-drift.test.mjs +65 -0
- package/foundation/discovery/stray-pointers.d.mts +52 -0
- package/foundation/discovery/stray-pointers.mjs +293 -0
- package/foundation/discovery/stray-pointers.test.mjs +86 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +16 -0
- package/foundation/doc-compiler/links.d.mts +32 -0
- package/foundation/doc-compiler/links.mjs +163 -26
- package/foundation/doc-compiler/links.test.mjs +97 -4
- package/foundation/doc-compiler/tree.mjs +30 -1
- package/foundation/doc-compiler/tree.test.mjs +7 -0
- package/foundation/fs/module-loader.d.mts +2 -1
- package/foundation/fs/module-loader.mjs +60 -4
- package/foundation/fs/module-loader.test.mjs +194 -0
- package/foundation/integrations/contribution-inventory.d.mts +11 -0
- package/foundation/integrations/contribution-inventory.mjs +50 -2
- package/foundation/integrations/issue.ts +6 -0
- package/foundation/integrations/validate-contributions.mjs +30 -1
- package/foundation/response/response-types.doc.mjs +5 -5
- package/package.json +11 -11
|
@@ -13,8 +13,7 @@ export const docs = {
|
|
|
13
13
|
title: 'Layout spacing',
|
|
14
14
|
placement: {parent: 'namespace:layout', slot: 'guides', order: 40},
|
|
15
15
|
category: 'guide',
|
|
16
|
-
description:
|
|
17
|
-
'Hold one content line per region, then tune gaps and density.',
|
|
16
|
+
description: 'Hold one content line per region, then tune gaps and density.',
|
|
18
17
|
keywords: [
|
|
19
18
|
'alignment',
|
|
20
19
|
'content line',
|
|
@@ -35,7 +34,7 @@ export const docs = {
|
|
|
35
34
|
content: [
|
|
36
35
|
{
|
|
37
36
|
type: 'prose',
|
|
38
|
-
text: 'Hold one content line per region, then tune gaps and density. Alignment, Rhythm, and Density and size
|
|
37
|
+
text: 'Hold one content line per region, then tune gaps and density. Alignment, Rhythm, and Density and size each build on these rules.',
|
|
39
38
|
},
|
|
40
39
|
{
|
|
41
40
|
type: 'list',
|
|
@@ -32,21 +32,21 @@ export const docs = {
|
|
|
32
32
|
blocks: [
|
|
33
33
|
{
|
|
34
34
|
type: 'prose',
|
|
35
|
-
text:
|
|
35
|
+
text: 'Build a layout outside-in. Settle the shell and its region budgets before any content exists, then work inward. Content-first layouts drift into a padded column of cards, because every section ends up inventing its own container.',
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
type: 'list',
|
|
39
39
|
style: 'ordered',
|
|
40
40
|
items: [
|
|
41
|
-
|
|
42
|
-
"Structure: rank
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
'Scaffold: pick the shell, budget each region, and choose navigation',
|
|
42
|
+
"Structure: rank each region's content and choose its container",
|
|
43
|
+
'Spacing: align each region to one content line, then set gaps and density',
|
|
44
|
+
'Breakpoints: decide what each region does as width changes',
|
|
45
45
|
],
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
type: 'prose',
|
|
49
|
-
text:
|
|
49
|
+
text: 'This guide decides layout, not component APIs. Run `npx astryx build "<idea>"` to start from the closest template for your app type, and `npx astryx component <Name>` for a component\'s props.',
|
|
50
50
|
},
|
|
51
51
|
],
|
|
52
52
|
slots: {
|
|
@@ -85,7 +85,7 @@ astryx component TextInput`,
|
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
type: 'prose',
|
|
88
|
-
text: 'For a shorter read to paste into an AI coding tool,
|
|
88
|
+
text: 'For a shorter read to paste into an AI coding tool, see {@link generic:working-with-ai}. Use `--json` when building automated migration reports.',
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
type: 'code',
|
|
@@ -130,7 +130,7 @@ export function AppRoot({children}: {children: React.ReactNode}) {
|
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
type: 'prose',
|
|
133
|
-
text: '
|
|
133
|
+
text: 'Import the global CSS file first in the root layout or app entry, before anything that imports Astryx or theme CSS, including the `astryx-themes` module and a root component like the `AppRoot` above. Why the order matters, and what to do when it cannot come first, is in {@link generic:tailwind}.',
|
|
134
134
|
},
|
|
135
135
|
{
|
|
136
136
|
type: 'code',
|
|
@@ -14,7 +14,7 @@ export const docs = {
|
|
|
14
14
|
category: 'guide',
|
|
15
15
|
keywords: ['publish an integration', 'npm publish', 'release'],
|
|
16
16
|
description:
|
|
17
|
-
'Publish your package to npm under the right release tag,
|
|
17
|
+
'Publish your package to npm under the right release tag, checking it before and after.',
|
|
18
18
|
sections: [
|
|
19
19
|
{
|
|
20
20
|
id: 'check-before-you-publish',
|
|
@@ -59,7 +59,7 @@ export const docs = {
|
|
|
59
59
|
items: [
|
|
60
60
|
'List only the roots you ship, and always `astryx.integration.mjs`. npm adds package.json, and a README and LICENSE when you have them.',
|
|
61
61
|
'Each later `integration add` appends its root to the list.',
|
|
62
|
-
'`integration verify` fails when a root is missing from the list
|
|
62
|
+
'`integration verify` fails when a root is missing from the list, and names the root to add to `files` (the message is in {@link generic:troubleshooting}).',
|
|
63
63
|
],
|
|
64
64
|
},
|
|
65
65
|
],
|
|
@@ -79,7 +79,7 @@ export const docs = {
|
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
type: 'prose',
|
|
82
|
-
text: 'To let apps try a release first, publish it under `next`, then point `latest` at it
|
|
82
|
+
text: 'To let apps try a release first, publish it under `next`, then point `latest` at it once ready.',
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
type: 'code',
|
|
@@ -95,7 +95,7 @@ export const docs = {
|
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
97
|
type: 'prose',
|
|
98
|
-
text:
|
|
98
|
+
text: "Run `integration check --strict` in every build ({@link generic:checks}): a doc, prop, template, or link that drifts from the code then fails your build, not your users' apps. Set it up now, as the `typecheck` script, and run it.",
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
101
|
type: 'code',
|
|
@@ -136,7 +136,7 @@ export const docs = {
|
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
type: 'prose',
|
|
139
|
-
text: '`integration verify`
|
|
139
|
+
text: '`integration verify` installs the packed package in a temporary app and confirms the component resolves through its public import there ({@link generic:checks}). It publishes nothing and leaves no `.tgz` file, so `npm pack` writes `../acme-astryx-widgets-1.0.0.tgz` for the next step.',
|
|
140
140
|
},
|
|
141
141
|
{
|
|
142
142
|
type: 'heading',
|
|
@@ -95,8 +95,8 @@ export const docs = {
|
|
|
95
95
|
type: 'list',
|
|
96
96
|
style: 'unordered',
|
|
97
97
|
items: [
|
|
98
|
-
'A `parent`
|
|
99
|
-
'A `slot`
|
|
98
|
+
'A `parent` your package does not ship, such as `namespace:cli`, "names no namespace".',
|
|
99
|
+
'A `slot` the namespace does not declare "is not a slot of namespace"; the message lists the declared slots.',
|
|
100
100
|
'The check exits 1; see {@link generic:check-your-docs}.',
|
|
101
101
|
],
|
|
102
102
|
},
|
|
@@ -67,7 +67,7 @@ export const docs = {
|
|
|
67
67
|
'Set `type` to the kind you chose in {@link generic:start-a-template}. It decides which other fields the doc accepts.',
|
|
68
68
|
'The file name sets the template id ({@link generic:start-a-template}). Labels live in the doc: the terminal list prints `name`, and JSON listings print `displayName`. Changing either never changes the id.',
|
|
69
69
|
'Write the description for someone choosing between templates. The Doc metadata category in {@link generic:template-grading-rubric} defines what a complete description covers.',
|
|
70
|
-
"Name the ideas the template serves in `keywords`: the domains, tasks, and other names a builder might use for it, in lowercase, such as `['monitoring', 'uptime', 'on-call']` for a service-health dashboard.
|
|
70
|
+
"Name the ideas the template serves in `keywords`: the domains, tasks, and other names a builder might use for it, in lowercase, such as `['monitoring', 'uptime', 'on-call']` for a service-health dashboard. How search and build use them is in {@link generic:authoring}, so the description can stay about the layout.",
|
|
71
71
|
'Add `isReady: false` as soon as you generate the doc, because a doc without `isReady` is listed as ready. Keep it until the template passes {@link generic:test-template-in-app} and the quality review.',
|
|
72
72
|
],
|
|
73
73
|
},
|
|
@@ -78,7 +78,7 @@ export const docs = {
|
|
|
78
78
|
"The `exports` map has no entry for it. Run `npm pkg set 'exports[./components/AcmeCarousel]=./components/AcmeCarousel.tsx'`, or `'exports[./templates/acme-dashboard]=./templates/acme-dashboard.tsx'` for a template.",
|
|
79
79
|
],
|
|
80
80
|
[
|
|
81
|
-
|
|
81
|
+
"`component_import_unresolvable`: `…but a consumer cannot resolve it: Cannot find package '@acme/old-name'`",
|
|
82
82
|
"You renamed the package after the add wrote each doc's `import`. Change `import` in every component doc to the new name.",
|
|
83
83
|
],
|
|
84
84
|
[
|
|
@@ -95,11 +95,11 @@ export const docs = {
|
|
|
95
95
|
],
|
|
96
96
|
[
|
|
97
97
|
'`component_replaces_needs_cli` (a warning): The package has a component that sets `replaces` but declares no @astryxdesign/cli peer, or a peer range that admits an earlier CLI.',
|
|
98
|
-
"Run `npm pkg set 'peerDependencies.@astryxdesign/cli=>=0.6.7'` and `npm pkg set 'peerDependenciesMeta.@astryxdesign/cli.optional=true' --json` to turn the replacement on. Until then
|
|
98
|
+
"Run `npm pkg set 'peerDependencies.@astryxdesign/cli=>=0.6.7'` and `npm pkg set 'peerDependenciesMeta.@astryxdesign/cli.optional=true' --json` to turn the replacement on. Until then apps see no change ({@link generic:replace-a-core-component}).",
|
|
99
99
|
],
|
|
100
100
|
[
|
|
101
101
|
'`keywords_needs_cli`: The package has a template that sets `keywords` but declares no @astryxdesign/cli peer.',
|
|
102
|
-
"Run `npm pkg set 'peerDependencies.@astryxdesign/cli=>=0.6.6'` and `npm pkg set 'peerDependenciesMeta.@astryxdesign/cli.optional=true' --json`.
|
|
102
|
+
"Run `npm pkg set 'peerDependencies.@astryxdesign/cli=>=0.6.6'` and `npm pkg set 'peerDependenciesMeta.@astryxdesign/cli.optional=true' --json`. What an older CLI does with the field is in {@link generic:template-doc-overview}.",
|
|
103
103
|
],
|
|
104
104
|
[
|
|
105
105
|
'`themes_need_cli`: The package ships a theme but declares no @astryxdesign/cli peer.',
|
|
@@ -130,7 +130,7 @@ export const docs = {
|
|
|
130
130
|
"Its doc still names its file. Set `name` to the export, such as `name: 'AcmeCarousel'` in `acme-carousel.doc.mjs`. A family member is listed only when the module its family doc imports exports it ({@link generic:component-family}).",
|
|
131
131
|
],
|
|
132
132
|
[
|
|
133
|
-
|
|
133
|
+
"`npx astryx component Dialog` opens Core's `Dialog`, not yours.",
|
|
134
134
|
"A name that Core, a legacy docs package, or another package's file already has stays theirs. Run `npx astryx component Dialog --package @acme/astryx-widgets`, or give your component a name of its own.",
|
|
135
135
|
],
|
|
136
136
|
[
|
|
@@ -151,7 +151,7 @@ export const docs = {
|
|
|
151
151
|
],
|
|
152
152
|
[
|
|
153
153
|
'Your docs section, templates, or themes are missing only in some apps',
|
|
154
|
-
"Those apps run a CLI too old to read them
|
|
154
|
+
"Those apps run a CLI too old to read them ({@link generic:checks} lists which field needs which CLI). Update `@astryxdesign/cli` there, and keep your optional `@astryxdesign/cli` peer so npm checks the app's CLI against it when the app installs your package.",
|
|
155
155
|
],
|
|
156
156
|
],
|
|
157
157
|
},
|
|
@@ -35,7 +35,7 @@ export const docs = {
|
|
|
35
35
|
style: 'unordered',
|
|
36
36
|
items: [
|
|
37
37
|
'Run every check in {@link generic:checks}, not only the ones shown.',
|
|
38
|
-
'
|
|
38
|
+
'Codemod folders are named for Core versions: {@link generic:codemods}.',
|
|
39
39
|
'Release the result as a new version of your package; see {@link generic:publishing}.',
|
|
40
40
|
],
|
|
41
41
|
},
|
|
@@ -16,7 +16,7 @@ export const doc = {
|
|
|
16
16
|
displayName: 'DiscoverSource',
|
|
17
17
|
namespace: 'authoring',
|
|
18
18
|
description:
|
|
19
|
-
'A source for `astryx discover`: an async function that returns a catalog of packages a project could add, their versions, and what each version adds. Set it as `discover` in astryx.config, or export it as `discover` from an integration manifest. Discover calls every source, the project one first, and
|
|
19
|
+
'A source for `astryx discover`: an async function that returns a catalog of packages a project could add, their versions, and what each version adds. Set it as `discover` in astryx.config, or export it as `discover` from an integration manifest. Discover calls every source, the project one first, and then reads the official list the CLI carries; another source\'s entry for an official package is kept. A source that throws, runs past 30 seconds, or returns an invalid catalog never hides the others; discover then uses the last good answer that source gave for the same request, or reports the source as failed when it saved none. Discover only reads: it prints the command that adds a package and never runs it.',
|
|
20
20
|
appliesTo:
|
|
21
21
|
'`discover` in astryx.config.*, or the `discover` named export of astryx.integration.*',
|
|
22
22
|
fields: [
|
|
@@ -56,7 +56,7 @@ export const doc = {
|
|
|
56
56
|
name: 'replaces',
|
|
57
57
|
type: 'string',
|
|
58
58
|
description:
|
|
59
|
-
'Integration components only: the exact `name` of the Core ComponentDoc this component takes over for unqualified lookup, so every app that loads the integration gets it from component detail, component lists, search, `swizzle <Name>`, and issue routing; `swizzle --list` keeps listing Core names. The Core original stays reachable with `--package @astryxdesign/core`. It takes effect only when the package\'s peer range starts at the release that applies it, `"@astryxdesign/cli": ">=0.6.7"` or later;
|
|
59
|
+
'Integration components only: the exact `name` of the Core ComponentDoc this component takes over for unqualified lookup, so every app that loads the integration gets it from component detail, component lists, search, `swizzle <Name>`, and issue routing; `swizzle --list` keeps listing Core names. The Core original stays reachable with `--package @astryxdesign/core`. It takes effect only when the package\'s peer range starts at the release that applies it, `"@astryxdesign/cli": ">=0.6.7"` or later; with a lower range nothing changes and `doctor integration components` warns ({@link generic:replace-a-core-component}). Set it only to intentionally own a Core identity; give an alternative or variant its own name instead.',
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
name: 'keywords',
|
|
@@ -273,6 +273,14 @@ export interface ComponentRef {
|
|
|
273
273
|
* Used by both `docsZh` (Chinese translation) and `docsDense` (compressed format).
|
|
274
274
|
*/
|
|
275
275
|
export interface ComponentTranslationDoc {
|
|
276
|
+
/** Optional exact name from the base doc. Allowed so an overlay can say
|
|
277
|
+
* which component it translates; the overlay renders through the base
|
|
278
|
+
* doc, so this field is ignored at render time. */
|
|
279
|
+
name?: string;
|
|
280
|
+
/** Optional translated displayName. Allowed so the displayName backfill
|
|
281
|
+
* codemod (which adds `displayName` next to every `name:` field) does not
|
|
282
|
+
* break translation overlays. Ignored at render time. */
|
|
283
|
+
displayName?: string;
|
|
276
284
|
/** Compressed/translated component description. */
|
|
277
285
|
description?: string;
|
|
278
286
|
/** Prop descriptions keyed by prop name. Only include props that have descriptions. */
|
|
@@ -68,6 +68,10 @@ export interface HookDoc extends AuthoredDocGraphFields {
|
|
|
68
68
|
* Translation overlay for hook documentation.
|
|
69
69
|
*/
|
|
70
70
|
export interface HookTranslationDoc {
|
|
71
|
+
/** Optional exact name from the base doc. Ignored at render time. */
|
|
72
|
+
name?: string;
|
|
73
|
+
/** Optional translated displayName. Ignored at render time. */
|
|
74
|
+
displayName?: string;
|
|
71
75
|
/** Compressed/translated description. */
|
|
72
76
|
description?: string;
|
|
73
77
|
/** Param descriptions keyed by param name. */
|
|
@@ -83,7 +83,10 @@ describe('astryx discover with a manifest that fails to load', () => {
|
|
|
83
83
|
});
|
|
84
84
|
|
|
85
85
|
expect(status).toBe(0);
|
|
86
|
-
|
|
86
|
+
const {meta} = JSON.parse(stdout);
|
|
87
|
+
expect(meta.configured).toBe(true);
|
|
88
|
+
// The official list still answers; nothing else is claimed.
|
|
89
|
+
expect(meta.sources.map(s => s.name)).toEqual(['Astryx']);
|
|
87
90
|
expect(stderr).not.toContain('integration issue');
|
|
88
91
|
});
|
|
89
92
|
});
|
|
@@ -17,7 +17,7 @@ export const doc = {
|
|
|
17
17
|
summary:
|
|
18
18
|
'Browse and search integrations: the ones you have and the ones you could add',
|
|
19
19
|
description:
|
|
20
|
-
'Lists the integrations
|
|
20
|
+
'Lists what this project has, the integrations it loads and the official packages it declares, then what it could add: the official Astryx packages first, then whatever its discover sources list, with what each one adds. ' +
|
|
21
21
|
'A package query shows one package: what it adds, every version a source knows, and the command that adds it. ' +
|
|
22
22
|
"An @scope/name/Component path prints an installed component's doc; any other item path shows that item. " +
|
|
23
23
|
'Anything else, even an exact component name, searches every item and package and lists the matches. Discover only reads: your package manager installs, updates, and removes packages.',
|
|
@@ -27,7 +27,12 @@ import {
|
|
|
27
27
|
code,
|
|
28
28
|
} from '../formatters/index.mjs';
|
|
29
29
|
import {cliError, rejectEmptyArgument} from '../lib/cli-error.mjs';
|
|
30
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
answersQueries,
|
|
32
|
+
discover as discoverApi,
|
|
33
|
+
OFFICIAL_SOURCE_NAME,
|
|
34
|
+
} from '../../../api/discover/discover.mjs';
|
|
35
|
+
import {isValidSemver} from '../../../foundation/env/semver.mjs';
|
|
31
36
|
import {Project} from '../../../foundation/config/project.mjs';
|
|
32
37
|
import {warnOnIntegrationIssues} from '../../../foundation/integrations/integration-warnings.mjs';
|
|
33
38
|
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
@@ -200,6 +205,72 @@ function versionLines(versions, marks) {
|
|
|
200
205
|
});
|
|
201
206
|
}
|
|
202
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Whether a package entry adds anything besides themes.
|
|
210
|
+
* @param {Record<string, unknown>} entry
|
|
211
|
+
* @returns {boolean}
|
|
212
|
+
*/
|
|
213
|
+
function addsMoreThanThemes(entry) {
|
|
214
|
+
return ITEM_FIELDS.some(field => {
|
|
215
|
+
const names = entry[field];
|
|
216
|
+
return field !== 'themes' && Array.isArray(names) && names.length > 0;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* What an official entry's add command installs, when that is not the version
|
|
222
|
+
* the page shows: the project's Core version, or the Core range it declares.
|
|
223
|
+
* @param {string} install the package-manager command
|
|
224
|
+
* @param {string | undefined} shown the version the page shows
|
|
225
|
+
* @param {string | undefined} source the entry's source
|
|
226
|
+
* @returns {string | undefined}
|
|
227
|
+
*/
|
|
228
|
+
function pinNote(install, shown, source) {
|
|
229
|
+
if (source !== OFFICIAL_SOURCE_NAME) return undefined;
|
|
230
|
+
const pin = /\S@([\d^~<>=*xXv][^"]*)"?$/u.exec(install)?.[1];
|
|
231
|
+
if (pin == null || pin === shown) return undefined;
|
|
232
|
+
return isValidSemver(pin)
|
|
233
|
+
? `This installs ${pin}, the version that matches this project's Core.`
|
|
234
|
+
: `This installs the newest release in ${pin}, the Core range this project declares.`;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The "Add it" blocks for a package the project does not have: the command
|
|
239
|
+
* that adds it, then what makes its items usable. A theme still needs
|
|
240
|
+
* `theme add` once the package is installed; anything else loads on the next
|
|
241
|
+
* command.
|
|
242
|
+
* @param {string} install the package-manager command
|
|
243
|
+
* @param {string[]} themes theme slugs the package or item adds
|
|
244
|
+
* @param {boolean} addsOther whether it adds anything besides themes
|
|
245
|
+
* @param {string} run how to invoke the CLI
|
|
246
|
+
* @param {string} [note] what the command installs, when the page shows
|
|
247
|
+
* another version
|
|
248
|
+
* @returns {import('../formatters/index.mjs').Block[]}
|
|
249
|
+
*/
|
|
250
|
+
function addBlocks(install, themes, addsOther, run, note) {
|
|
251
|
+
/** @type {import('../formatters/index.mjs').Block[]} */
|
|
252
|
+
const blocks = [section('Add it'), code(install)];
|
|
253
|
+
if (note) blocks.push(text(note));
|
|
254
|
+
if (themes.length > 0) {
|
|
255
|
+
blocks.push(
|
|
256
|
+
text(
|
|
257
|
+
themes.length === 1
|
|
258
|
+
? 'Then use its theme:'
|
|
259
|
+
: 'Then use one of its themes:',
|
|
260
|
+
),
|
|
261
|
+
code(themes.map(slug => `${run} theme add ${slug}`).join('\n')),
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
if (addsOther || themes.length === 0) {
|
|
265
|
+
blocks.push(
|
|
266
|
+
text(
|
|
267
|
+
'Astryx loads an integration on the next command once it is a dependency.',
|
|
268
|
+
),
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
return blocks;
|
|
272
|
+
}
|
|
273
|
+
|
|
203
274
|
/**
|
|
204
275
|
* @param {import('commander').Command} program
|
|
205
276
|
*/
|
|
@@ -222,8 +293,12 @@ export function registerDiscover(program) {
|
|
|
222
293
|
// Non-blocking nudge: if any configured integration has validation
|
|
223
294
|
// issues, print one compact line to stderr pointing at
|
|
224
295
|
// doctor integration validate. Best-effort; suppressed in --json mode.
|
|
296
|
+
// Whether a query gets its own answer here or the list (FR1); the
|
|
297
|
+
// list's hints must not suggest queries that only return it again.
|
|
298
|
+
let queries = true;
|
|
225
299
|
try {
|
|
226
300
|
const project = await Project.load(process.cwd());
|
|
301
|
+
queries = answersQueries(project);
|
|
227
302
|
await warnOnIntegrationIssues(project, {json});
|
|
228
303
|
} catch {
|
|
229
304
|
// Never let the nudge break the command.
|
|
@@ -263,71 +338,11 @@ export function registerDiscover(program) {
|
|
|
263
338
|
switch (result.type) {
|
|
264
339
|
case 'discover.list': {
|
|
265
340
|
const listOpts = itemListOptions(Boolean(options.components));
|
|
266
|
-
|
|
341
|
+
// Discover always has a source, the official list, so the list
|
|
342
|
+
// always has an Available side.
|
|
343
|
+
const available = result.meta?.available ?? [];
|
|
267
344
|
const sources = result.meta?.sources ?? [];
|
|
268
345
|
|
|
269
|
-
// No discover source: the list of what this project has, as always.
|
|
270
|
-
if (available === undefined) {
|
|
271
|
-
if (result.data.length === 0) {
|
|
272
|
-
if (options.available) {
|
|
273
|
-
// The user specifically asked for available packages but
|
|
274
|
-
// there is no source to answer from. Say so honestly.
|
|
275
|
-
emit(
|
|
276
|
-
text('No discover source is configured.'),
|
|
277
|
-
text(
|
|
278
|
-
[
|
|
279
|
-
'Available integrations are listed by discover sources.',
|
|
280
|
-
'A project can set one in astryx.config.mjs, and installed',
|
|
281
|
-
'integrations can provide one.',
|
|
282
|
-
].join(' '),
|
|
283
|
-
),
|
|
284
|
-
text(
|
|
285
|
-
[
|
|
286
|
-
`Find Astryx packages on npm: npm search @astryxdesign`,
|
|
287
|
-
`Learn more: ${run} docs cli/integrations`,
|
|
288
|
-
].join('\n'),
|
|
289
|
-
),
|
|
290
|
-
);
|
|
291
|
-
} else if (result.meta && result.meta.configured === false) {
|
|
292
|
-
emit(
|
|
293
|
-
text('No integrations configured.'),
|
|
294
|
-
text('Add integration package names to astryx.config.mjs:'),
|
|
295
|
-
code(
|
|
296
|
-
"export default {\n integrations: ['@scope/your-integration'],\n};",
|
|
297
|
-
),
|
|
298
|
-
text(
|
|
299
|
-
[
|
|
300
|
-
`Find Astryx packages on npm: npm search @astryxdesign`,
|
|
301
|
-
`Learn more: ${run} docs cli/integrations`,
|
|
302
|
-
].join('\n'),
|
|
303
|
-
),
|
|
304
|
-
);
|
|
305
|
-
} else {
|
|
306
|
-
emit(
|
|
307
|
-
text(
|
|
308
|
-
'No external components found in configured integrations.',
|
|
309
|
-
),
|
|
310
|
-
text(
|
|
311
|
-
`Find more packages: ${run} discover --available (needs a discover source)`,
|
|
312
|
-
),
|
|
313
|
-
);
|
|
314
|
-
}
|
|
315
|
-
break;
|
|
316
|
-
}
|
|
317
|
-
emit(
|
|
318
|
-
records(result.data, listOpts),
|
|
319
|
-
text(
|
|
320
|
-
[
|
|
321
|
-
'Usage:',
|
|
322
|
-
` ${run} discover <package> Browse a package`,
|
|
323
|
-
` ${run} discover <package>/Component View component docs`,
|
|
324
|
-
` ${run} discover <search> Search all packages`,
|
|
325
|
-
].join('\n'),
|
|
326
|
-
),
|
|
327
|
-
);
|
|
328
|
-
break;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
346
|
const kind = options.type
|
|
332
347
|
? (KIND_PLURALS[options.type] ?? options.type)
|
|
333
348
|
: null;
|
|
@@ -341,7 +356,9 @@ export function registerDiscover(program) {
|
|
|
341
356
|
: text(
|
|
342
357
|
kind
|
|
343
358
|
? `None of this project's integrations add ${kind}.`
|
|
344
|
-
:
|
|
359
|
+
: result.meta?.configured
|
|
360
|
+
? 'No external components found in configured integrations.'
|
|
361
|
+
: 'None yet.',
|
|
345
362
|
),
|
|
346
363
|
);
|
|
347
364
|
}
|
|
@@ -360,16 +377,44 @@ export function registerDiscover(program) {
|
|
|
360
377
|
);
|
|
361
378
|
}
|
|
362
379
|
blocks.push(...sourceNotes(sources));
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
380
|
+
if (!queries) {
|
|
381
|
+
// This project loads no integration and has no discover source
|
|
382
|
+
// of its own, so every query returns this list. Point at the
|
|
383
|
+
// add commands above instead of at queries.
|
|
384
|
+
if (query?.trim()) {
|
|
385
|
+
blocks.push(
|
|
386
|
+
text(
|
|
387
|
+
`This project loads no integration and has no discover source of its own, so discover lists everything instead of answering "${query}".`,
|
|
388
|
+
),
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
const themes = available.flatMap(entry =>
|
|
392
|
+
Array.isArray(entry.themes) ? entry.themes : [],
|
|
393
|
+
);
|
|
394
|
+
blocks.push(
|
|
395
|
+
text(
|
|
396
|
+
[
|
|
397
|
+
'To add a package, run its install command.',
|
|
398
|
+
...(themes.length > 0
|
|
399
|
+
? [
|
|
400
|
+
`Then use a theme it adds: ${run} theme add <theme>, for example ${run} theme add ${themes[0]}`,
|
|
401
|
+
]
|
|
402
|
+
: []),
|
|
403
|
+
].join('\n'),
|
|
404
|
+
),
|
|
405
|
+
);
|
|
406
|
+
} else {
|
|
407
|
+
blocks.push(
|
|
408
|
+
text(
|
|
409
|
+
[
|
|
410
|
+
'Usage:',
|
|
411
|
+
` ${run} discover <package> Browse a package and its versions`,
|
|
412
|
+
` ${run} discover <package>/<item> View one item`,
|
|
413
|
+
` ${run} discover <search> Search every item and package`,
|
|
414
|
+
].join('\n'),
|
|
415
|
+
),
|
|
416
|
+
);
|
|
417
|
+
}
|
|
373
418
|
emit(...blocks);
|
|
374
419
|
break;
|
|
375
420
|
}
|
|
@@ -378,7 +423,7 @@ export function registerDiscover(program) {
|
|
|
378
423
|
const d = result.data;
|
|
379
424
|
/** @type {import('../formatters/index.mjs').Block[]} */
|
|
380
425
|
const blocks = [record(d, {omit: ['versions', 'install']})];
|
|
381
|
-
if (d.versions) {
|
|
426
|
+
if (d.versions && d.versions.length > 0) {
|
|
382
427
|
const shown = d.version;
|
|
383
428
|
const lines = versionLines(d.versions, {
|
|
384
429
|
shown,
|
|
@@ -387,12 +432,12 @@ export function registerDiscover(program) {
|
|
|
387
432
|
: undefined,
|
|
388
433
|
latest: d.latest,
|
|
389
434
|
});
|
|
390
|
-
|
|
435
|
+
// The shown version is listed even when it is a prerelease.
|
|
436
|
+
const prereleases = d.versions.filter(
|
|
437
|
+
v => v.prerelease && v.version !== shown,
|
|
438
|
+
).length;
|
|
391
439
|
blocks.push(
|
|
392
|
-
section(
|
|
393
|
-
'Versions',
|
|
394
|
-
`${d.versions.length} published, newest first`,
|
|
395
|
-
),
|
|
440
|
+
section('Versions', `${d.versions.length} known, newest first`),
|
|
396
441
|
);
|
|
397
442
|
if (lines.length > 0) blocks.push(list(lines));
|
|
398
443
|
if (prereleases > 0) {
|
|
@@ -405,10 +450,16 @@ export function registerDiscover(program) {
|
|
|
405
450
|
}
|
|
406
451
|
if (d.install) {
|
|
407
452
|
blocks.push(
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
453
|
+
...addBlocks(
|
|
454
|
+
d.install,
|
|
455
|
+
d.themes ?? [],
|
|
456
|
+
addsMoreThanThemes(
|
|
457
|
+
/** @type {Record<string, unknown>} */ (
|
|
458
|
+
/** @type {unknown} */ (d)
|
|
459
|
+
),
|
|
460
|
+
),
|
|
461
|
+
run,
|
|
462
|
+
pinNote(d.install, d.version, d.source),
|
|
412
463
|
),
|
|
413
464
|
);
|
|
414
465
|
} else if (d.installedAs) {
|
|
@@ -420,7 +471,7 @@ export function registerDiscover(program) {
|
|
|
420
471
|
}
|
|
421
472
|
blocks.push(
|
|
422
473
|
text(
|
|
423
|
-
d.installed
|
|
474
|
+
d.installed && d.components.length > 0
|
|
424
475
|
? `Usage: ${run} discover ${d.name}/<ComponentName>`
|
|
425
476
|
: `See one item: ${run} discover ${d.name}/<item>`,
|
|
426
477
|
),
|
|
@@ -446,13 +497,13 @@ export function registerDiscover(program) {
|
|
|
446
497
|
emit(
|
|
447
498
|
record(d, {omit: ['install']}),
|
|
448
499
|
...(d.install
|
|
449
|
-
?
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
),
|
|
455
|
-
|
|
500
|
+
? addBlocks(
|
|
501
|
+
d.install,
|
|
502
|
+
d.kind === 'theme' ? [d.name] : [],
|
|
503
|
+
d.kind !== 'theme',
|
|
504
|
+
run,
|
|
505
|
+
pinNote(d.install, d.version, d.source),
|
|
506
|
+
)
|
|
456
507
|
: []),
|
|
457
508
|
text(`Its package: ${run} discover ${d.package}`),
|
|
458
509
|
);
|