@astryxdesign/cli 0.6.3-canary.039a67e → 0.6.3-canary.0550afd
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 +209 -28
- package/api/docs/_adapter.mjs +667 -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 +35 -15
- package/api/docs/docs.mjs +44 -8
- package/api/docs/docs.test.mjs +158 -4
- package/api/docs/docs.type.d.mts +165 -2
- package/api/docs/docs.type.mjs +101 -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 +547 -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/doctor/doctor.d.mts +30 -2
- package/api/doctor/doctor.mjs +146 -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 +125 -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 +2 -2
- package/assets/docs/styling.doc.mjs +4 -4
- package/assets/docs/theme.doc.mjs +3 -3
- 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/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/namespace/namespace.doc.mjs +5 -9
- package/authoring/doctypes/reference/reference.doc.mjs +3 -3
- package/authoring/doctypes/reference/type.ts +3 -0
- 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.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 +175 -18
- 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.test.mjs +17 -7
- 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 +105 -8
- package/foundation/discovery/docs-discovery.mjs +177 -13
- package/foundation/discovery/docs-discovery.test.mjs +56 -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 +3 -2
- package/foundation/doc-compiler/lenses.mjs +2 -1
- package/foundation/doc-compiler/links.d.mts +135 -0
- package/foundation/doc-compiler/links.mjs +253 -0
- package/foundation/doc-compiler/links.test.mjs +139 -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 +109 -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
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
* - Discovery methods (components/templates/codemods/docs/themes) are MEMOIZED per
|
|
22
22
|
* instance (via the pluggable cache) and orchestrate the EXISTING discovery
|
|
23
23
|
* functions — Project never reimplements discovery.
|
|
24
|
-
* - SKIP + WARN policy:
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
24
|
+
* - SKIP + WARN policy: discovery records each integration issue. Other valid
|
|
25
|
+
* contribution kinds remain available; invalid template and component files
|
|
26
|
+
* do not hide valid siblings. A manifest load failure still withdraws the
|
|
27
|
+
* package because its roots cannot be trusted.
|
|
28
28
|
* - `issues()` returns the deduped accumulated set, and (when called
|
|
29
29
|
* directly) fills in validation for any configured integration not yet
|
|
30
30
|
* visited by a discovery call, so it is always complete on demand.
|
|
@@ -52,11 +52,13 @@ import {
|
|
|
52
52
|
import {
|
|
53
53
|
CORE_PACKAGE,
|
|
54
54
|
discoverOwnedComponents,
|
|
55
|
-
|
|
55
|
+
discoverValidIntegrationComponents,
|
|
56
56
|
} from '../discovery/component-discovery.mjs';
|
|
57
57
|
import {findCoreDir} from '../fs/paths.mjs';
|
|
58
58
|
import {
|
|
59
|
-
|
|
59
|
+
applyTemplateReplacements,
|
|
60
|
+
effectiveTemplateDiscovery,
|
|
61
|
+
discoverAllUnresolved as discoverTemplates,
|
|
60
62
|
discoverIntegrationTemplatesForOne,
|
|
61
63
|
} from '../discovery/template-adapter.mjs';
|
|
62
64
|
import {
|
|
@@ -72,10 +74,7 @@ import {
|
|
|
72
74
|
discoverIntegrationCodemods,
|
|
73
75
|
selectIntegrationCodemods,
|
|
74
76
|
} from '../../assets/codemods/integration-discovery.mjs';
|
|
75
|
-
import {
|
|
76
|
-
INVALID_AGENT_DOCS,
|
|
77
|
-
validateLoadedIntegration,
|
|
78
|
-
} from '../integrations/validate-contributions.mjs';
|
|
77
|
+
import {validateLoadedIntegration} from '../integrations/validate-contributions.mjs';
|
|
79
78
|
import {
|
|
80
79
|
InMemoryConfigCache,
|
|
81
80
|
cacheKey,
|
|
@@ -346,6 +345,8 @@ export class Project {
|
|
|
346
345
|
* @type {Set<object>}
|
|
347
346
|
*/
|
|
348
347
|
#visitedIssues = new Set();
|
|
348
|
+
/** @type {Promise<Array<object>> | null} */
|
|
349
|
+
#templatesPromise = null;
|
|
349
350
|
|
|
350
351
|
/**
|
|
351
352
|
* @param {object} init
|
|
@@ -597,22 +598,6 @@ export class Project {
|
|
|
597
598
|
return integration?.name ?? integration?.__spec ?? '(integration)';
|
|
598
599
|
}
|
|
599
600
|
|
|
600
|
-
/**
|
|
601
|
-
* Whether this package has an error that invalidates its regular manifest
|
|
602
|
-
* contributions. Invalid `agentDocs` blocks agent-doc writes only; it must not
|
|
603
|
-
* withdraw components, templates, docs, or codemods.
|
|
604
|
-
* @param {string} pkg
|
|
605
|
-
* @returns {boolean}
|
|
606
|
-
*/
|
|
607
|
-
#hasBlockingContributionIssue(pkg) {
|
|
608
|
-
return this.#issues.some(
|
|
609
|
-
issue =>
|
|
610
|
-
issue.package === pkg &&
|
|
611
|
-
issue.severity === 'error' &&
|
|
612
|
-
issue.code !== INVALID_AGENT_DOCS,
|
|
613
|
-
);
|
|
614
|
-
}
|
|
615
|
-
|
|
616
601
|
/**
|
|
617
602
|
* Validate one loaded integration and collect any issues. Marks the
|
|
618
603
|
* integration visited so issues() won't redo the work. Best-effort: a
|
|
@@ -649,9 +634,9 @@ export class Project {
|
|
|
649
634
|
/**
|
|
650
635
|
* Core + integration component ownership records. Wraps
|
|
651
636
|
* discoverOwnedComponents for core and discoverIntegrationComponents (via
|
|
652
|
-
* discoverOwnedComponents) for integrations
|
|
653
|
-
*
|
|
654
|
-
*
|
|
637
|
+
* discoverOwnedComponents) for integrations. Invalid component records are
|
|
638
|
+
* omitted and reported; valid component siblings and other contribution kinds
|
|
639
|
+
* remain available. Memoized per instance.
|
|
655
640
|
*
|
|
656
641
|
* @returns {Promise<Array<{name: string, package: string, group: string|null, docPath: string|null, sourcePath: string|null, issuesUrl: string|undefined}>>}
|
|
657
642
|
*/
|
|
@@ -671,18 +656,17 @@ export class Project {
|
|
|
671
656
|
}
|
|
672
657
|
}
|
|
673
658
|
|
|
674
|
-
// Each integration
|
|
659
|
+
// Each integration is discovered independently. Invalid records are
|
|
660
|
+
// omitted below without hiding valid siblings or other contribution kinds.
|
|
675
661
|
for (const integration of this.#loadedIntegrations) {
|
|
676
662
|
await this.#collectIssues(integration);
|
|
677
663
|
const pkg = this.#pkgLabel(integration);
|
|
678
|
-
if (this.#hasBlockingContributionIssue(pkg)) continue;
|
|
679
664
|
try {
|
|
680
|
-
//
|
|
681
|
-
//
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
}
|
|
665
|
+
// #collectIssues (above) already reported each withdrawn record,
|
|
666
|
+
// with its fix, through the same discovery.
|
|
667
|
+
const {components} =
|
|
668
|
+
await discoverValidIntegrationComponents(integration);
|
|
669
|
+
records.push(...components);
|
|
686
670
|
} catch (err) {
|
|
687
671
|
this.#pushIssue(pkg, {
|
|
688
672
|
code: 'invalid_component',
|
|
@@ -697,17 +681,21 @@ export class Project {
|
|
|
697
681
|
}
|
|
698
682
|
|
|
699
683
|
/**
|
|
700
|
-
* Core + integration templates, type-tagged
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
684
|
+
* Core + integration templates, type-tagged, with valid integration
|
|
685
|
+
* replacements projected over their Core targets. Wraps raw template discovery
|
|
686
|
+
* (Core + external blocks) and discoverIntegrationTemplatesForOne per integration
|
|
687
|
+
* so unusable template files are reported and omitted while valid siblings
|
|
688
|
+
* remain available. Memoized per instance.
|
|
704
689
|
*
|
|
705
690
|
* @returns {Promise<Array<object>>}
|
|
706
691
|
*/
|
|
707
692
|
async templates() {
|
|
708
|
-
|
|
693
|
+
if (this.#templatesPromise) return this.#templatesPromise;
|
|
694
|
+
this.#templatesPromise = (async () => {
|
|
709
695
|
/** @type {any[]} */
|
|
710
696
|
const templates = [];
|
|
697
|
+
/** @type {import('../discovery/template-adapter.mjs').TemplateDiscoveryError[]} */
|
|
698
|
+
const replacementErrors = [];
|
|
711
699
|
|
|
712
700
|
// Core + external-package templates (discoverTemplates internally also
|
|
713
701
|
// loads integration templates via loadConfig today; we intentionally
|
|
@@ -728,20 +716,24 @@ export class Project {
|
|
|
728
716
|
for (const integration of this.#loadedIntegrations) {
|
|
729
717
|
await this.#collectIssues(integration);
|
|
730
718
|
const pkg = this.#pkgLabel(integration);
|
|
731
|
-
|
|
719
|
+
// Template discovery already isolates invalid template files and returns
|
|
720
|
+
// every valid sibling. Do not withdraw templates because another
|
|
721
|
+
// contribution kind in this package is broken.
|
|
732
722
|
try {
|
|
733
723
|
const {templates: ts, errors} =
|
|
734
724
|
await discoverIntegrationTemplatesForOne(integration);
|
|
735
725
|
for (const e of errors) {
|
|
736
726
|
this.#pushIssue(pkg, {
|
|
737
|
-
code: 'invalid_template',
|
|
738
|
-
severity: 'error',
|
|
727
|
+
code: e.code ?? 'invalid_template',
|
|
728
|
+
severity: e.severity ?? 'error',
|
|
739
729
|
message: e.message,
|
|
740
730
|
});
|
|
731
|
+
if (e.replacementTarget != null) replacementErrors.push(e);
|
|
741
732
|
}
|
|
742
|
-
//
|
|
743
|
-
//
|
|
744
|
-
|
|
733
|
+
// Discovery already omits each unusable template from `ts`. Keep all
|
|
734
|
+
// valid siblings, while the collected errors remain visible through
|
|
735
|
+
// issues() and replacement errors disable only their own targets.
|
|
736
|
+
templates.push(...ts);
|
|
745
737
|
} catch (err) {
|
|
746
738
|
this.#pushIssue(pkg, {
|
|
747
739
|
code: 'invalid_template',
|
|
@@ -751,15 +743,24 @@ export class Project {
|
|
|
751
743
|
}
|
|
752
744
|
}
|
|
753
745
|
|
|
754
|
-
|
|
755
|
-
|
|
746
|
+
const resolved = applyTemplateReplacements(templates, replacementErrors);
|
|
747
|
+
for (const error of resolved.errors) {
|
|
748
|
+
this.#pushIssue(error.package, {
|
|
749
|
+
code: error.code,
|
|
750
|
+
severity: error.severity,
|
|
751
|
+
message: error.message,
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
return effectiveTemplateDiscovery(resolved.templates);
|
|
755
|
+
})();
|
|
756
|
+
return this.#templatesPromise;
|
|
756
757
|
}
|
|
757
758
|
|
|
758
759
|
/**
|
|
759
760
|
* Bundled source themes plus themes contributed by installed integrations.
|
|
760
761
|
* Each record keeps its package owner and source directory so callers can
|
|
761
|
-
* both list and copy it without reconstructing paths. A broken
|
|
762
|
-
*
|
|
762
|
+
* both list and copy it without reconstructing paths. A broken theme
|
|
763
|
+
* contribution is reported without hiding the package's other valid kinds.
|
|
763
764
|
*
|
|
764
765
|
* @returns {Promise<import('../discovery/theme-discovery.mjs').DiscoveredTheme[]>}
|
|
765
766
|
*/
|
|
@@ -770,7 +771,6 @@ export class Project {
|
|
|
770
771
|
for (const integration of this.#loadedIntegrations) {
|
|
771
772
|
await this.#collectIssues(integration);
|
|
772
773
|
const pkg = this.#pkgLabel(integration);
|
|
773
|
-
if (this.#hasBlockingContributionIssue(pkg)) continue;
|
|
774
774
|
if (!integration?.themes) continue;
|
|
775
775
|
try {
|
|
776
776
|
themes.push(...(await discoverIntegrationThemes(integration)));
|
|
@@ -804,14 +804,16 @@ export class Project {
|
|
|
804
804
|
async docs() {
|
|
805
805
|
return this.#memo('docs', async () => {
|
|
806
806
|
const catalog = DocsCatalog.fromBuiltins();
|
|
807
|
+
let rank = 0;
|
|
807
808
|
|
|
808
809
|
for (const integration of this.#loadedIntegrations) {
|
|
810
|
+
rank += 1;
|
|
809
811
|
await this.#collectIssues(integration);
|
|
810
812
|
const pkg = this.#pkgLabel(integration);
|
|
811
|
-
if (this.#hasBlockingContributionIssue(pkg)) continue;
|
|
812
813
|
if (!integration?.docs) continue;
|
|
813
814
|
try {
|
|
814
|
-
const {records, errors} =
|
|
815
|
+
const {records, errors, namespaces, guides} =
|
|
816
|
+
await discoverIntegrationDocs(integration);
|
|
815
817
|
for (const e of errors) {
|
|
816
818
|
this.#pushIssue(pkg, {
|
|
817
819
|
code: 'invalid_doc',
|
|
@@ -823,11 +825,20 @@ export class Project {
|
|
|
823
825
|
// how a bad template withdraws its package's templates: a partial
|
|
824
826
|
// docs contribution is the state where a `replaces` silently does
|
|
825
827
|
// nothing and a reader gets the topic it was meant to replace.
|
|
826
|
-
if (errors.length > 0)
|
|
828
|
+
if (errors.length > 0) {
|
|
829
|
+
for (const e of errors) {
|
|
830
|
+
catalog.addIssue({package: integration.name ?? pkg, message: e.message});
|
|
831
|
+
}
|
|
832
|
+
continue;
|
|
833
|
+
}
|
|
827
834
|
for (const record of records) {
|
|
828
835
|
const issue = catalog.add(record);
|
|
829
836
|
if (issue) this.#pushIssue(pkg, issue);
|
|
830
837
|
}
|
|
838
|
+
catalog.addTreeInputs({
|
|
839
|
+
namespaces: namespaces.map(input => ({...input, rank})),
|
|
840
|
+
guides: guides.map(input => ({...input, rank})),
|
|
841
|
+
});
|
|
831
842
|
} catch (err) {
|
|
832
843
|
this.#pushIssue(pkg, {
|
|
833
844
|
code: 'invalid_doc',
|
|
@@ -844,8 +855,8 @@ export class Project {
|
|
|
844
855
|
/**
|
|
845
856
|
* Core registry transforms + integration codemods for an upgrade range.
|
|
846
857
|
* Wraps getTransformsBetween (core) and discoverIntegrationCodemods /
|
|
847
|
-
* selectIntegrationCodemods (integrations).
|
|
848
|
-
*
|
|
858
|
+
* selectIntegrationCodemods (integrations). An invalid codemod contribution
|
|
859
|
+
* is reported and omitted without hiding other valid contribution kinds.
|
|
849
860
|
* Memoized per (from, to) key.
|
|
850
861
|
*
|
|
851
862
|
* @param {string} fromVersion exclusive lower bound
|
|
@@ -863,7 +874,6 @@ export class Project {
|
|
|
863
874
|
for (const integration of this.#loadedIntegrations) {
|
|
864
875
|
await this.#collectIssues(integration);
|
|
865
876
|
const pkg = this.#pkgLabel(integration);
|
|
866
|
-
if (this.#hasBlockingContributionIssue(pkg)) continue;
|
|
867
877
|
if (!integration?.codemods) continue;
|
|
868
878
|
try {
|
|
869
879
|
// Validate this integration's codemods discover cleanly in
|
|
@@ -918,6 +928,10 @@ export class Project {
|
|
|
918
928
|
* @returns {Promise<ProjectIntegrationIssue[]>}
|
|
919
929
|
*/
|
|
920
930
|
async issues() {
|
|
931
|
+
// Template replacement validity depends on the combined Core + integration
|
|
932
|
+
// catalog. Resolve it first so issue results never depend on which discovery
|
|
933
|
+
// method the caller happened to invoke earlier.
|
|
934
|
+
await this.templates();
|
|
921
935
|
for (const integration of this.#loadedIntegrations) {
|
|
922
936
|
await this.#collectIssues(integration);
|
|
923
937
|
}
|
|
@@ -6,6 +6,7 @@ import * as path from 'node:path';
|
|
|
6
6
|
import {Project, DEFAULT_ISSUES_URL, findConfigPath} from './project.mjs';
|
|
7
7
|
import {InMemoryConfigCache} from './config-cache.mjs';
|
|
8
8
|
import * as componentDiscovery from '../discovery/component-discovery.mjs';
|
|
9
|
+
import {discoverCoreTemplates} from '../discovery/template-adapter.mjs';
|
|
9
10
|
|
|
10
11
|
let tmpDir;
|
|
11
12
|
let originalCwd;
|
|
@@ -21,6 +22,9 @@ function scaffold({
|
|
|
21
22
|
issuesUrl,
|
|
22
23
|
withComponents = true,
|
|
23
24
|
withTemplates = true,
|
|
25
|
+
templateId = 'hero',
|
|
26
|
+
templateType = 'block',
|
|
27
|
+
templateReplaces = null,
|
|
24
28
|
withCodemods = true,
|
|
25
29
|
brokenComponent = false,
|
|
26
30
|
brokenCodemod = false,
|
|
@@ -65,7 +69,7 @@ function scaffold({
|
|
|
65
69
|
fs.mkdirSync(compDir, {recursive: true});
|
|
66
70
|
fs.writeFileSync(
|
|
67
71
|
path.join(compDir, 'Widget.doc.mjs'),
|
|
68
|
-
`export const docs = { name: 'Widget', usage: {description: 'A widget'} };\n`,
|
|
72
|
+
`export const docs = { name: 'Widget', usage: {description: 'A widget'}, props: [] };\n`,
|
|
69
73
|
);
|
|
70
74
|
if (!brokenComponent) {
|
|
71
75
|
fs.writeFileSync(
|
|
@@ -80,12 +84,12 @@ function scaffold({
|
|
|
80
84
|
const tDir = path.join(pkgDir, 'templates');
|
|
81
85
|
fs.mkdirSync(tDir, {recursive: true});
|
|
82
86
|
fs.writeFileSync(
|
|
83
|
-
path.join(tDir,
|
|
84
|
-
`export default { type: '
|
|
87
|
+
path.join(tDir, `${templateId}.doc.mjs`),
|
|
88
|
+
`export default { type: '${templateType}', name: 'Fixture template', description: 'A fixture template'${templateReplaces == null ? '' : `, replaces: ${JSON.stringify(templateReplaces)}`} };\n`,
|
|
85
89
|
);
|
|
86
90
|
fs.writeFileSync(
|
|
87
|
-
path.join(tDir,
|
|
88
|
-
`export default function
|
|
91
|
+
path.join(tDir, `${templateId}.tsx`),
|
|
92
|
+
`export default function FixtureTemplate() { return null; }\n`,
|
|
89
93
|
);
|
|
90
94
|
}
|
|
91
95
|
|
|
@@ -324,6 +328,91 @@ describe('Project discovery', () => {
|
|
|
324
328
|
expect(hero.type).toBe('block');
|
|
325
329
|
});
|
|
326
330
|
|
|
331
|
+
it('templates() projects a valid integration replacement instead of its Core target', async () => {
|
|
332
|
+
const corePage = (await discoverCoreTemplates()).find(
|
|
333
|
+
template => template.type === 'page',
|
|
334
|
+
);
|
|
335
|
+
expect(corePage).toBeDefined();
|
|
336
|
+
scaffold({
|
|
337
|
+
templateId: 'acme-app-shell',
|
|
338
|
+
templateType: 'page',
|
|
339
|
+
templateReplaces: corePage.dirName,
|
|
340
|
+
});
|
|
341
|
+
const project = await Project.load(tmpDir);
|
|
342
|
+
|
|
343
|
+
const templates = await project.templates();
|
|
344
|
+
|
|
345
|
+
expect(
|
|
346
|
+
templates.find(template => template.dirName === 'acme-app-shell'),
|
|
347
|
+
).toMatchObject({
|
|
348
|
+
package: '@acme/widgets',
|
|
349
|
+
replaces: corePage.dirName,
|
|
350
|
+
});
|
|
351
|
+
expect(
|
|
352
|
+
templates.find(
|
|
353
|
+
template =>
|
|
354
|
+
template.dirName === corePage.dirName &&
|
|
355
|
+
template.package !== '@acme/widgets',
|
|
356
|
+
),
|
|
357
|
+
).toBeUndefined();
|
|
358
|
+
expect(await project.issues()).toEqual([]);
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it('reports replacement issues regardless of discovery call order without hiding other contributions', async () => {
|
|
362
|
+
scaffold({
|
|
363
|
+
templateReplaces: 'missing-core-template',
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
const componentsFirst = await Project.load(tmpDir);
|
|
367
|
+
expect(
|
|
368
|
+
(await componentsFirst.components()).some(
|
|
369
|
+
component => component.package === '@acme/widgets',
|
|
370
|
+
),
|
|
371
|
+
).toBe(true);
|
|
372
|
+
expect(await componentsFirst.issues()).toEqual(
|
|
373
|
+
expect.arrayContaining([
|
|
374
|
+
expect.objectContaining({
|
|
375
|
+
code: 'missing_template_replacement_target',
|
|
376
|
+
package: '@acme/widgets',
|
|
377
|
+
}),
|
|
378
|
+
]),
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
const issuesFirst = await Project.load(tmpDir, {fresh: true});
|
|
382
|
+
expect(await issuesFirst.issues()).toEqual(
|
|
383
|
+
expect.arrayContaining([
|
|
384
|
+
expect.objectContaining({
|
|
385
|
+
code: 'missing_template_replacement_target',
|
|
386
|
+
package: '@acme/widgets',
|
|
387
|
+
}),
|
|
388
|
+
]),
|
|
389
|
+
);
|
|
390
|
+
expect(
|
|
391
|
+
(await issuesFirst.components()).some(
|
|
392
|
+
component => component.package === '@acme/widgets',
|
|
393
|
+
),
|
|
394
|
+
).toBe(true);
|
|
395
|
+
const ownTemplate = (await issuesFirst.templates()).find(
|
|
396
|
+
template =>
|
|
397
|
+
template.package === '@acme/widgets' && template.dirName === 'hero',
|
|
398
|
+
);
|
|
399
|
+
expect(ownTemplate).toBeDefined();
|
|
400
|
+
expect(ownTemplate).not.toHaveProperty('replaces');
|
|
401
|
+
|
|
402
|
+
const sharedCache = new InMemoryConfigCache();
|
|
403
|
+
const warm = await Project.load(tmpDir, {cache: sharedCache});
|
|
404
|
+
await warm.templates();
|
|
405
|
+
const cached = await Project.load(tmpDir, {cache: sharedCache});
|
|
406
|
+
expect(await cached.issues()).toEqual(
|
|
407
|
+
expect.arrayContaining([
|
|
408
|
+
expect.objectContaining({
|
|
409
|
+
code: 'missing_template_replacement_target',
|
|
410
|
+
package: '@acme/widgets',
|
|
411
|
+
}),
|
|
412
|
+
]),
|
|
413
|
+
);
|
|
414
|
+
});
|
|
415
|
+
|
|
327
416
|
it('codemods() returns core registry groups + integration groups', async () => {
|
|
328
417
|
scaffold();
|
|
329
418
|
const project = await Project.load(tmpDir);
|
|
@@ -468,6 +557,53 @@ describe('Project issues (skip + warn)', () => {
|
|
|
468
557
|
expect(issues.some(i => i.package === '@acme/widgets')).toBe(true);
|
|
469
558
|
});
|
|
470
559
|
|
|
560
|
+
it('keeps valid contribution kinds and siblings when others are broken', async () => {
|
|
561
|
+
const pkgDir = scaffold({brokenComponent: true});
|
|
562
|
+
fs.writeFileSync(
|
|
563
|
+
path.join(pkgDir, 'templates', 'broken.template.mjs'),
|
|
564
|
+
`export default {type: 'block', name: 'Broken', description: 'Missing source'};\n`,
|
|
565
|
+
);
|
|
566
|
+
fs.writeFileSync(
|
|
567
|
+
path.join(pkgDir, 'components', 'ValidWidget.doc.mjs'),
|
|
568
|
+
`export default {type: 'component', name: 'ValidWidget', props: []};\n`,
|
|
569
|
+
);
|
|
570
|
+
fs.writeFileSync(
|
|
571
|
+
path.join(pkgDir, 'components', 'ValidWidget.tsx'),
|
|
572
|
+
`export function ValidWidget() { return null; }\n`,
|
|
573
|
+
);
|
|
574
|
+
const project = await Project.load(tmpDir);
|
|
575
|
+
|
|
576
|
+
const templates = await project.templates();
|
|
577
|
+
const components = await project.components();
|
|
578
|
+
const issues = await project.issues();
|
|
579
|
+
|
|
580
|
+
expect(
|
|
581
|
+
templates.find(
|
|
582
|
+
template =>
|
|
583
|
+
template.dirName === 'hero' && template.package === '@acme/widgets',
|
|
584
|
+
),
|
|
585
|
+
).toBeDefined();
|
|
586
|
+
expect(
|
|
587
|
+
components.find(
|
|
588
|
+
component =>
|
|
589
|
+
component.name === 'ValidWidget' &&
|
|
590
|
+
component.package === '@acme/widgets',
|
|
591
|
+
),
|
|
592
|
+
).toBeDefined();
|
|
593
|
+
expect(
|
|
594
|
+
components.find(
|
|
595
|
+
component =>
|
|
596
|
+
component.name === 'Widget' && component.package === '@acme/widgets',
|
|
597
|
+
),
|
|
598
|
+
).toBeUndefined();
|
|
599
|
+
expect(issues).toEqual(
|
|
600
|
+
expect.arrayContaining([
|
|
601
|
+
expect.objectContaining({code: 'invalid_component'}),
|
|
602
|
+
expect.objectContaining({code: 'invalid_template'}),
|
|
603
|
+
]),
|
|
604
|
+
);
|
|
605
|
+
});
|
|
606
|
+
|
|
471
607
|
it('does not throw when an integration codemod is broken', async () => {
|
|
472
608
|
scaffold({brokenCodemod: true});
|
|
473
609
|
const project = await Project.load(tmpDir);
|
|
@@ -60,17 +60,25 @@ describe('authoring self-docs', () => {
|
|
|
60
60
|
);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
describe('what the authoring docs say about the
|
|
64
|
-
it('marks exactly the fields
|
|
63
|
+
describe('what the authoring docs say about the docs tree', () => {
|
|
64
|
+
it('marks exactly the fields the docs tree does not read yet', () => {
|
|
65
65
|
const notReadYet = graphFieldsDoc.fields
|
|
66
66
|
.filter(field => /Not read yet/.test(field.description))
|
|
67
67
|
.map(field => field.name);
|
|
68
|
-
|
|
68
|
+
// The tree reads `placement` for every guide (spec:AST-046); the other
|
|
69
|
+
// graph fields are still refused by every topic reader.
|
|
70
|
+
expect(notReadYet.sort()).toEqual(
|
|
71
|
+
GRAPH_ONLY_FIELDS.filter(field => field !== 'placement').sort(),
|
|
72
|
+
);
|
|
69
73
|
for (const field of graphFieldsDoc.fields) {
|
|
70
|
-
if (
|
|
74
|
+
if (GRAPH_ONLY_FIELDS.includes(field.name)) {
|
|
71
75
|
expect(field.description).toMatch(/fails to load/);
|
|
72
76
|
}
|
|
73
77
|
}
|
|
78
|
+
const placement = graphFieldsDoc.fields.find(f => f.name === 'placement');
|
|
79
|
+
expect(placement.description).toMatch(
|
|
80
|
+
/Read for every guide, the CLI's and each integration's/,
|
|
81
|
+
);
|
|
74
82
|
expect(graphFieldsDoc.description).toMatch(/not built yet/);
|
|
75
83
|
});
|
|
76
84
|
|
|
@@ -85,8 +93,10 @@ describe('what the authoring docs say about the unbuilt docs graph', () => {
|
|
|
85
93
|
}
|
|
86
94
|
});
|
|
87
95
|
|
|
88
|
-
it('says namespace docs
|
|
89
|
-
expect(namespaceDoc.description).toMatch(
|
|
96
|
+
it('says where namespace docs live: the CLI tree, and each integration', () => {
|
|
97
|
+
expect(namespaceDoc.description).toMatch(
|
|
98
|
+
/an integration ships its own in its docs directory/,
|
|
99
|
+
);
|
|
90
100
|
expect(
|
|
91
101
|
problemsInTopic({
|
|
92
102
|
...namespaceDoc.examples?.[0],
|
|
@@ -94,7 +104,7 @@ describe('what the authoring docs say about the unbuilt docs graph', () => {
|
|
|
94
104
|
name: 'x',
|
|
95
105
|
}),
|
|
96
106
|
).toEqual([
|
|
97
|
-
'"x" is a namespace doc
|
|
107
|
+
'"x" is a namespace doc, which the docs tree reads, not the topic list. The CLI keeps its own in assets/docs/tree; an integration ships its namespace docs in its docs directory.',
|
|
98
108
|
]);
|
|
99
109
|
});
|
|
100
110
|
});
|
|
@@ -27,46 +27,45 @@ export function loadCliSelfDocs(sources?: string[], root?: string): Promise<{
|
|
|
27
27
|
}[];
|
|
28
28
|
}>;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
30
|
+
* What cross-links need: the loaded function docs by name, the command names,
|
|
31
|
+
* and the route the docs tree gave a doc, if it gave one.
|
|
32
|
+
* @typedef {object} CliDocIndex
|
|
33
|
+
* @property {Map<string, any>} functions
|
|
34
|
+
* @property {Set<string>} commands
|
|
35
|
+
* @property {(kind: string, name: string) => string | null} route
|
|
34
36
|
*/
|
|
35
|
-
export function keySegment(name: string): string;
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
-
* @returns {string | null}
|
|
41
|
-
*/
|
|
42
|
-
export function cliSectionKey(doc: any): string | null;
|
|
43
|
-
/**
|
|
44
|
-
* The `cli` topic: one section per doc whose namespace is `cli/…`.
|
|
45
|
-
* @param {any[]} docs every loaded CLI doc; the ones in other namespaces are
|
|
46
|
-
* left out
|
|
47
|
-
* @returns {import('../../authoring/doctypes/reference/type').ReferenceDoc}
|
|
38
|
+
* @param {any[]} docs every loaded CLI typed doc
|
|
39
|
+
* @param {(kind: string, name: string) => string | null} [route]
|
|
40
|
+
* @returns {CliDocIndex}
|
|
48
41
|
*/
|
|
49
|
-
export function
|
|
42
|
+
export function cliDocIndex(docs: any[], route?: (kind: string, name: string) => string | null): CliDocIndex;
|
|
50
43
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @
|
|
44
|
+
* What `astryx docs <route>` prints for one CLI typed doc: its title and the
|
|
45
|
+
* blocks of its content, with cross-links to the routes the tree gave.
|
|
46
|
+
* @param {any} doc
|
|
47
|
+
* @param {CliDocIndex} index
|
|
48
|
+
* @returns {{id: string, title: string, content: any[]}}
|
|
54
49
|
*/
|
|
55
|
-
export function
|
|
50
|
+
export function cliDocSection(doc: any, index: CliDocIndex): {
|
|
51
|
+
id: string;
|
|
52
|
+
title: string;
|
|
53
|
+
content: any[];
|
|
54
|
+
};
|
|
56
55
|
/**
|
|
57
|
-
* What stands between a CLI doc and a reader: a missing namespace, one
|
|
58
|
-
*
|
|
59
|
-
*
|
|
56
|
+
* What stands between a CLI doc and a reader: a missing namespace, one nothing
|
|
57
|
+
* reads, one that disagrees with the authoring topic's list, a doc that fails
|
|
58
|
+
* to load, and a tree leaf too large for one read. Whether the tree gives
|
|
59
|
+
* every `cli/...` doc a route is the docs-tree check's job.
|
|
60
60
|
* @param {{root?: string, sources?: string[], budget?: number, authoringSources?: string[]}} [options]
|
|
61
61
|
* @returns {Promise<{
|
|
62
62
|
* docs: number,
|
|
63
|
-
*
|
|
63
|
+
* tree: number,
|
|
64
64
|
* authoring: number,
|
|
65
65
|
* missing: string[],
|
|
66
66
|
* unknown: {source: string, namespace: string}[],
|
|
67
67
|
* misfiled: {source: string, message: string}[],
|
|
68
68
|
* failed: {source: string, error: string}[],
|
|
69
|
-
* keyProblems: string[],
|
|
70
69
|
* oversized: {key: string, title: string, bytes: number}[],
|
|
71
70
|
* }>}
|
|
72
71
|
*/
|
|
@@ -77,7 +76,7 @@ export function auditCliSelfDocs({ root, sources, budget, authoringSources, }?:
|
|
|
77
76
|
authoringSources?: string[];
|
|
78
77
|
}): Promise<{
|
|
79
78
|
docs: number;
|
|
80
|
-
|
|
79
|
+
tree: number;
|
|
81
80
|
authoring: number;
|
|
82
81
|
missing: string[];
|
|
83
82
|
unknown: {
|
|
@@ -92,7 +91,6 @@ export function auditCliSelfDocs({ root, sources, budget, authoringSources, }?:
|
|
|
92
91
|
source: string;
|
|
93
92
|
error: string;
|
|
94
93
|
}[];
|
|
95
|
-
keyProblems: string[];
|
|
96
94
|
oversized: {
|
|
97
95
|
key: string;
|
|
98
96
|
title: string;
|
|
@@ -102,12 +100,20 @@ export function auditCliSelfDocs({ root, sources, budget, authoringSources, }?:
|
|
|
102
100
|
/** The directories, relative to the CLI root, that hold the CLI's own docs. */
|
|
103
101
|
export const CLI_SELF_DOC_DIRS: string[];
|
|
104
102
|
/**
|
|
105
|
-
* Every namespace a CLI doc may declare, and
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @type {Record<string, {
|
|
103
|
+
* Every namespace a CLI doc may declare, and what reads it. The docs tree
|
|
104
|
+
* adopts `cli/commands` (under `cli/commands`) and `cli/api` (under
|
|
105
|
+
* `cli/api/<kind>s`); `astryx docs authoring` reads `authoring` from its list.
|
|
106
|
+
* @type {Record<string, {reader: 'tree' | 'authoring'}>}
|
|
109
107
|
*/
|
|
110
108
|
export const CLI_DOC_NAMESPACES: Record<string, {
|
|
111
|
-
|
|
112
|
-
keyPrefix?: string;
|
|
109
|
+
reader: "tree" | "authoring";
|
|
113
110
|
}>;
|
|
111
|
+
/**
|
|
112
|
+
* What cross-links need: the loaded function docs by name, the command names,
|
|
113
|
+
* and the route the docs tree gave a doc, if it gave one.
|
|
114
|
+
*/
|
|
115
|
+
export type CliDocIndex = {
|
|
116
|
+
functions: Map<string, any>;
|
|
117
|
+
commands: Set<string>;
|
|
118
|
+
route: (kind: string, name: string) => string | null;
|
|
119
|
+
};
|