@astryxdesign/cli 0.7.3-canary.f94e962 → 0.7.3-canary.fba04ed
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 +68 -68
- package/api/build/_adapter.mjs +37 -25
- package/api/build/blocks/blocks.d.mts +68 -18
- package/api/build/blocks/blocks.mjs +475 -116
- package/api/build/blocks/blocks.test.mjs +191 -61
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/build.type.mjs +1 -1
- package/api/build/kit/answer.d.mts +9 -5
- package/api/build/kit/answer.mjs +123 -13
- package/api/build/kit/answer.test.mjs +73 -3
- package/api/build/kit/signals.d.mts +19 -0
- package/api/build/kit/signals.mjs +18 -7
- package/api/build/tree.mjs +2 -1
- package/api/build/tree.test.mjs +37 -29
- package/api/component/_adapter.mjs +39 -5
- package/api/component/component-replacement.test.mjs +1 -0
- package/api/component/component.mjs +1 -1
- package/api/component/doc-links.test.mjs +2 -2
- package/api/discover/_adapter.d.mts +1 -2
- package/api/discover/_adapter.mjs +6 -8
- package/api/discover/discover.mjs +0 -1
- package/api/docs/_adapter.d.mts +2 -2
- package/api/docs/_adapter.mjs +65 -18
- package/api/docs/docs-homes.test.mjs +127 -0
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.test.mjs +28 -18
- package/api/docs/integration-tree.test.mjs +20 -20
- package/api/docs/integrationDocs.test.mjs +1 -1
- package/api/docs/namespace-section.test.mjs +6 -6
- package/api/docs/reference-blocks.test.mjs +2 -2
- package/api/doctor/_adapter.d.mts +33 -13
- package/api/doctor/_adapter.mjs +55 -25
- package/api/doctor/doctor.d.mts +23 -5
- package/api/doctor/doctor.mjs +97 -28
- package/api/doctor/doctor.test.mjs +67 -9
- package/api/hook/hook.mjs +1 -1
- package/api/integration/validate-integration-fixes.test.mjs +6 -5
- package/api/integration/validate-integration-gaps.test.mjs +12 -1
- package/api/integration/validate-integration.d.mts +4 -0
- package/api/integration/validate-integration.mjs +48 -7
- package/api/integration/validate-integration.type.d.mts +36 -5
- package/api/integration/validate-integration.type.mjs +27 -6
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_adapter.d.mts +16 -0
- package/api/search/_adapter.mjs +39 -0
- package/api/search/_adapter.test.mjs +173 -0
- package/api/search/_candidate-score.mjs +1 -1
- package/api/search/_entries.d.mts +11 -0
- package/api/search/_entries.mjs +35 -17
- package/api/search/_entries.test.mjs +48 -0
- package/api/search/_gather-docs.mjs +3 -3
- package/api/search/_gather-templates.d.mts +0 -1
- package/api/search/_gather-templates.mjs +25 -0
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.integration-block.test.mjs +100 -0
- package/api/search/search.mjs +6 -2
- package/api/search/search.test.mjs +14 -14
- package/api/template/template.mjs +5 -1
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/add-a-component.doc.mjs +1 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +1 -1
- package/assets/docs/tree/agent-guidance.doc.mjs +1 -1
- package/assets/docs/tree/{integrations.doc.mjs → authoring.doc.mjs} +15 -6
- package/assets/docs/tree/block-template.doc.mjs +1 -1
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/building-blocks.doc.mjs +2 -2
- package/assets/docs/tree/check-the-props.doc.mjs +1 -1
- package/assets/docs/tree/check-your-docs.doc.mjs +2 -2
- package/assets/docs/tree/checks.doc.mjs +2 -2
- package/assets/docs/tree/ci-and-containers.doc.mjs +13 -0
- package/assets/docs/tree/cli-command.doc.mjs +1 -1
- package/assets/docs/tree/cli.doc.mjs +1 -1
- package/assets/docs/tree/codemods.doc.mjs +1 -1
- package/assets/docs/tree/component-family.doc.mjs +1 -1
- package/assets/docs/tree/component-imports.doc.mjs +1 -1
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/configuration.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +1 -1
- package/assets/docs/tree/define-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/docs.doc.mjs +1 -1
- package/assets/docs/tree/document-the-template.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +1 -1
- package/assets/docs/{authoring.doc.mjs → tree/field-reference.doc.mjs} +4 -3
- package/assets/docs/tree/fonts-and-assets.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
- package/assets/docs/tree/global-integrations.doc.mjs +2 -2
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +4 -4
- package/assets/docs/tree/help.doc.mjs +2 -2
- package/assets/docs/tree/links.doc.mjs +1 -1
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +1 -1
- package/assets/docs/tree/publishing.doc.mjs +1 -1
- package/assets/docs/tree/quick-start.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +1 -1
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/ship.doc.mjs +2 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +1 -1
- package/assets/docs/tree/single-component.doc.mjs +1 -1
- package/assets/docs/tree/start-a-template.doc.mjs +1 -1
- package/assets/docs/tree/subcomponent.doc.mjs +1 -1
- package/assets/docs/tree/template-assets.doc.mjs +1 -1
- package/assets/docs/tree/template-doc-overview.doc.mjs +2 -2
- package/assets/docs/tree/template-fonts.doc.mjs +1 -1
- package/assets/docs/tree/template-grading-rubric.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 +1 -1
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/themes.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +1 -1
- package/assets/docs/tree/upgrading.doc.mjs +1 -1
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +5 -1
- package/assets/docs/tree/write-good-templates.doc.mjs +1 -1
- package/assets/docs/tree/write-the-template-file.doc.mjs +1 -1
- package/assets/docs/use-integrations.doc.mjs +120 -0
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/integration/integration.doc.mjs +1 -1
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/command-result-coverage.test.mjs +6 -5
- package/clients/cli/commands/build-theme.color-scheme.test.mjs +1 -1
- package/clients/cli/commands/{component/index.mjs → component.mjs} +37 -37
- package/clients/cli/commands/component.test.mjs +6 -6
- package/clients/cli/commands/docs.doc.mjs +2 -2
- package/clients/cli/commands/docs.mjs +1 -1
- package/clients/cli/commands/docs.test.mjs +14 -14
- package/clients/cli/commands/doctor-integration.test.mjs +49 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.mjs +10 -0
- package/clients/cli/commands/{hook/index.mjs → hook.mjs} +22 -22
- package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
- package/clients/cli/commands/integration.doc.mjs +1 -1
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/manifest.mjs +67 -0
- package/clients/cli/commands/outside-project.test.mjs +99 -0
- package/clients/cli/commands/postinstall.doc.mjs +23 -0
- package/clients/cli/commands/postinstall.mjs +31 -0
- package/clients/cli/commands/setup-nudge.test.mjs +17 -0
- package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
- package/clients/cli/index.mjs +35 -93
- package/clients/cli/lib/component-format.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +12 -7
- package/clients/cli/lib/exit-codes.test.mjs +5 -0
- package/clients/cli/lib/manifest.test.mjs +12 -0
- package/clients/cli/lib/welcome-box.mjs +50 -0
- package/foundation/agent-docs/agent-doc-state.d.mts +12 -0
- package/foundation/agent-docs/agent-doc-state.mjs +24 -2
- package/foundation/agent-docs/agent-docs.mjs +7 -6
- package/foundation/agent-docs/agent-docs.test.mjs +5 -4
- package/foundation/agent-docs/computer-agent-text.d.mts +39 -2
- package/foundation/agent-docs/computer-agent-text.mjs +135 -8
- package/foundation/agent-docs/computer-agent-text.test.mjs +99 -2
- package/foundation/discovery/authoring-self-docs.d.mts +7 -0
- package/foundation/discovery/authoring-self-docs.mjs +16 -4
- package/foundation/discovery/authoring-self-docs.test.mjs +15 -3
- package/foundation/discovery/authoring-surface.d.mts +1 -1
- package/foundation/discovery/authoring-surface.mjs +2 -2
- package/foundation/discovery/authoring-surface.test.mjs +1 -1
- package/foundation/discovery/cli-self-docs.d.mts +2 -1
- package/foundation/discovery/cli-self-docs.mjs +4 -3
- package/foundation/discovery/cli-self-docs.test.mjs +2 -2
- package/foundation/discovery/runner-commands.mjs +1 -0
- package/foundation/discovery/stray-pointers.test.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +21 -9
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +3 -2
- package/foundation/doc-compiler/tree.d.mts +32 -6
- package/foundation/doc-compiler/tree.mjs +77 -43
- package/foundation/doc-compiler/tree.test.mjs +7 -7
- package/foundation/fs/read-record.d.mts +18 -0
- package/foundation/fs/read-record.mjs +131 -0
- package/foundation/fs/read-record.test.mjs +77 -0
- package/foundation/integrations/cli-peer-version.d.mts +36 -0
- package/foundation/integrations/cli-peer-version.mjs +132 -0
- package/foundation/integrations/cli-peer-version.test.mjs +354 -0
- package/foundation/integrations/exports-subpaths.d.mts +57 -0
- package/foundation/integrations/exports-subpaths.mjs +113 -0
- package/foundation/integrations/public-imports.d.mts +118 -0
- package/foundation/integrations/public-imports.mjs +1769 -0
- package/foundation/integrations/public-imports.test.mjs +1793 -0
- package/foundation/release/cache.test.mjs +24 -21
- package/foundation/release/global-state.d.mts +8 -4
- package/foundation/release/global-state.mjs +4 -2
- package/foundation/release/notices.d.mts +62 -8
- package/foundation/release/notices.mjs +136 -25
- package/foundation/release/notices.test.mjs +21 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/text/string-utils.d.mts +2 -1
- package/foundation/text/string-utils.mjs +16 -5
- package/foundation/text/suggest-order.d.mts +72 -0
- package/foundation/text/suggest-order.mjs +363 -0
- package/foundation/text/suggest-order.test.mjs +259 -0
- package/package.json +9 -9
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
availableComputerIntegrations,
|
|
26
26
|
} from '../../foundation/config/project.mjs';
|
|
27
27
|
import {isOutsideProject} from '../../foundation/env/project-scope.mjs';
|
|
28
|
+
import {projectAddCommand} from '../../foundation/release/notices.mjs';
|
|
28
29
|
import {hostedRun} from '../../foundation/runtime/package-root.mjs';
|
|
29
30
|
import {
|
|
30
31
|
scanAllPackages,
|
|
@@ -274,17 +275,14 @@ const COMPUTER_SOURCE = 'installed for this computer';
|
|
|
274
275
|
* @param {Project | undefined} project
|
|
275
276
|
* @param {Array<{name: string}>} installed
|
|
276
277
|
* @param {Set<string>} declared
|
|
277
|
-
* @param {(name: string, version?: string) => string} add
|
|
278
278
|
* @returns {Promise<import('./discover.type.mjs').DiscoverAvailableEntry[]>}
|
|
279
279
|
*/
|
|
280
|
-
export async function computerAvailableEntries(
|
|
281
|
-
project,
|
|
282
|
-
installed,
|
|
283
|
-
declared,
|
|
284
|
-
add,
|
|
285
|
-
) {
|
|
280
|
+
export async function computerAvailableEntries(project, installed, declared) {
|
|
286
281
|
const cwd = project?.cwd ?? process.cwd();
|
|
287
282
|
if (isOutsideProject(cwd)) return [];
|
|
283
|
+
// The same command doctor names: in the project spec:AST-040 FR9 defines,
|
|
284
|
+
// and none where FR9 finds no project.
|
|
285
|
+
const add = projectAddCommand(cwd);
|
|
288
286
|
const have = new Set([...installed.map(pkg => pkg.name), ...declared]);
|
|
289
287
|
return (await availableComputerIntegrations(cwd, have)).map(c => ({
|
|
290
288
|
name: c.name,
|
|
@@ -292,7 +290,7 @@ export async function computerAvailableEntries(
|
|
|
292
290
|
...(c.version ? {version: c.version} : {}),
|
|
293
291
|
...(c.description ? {description: c.description} : {}),
|
|
294
292
|
source: COMPUTER_SOURCE,
|
|
295
|
-
install: add(c.name),
|
|
293
|
+
...(add ? {install: add(c.name)} : {}),
|
|
296
294
|
}));
|
|
297
295
|
}
|
|
298
296
|
|
package/api/docs/_adapter.d.mts
CHANGED
|
@@ -226,7 +226,7 @@ export function topicUp(entry: import("../../foundation/discovery/docs-discovery
|
|
|
226
226
|
export function placeLinks(tree: DocsTree, node: TreeNode): import("./docs.type.mjs").DocsLinks;
|
|
227
227
|
/**
|
|
228
228
|
* The moves a topic read offers: from its place in the tree, where a guide
|
|
229
|
-
* sits in its namespace and a flat topic in
|
|
229
|
+
* sits in its namespace and a flat topic in its topic level.
|
|
230
230
|
* @param {DocsCatalog} catalog
|
|
231
231
|
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
232
232
|
* @returns {Promise<import('./docs.type.mjs').DocsLinks>}
|
|
@@ -290,7 +290,7 @@ export function holdsOwnName(tree: DocsTree, catalog: DocsCatalog, entry: import
|
|
|
290
290
|
/**
|
|
291
291
|
* The doc that took a flat topic's route in the docs tree, when it is not
|
|
292
292
|
* that topic (spec:AST-046 FR11): the CLI keeps its routes, such as `cli`
|
|
293
|
-
* and `
|
|
293
|
+
* and `guides`, and a namespace keeps its route over a topic of the same
|
|
294
294
|
* name. Null when the topic owns its route, or the tree has no node there.
|
|
295
295
|
* @param {DocsTree} tree
|
|
296
296
|
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
package/api/docs/_adapter.mjs
CHANGED
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
cliDocSection,
|
|
53
53
|
} from '../../foundation/discovery/cli-self-docs.mjs';
|
|
54
54
|
import {
|
|
55
|
+
AUTHORING_REFERENCE_ROUTE,
|
|
55
56
|
loadAuthoringSelfDocs,
|
|
56
57
|
schemaFieldTable,
|
|
57
58
|
selfDocSection,
|
|
@@ -70,6 +71,7 @@ import {
|
|
|
70
71
|
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
71
72
|
import {AstryxError} from '../error.mjs';
|
|
72
73
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
74
|
+
import {orderRouteSuggestions} from '../../foundation/text/suggest-order.mjs';
|
|
73
75
|
import {formatCliCommand} from '../../foundation/env/package-manager.mjs';
|
|
74
76
|
|
|
75
77
|
export {OVERLAY_LANGUAGES, overlayLanguages};
|
|
@@ -385,7 +387,7 @@ export function projectTree(catalog, {fresh = false} = {}) {
|
|
|
385
387
|
let cliTreeInputs;
|
|
386
388
|
|
|
387
389
|
/**
|
|
388
|
-
* Every flat topic in the catalog, as the tree's
|
|
390
|
+
* Every flat topic in the catalog, as the tree's topic levels read it.
|
|
389
391
|
* @param {DocsCatalog} catalog
|
|
390
392
|
* @returns {Promise<import('../../foundation/doc-compiler/tree.mjs').TreeTopicInput[]>}
|
|
391
393
|
*/
|
|
@@ -394,12 +396,13 @@ async function flatTopicInputs(catalog) {
|
|
|
394
396
|
const topics = [];
|
|
395
397
|
for (const entry of catalog.entries()) {
|
|
396
398
|
const aliases = catalog.aliasesOf(entry);
|
|
397
|
-
let {title, description} = entry;
|
|
398
|
-
if (title == null || description == null) {
|
|
399
|
+
let {title, description, category} = entry;
|
|
400
|
+
if (title == null || description == null || category === undefined) {
|
|
399
401
|
try {
|
|
400
402
|
const file = await loadTopicFile(entry.path, null);
|
|
401
403
|
title ??= file.doc?.title;
|
|
402
404
|
description ??= file.doc?.description;
|
|
405
|
+
category ??= file.doc?.category;
|
|
403
406
|
} catch {
|
|
404
407
|
// A topic that does not load is reported where it is read.
|
|
405
408
|
}
|
|
@@ -410,6 +413,7 @@ async function flatTopicInputs(catalog) {
|
|
|
410
413
|
name: entry.name,
|
|
411
414
|
title: title ?? entry.name,
|
|
412
415
|
summary: description ?? '',
|
|
416
|
+
category: category ?? null,
|
|
413
417
|
source: `${entry.package}:${entry.name}`,
|
|
414
418
|
...(aliases.length > 0 ? {aliases} : {}),
|
|
415
419
|
});
|
|
@@ -419,7 +423,7 @@ async function flatTopicInputs(catalog) {
|
|
|
419
423
|
|
|
420
424
|
/**
|
|
421
425
|
* The CLI's tree, each configured integration's namespaces and guides, and
|
|
422
|
-
* every flat topic in the generated
|
|
426
|
+
* every flat topic in the generated level for its category.
|
|
423
427
|
* @param {DocsCatalog} catalog
|
|
424
428
|
* @param {boolean} fresh
|
|
425
429
|
* @returns {Promise<DocsTree>}
|
|
@@ -509,23 +513,22 @@ function identitiesOf(tree) {
|
|
|
509
513
|
}
|
|
510
514
|
|
|
511
515
|
/**
|
|
512
|
-
* The CLI's authoring docs, by kind and name.
|
|
513
|
-
* each as one section keyed by its name, so a
|
|
514
|
-
* Loaded once per process, like the CLI's
|
|
516
|
+
* The CLI's authoring docs, by kind and name. The field reference under
|
|
517
|
+
* `astryx docs authoring` reads each as one section keyed by its name, so a
|
|
518
|
+
* link to one opens that section. Loaded once per process, like the CLI's
|
|
519
|
+
* tree files.
|
|
515
520
|
* @type {Promise<Map<string, any>> | undefined}
|
|
516
521
|
*/
|
|
517
522
|
let authoringDocs;
|
|
518
523
|
|
|
519
524
|
/**
|
|
520
|
-
* The CLI authoring doc a link names
|
|
521
|
-
*
|
|
522
|
-
* @param {DocsCatalog} catalog
|
|
525
|
+
* The CLI authoring doc a link names. The `authoring` namespace is the CLI's
|
|
526
|
+
* own, so no integration can take its route.
|
|
523
527
|
* @param {string} kind
|
|
524
528
|
* @param {string} name
|
|
525
529
|
* @returns {Promise<any | null>}
|
|
526
530
|
*/
|
|
527
|
-
async function authoringDoc(
|
|
528
|
-
if (catalog.resolve('authoring')?.package !== CLI_PROVIDER_ID) return null;
|
|
531
|
+
async function authoringDoc(kind, name) {
|
|
529
532
|
authoringDocs ??= loadAuthoringSelfDocs().then(
|
|
530
533
|
({loaded}) =>
|
|
531
534
|
new Map(loaded.map(({doc}) => [`${doc.type}\u0000${doc.name}`, doc])),
|
|
@@ -611,14 +614,14 @@ function docFinderOver(catalog, tree, fromProvider, summaries = true) {
|
|
|
611
614
|
}
|
|
612
615
|
const authored =
|
|
613
616
|
provider === CLI_PROVIDER_ID
|
|
614
|
-
? await authoringDoc(
|
|
617
|
+
? await authoringDoc(parsed.kind, parsed.name)
|
|
615
618
|
: null;
|
|
616
619
|
if (authored) {
|
|
617
620
|
return {
|
|
618
621
|
link: {
|
|
619
622
|
target,
|
|
620
623
|
id: createDocId(provider, authored.type, authored.name),
|
|
621
|
-
route:
|
|
624
|
+
route: AUTHORING_REFERENCE_ROUTE,
|
|
622
625
|
title: authored.displayName ?? authored.name,
|
|
623
626
|
summary: authored.description ?? '',
|
|
624
627
|
command: `astryx docs authoring ${authored.name}`,
|
|
@@ -1428,7 +1431,7 @@ export function placeLinks(tree, node) {
|
|
|
1428
1431
|
|
|
1429
1432
|
/**
|
|
1430
1433
|
* The moves a topic read offers: from its place in the tree, where a guide
|
|
1431
|
-
* sits in its namespace and a flat topic in
|
|
1434
|
+
* sits in its namespace and a flat topic in its topic level.
|
|
1432
1435
|
* @param {DocsCatalog} catalog
|
|
1433
1436
|
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
1434
1437
|
* @returns {Promise<import('./docs.type.mjs').DocsLinks>}
|
|
@@ -1526,7 +1529,7 @@ function treeArgument(catalog, tree, node) {
|
|
|
1526
1529
|
/**
|
|
1527
1530
|
* The doc that took a flat topic's route in the docs tree, when it is not
|
|
1528
1531
|
* that topic (spec:AST-046 FR11): the CLI keeps its routes, such as `cli`
|
|
1529
|
-
* and `
|
|
1532
|
+
* and `guides`, and a namespace keeps its route over a topic of the same
|
|
1530
1533
|
* name. Null when the topic owns its route, or the tree has no node there.
|
|
1531
1534
|
* @param {DocsTree} tree
|
|
1532
1535
|
* @param {import('../../foundation/discovery/docs-discovery.mjs').DocsTopicEntry} entry
|
|
@@ -1540,6 +1543,35 @@ export function routeOwner(tree, entry) {
|
|
|
1540
1543
|
: node;
|
|
1541
1544
|
}
|
|
1542
1545
|
|
|
1546
|
+
/**
|
|
1547
|
+
* Routes that moved, old prefix first: the integration guides moved from
|
|
1548
|
+
* `cli/integrations` (and, before that, the `cli-integrations` topic) into
|
|
1549
|
+
* `authoring`, the one home for integration authors.
|
|
1550
|
+
* Only the not-found error reads this, to name where a doc went; an old route
|
|
1551
|
+
* opens nothing.
|
|
1552
|
+
*/
|
|
1553
|
+
const MOVED_ROUTES = [
|
|
1554
|
+
['cli/integrations', 'authoring'],
|
|
1555
|
+
['cli-integrations', 'authoring'],
|
|
1556
|
+
];
|
|
1557
|
+
|
|
1558
|
+
/**
|
|
1559
|
+
* The node an old route moved to, or null.
|
|
1560
|
+
* @param {unknown} topic
|
|
1561
|
+
* @param {DocsTree} tree
|
|
1562
|
+
* @returns {TreeNode | null}
|
|
1563
|
+
*/
|
|
1564
|
+
function movedRoute(topic, tree) {
|
|
1565
|
+
if (typeof topic !== 'string') return null;
|
|
1566
|
+
const wanted = topic.toLowerCase();
|
|
1567
|
+
for (const [from, to] of MOVED_ROUTES) {
|
|
1568
|
+
if (wanted !== from && !wanted.startsWith(`${from}/`)) continue;
|
|
1569
|
+
const node = tree.getFolded(`${to}${wanted.slice(from.length)}`);
|
|
1570
|
+
if (node) return node;
|
|
1571
|
+
}
|
|
1572
|
+
return null;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1543
1575
|
/**
|
|
1544
1576
|
* The error for a docs argument that names nothing. For a route, it suggests
|
|
1545
1577
|
* the children of the deepest namespace the route reaches; otherwise, every
|
|
@@ -1572,8 +1604,7 @@ export async function unknownTopicError(topic, catalog) {
|
|
|
1572
1604
|
}
|
|
1573
1605
|
if (suggestions.length === 0 && typeof topic === 'string') {
|
|
1574
1606
|
// The docs whose own name it is (`doctor` is cli/commands/doctor), or whose
|
|
1575
|
-
// route it spells with hyphens (`cli-
|
|
1576
|
-
// it moved to cli/integrations).
|
|
1607
|
+
// route it spells with hyphens (`cli-host-entry` is cli/host-entry).
|
|
1577
1608
|
const wanted = topic.toLowerCase();
|
|
1578
1609
|
suggestions = [...tree.nodes.values()]
|
|
1579
1610
|
.filter(
|
|
@@ -1592,6 +1623,22 @@ export async function unknownTopicError(topic, catalog) {
|
|
|
1592
1623
|
...catalog.names().map(name => ({name, reason: 'available topic'})),
|
|
1593
1624
|
];
|
|
1594
1625
|
}
|
|
1626
|
+
if (typeof topic === 'string') {
|
|
1627
|
+
suggestions = orderRouteSuggestions(topic, suggestions);
|
|
1628
|
+
}
|
|
1629
|
+
// A route that moved names where it went, ahead of the usual suggestions
|
|
1630
|
+
// (spec:AST-046 FR9, FR6).
|
|
1631
|
+
const moved = movedRoute(topic, tree);
|
|
1632
|
+
if (moved) {
|
|
1633
|
+
return new AstryxError(
|
|
1634
|
+
`Unknown topic "${String(topic)}". It moved to "${moved.route}"${notLoaded(catalog)}`,
|
|
1635
|
+
[
|
|
1636
|
+
{name: moved.route, reason: moved.summary},
|
|
1637
|
+
...suggestions.filter(entry => entry.name !== moved.route),
|
|
1638
|
+
],
|
|
1639
|
+
ERROR_CODES.ERR_UNKNOWN_TOPIC,
|
|
1640
|
+
);
|
|
1641
|
+
}
|
|
1595
1642
|
return new AstryxError(
|
|
1596
1643
|
`Unknown topic "${String(topic)}"${notLoaded(catalog)}`,
|
|
1597
1644
|
suggestions,
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Every Core doc has a named home in the docs tree (spec:AST-046 FR12).
|
|
5
|
+
*
|
|
6
|
+
* A reader sees a doc's home in its path (`Guides › Getting started`) and in
|
|
7
|
+
* its Up move. A flat Core topic sits in Guides or Foundations by the
|
|
8
|
+
* category it declares, so a new topic with no category, or one the levels
|
|
9
|
+
* do not know, fails here instead of landing in a catch-all. The integration
|
|
10
|
+
* guides and their field reference live under `authoring`, and the routes
|
|
11
|
+
* they left name where they went.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {describe, expect, it} from 'vitest';
|
|
15
|
+
import {docs} from './docs.mjs';
|
|
16
|
+
import {TOPIC_LEVELS} from '../../foundation/doc-compiler/tree.mjs';
|
|
17
|
+
|
|
18
|
+
const CLI = '@astryxdesign/cli';
|
|
19
|
+
const SLOW = 60_000;
|
|
20
|
+
|
|
21
|
+
describe('every Core doc has a named home', () => {
|
|
22
|
+
it(
|
|
23
|
+
'puts each flat Core topic in Guides or Foundations by its category',
|
|
24
|
+
async () => {
|
|
25
|
+
const list = await docs();
|
|
26
|
+
const core = list.data.filter(topic => topic.package === CLI);
|
|
27
|
+
expect(core.length).toBeGreaterThan(10);
|
|
28
|
+
/** @type {string[]} */
|
|
29
|
+
const unfiled = [];
|
|
30
|
+
for (const topic of core) {
|
|
31
|
+
const read = await docs(topic.topic);
|
|
32
|
+
const {category} = read.data;
|
|
33
|
+
if (category !== 'guide' && category !== 'foundations') {
|
|
34
|
+
unfiled.push(`${topic.topic} (category ${String(category)})`);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const level =
|
|
38
|
+
category === 'foundations'
|
|
39
|
+
? TOPIC_LEVELS.foundations
|
|
40
|
+
: TOPIC_LEVELS.guides;
|
|
41
|
+
expect(read.data.links.up, topic.topic).toBe(
|
|
42
|
+
`astryx docs ${level.route}`,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
expect(unfiled, 'Core topics with no home: give each a category').toEqual(
|
|
46
|
+
[],
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
SLOW,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
it(
|
|
53
|
+
'lists each level under a plain name, and no catch-all',
|
|
54
|
+
async () => {
|
|
55
|
+
const list = await docs();
|
|
56
|
+
const roots = (list.meta.namespaces ?? []).map(entry => entry.topic);
|
|
57
|
+
expect(roots).toEqual(expect.arrayContaining(['guides', 'foundations']));
|
|
58
|
+
expect(roots).not.toContain('unorganized');
|
|
59
|
+
const guides = await docs('guides');
|
|
60
|
+
expect(guides.data).toMatchObject({route: 'guides', title: 'Guides'});
|
|
61
|
+
expect(guides.data.slots[0].children.map(child => child.route)).toEqual(
|
|
62
|
+
expect.arrayContaining(['getting-started', 'principles', 'theme']),
|
|
63
|
+
);
|
|
64
|
+
const foundations = await docs('foundations');
|
|
65
|
+
expect(foundations.data.title).toBe('Foundations');
|
|
66
|
+
expect(
|
|
67
|
+
foundations.data.slots[0].children.map(child => child.route),
|
|
68
|
+
).toEqual(expect.arrayContaining(['color', 'icons', 'spacing']));
|
|
69
|
+
await expect(docs('unorganized')).rejects.toMatchObject({
|
|
70
|
+
code: 'ERR_UNKNOWN_TOPIC',
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
SLOW,
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
it(
|
|
77
|
+
'keeps everything for integration authors under authoring, and names where an old route went',
|
|
78
|
+
async () => {
|
|
79
|
+
const authoring = await docs('authoring');
|
|
80
|
+
expect(authoring.data).toMatchObject({
|
|
81
|
+
route: 'authoring',
|
|
82
|
+
kind: 'namespace',
|
|
83
|
+
breadcrumb: [],
|
|
84
|
+
links: {up: 'astryx docs'},
|
|
85
|
+
});
|
|
86
|
+
const children = authoring.data.slots.flatMap(slot =>
|
|
87
|
+
slot.children.map(child => child.route),
|
|
88
|
+
);
|
|
89
|
+
expect(children).toEqual(
|
|
90
|
+
expect.arrayContaining([
|
|
91
|
+
'authoring/quick-start',
|
|
92
|
+
'authoring/building-blocks',
|
|
93
|
+
'authoring/ship',
|
|
94
|
+
'authoring/help',
|
|
95
|
+
'authoring/field-reference',
|
|
96
|
+
]),
|
|
97
|
+
);
|
|
98
|
+
// Every field reference section still opens from the namespace by its
|
|
99
|
+
// key, as `astryx docs authoring <name>` did on the topic (FR13).
|
|
100
|
+
const reference = await docs('authoring/field-reference', undefined, {
|
|
101
|
+
index: true,
|
|
102
|
+
});
|
|
103
|
+
const keys = reference.data.sections.map(section => section.id);
|
|
104
|
+
expect(keys.length).toBeGreaterThan(15);
|
|
105
|
+
for (const key of keys) {
|
|
106
|
+
const section = await docs('authoring', key);
|
|
107
|
+
expect(section.type, key).toBe('docs.detail.section');
|
|
108
|
+
expect(section.data.id, key).toBe(key);
|
|
109
|
+
}
|
|
110
|
+
for (const [old, now] of [
|
|
111
|
+
['cli/integrations', 'authoring'],
|
|
112
|
+
['cli/integrations/quick-start', 'authoring/quick-start'],
|
|
113
|
+
['cli/integrations/ship/publishing', 'authoring/ship/publishing'],
|
|
114
|
+
]) {
|
|
115
|
+
const error = await docs(old).catch(e => e);
|
|
116
|
+
expect(error).toMatchObject({
|
|
117
|
+
code: 'ERR_UNKNOWN_TOPIC',
|
|
118
|
+
message: expect.stringContaining(`It moved to "${now}"`),
|
|
119
|
+
});
|
|
120
|
+
// The new route comes first, ahead of the suggestions any unknown
|
|
121
|
+
// route gets (FR6).
|
|
122
|
+
expect(error.suggestions[0]).toMatchObject({name: now});
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
SLOW,
|
|
126
|
+
);
|
|
127
|
+
});
|
package/api/docs/docs.doc.mjs
CHANGED
|
@@ -28,7 +28,7 @@ export const doc = {
|
|
|
28
28
|
'`cli/api` returns its children one level down (`depth` reads as many ' +
|
|
29
29
|
'levels as asked, and `detail` how much of each doc below), a typed doc such as ' +
|
|
30
30
|
"`cli/api/functions/search` returns its content, and a guide the tree " +
|
|
31
|
-
'places (`
|
|
31
|
+
'places (`authoring/quick-start`) reads like any topic. ' +
|
|
32
32
|
'Every read but the list carries `links`, the commands that move from it: ' +
|
|
33
33
|
'`up` to the level it sits in, `previous` and `next` to its neighbors, and, ' +
|
|
34
34
|
'for a typed doc, `related` to the docs it names (its command or function, ' +
|
|
@@ -162,12 +162,12 @@ export const doc = {
|
|
|
162
162
|
},
|
|
163
163
|
{
|
|
164
164
|
label: 'A namespace and everything below it, in full',
|
|
165
|
-
code: "await docs('
|
|
165
|
+
code: "await docs('authoring', undefined, {depth: 'all', detail: 'full'});",
|
|
166
166
|
},
|
|
167
167
|
{label: 'One API function', code: "await docs('cli/api/functions/search');"},
|
|
168
168
|
{
|
|
169
169
|
label: 'A whole guide from the docs tree',
|
|
170
|
-
code: "await docs('
|
|
170
|
+
code: "await docs('authoring/quick-start');",
|
|
171
171
|
},
|
|
172
172
|
{label: 'One section by key', code: "await docs('spacing', 'scale');"},
|
|
173
173
|
],
|
package/api/docs/docs.test.mjs
CHANGED
|
@@ -93,7 +93,7 @@ describe('docs() dispatcher routing', () => {
|
|
|
93
93
|
|
|
94
94
|
it("lists the docs tree's namespaces in meta, so every data entry reads as a topic", async () => {
|
|
95
95
|
const res = await docs();
|
|
96
|
-
expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'global', 'internationalization', 'layout', 'migration', 'styling', 'styling-libraries', 'tokens', 'typography'
|
|
96
|
+
expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['authoring', 'cli', 'foundations', 'global', 'guides', 'internationalization', 'layout', 'migration', 'styling', 'styling-libraries', 'tokens', 'typography']);
|
|
97
97
|
for (const entry of res.data) {
|
|
98
98
|
expect((await docs(entry.topic)).type).toBe('docs.detail');
|
|
99
99
|
}
|
|
@@ -158,8 +158,8 @@ describe('docs() dispatcher routing', () => {
|
|
|
158
158
|
}, SLOW);
|
|
159
159
|
|
|
160
160
|
it('a guide the tree places reads like a topic: the whole doc, its index, a section', async () => {
|
|
161
|
-
//
|
|
162
|
-
const integrations = await docs('
|
|
161
|
+
// authoring is a namespace of short guides; each guide reads like a topic.
|
|
162
|
+
const integrations = await docs('authoring');
|
|
163
163
|
expect(integrations.type).toBe('docs.node');
|
|
164
164
|
const guide = placedGuide(integrations.data);
|
|
165
165
|
expect((await docs(guide)).type).toBe('docs.detail');
|
|
@@ -178,7 +178,7 @@ describe('docs() dispatcher routing', () => {
|
|
|
178
178
|
expect(leaf.links.up).toBe('astryx docs cli/api/functions');
|
|
179
179
|
expect(leaf.links.previous).toMatch(/^astryx docs cli\/api\/functions\/[a-z-]+$/);
|
|
180
180
|
expect(leaf.links.next).toMatch(/^astryx docs cli\/api\/functions\/[a-z-]+$/);
|
|
181
|
-
const integrations = (await docs('
|
|
181
|
+
const integrations = (await docs('authoring')).data;
|
|
182
182
|
const guide = placedGuide(integrations);
|
|
183
183
|
const siblings = integrations.slots
|
|
184
184
|
.find(slot => slot.children.some(child => child.route === guide))
|
|
@@ -187,7 +187,7 @@ describe('docs() dispatcher routing', () => {
|
|
|
187
187
|
const index = await docs(guide, undefined, {index: true});
|
|
188
188
|
// A guide moves across its namespace's slot, as any tree node does.
|
|
189
189
|
expect(index.data.links).toEqual({
|
|
190
|
-
up: 'astryx docs
|
|
190
|
+
up: 'astryx docs authoring',
|
|
191
191
|
...(at > 0 ? {previous: `astryx docs ${siblings[at - 1]}`} : {}),
|
|
192
192
|
...(at < siblings.length - 1
|
|
193
193
|
? {next: `astryx docs ${siblings[at + 1]}`}
|
|
@@ -204,16 +204,22 @@ describe('docs() dispatcher routing', () => {
|
|
|
204
204
|
expect(end.links.previous).toBe(
|
|
205
205
|
`astryx docs ${guide} ${index.data.sections.at(-2).id}`,
|
|
206
206
|
);
|
|
207
|
-
// A flat topic's home is the
|
|
207
|
+
// A flat topic's home is the level for its category, and it moves across it.
|
|
208
208
|
const flat = (await docs('principles')).data.links;
|
|
209
|
-
expect(flat.up).toBe('astryx docs
|
|
209
|
+
expect(flat.up).toBe('astryx docs guides');
|
|
210
210
|
expect(flat.previous).toMatch(/^astryx docs [a-z-]+$/);
|
|
211
211
|
expect(flat.next).toMatch(/^astryx docs [a-z-]+$/);
|
|
212
|
-
const
|
|
213
|
-
expect(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
const guides = (await docs('guides')).data;
|
|
213
|
+
expect(guides).toMatchObject({id: null, kind: 'namespace', links: {up: 'astryx docs'}});
|
|
214
|
+
const foundations = (await docs('foundations')).data;
|
|
215
|
+
expect(foundations).toMatchObject({id: null, kind: 'namespace', links: {up: 'astryx docs'}});
|
|
216
|
+
// Between them the two levels hold every flat topic, each in list order.
|
|
217
|
+
const topics = (await docs()).data.map(entry => entry.topic);
|
|
218
|
+
const held = [guides, foundations].map(level => level.slots[0].children.map(child => child.route));
|
|
219
|
+
for (const routes of held) {
|
|
220
|
+
expect(routes).toEqual(topics.filter(topic => routes.includes(topic)));
|
|
221
|
+
}
|
|
222
|
+
expect(held.flat().sort()).toEqual([...topics].sort());
|
|
217
223
|
}, SLOW);
|
|
218
224
|
|
|
219
225
|
it('names a node by its doc identity; a generated level has id null', async () => {
|
|
@@ -240,10 +246,9 @@ describe('docs() dispatcher routing', () => {
|
|
|
240
246
|
}, SLOW);
|
|
241
247
|
|
|
242
248
|
it("the guide's old flat name is gone, and its error names the new route", async () => {
|
|
243
|
-
await
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
});
|
|
249
|
+
const error = await docs('cli-integrations').catch(e => e);
|
|
250
|
+
expect(error.code).toBe('ERR_UNKNOWN_TOPIC');
|
|
251
|
+
expect(error.suggestions[0]).toMatchObject({name: 'authoring'});
|
|
247
252
|
expect((await docs()).data.map(entry => entry.topic)).not.toContain(
|
|
248
253
|
'cli-integrations',
|
|
249
254
|
);
|
|
@@ -253,11 +258,16 @@ describe('docs() dispatcher routing', () => {
|
|
|
253
258
|
const err = await docs('cli', 'zzzz-nope').catch(e => e);
|
|
254
259
|
expect(err).toBeInstanceOf(AstryxError);
|
|
255
260
|
expect(err.code).toBe('ERR_UNKNOWN_SECTION');
|
|
256
|
-
// It names every guide below the namespace, at any depth.
|
|
257
261
|
const names = err.suggestions.map(s => s.name);
|
|
258
262
|
expect(names).toContain('cli/component-lookups');
|
|
259
|
-
expect(names).toContain('cli/integrations/quick-start');
|
|
260
263
|
expect(names.every(name => name.startsWith('cli/'))).toBe(true);
|
|
264
|
+
// It names every guide below the namespace, at any depth.
|
|
265
|
+
const deep = await docs('authoring', 'zzzz-nope').catch(e => e);
|
|
266
|
+
expect(deep.code).toBe('ERR_UNKNOWN_SECTION');
|
|
267
|
+
const below = deep.suggestions.map(s => s.name);
|
|
268
|
+
expect(below).toContain('authoring/quick-start');
|
|
269
|
+
expect(below).toContain('authoring/building-blocks/components/add-a-component');
|
|
270
|
+
expect(below.every(name => name.startsWith('authoring/'))).toBe(true);
|
|
261
271
|
}, SLOW);
|
|
262
272
|
|
|
263
273
|
it('an unknown route suggests the children of the deepest namespace it reaches', async () => {
|
|
@@ -246,7 +246,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
246
246
|
});
|
|
247
247
|
scaffold({
|
|
248
248
|
...kit(),
|
|
249
|
-
'
|
|
249
|
+
'guides.doc.mjs': {...NAMESPACE, name: 'guides', title: 'Mine', summary: 'Mine.'},
|
|
250
250
|
'use-a-theme.doc.mjs': {...NAMESPACE, name: 'use-a-theme', title: 'Acme use-a-theme', summary: 'Acme use-a-theme.'},
|
|
251
251
|
'cli.doc.mjs': flat('cli'),
|
|
252
252
|
});
|
|
@@ -254,26 +254,26 @@ describe('integration docs in the docs tree', () => {
|
|
|
254
254
|
expect(listed.meta.namespaces).toEqual(
|
|
255
255
|
expect.arrayContaining([
|
|
256
256
|
expect.objectContaining({topic: 'cli', package: '@astryxdesign/cli'}),
|
|
257
|
-
expect.objectContaining({topic: '
|
|
257
|
+
expect.objectContaining({topic: 'guides', package: '@astryxdesign/cli'}),
|
|
258
258
|
]),
|
|
259
259
|
);
|
|
260
|
-
expect(listed.meta.namespaces.filter(n => ['use-a-theme', '
|
|
260
|
+
expect(listed.meta.namespaces.filter(n => ['use-a-theme', 'guides'].includes(n.topic) && n.package === '@acme/kit')).toEqual([]);
|
|
261
261
|
expect(listed.data.map(entry => entry.topic)).not.toContain('cli');
|
|
262
262
|
// Each name opens the CLI's doc, and a CLI topic keeps its home.
|
|
263
263
|
expect((await docs('cli', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'cli', package: '@astryxdesign/cli'});
|
|
264
|
-
expect((await docs('
|
|
264
|
+
expect((await docs('guides', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'guides', package: '@astryxdesign/cli'});
|
|
265
265
|
const tokens = await docs('use-a-theme', undefined, {cwd: tmpDir});
|
|
266
266
|
expect(tokens.type).toBe('docs.detail');
|
|
267
|
-
expect(tokens.data.links.up).toBe('astryx docs
|
|
267
|
+
expect(tokens.data.links.up).toBe('astryx docs guides');
|
|
268
268
|
// The project doctor and the package doctor both name the claims.
|
|
269
269
|
const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
|
|
270
270
|
expect(check.status).toBe('warn');
|
|
271
|
-
expect(check.message).toContain('takes the route "
|
|
271
|
+
expect(check.message).toContain('takes the route "guides", which the CLI\'s own docs keep');
|
|
272
272
|
expect(check.message).toContain('takes the route "use-a-theme"');
|
|
273
273
|
expect(check.message).toContain('both have the route "cli"');
|
|
274
274
|
const result = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
|
|
275
275
|
const graph = result.data.issues.filter(issue => issue.code === 'invalid_doc_graph').map(issue => issue.message).join('\n');
|
|
276
|
-
expect(graph).toContain('takes the route "
|
|
276
|
+
expect(graph).toContain('takes the route "guides"');
|
|
277
277
|
expect(graph).toContain('takes the route "use-a-theme"');
|
|
278
278
|
expect(graph).toContain('route "cli"');
|
|
279
279
|
}, SLOW);
|
|
@@ -294,16 +294,16 @@ describe('integration docs in the docs tree', () => {
|
|
|
294
294
|
const nested = path.join(tmpDir, 'node_modules', '@acme', 'kit', 'docs', 'nested');
|
|
295
295
|
fs.mkdirSync(nested, {recursive: true});
|
|
296
296
|
fs.writeFileSync(
|
|
297
|
-
path.join(nested, 'caps-
|
|
298
|
-
`export const docs = ${JSON.stringify(flat('
|
|
297
|
+
path.join(nested, 'caps-guides.doc.mjs'),
|
|
298
|
+
`export const docs = ${JSON.stringify(flat('Guides'), null, 2)};\n`,
|
|
299
299
|
);
|
|
300
300
|
fs.writeFileSync(
|
|
301
301
|
path.join(nested, 'caps-use-a-theme.doc.mjs'),
|
|
302
302
|
`export const docs = ${JSON.stringify(flat('USE-A-THEME'), null, 2)};\n`,
|
|
303
303
|
);
|
|
304
304
|
expect((await docs('cli', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'cli', package: '@astryxdesign/cli'});
|
|
305
|
-
expect((await docs('
|
|
306
|
-
expect((await docs('theme', undefined, {cwd: tmpDir, index: true})).data.links.up).toBe('astryx docs
|
|
305
|
+
expect((await docs('guides', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'guides', package: '@astryxdesign/cli'});
|
|
306
|
+
expect((await docs('theme', undefined, {cwd: tmpDir, index: true})).data.links.up).toBe('astryx docs guides');
|
|
307
307
|
const listed = await docs(undefined, undefined, {cwd: tmpDir});
|
|
308
308
|
expect(listed.data.map(entry => entry.topic.toLowerCase())).not.toContain('cli');
|
|
309
309
|
// Search does not offer a topic whose route another doc owns.
|
|
@@ -314,10 +314,10 @@ describe('integration docs in the docs tree', () => {
|
|
|
314
314
|
const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
|
|
315
315
|
expect(check.status).toBe('warn');
|
|
316
316
|
expect(check.message).toContain('route "CLI"');
|
|
317
|
-
expect(check.message).toContain('takes the route "
|
|
317
|
+
expect(check.message).toContain('takes the route "Guides"');
|
|
318
318
|
// `USE-A-THEME` is the CLI's topic `use-a-theme` in another spelling: the CLI's wins.
|
|
319
319
|
const tokens = await docs('USE-A-THEME', undefined, {cwd: tmpDir, index: true});
|
|
320
|
-
expect(tokens.data).toMatchObject({name: 'use-a-theme', links: {up: 'astryx docs
|
|
320
|
+
expect(tokens.data).toMatchObject({name: 'use-a-theme', links: {up: 'astryx docs guides'}});
|
|
321
321
|
expect(tokens.data.title).not.toBe('Acme USE-A-THEME');
|
|
322
322
|
const result = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
|
|
323
323
|
const graph = result.data.issues
|
|
@@ -325,7 +325,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
325
325
|
.map(issue => issue.message)
|
|
326
326
|
.join('\n');
|
|
327
327
|
expect(graph).toContain('route "CLI"');
|
|
328
|
-
expect(graph).toContain('takes the route "
|
|
328
|
+
expect(graph).toContain('takes the route "Guides"');
|
|
329
329
|
}, SLOW);
|
|
330
330
|
|
|
331
331
|
it("keeps a replaced name for the topic that replaces it, over another integration's namespace", async () => {
|
|
@@ -420,9 +420,9 @@ describe('integration docs in the docs tree', () => {
|
|
|
420
420
|
scaffold({
|
|
421
421
|
...kit(),
|
|
422
422
|
'a-cli.doc.mjs': flat('cli'),
|
|
423
|
-
'a-
|
|
423
|
+
'a-guides.doc.mjs': flat('Guides'),
|
|
424
424
|
'z-b2.doc.mjs': flat('b2', {replaces: 'cli'}),
|
|
425
|
-
'z-u2.doc.mjs': flat('u2', {replaces: '
|
|
425
|
+
'z-u2.doc.mjs': flat('u2', {replaces: 'Guides'}),
|
|
426
426
|
});
|
|
427
427
|
// Another package carries the chain on: c3 replaces b2, which replaced cli.
|
|
428
428
|
const three = path.join(tmpDir, 'node_modules', '@acme', 'three');
|
|
@@ -440,8 +440,8 @@ describe('integration docs in the docs tree', () => {
|
|
|
440
440
|
for (const name of ['cli', 'CLI']) {
|
|
441
441
|
expect((await docs(name, undefined, {cwd: tmpDir})).data).toMatchObject({route: 'cli', package: '@astryxdesign/cli'});
|
|
442
442
|
}
|
|
443
|
-
for (const name of ['
|
|
444
|
-
expect((await docs(name, undefined, {cwd: tmpDir})).data).toMatchObject({route: '
|
|
443
|
+
for (const name of ['guides', 'GUIDES']) {
|
|
444
|
+
expect((await docs(name, undefined, {cwd: tmpDir})).data).toMatchObject({route: 'guides', package: '@astryxdesign/cli'});
|
|
445
445
|
}
|
|
446
446
|
// The replacement still answers to its own names.
|
|
447
447
|
for (const name of ['b2', 'c3']) {
|
|
@@ -456,7 +456,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
456
456
|
const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
|
|
457
457
|
expect(check.status).toBe('warn');
|
|
458
458
|
expect(check.message).toContain('The topic "c3" answers to "cli" through replaces');
|
|
459
|
-
expect(check.message).toContain('The topic "u2" answers to "
|
|
459
|
+
expect(check.message).toContain('The topic "u2" answers to "guides" through replaces');
|
|
460
460
|
const inPackage = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
|
|
461
461
|
const graph = inPackage.data.issues
|
|
462
462
|
.filter(issue => issue.code === 'invalid_doc_graph')
|
|
@@ -519,7 +519,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
519
519
|
});
|
|
520
520
|
const {data} = await docs('theme', 'acme-theming-notes', {cwd: tmpDir});
|
|
521
521
|
// `generic:integrations` is the extension's own guide, never the CLI's
|
|
522
|
-
// `
|
|
522
|
+
// `authoring`; a provider-qualified link reaches the CLI's topic.
|
|
523
523
|
expect(data.content[0].text).toBe(
|
|
524
524
|
'See `astryx docs acme/integrations`, and `astryx docs tokens` for the tokens.',
|
|
525
525
|
);
|
|
@@ -447,7 +447,7 @@ describe('integration-contributed topics', () => {
|
|
|
447
447
|
// places it.
|
|
448
448
|
expect(top).toContain('troubleshooting');
|
|
449
449
|
expect(
|
|
450
|
-
top.some(name => /^
|
|
450
|
+
top.some(name => /^authoring\/(?:.+\/)?troubleshooting$/.test(name)),
|
|
451
451
|
top.join(', '),
|
|
452
452
|
).toBe(true);
|
|
453
453
|
}, SLOW);
|