@astryxdesign/cli 0.7.1 → 0.7.2-canary.01eab6a
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 +7 -7
- package/api/component/_adapter.d.mts +41 -1
- package/api/component/_adapter.mjs +93 -7
- package/api/component/component.mjs +22 -5
- package/api/component/component.test.mjs +420 -167
- package/api/component/integration-export-name.test.mjs +644 -0
- package/api/component/list/list.mjs +42 -4
- package/api/gap-report/gap-report.mjs +67 -4
- package/api/integration/_adapter.d.mts +12 -0
- package/api/integration/_adapter.mjs +54 -0
- package/api/integration/add-contribution.component-names.test.mjs +66 -0
- package/api/integration/add-contribution.mjs +7 -3
- package/api/integration/authoring-checks.mjs +11 -2
- package/api/integration/authoring-checks.test.mjs +39 -0
- package/api/integration/authoring-checks.type.d.mts +9 -0
- package/api/integration/authoring-checks.type.mjs +14 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +21 -5
- package/api/integration/pack-check.mjs +61 -107
- package/api/integration/pack-check.test.mjs +359 -0
- package/api/search/search.d.mts +9 -0
- package/api/search/search.mjs +108 -16
- package/api/search/search.test.mjs +36 -0
- package/api/swizzle/copy/copy.mjs +28 -14
- package/api/template/table-filter-view-tabs.test.mjs +45 -0
- package/api/template/template.test.mjs +120 -3
- package/api/theme/build/build.core-on-demand.test.mjs +113 -0
- package/api/theme/build/build.d.mts +13 -13
- package/api/theme/build/build.family.test.mjs +16 -0
- package/api/theme/build/build.mjs +149 -55
- package/api/theme/themeBuild.doc.mjs +3 -3
- package/assets/codemods/transforms/next/__tests__/migrate-list-edge-compensation-to-edge.test.mjs +120 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-list-edge-compensation-to-edge.mjs +198 -0
- package/assets/docs/tree/add-a-component.doc.mjs +10 -0
- package/assets/docs/tree/check-the-props.doc.mjs +145 -0
- package/assets/docs/tree/checks.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +5 -1
- package/assets/docs/tree/component-imports.doc.mjs +8 -0
- package/assets/docs/tree/describe-the-component.doc.mjs +1 -1
- package/assets/docs/tree/single-component.doc.mjs +3 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +9 -1
- package/assets/docs/tree/versioning.doc.mjs +1 -0
- package/assets/docs/working-with-ai.doc.mjs +43 -4
- package/assets/templates/blocks/components/Drawer/DrawerForm.doc.mjs +24 -0
- package/assets/templates/blocks/components/Drawer/DrawerForm.tsx +62 -0
- package/assets/templates/blocks/components/Drawer/DrawerScrim.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerScrim.tsx +68 -0
- package/assets/templates/blocks/components/Drawer/DrawerShowcase.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerShowcase.tsx +41 -0
- package/assets/templates/blocks/components/Drawer/DrawerStart.doc.mjs +21 -0
- package/assets/templates/blocks/components/Drawer/DrawerStart.tsx +41 -0
- package/assets/templates/blocks/components/Drawer/DrawerWidths.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerWidths.tsx +54 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.tsx +73 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.doc.mjs +22 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.tsx +49 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.doc.mjs +21 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.tsx +42 -0
- package/assets/templates/pages/detail-page/page.tsx +3 -3
- package/assets/templates/pages/table-filter/page.tsx +3 -2
- package/assets/templates/pages/table-inbox/page.tsx +10 -8
- package/authoring/doctypes/base/type.ts +6 -0
- package/authoring/doctypes/component/component.doc.mjs +4 -4
- package/authoring/doctypes/component/type.ts +6 -3
- package/clients/cli/commands/build-theme.path-safety.test.mjs +84 -0
- package/clients/cli/commands/build-theme.registry.test.mjs +5 -2
- package/clients/cli/commands/doctor-integration-components.doc.mjs +9 -3
- package/clients/cli/commands/doctor-integration.test.mjs +327 -0
- package/clients/cli/commands/doctor.mjs +74 -0
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/lib/component-format.mjs +5 -1
- package/foundation/discovery/component-discovery.d.mts +190 -10
- package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
- package/foundation/discovery/component-discovery.mjs +864 -56
- package/foundation/discovery/component-discovery.test.mjs +96 -0
- package/foundation/discovery/component-replacement.mjs +18 -0
- package/foundation/discovery/component-replacement.test.mjs +40 -0
- package/foundation/discovery/module-exports.d.mts +27 -0
- package/foundation/discovery/module-exports.mjs +356 -31
- package/foundation/discovery/module-exports.test.mjs +172 -0
- package/foundation/discovery/package-tsconfig.d.mts +14 -0
- package/foundation/discovery/package-tsconfig.mjs +228 -0
- package/foundation/discovery/package-tsconfig.test.mjs +210 -0
- package/foundation/discovery/project-typescript.d.mts +23 -0
- package/foundation/discovery/project-typescript.mjs +61 -0
- package/foundation/discovery/prop-drift.d.mts +220 -0
- package/foundation/discovery/prop-drift.mjs +1765 -0
- package/foundation/discovery/prop-drift.test.mjs +1197 -0
- package/foundation/discovery/template-adapter.mjs +74 -5
- package/foundation/discovery/unresolved-references.d.mts +62 -0
- package/foundation/discovery/unresolved-references.mjs +790 -0
- package/foundation/discovery/unresolved-references.test.mjs +567 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +9 -1
- package/foundation/doc-compiler/inputs.mjs +23 -0
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/integrations/contribution-inventory.mjs +6 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/xle/registry.mjs +4 -0
- package/foundation/xle/registry.test.mjs +28 -0
- package/package.json +10 -10
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
discoverComponents,
|
|
17
17
|
discoverExternalComponentsGrouped,
|
|
18
18
|
discoverValidIntegrationComponents,
|
|
19
|
+
familyMember,
|
|
19
20
|
findComponentReadme,
|
|
20
21
|
findExternalComponentDoc,
|
|
21
22
|
resolveImportPath,
|
|
@@ -66,6 +67,33 @@ async function legacyImport(ext, name, coreDir, docOpts) {
|
|
|
66
67
|
*/
|
|
67
68
|
const coreEntry = doc => ({name: doc.name, package: CORE_PACKAGE, ...doc});
|
|
68
69
|
|
|
70
|
+
/**
|
|
71
|
+
* The full-level entry for a component documented as a member of its family's
|
|
72
|
+
* doc (VStack in Stack's doc): a component doc built from the member's own
|
|
73
|
+
* entry, under its own name, display name and import, shaped like every other
|
|
74
|
+
* full entry. Null when the doc is the component's own.
|
|
75
|
+
* @param {any} docs
|
|
76
|
+
* @param {string} name
|
|
77
|
+
* @param {string} coreDir
|
|
78
|
+
* @returns {any}
|
|
79
|
+
*/
|
|
80
|
+
function memberEntry(docs, name, coreDir) {
|
|
81
|
+
const member = familyMember(docs, name);
|
|
82
|
+
if (!member) return null;
|
|
83
|
+
return {
|
|
84
|
+
name,
|
|
85
|
+
package: CORE_PACKAGE,
|
|
86
|
+
displayName: member.displayName ?? name,
|
|
87
|
+
...(docs.group ? {group: docs.group} : {}),
|
|
88
|
+
...(docs.category ? {category: docs.category} : {}),
|
|
89
|
+
usage: member.usage ?? {description: member.description ?? ''},
|
|
90
|
+
props: member.props ?? [],
|
|
91
|
+
...(member.examples ? {examples: member.examples} : {}),
|
|
92
|
+
...(docs.theming ? {theming: docs.theming} : {}),
|
|
93
|
+
import: resolveImportPath(coreDir, name),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
69
97
|
/**
|
|
70
98
|
* The entry for a Core slot an integration component replaces
|
|
71
99
|
* (spec:AST-035 FR11), at the list's detail level: the replacement's own name,
|
|
@@ -177,7 +205,11 @@ export async function componentList(
|
|
|
177
205
|
entries.push({
|
|
178
206
|
name: comp,
|
|
179
207
|
package: CORE_PACKAGE,
|
|
180
|
-
description:
|
|
208
|
+
description:
|
|
209
|
+
familyMember(docs, comp)?.description ||
|
|
210
|
+
docs.usage?.description ||
|
|
211
|
+
docs.description ||
|
|
212
|
+
'',
|
|
181
213
|
import: resolveImportPath(coreDir, comp),
|
|
182
214
|
});
|
|
183
215
|
} catch {
|
|
@@ -215,7 +247,8 @@ export async function componentList(
|
|
|
215
247
|
const readme = findComponentReadme(coreDir, comp);
|
|
216
248
|
if (readme && readme.endsWith('.doc.mjs')) {
|
|
217
249
|
try {
|
|
218
|
-
|
|
250
|
+
const docs = await loadComponentDoc(readme, {zh, lang, dense});
|
|
251
|
+
entries.push(memberEntry(docs, comp, coreDir) ?? coreEntry(docs));
|
|
219
252
|
} catch {
|
|
220
253
|
entries.push({name: `XDS${comp}`, package: CORE_PACKAGE, description: ''});
|
|
221
254
|
}
|
|
@@ -269,7 +302,11 @@ export async function componentList(
|
|
|
269
302
|
result[cat].push({
|
|
270
303
|
name: comp,
|
|
271
304
|
package: CORE_PACKAGE,
|
|
272
|
-
description:
|
|
305
|
+
description:
|
|
306
|
+
familyMember(docs, comp)?.description ||
|
|
307
|
+
docs.usage?.description ||
|
|
308
|
+
docs.description ||
|
|
309
|
+
'',
|
|
273
310
|
import: resolveImportPath(coreDir, comp),
|
|
274
311
|
});
|
|
275
312
|
} catch {
|
|
@@ -310,7 +347,8 @@ export async function componentList(
|
|
|
310
347
|
const readme = findComponentReadme(coreDir, comp);
|
|
311
348
|
if (readme && readme.endsWith('.doc.mjs')) {
|
|
312
349
|
try {
|
|
313
|
-
|
|
350
|
+
const docs = await loadComponentDoc(readme, {zh, lang, dense});
|
|
351
|
+
result[cat].push(memberEntry(docs, comp, coreDir) ?? coreEntry(docs));
|
|
314
352
|
} catch {
|
|
315
353
|
result[cat].push({name: `XDS${comp}`, package: CORE_PACKAGE, description: ''});
|
|
316
354
|
}
|
|
@@ -17,7 +17,18 @@
|
|
|
17
17
|
import {Worker} from 'node:worker_threads';
|
|
18
18
|
import {AstryxError} from '../error.mjs';
|
|
19
19
|
import {Project} from '../../foundation/config/project.mjs';
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
CORE_PACKAGE,
|
|
22
|
+
discoverIntegrationComponents,
|
|
23
|
+
docStem,
|
|
24
|
+
findComponentReadme,
|
|
25
|
+
findIntegrationComponent,
|
|
26
|
+
integrationRecordHold,
|
|
27
|
+
isIntegrationMember,
|
|
28
|
+
unscopedComponentOwners,
|
|
29
|
+
} from '../../foundation/discovery/component-discovery.mjs';
|
|
30
|
+
import {legacyExternalKeeps} from '../component/_adapter.mjs';
|
|
31
|
+
import {findCoreDir} from '../../foundation/fs/paths.mjs';
|
|
21
32
|
import {captureEnv} from '../../foundation/debug/event.mjs';
|
|
22
33
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
23
34
|
import {parseGapReportReceipt} from '../../authoring/gap-report/parse.mjs';
|
|
@@ -178,13 +189,65 @@ async function selectTarget(project, component, packageName) {
|
|
|
178
189
|
coreName,
|
|
179
190
|
);
|
|
180
191
|
if (replacement) return targetForPackage(project, replacement.package);
|
|
192
|
+
// The owner rule runs over every owner discovery finds, loadable or not
|
|
193
|
+
// (a doc recorded under another export still answers to its file's name);
|
|
194
|
+
// then only owners whose docs load route a report.
|
|
195
|
+
const wanted = bareComponent.toLowerCase();
|
|
196
|
+
const loads = new Set(records.map(r => `${r.package}\0${r.docPath}`));
|
|
197
|
+
const recorded = project.loadedIntegrations.flatMap(integration =>
|
|
198
|
+
discoverIntegrationComponents(integration).flatMap(r =>
|
|
199
|
+
r.name.toLowerCase() === wanted
|
|
200
|
+
? [{...r, hold: integrationRecordHold(r)}]
|
|
201
|
+
: docStem(r.docPath).toLowerCase() === wanted && !isIntegrationMember(r)
|
|
202
|
+
? [{...r, hold: 'doc'}]
|
|
203
|
+
: [],
|
|
204
|
+
),
|
|
205
|
+
);
|
|
206
|
+
// The checks below find files by name, so they run on every spelling the
|
|
207
|
+
// case-blind match above found, as well as the one typed.
|
|
208
|
+
const spellings = new Set([
|
|
209
|
+
bareComponent,
|
|
210
|
+
...recorded.flatMap(r =>
|
|
211
|
+
[r.name, docStem(r.docPath)].filter(n => n.toLowerCase() === wanted),
|
|
212
|
+
),
|
|
213
|
+
]);
|
|
214
|
+
// Core also holds a name only its doc lookup finds, as in detail: a name a
|
|
215
|
+
// doc records yields to it, though it routes no report itself.
|
|
216
|
+
const coreDir = findCoreDir(project.cwd);
|
|
217
|
+
const coreDocs =
|
|
218
|
+
coreDir != null &&
|
|
219
|
+
[...spellings].some(name => findComponentReadme(coreDir, name) != null);
|
|
220
|
+
const ruled = unscopedComponentOwners([
|
|
221
|
+
...records
|
|
222
|
+
.filter(
|
|
223
|
+
r => r.package === CORE_PACKAGE && r.name.toLowerCase() === wanted,
|
|
224
|
+
)
|
|
225
|
+
.map(r => ({...r, hold: 'core'})),
|
|
226
|
+
...recorded,
|
|
227
|
+
// A hidden doc named after its file still holds that name, as the
|
|
228
|
+
// component lookup finds it; it routes no report.
|
|
229
|
+
...project.loadedIntegrations.flatMap(integration =>
|
|
230
|
+
[...spellings].flatMap(spelling => {
|
|
231
|
+
const found = findIntegrationComponent(integration, spelling);
|
|
232
|
+
return found?.hold === 'file'
|
|
233
|
+
? [{...found, package: integration.name}]
|
|
234
|
+
: [];
|
|
235
|
+
}),
|
|
236
|
+
),
|
|
237
|
+
]).filter(r => !coreDocs || r.hold !== 'doc');
|
|
238
|
+
// A legacy docs package keeps an export name a doc records, as in detail.
|
|
181
239
|
const owners = [
|
|
182
240
|
...new Set(
|
|
183
|
-
|
|
241
|
+
([...spellings].some(name =>
|
|
242
|
+
legacyExternalKeeps(project.cwd, name, ruled),
|
|
243
|
+
)
|
|
244
|
+
? []
|
|
245
|
+
: ruled
|
|
246
|
+
)
|
|
184
247
|
.filter(
|
|
185
|
-
|
|
248
|
+
r => r.hold === 'core' || loads.has(`${r.package}\0${r.docPath}`),
|
|
186
249
|
)
|
|
187
|
-
.map(
|
|
250
|
+
.map(r => r.package),
|
|
188
251
|
),
|
|
189
252
|
];
|
|
190
253
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Each component doc's props compared with the component's TypeScript props,
|
|
6
|
+
* read with the project's own compiler (spec:AST-039 FR12). Without one, the
|
|
7
|
+
* report says the comparison was skipped.
|
|
8
|
+
* @param {any} integration a loaded integration
|
|
9
|
+
* @param {string} cwd
|
|
10
|
+
* @returns {Promise<import('../../foundation/discovery/prop-drift.mjs').PropDriftReport>}
|
|
11
|
+
*/
|
|
12
|
+
export function integrationPropDrift(integration: any, cwd: string): Promise<import("../../foundation/discovery/prop-drift.mjs").PropDriftReport>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The integration subject's access to the environment (INV21): reading
|
|
5
|
+
* one package's component docs and sources with the project's own TypeScript.
|
|
6
|
+
*
|
|
7
|
+
* @input a loaded integration and the directory the command runs in
|
|
8
|
+
* @output the reports the integration checks attach to their results
|
|
9
|
+
* @position api/integration (internal; not exported from ./api)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
discoverValidIntegrationComponents,
|
|
14
|
+
forEachIntegrationDoc,
|
|
15
|
+
integrationSourceForDoc,
|
|
16
|
+
} from '../../foundation/discovery/component-discovery.mjs';
|
|
17
|
+
import {comparePropDocs} from '../../foundation/discovery/prop-drift.mjs';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Each component doc's props compared with the component's TypeScript props,
|
|
21
|
+
* read with the project's own compiler (spec:AST-039 FR12). Without one, the
|
|
22
|
+
* report says the comparison was skipped.
|
|
23
|
+
* @param {any} integration a loaded integration
|
|
24
|
+
* @param {string} cwd
|
|
25
|
+
* @returns {Promise<import('../../foundation/discovery/prop-drift.mjs').PropDriftReport>}
|
|
26
|
+
*/
|
|
27
|
+
export async function integrationPropDrift(integration, cwd) {
|
|
28
|
+
const packageDir = /** @type {{__packageDir?: string}} */ (integration)
|
|
29
|
+
.__packageDir;
|
|
30
|
+
const {components} = await discoverValidIntegrationComponents(integration);
|
|
31
|
+
// Every doc the package ships has its prop tables compared or listed as not
|
|
32
|
+
// compared. A doc discovery leaves out (a hidden one, a second doc for one
|
|
33
|
+
// name, or one whose source or own file doesn't load) gets a record under
|
|
34
|
+
// its file name.
|
|
35
|
+
const recorded = new Set(components.map(c => c.docPath));
|
|
36
|
+
/** @type {typeof components} */
|
|
37
|
+
const left = [];
|
|
38
|
+
forEachIntegrationDoc(integration?.components, (docPath, stem) => {
|
|
39
|
+
if (recorded.has(docPath)) return;
|
|
40
|
+
recorded.add(docPath);
|
|
41
|
+
left.push({
|
|
42
|
+
name: stem,
|
|
43
|
+
package: integration.name,
|
|
44
|
+
docPath,
|
|
45
|
+
sourcePath: integrationSourceForDoc(docPath),
|
|
46
|
+
issuesUrl: integration.issuesUrl,
|
|
47
|
+
group: null,
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
return comparePropDocs([...components, ...left], {
|
|
51
|
+
packageDir: packageDir ?? cwd,
|
|
52
|
+
resolveFrom: [cwd, packageDir],
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -98,6 +98,72 @@ describe('integrationAddComponent name collisions', () => {
|
|
|
98
98
|
expect(snapshot()).toEqual(before);
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
+
it('adds a name a family doc lists but the module it imports does not export', async () => {
|
|
102
|
+
fs.writeFileSync(
|
|
103
|
+
path.join(tmpDir, 'package.json'),
|
|
104
|
+
`${JSON.stringify({name: '@acme/widgets', version: '1.0.0', files: ['dist'], exports: {'./tabs': './components/tabs/index.ts'}}, null, 2)}\n`,
|
|
105
|
+
);
|
|
106
|
+
const tabs = path.join(tmpDir, 'components', 'tabs');
|
|
107
|
+
fs.mkdirSync(tabs, {recursive: true});
|
|
108
|
+
fs.writeFileSync(
|
|
109
|
+
path.join(tabs, 'AcmeTabs.doc.mjs'),
|
|
110
|
+
"export default {type: 'component', name: 'AcmeTabs', import: '@acme/widgets/tabs', description: 'x', components: [{name: 'AcmeTabExtra', description: 'x'}]};\n",
|
|
111
|
+
);
|
|
112
|
+
fs.writeFileSync(
|
|
113
|
+
path.join(tabs, 'AcmeTabs.tsx'),
|
|
114
|
+
'export function AcmeTabs() { return null; }\nexport function AcmeTabExtra() { return null; }\n',
|
|
115
|
+
);
|
|
116
|
+
fs.writeFileSync(
|
|
117
|
+
path.join(tabs, 'index.ts'),
|
|
118
|
+
"export {AcmeTabs} from './AcmeTabs';\n",
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const result = await integrationAdd('component', 'AcmeTabExtra', {
|
|
122
|
+
cwd: tmpDir,
|
|
123
|
+
dryRun: true,
|
|
124
|
+
});
|
|
125
|
+
expect(result.data.files).toContain('components/AcmeTabExtra.doc.mjs');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('refuses a member a family exports through built output', async () => {
|
|
129
|
+
fs.writeFileSync(
|
|
130
|
+
path.join(tmpDir, 'package.json'),
|
|
131
|
+
`${JSON.stringify({name: '@acme/widgets', version: '1.0.0', files: ['dist'], exports: {'./tabs': './dist/tabs/index.js'}}, null, 2)}\n`,
|
|
132
|
+
);
|
|
133
|
+
const tabs = path.join(tmpDir, 'components', 'tabs');
|
|
134
|
+
fs.mkdirSync(tabs, {recursive: true});
|
|
135
|
+
fs.writeFileSync(
|
|
136
|
+
path.join(tabs, 'AcmeTabs.doc.mjs'),
|
|
137
|
+
"export default {type: 'component', name: 'AcmeTabs', import: '@acme/widgets/tabs', description: 'x', components: [{name: 'AcmeTab', description: 'x'}]};\n",
|
|
138
|
+
);
|
|
139
|
+
fs.writeFileSync(
|
|
140
|
+
path.join(tabs, 'AcmeTabs.tsx'),
|
|
141
|
+
'export function AcmeTabs() { return null; }\n',
|
|
142
|
+
);
|
|
143
|
+
fs.writeFileSync(
|
|
144
|
+
path.join(tabs, 'AcmeTab.tsx'),
|
|
145
|
+
'export function AcmeTab() { return null; }\n',
|
|
146
|
+
);
|
|
147
|
+
const dist = path.join(tmpDir, 'dist', 'tabs');
|
|
148
|
+
fs.mkdirSync(dist, {recursive: true});
|
|
149
|
+
fs.writeFileSync(
|
|
150
|
+
path.join(dist, 'index.js'),
|
|
151
|
+
"export {AcmeTabs} from './tabs.js';\nexport {AcmeTab} from './tab.js';\n",
|
|
152
|
+
);
|
|
153
|
+
fs.writeFileSync(
|
|
154
|
+
path.join(dist, 'tabs.js'),
|
|
155
|
+
'export function AcmeTabs() { return null; }\n',
|
|
156
|
+
);
|
|
157
|
+
fs.writeFileSync(
|
|
158
|
+
path.join(dist, 'tab.js'),
|
|
159
|
+
'export function AcmeTab() { return null; }\n',
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
await expect(
|
|
163
|
+
integrationAdd('component', 'AcmeTab', {cwd: tmpDir, dryRun: true}),
|
|
164
|
+
).rejects.toThrow('Refusing to add component "AcmeTab"');
|
|
165
|
+
});
|
|
166
|
+
|
|
101
167
|
it('still adds a component whose name is free', async () => {
|
|
102
168
|
writeAuthoredComponent('components/AcmeWidget/AcmeWidget.doc.mjs');
|
|
103
169
|
|
|
@@ -264,9 +264,13 @@ async function addComponent(name, options) {
|
|
|
264
264
|
ERROR_CODES.ERR_FILE_EXISTS,
|
|
265
265
|
);
|
|
266
266
|
}
|
|
267
|
-
//
|
|
268
|
-
//
|
|
269
|
-
|
|
267
|
+
// A second doc under a name discovery already records, by a doc's file name
|
|
268
|
+
// anywhere under the root or by a name a doc documents, would shadow one of
|
|
269
|
+
// the two.
|
|
270
|
+
const existingDoc = findIntegrationComponentDoc(
|
|
271
|
+
{name: owner, components: root, __packageDir: packageDir},
|
|
272
|
+
name,
|
|
273
|
+
);
|
|
270
274
|
if (existingDoc != null) {
|
|
271
275
|
throw new AstryxError(
|
|
272
276
|
`Refusing to add component "${name}": ${projectPath(path.relative(packageDir, existingDoc))} already defines it.`,
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Integration authoring diagnostics against the built-in Core catalog.
|
|
5
5
|
*
|
|
6
|
+
* The components check also compares each component doc's props with the
|
|
7
|
+
* component's TypeScript props (foundation/discovery/prop-drift.mjs); those
|
|
8
|
+
* findings are warnings under `propDrift`.
|
|
9
|
+
*
|
|
6
10
|
* Templates may intentionally replace Core identities; undeclared same-id
|
|
7
11
|
* overlaps stay fail-closed and require package selection. The CLI package
|
|
8
12
|
* version gates replacement-specific fields so 0.6.x keeps its released shape.
|
|
@@ -25,6 +29,7 @@ import {
|
|
|
25
29
|
discoverOwnedComponents,
|
|
26
30
|
} from '../../foundation/discovery/component-discovery.mjs';
|
|
27
31
|
import {loadComponentReplacements} from '../component/_adapter.mjs';
|
|
32
|
+
import {integrationPropDrift} from './_adapter.mjs';
|
|
28
33
|
import {
|
|
29
34
|
discoverBuiltinTopics,
|
|
30
35
|
discoverIntegrationDocs,
|
|
@@ -242,6 +247,10 @@ export async function integrationComponentConflicts(pkg, options = {}) {
|
|
|
242
247
|
};
|
|
243
248
|
}
|
|
244
249
|
|
|
250
|
+
// Each documented prop against the component's TypeScript props, read with
|
|
251
|
+
// the project's own compiler; without one the report says it was skipped.
|
|
252
|
+
const propDrift = await integrationPropDrift(resolved.integration, cwd);
|
|
253
|
+
|
|
245
254
|
const coreDir = findCoreDir(cwd);
|
|
246
255
|
if (!coreDir) {
|
|
247
256
|
issues.push({
|
|
@@ -252,7 +261,7 @@ export async function integrationComponentConflicts(pkg, options = {}) {
|
|
|
252
261
|
});
|
|
253
262
|
return {
|
|
254
263
|
type: 'integration.component-conflicts',
|
|
255
|
-
data: {validated, name, version, conflicts: [], issues},
|
|
264
|
+
data: {validated, name, version, conflicts: [], issues, propDrift},
|
|
256
265
|
};
|
|
257
266
|
}
|
|
258
267
|
|
|
@@ -296,7 +305,7 @@ export async function integrationComponentConflicts(pkg, options = {}) {
|
|
|
296
305
|
|
|
297
306
|
return {
|
|
298
307
|
type: 'integration.component-conflicts',
|
|
299
|
-
data: {validated, name, version, conflicts, issues},
|
|
308
|
+
data: {validated, name, version, conflicts, issues, propDrift},
|
|
300
309
|
};
|
|
301
310
|
}
|
|
302
311
|
|
|
@@ -417,6 +417,45 @@ describe('integrationComponentConflicts', () => {
|
|
|
417
417
|
expect(result.data.conflicts).toEqual([]);
|
|
418
418
|
expect(result.data.issues).toEqual([]);
|
|
419
419
|
});
|
|
420
|
+
|
|
421
|
+
it("compares each component doc's props with the component's TypeScript props, as warnings", async () => {
|
|
422
|
+
writeComponentIntegration('AcmeBadge');
|
|
423
|
+
fs.writeFileSync(
|
|
424
|
+
path.join(tmpDir, 'components', 'AcmeBadge.doc.mjs'),
|
|
425
|
+
`export default {type: 'component', name: 'AcmeBadge', displayName: 'AcmeBadge', description: 'Fixture component.', props: [{name: 'label', type: 'string', description: 'Text.', required: true}, {name: 'size', type: "'sm' | 'md'", description: 'Size.'}]};\n`,
|
|
426
|
+
);
|
|
427
|
+
fs.writeFileSync(
|
|
428
|
+
path.join(tmpDir, 'components', 'AcmeBadge.tsx'),
|
|
429
|
+
'export function AcmeBadge(props: {label: string; count?: number}) { return null; }\n',
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
const result = await integrationComponentConflicts(undefined, {
|
|
433
|
+
cwd: tmpDir,
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
expect(result.data.issues).toEqual([]);
|
|
437
|
+
expect(result.data.propDrift).toMatchObject({
|
|
438
|
+
status: 'checked',
|
|
439
|
+
components: 1,
|
|
440
|
+
unchecked: [],
|
|
441
|
+
});
|
|
442
|
+
expect(
|
|
443
|
+
result.data.propDrift?.findings.map(f => [f.prop, f.kind, f.severity]),
|
|
444
|
+
).toEqual([
|
|
445
|
+
['count', 'not_in_doc', 'warning'],
|
|
446
|
+
['size', 'not_in_code', 'warning'],
|
|
447
|
+
]);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
it('leaves propDrift out when the package has no components root', async () => {
|
|
451
|
+
writeDocIntegration({name: 'acme-setup'});
|
|
452
|
+
|
|
453
|
+
const result = await integrationComponentConflicts(undefined, {
|
|
454
|
+
cwd: tmpDir,
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
expect(result.data).not.toHaveProperty('propDrift');
|
|
458
|
+
});
|
|
420
459
|
});
|
|
421
460
|
|
|
422
461
|
describe('integrationDocConflicts', () => {
|
|
@@ -47,6 +47,14 @@ export type IntegrationTemplateConflictResponse = {
|
|
|
47
47
|
issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
|
|
48
48
|
};
|
|
49
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Documented props compared with the component's TypeScript props. Present
|
|
52
|
+
* when the manifest loads and declares a components root. `status: 'skipped'`
|
|
53
|
+
* means nothing was compared (no TypeScript in the project) and `reason` says
|
|
54
|
+
* why. Every finding is a warning.
|
|
55
|
+
*/
|
|
56
|
+
export type PropDriftReport = import("../../foundation/discovery/prop-drift.mjs").PropDriftReport;
|
|
57
|
+
export type PropDriftFinding = import("../../foundation/discovery/prop-drift.mjs").PropDriftFinding;
|
|
50
58
|
export type IntegrationComponentConflictResponse = {
|
|
51
59
|
type: "integration.component-conflicts";
|
|
52
60
|
data: {
|
|
@@ -55,6 +63,7 @@ export type IntegrationComponentConflictResponse = {
|
|
|
55
63
|
version: string | null;
|
|
56
64
|
conflicts: IntegrationComponentConflict[];
|
|
57
65
|
issues: import("../../foundation/integrations/issue").AstryxIntegrationIssue[];
|
|
66
|
+
propDrift?: PropDriftReport;
|
|
58
67
|
};
|
|
59
68
|
};
|
|
60
69
|
export type IntegrationDocConflictResponse = {
|
|
@@ -58,10 +58,23 @@
|
|
|
58
58
|
* @property {{validated: boolean, name: string | null, version: string | null, conflicts: IntegrationTemplateConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
59
59
|
*/
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Documented props compared with the component's TypeScript props. Present
|
|
63
|
+
* when the manifest loads and declares a components root. `status: 'skipped'`
|
|
64
|
+
* means nothing was compared (no TypeScript in the project) and `reason` says
|
|
65
|
+
* why. Every finding is a warning.
|
|
66
|
+
*
|
|
67
|
+
* @typedef {import('../../foundation/discovery/prop-drift.mjs').PropDriftReport} PropDriftReport
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @typedef {import('../../foundation/discovery/prop-drift.mjs').PropDriftFinding} PropDriftFinding
|
|
72
|
+
*/
|
|
73
|
+
|
|
61
74
|
/**
|
|
62
75
|
* @typedef {object} IntegrationComponentConflictResponse
|
|
63
76
|
* @property {'integration.component-conflicts'} type
|
|
64
|
-
* @property {{validated: boolean, name: string | null, version: string | null, conflicts: IntegrationComponentConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[]}} data
|
|
77
|
+
* @property {{validated: boolean, name: string | null, version: string | null, conflicts: IntegrationComponentConflict[], issues: import('../../foundation/integrations/issue').AstryxIntegrationIssue[], propDrift?: PropDriftReport}} data
|
|
65
78
|
*/
|
|
66
79
|
|
|
67
80
|
/**
|
|
@@ -10,17 +10,30 @@ export const doc = {
|
|
|
10
10
|
namespace: 'cli/api',
|
|
11
11
|
displayName: 'integrationComponentConflicts()',
|
|
12
12
|
summary:
|
|
13
|
-
'Check integration component names
|
|
13
|
+
'Check integration component names, replaces declarations, and documented props.',
|
|
14
14
|
description:
|
|
15
15
|
'Loads one local or installed integration, compares its component names with ' +
|
|
16
16
|
'Core, and returns non-blocking conflicts with the exact package-qualified ' +
|
|
17
17
|
"component command required to keep an intentional overlap. Each component's " +
|
|
18
18
|
'replaces is checked too: its findings are issues, errors for a package that ' +
|
|
19
|
-
'declares the CLI range that turns replacement on and warnings otherwise.'
|
|
19
|
+
'declares the CLI range that turns replacement on and warnings otherwise. ' +
|
|
20
|
+
"Each component doc's props are compared with the component's TypeScript props, " +
|
|
21
|
+
"read with the project's own `typescript`: a documented prop the code lacks, a " +
|
|
22
|
+
'prop the package declares that the doc omits, or a wrong `required`. Those ' +
|
|
23
|
+
'findings are warnings ' +
|
|
24
|
+
'in `propDrift`; without TypeScript it is `skipped` with a reason.',
|
|
20
25
|
importPath: '@astryxdesign/cli/api',
|
|
21
26
|
signature:
|
|
22
27
|
'integrationComponentConflicts(pkg?: string, options?: IntegrationAuthoringOptions): Promise<IntegrationComponentConflictResponse>',
|
|
23
|
-
keywords: [
|
|
28
|
+
keywords: [
|
|
29
|
+
'integration',
|
|
30
|
+
'component',
|
|
31
|
+
'conflict',
|
|
32
|
+
'authoring',
|
|
33
|
+
'doctor',
|
|
34
|
+
'props',
|
|
35
|
+
'drift',
|
|
36
|
+
],
|
|
24
37
|
params: [
|
|
25
38
|
{name: 'pkg', type: 'string', description: 'Installed package; omit for the local package.'},
|
|
26
39
|
{name: 'options.cwd', type: 'string', description: 'Resolution directory.'},
|
|
@@ -29,11 +42,14 @@ export const doc = {
|
|
|
29
42
|
{
|
|
30
43
|
type: 'integration.component-conflicts',
|
|
31
44
|
description:
|
|
32
|
-
'`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural and replaces issues, and Core component-name conflicts with package-qualified commands. An active replacement that keeps the Core name it replaces is not a conflict.',
|
|
45
|
+
'`validated` (false when no integration manifest was found, so nothing was inspected), integration identity, structural and replaces issues, and Core component-name conflicts with package-qualified commands. An active replacement that keeps the Core name it replaces is not a conflict. When the manifest loads and declares a components root, `propDrift` holds the props comparison: `status` (`checked` | `skipped`), `reason` when skipped, `typescript`, `components` compared, `findings` ({component, prop, kind: `not_in_code` | `not_in_doc` | `required_mismatch`, severity: `warning`, message, doc, source, docType?, codeType?, docRequired?, codeRequired?}), `unchecked` ({component, doc, reason}), and `propsNotChecked` when a mapped type builds props from keys the check cannot trace to the package ({component, doc, reason, props}: no warning is drawn for those props).',
|
|
33
46
|
},
|
|
34
47
|
],
|
|
35
48
|
examples: [
|
|
36
|
-
{
|
|
49
|
+
{
|
|
50
|
+
label: 'Check the local integration',
|
|
51
|
+
code: 'await integrationComponentConflicts();',
|
|
52
|
+
},
|
|
37
53
|
],
|
|
38
54
|
command: 'doctor integration components',
|
|
39
55
|
related: ['integrationTemplateConflicts', 'component'],
|