@astryxdesign/cli 0.6.4-canary.ed2e54e → 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 +66 -64
- 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 +10 -23
- 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/docs.test.mjs +0 -2
- package/api/doctor/doctor.d.mts +3 -8
- package/api/doctor/doctor.mjs +9 -90
- package/api/doctor/doctor.test.mjs +10 -122
- package/api/index.d.mts +2 -1
- package/api/index.mjs +4 -4
- package/api/integration/add-helpers.d.mts +2 -5
- package/api/integration/add-helpers.mjs +9 -36
- package/api/integration/pack-check.mjs +3 -28
- package/api/json/index.ts +1 -0
- 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.test.mjs +0 -18
- package/api/template/template-integration.test.mjs +65 -1
- 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/upgrade/run/run.mjs +4 -6
- 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/internationalization.doc.mjs +5 -7
- package/assets/docs/tree/integrations.doc.mjs +1 -20
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
- package/authoring/config/config.doc.mjs +1 -9
- 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/command/command.doc.mjs +1 -1
- package/authoring/doctypes/command/type.ts +1 -1
- package/authoring/index.d.mts +0 -1
- package/authoring/index.d.ts +0 -10
- package/authoring/index.mjs +0 -1
- 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 +6 -23
- 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.test.mjs +0 -29
- 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/text-json-parity.test.mjs +17 -0
- package/clients/cli/index.mjs +4 -0
- package/clients/cli/lib/exit-codes.test.mjs +8 -1
- 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 +8 -3
- package/clients/cli/lib/manifest.test.mjs +2 -5
- package/foundation/discovery/authoring-self-docs.mjs +0 -1
- package/foundation/discovery/template-adapter.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +12 -0
- package/foundation/doc-compiler/tree.test.mjs +1 -9
- 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/response-types.doc.mjs +21 -15
- package/foundation/response/response-types.doc.test.mjs +0 -23
- 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 -105
- 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/component-lookups.doc.mjs +0 -149
- 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/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
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* @file Programmatic API for the component command — DISPATCHER + BARREL.
|
|
5
5
|
*
|
|
6
6
|
* Returns the same typed envelope { type, data } that `astryx --json component`
|
|
7
|
-
* outputs. `component(name, opts)` parses
|
|
8
|
-
*
|
|
9
|
-
* (list · detail · detail.props/source/showcase/blocks)
|
|
10
|
-
* is a thin wrapper around this function.
|
|
7
|
+
* outputs. `component(name, opts)` parses the (name, options) pair, resolves the
|
|
8
|
+
* subject once via `_adapter`, and routes to the correct leaf
|
|
9
|
+
* (list · detail · detail.props/source/showcase/blocks), returning that leaf's
|
|
10
|
+
* envelope. The CLI command handler is a thin wrapper around this function.
|
|
11
11
|
*
|
|
12
12
|
* Every leaf is also re-exported for direct scripting use.
|
|
13
13
|
*/
|
|
@@ -26,8 +26,6 @@ import {
|
|
|
26
26
|
resolveUnscopedDoc,
|
|
27
27
|
loadComponentDoc,
|
|
28
28
|
scopeSubComponent,
|
|
29
|
-
ComponentAmbiguityError,
|
|
30
|
-
installedComponentPackageVersion,
|
|
31
29
|
} from './_adapter.mjs';
|
|
32
30
|
import {componentList} from './list/list.mjs';
|
|
33
31
|
import {componentDetail} from './detail/detail.mjs';
|
|
@@ -36,199 +34,13 @@ import {componentDetailSource} from './detail/source/source.mjs';
|
|
|
36
34
|
import {componentDetailShowcase} from './detail/showcase/showcase.mjs';
|
|
37
35
|
import {componentDetailBlocks} from './detail/blocks/blocks.mjs';
|
|
38
36
|
|
|
39
|
-
/** Maximum selectors accepted before any component resolution starts. */
|
|
40
|
-
export const COMPONENT_BATCH_SELECTOR_LIMIT = 100;
|
|
41
|
-
|
|
42
37
|
/** @type {ReadonlyArray<string>} */
|
|
43
38
|
const DETAIL_LEVELS = ['full', 'compact', 'brief'];
|
|
44
39
|
/** @type {ReadonlyArray<string>} */
|
|
45
40
|
const LANGS = ['en', 'zh', 'dense'];
|
|
46
|
-
/** @type {Set<string>} */
|
|
47
|
-
const NOT_FOUND_CODES = new Set([
|
|
48
|
-
ERROR_CODES.ERR_UNKNOWN_COMPONENT,
|
|
49
|
-
ERROR_CODES.ERR_UNKNOWN_PACKAGE,
|
|
50
|
-
ERROR_CODES.ERR_NOT_FOUND,
|
|
51
|
-
]);
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Discover-compatible package target grammar. Versions belong to the package
|
|
55
|
-
* head, never the item after the package slash.
|
|
56
|
-
* @param {string} selector
|
|
57
|
-
* @returns {{scoped: boolean, name: string, version?: string, item?: string}}
|
|
58
|
-
*/
|
|
59
|
-
function splitSelector(selector) {
|
|
60
|
-
const scoped = selector.startsWith('@');
|
|
61
|
-
const firstSlash = selector.indexOf('/');
|
|
62
|
-
let head = selector;
|
|
63
|
-
/** @type {string | undefined} */
|
|
64
|
-
let rest;
|
|
65
|
-
const split = scoped
|
|
66
|
-
? firstSlash < 0
|
|
67
|
-
? -1
|
|
68
|
-
: selector.indexOf('/', firstSlash + 1)
|
|
69
|
-
: firstSlash;
|
|
70
|
-
if (split > 0) {
|
|
71
|
-
head = selector.slice(0, split);
|
|
72
|
-
rest = selector.slice(split + 1) || undefined;
|
|
73
|
-
}
|
|
74
|
-
const at = head.indexOf('@', 1);
|
|
75
|
-
return {
|
|
76
|
-
scoped,
|
|
77
|
-
name: at > 0 ? head.slice(0, at) : head,
|
|
78
|
-
...(at > 0 && head.slice(at + 1) ? {version: head.slice(at + 1)} : {}),
|
|
79
|
-
...(rest ? {item: rest} : {}),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Resolve one component selector into the existing single-component API inputs.
|
|
85
|
-
* @param {unknown} value
|
|
86
|
-
* @param {string|undefined} packageScope
|
|
87
|
-
* @returns {{selector: string, name: string, package?: string, version?: string}}
|
|
88
|
-
*/
|
|
89
|
-
function parseComponentSelector(value, packageScope) {
|
|
90
|
-
if (typeof value !== 'string' || value.length === 0) {
|
|
91
|
-
throw new AstryxError(
|
|
92
|
-
`Invalid component selector "${String(value)}"`,
|
|
93
|
-
undefined,
|
|
94
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
const target = splitSelector(value);
|
|
98
|
-
const packageShaped =
|
|
99
|
-
target.scoped || target.item != null || target.version != null;
|
|
100
|
-
if (!packageShaped) {
|
|
101
|
-
return {selector: value, name: target.name, package: packageScope};
|
|
102
|
-
}
|
|
103
|
-
if (!target.item) {
|
|
104
|
-
throw new AstryxError(
|
|
105
|
-
`Component selector "${value}" names a package but no component`,
|
|
106
|
-
undefined,
|
|
107
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
if (packageScope && packageScope !== target.name) {
|
|
111
|
-
throw new AstryxError(
|
|
112
|
-
`Component selector "${value}" conflicts with --package "${packageScope}"`,
|
|
113
|
-
undefined,
|
|
114
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
selector: value,
|
|
119
|
-
name: target.item,
|
|
120
|
-
package: target.name,
|
|
121
|
-
...(target.version ? {version: target.version} : {}),
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* A version-qualified selector never falls through to another installed
|
|
127
|
-
* version. Its structured suggestion points at the command that can discover
|
|
128
|
-
* the requested package release.
|
|
129
|
-
* @param {{package?: string, version?: string}} target
|
|
130
|
-
* @param {string} coreDir
|
|
131
|
-
* @param {import('../../foundation/integrations/integrations.mjs').LoadedIntegration[]} loadedIntegrations
|
|
132
|
-
* @returns {void}
|
|
133
|
-
*/
|
|
134
|
-
function requireInstalledSelectorVersion(target, coreDir, loadedIntegrations) {
|
|
135
|
-
if (!target.version) return;
|
|
136
|
-
const packageName = /** @type {string} */ (target.package);
|
|
137
|
-
const installed = installedComponentPackageVersion(
|
|
138
|
-
coreDir,
|
|
139
|
-
loadedIntegrations,
|
|
140
|
-
packageName,
|
|
141
|
-
);
|
|
142
|
-
if (installed === target.version) return;
|
|
143
|
-
const exact = `${packageName}@${target.version}`;
|
|
144
|
-
throw new AstryxError(
|
|
145
|
-
`Package "${exact}" is not installed`,
|
|
146
|
-
[
|
|
147
|
-
{
|
|
148
|
-
name: `astryx discover ${exact}`,
|
|
149
|
-
reason: 'look up this package version',
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
ERROR_CODES.ERR_UNKNOWN_PACKAGE,
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Turn a single-lookup failure into one complete batch row.
|
|
158
|
-
* @param {string} selector
|
|
159
|
-
* @param {unknown} error
|
|
160
|
-
* @returns {import('./component.type.mjs').ComponentBatchResult}
|
|
161
|
-
*/
|
|
162
|
-
function batchFailure(selector, error) {
|
|
163
|
-
const err =
|
|
164
|
-
error instanceof AstryxError
|
|
165
|
-
? error
|
|
166
|
-
: new AstryxError(
|
|
167
|
-
error instanceof Error ? error.message : String(error),
|
|
168
|
-
undefined,
|
|
169
|
-
ERROR_CODES.ERR_UNKNOWN,
|
|
170
|
-
);
|
|
171
|
-
if (err instanceof ComponentAmbiguityError) {
|
|
172
|
-
return {
|
|
173
|
-
selector,
|
|
174
|
-
status: 'ambiguous',
|
|
175
|
-
code: err.code,
|
|
176
|
-
error: err.message,
|
|
177
|
-
candidates: err.candidates,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
return {
|
|
181
|
-
selector,
|
|
182
|
-
status: NOT_FOUND_CODES.has(err.code) ? 'not_found' : 'error',
|
|
183
|
-
code: err.code,
|
|
184
|
-
error: err.message,
|
|
185
|
-
...(err.suggestions ? {suggestions: err.suggestions} : {}),
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
41
|
|
|
189
42
|
/**
|
|
190
|
-
* @param {
|
|
191
|
-
* @param {object} options
|
|
192
|
-
* @param {string} options.cwd
|
|
193
|
-
* @param {string} [options.package]
|
|
194
|
-
* @param {boolean} [options.props]
|
|
195
|
-
* @param {boolean} [options.source]
|
|
196
|
-
* @param {boolean} [options.showcase]
|
|
197
|
-
* @param {boolean} [options.blocks]
|
|
198
|
-
* @param {'full'|'compact'|'brief'} [options.detail]
|
|
199
|
-
* @param {string|null} [options.lang]
|
|
200
|
-
* @param {boolean} [options.zh]
|
|
201
|
-
* @param {boolean} [options.dense]
|
|
202
|
-
* @param {string} coreDir
|
|
203
|
-
* @returns {Promise<import('./component.type.mjs').ComponentBatchResponse>}
|
|
204
|
-
*/
|
|
205
|
-
async function componentBatch(selectors, options, coreDir) {
|
|
206
|
-
const loadedIntegrations = await loadIntegrationsSafely(options.cwd);
|
|
207
|
-
/** @type {import('./component.type.mjs').ComponentBatchResult[]} */
|
|
208
|
-
const results = [];
|
|
209
|
-
for (const value of selectors) {
|
|
210
|
-
const selector = typeof value === 'string' ? value : String(value);
|
|
211
|
-
try {
|
|
212
|
-
const target = parseComponentSelector(value, options.package);
|
|
213
|
-
requireInstalledSelectorVersion(target, coreDir, loadedIntegrations);
|
|
214
|
-
const result =
|
|
215
|
-
/** @type {import('./component.type.mjs').ComponentSingleResponse} */ (
|
|
216
|
-
await component(target.name, {
|
|
217
|
-
...options,
|
|
218
|
-
lang: options.lang ?? undefined,
|
|
219
|
-
package: target.package,
|
|
220
|
-
})
|
|
221
|
-
);
|
|
222
|
-
results.push({selector, status: 'found', result});
|
|
223
|
-
} catch (error) {
|
|
224
|
-
results.push(batchFailure(selector, error));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
return {type: 'component.batch', data: {count: results.length, results}};
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* @param {string|string[]} [name]
|
|
43
|
+
* @param {string} [name]
|
|
232
44
|
* @param {object} [options]
|
|
233
45
|
* @param {string} [options.cwd]
|
|
234
46
|
* @param {boolean} [options.list]
|
|
@@ -244,7 +56,6 @@ async function componentBatch(selectors, options, coreDir) {
|
|
|
244
56
|
* @param {boolean} [options.dense]
|
|
245
57
|
* @returns {Promise<(
|
|
246
58
|
* import('./component.type.mjs').ComponentListResponse
|
|
247
|
-
* | import('./component.type.mjs').ComponentBatchResponse
|
|
248
59
|
* | import('./component.type.mjs').ComponentDetailResponse
|
|
249
60
|
* | import('./component.type.mjs').ComponentDetailPropsResponse
|
|
250
61
|
* | import('./component.type.mjs').ComponentDetailSourceResponse
|
|
@@ -268,16 +79,11 @@ export async function component(name, options = {}) {
|
|
|
268
79
|
dense = false,
|
|
269
80
|
} = options;
|
|
270
81
|
|
|
271
|
-
const selectorList = Array.isArray(name) ? name : null;
|
|
272
|
-
const noName = selectorList == null && !name;
|
|
273
|
-
|
|
274
82
|
// Default detail level mirrors the CLI (see commands/component/index.mjs):
|
|
275
83
|
// single-component views default to 'full', list-style views (--list,
|
|
276
84
|
// --category, or no name) default to 'brief' (scannable name lists).
|
|
277
|
-
//
|
|
278
|
-
|
|
279
|
-
const isListView =
|
|
280
|
-
selectorList == null && (list || category != null || noName);
|
|
85
|
+
// Keeping this in sync with the CLI is what the API↔CLI parity test checks.
|
|
86
|
+
const isListView = list || category != null || !name;
|
|
281
87
|
const detail = detailOption ?? (isListView ? 'brief' : 'full');
|
|
282
88
|
|
|
283
89
|
// Same accepted values and codes as the CLI's --detail and --lang, checked
|
|
@@ -297,14 +103,6 @@ export async function component(name, options = {}) {
|
|
|
297
103
|
);
|
|
298
104
|
}
|
|
299
105
|
|
|
300
|
-
if (selectorList && selectorList.length > COMPONENT_BATCH_SELECTOR_LIMIT) {
|
|
301
|
-
throw new AstryxError(
|
|
302
|
-
`Component batch accepts at most ${COMPONENT_BATCH_SELECTOR_LIMIT} selectors; received ${selectorList.length}`,
|
|
303
|
-
undefined,
|
|
304
|
-
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
106
|
const coreDir = requireCoreDir(cwd);
|
|
309
107
|
|
|
310
108
|
// A public API caller could pass a non-string category; the list leaf does
|
|
@@ -318,46 +116,11 @@ export async function component(name, options = {}) {
|
|
|
318
116
|
);
|
|
319
117
|
}
|
|
320
118
|
|
|
321
|
-
// ── Explicit batch selector list ─────────────────────────────────
|
|
322
|
-
// Array shape owns cardinality even if a caller also supplies a list-only
|
|
323
|
-
// option. The aggregate limit above is checked before core or integrations
|
|
324
|
-
// are resolved, so an oversized request can never emit a partial receipt.
|
|
325
|
-
if (selectorList) {
|
|
326
|
-
return componentBatch(
|
|
327
|
-
selectorList,
|
|
328
|
-
{
|
|
329
|
-
cwd,
|
|
330
|
-
package: packageScope,
|
|
331
|
-
props,
|
|
332
|
-
source,
|
|
333
|
-
showcase,
|
|
334
|
-
blocks,
|
|
335
|
-
detail,
|
|
336
|
-
lang,
|
|
337
|
-
zh,
|
|
338
|
-
dense,
|
|
339
|
-
},
|
|
340
|
-
coreDir,
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
119
|
// ── List mode ──────────────────────────────────────────────────
|
|
345
|
-
if (category || list ||
|
|
120
|
+
if (category || list || !name) {
|
|
346
121
|
return componentList(coreDir, {cwd, category, detail, zh, dense, lang});
|
|
347
122
|
}
|
|
348
123
|
|
|
349
|
-
if (typeof name === 'string') {
|
|
350
|
-
const target = parseComponentSelector(name, packageScope);
|
|
351
|
-
if (target.version) {
|
|
352
|
-
const loadedIntegrations = await loadIntegrationsSafely(cwd);
|
|
353
|
-
requireInstalledSelectorVersion(target, coreDir, loadedIntegrations);
|
|
354
|
-
}
|
|
355
|
-
if (target.name !== name || target.package !== packageScope) {
|
|
356
|
-
return component(target.name, {...options, package: target.package});
|
|
357
|
-
}
|
|
358
|
-
name = target.name;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
124
|
// ── Single component ───────────────────────────────────────────
|
|
362
125
|
if (typeof name !== 'string') {
|
|
363
126
|
throw new AstryxError(
|
|
@@ -423,10 +186,7 @@ export async function component(name, options = {}) {
|
|
|
423
186
|
if (extDocPath) {
|
|
424
187
|
// Legacy packages ship docs, never source.
|
|
425
188
|
if (source) {
|
|
426
|
-
return componentDetailSource(dirName, null, {
|
|
427
|
-
name,
|
|
428
|
-
notFoundInPackage: packageScope,
|
|
429
|
-
});
|
|
189
|
+
return componentDetailSource(dirName, null, {name, notFoundInPackage: packageScope});
|
|
430
190
|
}
|
|
431
191
|
if (blocks) {
|
|
432
192
|
return componentDetailBlocks(dirName, cwd);
|
|
@@ -28,31 +28,6 @@ export type ComponentListData = ({
|
|
|
28
28
|
detail: "full";
|
|
29
29
|
components: Record<string, import("@astryxdesign/cli/authoring").ComponentDoc[]>;
|
|
30
30
|
});
|
|
31
|
-
/**
|
|
32
|
-
* `component(string[])` always returns this type, including empty and one-item
|
|
33
|
-
* arrays. The CLI returns it for two or more positional selectors.
|
|
34
|
-
*/
|
|
35
|
-
export type ComponentBatchResponse = import("../../foundation/response/batch.type.mjs").BatchResponse<"component.batch", ComponentSingleResponse, ComponentBatchCandidate>;
|
|
36
|
-
/**
|
|
37
|
-
* One installed component that makes an unqualified selector ambiguous.
|
|
38
|
-
* Keys match a component row in `discover.search` so a caller does not learn a
|
|
39
|
-
* second candidate shape.
|
|
40
|
-
*/
|
|
41
|
-
export type ComponentBatchCandidate = {
|
|
42
|
-
package: string;
|
|
43
|
-
component: string;
|
|
44
|
-
kind: "component";
|
|
45
|
-
installed: true;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* The response a successful single selector would have returned.
|
|
49
|
-
*/
|
|
50
|
-
export type ComponentSingleResponse = (ComponentDetailResponse | ComponentDetailPropsResponse | ComponentDetailSourceResponse | ComponentDetailShowcaseResponse | ComponentDetailBlocksResponse);
|
|
51
|
-
/**
|
|
52
|
-
* One row per requested selector, in argument order. Duplicate selectors keep
|
|
53
|
-
* duplicate rows.
|
|
54
|
-
*/
|
|
55
|
-
export type ComponentBatchResult = import("../../foundation/response/batch.type.mjs").BatchRow<ComponentSingleResponse, ComponentBatchCandidate>;
|
|
56
31
|
/**
|
|
57
32
|
* A single entry in a `component.list` group at `detail: 'names'`. Pre-1.0 the
|
|
58
33
|
* list moved from bare strings to package-qualified objects so consumers can
|
|
@@ -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';
|