@astryxdesign/cli 0.7.2-canary.ba80461 → 0.7.2-canary.bd72a5f
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 +74 -73
- package/api/build/help/help.mjs +1 -1
- package/api/component/_adapter.d.mts +72 -1
- package/api/component/_adapter.mjs +209 -7
- package/api/component/component.mjs +82 -15
- package/api/component/doc-links.test.mjs +386 -0
- package/api/component/integration-export-name.test.mjs +644 -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 +74 -0
- package/api/docs/_adapter.mjs +550 -14
- package/api/docs/integration-tree.test.mjs +22 -0
- package/api/docs/integrationDocs.test.mjs +124 -0
- package/api/docs/list/list.mjs +12 -2
- package/api/doctor/doctor.mjs +27 -3
- package/api/doctor/doctor.test.mjs +43 -0
- package/api/doctor/theme-checks.mjs +1 -1
- package/api/doctor/theme-checks.test.mjs +136 -0
- package/api/gap-report/gap-report.d.mts +3 -0
- package/api/gap-report/gap-report.doc.mjs +11 -3
- package/api/gap-report/gap-report.mjs +219 -52
- package/api/gap-report/gap-report.test.mjs +233 -0
- package/api/gap-report/gap-report.type.d.mts +41 -0
- package/api/gap-report/gap-report.type.mjs +18 -0
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/init/run/run.mjs +2 -2
- package/api/integration/_adapter.d.mts +45 -0
- package/api/integration/_adapter.mjs +112 -0
- package/api/integration/add-contribution.component-names.test.mjs +66 -0
- package/api/integration/add-contribution.mjs +8 -4
- package/api/integration/add-contribution.test.mjs +4 -2
- package/api/integration/authoring-checks.mjs +108 -4
- package/api/integration/authoring-checks.test.mjs +808 -0
- package/api/integration/authoring-checks.type.d.mts +143 -0
- package/api/integration/authoring-checks.type.mjs +74 -2
- package/api/integration/check/check.d.mts +96 -0
- package/api/integration/check/check.mjs +357 -0
- package/api/integration/check/check.test.mjs +489 -0
- package/api/integration/integration-check.type.d.mts +118 -0
- package/api/integration/integration-check.type.mjs +84 -0
- package/api/integration/integrationCheck.doc.d.mts +10 -0
- package/api/integration/integrationCheck.doc.mjs +73 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +45 -6
- package/api/integration/integrationDocConflicts.doc.mjs +22 -5
- package/api/integration/pack-check.mjs +347 -104
- package/api/integration/pack-check.test.mjs +726 -0
- package/api/integration/validate-integration-fixes.test.mjs +67 -0
- package/api/integration/validate-integration.mjs +36 -3
- package/api/integration/validate-integration.test.mjs +88 -8
- package/api/integration/validate-integration.type.d.mts +8 -0
- package/api/integration/validate-integration.type.mjs +12 -1
- package/api/integration/validateIntegration.doc.mjs +19 -3
- package/api/search/search.d.mts +81 -12
- package/api/search/search.domain-priority.test.mjs +108 -18
- package/api/search/search.integration-check.test.mjs +24 -0
- package/api/search/search.mjs +603 -51
- package/api/search/search.test.mjs +139 -0
- package/api/swizzle/copy/copy.mjs +28 -14
- package/api/theme/build/build.family.test.mjs +54 -6
- package/api/theme/build/build.mjs +114 -17
- package/api/theme/themeBuild.doc.mjs +4 -4
- package/api/upgrade/_adapter.d.mts +40 -2
- package/api/upgrade/_adapter.mjs +117 -4
- package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
- package/api/upgrade/run/run.mjs +30 -1
- package/api/upgrade/status/status.d.mts +21 -5
- package/api/upgrade/status/status.mjs +45 -8
- package/api/upgrade/upgrade.doc.mjs +5 -3
- package/api/upgrade/upgrade.type.d.mts +23 -0
- package/api/upgrade/upgrade.type.mjs +16 -1
- package/assets/codemods/runner.mjs +7 -1
- package/assets/discover/official-packages.json +367 -0
- package/assets/docs/README.md +10 -0
- package/assets/docs/author-a-theme.doc.mjs +3 -3
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +2 -2
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/add-a-component.doc.mjs +11 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +11 -8
- package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
- package/assets/docs/tree/block-template.doc.mjs +8 -20
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/check-the-props.doc.mjs +201 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +65 -7
- package/assets/docs/tree/checks.doc.mjs +26 -18
- package/assets/docs/tree/codemods.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +8 -6
- package/assets/docs/tree/component-imports.doc.mjs +10 -2
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +30 -21
- package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
- package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
- package/assets/docs/tree/docs.doc.mjs +3 -3
- package/assets/docs/tree/document-the-template.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +3 -3
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
- package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
- package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
- package/assets/docs/tree/integrations.doc.mjs +8 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +2 -3
- package/assets/docs/tree/layout.doc.mjs +6 -6
- package/assets/docs/tree/links.doc.mjs +6 -5
- package/assets/docs/tree/migration-setup.doc.mjs +3 -2
- package/assets/docs/tree/migration-verification.doc.mjs +0 -1
- package/assets/docs/tree/migration.doc.mjs +0 -1
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +4 -8
- package/assets/docs/tree/publishing.doc.mjs +4 -4
- package/assets/docs/tree/quick-start.doc.mjs +38 -22
- package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
- package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
- package/assets/docs/tree/sections-and-placement.doc.mjs +6 -8
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
- package/assets/docs/tree/single-component.doc.mjs +15 -6
- package/assets/docs/tree/start-a-template.doc.mjs +3 -3
- package/assets/docs/tree/subcomponent.doc.mjs +6 -6
- package/assets/docs/tree/template-assets.doc.mjs +2 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +5 -16
- package/assets/docs/tree/template-fonts.doc.mjs +1 -1
- package/assets/docs/tree/template-icons.doc.mjs +1 -1
- package/assets/docs/tree/template-images-media.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +2 -2
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
- package/assets/docs/tree/troubleshooting.doc.mjs +16 -8
- package/assets/docs/tree/type-scale.doc.mjs +3 -3
- package/assets/docs/tree/upgrading.doc.mjs +4 -4
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +7 -6
- package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/theme.template.ts +1 -1
- package/authoring/codemod/codemod.doc.mjs +7 -3
- package/authoring/config/config.doc.mjs +9 -6
- package/authoring/config/type.ts +4 -2
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
- package/authoring/doctypes/command/command.doc.mjs +14 -12
- package/authoring/doctypes/component/component.doc.mjs +30 -27
- package/authoring/doctypes/component/type.ts +21 -8
- package/authoring/doctypes/enum/enum.doc.mjs +7 -4
- package/authoring/doctypes/function/function.doc.mjs +9 -8
- package/authoring/doctypes/hook/hook.doc.mjs +5 -4
- package/authoring/doctypes/hook/type.ts +4 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
- package/authoring/doctypes/reference/reference.doc.mjs +11 -10
- package/authoring/doctypes/schema/schema.doc.mjs +9 -9
- package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
- package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
- package/authoring/doctypes/template/parse.d.mts +6 -2
- package/authoring/doctypes/template/parse.mjs +3 -1
- package/authoring/doctypes/template/template.doc.mjs +3 -3
- package/authoring/doctypes/template/type.ts +22 -0
- package/authoring/doctypes/theme/theme.doc.mjs +2 -2
- package/authoring/gap-report/gap-report.doc.mjs +2 -2
- package/authoring/identity/identity.doc.mjs +3 -3
- package/authoring/index.d.ts +1 -0
- package/authoring/integration/integration.doc.mjs +12 -4
- package/authoring/integration/parse.test.mjs +10 -0
- package/authoring/integration/schema.d.mts +2 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +4 -0
- package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
- package/clients/cli/commands/build-theme.mjs +1 -1
- package/clients/cli/commands/build-theme.path-safety.test.mjs +155 -21
- package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
- 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 +18 -4
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +19 -5
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
- package/clients/cli/commands/doctor-integration.test.mjs +884 -0
- package/clients/cli/commands/doctor.mjs +281 -5
- package/clients/cli/commands/gap-report.doc.mjs +14 -2
- package/clients/cli/commands/gap-report.mjs +24 -2
- package/clients/cli/commands/gap-report.test.mjs +79 -0
- package/clients/cli/commands/integration-authoring.test.mjs +46 -0
- package/clients/cli/commands/integration-check.doc.mjs +85 -0
- package/clients/cli/commands/integration-check.test.mjs +411 -0
- package/clients/cli/commands/integration.doc.mjs +6 -2
- package/clients/cli/commands/integration.mjs +116 -5
- package/clients/cli/commands/json-contract.test.mjs +5 -1
- package/clients/cli/commands/setup-nudge.test.mjs +79 -1
- package/clients/cli/commands/swizzle.mjs +5 -3
- package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
- package/clients/cli/commands/text-json-parity.test.mjs +5 -0
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/upgrade.doc.mjs +14 -0
- package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
- package/clients/cli/index.mjs +30 -5
- package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
- package/foundation/agent-docs/agent-doc-state.mjs +38 -0
- package/foundation/agent-docs/agent-docs.d.mts +2 -1
- package/foundation/agent-docs/agent-docs.mjs +8 -6
- package/foundation/config/project.mjs +82 -0
- package/foundation/discovery/authoring-self-docs.mjs +2 -1
- package/foundation/discovery/component-discovery.d.mts +178 -10
- package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
- package/foundation/discovery/component-discovery.mjs +659 -62
- package/foundation/discovery/component-replacement.mjs +18 -0
- package/foundation/discovery/component-replacement.test.mjs +40 -0
- package/foundation/discovery/copied-passages.d.mts +216 -0
- package/foundation/discovery/copied-passages.mjs +720 -0
- package/foundation/discovery/copied-passages.test.mjs +124 -0
- package/foundation/discovery/doc-consistency.d.mts +34 -0
- package/foundation/discovery/doc-consistency.mjs +513 -0
- package/foundation/discovery/doc-consistency.test.mjs +347 -0
- package/foundation/discovery/doc-fluff.d.mts +112 -0
- package/foundation/discovery/doc-fluff.mjs +328 -0
- package/foundation/discovery/doc-fluff.test.mjs +142 -0
- package/foundation/discovery/doc-types.d.mts +157 -0
- package/foundation/discovery/doc-types.mjs +1231 -0
- package/foundation/discovery/doc-types.test.mjs +744 -0
- package/foundation/discovery/docs-discovery.d.mts +88 -0
- package/foundation/discovery/docs-discovery.mjs +83 -2
- package/foundation/discovery/integration-doc-files.d.mts +22 -0
- package/foundation/discovery/integration-doc-files.mjs +231 -0
- package/foundation/discovery/integration-doc-files.test.mjs +246 -0
- package/foundation/discovery/module-exports.d.mts +27 -0
- package/foundation/discovery/module-exports.mjs +356 -31
- package/foundation/discovery/module-exports.test.mjs +172 -0
- package/foundation/discovery/package-tsconfig.d.mts +14 -0
- package/foundation/discovery/package-tsconfig.mjs +228 -0
- package/foundation/discovery/package-tsconfig.test.mjs +210 -0
- package/foundation/discovery/project-typescript.d.mts +32 -0
- package/foundation/discovery/project-typescript.mjs +89 -0
- package/foundation/discovery/prop-drift.d.mts +297 -0
- package/foundation/discovery/prop-drift.mjs +2428 -0
- package/foundation/discovery/prop-drift.test.mjs +2337 -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/discovery/type-match.d.mts +53 -0
- package/foundation/discovery/type-match.mjs +660 -0
- package/foundation/discovery/type-match.test.mjs +169 -0
- package/foundation/discovery/type-text.d.mts +68 -0
- package/foundation/discovery/type-text.mjs +658 -0
- package/foundation/discovery/type-text.test.mjs +196 -0
- package/foundation/discovery/unresolved-references.d.mts +62 -0
- package/foundation/discovery/unresolved-references.mjs +790 -0
- package/foundation/discovery/unresolved-references.test.mjs +567 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +26 -0
- package/foundation/doc-compiler/links.d.mts +41 -5
- package/foundation/doc-compiler/links.mjs +167 -28
- package/foundation/doc-compiler/links.test.mjs +97 -4
- package/foundation/doc-compiler/tree.mjs +30 -1
- package/foundation/doc-compiler/tree.test.mjs +7 -0
- package/foundation/env/package-manager.d.mts +32 -0
- package/foundation/env/package-manager.mjs +47 -0
- package/foundation/env/package-manager.test.mjs +194 -7
- package/foundation/fs/module-loader.d.mts +2 -1
- package/foundation/fs/module-loader.mjs +60 -4
- package/foundation/fs/module-loader.test.mjs +194 -0
- package/foundation/integrations/contribution-inventory.d.mts +11 -0
- package/foundation/integrations/contribution-inventory.mjs +56 -3
- package/foundation/integrations/issue.ts +6 -0
- package/foundation/integrations/validate-contributions.mjs +30 -1
- package/foundation/response/response-types.doc.mjs +15 -9
- package/package.json +11 -11
- package/scripts/postinstall.mjs +3 -3
|
@@ -9,9 +9,12 @@
|
|
|
9
9
|
* - Multi-file write is atomic: if one file fails, none are left behind.
|
|
10
10
|
* - An `--out` escape, or an output directory that cannot be created, fails
|
|
11
11
|
* with a registered error code.
|
|
12
|
-
* - Every output stays inside the working directory: an
|
|
13
|
-
* path or a theme file outside it fails before anything
|
|
14
|
-
* absolute paths inside it build, also through a
|
|
12
|
+
* - Every output a build writes stays inside the working directory: an
|
|
13
|
+
* absolute `--out` path or a theme file outside it fails before anything
|
|
14
|
+
* is written, while absolute paths inside it build, also through a
|
|
15
|
+
* symlinked spelling. `--check` writes nothing, so it compares those
|
|
16
|
+
* outside outputs read-only, and a stale report for them ends with a
|
|
17
|
+
* remedy that works: the directory to build and check from.
|
|
15
18
|
*
|
|
16
19
|
* Runs the CLI in-process (shared runCli harness) against a tiny synthetic theme file.
|
|
17
20
|
*/
|
|
@@ -25,6 +28,7 @@ import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
|
25
28
|
import {themeBuild} from '../../../api/theme/build/build.mjs';
|
|
26
29
|
import {AstryxError} from '../../../api/error.mjs';
|
|
27
30
|
import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
|
|
31
|
+
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
28
32
|
|
|
29
33
|
function writeTheme(dir, name) {
|
|
30
34
|
fs.mkdirSync(dir, {recursive: true});
|
|
@@ -62,7 +66,9 @@ describe('theme build path safety', () => {
|
|
|
62
66
|
);
|
|
63
67
|
|
|
64
68
|
expect(result.code).not.toBe(0);
|
|
65
|
-
expect(result.stderr + result.stdout).toMatch(
|
|
69
|
+
expect(result.stderr + result.stdout).toMatch(
|
|
70
|
+
/path separator|invalid theme name/i,
|
|
71
|
+
);
|
|
66
72
|
|
|
67
73
|
// The traversal target must not exist.
|
|
68
74
|
expect(fs.existsSync(path.join(tmpDir, 'escaped.js'))).toBe(false);
|
|
@@ -95,7 +101,10 @@ describe('theme build path safety', () => {
|
|
|
95
101
|
|
|
96
102
|
const themeFile = writeTheme(themesDir, '../leak');
|
|
97
103
|
|
|
98
|
-
await runCli(
|
|
104
|
+
await runCli(
|
|
105
|
+
['theme', 'build', path.relative(project, themeFile)],
|
|
106
|
+
project,
|
|
107
|
+
);
|
|
99
108
|
|
|
100
109
|
// Neither the CSS nor any sibling JS should have been written.
|
|
101
110
|
const entries = fs.readdirSync(themesDir).sort();
|
|
@@ -117,41 +126,88 @@ describe('theme build output-path failures carry registered codes', () => {
|
|
|
117
126
|
return {result, envelope: JSON.parse(result.stdout)};
|
|
118
127
|
}
|
|
119
128
|
|
|
120
|
-
it('reports
|
|
129
|
+
it('reports a relative --out path outside the project as ERR_PATH_TRAVERSAL, with --check too', async () => {
|
|
121
130
|
const project = path.join(tmpDir, 'project');
|
|
122
131
|
const themeFile = writeTheme(path.join(project, 'themes'), 'ocean');
|
|
123
132
|
|
|
133
|
+
for (const extra of [[], ['--check']]) {
|
|
134
|
+
const {result, envelope} = await buildJson(
|
|
135
|
+
[
|
|
136
|
+
path.relative(project, themeFile),
|
|
137
|
+
'--out',
|
|
138
|
+
'../escaped.css',
|
|
139
|
+
...extra,
|
|
140
|
+
],
|
|
141
|
+
project,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
expect(result.code).toBe(1);
|
|
145
|
+
expect(envelope.code).toBe(ERROR_CODES.ERR_PATH_TRAVERSAL);
|
|
146
|
+
expect(registered.has(envelope.code)).toBe(true);
|
|
147
|
+
}
|
|
148
|
+
expect(fs.existsSync(path.join(tmpDir, 'escaped.css'))).toBe(false);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('reports an absolute --out path outside the project as ERR_PATH_TRAVERSAL', async () => {
|
|
152
|
+
const project = path.join(tmpDir, 'project');
|
|
153
|
+
const outside = path.join(tmpDir, 'outside');
|
|
154
|
+
fs.mkdirSync(outside, {recursive: true});
|
|
155
|
+
const themeFile = writeTheme(path.join(project, 'themes'), 'ocean');
|
|
156
|
+
const out = path.join(outside, 'ocean.css');
|
|
157
|
+
|
|
124
158
|
const {result, envelope} = await buildJson(
|
|
125
|
-
[path.relative(project, themeFile), '--out',
|
|
159
|
+
[path.relative(project, themeFile), '--out', out],
|
|
126
160
|
project,
|
|
127
161
|
);
|
|
128
162
|
|
|
129
163
|
expect(result.code).toBe(1);
|
|
130
164
|
expect(envelope.code).toBe(ERROR_CODES.ERR_PATH_TRAVERSAL);
|
|
131
|
-
expect(
|
|
132
|
-
expect(fs.existsSync(path.join(tmpDir, 'escaped.css'))).toBe(false);
|
|
165
|
+
expect(fs.readdirSync(outside)).toEqual([]);
|
|
133
166
|
});
|
|
134
167
|
|
|
135
|
-
it('
|
|
168
|
+
it('checks an absolute --out path outside the project read-only', async () => {
|
|
136
169
|
const project = path.join(tmpDir, 'project');
|
|
137
170
|
const outside = path.join(tmpDir, 'outside');
|
|
138
171
|
fs.mkdirSync(outside, {recursive: true});
|
|
139
|
-
const themeFile =
|
|
172
|
+
const themeFile = path.relative(
|
|
173
|
+
project,
|
|
174
|
+
writeTheme(path.join(project, 'themes'), 'ocean'),
|
|
175
|
+
);
|
|
140
176
|
const out = path.join(outside, 'ocean.css');
|
|
141
177
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
178
|
+
const missing = await buildJson(
|
|
179
|
+
[themeFile, '--out', out, '--check'],
|
|
180
|
+
project,
|
|
181
|
+
);
|
|
182
|
+
expect(missing.result.code).toBe(1);
|
|
183
|
+
expect(missing.envelope.type).toBe('theme.build.check');
|
|
184
|
+
expect(missing.envelope.data.upToDate).toBe(false);
|
|
185
|
+
expect(fs.readdirSync(outside)).toEqual([]);
|
|
147
186
|
|
|
148
|
-
|
|
149
|
-
|
|
187
|
+
// Outputs built inside the project compare equal once copied outside:
|
|
188
|
+
// only the volatile Command line, which --check ignores, names --out.
|
|
189
|
+
const dist = path.join(project, 'dist');
|
|
190
|
+
const built = await buildJson(
|
|
191
|
+
[themeFile, '--out', path.join(dist, 'ocean.css')],
|
|
192
|
+
project,
|
|
193
|
+
);
|
|
194
|
+
expect(built.result.code).toBe(0);
|
|
195
|
+
for (const file of fs.readdirSync(dist)) {
|
|
196
|
+
fs.copyFileSync(path.join(dist, file), path.join(outside, file));
|
|
150
197
|
}
|
|
151
|
-
|
|
198
|
+
const copied = fs.readdirSync(outside).sort();
|
|
199
|
+
|
|
200
|
+
const current = await buildJson(
|
|
201
|
+
[themeFile, '--out', out, '--check'],
|
|
202
|
+
project,
|
|
203
|
+
);
|
|
204
|
+
expect(current.result.code).toBe(0);
|
|
205
|
+
expect(current.envelope.type).toBe('theme.build.check');
|
|
206
|
+
expect(current.envelope.data.upToDate).toBe(true);
|
|
207
|
+
expect(fs.readdirSync(outside).sort()).toEqual(copied);
|
|
152
208
|
});
|
|
153
209
|
|
|
154
|
-
it('reports a theme file outside the project as ERR_PATH_TRAVERSAL, because its outputs go beside it', async () => {
|
|
210
|
+
it('reports a theme file outside the project as ERR_PATH_TRAVERSAL, because its outputs go beside it; --check only compares them', async () => {
|
|
155
211
|
const project = path.join(tmpDir, 'project');
|
|
156
212
|
fs.mkdirSync(project, {recursive: true});
|
|
157
213
|
const shared = path.join(tmpDir, 'shared');
|
|
@@ -162,10 +218,82 @@ describe('theme build output-path failures carry registered codes', () => {
|
|
|
162
218
|
|
|
163
219
|
expect(result.code).toBe(1);
|
|
164
220
|
expect(envelope.code).toBe(ERROR_CODES.ERR_PATH_TRAVERSAL);
|
|
221
|
+
|
|
222
|
+
const checked = await buildJson([file, '--check'], project);
|
|
223
|
+
expect(checked.result.code).toBe(1);
|
|
224
|
+
expect(checked.envelope.type).toBe('theme.build.check');
|
|
225
|
+
expect(checked.envelope.data.upToDate).toBe(false);
|
|
165
226
|
}
|
|
166
227
|
expect(fs.readdirSync(shared)).toEqual(['theme.mjs']);
|
|
167
228
|
});
|
|
168
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Read the remedy that ends a stale report for outputs outside cwd: the
|
|
232
|
+
* directory to run from, then the build and check arguments after `theme
|
|
233
|
+
* build`. Each command starts with the install-aware invocation for it.
|
|
234
|
+
* @param {string} stderr
|
|
235
|
+
*/
|
|
236
|
+
function readRemedy(stderr) {
|
|
237
|
+
const lines = stderr.split('\n').map(line => line.trim());
|
|
238
|
+
const cd = lines.find(line => line.startsWith('cd '));
|
|
239
|
+
expect(cd).toBeDefined();
|
|
240
|
+
const dir = /** @type {string} */ (cd).slice('cd '.length);
|
|
241
|
+
const stem = `${getCliInvocation(dir)} theme build `;
|
|
242
|
+
const commands = lines.filter(line => line.startsWith(stem));
|
|
243
|
+
expect(commands).toHaveLength(2);
|
|
244
|
+
const [build, check] = commands.map(line =>
|
|
245
|
+
line.slice(stem.length).split(' '),
|
|
246
|
+
);
|
|
247
|
+
expect(check).toEqual([...build, '--check']);
|
|
248
|
+
return {dir, build, check};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
it('ends a stale report for outputs outside cwd with a remedy that works, and keeps the report for outputs inside it', async () => {
|
|
252
|
+
const project = path.join(tmpDir, 'project');
|
|
253
|
+
const inside = path.relative(
|
|
254
|
+
project,
|
|
255
|
+
writeTheme(path.join(project, 'themes'), 'ocean'),
|
|
256
|
+
);
|
|
257
|
+
const shared = writeTheme(path.join(tmpDir, 'shared'), 'ocean');
|
|
258
|
+
const outside = path.join(tmpDir, 'outside');
|
|
259
|
+
|
|
260
|
+
for (const args of [
|
|
261
|
+
[path.relative(project, shared)],
|
|
262
|
+
[inside, '--out', path.join(outside, 'ocean.css')],
|
|
263
|
+
]) {
|
|
264
|
+
const stale = await runCli(
|
|
265
|
+
['theme', 'build', ...args, '--check'],
|
|
266
|
+
project,
|
|
267
|
+
);
|
|
268
|
+
expect(stale.code).toBe(1);
|
|
269
|
+
// The old remedy ran the build from cwd, which refuses these outputs.
|
|
270
|
+
expect(stale.stderr).not.toContain('Rebuild with:');
|
|
271
|
+
expect(stale.stderr).not.toContain(`theme build ${args.join(' ')}`);
|
|
272
|
+
|
|
273
|
+
// Following the remedy builds, and the check from there passes.
|
|
274
|
+
const remedy = readRemedy(stale.stderr);
|
|
275
|
+
const built = await runCli(
|
|
276
|
+
['theme', 'build', ...remedy.build],
|
|
277
|
+
remedy.dir,
|
|
278
|
+
);
|
|
279
|
+
expect(built.code).toBe(0);
|
|
280
|
+
const checked = await runCli(
|
|
281
|
+
['--json', 'theme', 'build', ...remedy.check],
|
|
282
|
+
remedy.dir,
|
|
283
|
+
);
|
|
284
|
+
expect(checked.code).toBe(0);
|
|
285
|
+
expect(JSON.parse(checked.stdout).data.upToDate).toBe(true);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Outputs inside cwd keep the plain rebuild line.
|
|
289
|
+
const local = await runCli(['theme', 'build', inside, '--check'], project);
|
|
290
|
+
expect(local.code).toBe(1);
|
|
291
|
+
expect(local.stderr).toContain(
|
|
292
|
+
`Rebuild with: astryx theme build ${inside}`,
|
|
293
|
+
);
|
|
294
|
+
expect(local.stderr).not.toMatch(/^\s*cd /m);
|
|
295
|
+
});
|
|
296
|
+
|
|
169
297
|
it('builds absolute paths inside the project, also when they reach it through a symlink', async () => {
|
|
170
298
|
const project = path.join(tmpDir, 'project');
|
|
171
299
|
const themeFile = writeTheme(path.join(project, 'themes'), 'ocean');
|
|
@@ -243,7 +371,7 @@ describe('theme build output-path failures carry registered codes', () => {
|
|
|
243
371
|
});
|
|
244
372
|
});
|
|
245
373
|
|
|
246
|
-
it('themeBuild() rejects an output outside cwd
|
|
374
|
+
it('themeBuild() rejects an output outside cwd, an absolute out path or the default beside a theme file outside cwd, and checks it read-only', async () => {
|
|
247
375
|
const project = path.join(tmpDir, 'project');
|
|
248
376
|
const inside = writeTheme(path.join(project, 'themes'), 'ocean');
|
|
249
377
|
const shared = path.join(tmpDir, 'shared');
|
|
@@ -257,6 +385,12 @@ describe('theme build output-path failures carry registered codes', () => {
|
|
|
257
385
|
await expect(
|
|
258
386
|
themeBuild(file, options, {cwd: project}),
|
|
259
387
|
).rejects.toMatchObject({code: ERROR_CODES.ERR_PATH_TRAVERSAL});
|
|
388
|
+
await expect(
|
|
389
|
+
themeBuild(file, {...options, check: true}, {cwd: project}),
|
|
390
|
+
).resolves.toMatchObject({
|
|
391
|
+
type: 'theme.build.check',
|
|
392
|
+
data: {upToDate: false},
|
|
393
|
+
});
|
|
260
394
|
}
|
|
261
395
|
expect(fs.existsSync(outDir)).toBe(false);
|
|
262
396
|
expect(fs.readdirSync(shared)).toEqual(['theme.mjs']);
|
|
@@ -8,9 +8,16 @@
|
|
|
8
8
|
* transient fetch (path _npx or npm_command=exec), and once set up.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {describe, it, expect} from 'vitest';
|
|
11
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
12
|
+
import {spawnSync} from 'node:child_process';
|
|
13
|
+
import * as fs from 'node:fs';
|
|
14
|
+
import * as os from 'node:os';
|
|
15
|
+
import * as path from 'node:path';
|
|
16
|
+
import {fileURLToPath} from 'node:url';
|
|
12
17
|
import {shouldNudge} from '../../../scripts/postinstall.mjs';
|
|
13
18
|
|
|
19
|
+
const CLI = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../..');
|
|
20
|
+
|
|
14
21
|
const DEP = '/proj/node_modules/@astryxdesign/cli/scripts/postinstall.mjs'; // real dep install
|
|
15
22
|
const NPX = '/Users/x/.npm/_npx/a1b2/node_modules/@astryxdesign/cli/scripts/postinstall.mjs';
|
|
16
23
|
const REPO = '/repo/packages/cli/scripts/postinstall.mjs'; // monorepo/source
|
|
@@ -40,3 +47,44 @@ describe('cli postinstall — shouldNudge', () => {
|
|
|
40
47
|
expect(shouldNudge({})).toBe(false);
|
|
41
48
|
});
|
|
42
49
|
});
|
|
50
|
+
|
|
51
|
+
// Install time, end to end: the real script and the leaf it loads, installed
|
|
52
|
+
// under a monorepo's node_modules, run the way npm runs them for a package.
|
|
53
|
+
describe('cli postinstall — inside a monorepo package', () => {
|
|
54
|
+
let repo;
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
repo = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-cli-postinstall-'));
|
|
57
|
+
fs.mkdirSync(path.join(repo, '.git'));
|
|
58
|
+
fs.mkdirSync(path.join(repo, 'packages/app'), {recursive: true});
|
|
59
|
+
fs.writeFileSync(path.join(repo, 'packages/app/package.json'), '{"name":"app"}');
|
|
60
|
+
const installed = path.join(repo, 'node_modules/@astryxdesign/cli');
|
|
61
|
+
for (const rel of ['scripts/postinstall.mjs', 'foundation/agent-docs/agent-doc-state.mjs']) {
|
|
62
|
+
fs.mkdirSync(path.dirname(path.join(installed, rel)), {recursive: true});
|
|
63
|
+
fs.copyFileSync(path.join(CLI, rel), path.join(installed, rel));
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
afterEach(() => fs.rmSync(repo, {recursive: true, force: true}));
|
|
67
|
+
|
|
68
|
+
const install = () =>
|
|
69
|
+
spawnSync(
|
|
70
|
+
process.execPath,
|
|
71
|
+
[path.join(repo, 'node_modules/@astryxdesign/cli/scripts/postinstall.mjs')],
|
|
72
|
+
{
|
|
73
|
+
env: {...process.env, INIT_CWD: path.join(repo, 'packages/app'), npm_command: 'install'},
|
|
74
|
+
encoding: 'utf8',
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
it('stays quiet when init ran at the repository root', () => {
|
|
79
|
+
fs.writeFileSync(path.join(repo, 'AGENTS.md'), '<!-- ASTRYX:START -->\n');
|
|
80
|
+
const r = install();
|
|
81
|
+
expect(r.status).toBe(0);
|
|
82
|
+
expect(r.stdout).toBe('');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('still nudges when no folder up to the repository root ran init', () => {
|
|
86
|
+
const r = install();
|
|
87
|
+
expect(r.status).toBe(0);
|
|
88
|
+
expect(r.stdout).toMatch(/finish setup and install the Astryx agent prompt/);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -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
|
);
|