@astryxdesign/cli 0.6.5-canary.d6fa1d6 → 0.6.5-canary.e5d11eb
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 +2 -2
- package/api/build/_adapter.d.mts +0 -14
- package/api/build/_adapter.mjs +1 -58
- package/api/build/build.test.mjs +1 -74
- package/api/build/kit/kit.mjs +7 -39
- package/api/build/kit/rank.d.mts +0 -8
- package/api/build/kit/rank.mjs +0 -14
- package/api/docs/docs.d.mts +0 -6
- package/api/docs/docs.doc.mjs +2 -31
- package/api/docs/docs.mjs +1 -44
- package/api/docs/docs.type.d.mts +1 -38
- package/api/docs/docs.type.mjs +1 -18
- package/api/docs/node/node.d.mts +3 -28
- package/api/docs/node/node.mjs +23 -146
- package/api/gap-report/gap-report.d.mts +1 -3
- package/api/gap-report/gap-report.mjs +2 -12
- package/api/gap-report/gap-report.test.mjs +0 -106
- package/api/hook/list/list.d.mts +1 -1
- package/api/integration/add-theme.mjs +3 -93
- package/api/integration/add-theme.test.mjs +0 -100
- package/api/integration/integrationAddTheme.doc.mjs +1 -1
- package/api/search/search.d.mts +5 -12
- package/api/search/search.doc.mjs +4 -4
- package/api/search/search.mjs +53 -123
- package/api/search/search.test.mjs +8 -123
- package/api/search/search.type.d.mts +5 -5
- package/api/search/search.type.mjs +5 -5
- package/api/theme/build/build.mjs +69 -146
- package/api/theme/build/build.test.mjs +1 -190
- package/api/theme/themeBuild.doc.d.mts +1 -4
- package/api/theme/themeBuild.doc.mjs +3 -14
- package/assets/docs/theme.doc.mjs +1 -2
- package/assets/docs/tree/add-a-theme.doc.mjs +0 -4
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.mjs +2 -8
- package/clients/cli/commands/discover.mjs +1 -29
- package/clients/cli/commands/docs.doc.mjs +2 -15
- package/clients/cli/commands/docs.mjs +5 -222
- package/clients/cli/commands/gap-report.mjs +0 -12
- package/clients/cli/commands/gap-report.test.mjs +0 -63
- package/clients/cli/commands/integration-add.doc.mjs +1 -1
- package/clients/cli/commands/search.doc.mjs +4 -5
- package/clients/cli/commands/search.mjs +6 -30
- package/clients/cli/commands/search.test.mjs +16 -60
- package/foundation/agent-docs/agent-docs.mjs +1 -2
- package/foundation/agent-docs/agent-docs.test.mjs +0 -8
- package/foundation/discovery/theme-discovery.d.mts +0 -6
- package/foundation/discovery/theme-discovery.mjs +0 -9
- package/foundation/doc-compiler/doc-loads.test.mjs +1 -1
- package/package.json +9 -9
- package/api/build/kit/weights.d.mts +0 -82
- package/api/build/kit/weights.json +0 -1
- package/api/build/kit/weights.mjs +0 -305
- package/api/build/kit/weights.test.mjs +0 -190
- package/api/docs/docs.depth.test.mjs +0 -132
- package/api/theme/build/build.icon-lineage.test.mjs +0 -117
- package/api/theme/build/build.icon-preservation.test.mjs +0 -639
- package/api/theme/build/icon-imports.d.mts +0 -47
- package/api/theme/build/icon-imports.mjs +0 -691
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.doc.mjs +0 -15
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupShowcase.tsx +0 -38
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.doc.mjs +0 -20
- package/assets/templates/blocks/components/DropdownMenuGroup/DropdownMenuGroupWithSelectable.tsx +0 -48
- package/clients/cli/commands/discover.no-source.test.mjs +0 -75
- package/clients/cli/commands/docs.depth.test.mjs +0 -219
- package/clients/cli/commands/theme-list.behavior.test.mjs +0 -41
|
@@ -65,10 +65,6 @@ Declare theme root ./themes in astryx.integration.mjs.
|
|
|
65
65
|
lang: 'bash',
|
|
66
66
|
code: 'npx astryx integration add theme ocean --from neutral',
|
|
67
67
|
},
|
|
68
|
-
{
|
|
69
|
-
type: 'prose',
|
|
70
|
-
text: 'The copy keeps the packages the base theme uses, such as `lucide-react` for its icons: `--from` adds them to your `dependencies`, so an app that installs your package gets them too. Install your dependencies again before you build the theme.',
|
|
71
|
-
},
|
|
72
68
|
{
|
|
73
69
|
type: 'prose',
|
|
74
70
|
text: 'Use `--from` when you want to change a lot. For a small change that should stay linked to a base theme, use `extends` instead ({@link generic:define-the-theme}).',
|
|
@@ -174,7 +174,7 @@ message: Rerun with --confirm-public to file this report.`,
|
|
|
174
174
|
},
|
|
175
175
|
{
|
|
176
176
|
type: 'prose',
|
|
177
|
-
text: 'One handler anywhere in the app, from the app or from any package, turns the fallback off for every report.
|
|
177
|
+
text: 'One handler anywhere in the app, from the app or from any package, turns the fallback off for every report. See {@link command:gap-report}.',
|
|
178
178
|
},
|
|
179
179
|
],
|
|
180
180
|
},
|
|
@@ -209,16 +209,11 @@ async function warnOnThemeIntegrationIssues(json) {
|
|
|
209
209
|
* @param {import('../../../api/theme/theme.type.mjs').ThemeListEntry[]} themes
|
|
210
210
|
*/
|
|
211
211
|
function printThemeList(themes) {
|
|
212
|
-
const run = getCliInvocation();
|
|
213
|
-
// `theme list` shows what this project can add now. Themes in packages it
|
|
214
|
-
// has not installed are `discover`'s.
|
|
215
|
-
const more = text(
|
|
216
|
-
`More themes in packages you could add: ${run} discover theme`,
|
|
217
|
-
);
|
|
218
212
|
if (themes.length === 0) {
|
|
219
|
-
emit(text('No themes are available in this project.')
|
|
213
|
+
emit(text('No themes are available in this project.'));
|
|
220
214
|
return;
|
|
221
215
|
}
|
|
216
|
+
const run = getCliInvocation();
|
|
222
217
|
emit(
|
|
223
218
|
section('Themes'),
|
|
224
219
|
list(
|
|
@@ -231,7 +226,6 @@ function printThemeList(themes) {
|
|
|
231
226
|
text(
|
|
232
227
|
`Usage:\n ${run} theme add <slug> [target-path] Scaffold a theme file you own`,
|
|
233
228
|
),
|
|
234
|
-
more,
|
|
235
229
|
);
|
|
236
230
|
}
|
|
237
231
|
|
|
@@ -268,47 +268,19 @@ export function registerDiscover(program) {
|
|
|
268
268
|
// No discover source: the list of what this project has, as always.
|
|
269
269
|
if (available === undefined) {
|
|
270
270
|
if (result.data.length === 0) {
|
|
271
|
-
if (
|
|
272
|
-
// The user specifically asked for available packages but
|
|
273
|
-
// there is no source to answer from. Say so honestly.
|
|
274
|
-
emit(
|
|
275
|
-
text('No discover source is configured.'),
|
|
276
|
-
text(
|
|
277
|
-
[
|
|
278
|
-
'Available integrations are listed by discover sources.',
|
|
279
|
-
'A project can set one in astryx.config.mjs, and installed',
|
|
280
|
-
'integrations can provide one.',
|
|
281
|
-
].join(' '),
|
|
282
|
-
),
|
|
283
|
-
text(
|
|
284
|
-
[
|
|
285
|
-
`Find Astryx packages on npm: npm search @astryxdesign`,
|
|
286
|
-
`Learn more: ${run} docs cli/integrations`,
|
|
287
|
-
].join('\n'),
|
|
288
|
-
),
|
|
289
|
-
);
|
|
290
|
-
} else if (result.meta && result.meta.configured === false) {
|
|
271
|
+
if (result.meta && result.meta.configured === false) {
|
|
291
272
|
emit(
|
|
292
273
|
text('No integrations configured.'),
|
|
293
274
|
text('Add integration package names to astryx.config.mjs:'),
|
|
294
275
|
code(
|
|
295
276
|
"export default {\n integrations: ['@scope/your-integration'],\n};",
|
|
296
277
|
),
|
|
297
|
-
text(
|
|
298
|
-
[
|
|
299
|
-
`Find Astryx packages on npm: npm search @astryxdesign`,
|
|
300
|
-
`Learn more: ${run} docs cli/integrations`,
|
|
301
|
-
].join('\n'),
|
|
302
|
-
),
|
|
303
278
|
);
|
|
304
279
|
} else {
|
|
305
280
|
emit(
|
|
306
281
|
text(
|
|
307
282
|
'No external components found in configured integrations.',
|
|
308
283
|
),
|
|
309
|
-
text(
|
|
310
|
-
`Find more packages: ${run} discover --available (needs a discover source)`,
|
|
311
|
-
),
|
|
312
284
|
);
|
|
313
285
|
}
|
|
314
286
|
break;
|
|
@@ -22,9 +22,7 @@ export const doc = {
|
|
|
22
22
|
'does, and `--index` its section index. A route ' +
|
|
23
23
|
'opens a node of the docs tree: `cli` lists its guides and reference, ' +
|
|
24
24
|
'`cli/api/functions` lists every API function, and `cli/api/functions/search` prints ' +
|
|
25
|
-
'one.
|
|
26
|
-
'everything below it (all), and with it `--detail` sets how much of each doc below ' +
|
|
27
|
-
'shows: one line (brief, the default), its sections (compact), or all of it (full).',
|
|
25
|
+
'one.',
|
|
28
26
|
fn: 'docs',
|
|
29
27
|
args: [
|
|
30
28
|
{name: 'topic', param: 'topic', required: false},
|
|
@@ -41,12 +39,6 @@ export const doc = {
|
|
|
41
39
|
description:
|
|
42
40
|
'Print the whole topic instead of its sections (text; `--json` returns the whole topic unless --index). Cannot be set with --index',
|
|
43
41
|
},
|
|
44
|
-
{
|
|
45
|
-
flag: '--depth <levels>',
|
|
46
|
-
param: 'options.depth',
|
|
47
|
-
description:
|
|
48
|
-
'How many levels of the docs tree to read below a namespace: 0 for the namespace alone, 1 for its children (what a read without --depth shows), all for everything below it. With it, --detail sets how much of each doc below shows: brief (one line each, the default), compact (with its sections), or full',
|
|
49
|
-
},
|
|
50
42
|
],
|
|
51
43
|
examples: [
|
|
52
44
|
{label: 'List topics', cli: 'astryx docs'},
|
|
@@ -54,11 +46,6 @@ export const doc = {
|
|
|
54
46
|
{label: 'A whole topic as JSON', cli: 'astryx docs spacing --json'},
|
|
55
47
|
{label: 'One section', cli: 'astryx docs theme quick-start'},
|
|
56
48
|
{label: 'The CLI docs tree', cli: 'astryx docs cli'},
|
|
57
|
-
{label: 'Every CLI doc, one line each', cli: 'astryx docs cli --depth all'},
|
|
58
|
-
{
|
|
59
|
-
label: 'The integration guides as one read',
|
|
60
|
-
cli: 'astryx docs cli/integrations --depth all --detail full',
|
|
61
|
-
},
|
|
62
49
|
{label: 'One API function', cli: 'astryx docs cli/api/functions/search'},
|
|
63
50
|
{label: 'A whole guide', cli: 'astryx docs cli/integrations/quick-start --full'},
|
|
64
51
|
],
|
|
@@ -66,7 +53,7 @@ export const doc = {
|
|
|
66
53
|
{code: 0, when: 'success'},
|
|
67
54
|
{
|
|
68
55
|
code: 1,
|
|
69
|
-
when: 'unknown topic or route, a section that matches no section or more than one
|
|
56
|
+
when: 'unknown topic or route, or a section that matches no section or more than one',
|
|
70
57
|
},
|
|
71
58
|
],
|
|
72
59
|
related: ['search', 'component', 'hook', 'template'],
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
* @file docs command — Print Astryx reference docs
|
|
5
5
|
*
|
|
6
6
|
* In text, every read is one level: a topic lists its sections, so a reader can
|
|
7
|
-
* open one section by its key, and `--full` prints the whole topic. `--
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* contract: a topic returns its whole doc, and `--index` its sections.
|
|
7
|
+
* open one section by its key, and `--full` prints the whole topic. `--json`
|
|
8
|
+
* keeps the docs() contract: a topic returns its whole doc, and `--index` its
|
|
9
|
+
* sections.
|
|
11
10
|
* Supports --detail (full|compact|brief) and --lang (en|zh|dense). A code
|
|
12
11
|
* block's label prints above its fence, and table cells escape their pipes.
|
|
13
12
|
*
|
|
@@ -19,7 +18,6 @@
|
|
|
19
18
|
* astryx docs <topic> --full Print the whole topic
|
|
20
19
|
* astryx docs <route> Open a node of the docs tree, such as
|
|
21
20
|
* cli, cli/api, or cli/api/functions/search
|
|
22
|
-
* astryx docs <route> --depth <n|all> Read that many levels below it
|
|
23
21
|
*/
|
|
24
22
|
|
|
25
23
|
import {
|
|
@@ -183,202 +181,6 @@ function formatReferenceFull(docs, detail) {
|
|
|
183
181
|
return `${header}\n\n${sections.join(sep)}`;
|
|
184
182
|
}
|
|
185
183
|
|
|
186
|
-
/**
|
|
187
|
-
* @param {string} title
|
|
188
|
-
* @param {number} level
|
|
189
|
-
* @returns {string}
|
|
190
|
-
*/
|
|
191
|
-
function treeHeading(title, level) {
|
|
192
|
-
return `${'#'.repeat(Math.max(1, Math.min(6, level)))} ${title}`;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* A doc's blocks at one depth: its headings move down with it.
|
|
197
|
-
* @param {import('@astryxdesign/cli/authoring').ReferenceContentBlock[]} blocks
|
|
198
|
-
* @param {'full' | 'compact' | 'brief'} detail
|
|
199
|
-
* @param {number} headingOffset
|
|
200
|
-
* @returns {string[]}
|
|
201
|
-
*/
|
|
202
|
-
function formatTreeBlocks(blocks, detail, headingOffset) {
|
|
203
|
-
/** @type {string[]} */
|
|
204
|
-
const formatted = [];
|
|
205
|
-
for (const block of blocks) {
|
|
206
|
-
const value =
|
|
207
|
-
block.type === 'heading'
|
|
208
|
-
? treeHeading(block.text, (block.level || 3) + headingOffset)
|
|
209
|
-
: formatBlock(block, detail);
|
|
210
|
-
if (value) formatted.push(value);
|
|
211
|
-
}
|
|
212
|
-
return formatted;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* @param {import('../../../api/docs/docs.type.mjs').DocsReadSection} docSection
|
|
217
|
-
* @param {'full' | 'compact' | 'brief'} detail
|
|
218
|
-
* @param {number} headingLevel
|
|
219
|
-
* @returns {string}
|
|
220
|
-
*/
|
|
221
|
-
function formatTreeSection(docSection, detail, headingLevel) {
|
|
222
|
-
const heading = treeHeading(docSection.title, headingLevel);
|
|
223
|
-
const blocks = formatTreeBlocks(docSection.content, detail, headingLevel - 2);
|
|
224
|
-
return blocks.length > 0 ? `${heading}\n\n${blocks.join('\n\n')}` : heading;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Where a route sits below the namespace a read names.
|
|
229
|
-
* @param {string} route
|
|
230
|
-
* @param {string} root
|
|
231
|
-
* @returns {string}
|
|
232
|
-
*/
|
|
233
|
-
function belowRoot(route, root) {
|
|
234
|
-
return route.startsWith(`${root}/`) ? route.slice(root.length + 1) : route;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* @param {number} count
|
|
239
|
-
* @returns {string}
|
|
240
|
-
*/
|
|
241
|
-
function docsBelow(count) {
|
|
242
|
-
return `${count} ${count === 1 ? 'doc' : 'docs'} below`;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Every child of a depth read, one row each in reading order, named by where
|
|
247
|
-
* it sits below the read's namespace.
|
|
248
|
-
* @param {import('../../../api/docs/docs.type.mjs').DocsNodeChild[]} children
|
|
249
|
-
* @param {string} root
|
|
250
|
-
* @returns {{name: string, summary: string}[]}
|
|
251
|
-
*/
|
|
252
|
-
function treeRows(children, root) {
|
|
253
|
-
return children.flatMap(child => [
|
|
254
|
-
{
|
|
255
|
-
name: belowRoot(child.route, root),
|
|
256
|
-
summary: child.childCount
|
|
257
|
-
? `${childRow(child).summary} (${docsBelow(child.childCount)})`
|
|
258
|
-
: childRow(child).summary,
|
|
259
|
-
},
|
|
260
|
-
...(child.slots ?? []).flatMap(slot => treeRows(slot.children, root)),
|
|
261
|
-
]);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* One child of a depth read with its text, under a heading for its level, and
|
|
266
|
-
* its own children below it.
|
|
267
|
-
* @param {import('../../../api/docs/docs.type.mjs').DocsNodeChild} child
|
|
268
|
-
* @param {'full' | 'compact'} detail
|
|
269
|
-
* @param {number} level
|
|
270
|
-
* @param {string} root
|
|
271
|
-
* @param {string} run
|
|
272
|
-
* @returns {string}
|
|
273
|
-
*/
|
|
274
|
-
function formatTreeChild(child, detail, level, root, run) {
|
|
275
|
-
const parts = [
|
|
276
|
-
`${treeHeading(child.title, level)} (${belowRoot(child.route, root)})`,
|
|
277
|
-
];
|
|
278
|
-
if (
|
|
279
|
-
child.summary &&
|
|
280
|
-
(child.kind === 'namespace' || child.kind === 'generic')
|
|
281
|
-
) {
|
|
282
|
-
parts.push(child.summary);
|
|
283
|
-
}
|
|
284
|
-
const content = formatTreeBlocks(child.content ?? [], detail, level - 2);
|
|
285
|
-
if (content.length > 0) parts.push(content.join('\n\n'));
|
|
286
|
-
parts.push(
|
|
287
|
-
...(child.sections ?? []).map(docSection =>
|
|
288
|
-
formatTreeSection(docSection, detail, level + 1),
|
|
289
|
-
),
|
|
290
|
-
);
|
|
291
|
-
if (child.childCount) {
|
|
292
|
-
parts.push(
|
|
293
|
-
`${docsBelow(child.childCount)}: ${run} docs ${child.route} --depth 1`,
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
for (const slot of child.slots ?? []) {
|
|
297
|
-
parts.push(
|
|
298
|
-
...slot.children.map(each =>
|
|
299
|
-
formatTreeChild(each, detail, level + 1, root, run),
|
|
300
|
-
),
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
return parts.join('\n\n');
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* A depth read of a namespace: its intro, then each slot's docs as deep as
|
|
308
|
-
* asked, one line each (brief) or with their text (compact, full). A typed doc
|
|
309
|
-
* has nothing below it, so it reads as it always does.
|
|
310
|
-
* @param {import('../../../api/docs/docs.type.mjs').DocsNode} node
|
|
311
|
-
* @param {'full' | 'compact' | 'brief'} detail how the named node reads
|
|
312
|
-
* @param {'full' | 'compact' | 'brief'} childDetail how each doc below reads
|
|
313
|
-
* @param {string} run
|
|
314
|
-
*/
|
|
315
|
-
function emitTree(node, detail, childDetail, run) {
|
|
316
|
-
if (node.kind !== 'namespace') {
|
|
317
|
-
emitNode(node, detail, run);
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* @param {import('../../../api/docs/docs.type.mjs').DocsNodeChild[]} children
|
|
322
|
-
* @returns {string[]}
|
|
323
|
-
*/
|
|
324
|
-
const routes = children =>
|
|
325
|
-
children.flatMap(child => [
|
|
326
|
-
child.route,
|
|
327
|
-
...(child.slots ?? []).flatMap(slot => routes(slot.children)),
|
|
328
|
-
]);
|
|
329
|
-
const allBelow = node.slots
|
|
330
|
-
.flatMap(slot => routes(slot.children))
|
|
331
|
-
.every(route => route.startsWith(`${node.route}/`));
|
|
332
|
-
const root = allBelow ? node.route : '';
|
|
333
|
-
emit(
|
|
334
|
-
section(node.title, wrapText(node.summary)),
|
|
335
|
-
...(node.content?.length
|
|
336
|
-
? [
|
|
337
|
-
text(
|
|
338
|
-
node.content
|
|
339
|
-
.map(b => formatBlock(b, detail))
|
|
340
|
-
.filter(Boolean)
|
|
341
|
-
.join('\n\n'),
|
|
342
|
-
),
|
|
343
|
-
]
|
|
344
|
-
: []),
|
|
345
|
-
...(node.childCount
|
|
346
|
-
? [
|
|
347
|
-
text(
|
|
348
|
-
`${docsBelow(node.childCount)}. Read them: ${run} docs ${node.route} --depth 1`,
|
|
349
|
-
),
|
|
350
|
-
]
|
|
351
|
-
: []),
|
|
352
|
-
...node.slots.flatMap(slot => [
|
|
353
|
-
...(node.slots.length === 1 && slot.title === node.title
|
|
354
|
-
? []
|
|
355
|
-
: [section(slot.title)]),
|
|
356
|
-
childDetail === 'brief'
|
|
357
|
-
? records(treeRows(slot.children, root), {
|
|
358
|
-
fields: ['name', 'summary'],
|
|
359
|
-
layout: 'inline',
|
|
360
|
-
})
|
|
361
|
-
: code(
|
|
362
|
-
slot.children
|
|
363
|
-
.map(child => formatTreeChild(child, childDetail, 2, root, run))
|
|
364
|
-
.join('\n\n'),
|
|
365
|
-
),
|
|
366
|
-
]),
|
|
367
|
-
text(
|
|
368
|
-
[
|
|
369
|
-
...(node.slots.length > 0
|
|
370
|
-
? [
|
|
371
|
-
allBelow
|
|
372
|
-
? `Open one: ${run} docs ${node.route}/<name>`
|
|
373
|
-
: `Open one: ${run} docs <name>`,
|
|
374
|
-
]
|
|
375
|
-
: []),
|
|
376
|
-
...linkLines(node.links),
|
|
377
|
-
].join('\n'),
|
|
378
|
-
),
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
184
|
/**
|
|
383
185
|
* The moves a read offers (spec:AST-047), one runnable command per line: up to
|
|
384
186
|
* the level it sits in, the item before and after it, and the docs it names.
|
|
@@ -529,7 +331,7 @@ export function registerDocs(program) {
|
|
|
529
331
|
action: async (
|
|
530
332
|
/** @type {string | undefined} */ topic,
|
|
531
333
|
/** @type {string | undefined} */ sectionName,
|
|
532
|
-
/** @type {{index?: boolean, full?: boolean
|
|
334
|
+
/** @type {{index?: boolean, full?: boolean}} */ options = {},
|
|
533
335
|
) => {
|
|
534
336
|
const run = getCliInvocation();
|
|
535
337
|
const lang = program.opts().lang || null;
|
|
@@ -544,22 +346,6 @@ export function registerDocs(program) {
|
|
|
544
346
|
{code: ERROR_CODES.ERR_INVALID_ARGUMENT},
|
|
545
347
|
);
|
|
546
348
|
}
|
|
547
|
-
/** @type {number | 'all' | undefined} */
|
|
548
|
-
let depth;
|
|
549
|
-
if (options.depth != null) {
|
|
550
|
-
if (options.depth === 'all') depth = 'all';
|
|
551
|
-
else if (/^\d+$/.test(options.depth)) depth = Number(options.depth);
|
|
552
|
-
else {
|
|
553
|
-
return cliError(
|
|
554
|
-
`--depth takes a number of levels (0, 1, 2, ...) or all, not "${options.depth}".`,
|
|
555
|
-
{code: ERROR_CODES.ERR_INVALID_ARGUMENT},
|
|
556
|
-
);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
// With --depth, --detail is how much of each doc below shows; left at
|
|
560
|
-
// its default, each is one line.
|
|
561
|
-
const childDetail =
|
|
562
|
-
program.getOptionValueSource('detail') === 'default' ? 'brief' : detail;
|
|
563
349
|
// Text reads one level: a topic lists its sections (one with a single
|
|
564
350
|
// section prints whole). JSON keeps docs(): the whole topic unless
|
|
565
351
|
// --index. The dense variant is written to be read whole.
|
|
@@ -577,7 +363,6 @@ export function registerDocs(program) {
|
|
|
577
363
|
zh,
|
|
578
364
|
dense,
|
|
579
365
|
index: listSections,
|
|
580
|
-
...(depth != null ? {depth, detail: childDetail} : {}),
|
|
581
366
|
});
|
|
582
367
|
if (
|
|
583
368
|
!options.index &&
|
|
@@ -632,7 +417,6 @@ export function registerDocs(program) {
|
|
|
632
417
|
` ${run} docs <topic> <section> read one section`,
|
|
633
418
|
` ${run} docs <topic> --full read the whole topic`,
|
|
634
419
|
` ${run} docs cli/api go down the docs tree one level at a time`,
|
|
635
|
-
` ${run} docs cli --depth all every doc below cli, one line each`,
|
|
636
420
|
`With --json, a topic returns its whole doc; add --index for its section list.`,
|
|
637
421
|
].join('\n'),
|
|
638
422
|
),
|
|
@@ -678,8 +462,7 @@ export function registerDocs(program) {
|
|
|
678
462
|
}
|
|
679
463
|
|
|
680
464
|
case 'docs.node': {
|
|
681
|
-
|
|
682
|
-
else emitNode(result.data, detail, run);
|
|
465
|
+
emitNode(result.data, detail, run);
|
|
683
466
|
break;
|
|
684
467
|
}
|
|
685
468
|
}
|
|
@@ -55,18 +55,6 @@ export function registerGapReport(program) {
|
|
|
55
55
|
result.type === 'gap-report.file' &&
|
|
56
56
|
(result.data.status === 'failed' || result.data.status === 'partial');
|
|
57
57
|
|
|
58
|
-
// stderr in both modes, so a caller that reads only the exit code or the
|
|
59
|
-
// JSON envelope still sees which delivery failed and why.
|
|
60
|
-
if (isFailure && result.type === 'gap-report.file') {
|
|
61
|
-
for (const delivery of result.data.deliveries) {
|
|
62
|
-
if (delivery.status === 'failed') {
|
|
63
|
-
console.error(
|
|
64
|
-
`gap-report: delivery to ${delivery.handler} failed: ${delivery.message ?? 'no message'}`,
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
58
|
if (program.opts().json) {
|
|
71
59
|
jsonOut(result);
|
|
72
60
|
if (isFailure) process.exitCode = 1;
|
|
@@ -172,69 +172,6 @@ export default {};\n`,
|
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
-
it('exits nonzero and names the integration on stderr when one fails to load', async () => {
|
|
176
|
-
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-gap-broken-'));
|
|
177
|
-
try {
|
|
178
|
-
fs.writeFileSync(
|
|
179
|
-
path.join(cwd, 'package.json'),
|
|
180
|
-
JSON.stringify({name: 'fixture-app'}),
|
|
181
|
-
);
|
|
182
|
-
fs.writeFileSync(
|
|
183
|
-
path.join(cwd, 'astryx.config.mjs'),
|
|
184
|
-
"export default {integrations: ['@test/broken']};\n",
|
|
185
|
-
);
|
|
186
|
-
const integrationDir = path.join(cwd, 'node_modules', '@test', 'broken');
|
|
187
|
-
fs.mkdirSync(integrationDir, {recursive: true});
|
|
188
|
-
fs.writeFileSync(
|
|
189
|
-
path.join(integrationDir, 'package.json'),
|
|
190
|
-
JSON.stringify({
|
|
191
|
-
name: '@test/broken',
|
|
192
|
-
version: '1.0.0',
|
|
193
|
-
type: 'module',
|
|
194
|
-
}),
|
|
195
|
-
);
|
|
196
|
-
fs.writeFileSync(
|
|
197
|
-
path.join(integrationDir, 'astryx.integration.mjs'),
|
|
198
|
-
"throw new Error('intentional integration load failure');\n",
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
const cli = await runCli(
|
|
202
|
-
[
|
|
203
|
-
'gap-report',
|
|
204
|
-
'General',
|
|
205
|
-
'--category',
|
|
206
|
-
'docs_gap',
|
|
207
|
-
'--reason',
|
|
208
|
-
'Need a keyboard example',
|
|
209
|
-
'--json',
|
|
210
|
-
],
|
|
211
|
-
{cwd},
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
expect(cli.status).toBe(1);
|
|
215
|
-
expect(JSON.parse(cli.stdout)).toMatchObject({
|
|
216
|
-
type: 'gap-report.file',
|
|
217
|
-
data: {
|
|
218
|
-
status: 'failed',
|
|
219
|
-
filedCount: 0,
|
|
220
|
-
deliveries: [
|
|
221
|
-
{
|
|
222
|
-
handlerType: 'integration',
|
|
223
|
-
handler: '@test/broken',
|
|
224
|
-
status: 'failed',
|
|
225
|
-
},
|
|
226
|
-
],
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
expect(cli.stderr).toContain(
|
|
230
|
-
'gap-report: delivery to @test/broken failed:',
|
|
231
|
-
);
|
|
232
|
-
expect(cli.stderr).toContain('intentional integration load failure');
|
|
233
|
-
} finally {
|
|
234
|
-
fs.rmSync(cwd, {recursive: true, force: true});
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
|
|
238
175
|
it('reports missing required fields through the JSON error contract', async () => {
|
|
239
176
|
const cli = await runCli(['gap-report', 'Button', '--json']);
|
|
240
177
|
expect(cli.status).toBe(1);
|
|
@@ -60,7 +60,7 @@ export const doc = {
|
|
|
60
60
|
flag: '--from <theme>',
|
|
61
61
|
param: 'options.from',
|
|
62
62
|
description:
|
|
63
|
-
'Existing theme slug to fork as a starting point instead of a blank scaffold; the new theme copies the base and has no link back
|
|
63
|
+
'Existing theme slug to fork as a starting point instead of a blank scaffold; the new theme copies the base and has no link back. Only valid for theme',
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
flag: '--to <version>',
|
|
@@ -13,11 +13,11 @@ export const doc = {
|
|
|
13
13
|
name: 'search',
|
|
14
14
|
displayName: 'astryx search',
|
|
15
15
|
namespace: 'cli/commands',
|
|
16
|
-
summary: 'Search components, hooks, docs,
|
|
16
|
+
summary: 'Search components, hooks, docs, and templates in one ranked list',
|
|
17
17
|
description:
|
|
18
18
|
'Terminal front-end to search(): prints one ranked, greppable list across ' +
|
|
19
19
|
'every content domain, each row carrying a follow-up command to act on it. ' +
|
|
20
|
-
'Outside an app, where @astryxdesign/core is not installed, it searches the docs
|
|
20
|
+
'Outside an app, where @astryxdesign/core is not installed, it searches the docs.',
|
|
21
21
|
fn: 'search',
|
|
22
22
|
// Every word after `search` is the query: `astryx search dark mode` searches
|
|
23
23
|
// for "dark mode", with no quotes needed.
|
|
@@ -26,8 +26,8 @@ export const doc = {
|
|
|
26
26
|
{
|
|
27
27
|
flag: '--type <domain>',
|
|
28
28
|
param: 'options.type',
|
|
29
|
-
choices: ['component', 'hook', 'doc', 'template'
|
|
30
|
-
description: 'Filter to one domain (component|hook|doc|template
|
|
29
|
+
choices: ['component', 'hook', 'doc', 'template'],
|
|
30
|
+
description: 'Filter to one domain (component|hook|doc|template)',
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
flag: '--limit <n>',
|
|
@@ -49,7 +49,6 @@ export const doc = {
|
|
|
49
49
|
label: 'Filter + JSON',
|
|
50
50
|
cli: 'astryx search "data table" --type template --json',
|
|
51
51
|
},
|
|
52
|
-
{label: 'Themes you can add', cli: 'astryx search warm --type theme'},
|
|
53
52
|
],
|
|
54
53
|
exitCodes: [
|
|
55
54
|
{code: 0, when: 'success (including zero matches)'},
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @file search command — unified ranked search with a stable result summary.
|
|
5
5
|
*
|
|
6
6
|
* One "I'm looking for X" entry point spanning components, hooks, docs topics,
|
|
7
|
-
* templates (page + block)
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* and templates (page + block). Results are ranked by relevance and tagged
|
|
8
|
+
* with their domain, with a follow-up command so the user knows what to run
|
|
9
|
+
* next.
|
|
10
10
|
*
|
|
11
11
|
* The command surface (description, args, flags) is sourced from the colocated
|
|
12
12
|
* `search.doc.mjs` CommandDoc via `defineCommand`; this file supplies only the
|
|
@@ -104,13 +104,13 @@ export function registerSearch(program) {
|
|
|
104
104
|
// ── Text output ──────────────────────────────────────────────
|
|
105
105
|
const run = getCliInvocation();
|
|
106
106
|
const {query: q, matchCount, results} = result.data;
|
|
107
|
-
// Outside an app an open search covers the docs
|
|
108
|
-
//
|
|
107
|
+
// Outside an app an open search covers the docs alone. Say so, so a
|
|
108
|
+
// docs-only list does not read as "Astryx has no such component".
|
|
109
109
|
const note =
|
|
110
110
|
!options.type && !findCoreDir(process.cwd())
|
|
111
111
|
? [
|
|
112
112
|
text(
|
|
113
|
-
'@astryxdesign/core is not installed here, so only the docs
|
|
113
|
+
'@astryxdesign/core is not installed here, so only the docs were searched.',
|
|
114
114
|
),
|
|
115
115
|
]
|
|
116
116
|
: [];
|
|
@@ -123,7 +123,6 @@ export function registerSearch(program) {
|
|
|
123
123
|
text(
|
|
124
124
|
`Try a broader term, or browse: ${run} ${note.length > 0 ? 'docs' : 'component --list'}`,
|
|
125
125
|
),
|
|
126
|
-
...discoverHint(run, q, options.type),
|
|
127
126
|
);
|
|
128
127
|
return answered;
|
|
129
128
|
}
|
|
@@ -175,34 +174,11 @@ export function registerSearch(program) {
|
|
|
175
174
|
format: {command: formatCliCommand, parent: formatCliCommand},
|
|
176
175
|
}),
|
|
177
176
|
...note,
|
|
178
|
-
...discoverHint(run, q, options.type),
|
|
179
177
|
);
|
|
180
178
|
return answered;
|
|
181
179
|
},
|
|
182
180
|
});
|
|
183
181
|
}
|
|
184
182
|
|
|
185
|
-
/**
|
|
186
|
-
* Search reads only what is installed. Point at `discover` for the packages
|
|
187
|
-
* that could add more, except for hooks, which no integration adds.
|
|
188
|
-
* @param {string} run - The caller's CLI invocation prefix.
|
|
189
|
-
* @param {string} query
|
|
190
|
-
* @param {string | undefined} type
|
|
191
|
-
*/
|
|
192
|
-
function discoverHint(run, query, type) {
|
|
193
|
-
if (type === 'hook') return [];
|
|
194
|
-
return [
|
|
195
|
-
text(`More in packages you could add: ${run} discover ${shellWord(query)}`),
|
|
196
|
-
];
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* One shell word: the value itself when it is plain, else single-quoted.
|
|
201
|
-
* @param {string} value
|
|
202
|
-
*/
|
|
203
|
-
function shellWord(value) {
|
|
204
|
-
return /^[\w@./:-]+$/.test(value) ? value : `'${value.replace(/'/g, `'\\''`)}'`;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
183
|
// Re-export the API for external consumers.
|
|
208
184
|
export {search, SEARCH_DOMAINS} from '../../../api/search/search.mjs';
|