@astryxdesign/cli 0.7.3 → 0.7.4-canary.1a552f2
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 +63 -63
- package/api/component/_adapter.mjs +4 -3
- package/api/component/component.mjs +13 -6
- package/api/component/doc-links.test.mjs +33 -0
- package/api/discover/_adapter.mjs +22 -10
- package/api/discover/_catalog-view.d.mts +2 -0
- package/api/discover/_catalog-view.mjs +1 -0
- package/api/discover/_catalog-view.test.mjs +1 -0
- package/api/discover/detail/detail.mjs +1 -0
- package/api/discover/detail/detail.test.mjs +3 -0
- package/api/discover/detail/doc/doc.mjs +5 -1
- package/api/discover/detail/doc/doc.test.mjs +1 -0
- package/api/discover/detail/item/item.mjs +2 -0
- package/api/discover/detail/item/item.test.mjs +2 -0
- package/api/discover/discover.doc.mjs +4 -4
- package/api/discover/discover.type.d.mts +20 -0
- package/api/discover/discover.type.mjs +5 -0
- package/api/discover/list/list.test.mjs +2 -0
- package/api/discover/search/search.d.mts +3 -2
- package/api/discover/search/search.mjs +26 -7
- package/api/discover/search/search.test.mjs +67 -0
- package/api/docs/_adapter.d.mts +80 -0
- package/api/docs/_adapter.mjs +261 -11
- package/api/docs/detail/detail.mjs +8 -0
- package/api/docs/docOverlays.test.mjs +2 -1
- package/api/docs/docs.d.mts +16 -6
- package/api/docs/docs.doc.mjs +1 -1
- package/api/docs/docs.mjs +55 -6
- package/api/docs/docs.type.d.mts +28 -2
- package/api/docs/docs.type.mjs +13 -3
- package/api/docs/guide-route-targets.test.mjs +1002 -0
- package/api/docs/index/index.mjs +9 -0
- package/api/docs/integration-tree.test.mjs +22 -0
- package/api/docs/integrationDocs.test.mjs +85 -0
- package/api/docs/list/list.mjs +7 -1
- package/api/docs/node/node.mjs +9 -1
- package/api/docs/reference-blocks.test.mjs +1 -1
- package/api/doctor/_adapter.d.mts +40 -0
- package/api/doctor/_adapter.mjs +171 -1
- package/api/doctor/built-checks.d.mts +85 -0
- package/api/doctor/built-checks.mjs +837 -0
- package/api/doctor/built-checks.test.mjs +531 -0
- package/api/doctor/doctor.d.mts +6 -5
- package/api/doctor/doctor.doc.mjs +11 -1
- package/api/doctor/doctor.mjs +18 -3
- package/api/doctor/doctor.type.d.mts +6 -0
- package/api/doctor/doctor.type.mjs +3 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/integration/_adapter.d.mts +11 -2
- package/api/integration/_adapter.mjs +30 -4
- package/api/integration/authoring-checks.mjs +29 -2
- package/api/integration/authoring-checks.test.mjs +131 -1
- package/api/integration/check/check.d.mts +4 -1
- package/api/integration/check/check.mjs +34 -4
- package/api/integration/check/check.test.mjs +49 -0
- package/api/integration/integration-check.type.d.mts +8 -0
- package/api/integration/integration-check.type.mjs +4 -1
- package/api/integration/integrationCheck.doc.mjs +8 -1
- package/api/integration/integrationDocConflicts.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +71 -2
- package/api/integration/pack-check.test.mjs +77 -0
- package/api/integration/validate-integration-case-disk.test.mjs +2 -0
- package/api/integration/validate-integration-gaps.test.mjs +7 -4
- package/api/integration/validate-integration.mjs +96 -14
- package/api/integration/validate-integration.type.d.mts +10 -4
- package/api/integration/validate-integration.type.mjs +10 -5
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/_candidate-score.d.mts +3 -2
- package/api/search/_candidate-score.mjs +66 -3
- package/api/search/_gather-docs.mjs +12 -2
- package/api/search/_priority.mjs +2 -1
- package/api/search/_score.d.mts +2 -1
- package/api/search/_score.mjs +2 -2
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.family-members.test.mjs +124 -0
- package/api/search/search.mjs +28 -0
- package/api/theme/palette/generate/generate.d.mts +8 -0
- package/api/theme/palette/generate/generate.mjs +38 -11
- package/api/theme/palette/generate/generate.test.mjs +83 -4
- package/api/theme/palette/generate/generator.d.mts +6 -0
- package/api/theme/palette/generate/generator.mjs +6 -0
- package/api/theme/theme.type.d.mts +12 -1
- package/api/theme/theme.type.mjs +7 -1
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeList.doc.mjs +1 -1
- package/api/theme/themePaletteGenerate.doc.mjs +1 -1
- package/api/theme/themeTargets.doc.mjs +1 -1
- package/assets/discover/official-packages.json +16 -0
- package/assets/docs/author-a-theme.doc.mjs +15 -15
- package/assets/docs/browser-support.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +16 -16
- package/assets/docs/is-my-code-good.doc.mjs +6 -6
- package/assets/docs/styling-overview.doc.mjs +5 -5
- package/assets/docs/theme.doc.mjs +5 -5
- package/assets/docs/tree/add-a-component.doc.mjs +1 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +2 -2
- package/assets/docs/tree/add-a-topic.doc.mjs +6 -6
- package/assets/docs/tree/agent-guidance.doc.mjs +5 -5
- package/assets/docs/tree/authoring.doc.mjs +2 -2
- package/assets/docs/tree/block-template.doc.mjs +1 -1
- package/assets/docs/tree/check-the-props.doc.mjs +3 -3
- package/assets/docs/tree/check-your-docs.doc.mjs +6 -6
- package/assets/docs/tree/checks.doc.mjs +11 -11
- package/assets/docs/tree/ci-and-containers.doc.mjs +1 -1
- package/assets/docs/tree/cli-command.doc.mjs +6 -6
- package/assets/docs/tree/codemods.doc.mjs +7 -7
- package/assets/docs/tree/component-family.doc.mjs +1 -1
- package/assets/docs/tree/component-imports.doc.mjs +2 -2
- package/assets/docs/tree/component-lookups.doc.mjs +6 -5
- package/assets/docs/tree/computer-agent-guide.doc.mjs +7 -7
- package/assets/docs/tree/computer-integrations.doc.mjs +5 -5
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +3 -3
- 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/doc-syntax.doc.mjs +219 -0
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +39 -7
- package/assets/docs/tree/font-setup.doc.mjs +1 -1
- package/assets/docs/tree/generate-a-palette.doc.mjs +1 -1
- package/assets/docs/tree/global-integrations.doc.mjs +11 -11
- package/assets/docs/tree/global.doc.mjs +2 -2
- package/assets/docs/tree/host-entry.doc.mjs +1 -1
- package/assets/docs/tree/install-once.doc.mjs +4 -4
- package/assets/docs/tree/layout.doc.mjs +1 -1
- package/assets/docs/tree/links.doc.mjs +2 -2
- package/assets/docs/tree/migration-setup.doc.mjs +15 -15
- package/assets/docs/tree/migration.doc.mjs +2 -1
- package/assets/docs/tree/other-libraries.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +2 -2
- package/assets/docs/tree/problems.doc.mjs +8 -8
- package/assets/docs/tree/project-global-or-both.doc.mjs +2 -2
- package/assets/docs/tree/publishing.doc.mjs +7 -7
- package/assets/docs/tree/quick-start.doc.mjs +9 -9
- package/assets/docs/tree/reference.doc.mjs +2 -2
- package/assets/docs/tree/replace-a-core-component.doc.mjs +1 -1
- package/assets/docs/tree/replace-a-core-template.doc.mjs +4 -4
- package/assets/docs/tree/scaffold.doc.mjs +1 -1
- package/assets/docs/tree/sections-and-placement.doc.mjs +3 -3
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +3 -3
- package/assets/docs/tree/short-and-findable.doc.mjs +3 -3
- package/assets/docs/tree/single-component.doc.mjs +4 -4
- package/assets/docs/tree/start-a-template.doc.mjs +5 -5
- package/assets/docs/tree/styling-advanced.doc.mjs +1 -1
- package/assets/docs/tree/styling-libraries.doc.mjs +2 -1
- package/assets/docs/tree/styling.doc.mjs +1 -1
- package/assets/docs/tree/tailwind.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +5 -5
- package/assets/docs/tree/test-template-in-app.doc.mjs +6 -6
- package/assets/docs/tree/tokens-and-setup.doc.mjs +1 -1
- package/assets/docs/tree/troubleshooting.doc.mjs +24 -20
- package/assets/docs/tree/uninstall.doc.mjs +2 -2
- package/assets/docs/tree/updates.doc.mjs +1 -1
- package/assets/docs/tree/upgrading.doc.mjs +3 -3
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +1 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +3 -3
- package/assets/docs/tree/versioning.doc.mjs +4 -4
- package/assets/docs/tree/who-answers.doc.mjs +4 -4
- package/assets/docs/tree/write-the-template-file.doc.mjs +4 -4
- package/assets/docs/use-a-theme.doc.mjs +10 -10
- package/assets/docs/use-integrations.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +15 -15
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +1 -1
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/butter/butterPalettes.generated.receipt.json +1499 -0
- package/assets/templates/themes/butter/butterPalettes.generated.ts +550 -0
- package/assets/templates/themes/butter/butterTheme.ts +274 -234
- package/assets/templates/themes/butter/palette.config.json +484 -0
- package/assets/templates/themes/gothic/gothicPaletteRefs.generated.ts +41 -0
- package/assets/templates/themes/gothic/gothicPalettes.generated.receipt.json +979 -0
- package/assets/templates/themes/gothic/gothicPalettes.generated.ts +271 -0
- package/assets/templates/themes/gothic/gothicTheme.ts +130 -160
- package/assets/templates/themes/gothic/palette.config.json +371 -0
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +51 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.receipt.json +1502 -0
- package/assets/templates/themes/matcha/matchaPalettes.generated.ts +501 -0
- package/assets/templates/themes/matcha/matchaPalettes.ts +21 -0
- package/assets/templates/themes/matcha/matchaTheme.ts +164 -103
- package/assets/templates/themes/matcha/palette.config.json +448 -0
- package/assets/templates/themes/stone/palette.config.json +262 -0
- package/assets/templates/themes/stone/stonePaletteRefs.generated.ts +51 -0
- package/assets/templates/themes/stone/stonePalettes.generated.receipt.json +840 -0
- package/assets/templates/themes/stone/stonePalettes.generated.ts +501 -0
- package/assets/templates/themes/stone/stoneTheme.ts +190 -207
- package/assets/templates/themes/y2k/palette.config.json +166 -0
- package/assets/templates/themes/y2k/y2kPaletteRefs.generated.ts +54 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.receipt.json +872 -0
- package/assets/templates/themes/y2k/y2kPalettes.generated.ts +550 -0
- package/assets/templates/themes/y2k/y2kPalettes.ts +257 -0
- package/assets/templates/themes/y2k/y2kTheme.ts +164 -391
- package/authoring/codemod/codemod.doc.mjs +1 -1
- package/authoring/config/config.doc.mjs +4 -4
- package/authoring/debug/parse.d.mts +1 -1
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/_schema.d.mts +4 -0
- package/authoring/doctypes/_schema.mjs +4 -0
- package/authoring/doctypes/reference/type.ts +14 -2
- package/authoring/gap-report/gap-report.doc.mjs +1 -1
- package/authoring/integration/integration.doc.mjs +6 -6
- package/clients/cli/commands/discover.mjs +1 -1
- package/clients/cli/commands/discover.sources.test.mjs +6 -0
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/docs.mjs +27 -2
- package/clients/cli/commands/docs.test.mjs +1 -1
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +1 -1
- package/clients/cli/commands/doctor.doc.mjs +13 -1
- package/clients/cli/commands/doctor.mjs +25 -9
- package/clients/cli/commands/integration-check.doc.mjs +11 -0
- package/clients/cli/commands/integration-check.test.mjs +36 -3
- package/clients/cli/commands/integration-pack.doc.mjs +1 -1
- package/clients/cli/commands/integration-verify.doc.mjs +1 -1
- package/clients/cli/commands/integration.mjs +15 -3
- package/clients/cli/commands/theme-targets.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +2 -2
- package/clients/cli/lib/define-command.mjs +5 -3
- package/foundation/agent-docs/agent-docs.d.mts +14 -2
- package/foundation/agent-docs/agent-docs.mjs +65 -4
- package/foundation/agent-docs/agent-docs.test.mjs +107 -0
- package/foundation/discovery/docs-discovery.d.mts +93 -2
- package/foundation/discovery/docs-discovery.mjs +237 -8
- package/foundation/discovery/runner-allowlist.d.mts +2 -0
- package/foundation/discovery/runner-allowlist.mjs +4 -0
- package/foundation/discovery/runner-commands.d.mts +29 -13
- package/foundation/discovery/runner-commands.mjs +253 -17
- package/foundation/discovery/stray-pointers.mjs +11 -5
- package/foundation/discovery/stray-pointers.test.mjs +6 -0
- package/foundation/doc-compiler/compile.mjs +8 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +3 -0
- package/foundation/doc-compiler/doc-syntax.d.mts +194 -0
- package/foundation/doc-compiler/doc-syntax.mjs +739 -0
- package/foundation/doc-compiler/doc-syntax.test.mjs +383 -0
- package/foundation/doc-compiler/links.d.mts +13 -16
- package/foundation/doc-compiler/links.mjs +40 -7
- package/foundation/doc-compiler/tree.d.mts +5 -0
- package/foundation/doc-compiler/tree.mjs +9 -0
- package/foundation/env/package-manager.d.mts +18 -0
- package/foundation/env/package-manager.mjs +40 -0
- package/foundation/integrations/cli-requirement.d.mts +29 -0
- package/foundation/integrations/cli-requirement.mjs +47 -0
- package/foundation/integrations/cli-requirement.test.mjs +23 -2
- package/foundation/response/error-codes.test.mjs +9 -0
- package/foundation/response/response-types.doc.mjs +11 -11
- package/foundation/response/response-types.doc.test.mjs +29 -0
- package/package.json +9 -9
|
@@ -67,6 +67,29 @@ const INTEGRATION_DOC_SUFFIXES = ['.doc.ts', '.doc.mjs', '.doc.js'];
|
|
|
67
67
|
/** A topic name is a CLI argument and a URL segment; keep it to both. */
|
|
68
68
|
const TOPIC_NAME_RE = /^[\w-]+$/;
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Whether a `replaces` or `extends` names a route of the docs tree rather than
|
|
72
|
+
* a flat topic: a topic name never holds a `/`, and a guide the tree places is
|
|
73
|
+
* always read by a route that does.
|
|
74
|
+
* @param {unknown} target
|
|
75
|
+
* @returns {target is string}
|
|
76
|
+
*/
|
|
77
|
+
export function isGuideRoute(target) {
|
|
78
|
+
return typeof target === 'string' && target.includes('/');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* What the integrations do to one guide the docs tree places, in configured
|
|
83
|
+
* order: a replacement, and the extensions merged onto whatever is there.
|
|
84
|
+
* @typedef {object} GuideOverlay
|
|
85
|
+
* @property {DocsTopicRecord | null} replacement the doc readers get at the
|
|
86
|
+
* route instead of the guide; the last package configured wins
|
|
87
|
+
* @property {Array<{package: string, path: string, providerId?: string}>} extensions
|
|
88
|
+
* extensions authored after the replacement, if any, in configured order
|
|
89
|
+
* @property {string} [replacedPackage] the package of the replacement this one
|
|
90
|
+
* took over from, when the guide was replaced twice
|
|
91
|
+
*/
|
|
92
|
+
|
|
70
93
|
/**
|
|
71
94
|
* @typedef {object} DocsTopicRecord A doc file discovered under a docs root.
|
|
72
95
|
* @property {string} name
|
|
@@ -92,6 +115,8 @@ const TOPIC_NAME_RE = /^[\w-]+$/;
|
|
|
92
115
|
* @property {string} [description]
|
|
93
116
|
* @property {string|null} [category]
|
|
94
117
|
* @property {string} [replaces] the topic this one took the place of
|
|
118
|
+
* @property {string} [replacedPackage] the package whose topic or guide this
|
|
119
|
+
* one took the place of
|
|
95
120
|
* @property {Array<{package: string, path: string, providerId?: string}>} extensions
|
|
96
121
|
* overlays to merge onto the base doc, in the order their integrations were
|
|
97
122
|
* configured; each section an extension adds resolves its links against the
|
|
@@ -205,7 +230,21 @@ const BLOCK_FIELD_VALUES = {
|
|
|
205
230
|
const PROJECTION_FIELDS = ['fields', 'sections'];
|
|
206
231
|
|
|
207
232
|
/** Keys a section may carry. */
|
|
208
|
-
const SECTION_FIELDS = [
|
|
233
|
+
const SECTION_FIELDS = [
|
|
234
|
+
'id',
|
|
235
|
+
'title',
|
|
236
|
+
'category',
|
|
237
|
+
'content',
|
|
238
|
+
'previewType',
|
|
239
|
+
'before',
|
|
240
|
+
'after',
|
|
241
|
+
];
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The fields an extension section places itself with: the key of the base
|
|
245
|
+
* section it goes before or after. Read only by a merge, never by a reader.
|
|
246
|
+
*/
|
|
247
|
+
export const SECTION_POSITION_FIELDS = ['before', 'after'];
|
|
209
248
|
|
|
210
249
|
/**
|
|
211
250
|
* Check the fields the docs surfaces actually read. `parseDoc` is the outer
|
|
@@ -265,6 +304,19 @@ export function problemsInTopic(doc, {placement = false} = {}) {
|
|
|
265
304
|
problems.push(`${at}.${key}: not a field of a section`);
|
|
266
305
|
}
|
|
267
306
|
}
|
|
307
|
+
for (const field of SECTION_POSITION_FIELDS) {
|
|
308
|
+
const value = section?.[field];
|
|
309
|
+
if (value != null && (typeof value !== 'string' || value === '')) {
|
|
310
|
+
problems.push(
|
|
311
|
+
`${at}.${field}: expected the key of a section, as \`--index\` shows it`,
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (section?.before != null && section?.after != null) {
|
|
316
|
+
problems.push(
|
|
317
|
+
`${at}: sets both \`before\` and \`after\`; a section goes in one place`,
|
|
318
|
+
);
|
|
319
|
+
}
|
|
268
320
|
if (!Array.isArray(section?.content)) {
|
|
269
321
|
problems.push(`${at}.content: expected an array of blocks`);
|
|
270
322
|
return;
|
|
@@ -565,6 +617,7 @@ export async function discoverIntegrationDocs(integration) {
|
|
|
565
617
|
kind: 'generic',
|
|
566
618
|
name: parsed.name,
|
|
567
619
|
title: parsed.title,
|
|
620
|
+
// Rendered once, where the tree is built (api/docs/_adapter.mjs).
|
|
568
621
|
summary: parsed.description,
|
|
569
622
|
group: null,
|
|
570
623
|
placement: parsed.placement,
|
|
@@ -599,8 +652,9 @@ export async function discoverIntegrationDocs(integration) {
|
|
|
599
652
|
/**
|
|
600
653
|
* Merge an extension onto a base topic: a section with a stable `id` replaces
|
|
601
654
|
* the base section with the same `id`; legacy sections without IDs fall back to
|
|
602
|
-
* title matching. A section with no match is
|
|
603
|
-
*
|
|
655
|
+
* title matching. A section with no match is added: before or after the
|
|
656
|
+
* section whose key its `before` or `after` names, else at the end. The title
|
|
657
|
+
* and description stay the base topic's: an extension adds to a topic, it never
|
|
604
658
|
* renames it. A topic that `replaces` another is the one that renames.
|
|
605
659
|
*
|
|
606
660
|
* Keyed by section TITLE rather than by position, the way the localization
|
|
@@ -613,22 +667,123 @@ export async function discoverIntegrationDocs(integration) {
|
|
|
613
667
|
* @returns {any} a new doc; neither input is mutated
|
|
614
668
|
*/
|
|
615
669
|
export function mergeTopic(base, overlay) {
|
|
670
|
+
return mergeTopicReport(base, overlay).doc;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* {@link mergeTopic}, also naming each `before` or `after` that found no
|
|
675
|
+
* section: that section was added at the end instead.
|
|
676
|
+
*
|
|
677
|
+
* @param {any} base
|
|
678
|
+
* @param {any} overlay
|
|
679
|
+
* @returns {{doc: any, unplaced: Array<{section: string, field: 'before' | 'after', key: string}>}}
|
|
680
|
+
*/
|
|
681
|
+
export function mergeTopicReport(base, overlay) {
|
|
616
682
|
const sections = [...(base.sections ?? [])];
|
|
617
|
-
|
|
683
|
+
/** @type {Array<{section: string, field: 'before' | 'after', key: string}>} */
|
|
684
|
+
const unplaced = [];
|
|
685
|
+
|
|
686
|
+
for (const authored of overlay.sections ?? []) {
|
|
687
|
+
const section = withoutPosition(authored);
|
|
618
688
|
const at = findMergeTarget(sections, section);
|
|
619
689
|
if (at === -1) {
|
|
620
|
-
|
|
690
|
+
const field = authored.before != null ? 'before' : 'after';
|
|
691
|
+
const key = authored[field];
|
|
692
|
+
if (typeof key !== 'string') {
|
|
693
|
+
sections.push(section);
|
|
694
|
+
continue;
|
|
695
|
+
}
|
|
696
|
+
const anchor = sections.findIndex(
|
|
697
|
+
candidate => sectionKey(candidate) === key || candidate.id === key,
|
|
698
|
+
);
|
|
699
|
+
if (anchor === -1) {
|
|
700
|
+
unplaced.push({section: sectionKey(section), field, key});
|
|
701
|
+
sections.push(section);
|
|
702
|
+
} else if (field === 'before') {
|
|
703
|
+
// Placed just before a section another was placed `after`, it joins
|
|
704
|
+
// that section's group, so later sections placed there follow both.
|
|
705
|
+
if (sections[anchor][PLACED_AFTER] != null) {
|
|
706
|
+
Object.defineProperty(section, PLACED_AFTER, {
|
|
707
|
+
value: sections[anchor][PLACED_AFTER],
|
|
708
|
+
configurable: true,
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
sections.splice(anchor, 0, section);
|
|
712
|
+
} else {
|
|
713
|
+
// Sections placed after one key keep their order, across every
|
|
714
|
+
// extension merged onto the topic: each goes after every section
|
|
715
|
+
// placed there before it, and after the sections placed after those.
|
|
716
|
+
const group = new Set([key]);
|
|
717
|
+
let at = anchor + 1;
|
|
718
|
+
while (at < sections.length && group.has(sections[at][PLACED_AFTER])) {
|
|
719
|
+
group.add(sectionKey(sections[at]));
|
|
720
|
+
at += 1;
|
|
721
|
+
}
|
|
722
|
+
Object.defineProperty(section, PLACED_AFTER, {
|
|
723
|
+
value: key,
|
|
724
|
+
configurable: true,
|
|
725
|
+
});
|
|
726
|
+
sections.splice(at, 0, section);
|
|
727
|
+
}
|
|
621
728
|
} else {
|
|
622
729
|
// A legacy extension that replaces a section which has since gained a
|
|
623
|
-
// stable ID keeps that ID, so readers addressing it keep working.
|
|
730
|
+
// stable ID keeps that ID, so readers addressing it keep working. A
|
|
731
|
+
// replacing section keeps the place of the one it replaces.
|
|
624
732
|
const replaced = sections[at];
|
|
625
|
-
|
|
733
|
+
const replacing =
|
|
626
734
|
section.id == null && replaced.id != null
|
|
627
735
|
? withSourceTitle({...section, id: replaced.id}, sourceTitle(section))
|
|
628
736
|
: section;
|
|
737
|
+
// It also keeps the place an earlier `after` gave the one it replaces,
|
|
738
|
+
// so sections placed after that key later still follow it.
|
|
739
|
+
if (replaced[PLACED_AFTER] != null) {
|
|
740
|
+
const placed = replacing === section ? withoutPosition({...section}) : replacing;
|
|
741
|
+
for (const symbol of Object.getOwnPropertySymbols(section)) {
|
|
742
|
+
if (!(symbol in placed)) {
|
|
743
|
+
Object.defineProperty(
|
|
744
|
+
placed,
|
|
745
|
+
symbol,
|
|
746
|
+
/** @type {PropertyDescriptor} */ (
|
|
747
|
+
Object.getOwnPropertyDescriptor(section, symbol)
|
|
748
|
+
),
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
Object.defineProperty(placed, PLACED_AFTER, {
|
|
753
|
+
value: replaced[PLACED_AFTER],
|
|
754
|
+
configurable: true,
|
|
755
|
+
});
|
|
756
|
+
sections[at] = placed;
|
|
757
|
+
} else {
|
|
758
|
+
sections[at] = replacing;
|
|
759
|
+
}
|
|
629
760
|
}
|
|
630
761
|
}
|
|
631
|
-
return {...base, sections};
|
|
762
|
+
return {doc: {...base, sections}, unplaced};
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
/** The key a merged section was placed `after`, so later ones follow it. */
|
|
766
|
+
const PLACED_AFTER = Symbol('astryx.docs.placedAfter');
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* A section without the fields that place it; readers never see them.
|
|
770
|
+
* @param {any} section
|
|
771
|
+
* @returns {any}
|
|
772
|
+
*/
|
|
773
|
+
export function withoutPosition(section) {
|
|
774
|
+
if (section?.before == null && section?.after == null) return section;
|
|
775
|
+
const {before: _before, after: _after, ...rest} = section;
|
|
776
|
+
// Copy every own symbol (the provider and authored-title marks) too.
|
|
777
|
+
for (const symbol of Object.getOwnPropertySymbols(section)) {
|
|
778
|
+
Object.defineProperty(
|
|
779
|
+
rest,
|
|
780
|
+
symbol,
|
|
781
|
+
/** @type {PropertyDescriptor} */ (
|
|
782
|
+
Object.getOwnPropertyDescriptor(section, symbol)
|
|
783
|
+
),
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
return rest;
|
|
632
787
|
}
|
|
633
788
|
|
|
634
789
|
/**
|
|
@@ -723,6 +878,71 @@ export class DocsCatalog {
|
|
|
723
878
|
#treeInputs = [];
|
|
724
879
|
/** @type {Array<{package: string, message: string}>} */
|
|
725
880
|
#issues = [];
|
|
881
|
+
/** @type {Map<string, GuideOverlay>} lowercased route → what applies there */
|
|
882
|
+
#guideOverlays = new Map();
|
|
883
|
+
/** @type {DocsTopicRecord[]} every doc that targets a route, in order */
|
|
884
|
+
#guideTargeters = [];
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* Record a doc that replaces or extends a guide the docs tree places, by
|
|
888
|
+
* its route. Whether the route holds such a guide is known only once the
|
|
889
|
+
* tree is built: {@link guideOverlay} applies the record there, and a route
|
|
890
|
+
* that holds none applies nothing.
|
|
891
|
+
* @param {DocsTopicRecord} record
|
|
892
|
+
* @returns {import('../integrations/issue').AstryxIntegrationIssue | null}
|
|
893
|
+
*/
|
|
894
|
+
#targetGuide(record) {
|
|
895
|
+
const route = /** @type {string} */ (
|
|
896
|
+
record.replaces ?? record.extendsTopic
|
|
897
|
+
);
|
|
898
|
+
const key = route.toLowerCase();
|
|
899
|
+
const overlay = this.#guideOverlays.get(key) ?? {
|
|
900
|
+
replacement: null,
|
|
901
|
+
extensions: [],
|
|
902
|
+
};
|
|
903
|
+
if (record.replaces != null) {
|
|
904
|
+
const earlier = overlay.replacement;
|
|
905
|
+
if (earlier) {
|
|
906
|
+
// As with a flat topic, the later-configured doc wins, and reads name
|
|
907
|
+
// the replacement it took over from. Unlike a flat topic's, this is
|
|
908
|
+
// no warning: a new failing finding joins only in a minor release
|
|
909
|
+
// (architecture:cli-surface INV35); `integration validate` lists one
|
|
910
|
+
// package's two replacements of a guide as a note.
|
|
911
|
+
overlay.replacedPackage = earlier.package;
|
|
912
|
+
}
|
|
913
|
+
// Extensions were authored against the content that just went away.
|
|
914
|
+
overlay.replacement = record;
|
|
915
|
+
overlay.extensions = [];
|
|
916
|
+
} else {
|
|
917
|
+
overlay.extensions.push({
|
|
918
|
+
package: record.package,
|
|
919
|
+
path: record.path,
|
|
920
|
+
...(record.providerId ? {providerId: record.providerId} : {}),
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
this.#guideOverlays.set(key, overlay);
|
|
924
|
+
this.#guideTargeters.push(record);
|
|
925
|
+
return null;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* What the integrations do to the guide the docs tree places at `route`, or
|
|
930
|
+
* null when they leave it as it is.
|
|
931
|
+
* @param {string} route
|
|
932
|
+
* @returns {GuideOverlay | null}
|
|
933
|
+
*/
|
|
934
|
+
guideOverlay(route) {
|
|
935
|
+
return this.#guideOverlays.get(route.toLowerCase()) ?? null;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* Every doc that replaces or extends a guide by its route, in configured
|
|
940
|
+
* order, so a check can name a route that holds no guide.
|
|
941
|
+
* @returns {ReadonlyArray<DocsTopicRecord>}
|
|
942
|
+
*/
|
|
943
|
+
get guideTargeters() {
|
|
944
|
+
return this.#guideTargeters;
|
|
945
|
+
}
|
|
726
946
|
|
|
727
947
|
/**
|
|
728
948
|
* Record a doc file a package ships that did not load. Its package's docs
|
|
@@ -810,6 +1030,9 @@ export class DocsCatalog {
|
|
|
810
1030
|
add(record) {
|
|
811
1031
|
if (record.extendsTopic != null) {
|
|
812
1032
|
const target = this.resolve(record.extendsTopic);
|
|
1033
|
+
if (!target && isGuideRoute(record.extendsTopic)) {
|
|
1034
|
+
return this.#targetGuide(record);
|
|
1035
|
+
}
|
|
813
1036
|
if (!target) {
|
|
814
1037
|
return {
|
|
815
1038
|
code: 'invalid_doc',
|
|
@@ -827,6 +1050,9 @@ export class DocsCatalog {
|
|
|
827
1050
|
|
|
828
1051
|
if (record.replaces != null) {
|
|
829
1052
|
const target = this.resolve(record.replaces);
|
|
1053
|
+
if (!target && isGuideRoute(record.replaces)) {
|
|
1054
|
+
return this.#targetGuide(record);
|
|
1055
|
+
}
|
|
830
1056
|
if (!target) {
|
|
831
1057
|
return {
|
|
832
1058
|
code: 'invalid_doc',
|
|
@@ -859,6 +1085,9 @@ export class DocsCatalog {
|
|
|
859
1085
|
description: record.description,
|
|
860
1086
|
category: record.category,
|
|
861
1087
|
replaces: replaced,
|
|
1088
|
+
// The package whose topic it took over: an earlier replacement's, when
|
|
1089
|
+
// the topic was already replaced.
|
|
1090
|
+
replacedPackage: target.package,
|
|
862
1091
|
...(record.providerId ? {providerId: record.providerId} : {}),
|
|
863
1092
|
// Extensions were authored against the content that just went away.
|
|
864
1093
|
extensions: [],
|
|
@@ -33,6 +33,8 @@ export const RUNNER_COMMAND_ALLOWLIST: Readonly<{
|
|
|
33
33
|
'packages/cli/assets/docs/tree/who-answers.doc.mjs': "explains how printed commands start, the pinned `npx @astryxdesign/cli@<version>` among them";
|
|
34
34
|
'packages/cli/assets/docs/tree/project-global-or-both.doc.mjs': "compares running the CLI with npx to installing it, and is found by searching for that command";
|
|
35
35
|
'packages/cli/assets/docs/tree/install-once.doc.mjs': "names a pinned release, `npx @astryxdesign/cli@<version>`, which answers as that version";
|
|
36
|
+
'packages/cli/assets/docs/tree/doc-syntax.doc.mjs': "shows what each doc token renders as, in every package manager";
|
|
37
|
+
'packages/cli/assets/docs/tree/add-a-topic.doc.mjs': "shows what a reader sees for a command token, with their runner";
|
|
36
38
|
'packages/cli/clients/cli/commands/upgrade.doc.mjs': "quotes the command upgrade prints when the CLI is older than Core, pinned to the matching release";
|
|
37
39
|
}>;
|
|
38
40
|
}>;
|
|
@@ -45,6 +45,10 @@ export const RUNNER_COMMAND_ALLOWLIST = Object.freeze({
|
|
|
45
45
|
'compares running the CLI with npx to installing it, and is found by searching for that command',
|
|
46
46
|
'packages/cli/assets/docs/tree/install-once.doc.mjs':
|
|
47
47
|
'names a pinned release, `npx @astryxdesign/cli@<version>`, which answers as that version',
|
|
48
|
+
'packages/cli/assets/docs/tree/doc-syntax.doc.mjs':
|
|
49
|
+
'shows what each doc token renders as, in every package manager',
|
|
50
|
+
'packages/cli/assets/docs/tree/add-a-topic.doc.mjs':
|
|
51
|
+
'shows what a reader sees for a command token, with their runner',
|
|
48
52
|
'packages/cli/clients/cli/commands/upgrade.doc.mjs':
|
|
49
53
|
'quotes the command upgrade prints when the CLI is older than Core, pinned to the matching release',
|
|
50
54
|
}),
|
|
@@ -14,24 +14,28 @@ export function runnerCommandsIn(text: string): {
|
|
|
14
14
|
download: boolean;
|
|
15
15
|
}[];
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
21
|
-
* @
|
|
22
|
-
* @
|
|
23
|
-
* @property {number | null} line the file line that holds it, when found
|
|
24
|
-
* @property {string} command the command as written
|
|
25
|
-
* @property {string} message the bare command to write instead
|
|
17
|
+
* The doc-syntax findings in one string of a doc, in order: runner commands,
|
|
18
|
+
* package-manager commands, bare Astryx commands and tokens that do not
|
|
19
|
+
* parse, each with what to write instead.
|
|
20
|
+
* @param {string} text
|
|
21
|
+
* @param {string | null} lang the code block's language; null for text
|
|
22
|
+
* @returns {{at: number, written: string, code: string, fix: string}[]}
|
|
26
23
|
*/
|
|
24
|
+
export function docCommandsIn(text: string, lang: string | null): {
|
|
25
|
+
at: number;
|
|
26
|
+
written: string;
|
|
27
|
+
code: string;
|
|
28
|
+
fix: string;
|
|
29
|
+
}[];
|
|
27
30
|
/**
|
|
28
|
-
*
|
|
31
|
+
* The doc-syntax findings in a package's topics, each placed on the file line
|
|
32
|
+
* that holds it.
|
|
29
33
|
*
|
|
30
34
|
* @param {{records: {name: string, path: string}[], guides?: {name: string, ref?: {topicFile?: string}}[]}} discovered
|
|
31
35
|
* the package's docs, as discoverIntegrationDocs returns them
|
|
32
36
|
* @returns {Promise<RunnerCommand[]>}
|
|
33
37
|
*/
|
|
34
|
-
export function
|
|
38
|
+
export function findDocCommands(discovered: {
|
|
35
39
|
records: {
|
|
36
40
|
name: string;
|
|
37
41
|
path: string;
|
|
@@ -43,6 +47,14 @@ export function findRunnerCommands(discovered: {
|
|
|
43
47
|
};
|
|
44
48
|
}[];
|
|
45
49
|
}): Promise<RunnerCommand[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Runner commands in a package's topics: the `runner_command` findings of
|
|
52
|
+
* {@link findDocCommands}.
|
|
53
|
+
*
|
|
54
|
+
* @param {Parameters<typeof findDocCommands>[0]} discovered
|
|
55
|
+
* @returns {Promise<RunnerCommand[]>}
|
|
56
|
+
*/
|
|
57
|
+
export function findRunnerCommands(discovered: Parameters<typeof findDocCommands>[0]): Promise<RunnerCommand[]>;
|
|
46
58
|
/**
|
|
47
59
|
* The CLI's top-level commands, the words that make a project runner's
|
|
48
60
|
* `astryx <word>` a command; runner-commands.test.mjs keeps the list equal to
|
|
@@ -50,9 +62,13 @@ export function findRunnerCommands(discovered: {
|
|
|
50
62
|
*/
|
|
51
63
|
export const CLI_COMMANDS: readonly string[];
|
|
52
64
|
/**
|
|
53
|
-
*
|
|
65
|
+
* A command a topic writes that the doc syntax writes another way: with a
|
|
66
|
+
* runner in front (`runner_command`), a package-manager command written for
|
|
67
|
+
* one package manager (`package_manager_command`), a bare Astryx command
|
|
68
|
+
* (`plain_command`), or a doc token that does not parse (`doc_token`).
|
|
54
69
|
*/
|
|
55
70
|
export type RunnerCommand = {
|
|
71
|
+
code: string;
|
|
56
72
|
topic: string;
|
|
57
73
|
/**
|
|
58
74
|
* the title of the section it is in
|
|
@@ -71,7 +87,7 @@ export type RunnerCommand = {
|
|
|
71
87
|
*/
|
|
72
88
|
command: string;
|
|
73
89
|
/**
|
|
74
|
-
*
|
|
90
|
+
* what to write instead
|
|
75
91
|
*/
|
|
76
92
|
message: string;
|
|
77
93
|
};
|