@astryxdesign/cli 0.6.1 → 0.6.2-canary.2b2113d
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/CHANGELOG.md +35 -1
- package/README.md +1 -1
- package/api/component/_adapter.mjs +64 -23
- package/api/component/component.doc.mjs +1 -1
- package/api/component/component.type.d.mts +8 -2
- package/api/component/component.type.mjs +5 -2
- package/api/component/integration-import-agreement.test.mjs +162 -6
- package/api/component/list/list.mjs +91 -15
- package/api/doctor/doctor.mjs +5 -16
- package/api/init/init.doc.mjs +2 -2
- package/api/init/init.type.d.mts +1 -1
- package/api/init/init.type.mjs +1 -1
- package/api/init/run/run.mjs +1 -1
- package/api/integration/add-helpers.mjs +2 -1
- package/api/integration/pack-check.mjs +9 -3
- package/api/search/search.d.mts +1 -1
- package/api/search/search.mjs +135 -41
- package/api/theme/build/build.d.mts +45 -17
- package/api/theme/build/build.family.test.mjs +435 -0
- package/api/theme/build/build.mjs +681 -121
- package/api/theme/build/build.packed-old-core.test.mjs +25 -9
- package/api/theme/build/build.test.mjs +142 -0
- package/api/theme/build/core-interception.d.mts +14 -2
- package/api/theme/build/core-interception.mjs +38 -14
- package/api/theme/build/family.d.mts +15 -0
- package/api/theme/build/family.mjs +442 -0
- package/api/theme/palette/generate/generate.mjs +2 -1
- package/assets/docs/theme.doc.dense.mjs +12 -0
- package/assets/docs/theme.doc.mjs +37 -0
- package/assets/docs/working-with-ai.doc.mjs +2 -1
- package/clients/cli/commands/build-theme.mjs +63 -5
- package/clients/cli/commands/component/index.mjs +4 -1
- package/clients/cli/commands/init.doc.mjs +2 -2
- package/clients/cli/commands/theme-build.doc.mjs +28 -10
- package/foundation/agent-docs/agent-doc-state.mjs +1 -1
- package/foundation/agent-docs/agent-docs.d.mts +2 -2
- package/foundation/agent-docs/agent-docs.mjs +8 -6
- package/foundation/agent-docs/agent-docs.test.mjs +14 -0
- package/foundation/discovery/__fixtures__/component-both-exports.doc.d.mts +24 -0
- package/foundation/discovery/__fixtures__/component-both-exports.doc.mjs +19 -0
- package/foundation/discovery/__fixtures__/component-default-export.doc.d.mts +14 -0
- package/foundation/discovery/__fixtures__/component-default-export.doc.mjs +13 -0
- package/foundation/discovery/__fixtures__/component-named-export.doc.d.mts +13 -0
- package/foundation/discovery/__fixtures__/component-named-export.doc.mjs +11 -0
- package/foundation/discovery/component-discovery.d.mts +5 -3
- package/foundation/discovery/component-discovery.mjs +25 -9
- package/foundation/discovery/component-loader.mjs +4 -1
- package/foundation/discovery/component-loader.test.mjs +48 -0
- package/foundation/discovery/theming-targets.test.mjs +29 -0
- package/foundation/fs/paths.d.mts +19 -0
- package/foundation/fs/paths.mjs +54 -0
- package/foundation/fs/paths.test.mjs +102 -1
- package/foundation/fs/publish-file-eperm-mutation.test.mjs +62 -0
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +107 -0
- package/foundation/fs/publish-file.d.mts +22 -0
- package/foundation/fs/publish-file.mjs +68 -0
- package/foundation/fs/publish-file.test.mjs +136 -0
- package/foundation/integrations/manifest-writer.mjs +2 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +15 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @xds/cli
|
|
2
2
|
|
|
3
|
+
# 0.6.2
|
|
4
|
+
|
|
5
|
+
#### New Features
|
|
6
|
+
|
|
7
|
+
- Add `muse` preset to `astryx init --agent` targeting `AGENTS.md` for Muse Code. (#6045)
|
|
8
|
+
- Build one keyed artifact trio for a selected theme family (#6268)
|
|
9
|
+
|
|
10
|
+
#### Fixes
|
|
11
|
+
|
|
12
|
+
- doctor: range-check every peer against the project's own node_modules, so a peer that is only reachable from the ambient environment no longer reads as installed (#5327)
|
|
13
|
+
`checkPeerDeps` resolved each peer with `require.resolve(name, {paths: [cwd]})`. Node folds `NODE_PATH` into that lookup regardless of `paths`, so a peer merely reachable from the ambient environment resolved, and doctor reported nothing while the project itself was missing it. It now walks the project's own `node_modules` and reads each `package.json` off disk, so a missing peer is reported and an installed one is checked against the declared range.
|
|
14
|
+
|
|
15
|
+
Yarn Plug'n'Play projects have no `node_modules` for that walk to find, so the lookup asks the PnP runtime when the walk comes up empty. PnP resolves from the project's own dependency graph and ignores `NODE_PATH`, which keeps the answer project-local. A PnP project now gets its peers range-checked too — previously `require.resolve` could confirm a peer was present there but not read its version, because Core does not export `./package.json`.
|
|
16
|
+
|
|
17
|
+
- Component loader now reads default-export `.doc.mjs` files (the shape `integration add component` writes), fixing a crash where `component` and `search` could not load generated docs. Human `component` detail and list views now use the API-resolved import specifier instead of recomputing from core, so integration components report their package-authored import. `pack --check` now reports an error when a component doc cannot be loaded instead of silently approving. (#6291)
|
|
18
|
+
- Fix `theme build` emitting invalid JS identifiers for theme names containing hyphens or dots followed by digits. The output identifier is now derived deterministically from `theme.name` by camelCasing across `-` and `.` separators (underscores are preserved as valid identifier characters). Names like `chaos-07` correctly produce `chaos07Theme` instead of the unparseable `chaos-07Theme`. (#6289)
|
|
19
|
+
- Make staged writes portable across filesystems that reject hard links.
|
|
20
|
+
The create-only publisher now falls back from `linkSync` to `copyFileSync` with `COPYFILE_EXCL` for `EPERM` and `EXDEV`, while preserving no-clobber, concurrent-creator safety, compare-and-swap replacements, symlink rejection, rollback, and temporary-file cleanup. (#6287)
|
|
21
|
+
- theme build: only treat a core the theme's own node_modules chain can reach as one a CommonJS dependency could reach, so an ambient-only core no longer fails the build with ERR_CORE_INCOMPATIBLE (#5327)
|
|
22
|
+
`patchCommonJs` required `@astryxdesign/core` from the theme file to see whether it could wrap `defineTheme` for `.cjs` dependencies. `require` folds `NODE_PATH` in, and pnpm's isolated layout puts every package in `node_modules/.pnpm/node_modules`, so a core no dependency of the theme could reach answered that lookup. Wrapping it fails on a `require(esm)` namespace, and the reported coverage gap then rejected any theme whose lineage was unobserved. The lookup now walks the theme's own `node_modules` chain first, the same way `doctor` resolves peers.
|
|
23
|
+
|
|
24
|
+
#### Contributors
|
|
25
|
+
|
|
26
|
+
Thanks to everyone who contributed to this release:
|
|
27
|
+
|
|
28
|
+
- @cixzhang
|
|
29
|
+
- @Han5991
|
|
30
|
+
- @josephfarina
|
|
31
|
+
- @oliprovscode
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
3
35
|
# 0.6.1
|
|
4
36
|
|
|
5
37
|
#### New Features
|
|
@@ -12,10 +44,12 @@
|
|
|
12
44
|
An explicit `astryx.config` entry keeps its precedence and its position, and a dependency whose manifest fails to load is dropped quietly rather than reported as the consuming project's problem.
|
|
13
45
|
|
|
14
46
|
`astryx doctor` gains an `implicit-integrations` line naming each integration linked this way, the package.json field that declared it, and what it contributes — so an author can answer "why can the CLI see this?" without reading the CLI's source, and an unused-dependency check has something to read that says the dependency is load-bearing. The line is always informational, so the doctor CI gate is unaffected.
|
|
47
|
+
|
|
15
48
|
- Replace executable gap-report writers with composable handlers. (#6200)
|
|
16
49
|
Gap reports now fan out to every configured handler — project config first, then each loaded integration in config order — instead of selecting one writer. Each handler gets its own report copy and an abort signal under a 30 s budget. A failed handler cannot stop later handlers, and the aggregate receipt shows every outcome.
|
|
17
50
|
|
|
18
51
|
Public types: `GapReportHandler` replaces `GapReportWriter`; the handler receives a normalized `GapReport` event and returns a strict `GapReportHandlerReceipt`. Project config gains a `gapReport` field; the integration named export uses the same type.
|
|
52
|
+
|
|
19
53
|
- Add integration authoring and packed-package verification. `astryx integration add <kind> <name>` and the per-kind `integrationAddComponent`, `integrationAddDoc`, `integrationAddTemplate`, `integrationAddCodemod`, `integrationAddAgentDoc`, and `integrationAddTheme` APIs write complete contributions. Existing component, docs, template, and theme commands see the package being authored without publishing it first. `astryx integration pack --check` proves the same contributions survive the npm tarball and that packed components remain available through their public imports. Doctor now names source-only components, unreachable metadata, codemods outside a version folder, and invalid version folders. (#6245)
|
|
20
54
|
- Remove the prefix requirement from theme-local tokens (#6285)
|
|
21
55
|
- Add upgrade receipts and safe three-way reconciliation for ShadCN-copied compositions. (#6228)
|
|
@@ -490,7 +524,7 @@ Thanks to everyone who contributed to this release:
|
|
|
490
524
|
|
|
491
525
|
- Bottom Sheet showcase block: the filter checkboxes are interactive again (#5157).
|
|
492
526
|
`CheckboxInput` is fully controlled — `value` is required and the input only moves when the owner updates it. The showcase passed a literal `value={false}` with no `onChange`, so the three filters ("In stock", "On sale", "Free shipping") rendered but could never be toggled: on the docs site the first thing a reader tries in a Bottom Sheet does nothing, and anyone copying the block inherits three dead controls. Each filter now has its own `useState` and `onChange`, matching the checkbox wiring already used in the Bottom Sheet Switcher showcase.
|
|
493
|
-
- An integration whose manifest fails to load is no longer silent. A manifest that throws on import — the common case being one still calling a `create*` authoring factory, removed in 0.3.0 — contributes nothing, and the CLI treated that as if the package had never been configured: `astryx discover` answered `No integrations configured.` while `astryx.config.mjs` plainly configured one, and no command said a word. The only way to find out was to already suspect it and run `validate-integration` by name.
|
|
527
|
+
- An integration whose manifest fails to load is no longer silent. A manifest that throws on import — the common case being one still calling a `create*` authoring factory, removed in 0.3.0 — contributes nothing, and the CLI treated that as if the package had never been configured: `astryx discover` answered `No integrations configured.` while `astryx.config.mjs` plainly configured one, and no command said a word. The only way to find out was to already suspect it and run `validate-integration` by name. A configured integration could remain invisible to CLI discovery, leading an app team to conclude that its components did not exist (#5119).
|
|
494
528
|
The load error now counts as an integration issue, so the existing one-line stderr nudge fires on `component`, `template` and `upgrade`, and `discover` — the command whose whole job is listing integrations — nudges too, as does `search`. `discover` also stops reporting `configured: false` for a project that configured an integration that failed to load; the empty state now distinguishes "you configured nothing" from "what you configured contributed nothing", which is the distinction `meta.configured` was introduced to carry.
|
|
495
529
|
|
|
496
530
|
Nothing becomes fatal: the warning is best-effort, stderr-only, suppressed under `--json`, and never changes an exit code. Broken contributions are still skipped exactly as before.
|
package/README.md
CHANGED
|
@@ -395,7 +395,7 @@ Every response has a `type` discriminant. The full set is below (generated from
|
|
|
395
395
|
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
396
396
|
| `init.run` | The install receipt: the `mode` (`default` \| `features`), the features run, agent-doc files written, any soft `docsError`, whether theme guidance was emitted, the template outcome (`workflow` \| `created` \| `skipped`) plus its path, and whether the next-steps were emitted. |
|
|
397
397
|
| `init.remove` | Confirmation that the managed agent-docs block was removed (`data.removed: true`) — returned when --remove-agents is set. |
|
|
398
|
-
| `component.list` | The component catalog grouped by category: `detail` (the level: names \| compact \| full) and `components`, the grouped map of names
|
|
398
|
+
| `component.list` | The component catalog grouped by category: `detail` (the level: names \| compact \| full) and `components`, the grouped map of names entries ({name, package, and optional canonical import for integrations}), brief entries, or a full ComponentDoc per entry. |
|
|
399
399
|
| `component.detail` | One component's authored ComponentDoc plus ownership metadata (owner package, import specifier, and whether source is available). |
|
|
400
400
|
| `component.detail.props` | Just one component's props table (ComponentPropDoc[]). |
|
|
401
401
|
| `component.detail.source` | One component's source file, as {component, source}. |
|
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
findCoreDir,
|
|
24
|
+
discoverExternalPackages,
|
|
25
|
+
} from '../../foundation/fs/paths.mjs';
|
|
23
26
|
import {
|
|
24
27
|
CORE_PACKAGE,
|
|
25
28
|
discoverComponents,
|
|
@@ -109,7 +112,11 @@ export {CORE_PACKAGE};
|
|
|
109
112
|
export function requireCoreDir(cwd) {
|
|
110
113
|
const coreDir = findCoreDir(cwd);
|
|
111
114
|
if (!coreDir) {
|
|
112
|
-
throw new AstryxError(
|
|
115
|
+
throw new AstryxError(
|
|
116
|
+
'Could not find @astryxdesign/core package',
|
|
117
|
+
undefined,
|
|
118
|
+
ERROR_CODES.ERR_CORE_NOT_FOUND,
|
|
119
|
+
);
|
|
113
120
|
}
|
|
114
121
|
return coreDir;
|
|
115
122
|
}
|
|
@@ -197,12 +204,19 @@ export function resolveOwners(coreDir, dirName, loadedIntegrations) {
|
|
|
197
204
|
* @param {{owners: ComponentOwner[], loadedIntegrations: import('../../foundation/integrations/integrations.mjs').LoadedIntegration[], cwd: string, name: string}} ctx
|
|
198
205
|
* @returns {ScopeResolution}
|
|
199
206
|
*/
|
|
200
|
-
export function classifyScope(
|
|
207
|
+
export function classifyScope(
|
|
208
|
+
packageScope,
|
|
209
|
+
{owners, loadedIntegrations, cwd, name},
|
|
210
|
+
) {
|
|
201
211
|
// Core scope: resolve from core directly.
|
|
202
212
|
if (packageScope === CORE_PACKAGE) {
|
|
203
213
|
const owner = owners.find(o => o.package === CORE_PACKAGE);
|
|
204
214
|
if (!owner) {
|
|
205
|
-
throw new AstryxError(
|
|
215
|
+
throw new AstryxError(
|
|
216
|
+
`No component "${name}" in package "${packageScope}"`,
|
|
217
|
+
undefined,
|
|
218
|
+
ERROR_CODES.ERR_UNKNOWN_COMPONENT,
|
|
219
|
+
);
|
|
206
220
|
}
|
|
207
221
|
return {kind: 'core', owner};
|
|
208
222
|
}
|
|
@@ -212,7 +226,11 @@ export function classifyScope(packageScope, {owners, loadedIntegrations, cwd, na
|
|
|
212
226
|
if (integration) {
|
|
213
227
|
const owner = owners.find(o => o.package === packageScope);
|
|
214
228
|
if (!owner) {
|
|
215
|
-
throw new AstryxError(
|
|
229
|
+
throw new AstryxError(
|
|
230
|
+
`No component "${name}" in package "${packageScope}"`,
|
|
231
|
+
undefined,
|
|
232
|
+
ERROR_CODES.ERR_UNKNOWN_COMPONENT,
|
|
233
|
+
);
|
|
216
234
|
}
|
|
217
235
|
return {kind: 'integration', owner};
|
|
218
236
|
}
|
|
@@ -220,7 +238,11 @@ export function classifyScope(packageScope, {owners, loadedIntegrations, cwd, na
|
|
|
220
238
|
// Legacy fallback: node_modules `pkg.astryx.docs` external package.
|
|
221
239
|
const ext = resolveExternalPackage(packageScope, cwd);
|
|
222
240
|
if (!ext) {
|
|
223
|
-
throw new AstryxError(
|
|
241
|
+
throw new AstryxError(
|
|
242
|
+
`External package "${packageScope}" not found`,
|
|
243
|
+
undefined,
|
|
244
|
+
ERROR_CODES.ERR_UNKNOWN_PACKAGE,
|
|
245
|
+
);
|
|
224
246
|
}
|
|
225
247
|
return {kind: 'legacy', ext};
|
|
226
248
|
}
|
|
@@ -283,7 +305,9 @@ export async function resolveUnscopedDoc(dirName, {coreDir, cwd, name}) {
|
|
|
283
305
|
// type, which (unlike a fresh literal) does not widen on assignment.
|
|
284
306
|
/** @type {string} */
|
|
285
307
|
let resolvedOwnerPackage = CORE_PACKAGE;
|
|
286
|
-
let resolvedSourcePath = readmePath
|
|
308
|
+
let resolvedSourcePath = readmePath
|
|
309
|
+
? findComponentSource(coreDir, dirName)
|
|
310
|
+
: null;
|
|
287
311
|
|
|
288
312
|
if (!readmePath) {
|
|
289
313
|
const externals = discoverExternalPackages(cwd);
|
|
@@ -305,7 +329,8 @@ export async function resolveUnscopedDoc(dirName, {coreDir, cwd, name}) {
|
|
|
305
329
|
if (results.length > 0) {
|
|
306
330
|
const topScore = results[0].score;
|
|
307
331
|
const topTied = results.filter(r => r.score === topScore);
|
|
308
|
-
const secondScore =
|
|
332
|
+
const secondScore =
|
|
333
|
+
results.length > topTied.length ? results[topTied.length].score : 0;
|
|
309
334
|
const gap = topScore - secondScore;
|
|
310
335
|
|
|
311
336
|
if (topScore >= 90 && topTied.length === 1 && gap >= 20) {
|
|
@@ -315,8 +340,11 @@ export async function resolveUnscopedDoc(dirName, {coreDir, cwd, name}) {
|
|
|
315
340
|
resolvedSourcePath = findComponentSource(coreDir, resolvedName);
|
|
316
341
|
} else {
|
|
317
342
|
const threshold = Math.max(topScore - 20, 1);
|
|
318
|
-
const candidates = results
|
|
319
|
-
|
|
343
|
+
const candidates = results
|
|
344
|
+
.filter(r => r.score >= threshold)
|
|
345
|
+
.slice(0, 5);
|
|
346
|
+
if (candidates.length < 2)
|
|
347
|
+
candidates.push(...results.slice(candidates.length, 2));
|
|
320
348
|
throw new AstryxError(
|
|
321
349
|
`No component named "${name}"`,
|
|
322
350
|
candidates.map(c => ({name: c.name, reason: c.reason})),
|
|
@@ -324,12 +352,20 @@ export async function resolveUnscopedDoc(dirName, {coreDir, cwd, name}) {
|
|
|
324
352
|
);
|
|
325
353
|
}
|
|
326
354
|
} else {
|
|
327
|
-
throw new AstryxError(
|
|
355
|
+
throw new AstryxError(
|
|
356
|
+
`No component named "${name}"`,
|
|
357
|
+
undefined,
|
|
358
|
+
ERROR_CODES.ERR_UNKNOWN_COMPONENT,
|
|
359
|
+
);
|
|
328
360
|
}
|
|
329
361
|
}
|
|
330
362
|
|
|
331
363
|
if (!readmePath || !readmePath.endsWith('.doc.mjs')) {
|
|
332
|
-
throw new AstryxError(
|
|
364
|
+
throw new AstryxError(
|
|
365
|
+
`No .doc.mjs found for "${resolvedName}". The component needs a typed doc file.`,
|
|
366
|
+
undefined,
|
|
367
|
+
ERROR_CODES.ERR_NO_DOC,
|
|
368
|
+
);
|
|
333
369
|
}
|
|
334
370
|
|
|
335
371
|
return {readmePath, resolvedName, resolvedOwnerPackage, resolvedSourcePath};
|
|
@@ -357,7 +393,10 @@ export async function loadComponentDoc(docPath, opts = {}) {
|
|
|
357
393
|
* @returns {any[]}
|
|
358
394
|
*/
|
|
359
395
|
export function extractProps(docs) {
|
|
360
|
-
return
|
|
396
|
+
return (
|
|
397
|
+
docs.props ||
|
|
398
|
+
(docs.components ? docs.components.flatMap(c => c.props || []) : [])
|
|
399
|
+
);
|
|
361
400
|
}
|
|
362
401
|
|
|
363
402
|
/**
|
|
@@ -374,14 +413,12 @@ export function extractProps(docs) {
|
|
|
374
413
|
export function withOwnership(docs, owner, componentName, coreDir) {
|
|
375
414
|
const importSpec =
|
|
376
415
|
owner.package === CORE_PACKAGE
|
|
377
|
-
? resolveImportPath(coreDir, componentName)
|
|
378
|
-
: resolveIntegrationImportPath(owner, componentName);
|
|
416
|
+
? (docs.import ?? resolveImportPath(coreDir, componentName))
|
|
417
|
+
: resolveIntegrationImportPath(owner, componentName, docs.import);
|
|
379
418
|
return /** @type {any} */ ({
|
|
380
419
|
...docs,
|
|
381
420
|
package: owner.package,
|
|
382
|
-
|
|
383
|
-
// several components. Only fall back to a resolved one when it does not.
|
|
384
|
-
import: docs.import ?? importSpec,
|
|
421
|
+
import: importSpec,
|
|
385
422
|
sourceAvailable: owner.sourcePath != null,
|
|
386
423
|
});
|
|
387
424
|
}
|
|
@@ -395,9 +432,10 @@ export function withOwnership(docs, owner, componentName, coreDir) {
|
|
|
395
432
|
*
|
|
396
433
|
* @param {OwnershipSubject} owner
|
|
397
434
|
* @param {string} componentName
|
|
435
|
+
* @param {string|null} [authoredImport]
|
|
398
436
|
* @returns {string}
|
|
399
437
|
*/
|
|
400
|
-
function resolveIntegrationImportPath(owner, componentName) {
|
|
438
|
+
function resolveIntegrationImportPath(owner, componentName, authoredImport) {
|
|
401
439
|
return resolveIntegrationImport(
|
|
402
440
|
{
|
|
403
441
|
exportsMap: owner.integration?.__packageExports,
|
|
@@ -406,6 +444,7 @@ function resolveIntegrationImportPath(owner, componentName) {
|
|
|
406
444
|
packageName: owner.package,
|
|
407
445
|
},
|
|
408
446
|
componentName,
|
|
447
|
+
authoredImport,
|
|
409
448
|
);
|
|
410
449
|
}
|
|
411
450
|
|
|
@@ -421,10 +460,12 @@ function resolveIntegrationImportPath(owner, componentName) {
|
|
|
421
460
|
*/
|
|
422
461
|
export function scopeSubComponent(docs, dirName, coreDir) {
|
|
423
462
|
const requestedXDS = `XDS${dirName}`;
|
|
424
|
-
const isParentDoc =
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
463
|
+
const isParentDoc =
|
|
464
|
+
docs.name && docs.name.toLowerCase() !== dirName.toLowerCase();
|
|
465
|
+
const matchingComponent =
|
|
466
|
+
isParentDoc && docs.components
|
|
467
|
+
? docs.components.find(c => c.name === requestedXDS || c.name === dirName)
|
|
468
|
+
: null;
|
|
428
469
|
|
|
429
470
|
if (!matchingComponent) return null;
|
|
430
471
|
|
|
@@ -108,7 +108,7 @@ export const doc = {
|
|
|
108
108
|
{
|
|
109
109
|
type: 'component.list',
|
|
110
110
|
description:
|
|
111
|
-
"The catalog grouped by category. data.detail is the level ('names' | 'compact' | 'full') and data.components is the grouped map: names
|
|
111
|
+
"The catalog grouped by category. data.detail is the level ('names' | 'compact' | 'full') and data.components is the grouped map: names entries with name, package, and an optional canonical import for integrations; brief entries; or full ComponentDoc entries.",
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
type: 'component.detail',
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* The list view emits ONE `component.list` type across all three detail levels;
|
|
8
8
|
* the depth is carried in `data.detail` and `data.components` holds the grouped
|
|
9
9
|
* map whose entry shape depends on that level:
|
|
10
|
-
* - 'names' -> ComponentListEntry[] (name + owner package)
|
|
10
|
+
* - 'names' -> ComponentListEntry[] (name + owner package + optional import)
|
|
11
11
|
* - 'compact' -> ComponentBriefEntry[] (name + 1-line description + import)
|
|
12
12
|
* - 'full' -> ComponentDoc[] (full authored doc per entry)
|
|
13
13
|
*/
|
|
@@ -31,7 +31,9 @@ export type ComponentListData = ({
|
|
|
31
31
|
/**
|
|
32
32
|
* A single entry in a `component.list` group at `detail: 'names'`. Pre-1.0 the
|
|
33
33
|
* list moved from bare strings to package-qualified objects so consumers can
|
|
34
|
-
* disambiguate ownership (core vs. an integration package).
|
|
34
|
+
* disambiguate ownership (core vs. an integration package). Integration entries
|
|
35
|
+
* carry `import` — the package-authored specifier; core entries omit it (the
|
|
36
|
+
* specifier is derived from the component name by the renderer).
|
|
35
37
|
*/
|
|
36
38
|
export type ComponentListEntry = {
|
|
37
39
|
name: string;
|
|
@@ -39,6 +41,10 @@ export type ComponentListEntry = {
|
|
|
39
41
|
* - Owner package, e.g. '@astryxdesign/core' or '@acme/astryx-meta'.
|
|
40
42
|
*/
|
|
41
43
|
package: string;
|
|
44
|
+
/**
|
|
45
|
+
* - Import specifier; present for integration components, absent for core.
|
|
46
|
+
*/
|
|
47
|
+
import?: string | undefined;
|
|
42
48
|
};
|
|
43
49
|
/**
|
|
44
50
|
* A single entry in a `component.list` group at `detail: 'compact'`.
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* The list view emits ONE `component.list` type across all three detail levels;
|
|
33
33
|
* the depth is carried in `data.detail` and `data.components` holds the grouped
|
|
34
34
|
* map whose entry shape depends on that level:
|
|
35
|
-
* - 'names' -> ComponentListEntry[] (name + owner package)
|
|
35
|
+
* - 'names' -> ComponentListEntry[] (name + owner package + optional import)
|
|
36
36
|
* - 'compact' -> ComponentBriefEntry[] (name + 1-line description + import)
|
|
37
37
|
* - 'full' -> ComponentDoc[] (full authored doc per entry)
|
|
38
38
|
* @typedef {object} ComponentListResponse
|
|
@@ -52,10 +52,13 @@
|
|
|
52
52
|
/**
|
|
53
53
|
* A single entry in a `component.list` group at `detail: 'names'`. Pre-1.0 the
|
|
54
54
|
* list moved from bare strings to package-qualified objects so consumers can
|
|
55
|
-
* disambiguate ownership (core vs. an integration package).
|
|
55
|
+
* disambiguate ownership (core vs. an integration package). Integration entries
|
|
56
|
+
* carry `import` — the package-authored specifier; core entries omit it (the
|
|
57
|
+
* specifier is derived from the component name by the renderer).
|
|
56
58
|
* @typedef {object} ComponentListEntry
|
|
57
59
|
* @property {string} name
|
|
58
60
|
* @property {string} package - Owner package, e.g. '@astryxdesign/core' or '@acme/astryx-meta'.
|
|
61
|
+
* @property {string} [import] - Import specifier; present for integration components, absent for core.
|
|
59
62
|
*/
|
|
60
63
|
|
|
61
64
|
/**
|
|
@@ -106,7 +106,10 @@ function searchImportFor(result, name) {
|
|
|
106
106
|
async function bothSurfaces() {
|
|
107
107
|
const detail = await component('AcmeCarousel', {cwd: tmpDir});
|
|
108
108
|
const found = await search('carousel', {cwd: tmpDir});
|
|
109
|
-
return {
|
|
109
|
+
return {
|
|
110
|
+
detail: detail.data.import,
|
|
111
|
+
found: searchImportFor(found, 'AcmeCarousel'),
|
|
112
|
+
};
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
const SUBPATH_EXPORTS = {
|
|
@@ -115,7 +118,9 @@ const SUBPATH_EXPORTS = {
|
|
|
115
118
|
};
|
|
116
119
|
|
|
117
120
|
beforeEach(() => {
|
|
118
|
-
tmpDir = fs.mkdtempSync(
|
|
121
|
+
tmpDir = fs.mkdtempSync(
|
|
122
|
+
path.join(process.cwd(), '.astryx-import-agreement-test-'),
|
|
123
|
+
);
|
|
119
124
|
});
|
|
120
125
|
|
|
121
126
|
afterEach(() => {
|
|
@@ -224,7 +229,9 @@ describe('integration component import specifiers', () => {
|
|
|
224
229
|
'a prefixed wildcard only matches the subpaths it covers',
|
|
225
230
|
async () => {
|
|
226
231
|
// `./components/*` does not cover `./Carousel`, so this falls back.
|
|
227
|
-
scaffold({
|
|
232
|
+
scaffold({
|
|
233
|
+
exports: {'.': './src/index.js', './components/*': './src/*/index.js'},
|
|
234
|
+
});
|
|
228
235
|
const {detail, found} = await bothSurfaces();
|
|
229
236
|
|
|
230
237
|
expect(detail).toBe('@acme/widgets');
|
|
@@ -278,7 +285,10 @@ describe('integration component import specifiers', () => {
|
|
|
278
285
|
scaffold({
|
|
279
286
|
exports: {
|
|
280
287
|
'.': './src/index.js',
|
|
281
|
-
'./Carousel': {
|
|
288
|
+
'./Carousel': {
|
|
289
|
+
import: './src/Carousel/index.js',
|
|
290
|
+
require: './cjs/Carousel.js',
|
|
291
|
+
},
|
|
282
292
|
},
|
|
283
293
|
});
|
|
284
294
|
const {detail, found} = await bothSurfaces();
|
|
@@ -298,7 +308,12 @@ describe('integration component import specifiers', () => {
|
|
|
298
308
|
// loader looked and there was none.
|
|
299
309
|
scaffold({exports: SUBPATH_EXPORTS});
|
|
300
310
|
const pkgDir = path.join(tmpDir, 'node_modules', '@acme', 'widgets');
|
|
301
|
-
const docPath = path.join(
|
|
311
|
+
const docPath = path.join(
|
|
312
|
+
pkgDir,
|
|
313
|
+
'src',
|
|
314
|
+
'Carousel',
|
|
315
|
+
'AcmeCarousel.doc.mjs',
|
|
316
|
+
);
|
|
302
317
|
|
|
303
318
|
expect(
|
|
304
319
|
resolveIntegrationImportPath(
|
|
@@ -310,9 +325,150 @@ describe('integration component import specifiers', () => {
|
|
|
310
325
|
// A parsed `null` is an answer, not a gap: it must not fall back to a read.
|
|
311
326
|
expect(
|
|
312
327
|
resolveIntegrationImportPath(
|
|
313
|
-
{
|
|
328
|
+
{
|
|
329
|
+
exportsMap: null,
|
|
330
|
+
packageDir: pkgDir,
|
|
331
|
+
docPath,
|
|
332
|
+
packageName: '@acme/widgets',
|
|
333
|
+
},
|
|
314
334
|
'AcmeCarousel',
|
|
315
335
|
),
|
|
316
336
|
).toBe('@acme/widgets');
|
|
317
337
|
});
|
|
318
338
|
});
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Scaffold a default-export component doc (the shape `integration add component`
|
|
342
|
+
* generates). This is a separate function because the existing scaffold writes
|
|
343
|
+
* a named `export const docs`, and we need to test both.
|
|
344
|
+
*/
|
|
345
|
+
function scaffoldDefaultExport({exports: exportsMap, docImport} = {}) {
|
|
346
|
+
fs.writeFileSync(
|
|
347
|
+
path.join(tmpDir, 'package.json'),
|
|
348
|
+
JSON.stringify({name: 'consumer', version: '1.0.0'}),
|
|
349
|
+
);
|
|
350
|
+
fs.writeFileSync(
|
|
351
|
+
path.join(tmpDir, 'astryx.config.mjs'),
|
|
352
|
+
"export default {integrations: ['@acme/widgets']};\n",
|
|
353
|
+
);
|
|
354
|
+
|
|
355
|
+
const pkgDir = path.join(tmpDir, 'node_modules', '@acme', 'widgets');
|
|
356
|
+
const componentDir = path.join(pkgDir, 'src', 'Carousel');
|
|
357
|
+
fs.mkdirSync(componentDir, {recursive: true});
|
|
358
|
+
|
|
359
|
+
fs.writeFileSync(
|
|
360
|
+
path.join(pkgDir, 'package.json'),
|
|
361
|
+
JSON.stringify({
|
|
362
|
+
name: '@acme/widgets',
|
|
363
|
+
version: '1.0.0',
|
|
364
|
+
...(exportsMap ? {exports: exportsMap} : {}),
|
|
365
|
+
}),
|
|
366
|
+
);
|
|
367
|
+
fs.writeFileSync(
|
|
368
|
+
path.join(pkgDir, 'astryx.integration.mjs'),
|
|
369
|
+
"export default {components: './src'};\n",
|
|
370
|
+
);
|
|
371
|
+
fs.writeFileSync(
|
|
372
|
+
path.join(componentDir, 'AcmeCarousel.tsx'),
|
|
373
|
+
'export const AcmeCarousel = () => null;\n',
|
|
374
|
+
);
|
|
375
|
+
// Default export — the shape integration add component writes
|
|
376
|
+
fs.writeFileSync(
|
|
377
|
+
path.join(componentDir, 'AcmeCarousel.doc.mjs'),
|
|
378
|
+
`export default ${JSON.stringify(
|
|
379
|
+
{
|
|
380
|
+
type: 'component',
|
|
381
|
+
name: 'AcmeCarousel',
|
|
382
|
+
displayName: 'Acme Carousel',
|
|
383
|
+
keywords: ['carousel', 'slides'],
|
|
384
|
+
usage: {description: 'A carousel that cycles through slides.'},
|
|
385
|
+
props: [],
|
|
386
|
+
...(docImport ? {import: docImport} : {}),
|
|
387
|
+
},
|
|
388
|
+
null,
|
|
389
|
+
2,
|
|
390
|
+
)};\n`,
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
describe('default-export component doc agreement', () => {
|
|
395
|
+
it(
|
|
396
|
+
'component detail loads a default-export doc without crashing',
|
|
397
|
+
async () => {
|
|
398
|
+
scaffoldDefaultExport({exports: SUBPATH_EXPORTS});
|
|
399
|
+
const result = await component('AcmeCarousel', {cwd: tmpDir});
|
|
400
|
+
expect(result.type).toBe('component.detail');
|
|
401
|
+
expect(result.data.name).toBe('AcmeCarousel');
|
|
402
|
+
expect(result.data.import).toBe('@acme/widgets/Carousel');
|
|
403
|
+
expect(result.data.package).toBe('@acme/widgets');
|
|
404
|
+
},
|
|
405
|
+
SLOW,
|
|
406
|
+
);
|
|
407
|
+
|
|
408
|
+
it(
|
|
409
|
+
'a doc-authored import in a default export wins over the resolved subpath',
|
|
410
|
+
async () => {
|
|
411
|
+
scaffoldDefaultExport({
|
|
412
|
+
exports: SUBPATH_EXPORTS,
|
|
413
|
+
docImport: '@acme/widgets/Alias',
|
|
414
|
+
});
|
|
415
|
+
const result = await component('AcmeCarousel', {cwd: tmpDir});
|
|
416
|
+
expect(result.data.import).toBe('@acme/widgets/Alias');
|
|
417
|
+
},
|
|
418
|
+
SLOW,
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
it(
|
|
422
|
+
'search finds a default-export component with the correct import',
|
|
423
|
+
async () => {
|
|
424
|
+
scaffoldDefaultExport({exports: SUBPATH_EXPORTS});
|
|
425
|
+
const found = await search('carousel', {cwd: tmpDir});
|
|
426
|
+
const hit = searchImportFor(found, 'AcmeCarousel');
|
|
427
|
+
expect(hit).toBe('@acme/widgets/Carousel');
|
|
428
|
+
},
|
|
429
|
+
SLOW,
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
it(
|
|
433
|
+
'component and search agree on a default-export component',
|
|
434
|
+
async () => {
|
|
435
|
+
scaffoldDefaultExport({exports: SUBPATH_EXPORTS});
|
|
436
|
+
const {detail, found} = await bothSurfaces();
|
|
437
|
+
expect(detail).toBe('@acme/widgets/Carousel');
|
|
438
|
+
expect(found).toBe(detail);
|
|
439
|
+
},
|
|
440
|
+
SLOW,
|
|
441
|
+
);
|
|
442
|
+
|
|
443
|
+
it(
|
|
444
|
+
'list includes the integration import for a default-export component',
|
|
445
|
+
async () => {
|
|
446
|
+
scaffoldDefaultExport({exports: SUBPATH_EXPORTS});
|
|
447
|
+
const result = await component(undefined, {cwd: tmpDir, list: true});
|
|
448
|
+
expect(result.type).toBe('component.list');
|
|
449
|
+
const allEntries = Object.values(result.data.components).flat();
|
|
450
|
+
const entry = allEntries.find(e => e.name === 'AcmeCarousel');
|
|
451
|
+
expect(entry).toBeDefined();
|
|
452
|
+
expect(entry.package).toBe('@acme/widgets');
|
|
453
|
+
// The import must be the integration subpath, not a core path.
|
|
454
|
+
expect(/** @type {any} */ (entry).import).toBe('@acme/widgets/Carousel');
|
|
455
|
+
},
|
|
456
|
+
SLOW,
|
|
457
|
+
);
|
|
458
|
+
|
|
459
|
+
it(
|
|
460
|
+
'list honors a default-export component doc import alias',
|
|
461
|
+
async () => {
|
|
462
|
+
scaffoldDefaultExport({
|
|
463
|
+
exports: SUBPATH_EXPORTS,
|
|
464
|
+
docImport: '@acme/widgets/Alias',
|
|
465
|
+
});
|
|
466
|
+
const result = await component(undefined, {cwd: tmpDir, list: true});
|
|
467
|
+
expect(result.type).toBe('component.list');
|
|
468
|
+
const allEntries = Object.values(result.data.components).flat();
|
|
469
|
+
const entry = allEntries.find(e => e.name === 'AcmeCarousel');
|
|
470
|
+
expect(/** @type {any} */ (entry).import).toBe('@acme/widgets/Alias');
|
|
471
|
+
},
|
|
472
|
+
SLOW,
|
|
473
|
+
);
|
|
474
|
+
});
|