@astryxdesign/cli 0.6.3-canary.e59d786 → 0.6.3-canary.e7723cd
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 +19 -17
- 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 +24 -13
- package/api/docs/detail/section/section.test.mjs +15 -6
- 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 +147 -8
- package/api/doctor/doctor.test.mjs +95 -7
- 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 +26 -1
- package/api/search/search.doc.mjs +4 -3
- package/api/search/search.mjs +308 -29
- 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/template-integration.test.mjs +1022 -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/codemods/transforms/next/__tests__/migrate-native-picker-to-presentation.test.mjs +63 -0
- package/assets/codemods/transforms/next/__tests__/migrate-theme-catalog-to-descriptors.test.mjs +4 -0
- package/assets/codemods/transforms/next/index.mjs +8 -0
- package/assets/codemods/transforms/next/migrate-native-picker-to-presentation.mjs +148 -0
- package/assets/docs/getting-started.doc.mjs +2 -2
- 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/templates/blocks/components/DateInput/DateInputDateRange.tsx +1 -1
- package/assets/templates/blocks/components/TimeInput/TimeInputConstrained.tsx +1 -0
- package/authoring/debug/parse.d.mts +3 -3
- package/authoring/doctypes/_schema.d.mts +71 -141
- package/authoring/doctypes/_schema.mjs +29 -2
- 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 +1 -1
- package/authoring/doctypes/namespace/namespace.doc.mjs +6 -10
- package/authoring/doctypes/namespace/parse.test.mjs +23 -25
- package/authoring/doctypes/namespace/type.ts +5 -2
- package/authoring/doctypes/parse.mjs +3 -2
- package/authoring/doctypes/reference/reference.doc.mjs +6 -4
- package/authoring/doctypes/reference/type.ts +10 -8
- 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/index.d.ts +1 -0
- 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 +11 -45
- package/clients/cli/commands/build.mjs +5 -2
- 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 +182 -68
- package/clients/cli/commands/docs.test.mjs +120 -16
- 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 +719 -0
- package/clients/cli/commands/theme-targets.behavior.test.mjs +4 -3
- package/clients/cli/commands/upgrade.mjs +26 -7
- package/clients/cli/formatters/index.mjs +2 -0
- package/clients/cli/formatters/index.test.mjs +6 -0
- package/clients/cli/index.mjs +8 -0
- package/clients/cli/lib/manifest.mjs +9 -2
- package/foundation/agent-docs/agent-docs.mjs +1 -0
- package/foundation/agent-docs/agent-docs.test.mjs +10 -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 +20 -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 +105 -8
- package/foundation/discovery/docs-discovery.mjs +183 -18
- package/foundation/discovery/docs-discovery.test.mjs +63 -27
- 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 +28 -10
- package/foundation/discovery/docs-section-key.mjs +134 -33
- package/foundation/discovery/docs-section-key.test.mjs +41 -19
- 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 +57 -10
- 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 +18 -9
- 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
|
@@ -3,13 +3,19 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Integration authoring diagnostics against the built-in Core catalog.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Templates may intentionally replace Core identities; undeclared same-id
|
|
7
|
+
* overlaps stay fail-closed and require package selection. The CLI package
|
|
8
|
+
* version gates replacement-specific fields so 0.6.x keeps its released shape.
|
|
9
|
+
* Docs have explicit `replaces` / `extends` relationships with parallel
|
|
10
|
+
* validation semantics.
|
|
11
|
+
*
|
|
12
|
+
* @input Integration packages, built-in catalogs, and the CLI release boundary.
|
|
13
|
+
* @output Typed template, component, and documentation authoring diagnostics.
|
|
14
|
+
* @position Public integration-authoring API over private discovery adapters.
|
|
10
15
|
*/
|
|
11
16
|
|
|
12
17
|
import {getCliInvocation} from '../../foundation/env/package-manager.mjs';
|
|
18
|
+
import {packageDocsProblems} from '../docs/_adapter.mjs';
|
|
13
19
|
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
14
20
|
import {
|
|
15
21
|
discoverIntegrationComponents,
|
|
@@ -20,9 +26,11 @@ import {
|
|
|
20
26
|
discoverIntegrationDocs,
|
|
21
27
|
} from '../../foundation/discovery/docs-discovery.mjs';
|
|
22
28
|
import {
|
|
29
|
+
applyTemplateReplacements,
|
|
23
30
|
discoverCoreTemplates,
|
|
24
31
|
discoverIntegrationTemplatesForOne,
|
|
25
32
|
} from '../../foundation/discovery/template-adapter.mjs';
|
|
33
|
+
import {expandedTemplateConflictSchemaActive} from '../../foundation/discovery/template-conflict-release.mjs';
|
|
26
34
|
import {
|
|
27
35
|
validateInstalledIntegration,
|
|
28
36
|
validateLocalIntegration,
|
|
@@ -48,16 +56,27 @@ async function resolveIntegration(pkg, cwd) {
|
|
|
48
56
|
/**
|
|
49
57
|
* Add discovery errors once to an issue list.
|
|
50
58
|
* @param {Array<{code: string, severity: 'warning' | 'error', message: string}>} issues
|
|
51
|
-
* @param {Array<{message: string} | Error>} errors
|
|
59
|
+
* @param {Array<{message: string, code?: string, severity?: 'warning' | 'error'} | Error>} errors
|
|
52
60
|
* @param {string} code
|
|
53
61
|
*/
|
|
54
62
|
function addErrors(issues, errors, code) {
|
|
55
63
|
for (const error of errors) {
|
|
56
64
|
const message = error.message;
|
|
57
|
-
|
|
65
|
+
const issueCode =
|
|
66
|
+
'code' in error && typeof error.code === 'string' ? error.code : code;
|
|
67
|
+
const severity =
|
|
68
|
+
'severity' in error &&
|
|
69
|
+
(error.severity === 'warning' || error.severity === 'error')
|
|
70
|
+
? error.severity
|
|
71
|
+
: 'error';
|
|
72
|
+
if (
|
|
73
|
+
issues.some(
|
|
74
|
+
issue => issue.code === issueCode && issue.message === message,
|
|
75
|
+
)
|
|
76
|
+
) {
|
|
58
77
|
continue;
|
|
59
78
|
}
|
|
60
|
-
issues.push({code, severity
|
|
79
|
+
issues.push({code: issueCode, severity, message});
|
|
61
80
|
}
|
|
62
81
|
}
|
|
63
82
|
|
|
@@ -74,7 +93,7 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
|
|
|
74
93
|
const version = resolved.found ? (resolved.version ?? null) : null;
|
|
75
94
|
const issues = [...resolved.issues];
|
|
76
95
|
|
|
77
|
-
if (!resolved.integration
|
|
96
|
+
if (!resolved.integration || name == null) {
|
|
78
97
|
return {
|
|
79
98
|
type: 'integration.template-conflicts',
|
|
80
99
|
data: {name, version, conflicts: [], issues},
|
|
@@ -87,6 +106,32 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
|
|
|
87
106
|
]);
|
|
88
107
|
addErrors(issues, errors, 'invalid_template');
|
|
89
108
|
|
|
109
|
+
const expandedConflictSchema = expandedTemplateConflictSchemaActive();
|
|
110
|
+
const replacementResolution = applyTemplateReplacements(
|
|
111
|
+
[...coreTemplates, ...templates],
|
|
112
|
+
errors.filter(error => error.replacementTarget != null),
|
|
113
|
+
);
|
|
114
|
+
for (const error of replacementResolution.errors) {
|
|
115
|
+
if (
|
|
116
|
+
!issues.some(
|
|
117
|
+
issue => issue.code === error.code && issue.message === error.message,
|
|
118
|
+
)
|
|
119
|
+
) {
|
|
120
|
+
issues.push({
|
|
121
|
+
code: error.code,
|
|
122
|
+
severity: error.severity,
|
|
123
|
+
message: error.message,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const activeReplacementIds = new Set(
|
|
128
|
+
replacementResolution.templates
|
|
129
|
+
.filter(
|
|
130
|
+
template => template.package === name && template.replaces != null,
|
|
131
|
+
)
|
|
132
|
+
.map(template => template.dirName),
|
|
133
|
+
);
|
|
134
|
+
|
|
90
135
|
/** @type {Map<string, Array<{type: 'page' | 'block', name: string}>>} */
|
|
91
136
|
const coreById = new Map();
|
|
92
137
|
for (const template of coreTemplates) {
|
|
@@ -101,30 +146,69 @@ export async function integrationTemplateConflicts(pkg, options = {}) {
|
|
|
101
146
|
}
|
|
102
147
|
|
|
103
148
|
const run = getCliInvocation(cwd);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
149
|
+
/** @type {import('./authoring-checks.type.mjs').IntegrationTemplateConflict[]} */
|
|
150
|
+
const conflicts = [];
|
|
151
|
+
for (const template of templates) {
|
|
152
|
+
const sameIdCore = coreById.get(template.dirName);
|
|
153
|
+
const replacementIsActive = activeReplacementIds.has(template.dirName);
|
|
154
|
+
|
|
155
|
+
if (
|
|
156
|
+
expandedConflictSchema &&
|
|
157
|
+
replacementIsActive &&
|
|
158
|
+
template.replaces != null
|
|
159
|
+
) {
|
|
160
|
+
// This branch is unreachable before the package reaches 0.7.0. Keep the
|
|
161
|
+
// published 0.6.x conflict typedef narrow until the activation change.
|
|
162
|
+
conflicts.push(
|
|
163
|
+
/** @type {any} */ ({
|
|
114
164
|
id: template.dirName,
|
|
115
|
-
severity:
|
|
165
|
+
severity: 'info',
|
|
166
|
+
relationship: 'replaces',
|
|
167
|
+
replaces: template.replaces,
|
|
116
168
|
integrationPackage: name,
|
|
117
169
|
integrationType: template.type,
|
|
118
170
|
integrationName: template.name,
|
|
119
|
-
coreMatches,
|
|
171
|
+
coreMatches: coreById.get(template.replaces) ?? [],
|
|
120
172
|
message:
|
|
121
|
-
`
|
|
122
|
-
|
|
123
|
-
command
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
173
|
+
`Intentional replacement: "${template.dirName}" replaces the Core template ` +
|
|
174
|
+
`"${template.replaces}" for unqualified lookup.`,
|
|
175
|
+
command: `${run} template ${shellArg(template.replaces)} --package ${shellArg('@astryxdesign/core')}`,
|
|
176
|
+
}),
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (
|
|
181
|
+
sameIdCore &&
|
|
182
|
+
!(replacementIsActive && template.replaces === template.dirName)
|
|
183
|
+
) {
|
|
184
|
+
const coreKinds = sameIdCore
|
|
185
|
+
.map(match => `${match.type} "${match.name}"`)
|
|
186
|
+
.join(', ');
|
|
187
|
+
const compatibleKind = sameIdCore.some(
|
|
188
|
+
match => match.type === template.type,
|
|
189
|
+
);
|
|
190
|
+
conflicts.push({
|
|
191
|
+
id: template.dirName,
|
|
192
|
+
severity: 'warning',
|
|
193
|
+
...(expandedConflictSchema ? {relationship: 'accidental'} : {}),
|
|
194
|
+
integrationPackage: name,
|
|
195
|
+
integrationType: template.type,
|
|
196
|
+
integrationName: template.name,
|
|
197
|
+
coreMatches: sameIdCore,
|
|
198
|
+
message: expandedConflictSchema
|
|
199
|
+
? compatibleKind
|
|
200
|
+
? `Template id "${template.dirName}" conflicts with Core (${coreKinds}). Consider renaming it, or set replaces: ${JSON.stringify(template.dirName)} in its metadata to replace the Core template.`
|
|
201
|
+
: `Template id "${template.dirName}" conflicts with Core (${coreKinds}), but a ${template.type} template cannot replace a different template kind. Rename the integration template.`
|
|
202
|
+
: `Template id "${template.dirName}" conflicts with Core (${coreKinds}). Consider renaming the integration template. If you keep it, always select it with --package.`,
|
|
203
|
+
command: `${run} template ${shellArg(template.dirName)} --package ${shellArg(name)}`,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
conflicts.sort((a, b) =>
|
|
208
|
+
`${a.id}:${'relationship' in a ? a.relationship : ''}`.localeCompare(
|
|
209
|
+
`${b.id}:${'relationship' in b ? b.relationship : ''}`,
|
|
210
|
+
),
|
|
211
|
+
);
|
|
128
212
|
|
|
129
213
|
return {
|
|
130
214
|
type: 'integration.template-conflicts',
|
|
@@ -211,10 +295,11 @@ export async function integrationDocConflicts(pkg, options = {}) {
|
|
|
211
295
|
};
|
|
212
296
|
}
|
|
213
297
|
|
|
214
|
-
const [
|
|
298
|
+
const [discovered, builtinTopics] = await Promise.all([
|
|
215
299
|
discoverIntegrationDocs(resolved.integration),
|
|
216
300
|
Promise.resolve(discoverBuiltinTopics()),
|
|
217
301
|
]);
|
|
302
|
+
const {records, errors} = discovered;
|
|
218
303
|
addErrors(issues, errors, 'invalid_doc');
|
|
219
304
|
const coreTopicsByKey = new Map(
|
|
220
305
|
Object.keys(builtinTopics).map(topic => [topic.toLowerCase(), topic]),
|
|
@@ -276,6 +361,18 @@ export async function integrationDocConflicts(pkg, options = {}) {
|
|
|
276
361
|
),
|
|
277
362
|
);
|
|
278
363
|
|
|
364
|
+
// The same graph checks `astryx doctor` runs in a project: the namespaces
|
|
365
|
+
// and placed guides this package adds to the docs tree, and every link in
|
|
366
|
+
// its docs (spec:AST-046, spec:AST-047).
|
|
367
|
+
if (errors.length === 0) {
|
|
368
|
+
for (const message of await packageDocsProblems(
|
|
369
|
+
/** @type {{name: string}} */ (resolved.integration),
|
|
370
|
+
discovered,
|
|
371
|
+
)) {
|
|
372
|
+
issues.push({code: 'invalid_doc_graph', severity: 'warning', message});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
279
376
|
return {
|
|
280
377
|
type: 'integration.doc-conflicts',
|
|
281
378
|
data: {name, version, findings, issues},
|
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Hermetic integration authoring checks against the real Core catalogs.
|
|
5
|
+
* @input Integration fixtures and the post-0.7 conflict projection.
|
|
6
|
+
* @output Coverage for replacement validation and public diagnostics.
|
|
7
|
+
* @position Unit coverage; the 0.6.x compatibility shape has its own fixture.
|
|
5
8
|
*/
|
|
6
9
|
|
|
7
|
-
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
10
|
+
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
|
11
|
+
|
|
12
|
+
vi.mock('../../foundation/discovery/template-conflict-release.mjs', () => ({
|
|
13
|
+
expandedTemplateConflictSchemaActive: () => true,
|
|
14
|
+
}));
|
|
8
15
|
import * as fs from 'node:fs';
|
|
9
16
|
import * as path from 'node:path';
|
|
10
17
|
import {discoverCoreTemplates} from '../../foundation/discovery/template-adapter.mjs';
|
|
@@ -20,7 +27,14 @@ import {
|
|
|
20
27
|
|
|
21
28
|
let tmpDir;
|
|
22
29
|
|
|
23
|
-
function writeIntegration({
|
|
30
|
+
function writeIntegration({
|
|
31
|
+
id,
|
|
32
|
+
name,
|
|
33
|
+
type = 'block',
|
|
34
|
+
root = tmpDir,
|
|
35
|
+
replacements,
|
|
36
|
+
withSource = true,
|
|
37
|
+
}) {
|
|
24
38
|
fs.mkdirSync(root, {recursive: true});
|
|
25
39
|
fs.writeFileSync(
|
|
26
40
|
path.join(root, 'package.json'),
|
|
@@ -34,8 +48,9 @@ function writeIntegration({id, name, type = 'block', root = tmpDir}) {
|
|
|
34
48
|
fs.mkdirSync(path.dirname(stem), {recursive: true});
|
|
35
49
|
fs.writeFileSync(
|
|
36
50
|
`${stem}.doc.mjs`,
|
|
37
|
-
`export default {type: '${type}', name: ${JSON.stringify(name)}, description: 'fixture'};\n`,
|
|
51
|
+
`export default {type: '${type}', name: ${JSON.stringify(name)}, description: 'fixture'${replacements?.[id] == null ? '' : `, replaces: ${JSON.stringify(replacements[id])}`}};\n`,
|
|
38
52
|
);
|
|
53
|
+
if (!withSource) return;
|
|
39
54
|
fs.writeFileSync(
|
|
40
55
|
`${stem}.tsx`,
|
|
41
56
|
'export default function Fixture() { return null; }\n',
|
|
@@ -158,6 +173,159 @@ describe('integrationTemplateConflicts', () => {
|
|
|
158
173
|
);
|
|
159
174
|
});
|
|
160
175
|
|
|
176
|
+
it('classifies a valid replacement and points to the Core original', async () => {
|
|
177
|
+
const core = (await discoverCoreTemplates()).find(
|
|
178
|
+
template => template.type === 'page',
|
|
179
|
+
);
|
|
180
|
+
expect(core).toBeDefined();
|
|
181
|
+
writeIntegration({
|
|
182
|
+
id: 'acme-app-shell',
|
|
183
|
+
name: 'Acme app shell',
|
|
184
|
+
type: core.type,
|
|
185
|
+
replacements: {'acme-app-shell': core.dirName},
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
|
|
189
|
+
|
|
190
|
+
expect(result.data.issues).toEqual([]);
|
|
191
|
+
expect(result.data.conflicts).toEqual([
|
|
192
|
+
expect.objectContaining({
|
|
193
|
+
id: 'acme-app-shell',
|
|
194
|
+
severity: 'info',
|
|
195
|
+
relationship: 'replaces',
|
|
196
|
+
replaces: core.dirName,
|
|
197
|
+
}),
|
|
198
|
+
]);
|
|
199
|
+
expect(result.data.conflicts[0].command).toContain(
|
|
200
|
+
`template ${core.dirName} --package @astryxdesign/core`,
|
|
201
|
+
);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
it('reports a replacement target that Core does not provide', async () => {
|
|
205
|
+
writeIntegration({
|
|
206
|
+
id: 'acme-app-shell',
|
|
207
|
+
name: 'Acme app shell',
|
|
208
|
+
type: 'page',
|
|
209
|
+
replacements: {'acme-app-shell': 'missing-core-shell'},
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
|
|
213
|
+
|
|
214
|
+
expect(result.data.issues).toEqual(
|
|
215
|
+
expect.arrayContaining([
|
|
216
|
+
expect.objectContaining({
|
|
217
|
+
code: 'missing_template_replacement_target',
|
|
218
|
+
severity: 'error',
|
|
219
|
+
}),
|
|
220
|
+
]),
|
|
221
|
+
);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('reports a replacement declared by a template that cannot be used', async () => {
|
|
225
|
+
const [core] = await discoverCoreTemplates();
|
|
226
|
+
expect(core).toBeDefined();
|
|
227
|
+
writeIntegration({
|
|
228
|
+
id: 'broken-template',
|
|
229
|
+
name: 'Broken template',
|
|
230
|
+
type: core.type,
|
|
231
|
+
replacements: {'broken-template': core.dirName},
|
|
232
|
+
withSource: false,
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
|
|
236
|
+
|
|
237
|
+
expect(result.data.issues).toEqual(
|
|
238
|
+
expect.arrayContaining([
|
|
239
|
+
expect.objectContaining({
|
|
240
|
+
code: 'invalid_template_replacement',
|
|
241
|
+
severity: 'error',
|
|
242
|
+
message: expect.stringContaining('cannot be used'),
|
|
243
|
+
}),
|
|
244
|
+
]),
|
|
245
|
+
);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('reports two templates that replace the same Core target as ambiguous', async () => {
|
|
249
|
+
const [core] = await discoverCoreTemplates();
|
|
250
|
+
expect(core).toBeDefined();
|
|
251
|
+
const replacements = {
|
|
252
|
+
'acme-app-shell-a': core.dirName,
|
|
253
|
+
'acme-app-shell-b': core.dirName,
|
|
254
|
+
};
|
|
255
|
+
writeIntegration({
|
|
256
|
+
id: 'acme-app-shell-a',
|
|
257
|
+
name: 'Acme app shell A',
|
|
258
|
+
type: core.type,
|
|
259
|
+
replacements,
|
|
260
|
+
});
|
|
261
|
+
writeIntegration({
|
|
262
|
+
id: 'acme-app-shell-b',
|
|
263
|
+
name: 'Acme app shell B',
|
|
264
|
+
type: core.type,
|
|
265
|
+
replacements,
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
|
|
269
|
+
|
|
270
|
+
expect(result.data.issues).toEqual(
|
|
271
|
+
expect.arrayContaining([
|
|
272
|
+
expect.objectContaining({
|
|
273
|
+
code: 'ambiguous_template_replacement',
|
|
274
|
+
severity: 'error',
|
|
275
|
+
}),
|
|
276
|
+
]),
|
|
277
|
+
);
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
it('reports a replacement whose template kind differs from Core', async () => {
|
|
281
|
+
const corePage = (await discoverCoreTemplates()).find(
|
|
282
|
+
template => template.type === 'page',
|
|
283
|
+
);
|
|
284
|
+
expect(corePage).toBeDefined();
|
|
285
|
+
writeIntegration({
|
|
286
|
+
id: 'acme-app-shell',
|
|
287
|
+
name: 'Acme app shell',
|
|
288
|
+
type: 'block',
|
|
289
|
+
replacements: {'acme-app-shell': corePage.dirName},
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
|
|
293
|
+
|
|
294
|
+
expect(result.data.issues).toEqual(
|
|
295
|
+
expect.arrayContaining([
|
|
296
|
+
expect.objectContaining({
|
|
297
|
+
code: 'invalid_template_replacement',
|
|
298
|
+
severity: 'error',
|
|
299
|
+
message: expect.stringContaining('same type'),
|
|
300
|
+
}),
|
|
301
|
+
]),
|
|
302
|
+
);
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
it('does not recommend an impossible replacement for a different Core kind', async () => {
|
|
306
|
+
const corePage = (await discoverCoreTemplates()).find(
|
|
307
|
+
template => template.type === 'page',
|
|
308
|
+
);
|
|
309
|
+
expect(corePage).toBeDefined();
|
|
310
|
+
writeIntegration({
|
|
311
|
+
id: corePage.dirName,
|
|
312
|
+
name: 'Acme block with a page id',
|
|
313
|
+
type: 'block',
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
const result = await integrationTemplateConflicts(undefined, {cwd: tmpDir});
|
|
317
|
+
const conflict = result.data.conflicts.find(
|
|
318
|
+
item => item.id === corePage.dirName,
|
|
319
|
+
);
|
|
320
|
+
|
|
321
|
+
expect(conflict?.relationship).toBe('accidental');
|
|
322
|
+
expect(conflict?.message).toContain(
|
|
323
|
+
'cannot replace a different template kind',
|
|
324
|
+
);
|
|
325
|
+
expect(conflict?.message).toContain('Rename');
|
|
326
|
+
expect(conflict?.message).not.toContain('set replaces');
|
|
327
|
+
});
|
|
328
|
+
|
|
161
329
|
it('shell-quotes unusual ids instead of allowing command substitution', () => {
|
|
162
330
|
expect(shellArg('safe/id')).toBe('safe/id');
|
|
163
331
|
expect(shellArg('my$thing')).toBe("'my$thing'");
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* @file Colocated public types for integration authoring diagnostics.
|
|
5
|
+
* @input Stable response fields exposed by integration-authoring APIs.
|
|
6
|
+
* @output JSDoc typedefs consumed by declarations, commands, and callers.
|
|
7
|
+
* @position Public type boundary for integration diagnostics.
|
|
8
|
+
*/
|
|
4
9
|
|
|
5
10
|
/**
|
|
6
11
|
* @typedef {object} IntegrationAuthoringOptions
|
|
@@ -10,6 +10,7 @@ export type IntegrationAddComponentOptions = IntegrationAddBaseOptions;
|
|
|
10
10
|
export type IntegrationAddDocOptions = IntegrationAddBaseOptions & {
|
|
11
11
|
replaces?: string;
|
|
12
12
|
extends?: string;
|
|
13
|
+
parent?: string;
|
|
13
14
|
};
|
|
14
15
|
export type IntegrationAddTemplateOptions = IntegrationAddBaseOptions & {
|
|
15
16
|
type?: "page" | "block";
|
|
@@ -29,6 +30,7 @@ export type IntegrationAddOptions = {
|
|
|
29
30
|
templateType?: "page" | "block" | undefined;
|
|
30
31
|
replaces?: string | undefined;
|
|
31
32
|
extends?: string | undefined;
|
|
33
|
+
parent?: string | undefined;
|
|
32
34
|
to?: string | undefined;
|
|
33
35
|
};
|
|
34
36
|
/**
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* @typedef {IntegrationAddBaseOptions & {
|
|
21
21
|
* replaces?: string,
|
|
22
22
|
* extends?: string,
|
|
23
|
+
* parent?: string,
|
|
23
24
|
* }} IntegrationAddDocOptions
|
|
24
25
|
*/
|
|
25
26
|
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
* @property {'page'|'block'} [templateType]
|
|
49
50
|
* @property {string} [replaces]
|
|
50
51
|
* @property {string} [extends]
|
|
52
|
+
* @property {string} [parent]
|
|
51
53
|
* @property {string} [to]
|
|
52
54
|
*/
|
|
53
55
|
|
|
@@ -67,6 +67,12 @@ export const doc = {
|
|
|
67
67
|
description:
|
|
68
68
|
'Existing topic to extend. Only valid for doc, and not with options.replaces.',
|
|
69
69
|
},
|
|
70
|
+
{
|
|
71
|
+
name: 'options.parent',
|
|
72
|
+
type: 'string',
|
|
73
|
+
description:
|
|
74
|
+
"Namespace of this package to place the doc in, as a guide in its `guides` slot; the namespace doc is written when missing. Only valid for doc, and not with options.replaces or options.extends.",
|
|
75
|
+
},
|
|
70
76
|
{
|
|
71
77
|
name: 'options.to',
|
|
72
78
|
type: 'string',
|
|
@@ -9,7 +9,7 @@ export const doc = {
|
|
|
9
9
|
displayName: 'integrationAddDoc()',
|
|
10
10
|
summary: 'Add a complete reference-doc contribution.',
|
|
11
11
|
description:
|
|
12
|
-
'Creates a valid generic topic, declares the docs root on first use, and supports an intentional replaces or extends relationship.',
|
|
12
|
+
'Creates a valid generic topic, declares the docs root on first use, and supports an intentional replaces or extends relationship, or places the doc as a guide in a namespace of the package.',
|
|
13
13
|
importPath: '@astryxdesign/cli/api',
|
|
14
14
|
signature:
|
|
15
15
|
'integrationAddDoc(name: string, options?: IntegrationAddDocOptions): Promise<IntegrationAddResponse>',
|
|
@@ -42,6 +42,12 @@ export const doc = {
|
|
|
42
42
|
type: 'string',
|
|
43
43
|
description: 'Existing topic this topic extends.',
|
|
44
44
|
},
|
|
45
|
+
{
|
|
46
|
+
name: 'options.parent',
|
|
47
|
+
type: 'string',
|
|
48
|
+
description:
|
|
49
|
+
"Namespace of this package to place the doc in, as a guide in its `guides` slot; the namespace doc is written when missing, and package.json declares the CLI that reads it as an optional `@astryxdesign/cli` peer. Only valid for doc, and not with options.replaces or options.extends.",
|
|
50
|
+
},
|
|
45
51
|
],
|
|
46
52
|
returns: [
|
|
47
53
|
{
|
|
@@ -9,7 +9,7 @@ export const doc = {
|
|
|
9
9
|
name: 'integrationDocConflicts',
|
|
10
10
|
namespace: 'cli/api',
|
|
11
11
|
displayName: 'integrationDocConflicts()',
|
|
12
|
-
summary: '
|
|
12
|
+
summary: 'Check an integration\'s docs: the docs tree they add, every link, and overlaps with Core topics.',
|
|
13
13
|
description:
|
|
14
14
|
'Loads one local or installed integration and classifies Core doc overlaps as ' +
|
|
15
15
|
'intentional replacements, intentional extensions, or accidental same-name ' +
|
|
@@ -9,7 +9,7 @@ export const doc = {
|
|
|
9
9
|
displayName: 'integrationPackCheck()',
|
|
10
10
|
summary: 'Prove an integration package survives npm packing.',
|
|
11
11
|
description:
|
|
12
|
-
"Validates the local integration, runs the package lifecycle, packs with npm, checks required files against npm's authoritative tarball list, extracts the real tarball into a scratch consumer, compares local and packed contribution inventories, and resolves every packed component through its documented public import to verify that module exports the component.",
|
|
12
|
+
"Validates the local integration, runs the package lifecycle, packs with npm, checks required files against npm's authoritative tarball list, extracts the real tarball into a scratch consumer, compares local and packed contribution inventories, and resolves every packed component through its documented public import to verify that module exports the component. A package that ships a namespace doc or a placed guide, or has a template that sets `replaces`, fails unless its `@astryxdesign/cli` peer range admits only CLIs that read them.",
|
|
13
13
|
importPath: '@astryxdesign/cli/api',
|
|
14
14
|
signature:
|
|
15
15
|
'integrationPackCheck(options?: IntegrationPackCheckOptions): Promise<IntegrationPackCheckResponse>',
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @file FunctionDoc for integration template-conflict diagnostics.
|
|
6
|
+
* @input The stable 0.6.x `integrationTemplateConflicts` API contract.
|
|
7
|
+
* @output Generated CLI API reference metadata.
|
|
8
|
+
* @position Consumer-facing documentation for the public authoring API.
|
|
6
9
|
*/
|
|
7
10
|
/** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
|
|
8
11
|
export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file FunctionDoc for integration template-conflict diagnostics.
|
|
5
|
+
* @input The stable 0.6.x `integrationTemplateConflicts` API contract.
|
|
6
|
+
* @output Generated CLI API reference metadata.
|
|
7
|
+
* @position Consumer-facing documentation for the public authoring API.
|
|
5
8
|
*/
|
|
6
9
|
|
|
7
10
|
/** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
|
|
@@ -27,6 +27,11 @@ import {spawnSync} from 'node:child_process';
|
|
|
27
27
|
import jscodeshift from 'jscodeshift';
|
|
28
28
|
import {assertWithin} from '../../foundation/fs/path-safety.mjs';
|
|
29
29
|
import {resolvePackageDir} from '../../foundation/integrations/integrations.mjs';
|
|
30
|
+
import {
|
|
31
|
+
docsTreeCliProblem,
|
|
32
|
+
replacesCliProblem,
|
|
33
|
+
} from '../../foundation/integrations/cli-requirement.mjs';
|
|
34
|
+
import {discoverIntegrationDocs} from '../../foundation/discovery/docs-discovery.mjs';
|
|
30
35
|
import {
|
|
31
36
|
discoverIntegrationComponents,
|
|
32
37
|
resolveIntegrationImportPath,
|
|
@@ -591,6 +596,35 @@ export async function integrationPackCheck(options = {}) {
|
|
|
591
596
|
);
|
|
592
597
|
}
|
|
593
598
|
}
|
|
599
|
+
// A namespace doc or a placed guide needs a CLI that reads the docs tree
|
|
600
|
+
// (spec:AST-046 FR11): an older CLI can hide every doc topic the package
|
|
601
|
+
// ships, so the declared CLI range must admit only CLIs that read it.
|
|
602
|
+
if (loaded.docs) {
|
|
603
|
+
const {namespaces, guides} = await discoverIntegrationDocs(loaded).catch(
|
|
604
|
+
() => ({namespaces: [], guides: []}),
|
|
605
|
+
);
|
|
606
|
+
const problem =
|
|
607
|
+
namespaces.length > 0 || guides.length > 0
|
|
608
|
+
? docsTreeCliProblem(pkg)
|
|
609
|
+
: null;
|
|
610
|
+
if (problem != null) {
|
|
611
|
+
issues.push(error('docs_tree_needs_cli', problem));
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
// A template that sets `replaces` needs a CLI that reads the field
|
|
615
|
+
// (spec:AST-035): an older CLI withholds the package's templates and docs.
|
|
616
|
+
if (loaded.templates) {
|
|
617
|
+
const found = await discoverIntegrationTemplatesForOne(loaded).catch(
|
|
618
|
+
() => ({templates: [], errors: []}),
|
|
619
|
+
);
|
|
620
|
+
const setsReplaces =
|
|
621
|
+
found.templates.some(template => template.replaces != null) ||
|
|
622
|
+
found.errors.some(
|
|
623
|
+
(/** @type {any} */ issue) => issue.replacementTarget != null,
|
|
624
|
+
);
|
|
625
|
+
const problem = setsReplaces ? replacesCliProblem(pkg) : null;
|
|
626
|
+
if (problem != null) issues.push(error('replaces_needs_cli', problem));
|
|
627
|
+
}
|
|
594
628
|
|
|
595
629
|
// Temp resources — always cleaned up
|
|
596
630
|
const tgzTmpDir = fs.mkdtempSync(
|