@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
|
@@ -55,6 +55,15 @@ describe('generateCompressedIndex', () => {
|
|
|
55
55
|
expect(frameRule).not.toMatch(/https?:/);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
+
it('starts every page from a template before any component', () => {
|
|
59
|
+
const lines = generateCompressedIndex('1.0.0').split('\n');
|
|
60
|
+
const workflow = lines.findIndex(l => l.startsWith('WORKFLOW'));
|
|
61
|
+
expect(lines[workflow]).toMatch(/start every page from a template/);
|
|
62
|
+
expect(lines[workflow + 1]).toMatch(/^1\. `astryx build /);
|
|
63
|
+
expect(lines[workflow + 2]).toMatch(/^2\. `astryx template <name> <path>`/);
|
|
64
|
+
expect(lines.join('\n')).not.toMatch(/reference code/);
|
|
65
|
+
});
|
|
66
|
+
|
|
58
67
|
it('includes the post-generation self-check rule', () => {
|
|
59
68
|
const result = generateCompressedIndex('1.0.0');
|
|
60
69
|
expect(result).toContain('SELF-CHECK before you finish');
|
|
@@ -134,7 +143,6 @@ describe('generateCompressedIndex', () => {
|
|
|
134
143
|
const line = topicLine(generateCompressedIndex('1.0.0'));
|
|
135
144
|
for (const topic of [
|
|
136
145
|
'getting-started',
|
|
137
|
-
'cli-integrations',
|
|
138
146
|
'browser-support',
|
|
139
147
|
'styling-libraries',
|
|
140
148
|
'working-with-ai',
|
|
@@ -143,6 +151,16 @@ describe('generateCompressedIndex', () => {
|
|
|
143
151
|
}
|
|
144
152
|
});
|
|
145
153
|
|
|
154
|
+
it('points to the CLI docs tree on a line of its own', () => {
|
|
155
|
+
// The integration guide lives in the docs tree now (cli/integrations), so
|
|
156
|
+
// the topic line no longer names it; the tree's entry point does.
|
|
157
|
+
const block = generateCompressedIndex('1.0.0');
|
|
158
|
+
expect(block).toContain(
|
|
159
|
+
' docs cli commands, API reference, integration authoring (one level at a time)',
|
|
160
|
+
);
|
|
161
|
+
expect(topicLine(block)).not.toContain('cli-integrations');
|
|
162
|
+
});
|
|
163
|
+
|
|
146
164
|
it('lists the topics it is given, so an integration’s reach the agent', () => {
|
|
147
165
|
const line = topicLine(
|
|
148
166
|
generateCompressedIndex('1.0.0', {topics: ['tokens', 'deploying']}),
|
|
@@ -95,9 +95,9 @@ export class Project {
|
|
|
95
95
|
/**
|
|
96
96
|
* Core + integration component ownership records. Wraps
|
|
97
97
|
* discoverOwnedComponents for core and discoverIntegrationComponents (via
|
|
98
|
-
* discoverOwnedComponents) for integrations
|
|
99
|
-
*
|
|
100
|
-
*
|
|
98
|
+
* discoverOwnedComponents) for integrations. Invalid component records are
|
|
99
|
+
* omitted and reported; valid component siblings and other contribution kinds
|
|
100
|
+
* remain available. Memoized per instance.
|
|
101
101
|
*
|
|
102
102
|
* @returns {Promise<Array<{name: string, package: string, group: string|null, docPath: string|null, sourcePath: string|null, issuesUrl: string|undefined}>>}
|
|
103
103
|
*/
|
|
@@ -110,10 +110,11 @@ export class Project {
|
|
|
110
110
|
issuesUrl: string | undefined;
|
|
111
111
|
}>>;
|
|
112
112
|
/**
|
|
113
|
-
* Core + integration templates, type-tagged
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
113
|
+
* Core + integration templates, type-tagged, with valid integration
|
|
114
|
+
* replacements projected over their Core targets. Wraps raw template discovery
|
|
115
|
+
* (Core + external blocks) and discoverIntegrationTemplatesForOne per integration
|
|
116
|
+
* so unusable template files are reported and omitted while valid siblings
|
|
117
|
+
* remain available. Memoized per instance.
|
|
117
118
|
*
|
|
118
119
|
* @returns {Promise<Array<object>>}
|
|
119
120
|
*/
|
|
@@ -121,8 +122,8 @@ export class Project {
|
|
|
121
122
|
/**
|
|
122
123
|
* Bundled source themes plus themes contributed by installed integrations.
|
|
123
124
|
* Each record keeps its package owner and source directory so callers can
|
|
124
|
-
* both list and copy it without reconstructing paths. A broken
|
|
125
|
-
*
|
|
125
|
+
* both list and copy it without reconstructing paths. A broken theme
|
|
126
|
+
* contribution is reported without hiding the package's other valid kinds.
|
|
126
127
|
*
|
|
127
128
|
* @returns {Promise<import('../discovery/theme-discovery.mjs').DiscoveredTheme[]>}
|
|
128
129
|
*/
|
|
@@ -145,8 +146,8 @@ export class Project {
|
|
|
145
146
|
/**
|
|
146
147
|
* Core registry transforms + integration codemods for an upgrade range.
|
|
147
148
|
* Wraps getTransformsBetween (core) and discoverIntegrationCodemods /
|
|
148
|
-
* selectIntegrationCodemods (integrations).
|
|
149
|
-
*
|
|
149
|
+
* selectIntegrationCodemods (integrations). An invalid codemod contribution
|
|
150
|
+
* is reported and omitted without hiding other valid contribution kinds.
|
|
150
151
|
* Memoized per (from, to) key.
|
|
151
152
|
*
|
|
152
153
|
* @param {string} fromVersion exclusive lower bound
|
|
@@ -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);
|
|
@@ -24,6 +24,18 @@ export function loadAuthoringSelfDocs(sources?: string[], root?: string): Promis
|
|
|
24
24
|
error: string;
|
|
25
25
|
}[];
|
|
26
26
|
}>;
|
|
27
|
+
/**
|
|
28
|
+
* A schema's fields as the table its section prints, each nested field on the
|
|
29
|
+
* row after its parent; null when there are none. A reference block that
|
|
30
|
+
* names some of a schema's fields includes this table of just those.
|
|
31
|
+
* @param {any[]} fields
|
|
32
|
+
* @returns {{type: 'table', headers: string[], rows: string[][]} | null}
|
|
33
|
+
*/
|
|
34
|
+
export function schemaFieldTable(fields: any[]): {
|
|
35
|
+
type: "table";
|
|
36
|
+
headers: string[];
|
|
37
|
+
rows: string[][];
|
|
38
|
+
} | null;
|
|
27
39
|
/**
|
|
28
40
|
* One self-doc as a topic section, keyed by the doc's own name.
|
|
29
41
|
* @param {any} doc
|
|
@@ -133,6 +133,24 @@ function fieldRows(fields) {
|
|
|
133
133
|
]);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* A schema's fields as the table its section prints, each nested field on the
|
|
138
|
+
* row after its parent; null when there are none. A reference block that
|
|
139
|
+
* names some of a schema's fields includes this table of just those.
|
|
140
|
+
* @param {any[]} fields
|
|
141
|
+
* @returns {{type: 'table', headers: string[], rows: string[][]} | null}
|
|
142
|
+
*/
|
|
143
|
+
export function schemaFieldTable(fields) {
|
|
144
|
+
const rows = fieldRows(fields);
|
|
145
|
+
return rows.length > 0
|
|
146
|
+
? {
|
|
147
|
+
type: 'table',
|
|
148
|
+
headers: ['Field', 'Type', 'Required', 'Description'],
|
|
149
|
+
rows,
|
|
150
|
+
}
|
|
151
|
+
: null;
|
|
152
|
+
}
|
|
153
|
+
|
|
136
154
|
/**
|
|
137
155
|
* One self-doc as a topic section, keyed by the doc's own name.
|
|
138
156
|
* @param {any} doc
|
|
@@ -144,14 +162,8 @@ export function selfDocSection(doc) {
|
|
|
144
162
|
if (doc.appliesTo) {
|
|
145
163
|
content.push({type: 'prose', text: `Applies to: ${doc.appliesTo}`});
|
|
146
164
|
}
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
content.push({
|
|
150
|
-
type: 'table',
|
|
151
|
-
headers: ['Field', 'Type', 'Required', 'Description'],
|
|
152
|
-
rows,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
165
|
+
const table = schemaFieldTable(doc.fields ?? []);
|
|
166
|
+
if (table) content.push(table);
|
|
155
167
|
for (const example of doc.examples ?? []) {
|
|
156
168
|
if (typeof example?.code !== 'string' || example.code.trim() === '')
|
|
157
169
|
continue;
|