@astryxdesign/cli 0.7.3-canary.b1e1936 → 0.7.3-canary.ca48bb7
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/blocks/blocks.d.mts +6 -4
- package/api/build/blocks/blocks.mjs +103 -20
- package/api/build/blocks/blocks.test.mjs +126 -13
- package/api/build/blocks/blocks.weights.json +1 -1
- package/api/build/kit/answer.d.mts +5 -4
- package/api/build/kit/answer.mjs +114 -12
- package/api/build/kit/answer.test.mjs +73 -3
- package/api/build/kit/signals.d.mts +8 -0
- package/api/build/kit/signals.mjs +10 -0
- package/api/build/tree.test.mjs +19 -11
- package/api/component/component-replacement.test.mjs +1 -0
- package/api/component/component.mjs +17 -3
- package/api/component/component.test.mjs +15 -0
- package/api/component/doc-links.test.mjs +2 -2
- package/api/docs/_adapter.d.mts +2 -2
- package/api/docs/_adapter.mjs +61 -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/doctor.mjs +102 -24
- package/api/doctor/doctor.test.mjs +37 -12
- package/api/hook/hook.mjs +1 -1
- package/api/init/init.doc.mjs +20 -6
- package/api/init/init.test.mjs +18 -2
- package/api/init/init.type.d.mts +3 -3
- package/api/init/init.type.mjs +3 -3
- package/api/init/remove/remove.mjs +17 -4
- package/api/init/remove/remove.test.mjs +114 -2
- package/api/init/run/run.mjs +69 -6
- package/api/integration/_adapter.d.mts +8 -0
- package/api/integration/_adapter.mjs +21 -1
- package/api/integration/authoring-checks.test.mjs +220 -0
- package/api/integration/pack-check.mjs +110 -4
- package/api/integration/pack-check.test.mjs +69 -0
- package/api/integration/validate-integration-fixes.test.mjs +6 -5
- package/api/integration/validate-integration-gaps.test.mjs +304 -1
- package/api/integration/validate-integration.d.mts +6 -1
- package/api/integration/validate-integration.mjs +82 -13
- package/api/integration/validate-integration.type.d.mts +37 -4
- package/api/integration/validate-integration.type.mjs +28 -5
- 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 +77 -3
- package/api/search/_entries.test.mjs +48 -0
- package/api/search/_gather-docs.mjs +3 -3
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.mjs +6 -2
- package/api/search/search.test.mjs +14 -14
- package/api/theme/build/build.packed-old-core.test.mjs +1 -0
- package/api/upgrade/_adapter.d.mts +57 -9
- package/api/upgrade/_adapter.mjs +198 -28
- package/api/upgrade/registry/registry.d.mts +10 -4
- package/api/upgrade/registry/registry.mjs +33 -16
- package/api/upgrade/registry/registry.test.mjs +85 -0
- package/api/upgrade/run/run.d.mts +4 -2
- package/api/upgrade/run/run.mjs +13 -2
- package/api/upgrade/run/run.test.mjs +417 -3
- package/api/upgrade/upgrade.doc.mjs +10 -5
- package/api/upgrade/upgrade.mjs +13 -2
- package/api/upgrade/upgrade.test.mjs +194 -0
- package/api/upgrade/upgrade.type.d.mts +5 -3
- package/api/upgrade/upgrade.type.mjs +8 -6
- package/assets/docs/author-a-theme.doc.mjs +2 -2
- package/assets/docs/is-my-code-good.doc.mjs +287 -0
- 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 +2 -2
- 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 +3 -3
- 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 +17 -38
- 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/assets/docs/working-with-ai.doc.mjs +6 -2
- package/assets/templates/themes/butter/butterTheme.ts +4 -2
- package/assets/templates/themes/stone/stoneTheme.ts +4 -2
- package/assets/templates/themes/y2k/y2kTheme.ts +4 -2
- 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.mjs +10 -0
- package/clients/cli/commands/doctor.test.mjs +65 -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/init.behavior.test.mjs +230 -1
- package/clients/cli/commands/init.doc.mjs +28 -9
- package/clients/cli/commands/init.flag-help.test.mjs +1 -0
- package/clients/cli/commands/init.mjs +2 -2
- package/clients/cli/commands/integration-check.test.mjs +48 -0
- 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 +2 -1
- 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 +61 -0
- package/clients/cli/commands/{build-theme.mjs → theme.mjs} +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +4 -2
- package/clients/cli/commands/upgrade.mjs +9 -2
- package/clients/cli/commands/upgrade.subfolder-path.test.mjs +97 -0
- package/clients/cli/index.mjs +29 -86
- 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 +20 -7
- package/foundation/agent-docs/agent-doc-state.mjs +35 -8
- package/foundation/agent-docs/agent-docs.d.mts +100 -12
- package/foundation/agent-docs/agent-docs.mjs +1012 -100
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +1239 -17
- package/foundation/agent-docs/agent-docs.test.mjs +683 -39
- package/foundation/config/project.mjs +5 -20
- package/foundation/config/project.test.mjs +56 -0
- 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-allowlist.d.mts +2 -4
- package/foundation/discovery/runner-allowlist.mjs +2 -4
- package/foundation/discovery/runner-commands.d.mts +77 -0
- package/foundation/discovery/runner-commands.mjs +294 -0
- package/foundation/discovery/runner-commands.test.mjs +128 -0
- package/foundation/discovery/stray-pointers.test.mjs +1 -1
- package/foundation/discovery/template-adapter.mjs +18 -1
- package/foundation/discovery/template-needs.mjs +1 -44
- package/foundation/discovery/theme-discovery.mjs +147 -3
- package/foundation/doc-compiler/doc-loads.test.mjs +29 -9
- package/foundation/doc-compiler/read.mjs +59 -1
- package/foundation/doc-compiler/read.test.mjs +11 -2
- 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/paths.d.mts +70 -8
- package/foundation/fs/paths.mjs +526 -35
- package/foundation/fs/paths.test.mjs +430 -54
- 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/autolink.d.mts +2 -1
- package/foundation/integrations/autolink.mjs +4 -13
- 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/integrations.d.mts +20 -1
- package/foundation/integrations/integrations.mjs +59 -2
- 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/integrations/validate-contributions.d.mts +19 -0
- package/foundation/integrations/validate-contributions.mjs +172 -3
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +9 -9
|
@@ -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);
|
|
@@ -157,13 +157,13 @@ describe('a section read on a namespace', () => {
|
|
|
157
157
|
expect(names).toContain('layout/side-panels');
|
|
158
158
|
expect(names.every(name => name.startsWith('layout/'))).toBe(true);
|
|
159
159
|
// At any depth: guides under nested namespaces are named, namespaces are not.
|
|
160
|
-
const
|
|
161
|
-
expect(
|
|
162
|
-
expect(
|
|
163
|
-
'
|
|
160
|
+
const authoring = await docs('authoring', 'zzzz-nope').catch(e => e);
|
|
161
|
+
expect(authoring.code).toBe('ERR_UNKNOWN_SECTION');
|
|
162
|
+
expect(authoring.suggestions.map(s => s.name)).toContain(
|
|
163
|
+
'authoring/building-blocks/components/add-a-component',
|
|
164
164
|
);
|
|
165
|
-
expect(
|
|
166
|
-
'
|
|
165
|
+
expect(authoring.suggestions.map(s => s.name)).not.toContain(
|
|
166
|
+
'authoring/building-blocks',
|
|
167
167
|
);
|
|
168
168
|
},
|
|
169
169
|
SLOW,
|
|
@@ -300,11 +300,11 @@ describe('a reference block that includes what it names', () => {
|
|
|
300
300
|
});
|
|
301
301
|
|
|
302
302
|
describe('what a reference block names', () => {
|
|
303
|
-
it('resolves a CLI authoring schema by identity, to its section of
|
|
303
|
+
it('resolves a CLI authoring schema by identity, to its section of the field reference', async () => {
|
|
304
304
|
const resolve = await linkResolver(builtinCatalog(), CLI_PROVIDER_ID);
|
|
305
305
|
expect(await resolve('schema:integration')).toMatchObject({
|
|
306
306
|
id: createDocId(CLI_PROVIDER_ID, 'schema', 'integration'),
|
|
307
|
-
route: 'authoring',
|
|
307
|
+
route: 'authoring/field-reference',
|
|
308
308
|
title: 'Astryx Integration',
|
|
309
309
|
command: 'astryx docs authoring integration',
|
|
310
310
|
});
|