@astryxdesign/cli 0.7.3-canary.b74cf21 → 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 +16 -12
- package/api/doctor/doctor.test.mjs +37 -12
- package/api/hook/hook.mjs +1 -1
- 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/upgrade/_adapter.d.mts +57 -3
- package/api/upgrade/_adapter.mjs +149 -27
- 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.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/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/{hook/index.mjs → hook.mjs} +22 -22
- package/clients/cli/commands/import-hint-correctness.test.mjs +1 -1
- 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/postinstall.doc.mjs +23 -0
- package/clients/cli/commands/postinstall.mjs +31 -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 +10 -85
- 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-docs.mjs +2 -1
- package/foundation/agent-docs/agent-docs.test.mjs +5 -4
- 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 +25 -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
|
});
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -1048,16 +1048,20 @@ function nameTypes(names) {
|
|
|
1048
1048
|
}
|
|
1049
1049
|
|
|
1050
1050
|
/**
|
|
1051
|
-
* The section keys
|
|
1052
|
-
* command reads them.
|
|
1051
|
+
* The section keys the field reference lists (`astryx docs
|
|
1052
|
+
* authoring/field-reference --index`), read the way that command reads them.
|
|
1053
1053
|
* @returns {Promise<{keys: Set<string>} | {keys: null, error: string}>}
|
|
1054
1054
|
*/
|
|
1055
1055
|
async function authoringTopicKeys() {
|
|
1056
1056
|
try {
|
|
1057
|
+
const {AUTHORING_REFERENCE_ROUTE} =
|
|
1058
|
+
await import('../../foundation/discovery/authoring-self-docs.mjs');
|
|
1057
1059
|
const catalog = DocsCatalog.fromBuiltins();
|
|
1058
|
-
const
|
|
1059
|
-
if (!
|
|
1060
|
-
|
|
1060
|
+
const node = (await projectTree(catalog)).get(AUTHORING_REFERENCE_ROUTE);
|
|
1061
|
+
if (!node?.ref?.topicFile) {
|
|
1062
|
+
return {keys: null, error: 'the docs tree has no field reference'};
|
|
1063
|
+
}
|
|
1064
|
+
const index = indexView(await lowerTopic(catalog, guideEntry(node)));
|
|
1061
1065
|
return {keys: new Set(index.sections.map(section => section.id))};
|
|
1062
1066
|
} catch (err) {
|
|
1063
1067
|
return {
|
|
@@ -1076,7 +1080,7 @@ function surfaceProblems(surface) {
|
|
|
1076
1080
|
const problems = [];
|
|
1077
1081
|
if (surface.types === 0 && surface.untraced.length === 0) {
|
|
1078
1082
|
problems.push(
|
|
1079
|
-
`@astryxdesign/cli/authoring exports no types, so nothing was compared with \`${formatCliCommand('docs authoring')}\``,
|
|
1083
|
+
`@astryxdesign/cli/authoring exports no types, so nothing was compared with \`${formatCliCommand('docs authoring/field-reference')}\``,
|
|
1080
1084
|
);
|
|
1081
1085
|
}
|
|
1082
1086
|
for (const {module, names, reason, source, key} of surface.unreadable) {
|
|
@@ -1089,7 +1093,7 @@ function surfaceProblems(surface) {
|
|
|
1089
1093
|
? `${source} does not load`
|
|
1090
1094
|
: `${source} renders section "${key}", which the topic's index does not list`;
|
|
1091
1095
|
problems.push(
|
|
1092
|
-
`${nameTypes(names)} from ${module} ${names.length === 1 ? 'has' : 'have'} no doc in \`${formatCliCommand('docs authoring')}\`: ${why}`,
|
|
1096
|
+
`${nameTypes(names)} from ${module} ${names.length === 1 ? 'has' : 'have'} no doc in \`${formatCliCommand('docs authoring/field-reference')}\`: ${why}`,
|
|
1093
1097
|
);
|
|
1094
1098
|
}
|
|
1095
1099
|
for (const {name, reason} of surface.untraced) {
|
|
@@ -1130,7 +1134,7 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1130
1134
|
const audit = await auditAuthoringSelfDocs({root, sources});
|
|
1131
1135
|
const problems = [
|
|
1132
1136
|
...audit.unreachable.map(
|
|
1133
|
-
source => `${source} is not in \`${formatCliCommand('docs authoring')}\``,
|
|
1137
|
+
source => `${source} is not in \`${formatCliCommand('docs authoring/field-reference')}\``,
|
|
1134
1138
|
),
|
|
1135
1139
|
...audit.failed.map(
|
|
1136
1140
|
({source, error}) => `${source} failed to load: ${error}`,
|
|
@@ -1146,7 +1150,7 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1146
1150
|
: {keys: options.topicKeys};
|
|
1147
1151
|
const surface = [
|
|
1148
1152
|
...('error' in topic
|
|
1149
|
-
? [`\`${formatCliCommand('docs authoring')}\` could not be read: ${topic.error}`]
|
|
1153
|
+
? [`\`${formatCliCommand('docs authoring/field-reference')}\` could not be read: ${topic.error}`]
|
|
1150
1154
|
: []),
|
|
1151
1155
|
...surfaceProblems(
|
|
1152
1156
|
await auditAuthoringSurface({root, sources, topicKeys: topic.keys}),
|
|
@@ -1170,7 +1174,7 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
1170
1174
|
id,
|
|
1171
1175
|
label,
|
|
1172
1176
|
status: 'pass',
|
|
1173
|
-
message: `All ${audit.sections} authoring schemas are readable in \`${formatCliCommand('docs authoring')}\`.`,
|
|
1177
|
+
message: `All ${audit.sections} authoring schemas are readable in \`${formatCliCommand('docs authoring/field-reference')}\`.`,
|
|
1174
1178
|
};
|
|
1175
1179
|
} catch (err) {
|
|
1176
1180
|
return {
|
|
@@ -1238,7 +1242,7 @@ export async function checkCliDocs(_ctx, options = {}) {
|
|
|
1238
1242
|
id,
|
|
1239
1243
|
label,
|
|
1240
1244
|
status: 'pass',
|
|
1241
|
-
message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`${formatCliCommand('docs cli')}\` tree and ${audit.authoring} in \`${formatCliCommand('docs authoring')}\`.`,
|
|
1245
|
+
message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`${formatCliCommand('docs cli')}\` tree and ${audit.authoring} in \`${formatCliCommand('docs authoring/field-reference')}\`.`,
|
|
1242
1246
|
};
|
|
1243
1247
|
} catch (err) {
|
|
1244
1248
|
return {
|
|
@@ -1355,7 +1359,7 @@ export async function checkDocsProgressiveDisclosure(ctx) {
|
|
|
1355
1359
|
// A guide the docs tree places is a topic read by its route; it is held
|
|
1356
1360
|
// to the same budget as every flat topic.
|
|
1357
1361
|
const guides = [...(await projectTree(catalog)).nodes.values()]
|
|
1358
|
-
// A flat topic in
|
|
1362
|
+
// A flat topic in a topic level is checked above, as a topic.
|
|
1359
1363
|
.filter(node => node.kind === 'generic' && !node.ref?.flatTopic)
|
|
1360
1364
|
.map(guideEntry);
|
|
1361
1365
|
for (const entry of [...catalog.entries(), ...guides]) {
|
|
@@ -652,7 +652,7 @@ describe('checkAuthoringDocs', () => {
|
|
|
652
652
|
it('passes when every authoring self-doc is reachable and fits one read', async () => {
|
|
653
653
|
const c = await checkAuthoringDocs();
|
|
654
654
|
expect(c).toMatchObject({id: 'authoring-docs', status: 'pass'});
|
|
655
|
-
expect(c.message).toContain(formatCliCommand('docs authoring'));
|
|
655
|
+
expect(c.message).toContain(formatCliCommand('docs authoring/field-reference'));
|
|
656
656
|
}, SLOW);
|
|
657
657
|
});
|
|
658
658
|
|
|
@@ -680,7 +680,7 @@ describe('checkCliDocs', () => {
|
|
|
680
680
|
id: 'cli-docs',
|
|
681
681
|
label: 'CLI docs',
|
|
682
682
|
status: 'pass',
|
|
683
|
-
message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`${formatCliCommand('docs cli')}\` tree and ${audit.authoring} in \`${formatCliCommand('docs authoring')}\`.`,
|
|
683
|
+
message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`${formatCliCommand('docs cli')}\` tree and ${audit.authoring} in \`${formatCliCommand('docs authoring/field-reference')}\`.`,
|
|
684
684
|
});
|
|
685
685
|
},
|
|
686
686
|
SLOW,
|
|
@@ -790,7 +790,7 @@ describe('checkDocsTree', () => {
|
|
|
790
790
|
describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
791
791
|
const NAMESPACE = 'doctypes/namespace/namespace.doc.mjs';
|
|
792
792
|
const NAMESPACE_TYPES =
|
|
793
|
-
`NamespaceDoc, NamespaceProviderScope, NamespaceSlotAcceptance, NamespaceSlot, NamespaceAdoptionSource, NamespaceAdoptionRule from doctypes/namespace/type.ts have no doc in \`${formatCliCommand('docs authoring')}\``;
|
|
793
|
+
`NamespaceDoc, NamespaceProviderScope, NamespaceSlotAcceptance, NamespaceSlot, NamespaceAdoptionSource, NamespaceAdoptionRule from doctypes/namespace/type.ts have no doc in \`${formatCliCommand('docs authoring/field-reference')}\``;
|
|
794
794
|
const SURFACE_FIX =
|
|
795
795
|
'Put a self-doc beside each module whose types @astryxdesign/cli/authoring exports and list it in AUTHORING_SELF_DOCS; export what each listed self-doc documents, or remove that self-doc.';
|
|
796
796
|
|
|
@@ -820,7 +820,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
820
820
|
id: 'authoring-docs',
|
|
821
821
|
label: 'Authoring docs',
|
|
822
822
|
status: 'pass',
|
|
823
|
-
message: `All ${AUTHORING_SELF_DOCS.length} authoring schemas are readable in \`${formatCliCommand('docs authoring')}\`.`,
|
|
823
|
+
message: `All ${AUTHORING_SELF_DOCS.length} authoring schemas are readable in \`${formatCliCommand('docs authoring/field-reference')}\`.`,
|
|
824
824
|
});
|
|
825
825
|
},
|
|
826
826
|
SLOW,
|
|
@@ -849,7 +849,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
849
849
|
});
|
|
850
850
|
expect(c.status).toBe('fail');
|
|
851
851
|
expect(c.message).toBe(
|
|
852
|
-
`2 problems: ${NAMESPACE} is not in \`${formatCliCommand('docs authoring')}\`; ${NAMESPACE_TYPES}: ${NAMESPACE} is not listed in AUTHORING_SELF_DOCS`,
|
|
852
|
+
`2 problems: ${NAMESPACE} is not in \`${formatCliCommand('docs authoring/field-reference')}\`; ${NAMESPACE_TYPES}: ${NAMESPACE} is not listed in AUTHORING_SELF_DOCS`,
|
|
853
853
|
);
|
|
854
854
|
},
|
|
855
855
|
SLOW,
|
|
@@ -858,7 +858,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
858
858
|
it(
|
|
859
859
|
"fails when the topic's index no longer exposes the NamespaceDoc section",
|
|
860
860
|
async () => {
|
|
861
|
-
const index = await docs('authoring', undefined, {index: true});
|
|
861
|
+
const index = await docs('authoring/field-reference', undefined, {index: true});
|
|
862
862
|
const topicKeys = new Set(
|
|
863
863
|
index.data.sections
|
|
864
864
|
.map((/** @type {any} */ s) => s.id)
|
|
@@ -947,7 +947,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
947
947
|
expect(c.fix).toBe(SURFACE_FIX);
|
|
948
948
|
expect(c.message).toMatch(
|
|
949
949
|
new RegExp(
|
|
950
|
-
`^[A-Za-z, ]+ from ${escape(module)} have no doc in \`${escape(formatCliCommand('docs authoring'))}\`: no self-doc sits beside ${escape(module)}$`,
|
|
950
|
+
`^[A-Za-z, ]+ from ${escape(module)} have no doc in \`${escape(formatCliCommand('docs authoring/field-reference'))}\`: no self-doc sits beside ${escape(module)}$`,
|
|
951
951
|
),
|
|
952
952
|
);
|
|
953
953
|
for (const name of names) {
|
|
@@ -990,7 +990,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
990
990
|
expect(await checkAuthoringDocs()).toMatchObject({
|
|
991
991
|
status: 'fail',
|
|
992
992
|
message:
|
|
993
|
-
`\`${formatCliCommand('docs authoring')}\` could not be read: no built-in docs`,
|
|
993
|
+
`\`${formatCliCommand('docs authoring/field-reference')}\` could not be read: no built-in docs`,
|
|
994
994
|
fix: SURFACE_FIX,
|
|
995
995
|
});
|
|
996
996
|
} finally {
|
|
@@ -1011,7 +1011,7 @@ describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
|
1011
1011
|
const c = await checkAuthoringDocs(undefined, {root});
|
|
1012
1012
|
expect(c.status).toBe('fail');
|
|
1013
1013
|
expect(c.message).toContain(
|
|
1014
|
-
`@astryxdesign/cli/authoring exports no types, so nothing was compared with \`${formatCliCommand('docs authoring')}\``,
|
|
1014
|
+
`@astryxdesign/cli/authoring exports no types, so nothing was compared with \`${formatCliCommand('docs authoring/field-reference')}\``,
|
|
1015
1015
|
);
|
|
1016
1016
|
},
|
|
1017
1017
|
SLOW,
|
|
@@ -1317,8 +1317,12 @@ describe('a configured integration that cannot load fails the gate', () => {
|
|
|
1317
1317
|
'astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
|
|
1318
1318
|
};
|
|
1319
1319
|
|
|
1320
|
-
/**
|
|
1321
|
-
|
|
1320
|
+
/**
|
|
1321
|
+
* Run doctor on a project under the working directory, in its folder `at`.
|
|
1322
|
+
* @param {Record<string, string>} files
|
|
1323
|
+
* @param {string} [at]
|
|
1324
|
+
*/
|
|
1325
|
+
async function report(files, at = '.') {
|
|
1322
1326
|
const dir = fs.mkdtempSync(path.join(process.cwd(), '.astryx-doctor-gate-'));
|
|
1323
1327
|
tmpDirs.push(dir);
|
|
1324
1328
|
for (const [rel, content] of Object.entries(files)) {
|
|
@@ -1326,7 +1330,7 @@ describe('a configured integration that cannot load fails the gate', () => {
|
|
|
1326
1330
|
fs.mkdirSync(path.dirname(abs), {recursive: true});
|
|
1327
1331
|
fs.writeFileSync(abs, content);
|
|
1328
1332
|
}
|
|
1329
|
-
const {checks, summary} = (await doctor({cwd: dir})).data;
|
|
1333
|
+
const {checks, summary} = (await doctor({cwd: path.join(dir, at)})).data;
|
|
1330
1334
|
return {by: Object.fromEntries(checks.map(c => [c.id, c])), summary};
|
|
1331
1335
|
}
|
|
1332
1336
|
|
|
@@ -1354,6 +1358,27 @@ describe('a configured integration that cannot load fails the gate', () => {
|
|
|
1354
1358
|
SLOW,
|
|
1355
1359
|
);
|
|
1356
1360
|
|
|
1361
|
+
it(
|
|
1362
|
+
'passes in a workspace member whose configured integration is hoisted to the root',
|
|
1363
|
+
async () => {
|
|
1364
|
+
const {by} = await report(
|
|
1365
|
+
{
|
|
1366
|
+
'package.json': JSON.stringify({name: 'root', private: true, workspaces: ['apps/*']}),
|
|
1367
|
+
...CORE_STUB,
|
|
1368
|
+
...widgets(),
|
|
1369
|
+
'apps/web/package.json': '{"name":"web"}',
|
|
1370
|
+
'apps/web/astryx.config.mjs': "export default { integrations: ['@acme/widgets'] };\n",
|
|
1371
|
+
},
|
|
1372
|
+
'apps/web',
|
|
1373
|
+
);
|
|
1374
|
+
expect(by['configured-integrations'].status).toBe('pass');
|
|
1375
|
+
expect(by['configured-integrations'].message).toBe(
|
|
1376
|
+
'1 integration named in astryx.config loaded: @acme/widgets.',
|
|
1377
|
+
);
|
|
1378
|
+
},
|
|
1379
|
+
SLOW,
|
|
1380
|
+
);
|
|
1381
|
+
|
|
1357
1382
|
it(
|
|
1358
1383
|
'counts the package being authored when its own config names it',
|
|
1359
1384
|
async () => {
|