@astryxdesign/cli 0.6.3-canary.2bb99ed → 0.6.3-canary.2bdba84
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 +21 -19
- package/api/build/_adapter.d.mts +50 -0
- package/api/build/_adapter.mjs +60 -0
- package/api/build/build.doc.mjs +13 -7
- package/api/build/build.test.mjs +184 -6
- package/api/build/build.type.d.mts +57 -2
- package/api/build/build.type.mjs +30 -7
- package/api/build/help/help.d.mts +4 -0
- package/api/build/help/help.mjs +24 -11
- package/api/build/kit/kit.d.mts +4 -1
- package/api/build/kit/kit.mjs +165 -49
- package/api/build/kit/rank.d.mts +44 -0
- package/api/build/kit/rank.mjs +432 -0
- package/api/build/kit/rank.test.mjs +196 -0
- package/api/component/_adapter.d.mts +6 -12
- package/api/component/_adapter.mjs +20 -10
- package/api/component/component.mjs +60 -12
- package/api/component/list/list.mjs +3 -2
- package/api/docs/_adapter.d.mts +251 -28
- package/api/docs/_adapter.mjs +918 -35
- package/api/docs/detail/detail.mjs +11 -3
- package/api/docs/detail/section/section.mjs +20 -3
- package/api/docs/docs.d.mts +5 -3
- package/api/docs/docs.doc.mjs +38 -17
- package/api/docs/docs.mjs +44 -8
- package/api/docs/docs.test.mjs +158 -4
- package/api/docs/docs.type.d.mts +181 -2
- package/api/docs/docs.type.mjs +117 -3
- package/api/docs/index/index.mjs +11 -3
- package/api/docs/index/index.test.mjs +1 -1
- package/api/docs/integration-tree.test.mjs +555 -0
- package/api/docs/integrationDocs.test.mjs +14 -14
- package/api/docs/list/list.mjs +25 -5
- package/api/docs/node/node.d.mts +43 -0
- package/api/docs/node/node.mjs +192 -0
- package/api/docs/reference-blocks.test.mjs +406 -0
- package/api/doctor/doctor.d.mts +30 -2
- package/api/doctor/doctor.mjs +150 -7
- package/api/doctor/doctor.test.mjs +89 -1
- package/api/index.d.mts +1 -1
- package/api/index.mjs +1 -0
- package/api/init/init.doc.mjs +1 -1
- package/api/integration/add-contribution.d.mts +2 -1
- package/api/integration/add-contribution.mjs +107 -5
- package/api/integration/add-contribution.test.mjs +137 -0
- package/api/integration/authoring-checks.mjs +138 -28
- package/api/integration/authoring-checks.test.mjs +171 -3
- package/api/integration/authoring-checks.type.mjs +6 -1
- package/api/integration/integration-authoring.type.d.mts +2 -0
- package/api/integration/integration-authoring.type.mjs +2 -0
- package/api/integration/integrationAdd.doc.mjs +6 -0
- package/api/integration/integrationAddDoc.doc.mjs +7 -1
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/integrationPackCheck.doc.mjs +1 -1
- package/api/integration/integrationTemplateConflicts.doc.d.mts +3 -0
- package/api/integration/integrationTemplateConflicts.doc.mjs +3 -0
- package/api/integration/pack-check.mjs +34 -0
- package/api/integration/pack-check.test.mjs +121 -0
- package/api/integration/pack-check.type.d.mts +26 -2
- package/api/integration/pack-check.type.mjs +14 -1
- package/api/integration/template-conflict-compatibility.test.mjs +73 -0
- package/api/integration/validate-integration.test.mjs +3 -3
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/json/index.ts +2 -0
- package/api/layout/_adapter.mjs +20 -5
- package/api/search/search.d.mts +59 -1
- package/api/search/search.doc.mjs +4 -3
- package/api/search/search.mjs +442 -71
- package/api/search/search.test.mjs +91 -2
- package/api/search/search.type.d.mts +13 -1
- package/api/search/search.type.mjs +4 -1
- package/api/template/list/list.mjs +1 -0
- package/api/template/table-floating-bulk-actions.test.mjs +66 -0
- package/api/template/template-integration.test.mjs +1072 -3
- package/api/template/template.doc.mjs +27 -7
- package/api/template/template.mjs +45 -8
- package/api/template/template.type.d.mts +6 -8
- package/api/template/template.type.mjs +3 -2
- package/api/theme/template/template.test.mjs +5 -0
- package/api/theme/themeTemplate.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/layout.doc.dense.mjs +2 -2
- package/assets/docs/layout.doc.mjs +1 -1
- package/assets/docs/principles.doc.mjs +6 -6
- package/assets/docs/styling-libraries.doc.mjs +3 -3
- package/assets/docs/styling.doc.mjs +4 -4
- package/assets/docs/theme.doc.mjs +4 -4
- package/assets/docs/tokens.doc.mjs +1 -1
- package/assets/docs/tree/api.doc.mjs +30 -0
- package/assets/docs/tree/cli.doc.mjs +23 -0
- package/assets/docs/tree/commands.doc.mjs +25 -0
- package/assets/docs/{cli-integrations.doc.mjs → tree/integrations.doc.mjs} +37 -9
- package/assets/docs/tree/integrations.test.mjs +62 -0
- package/assets/docs/tree/writing-docs.doc.mjs +286 -0
- package/assets/docs/working-with-ai.doc.mjs +3 -3
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.doc.mjs +1 -1
- package/assets/templates/blocks/components/CheckboxList/CheckboxListSelectAllPattern.tsx +1 -3
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.doc.mjs +14 -0
- package/assets/templates/blocks/components/Table/TableBulkActionsTable.tsx +71 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.doc.mjs +19 -0
- package/assets/templates/blocks/components/Table/TableFloatingBulkActionsTable.tsx +139 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +72 -0
- package/authoring/doctypes/_schema.mjs +25 -1
- package/authoring/doctypes/base/graph-fields.doc.mjs +7 -5
- package/authoring/doctypes/base/type.ts +6 -5
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/command/type.ts +2 -2
- package/authoring/doctypes/enum/enum.doc.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +1 -1
- package/authoring/doctypes/function/function.doc.mjs +3 -2
- package/authoring/doctypes/function/type.ts +3 -2
- package/authoring/doctypes/load-contract.test.mjs +25 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +5 -9
- package/authoring/doctypes/reference/reference.doc.mjs +31 -4
- package/authoring/doctypes/reference/type.ts +23 -5
- package/authoring/doctypes/schema/schema.doc.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +1 -1
- package/authoring/doctypes/template/parse.d.mts +2 -0
- package/authoring/doctypes/template/parse.mjs +4 -0
- package/authoring/doctypes/template/parse.test.mjs +18 -0
- package/authoring/doctypes/template/template.doc.mjs +6 -0
- package/authoring/doctypes/template/type.ts +8 -0
- package/authoring/identity/identity.doc.mjs +2 -2
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/commands/build-theme.adaptations.test.mjs +100 -1
- package/clients/cli/commands/build-theme.mjs +1 -1
- package/clients/cli/commands/build.doc.mjs +11 -6
- package/clients/cli/commands/build.mjs +105 -67
- package/clients/cli/commands/build.text-fields.test.mjs +41 -0
- package/clients/cli/commands/component/index.mjs +1 -1
- package/clients/cli/commands/component-ownership.test.mjs +3 -3
- package/clients/cli/commands/discover.broken-integration.test.mjs +7 -8
- package/clients/cli/commands/discover.mjs +1 -1
- package/clients/cli/commands/docs.doc.mjs +20 -8
- package/clients/cli/commands/docs.mjs +177 -20
- package/clients/cli/commands/docs.test.mjs +114 -7
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +2 -2
- package/clients/cli/commands/doctor-integration-templates.doc.mjs +14 -7
- package/clients/cli/commands/doctor-integration.test.mjs +75 -1
- package/clients/cli/commands/doctor.mjs +53 -16
- package/clients/cli/commands/integration-add.doc.mjs +10 -0
- package/clients/cli/commands/integration.mjs +1 -0
- package/clients/cli/commands/search.mjs +11 -2
- package/clients/cli/commands/setup-nudge.test.mjs +6 -0
- package/clients/cli/commands/template.doc.mjs +23 -6
- package/clients/cli/commands/template.mjs +4 -91
- package/clients/cli/commands/text-json-parity.test.mjs +2 -1
- package/clients/cli/index.mjs +8 -0
- package/clients/cli/lib/manifest.mjs +9 -2
- package/foundation/agent-docs/agent-docs.d.mts +3 -2
- package/foundation/agent-docs/agent-docs.mjs +13 -9
- package/foundation/agent-docs/agent-docs.test.mjs +19 -1
- package/foundation/config/project.d.mts +12 -11
- package/foundation/config/project.mjs +73 -59
- package/foundation/config/project.test.mjs +141 -5
- package/foundation/discovery/authoring-self-docs.d.mts +12 -0
- package/foundation/discovery/authoring-self-docs.mjs +20 -8
- package/foundation/discovery/authoring-self-docs.test.mjs +24 -9
- package/foundation/discovery/cli-self-docs.d.mts +40 -34
- package/foundation/discovery/cli-self-docs.mjs +91 -115
- package/foundation/discovery/cli-self-docs.test.mjs +104 -166
- package/foundation/discovery/component-discovery.d.mts +38 -0
- package/foundation/discovery/component-discovery.mjs +48 -0
- package/foundation/discovery/docs-discovery.d.mts +109 -9
- package/foundation/discovery/docs-discovery.mjs +217 -19
- package/foundation/discovery/docs-discovery.test.mjs +96 -17
- package/foundation/discovery/docs-output-budget.d.mts +2 -2
- package/foundation/discovery/docs-output-budget.mjs +1 -1
- package/foundation/discovery/docs-section-key.d.mts +9 -2
- package/foundation/discovery/docs-section-key.mjs +15 -1
- package/foundation/discovery/template-adapter.d.mts +92 -6
- package/foundation/discovery/template-adapter.mjs +453 -17
- package/foundation/discovery/template-adapter.test.mjs +42 -0
- package/foundation/discovery/template-conflict-release.d.mts +13 -0
- package/foundation/discovery/template-conflict-release.mjs +40 -0
- package/foundation/discovery/template-conflict-release.test.mjs +40 -0
- package/foundation/doc-compiler/bundle.mjs +61 -1
- package/foundation/doc-compiler/bundle.test.mjs +21 -10
- package/foundation/doc-compiler/compile.d.mts +113 -132
- package/foundation/doc-compiler/compile.mjs +52 -6
- package/foundation/doc-compiler/diagnostics.mjs +28 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -2
- package/foundation/doc-compiler/inputs.d.mts +2 -2
- package/foundation/doc-compiler/inputs.mjs +6 -1
- package/foundation/doc-compiler/ir.mjs +7 -0
- package/foundation/doc-compiler/lenses.d.mts +8 -5
- package/foundation/doc-compiler/lenses.mjs +50 -4
- package/foundation/doc-compiler/links.d.mts +162 -0
- package/foundation/doc-compiler/links.mjs +294 -0
- package/foundation/doc-compiler/links.test.mjs +192 -0
- package/foundation/doc-compiler/lower-doc.test.mjs +5 -2
- package/foundation/doc-compiler/read.d.mts +3 -2
- package/foundation/doc-compiler/read.mjs +6 -1
- package/foundation/doc-compiler/tree.d.mts +288 -0
- package/foundation/doc-compiler/tree.mjs +876 -0
- package/foundation/doc-compiler/tree.test.mjs +598 -0
- package/foundation/integrations/autolink.test.mjs +1 -1
- package/foundation/integrations/cli-requirement.d.mts +45 -0
- package/foundation/integrations/cli-requirement.mjs +154 -0
- package/foundation/integrations/cli-requirement.test.mjs +84 -0
- package/foundation/integrations/contribution-inventory.d.mts +2 -1
- package/foundation/integrations/contribution-inventory.mjs +10 -4
- package/foundation/integrations/contribution-inventory.test.mjs +19 -0
- package/foundation/integrations/integration-warnings.d.mts +9 -2
- package/foundation/integrations/integration-warnings.mjs +51 -26
- package/foundation/integrations/integration-warnings.test.mjs +74 -1
- package/foundation/integrations/validate-contributions.mjs +25 -27
- package/foundation/response/response-types.doc.d.mts +5 -1
- package/foundation/response/response-types.doc.mjs +19 -10
- package/foundation/text/string-utils.d.mts +8 -0
- package/foundation/text/string-utils.mjs +18 -0
- package/foundation/xle/expand.mjs +1 -1
- package/foundation/xle/xle.test.mjs +13 -0
- package/package.json +9 -9
- package/assets/docs/cli.doc.mjs +0 -15
package/api/doctor/doctor.d.mts
CHANGED
|
@@ -68,7 +68,13 @@ export function checkAgentDocs(ctx: DoctorContext): DoctorCheck;
|
|
|
68
68
|
*/
|
|
69
69
|
export function checkPeerDeps(ctx: DoctorContext): DoctorCheck;
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* Summarize the combined integration graph, including cross-package warnings.
|
|
72
|
+
* @param {DoctorContext} ctx
|
|
73
|
+
* @returns {DoctorCheck}
|
|
74
|
+
*/
|
|
75
|
+
export function checkIntegrationIssues(ctx: DoctorContext): DoctorCheck;
|
|
76
|
+
/**
|
|
77
|
+
* Check 10 — report the detected package manager, and say so when the project's
|
|
72
78
|
* own declaration disagrees with what is on disk.
|
|
73
79
|
*
|
|
74
80
|
* Two states are worth surfacing rather than guessing past, because in both the
|
|
@@ -116,7 +122,7 @@ export function checkAuthoringDocs(_ctx?: DoctorContext, options?: {
|
|
|
116
122
|
}): Promise<DoctorCheck>;
|
|
117
123
|
/**
|
|
118
124
|
* Every command, API function, schema, and enum doc the CLI ships declares a
|
|
119
|
-
* namespace, and
|
|
125
|
+
* namespace, and something reads it: the docs tree under `astryx docs cli`
|
|
120
126
|
* for `cli/commands` and `cli/api`, `astryx docs authoring` for `authoring`.
|
|
121
127
|
* @param {DoctorContext | Partial<DoctorContext>} _ctx
|
|
122
128
|
* @param {{root?: string, sources?: string[], authoringSources?: string[]}} [options]
|
|
@@ -128,6 +134,19 @@ export function checkCliDocs(_ctx: DoctorContext | Partial<DoctorContext>, optio
|
|
|
128
134
|
sources?: string[];
|
|
129
135
|
authoringSources?: string[];
|
|
130
136
|
}): Promise<DoctorCheck>;
|
|
137
|
+
/**
|
|
138
|
+
* The docs tree builds with no error, and every CLI typed doc in a `cli/...`
|
|
139
|
+
* group has a route in it (spec:AST-046): each placement names a namespace of
|
|
140
|
+
* its own package and a slot that accepts it, exactly one namespace adopts
|
|
141
|
+
* each doc, and each route belongs to one doc.
|
|
142
|
+
* @param {DoctorContext | Partial<DoctorContext>} _ctx
|
|
143
|
+
* @param {{tree?: import('../../foundation/doc-compiler/tree.mjs').DocsTree}} [options]
|
|
144
|
+
* test seam: a tree to check instead of the CLI's own
|
|
145
|
+
* @returns {Promise<DoctorCheck>}
|
|
146
|
+
*/
|
|
147
|
+
export function checkDocsTree(_ctx: DoctorContext | Partial<DoctorContext>, options?: {
|
|
148
|
+
tree?: import("../../foundation/doc-compiler/tree.mjs").DocsTree;
|
|
149
|
+
}): Promise<DoctorCheck>;
|
|
131
150
|
/**
|
|
132
151
|
* Every topic reads progressively, in every language it ships: it loads, its
|
|
133
152
|
* section index and each of its sections fit in one read, and no contributed
|
|
@@ -238,6 +257,15 @@ export type DoctorContext = {
|
|
|
238
257
|
* could not be built, when it could not.
|
|
239
258
|
*/
|
|
240
259
|
docsCatalogError?: string | null | undefined;
|
|
260
|
+
/**
|
|
261
|
+
* Combined project-level integration issues, including cross-package template replacement warnings.
|
|
262
|
+
*/
|
|
263
|
+
integrationIssues?: {
|
|
264
|
+
package: string;
|
|
265
|
+
code: string;
|
|
266
|
+
severity: "warning" | "error";
|
|
267
|
+
message: string;
|
|
268
|
+
}[] | null | undefined;
|
|
241
269
|
/**
|
|
242
270
|
* - Error thrown while resolving the config
|
|
243
271
|
* path (e.g. multiple config files present), surfaced by checkConfig as a FAIL.
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -34,7 +34,16 @@ import {
|
|
|
34
34
|
docsIndexBytes,
|
|
35
35
|
oversizedDocSections,
|
|
36
36
|
} from '../../foundation/discovery/docs-output-budget.mjs';
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
builtinCatalog,
|
|
39
|
+
compileTopic,
|
|
40
|
+
docsLinkProblems,
|
|
41
|
+
guideEntry,
|
|
42
|
+
lowerTopic,
|
|
43
|
+
overlayLanguages,
|
|
44
|
+
projectTree,
|
|
45
|
+
} from '../docs/_adapter.mjs';
|
|
46
|
+
import {typedEdges} from '../docs/node/node.mjs';
|
|
38
47
|
import {detailView, indexView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
39
48
|
import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env/semver.mjs';
|
|
40
49
|
|
|
@@ -66,6 +75,8 @@ import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env
|
|
|
66
75
|
* `invalid_doc` issues from the project's contributed docs.
|
|
67
76
|
* @property {string|null} [docsCatalogError] - Why the project's docs catalog
|
|
68
77
|
* could not be built, when it could not.
|
|
78
|
+
* @property {Array<{package: string, code: string, severity: 'warning'|'error', message: string}>|null} [integrationIssues]
|
|
79
|
+
* Combined project-level integration issues, including cross-package template replacement warnings.
|
|
69
80
|
* @property {Error|null} [configError] - Error thrown while resolving the config
|
|
70
81
|
* path (e.g. multiple config files present), surfaced by checkConfig as a FAIL.
|
|
71
82
|
*/
|
|
@@ -585,7 +596,45 @@ export function checkPeerDeps(ctx) {
|
|
|
585
596
|
}
|
|
586
597
|
|
|
587
598
|
/**
|
|
588
|
-
*
|
|
599
|
+
* Summarize the combined integration graph, including cross-package warnings.
|
|
600
|
+
* @param {DoctorContext} ctx
|
|
601
|
+
* @returns {DoctorCheck}
|
|
602
|
+
*/
|
|
603
|
+
export function checkIntegrationIssues(ctx) {
|
|
604
|
+
const issues = ctx.integrationIssues;
|
|
605
|
+
if (issues == null) {
|
|
606
|
+
return {
|
|
607
|
+
id: 'integration-issues',
|
|
608
|
+
label: 'Integration contributions',
|
|
609
|
+
status: 'info',
|
|
610
|
+
message: 'Skipped — the project integration graph could not be loaded.',
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
if (issues.length === 0) {
|
|
614
|
+
return {
|
|
615
|
+
id: 'integration-issues',
|
|
616
|
+
label: 'Integration contributions',
|
|
617
|
+
status: 'pass',
|
|
618
|
+
message: 'Integration contributions and cross-package relationships are valid.',
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
const errors = issues.filter(issue => issue.severity === 'error').length;
|
|
622
|
+
const details = issues
|
|
623
|
+
.map(issue => `${issue.package}: ${issue.message}`)
|
|
624
|
+
.join(' | ');
|
|
625
|
+
// This check is new, so it warns: a project that passed before keeps
|
|
626
|
+
// passing (spec:AST-046 FR8). `astryx doctor integration` fails on errors.
|
|
627
|
+
return {
|
|
628
|
+
id: 'integration-issues',
|
|
629
|
+
label: 'Integration contributions',
|
|
630
|
+
status: 'warn',
|
|
631
|
+
message: `${issues.length} integration issue(s)${errors > 0 ? `, ${errors} of them errors` : ''}: ${details}`,
|
|
632
|
+
fix: 'Run `astryx doctor integration` for package-specific diagnostics and resolve cross-package precedence in astryx.config.',
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Check 10 — report the detected package manager, and say so when the project's
|
|
589
638
|
* own declaration disagrees with what is on disk.
|
|
590
639
|
*
|
|
591
640
|
* Two states are worth surfacing rather than guessing past, because in both the
|
|
@@ -882,9 +931,13 @@ export async function checkAuthoringDocs(_ctx, options = {}) {
|
|
|
882
931
|
const CLI_DOCS_FIX =
|
|
883
932
|
"Set `namespace` on each CLI doc to the one that reads it: cli/commands for a command, cli/api for an API function or the output schema, error codes, and response types, and authoring for a file an author writes (and list it in AUTHORING_SELF_DOCS).";
|
|
884
933
|
|
|
934
|
+
/** How the docs-tree check's problems are fixed. */
|
|
935
|
+
const DOCS_TREE_FIX =
|
|
936
|
+
'Fix each placement, adoption rule, or link the message names: a placement names a namespace of its own package, one of its slots, and a slot that accepts its kind; exactly one namespace adopts each doc; every route belongs to one doc; every link names a doc that exists, as `[<provider>:]<kind>:<name>`.';
|
|
937
|
+
|
|
885
938
|
/**
|
|
886
939
|
* Every command, API function, schema, and enum doc the CLI ships declares a
|
|
887
|
-
* namespace, and
|
|
940
|
+
* namespace, and something reads it: the docs tree under `astryx docs cli`
|
|
888
941
|
* for `cli/commands` and `cli/api`, `astryx docs authoring` for `authoring`.
|
|
889
942
|
* @param {DoctorContext | Partial<DoctorContext>} _ctx
|
|
890
943
|
* @param {{root?: string, sources?: string[], authoringSources?: string[]}} [options]
|
|
@@ -911,10 +964,9 @@ export async function checkCliDocs(_ctx, options = {}) {
|
|
|
911
964
|
...audit.failed.map(
|
|
912
965
|
({source, error}) => `${source} failed to load: ${error}`,
|
|
913
966
|
),
|
|
914
|
-
...audit.keyProblems.map(problem => `\`astryx docs cli\`: ${problem}`),
|
|
915
967
|
...audit.oversized.map(
|
|
916
968
|
({key, bytes}) =>
|
|
917
|
-
`
|
|
969
|
+
`CLI doc "${key}" is ${kilobytes(bytes)}, over the ${kilobytes(DOC_OUTPUT_BUDGET_BYTES)} one read may return`,
|
|
918
970
|
),
|
|
919
971
|
];
|
|
920
972
|
if (problems.length > 0) {
|
|
@@ -930,7 +982,7 @@ export async function checkCliDocs(_ctx, options = {}) {
|
|
|
930
982
|
id,
|
|
931
983
|
label,
|
|
932
984
|
status: 'pass',
|
|
933
|
-
message: `All ${audit.docs} CLI docs are readable: ${audit.
|
|
985
|
+
message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`astryx docs cli\` tree and ${audit.authoring} in \`astryx docs authoring\`.`,
|
|
934
986
|
};
|
|
935
987
|
} catch (err) {
|
|
936
988
|
return {
|
|
@@ -943,6 +995,85 @@ export async function checkCliDocs(_ctx, options = {}) {
|
|
|
943
995
|
}
|
|
944
996
|
}
|
|
945
997
|
|
|
998
|
+
/**
|
|
999
|
+
* The docs tree builds with no error, and every CLI typed doc in a `cli/...`
|
|
1000
|
+
* group has a route in it (spec:AST-046): each placement names a namespace of
|
|
1001
|
+
* its own package and a slot that accepts it, exactly one namespace adopts
|
|
1002
|
+
* each doc, and each route belongs to one doc.
|
|
1003
|
+
* @param {DoctorContext | Partial<DoctorContext>} _ctx
|
|
1004
|
+
* @param {{tree?: import('../../foundation/doc-compiler/tree.mjs').DocsTree}} [options]
|
|
1005
|
+
* test seam: a tree to check instead of the CLI's own
|
|
1006
|
+
* @returns {Promise<DoctorCheck>}
|
|
1007
|
+
*/
|
|
1008
|
+
export async function checkDocsTree(_ctx, options = {}) {
|
|
1009
|
+
const id = 'docs-tree';
|
|
1010
|
+
const label = 'Docs tree';
|
|
1011
|
+
try {
|
|
1012
|
+
const catalog =
|
|
1013
|
+
/** @type {any} */ (_ctx)?.docsCatalog ?? builtinCatalog();
|
|
1014
|
+
const tree = options.tree ?? (await projectTree(catalog, {fresh: true}));
|
|
1015
|
+
const problems = tree.diagnostics
|
|
1016
|
+
.filter(d => d.severity === 'error')
|
|
1017
|
+
.map(d => `${d.source ?? d.provider ?? 'docs tree'}: ${d.message}`);
|
|
1018
|
+
if (options.tree === undefined) {
|
|
1019
|
+
const {loadCliSelfDocs, CLI_DOC_NAMESPACES} =
|
|
1020
|
+
await import('../../foundation/discovery/cli-self-docs.mjs');
|
|
1021
|
+
const placed = new Set(
|
|
1022
|
+
[...tree.nodes.values()].map(
|
|
1023
|
+
node => `${node.provider}\u0000${node.kind}\u0000${node.name}`,
|
|
1024
|
+
),
|
|
1025
|
+
);
|
|
1026
|
+
for (const {source, doc} of (await loadCliSelfDocs()).loaded) {
|
|
1027
|
+
if (CLI_DOC_NAMESPACES[doc.namespace]?.reader !== 'tree') continue;
|
|
1028
|
+
if (!placed.has(`@astryxdesign/cli\u0000${doc.type}\u0000${doc.name}`)) {
|
|
1029
|
+
problems.push(
|
|
1030
|
+
`${source} has namespace "${doc.namespace}", but no docs-tree namespace adopts it`,
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
// Every link between docs names a doc that exists (spec:AST-047 FR9):
|
|
1035
|
+
// typed fields, reference and workflow blocks, and inline links. A
|
|
1036
|
+
// reference block also includes all it names.
|
|
1037
|
+
for (const node of tree.nodes.values()) {
|
|
1038
|
+
for (const edge of typedEdges(tree, node).unresolved) {
|
|
1039
|
+
problems.push(`${node.route}: ${edge}`);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
problems.push(...(await docsLinkProblems(catalog, tree)));
|
|
1043
|
+
problems.push(
|
|
1044
|
+
...(await docsLinkProblems(catalog, tree, {references: true})),
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
// New findings warn: a project that passed before keeps passing
|
|
1048
|
+
// (0.6 compatibility), and the warning names what to fix.
|
|
1049
|
+
if (problems.length > 0) {
|
|
1050
|
+
return {
|
|
1051
|
+
id,
|
|
1052
|
+
label,
|
|
1053
|
+
status: 'warn',
|
|
1054
|
+
message: joinProblems(problems),
|
|
1055
|
+
fix: DOCS_TREE_FIX,
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
1058
|
+
const nodes = [...tree.nodes.values()];
|
|
1059
|
+
const namespaces = nodes.filter(node => node.kind === 'namespace').length;
|
|
1060
|
+
return {
|
|
1061
|
+
id,
|
|
1062
|
+
label,
|
|
1063
|
+
status: 'pass',
|
|
1064
|
+
message: `The docs tree has ${nodes.length - namespaces} docs in ${namespaces} sections (${tree.roots().length} at the top), each at one route.`,
|
|
1065
|
+
};
|
|
1066
|
+
} catch (err) {
|
|
1067
|
+
return {
|
|
1068
|
+
id,
|
|
1069
|
+
label,
|
|
1070
|
+
status: 'warn',
|
|
1071
|
+
message: `The docs tree could not be built: ${err instanceof Error ? err.message : String(err)}`,
|
|
1072
|
+
fix: 'Reinstall @astryxdesign/cli.',
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
946
1077
|
/**
|
|
947
1078
|
* Every topic reads progressively, in every language it ships: it loads, its
|
|
948
1079
|
* section index and each of its sections fit in one read, and no contributed
|
|
@@ -965,7 +1096,13 @@ export async function checkDocsProgressiveDisclosure(ctx) {
|
|
|
965
1096
|
let topics = 0;
|
|
966
1097
|
const catalog = ctx.docsCatalog;
|
|
967
1098
|
if (catalog) {
|
|
968
|
-
|
|
1099
|
+
// A guide the docs tree places is a topic read by its route; it is held
|
|
1100
|
+
// to the same budget as every flat topic.
|
|
1101
|
+
const guides = [...(await projectTree(catalog)).nodes.values()]
|
|
1102
|
+
// A flat topic in the Unorganized level is checked above, as a topic.
|
|
1103
|
+
.filter(node => node.kind === 'generic' && !node.ref?.flatTopic)
|
|
1104
|
+
.map(guideEntry);
|
|
1105
|
+
for (const entry of [...catalog.entries(), ...guides]) {
|
|
969
1106
|
for (const lang of [null, ...overlayLanguages(entry)]) {
|
|
970
1107
|
const where = lang ? `${entry.name} [${lang}]` : entry.name;
|
|
971
1108
|
try {
|
|
@@ -1019,6 +1156,7 @@ export const SYNC_CHECKS = [
|
|
|
1019
1156
|
checkThemes,
|
|
1020
1157
|
checkImplicitIntegrations,
|
|
1021
1158
|
checkProviderIdentity,
|
|
1159
|
+
checkIntegrationIssues,
|
|
1022
1160
|
checkAgentDocs,
|
|
1023
1161
|
checkPeerDeps,
|
|
1024
1162
|
checkPackageManager,
|
|
@@ -1058,6 +1196,8 @@ export async function runChecks(options = {}) {
|
|
|
1058
1196
|
let docsCatalogIssues = [];
|
|
1059
1197
|
/** @type {string|null} */
|
|
1060
1198
|
let docsCatalogError = null;
|
|
1199
|
+
/** @type {Array<{package: string, code: string, severity: 'warning'|'error', message: string}>|null} */
|
|
1200
|
+
let integrationIssues = null;
|
|
1061
1201
|
try {
|
|
1062
1202
|
const project = await Project.load(cwd);
|
|
1063
1203
|
configTheme =
|
|
@@ -1072,6 +1212,7 @@ export async function runChecks(options = {}) {
|
|
|
1072
1212
|
docsCatalog = null;
|
|
1073
1213
|
docsCatalogError = err instanceof Error ? err.message : String(err);
|
|
1074
1214
|
}
|
|
1215
|
+
integrationIssues = await project.issues();
|
|
1075
1216
|
} catch {
|
|
1076
1217
|
// Best-effort: a missing/invalid config leaves configTheme null.
|
|
1077
1218
|
}
|
|
@@ -1087,6 +1228,7 @@ export async function runChecks(options = {}) {
|
|
|
1087
1228
|
docsCatalog,
|
|
1088
1229
|
docsCatalogIssues,
|
|
1089
1230
|
docsCatalogError,
|
|
1231
|
+
integrationIssues,
|
|
1090
1232
|
configError,
|
|
1091
1233
|
};
|
|
1092
1234
|
|
|
@@ -1101,6 +1243,7 @@ export async function runChecks(options = {}) {
|
|
|
1101
1243
|
}
|
|
1102
1244
|
checks.push(await checkAuthoringDocs(ctx));
|
|
1103
1245
|
checks.push(await checkCliDocs(ctx));
|
|
1246
|
+
checks.push(await checkDocsTree(ctx));
|
|
1104
1247
|
checks.push(await checkDocsProgressiveDisclosure(ctx));
|
|
1105
1248
|
|
|
1106
1249
|
const summary = {pass: 0, warn: 0, fail: 0, info: 0};
|
|
@@ -23,9 +23,11 @@ import {
|
|
|
23
23
|
doctor,
|
|
24
24
|
checkAuthoringDocs,
|
|
25
25
|
checkCliDocs,
|
|
26
|
+
checkDocsTree,
|
|
26
27
|
checkDocsProgressiveDisclosure,
|
|
27
28
|
checkImplicitIntegrations,
|
|
28
29
|
checkProviderIdentity,
|
|
30
|
+
checkIntegrationIssues,
|
|
29
31
|
checkVersionAlignment,
|
|
30
32
|
checkPackageManager,
|
|
31
33
|
} from './doctor.mjs';
|
|
@@ -84,6 +86,27 @@ describe('doctor leaf', () => {
|
|
|
84
86
|
}, SLOW);
|
|
85
87
|
});
|
|
86
88
|
|
|
89
|
+
describe('integration issue check', () => {
|
|
90
|
+
it('surfaces cross-package replacement warnings', () => {
|
|
91
|
+
const check = checkIntegrationIssues({
|
|
92
|
+
integrationIssues: [
|
|
93
|
+
{
|
|
94
|
+
package: '@acme/later',
|
|
95
|
+
code: 'ambiguous_template_replacement',
|
|
96
|
+
severity: 'warning',
|
|
97
|
+
message: 'Later configured replacement wins.',
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
expect(check).toMatchObject({
|
|
103
|
+
id: 'integration-issues',
|
|
104
|
+
status: 'warn',
|
|
105
|
+
message: expect.stringContaining('Later configured replacement wins.'),
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
87
110
|
describe('doctor leaf — degradation & error paths', () => {
|
|
88
111
|
it('does not crash on multiple config files; reports a config FAIL', async () => {
|
|
89
112
|
const dir = mkProject({
|
|
@@ -476,7 +499,7 @@ describe('checkCliDocs', () => {
|
|
|
476
499
|
id: 'cli-docs',
|
|
477
500
|
label: 'CLI docs',
|
|
478
501
|
status: 'pass',
|
|
479
|
-
message: `All ${audit.docs} CLI docs are readable: ${audit.
|
|
502
|
+
message: `All ${audit.docs} CLI docs are readable: ${audit.tree} in the \`astryx docs cli\` tree and ${audit.authoring} in \`astryx docs authoring\`.`,
|
|
480
503
|
});
|
|
481
504
|
},
|
|
482
505
|
SLOW,
|
|
@@ -518,6 +541,71 @@ describe('checkCliDocs', () => {
|
|
|
518
541
|
);
|
|
519
542
|
});
|
|
520
543
|
|
|
544
|
+
describe('checkDocsTree', () => {
|
|
545
|
+
it(
|
|
546
|
+
'passes on this repo: every CLI doc in a cli group has one route',
|
|
547
|
+
async () => {
|
|
548
|
+
const {loadDocsTree} = await import(
|
|
549
|
+
'../../foundation/doc-compiler/tree.mjs'
|
|
550
|
+
);
|
|
551
|
+
const tree = await loadDocsTree({fresh: true});
|
|
552
|
+
const nodes = [...tree.nodes.values()];
|
|
553
|
+
const namespaces = nodes.filter(node => node.kind === 'namespace').length;
|
|
554
|
+
expect(await checkDocsTree()).toEqual({
|
|
555
|
+
id: 'docs-tree',
|
|
556
|
+
label: 'Docs tree',
|
|
557
|
+
status: 'pass',
|
|
558
|
+
message: expect.stringMatching(
|
|
559
|
+
/^The docs tree has \d+ docs in \d+ sections \(\d+ at the top\), each at one route\.$/,
|
|
560
|
+
),
|
|
561
|
+
});
|
|
562
|
+
},
|
|
563
|
+
SLOW,
|
|
564
|
+
);
|
|
565
|
+
|
|
566
|
+
it('fails on a tree with a broken placement, and names the fix', async () => {
|
|
567
|
+
const {buildDocsTree} = await import(
|
|
568
|
+
'../../foundation/doc-compiler/tree.mjs'
|
|
569
|
+
);
|
|
570
|
+
const tree = buildDocsTree({
|
|
571
|
+
namespaces: [
|
|
572
|
+
{
|
|
573
|
+
provider: '@acme/kit',
|
|
574
|
+
providerId: '@acme/kit',
|
|
575
|
+
source: '@acme/kit/tree/guides.doc.mjs',
|
|
576
|
+
doc: {
|
|
577
|
+
type: 'namespace',
|
|
578
|
+
name: 'guides',
|
|
579
|
+
title: 'Guides',
|
|
580
|
+
summary: 'Every guide.',
|
|
581
|
+
slots: {all: {title: 'All', accepts: {kinds: ['generic']}}},
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
],
|
|
585
|
+
docs: [
|
|
586
|
+
{
|
|
587
|
+
provider: '@acme/kit',
|
|
588
|
+
providerId: '@acme/kit',
|
|
589
|
+
source: '@acme/kit/tree/setup.doc.mjs',
|
|
590
|
+
kind: 'generic',
|
|
591
|
+
name: 'setup',
|
|
592
|
+
title: 'Setup',
|
|
593
|
+
summary: 'Set it up.',
|
|
594
|
+
group: null,
|
|
595
|
+
placement: {parent: 'namespace:guidez'},
|
|
596
|
+
},
|
|
597
|
+
],
|
|
598
|
+
});
|
|
599
|
+
const c = await checkDocsTree(undefined, {tree});
|
|
600
|
+
// New findings warn (0.6 compatibility): a broken tree is named, not fatal.
|
|
601
|
+
expect(c).toMatchObject({id: 'docs-tree', status: 'warn'});
|
|
602
|
+
expect(c.message).toContain(
|
|
603
|
+
'@acme/kit/tree/setup.doc.mjs: placement.parent "namespace:guidez" names no namespace; @acme/kit declares "guides".',
|
|
604
|
+
);
|
|
605
|
+
expect(c.fix).toMatch(/a placement names a namespace of its own package/);
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
|
|
521
609
|
describe('checkAuthoringDocs against the public authoring surface', () => {
|
|
522
610
|
const NAMESPACE = 'doctypes/namespace/namespace.doc.mjs';
|
|
523
611
|
const NAMESPACE_TYPES =
|
package/api/index.d.mts
CHANGED
|
@@ -38,7 +38,7 @@ export * from "./integration/pack-check.type.mjs";
|
|
|
38
38
|
export * from "./integration/validate-integration.type.mjs";
|
|
39
39
|
export * from "./integration/authoring-checks.type.mjs";
|
|
40
40
|
export type Logger = import("./logger.mjs").Logger;
|
|
41
|
-
export { themeBuild, themeAdd, themeList, themeListAvailable, themeTargets, themePaletteGenerate, generateTonalPalette, listThemes } from "./theme/theme.mjs";
|
|
41
|
+
export { themeBuild, themeAdd, themeTemplate, themeList, themeListAvailable, themeTargets, themePaletteGenerate, generateTonalPalette, listThemes } from "./theme/theme.mjs";
|
|
42
42
|
export { layoutExpand, layoutCheck, layoutGrammar } from "./layout/layout.mjs";
|
|
43
43
|
export { integrationAdd, integrationAddAgentDoc, integrationAddCodemod, integrationAddComponent, integrationAddDoc, integrationAddTemplate } from "./integration/add-contribution.mjs";
|
|
44
44
|
export { validateIntegration, summarizeIssues } from "./integration/validate-integration.mjs";
|
package/api/index.mjs
CHANGED
package/api/init/init.doc.mjs
CHANGED
|
@@ -31,7 +31,7 @@ export function integrationAddAgentDoc(line: string, options?: import("./integra
|
|
|
31
31
|
*
|
|
32
32
|
* @param {'component'|'doc'|'template'|'codemod'|'agent-doc'|'theme'} kind
|
|
33
33
|
* @param {string} name
|
|
34
|
-
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string}} [options]
|
|
34
|
+
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string, parent?: string}} [options]
|
|
35
35
|
* @returns {Promise<import('./integration-authoring.type.mjs').IntegrationAddResponse>}
|
|
36
36
|
*/
|
|
37
37
|
export function integrationAdd(kind: "component" | "doc" | "template" | "codemod" | "agent-doc" | "theme", name: string, options?: {
|
|
@@ -41,4 +41,5 @@ export function integrationAdd(kind: "component" | "doc" | "template" | "codemod
|
|
|
41
41
|
to?: string;
|
|
42
42
|
replaces?: string;
|
|
43
43
|
extends?: string;
|
|
44
|
+
parent?: string;
|
|
44
45
|
}): Promise<import("./integration-authoring.type.mjs").IntegrationAddResponse>;
|
|
@@ -34,6 +34,11 @@ import {
|
|
|
34
34
|
} from '../../foundation/integrations/integrations.mjs';
|
|
35
35
|
import {isValidSemver} from '../../foundation/env/semver.mjs';
|
|
36
36
|
import {assertContributionVisible} from '../../foundation/integrations/contribution-inventory.mjs';
|
|
37
|
+
import {
|
|
38
|
+
docsTreeCliProblem,
|
|
39
|
+
withDocsTreeCli,
|
|
40
|
+
} from '../../foundation/integrations/cli-requirement.mjs';
|
|
41
|
+
import {discoverIntegrationDocs} from '../../foundation/discovery/docs-discovery.mjs';
|
|
37
42
|
import {findIntegrationComponentDoc} from '../../foundation/discovery/component-discovery.mjs';
|
|
38
43
|
import {parseAgentDocsField} from '../../authoring/integration/schema.mjs';
|
|
39
44
|
import {integrationAddTheme} from './add-theme.mjs';
|
|
@@ -83,6 +88,17 @@ function resolvePackage(cwd) {
|
|
|
83
88
|
}
|
|
84
89
|
const owner = typeof pkg.name === 'string' ? pkg.name : '(local integration)';
|
|
85
90
|
const existingManifest = findLocalIntegrationManifestOrNull(packageDir);
|
|
91
|
+
// The nearest package.json above the cwd may belong to another package (an
|
|
92
|
+
// app that contains the folder). Only a package that is already an
|
|
93
|
+
// integration is found from a subfolder; the first add runs in the package.
|
|
94
|
+
const here = path.resolve(cwd ?? process.cwd());
|
|
95
|
+
if (existingManifest == null && path.resolve(packageDir) !== here) {
|
|
96
|
+
throw new AstryxError(
|
|
97
|
+
`${here} has no package.json. The nearest is ${packageFile} (${owner}), which is not an Astryx integration yet. Run this in your integration package's own directory, next to its package.json.`,
|
|
98
|
+
undefined,
|
|
99
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
86
102
|
const manifestFile =
|
|
87
103
|
existingManifest ?? path.join(packageDir, 'astryx.integration.mjs');
|
|
88
104
|
return {
|
|
@@ -353,7 +369,7 @@ async function addComponent(name, options) {
|
|
|
353
369
|
|
|
354
370
|
/**
|
|
355
371
|
* @param {string} name topic name (must match [\w-]+)
|
|
356
|
-
* @param {{cwd?: string, dryRun?: boolean, replaces?: string, extends?: string}} options
|
|
372
|
+
* @param {{cwd?: string, dryRun?: boolean, replaces?: string, extends?: string, parent?: string}} options
|
|
357
373
|
* @returns {Promise<import('./integration-authoring.type.mjs').IntegrationAddResponse>}
|
|
358
374
|
*/
|
|
359
375
|
async function addDoc(name, options) {
|
|
@@ -372,6 +388,20 @@ async function addDoc(name, options) {
|
|
|
372
388
|
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
373
389
|
);
|
|
374
390
|
}
|
|
391
|
+
if (options.parent != null && (options.replaces != null || options.extends != null)) {
|
|
392
|
+
throw new AstryxError(
|
|
393
|
+
'A guide placed in a namespace has its own route: it cannot also replace or extend a topic.',
|
|
394
|
+
undefined,
|
|
395
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
if (options.parent != null && !/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(options.parent)) {
|
|
399
|
+
throw new AstryxError(
|
|
400
|
+
'--parent must name a namespace in lowercase letters and digits joined by single hyphens, such as "acme".',
|
|
401
|
+
undefined,
|
|
402
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
403
|
+
);
|
|
404
|
+
}
|
|
375
405
|
for (const [option, value] of [
|
|
376
406
|
['--replaces', options.replaces],
|
|
377
407
|
['--extends', options.extends],
|
|
@@ -432,20 +462,92 @@ async function addDoc(name, options) {
|
|
|
432
462
|
}
|
|
433
463
|
|
|
434
464
|
const title = kebabToTitle(name);
|
|
465
|
+
// --parent names a namespace of this package by its name, wherever its file
|
|
466
|
+
// is. An existing one is used as it is: its `guides` slot, or else its only
|
|
467
|
+
// slot that takes a guide. Otherwise the namespace doc is written, unless a
|
|
468
|
+
// file of that name is already something else (spec:AST-046 FR11).
|
|
469
|
+
const namespaceFile =
|
|
470
|
+
options.parent == null
|
|
471
|
+
? null
|
|
472
|
+
: assertWithin(`${options.parent}.doc.mjs`, root, {
|
|
473
|
+
label: 'namespace doc file',
|
|
474
|
+
});
|
|
475
|
+
let parentSlot = 'guides';
|
|
476
|
+
let writeNamespace = false;
|
|
477
|
+
if (options.parent != null && namespaceFile != null) {
|
|
478
|
+
const {namespaces} = await discoverIntegrationDocs({
|
|
479
|
+
name: owner,
|
|
480
|
+
docs: root,
|
|
481
|
+
});
|
|
482
|
+
const existing = namespaces.find(ns => ns.doc.name === options.parent);
|
|
483
|
+
if (existing != null) {
|
|
484
|
+
const takesGuides = Object.entries(existing.doc.slots ?? {})
|
|
485
|
+
.filter(([, slot]) => slot?.accepts?.kinds?.includes('generic'))
|
|
486
|
+
.map(([slotName]) => slotName);
|
|
487
|
+
const slot = takesGuides.includes('guides')
|
|
488
|
+
? 'guides'
|
|
489
|
+
: takesGuides.length === 1
|
|
490
|
+
? takesGuides[0]
|
|
491
|
+
: null;
|
|
492
|
+
if (slot == null) {
|
|
493
|
+
throw new AstryxError(
|
|
494
|
+
takesGuides.length === 0
|
|
495
|
+
? `Namespace "${options.parent}" (${existing.source}) has no slot that takes a guide. Add one, such as guides: {title: 'Guides', accepts: {kinds: ['generic']}}.`
|
|
496
|
+
: `Namespace "${options.parent}" (${existing.source}) has more than one slot that takes a guide (${takesGuides.join(', ')}). Write the guide yourself, and name its slot in its placement.`,
|
|
497
|
+
undefined,
|
|
498
|
+
ERROR_CODES.ERR_INVALID_ARGUMENT,
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
parentSlot = slot;
|
|
502
|
+
} else if (fs.existsSync(namespaceFile)) {
|
|
503
|
+
throw new AstryxError(
|
|
504
|
+
`${projectPath(path.relative(packageDir, namespaceFile))} exists but does not load as the namespace "${options.parent}". Fix or rename that file, or pass another --parent.`,
|
|
505
|
+
undefined,
|
|
506
|
+
ERROR_CODES.ERR_FILE_EXISTS,
|
|
507
|
+
);
|
|
508
|
+
} else {
|
|
509
|
+
writeNamespace = true;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
435
512
|
const relationship = options.replaces
|
|
436
513
|
? `\n replaces: '${options.replaces}',`
|
|
437
514
|
: options.extends
|
|
438
515
|
? `\n extends: '${options.extends}',`
|
|
439
|
-
:
|
|
516
|
+
: options.parent
|
|
517
|
+
? `\n placement: {parent: 'namespace:${options.parent}', slot: '${parentSlot}'},`
|
|
518
|
+
: '';
|
|
519
|
+
const namespaceTitle =
|
|
520
|
+
options.parent == null ? '' : kebabToTitle(options.parent);
|
|
521
|
+
const namespaceContents = `/** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */\nexport default {\n type: 'namespace',\n name: '${options.parent}',\n title: '${namespaceTitle}',\n summary: 'Guides for ${namespaceTitle}.',\n slots: {\n guides: {title: 'Guides', accepts: {kinds: ['generic']}},\n },\n};\n`;
|
|
440
522
|
const docContents = `/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */\nexport default {\n type: 'generic',\n name: '${name}',\n title: '${title}',\n description: '${title} documentation.',${relationship}\n sections: [\n {\n title: 'Overview',\n content: [\n { type: 'prose', text: '${title} documentation.' },\n ],\n },\n ],\n};\n`;
|
|
441
523
|
|
|
442
524
|
/** @type {import('./add-helpers.mjs').WritePlan[]} */
|
|
443
525
|
const plans = [{path: docFile, contents: docContents, createOnly: true}];
|
|
444
|
-
|
|
526
|
+
if (namespaceFile != null && writeNamespace) {
|
|
527
|
+
plans.push({path: namespaceFile, contents: namespaceContents, createOnly: true});
|
|
528
|
+
}
|
|
529
|
+
let pkgUpdate = packageJsonUpdate(
|
|
445
530
|
packageFile,
|
|
446
531
|
rootPath,
|
|
447
532
|
path.basename(manifestFile),
|
|
448
533
|
);
|
|
534
|
+
// A namespace doc needs a CLI that reads it: an older one hides every doc
|
|
535
|
+
// topic the package ships. Declare that CLI as a peer, so an older one fails
|
|
536
|
+
// at install instead (spec:AST-046 FR11).
|
|
537
|
+
if (options.parent != null) {
|
|
538
|
+
const expectedOriginal =
|
|
539
|
+
pkgUpdate?.expectedOriginal ?? fs.readFileSync(packageFile);
|
|
540
|
+
const text = pkgUpdate?.contents ?? expectedOriginal.toString('utf-8');
|
|
541
|
+
const current = JSON.parse(text);
|
|
542
|
+
if (docsTreeCliProblem(current) != null) {
|
|
543
|
+
pkgUpdate = {
|
|
544
|
+
contents:
|
|
545
|
+
JSON.stringify(withDocsTreeCli(current), null, 2) +
|
|
546
|
+
(text.endsWith('\n') ? '\n' : ''),
|
|
547
|
+
expectedOriginal,
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
}
|
|
449
551
|
if (pkgUpdate != null) {
|
|
450
552
|
plans.push({
|
|
451
553
|
path: packageFile,
|
|
@@ -1105,7 +1207,7 @@ export function integrationAddAgentDoc(line, options = {}) {
|
|
|
1105
1207
|
|
|
1106
1208
|
const KIND_OPTIONS = {
|
|
1107
1209
|
component: new Set(['cwd', 'dryRun']),
|
|
1108
|
-
doc: new Set(['cwd', 'dryRun', 'replaces', 'extends']),
|
|
1210
|
+
doc: new Set(['cwd', 'dryRun', 'replaces', 'extends', 'parent']),
|
|
1109
1211
|
template: new Set(['cwd', 'dryRun', 'templateType']),
|
|
1110
1212
|
codemod: new Set(['cwd', 'dryRun', 'to']),
|
|
1111
1213
|
'agent-doc': new Set(['cwd', 'dryRun']),
|
|
@@ -1136,7 +1238,7 @@ function validateKindOptions(kind, options) {
|
|
|
1136
1238
|
*
|
|
1137
1239
|
* @param {'component'|'doc'|'template'|'codemod'|'agent-doc'|'theme'} kind
|
|
1138
1240
|
* @param {string} name
|
|
1139
|
-
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string}} [options]
|
|
1241
|
+
* @param {{cwd?: string, dryRun?: boolean, templateType?: 'page'|'block', to?: string, replaces?: string, extends?: string, parent?: string}} [options]
|
|
1140
1242
|
* @returns {Promise<import('./integration-authoring.type.mjs').IntegrationAddResponse>}
|
|
1141
1243
|
*/
|
|
1142
1244
|
export async function integrationAdd(kind, name, options = {}) {
|