@astryxdesign/cli 0.7.2-canary.52c4239 → 0.7.2-canary.5814894
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/api/component/_adapter.d.mts +27 -1
- package/api/component/_adapter.mjs +45 -7
- package/api/component/component.mjs +12 -3
- package/api/component/component.test.mjs +80 -0
- package/api/component/integration-export-name.test.mjs +419 -0
- package/api/component/list/list.mjs +42 -4
- package/api/gap-report/gap-report.mjs +66 -4
- package/api/integration/pack-check.mjs +13 -104
- package/api/integration/pack-check.test.mjs +112 -0
- package/api/search/search.d.mts +9 -0
- package/api/search/search.mjs +90 -10
- package/api/search/search.test.mjs +36 -0
- package/api/swizzle/copy/copy.mjs +28 -14
- package/api/theme/build/build.family.test.mjs +16 -0
- package/api/theme/build/build.mjs +77 -18
- 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/component-imports.doc.mjs +8 -0
- package/assets/docs/working-with-ai.doc.mjs +43 -4
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- 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/theme-build.doc.mjs +2 -2
- package/foundation/discovery/component-discovery.d.mts +95 -6
- package/foundation/discovery/component-discovery.export-names.test.mjs +293 -0
- package/foundation/discovery/component-discovery.mjs +524 -49
- package/foundation/discovery/component-discovery.test.mjs +96 -0
- package/foundation/discovery/component-replacement.mjs +18 -0
- package/foundation/discovery/component-replacement.test.mjs +20 -0
- package/foundation/discovery/module-exports.d.mts +21 -0
- package/foundation/discovery/module-exports.mjs +343 -31
- package/foundation/discovery/module-exports.test.mjs +172 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +4 -0
- package/foundation/doc-compiler/inputs.mjs +23 -0
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/xle/registry.mjs +4 -0
- package/foundation/xle/registry.test.mjs +28 -0
- package/package.json +9 -9
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
* @property {string|null} sourcePath
|
|
27
27
|
* @property {string|undefined} issuesUrl
|
|
28
28
|
* @property {import('../../foundation/integrations/integrations.mjs').LoadedIntegration|null} integration
|
|
29
|
+
* @property {import('../../foundation/discovery/component-discovery.mjs').NameHold} hold
|
|
30
|
+
* how the owner holds the name, for the owner rule
|
|
29
31
|
*/
|
|
30
32
|
/**
|
|
31
33
|
* What ownership shaping needs from an owner. The core and legacy-external
|
|
@@ -138,6 +140,25 @@ export function assertUnambiguousOwners(owners: ComponentOwner[], dirName: strin
|
|
|
138
140
|
* @returns {string | null}
|
|
139
141
|
*/
|
|
140
142
|
export function resolveLegacyExternalDoc(ext: ExternalPackageRef, dirName: string): string | null;
|
|
143
|
+
/**
|
|
144
|
+
* Whether a legacy external package documents `dirName`.
|
|
145
|
+
* @param {string} cwd
|
|
146
|
+
* @param {string} dirName
|
|
147
|
+
* @returns {boolean}
|
|
148
|
+
*/
|
|
149
|
+
export function legacyExternalDocuments(cwd: string, dirName: string): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Whether a legacy docs package keeps `dirName` over these owners, each of which
|
|
152
|
+
* holds it only as an export a doc records.
|
|
153
|
+
* @param {string} cwd
|
|
154
|
+
* @param {string} dirName
|
|
155
|
+
* @param {Array<{hold?: string, docPath?: string | null}>} owners
|
|
156
|
+
* @returns {boolean}
|
|
157
|
+
*/
|
|
158
|
+
export function legacyExternalKeeps(cwd: string, dirName: string, owners: Array<{
|
|
159
|
+
hold?: string;
|
|
160
|
+
docPath?: string | null;
|
|
161
|
+
}>): boolean;
|
|
141
162
|
/**
|
|
142
163
|
* The core source file for `dirName` (the no-scope `--source` path reads core
|
|
143
164
|
* directly — it does NOT fall back to externals or fuzzy search).
|
|
@@ -210,7 +231,6 @@ export function scopeSubComponent(docs: LoadedComponentDoc, dirName: string, cor
|
|
|
210
231
|
};
|
|
211
232
|
matchingComponent: any;
|
|
212
233
|
} | null;
|
|
213
|
-
export { CORE_PACKAGE };
|
|
214
234
|
/**
|
|
215
235
|
* Internal ambiguity marker. Single-component callers still receive the same
|
|
216
236
|
* AstryxError code, message, and suggestions; batch callers can additionally
|
|
@@ -261,6 +281,10 @@ export type ComponentOwner = {
|
|
|
261
281
|
sourcePath: string | null;
|
|
262
282
|
issuesUrl: string | undefined;
|
|
263
283
|
integration: import("../../foundation/integrations/integrations.mjs").LoadedIntegration | null;
|
|
284
|
+
/**
|
|
285
|
+
* how the owner holds the name, for the owner rule
|
|
286
|
+
*/
|
|
287
|
+
hold: import("../../foundation/discovery/component-discovery.mjs").NameHold;
|
|
264
288
|
};
|
|
265
289
|
/**
|
|
266
290
|
* What ownership shaping needs from an owner. The core and legacy-external
|
|
@@ -303,4 +327,6 @@ export type ResolvedUnscopedDoc = {
|
|
|
303
327
|
resolvedSourcePath: string | null;
|
|
304
328
|
};
|
|
305
329
|
import { CORE_PACKAGE } from '../../foundation/discovery/component-discovery.mjs';
|
|
330
|
+
import { unscopedComponentOwners } from '../../foundation/discovery/component-discovery.mjs';
|
|
306
331
|
import { AstryxError } from '../error.mjs';
|
|
332
|
+
export { CORE_PACKAGE, unscopedComponentOwners };
|
|
@@ -28,13 +28,14 @@ import {
|
|
|
28
28
|
import {
|
|
29
29
|
CORE_PACKAGE,
|
|
30
30
|
discoverComponents,
|
|
31
|
+
docStem,
|
|
31
32
|
findComponentReadme,
|
|
32
33
|
findComponentSource,
|
|
33
34
|
findExternalComponentDoc,
|
|
34
|
-
|
|
35
|
-
findIntegrationComponentSource,
|
|
35
|
+
findIntegrationComponent,
|
|
36
36
|
resolveImportPath,
|
|
37
37
|
resolveIntegrationImportPath as resolveIntegrationImport,
|
|
38
|
+
unscopedComponentOwners,
|
|
38
39
|
} from '../../foundation/discovery/component-discovery.mjs';
|
|
39
40
|
import {Project} from '../../foundation/config/project.mjs';
|
|
40
41
|
import {loadComponentDoc as loadValidatedComponentDoc} from '../../foundation/discovery/component-loader.mjs';
|
|
@@ -42,7 +43,7 @@ import {resolveComponentReplacements} from '../../foundation/discovery/component
|
|
|
42
43
|
import {searchComponents} from '../../foundation/text/string-utils.mjs';
|
|
43
44
|
import {AstryxError} from '../error.mjs';
|
|
44
45
|
|
|
45
|
-
export {CORE_PACKAGE};
|
|
46
|
+
export {CORE_PACKAGE, unscopedComponentOwners};
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* A loaded component doc. The shared validated loader accepts stamped and legacy
|
|
@@ -71,6 +72,8 @@ export {CORE_PACKAGE};
|
|
|
71
72
|
* @property {string|null} sourcePath
|
|
72
73
|
* @property {string|undefined} issuesUrl
|
|
73
74
|
* @property {import('../../foundation/integrations/integrations.mjs').LoadedIntegration|null} integration
|
|
75
|
+
* @property {import('../../foundation/discovery/component-discovery.mjs').NameHold} hold
|
|
76
|
+
* how the owner holds the name, for the owner rule
|
|
74
77
|
*/
|
|
75
78
|
|
|
76
79
|
/**
|
|
@@ -240,17 +243,19 @@ export function resolveOwners(coreDir, dirName, loadedIntegrations) {
|
|
|
240
243
|
sourcePath: findComponentSource(coreDir, dirName),
|
|
241
244
|
issuesUrl: undefined,
|
|
242
245
|
integration: null,
|
|
246
|
+
hold: 'core',
|
|
243
247
|
});
|
|
244
248
|
}
|
|
245
249
|
for (const integration of loadedIntegrations) {
|
|
246
|
-
const
|
|
247
|
-
if (!
|
|
250
|
+
const found = findIntegrationComponent(integration, dirName);
|
|
251
|
+
if (!found) continue;
|
|
248
252
|
owners.push({
|
|
249
253
|
package: integration.name,
|
|
250
|
-
docPath,
|
|
251
|
-
sourcePath:
|
|
254
|
+
docPath: found.docPath,
|
|
255
|
+
sourcePath: found.sourcePath,
|
|
252
256
|
issuesUrl: integration.issuesUrl,
|
|
253
257
|
integration,
|
|
258
|
+
hold: found.hold,
|
|
254
259
|
});
|
|
255
260
|
}
|
|
256
261
|
return owners;
|
|
@@ -361,6 +366,39 @@ export function resolveLegacyExternalDoc(ext, dirName) {
|
|
|
361
366
|
return extDocPath && extDocPath.endsWith('.doc.mjs') ? extDocPath : null;
|
|
362
367
|
}
|
|
363
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Whether a legacy external package documents `dirName`.
|
|
371
|
+
* @param {string} cwd
|
|
372
|
+
* @param {string} dirName
|
|
373
|
+
* @returns {boolean}
|
|
374
|
+
*/
|
|
375
|
+
export function legacyExternalDocuments(cwd, dirName) {
|
|
376
|
+
return discoverExternalPackages(cwd).some(
|
|
377
|
+
ext => resolveLegacyExternalDoc(ext, dirName) != null,
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Whether a legacy docs package keeps `dirName` over these owners, each of which
|
|
383
|
+
* holds it only as an export a doc records.
|
|
384
|
+
* @param {string} cwd
|
|
385
|
+
* @param {string} dirName
|
|
386
|
+
* @param {Array<{hold?: string, docPath?: string | null}>} owners
|
|
387
|
+
* @returns {boolean}
|
|
388
|
+
*/
|
|
389
|
+
export function legacyExternalKeeps(cwd, dirName, owners) {
|
|
390
|
+
return (
|
|
391
|
+
owners.length > 0 &&
|
|
392
|
+
owners.every(
|
|
393
|
+
owner =>
|
|
394
|
+
owner.hold === 'doc' &&
|
|
395
|
+
owner.docPath != null &&
|
|
396
|
+
docStem(owner.docPath).toLowerCase() !== dirName.toLowerCase(),
|
|
397
|
+
) &&
|
|
398
|
+
legacyExternalDocuments(cwd, dirName)
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
|
|
364
402
|
/**
|
|
365
403
|
* The core source file for `dirName` (the no-scope `--source` path reads core
|
|
366
404
|
* directly — it does NOT fall back to externals or fuzzy search).
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
classifyScope,
|
|
23
23
|
assertUnambiguousOwners,
|
|
24
24
|
resolveLegacyExternalDoc,
|
|
25
|
+
legacyExternalKeeps,
|
|
25
26
|
resolveCoreSourcePath,
|
|
26
27
|
resolveUnscopedDoc,
|
|
27
28
|
loadComponentDoc,
|
|
@@ -29,6 +30,7 @@ import {
|
|
|
29
30
|
ComponentAmbiguityError,
|
|
30
31
|
installedComponentPackageVersion,
|
|
31
32
|
resolveComponentReplacement,
|
|
33
|
+
unscopedComponentOwners,
|
|
32
34
|
} from './_adapter.mjs';
|
|
33
35
|
import {componentList} from './list/list.mjs';
|
|
34
36
|
import {componentDetail} from './detail/detail.mjs';
|
|
@@ -481,12 +483,14 @@ export async function component(name, options = {}) {
|
|
|
481
483
|
});
|
|
482
484
|
}
|
|
483
485
|
|
|
486
|
+
// The owner rule runs first, over valid and invalid owners alike.
|
|
487
|
+
const ruled = unscopedComponentOwners(owners);
|
|
484
488
|
// Invalid integration metadata does not create ambiguity against a valid
|
|
485
|
-
// owner. Keep
|
|
489
|
+
// owner. Keep ruled owners only when no doc owner is valid, so an integration-
|
|
486
490
|
// only component still exposes its source and returns ERR_INVALID_DOC for
|
|
487
491
|
// detail instead of degrading to an unrelated unknown-component error.
|
|
488
492
|
const validOwners = [];
|
|
489
|
-
for (const owner of
|
|
493
|
+
for (const owner of ruled) {
|
|
490
494
|
if (owner.package === CORE_PACKAGE) {
|
|
491
495
|
validOwners.push(owner);
|
|
492
496
|
continue;
|
|
@@ -498,7 +502,12 @@ export async function component(name, options = {}) {
|
|
|
498
502
|
// Project/Doctor report invalid metadata; it is not an effective owner.
|
|
499
503
|
}
|
|
500
504
|
}
|
|
501
|
-
const
|
|
505
|
+
const loadable = validOwners.length > 0 ? validOwners : ruled;
|
|
506
|
+
// A legacy docs package's exact doc keeps its name over an export name a doc
|
|
507
|
+
// records, as Core and file-named owners do.
|
|
508
|
+
const effectiveOwners = legacyExternalKeeps(cwd, dirName, loadable)
|
|
509
|
+
? []
|
|
510
|
+
: loadable;
|
|
502
511
|
|
|
503
512
|
// ── Ambiguity: owned by MORE THAN ONE valid package, no --package ──
|
|
504
513
|
assertUnambiguousOwners(effectiveOwners, dirName);
|
|
@@ -13,6 +13,7 @@ import {describe, it, expect} from 'vitest';
|
|
|
13
13
|
import * as path from 'node:path';
|
|
14
14
|
import {fileURLToPath} from 'node:url';
|
|
15
15
|
import {component} from './component.mjs';
|
|
16
|
+
import {search} from '../search/search.mjs';
|
|
16
17
|
import {AstryxError} from '../error.mjs';
|
|
17
18
|
import {runCli} from '../../test-utils/run-cli.mjs';
|
|
18
19
|
|
|
@@ -92,6 +93,85 @@ describe('component dispatcher — detail levels on list', () => {
|
|
|
92
93
|
);
|
|
93
94
|
});
|
|
94
95
|
|
|
96
|
+
describe('component list — components whose docs live in a family folder', () => {
|
|
97
|
+
it('lists HStack, VStack and Heading at every detail level, each with its own import', async () => {
|
|
98
|
+
const {docs: stackDoc} = await import(
|
|
99
|
+
path.join(REPO, 'packages', 'core', 'src', 'Stack', 'Stack.doc.mjs')
|
|
100
|
+
);
|
|
101
|
+
const vstackMember = stackDoc.components.find(c => c.name === 'VStack');
|
|
102
|
+
|
|
103
|
+
const names = await component(undefined, {cwd, list: true});
|
|
104
|
+
const listed = Object.values(names.data.components).flat();
|
|
105
|
+
for (const name of ['HStack', 'VStack', 'Heading']) {
|
|
106
|
+
expect(listed).toContainEqual({name, package: '@astryxdesign/core'});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const compact = await component(undefined, {cwd, list: true, detail: 'compact'});
|
|
110
|
+
const brief = Object.values(compact.data.components).flat();
|
|
111
|
+
expect(brief.find(e => e.name === 'VStack')).toEqual({
|
|
112
|
+
name: 'VStack',
|
|
113
|
+
package: '@astryxdesign/core',
|
|
114
|
+
description: vstackMember.description,
|
|
115
|
+
import: '@astryxdesign/core/VStack',
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const full = await component(undefined, {cwd, list: true, detail: 'full'});
|
|
119
|
+
const entry = Object.values(full.data.components)
|
|
120
|
+
.flat()
|
|
121
|
+
.find(e => e.name === 'VStack');
|
|
122
|
+
// Shaped like every other full entry (a component doc plus its package):
|
|
123
|
+
// the member's own name, display name and summary, and no scoping field
|
|
124
|
+
// the full-entry type does not describe.
|
|
125
|
+
expect(entry).toEqual({
|
|
126
|
+
name: 'VStack',
|
|
127
|
+
package: '@astryxdesign/core',
|
|
128
|
+
displayName: vstackMember.displayName,
|
|
129
|
+
group: stackDoc.group,
|
|
130
|
+
category: stackDoc.category,
|
|
131
|
+
usage: {description: vstackMember.description},
|
|
132
|
+
props: vstackMember.props,
|
|
133
|
+
theming: stackDoc.theming,
|
|
134
|
+
import: '@astryxdesign/core/VStack',
|
|
135
|
+
});
|
|
136
|
+
}, SLOW);
|
|
137
|
+
|
|
138
|
+
it('prints each one\'s own import path in the list, the detail, and search', async () => {
|
|
139
|
+
// The path `component <Name>` prints is the one docs and examples teach:
|
|
140
|
+
// the component's own entry point, never its family's (/Stack, /Text) or
|
|
141
|
+
// a re-export (/Layout).
|
|
142
|
+
const compact = Object.values(
|
|
143
|
+
(await component(undefined, {cwd, list: true, detail: 'compact'})).data.components,
|
|
144
|
+
).flat();
|
|
145
|
+
const full = Object.values(
|
|
146
|
+
(await component(undefined, {cwd, list: true, detail: 'full'})).data.components,
|
|
147
|
+
).flat();
|
|
148
|
+
const textList = (await runCli(['component', '--list'], cwd)).stdout;
|
|
149
|
+
const textCompact = (
|
|
150
|
+
await runCli(['component', '--list', '--detail', 'compact'], cwd)
|
|
151
|
+
).stdout;
|
|
152
|
+
/** The `import:` line of a text record, found by its `name:` line. */
|
|
153
|
+
const textImport = (text, name) =>
|
|
154
|
+
new RegExp(`^name:\\s+${name}\\n(?:(?!name:).*\\n)*?import:\\s+(\\S+)`, 'm').exec(
|
|
155
|
+
text,
|
|
156
|
+
)?.[1];
|
|
157
|
+
for (const name of ['VStack', 'HStack', 'Heading']) {
|
|
158
|
+
const expected = `@astryxdesign/core/${name}`;
|
|
159
|
+
expect(compact.find(e => e.name === name)?.import).toBe(expected);
|
|
160
|
+
expect((await component(name, {cwd})).data.import).toBe(expected);
|
|
161
|
+
const hits = (await search(name, {cwd, type: 'component'})).data.results;
|
|
162
|
+
expect(hits.find(r => r.name === name)?.import).toBe(expected);
|
|
163
|
+
expect(textImport(textList, name)).toBe(expected);
|
|
164
|
+
expect(textImport(textCompact, name)).toBe(expected);
|
|
165
|
+
}
|
|
166
|
+
// The full level spreads a component's own doc, which states no import
|
|
167
|
+
// (Button's entry has none either); a member's entry is scoped to the
|
|
168
|
+
// member and states its own.
|
|
169
|
+
for (const name of ['VStack', 'HStack']) {
|
|
170
|
+
expect(full.find(e => e.name === name)?.import).toBe(`@astryxdesign/core/${name}`);
|
|
171
|
+
}
|
|
172
|
+
}, SLOW);
|
|
173
|
+
});
|
|
174
|
+
|
|
95
175
|
describe('component dispatcher — projection precedence (locked)', () => {
|
|
96
176
|
it(
|
|
97
177
|
'--props routes to component.detail.props',
|