@astryxdesign/cli 0.6.5-canary.84fdbd1 → 0.6.5-canary.8a5b3fb

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.
Files changed (81) hide show
  1. package/README.md +21 -21
  2. package/api/build/_adapter.d.mts +5 -0
  3. package/api/build/_adapter.mjs +2 -0
  4. package/api/build/build.type.d.mts +8 -0
  5. package/api/build/build.type.mjs +2 -0
  6. package/api/build/kit/kit.mjs +1 -0
  7. package/api/component/component.mjs +17 -15
  8. package/api/component/component.type.d.mts +33 -3
  9. package/api/component/component.type.mjs +10 -3
  10. package/api/component/detail/blocks/blocks.d.mts +2 -1
  11. package/api/component/detail/blocks/blocks.mjs +5 -2
  12. package/api/component/detail/detail.mjs +5 -1
  13. package/api/component/detail/props/props.d.mts +2 -1
  14. package/api/component/detail/props/props.mjs +3 -2
  15. package/api/component/detail/showcase/showcase.d.mts +3 -1
  16. package/api/component/detail/showcase/showcase.mjs +3 -1
  17. package/api/component/detail/source/source.d.mts +3 -2
  18. package/api/component/detail/source/source.mjs +7 -3
  19. package/api/component/list/list.mjs +18 -6
  20. package/api/docs/_adapter.d.mts +11 -0
  21. package/api/docs/_adapter.mjs +25 -0
  22. package/api/docs/detail/detail.mjs +19 -3
  23. package/api/docs/detail/section/section.mjs +7 -1
  24. package/api/docs/docs.depth.test.mjs +2 -0
  25. package/api/docs/docs.mjs +2 -0
  26. package/api/docs/docs.type.d.mts +43 -3
  27. package/api/docs/docs.type.mjs +23 -3
  28. package/api/docs/index/index.mjs +11 -2
  29. package/api/docs/index/index.test.mjs +2 -1
  30. package/api/docs/node/node.mjs +3 -0
  31. package/api/hook/_adapter.d.mts +1 -0
  32. package/api/hook/_adapter.mjs +3 -0
  33. package/api/hook/detail/detail.mjs +2 -2
  34. package/api/hook/detail/params/params.mjs +2 -2
  35. package/api/hook/hook.type.d.mts +12 -0
  36. package/api/hook/hook.type.mjs +3 -0
  37. package/api/hook/list/list.mjs +8 -8
  38. package/api/search/search.d.mts +3 -3
  39. package/api/search/search.mjs +9 -5
  40. package/api/search/search.type.d.mts +2 -2
  41. package/api/search/search.type.mjs +1 -1
  42. package/api/swizzle/_adapter.d.mts +1 -0
  43. package/api/swizzle/_adapter.mjs +3 -0
  44. package/api/swizzle/copy/copy.mjs +1 -1
  45. package/api/swizzle/list/list.mjs +2 -2
  46. package/api/swizzle/swizzle.type.d.mts +8 -0
  47. package/api/swizzle/swizzle.type.mjs +2 -0
  48. package/api/template/copy/copy.mjs +2 -1
  49. package/api/template/show/show.mjs +2 -0
  50. package/api/template/skeleton/skeleton.mjs +2 -1
  51. package/api/template/template.d.mts +1 -1
  52. package/api/template/template.mjs +1 -0
  53. package/api/template/template.type.d.mts +12 -0
  54. package/api/template/template.type.mjs +3 -0
  55. package/api/upgrade/_adapter.d.mts +1 -0
  56. package/api/upgrade/_adapter.mjs +3 -0
  57. package/api/upgrade/list/list.mjs +9 -3
  58. package/api/upgrade/upgrade.type.d.mts +4 -0
  59. package/api/upgrade/upgrade.type.mjs +1 -0
  60. package/clients/cli/commands/build.mjs +7 -6
  61. package/clients/cli/commands/build.text-fields.test.mjs +1 -1
  62. package/clients/cli/commands/component/index.mjs +34 -6
  63. package/clients/cli/commands/docs.mjs +63 -23
  64. package/clients/cli/commands/hook/index.mjs +7 -2
  65. package/clients/cli/commands/swizzle.mjs +2 -1
  66. package/clients/cli/commands/template.mjs +8 -4
  67. package/clients/cli/commands/text-json-parity.test.mjs +22 -0
  68. package/clients/cli/commands/upgrade.mjs +1 -1
  69. package/clients/cli/index.mjs +1 -1
  70. package/foundation/discovery/docs-output-budget.d.mts +6 -2
  71. package/foundation/discovery/docs-output-budget.mjs +2 -1
  72. package/foundation/discovery/docs-section-key.d.mts +4 -2
  73. package/foundation/discovery/docs-section-key.mjs +1 -1
  74. package/foundation/doc-compiler/lenses.d.mts +4 -2
  75. package/foundation/doc-compiler/lenses.mjs +1 -1
  76. package/foundation/response/base.d.ts +9 -3
  77. package/foundation/response/json.d.mts +7 -4
  78. package/foundation/response/json.mjs +10 -6
  79. package/foundation/response/response-types.doc.mjs +25 -20
  80. package/foundation/response/response.doc.mjs +17 -3
  81. package/package.json +9 -9
@@ -9,7 +9,7 @@
9
9
  * identical to the flat command's list branch.
10
10
  *
11
11
  * @input { cwd, category?, detail, zh, lang }
12
- * @output HookListResponse ({ type: 'hook.list', data: { detail, components } })
12
+ * @output HookListResponse ({ type: 'hook.list', package: CORE_PACKAGE, data: { detail, components } })
13
13
  * @position api/hook/list/list.mjs — dispatched from ../hook.mjs
14
14
  */
15
15
 
@@ -20,7 +20,7 @@ import {
20
20
  import {loadDocs} from '../../../foundation/discovery/component-loader.mjs';
21
21
  import {AstryxError} from '../../error.mjs';
22
22
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
23
- import {resolveCoreDir} from '../_adapter.mjs';
23
+ import {CORE_PACKAGE, resolveCoreDir} from '../_adapter.mjs';
24
24
 
25
25
  /**
26
26
  * @param {object} [options]
@@ -82,7 +82,7 @@ export async function list({
82
82
  }
83
83
  }
84
84
  return {
85
- type: 'hook.list',
85
+ type: 'hook.list', package: CORE_PACKAGE,
86
86
  data: {detail: 'compact', components: {[match[0]]: entries}},
87
87
  };
88
88
  }
@@ -111,14 +111,14 @@ export async function list({
111
111
  }
112
112
  }
113
113
  return {
114
- type: 'hook.list',
114
+ type: 'hook.list', package: CORE_PACKAGE,
115
115
  data: {detail: 'full', components: {[match[0]]: entries}},
116
116
  };
117
117
  }
118
118
 
119
119
  // Default: names only
120
120
  return {
121
- type: 'hook.list',
121
+ type: 'hook.list', package: CORE_PACKAGE,
122
122
  data: {detail: 'names', components: {[match[0]]: match[1]}},
123
123
  };
124
124
  }
@@ -155,7 +155,7 @@ export async function list({
155
155
  }
156
156
  }
157
157
  }
158
- return {type: 'hook.list', data: {detail: 'compact', components: result}};
158
+ return {type: 'hook.list', package: CORE_PACKAGE, data: {detail: 'compact', components: result}};
159
159
  }
160
160
 
161
161
  if (detail === 'full') {
@@ -186,9 +186,9 @@ export async function list({
186
186
  }
187
187
  }
188
188
  }
189
- return {type: 'hook.list', data: {detail: 'full', components: result}};
189
+ return {type: 'hook.list', package: CORE_PACKAGE, data: {detail: 'full', components: result}};
190
190
  }
191
191
 
192
192
  // Default: names only
193
- return {type: 'hook.list', data: {detail: 'names', components: hooks}};
193
+ return {type: 'hook.list', package: CORE_PACKAGE, data: {detail: 'names', components: hooks}};
194
194
  }
@@ -199,9 +199,9 @@ export type Candidate = {
199
199
  */
200
200
  _parent?: string | undefined;
201
201
  /**
202
- * - The npm package that authored a docs-tree
203
- * doc part. Flat topics carry none: an extension's sections can come from
204
- * another package.
202
+ * - The npm package that owns the candidate:
203
+ * Core's package for its components, hooks, and templates, the integration's
204
+ * for what it contributed, and for a doc part the package that wrote it.
205
205
  */
206
206
  _package?: string | undefined;
207
207
  _displayName?: string | undefined;
@@ -80,6 +80,7 @@ import {
80
80
  findComponentReadme,
81
81
  resolveImportPath,
82
82
  resolveIntegrationImportPath,
83
+ CORE_PACKAGE,
83
84
  } from '../../foundation/discovery/component-discovery.mjs';
84
85
  import {
85
86
  discoverHooks,
@@ -130,9 +131,9 @@ import {setResultCoverage} from './coverage.mjs';
130
131
  * @property {string} [_command] - The command that reads exactly this doc part.
131
132
  * @property {string} [_parent] - The command that opens the level above a doc
132
133
  * part: its topic's section list, or the docs-tree namespace it sits in.
133
- * @property {string} [_package] - The npm package that authored a docs-tree
134
- * doc part. Flat topics carry none: an extension's sections can come from
135
- * another package.
134
+ * @property {string} [_package] - The npm package that owns the candidate:
135
+ * Core's package for its components, hooks, and templates, the integration's
136
+ * for what it contributed, and for a doc part the package that wrote it.
136
137
  * @property {string} [_displayName]
137
138
  * @property {'page'|'block'} [_kind]
138
139
  * @property {string} [_resultName]
@@ -967,6 +968,7 @@ async function gatherCoreComponents(coreDir) {
967
968
  keywords,
968
969
  description,
969
970
  guidance,
971
+ _package: CORE_PACKAGE,
970
972
  _import: resolveImportPath(coreDir, comp),
971
973
  });
972
974
  }
@@ -997,6 +999,7 @@ async function gatherIntegrationComponents(cwd) {
997
999
  keywords: doc && Array.isArray(doc.keywords) ? doc.keywords : [],
998
1000
  description: doc ? doc.usage?.description || doc.description || '' : '',
999
1001
  guidance: guidanceFrom(doc),
1002
+ _package: rec.package ?? integration.name,
1000
1003
  // Exactly what `component` reports: a doc may state its own specifier
1001
1004
  // (one entry point exporting several components), and only when it
1002
1005
  // does not do we resolve the subpath against the owning package's
@@ -1123,6 +1126,7 @@ async function gatherHooks(coreDir) {
1123
1126
  name: hookName,
1124
1127
  keywords,
1125
1128
  description,
1129
+ _package: CORE_PACKAGE,
1126
1130
  _import: importPath,
1127
1131
  });
1128
1132
  }
@@ -1484,6 +1488,7 @@ async function gatherTemplates(cwd) {
1484
1488
  // short idea is not a direct match.
1485
1489
  prose: t.keywords ?? [],
1486
1490
  _displayName: t.name,
1491
+ _package: t.package ?? CORE_PACKAGE,
1487
1492
  _kind: t.type, // 'page' | 'block'
1488
1493
  _resultName: t.dirName,
1489
1494
  _commandName: commandName,
@@ -1536,6 +1541,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
1536
1541
  const base = {
1537
1542
  domain: c.domain,
1538
1543
  name: c._resultName ?? c.name,
1544
+ package: c._package,
1539
1545
  score,
1540
1546
  reason,
1541
1547
  description: c.description || '',
@@ -1566,7 +1572,6 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
1566
1572
  title: c._title,
1567
1573
  command: c._command ?? `astryx docs ${c.name}`,
1568
1574
  ...(c._parent ? {parent: c._parent} : {}),
1569
- ...(c._package ? {package: c._package} : {}),
1570
1575
  };
1571
1576
  break;
1572
1577
  case 'template':
@@ -1582,7 +1587,6 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
1582
1587
  ...base,
1583
1588
  displayName: c._displayName,
1584
1589
  command: `astryx theme add ${c.name}`,
1585
- ...(c._package ? {package: c._package} : {}),
1586
1590
  };
1587
1591
  break;
1588
1592
  default:
@@ -46,9 +46,9 @@ export type SearchResultEntry = {
46
46
  */
47
47
  section?: string | undefined;
48
48
  /**
49
- * - The npm package that authored a doc result (for a section, the package whose file the section came from), or that ships a theme result.
49
+ * - The npm package that owns the result: `@astryxdesign/core` for a Core component, hook, or template, `@astryxdesign/cli` for a doc the CLI ships, or the integration package that contributed it. For a doc section, the package whose file the section came from.
50
50
  */
51
- package?: string | undefined;
51
+ package: string;
52
52
  /**
53
53
  * - Command that opens the level above a doc result — its topic's section list for a section, the docs-tree namespace it sits in for a tree node — so a reader can see the siblings and open another.
54
54
  */
@@ -24,7 +24,7 @@
24
24
  * @property {string} [import] - Import path — present for component and hook results.
25
25
  * @property {string} [title] - Doc title — present for doc results.
26
26
  * @property {string} [section] - Section key — present when a doc result is one section of a topic; `command` reads only that section.
27
- * @property {string} [package] - The npm package that authored a doc result (for a section, the package whose file the section came from), or that ships a theme result.
27
+ * @property {string} package - The npm package that owns the result: `@astryxdesign/core` for a Core component, hook, or template, `@astryxdesign/cli` for a doc the CLI ships, or the integration package that contributed it. For a doc section, the package whose file the section came from.
28
28
  * @property {string} [parent] - Command that opens the level above a doc result — its topic's section list for a section, the docs-tree namespace it sits in for a tree node — so a reader can see the siblings and open another.
29
29
  * @property {string} [displayName] - Friendly display name — present for template and theme results.
30
30
  * @property {'page' | 'block'} [kind] - Template kind (`page` | `block`) — present for template results.
@@ -10,3 +10,4 @@ export function resolveCore(cwd: string): {
10
10
  coreDir: string;
11
11
  components: string[];
12
12
  };
13
+ export { CORE_PROVIDER_ID as CORE_PACKAGE } from "../../foundation/identity/providers.mjs";
@@ -15,6 +15,9 @@ import {findCoreDir, listComponents} from '../../foundation/fs/paths.mjs';
15
15
  import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
16
16
  import {AstryxError} from '../error.mjs';
17
17
 
18
+ /** The package that owns Core's components, hooks, and codemods. */
19
+ export {CORE_PROVIDER_ID as CORE_PACKAGE} from '../../foundation/identity/providers.mjs';
20
+
18
21
  /**
19
22
  * Locate @astryxdesign/core for `cwd` and list its swizzlable components.
20
23
  * @param {string} cwd
@@ -359,7 +359,7 @@ export async function swizzleCopy(component, options = {}) {
359
359
  usesStyleX,
360
360
  };
361
361
  if (feedback) data.feedback = feedback;
362
- return {type: 'swizzle.copy', data};
362
+ return {type: 'swizzle.copy', package: data.package, data};
363
363
  }
364
364
 
365
365
  /**
@@ -8,7 +8,7 @@
8
8
  * shared seam. All human prose / usage hints live in the CLI renderer.
9
9
  */
10
10
 
11
- import {resolveCore} from '../_adapter.mjs';
11
+ import {CORE_PACKAGE, resolveCore} from '../_adapter.mjs';
12
12
 
13
13
  /**
14
14
  * List swizzlable components discoverable from `cwd`'s @astryxdesign/core.
@@ -17,5 +17,5 @@ import {resolveCore} from '../_adapter.mjs';
17
17
  */
18
18
  export function swizzleList(cwd = process.cwd()) {
19
19
  const {components} = resolveCore(cwd);
20
- return {type: 'swizzle.list', data: components};
20
+ return {type: 'swizzle.list', package: CORE_PACKAGE, data: components};
21
21
  }
@@ -6,6 +6,10 @@
6
6
  */
7
7
  export type SwizzleListResponse = {
8
8
  type: "swizzle.list";
9
+ /**
10
+ * `@astryxdesign/core`, the package the listed components come from.
11
+ */
12
+ package: string;
9
13
  data: string[];
10
14
  };
11
15
  /**
@@ -26,6 +30,10 @@ export type SwizzleFeedback = {
26
30
  */
27
31
  export type SwizzleCopyResponse = {
28
32
  type: "swizzle.copy";
33
+ /**
34
+ * Owner package the component source was copied from (as `data.package`).
35
+ */
36
+ package: string;
29
37
  data: {
30
38
  component: string;
31
39
  package: string;
@@ -11,6 +11,7 @@
11
11
  *
12
12
  * @typedef {object} SwizzleListResponse
13
13
  * @property {'swizzle.list'} type
14
+ * @property {string} package `@astryxdesign/core`, the package the listed components come from.
14
15
  * @property {string[]} data
15
16
  */
16
17
 
@@ -27,6 +28,7 @@
27
28
  *
28
29
  * @typedef {object} SwizzleCopyResponse
29
30
  * @property {'swizzle.copy'} type
31
+ * @property {string} package Owner package the component source was copied from (as `data.package`).
30
32
  * @property {object} data
31
33
  * @property {string} data.component
32
34
  * @property {string} data.package Owner package the component source was copied from.
@@ -18,7 +18,7 @@ import {
18
18
  } from '../../../foundation/fs/path-safety.mjs';
19
19
  import {AstryxError, writeFailed} from '../../error.mjs';
20
20
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
21
- import {replaceDemoMedia} from '../../../foundation/discovery/template-adapter.mjs';
21
+ import {pkgOf, replaceDemoMedia} from '../../../foundation/discovery/template-adapter.mjs';
22
22
 
23
23
  /**
24
24
  * Scaffold an already-resolved template to `targetPath` (relative to `cwd`) and
@@ -96,6 +96,7 @@ export function templateCopy(match, {targetPath, cwd, overwrite = false}) {
96
96
  const relOutput = path.relative(cwd, outputDir) || '.';
97
97
  return {
98
98
  type: 'template.copy',
99
+ package: pkgOf(match),
99
100
  data: {
100
101
  template: match.dirName,
101
102
  outputDir: relOutput,
@@ -13,6 +13,7 @@ import {AstryxError} from '../../error.mjs';
13
13
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
14
14
  import {
15
15
  extractComponents,
16
+ pkgOf,
16
17
  replaceDemoMedia,
17
18
  } from '../../../foundation/discovery/template-adapter.mjs';
18
19
 
@@ -39,6 +40,7 @@ export function templateShow(match) {
39
40
 
40
41
  return {
41
42
  type: 'template.show',
43
+ package: pkgOf(match),
42
44
  data: {
43
45
  template: match.dirName,
44
46
  description: match.description,
@@ -11,7 +11,7 @@
11
11
  import * as fs from 'node:fs';
12
12
  import {AstryxError} from '../../error.mjs';
13
13
  import {ERROR_CODES} from '../../../foundation/response/error-codes.mjs';
14
- import {extractComponents} from '../../../foundation/discovery/template-adapter.mjs';
14
+ import {extractComponents, pkgOf} from '../../../foundation/discovery/template-adapter.mjs';
15
15
 
16
16
  const STRUCTURAL = new Set([
17
17
  'AppShell',
@@ -245,6 +245,7 @@ export function templateSkeleton(match, templates) {
245
245
  const src = fs.readFileSync(match.filePath, 'utf-8');
246
246
  return {
247
247
  type: 'template.skeleton',
248
+ package: pkgOf(match),
248
249
  data: {
249
250
  template: match.dirName,
250
251
  description: match.description,
@@ -41,4 +41,4 @@ export function template(name?: string, options?: {
41
41
  export type DiscoveredTemplate = import("../../foundation/discovery/template-adapter.mjs").DiscoveredTemplate;
42
42
  export type TemplateDiscoveryError = import("../../foundation/discovery/template-adapter.mjs").TemplateDiscoveryError;
43
43
  export type TemplateDocModule = import("../../foundation/discovery/template-adapter.mjs").TemplateDocModule;
44
- export { discoverAll, discoverAll as discoverTemplates, discoverAllWithErrors, discoverCoreTemplates, discoverIntegrationTemplatesForOne, stripTemplateAssetRefs, replaceDemoMedia, listTemplates, findRelatedBlocks, findShowcase, extractComponents } from "../../foundation/discovery/template-adapter.mjs";
44
+ export { discoverAll, discoverAll as discoverTemplates, discoverAllWithErrors, discoverCoreTemplates, discoverIntegrationTemplatesForOne, stripTemplateAssetRefs, replaceDemoMedia, listTemplates, findRelatedBlocks, findShowcase, extractComponents, pkgOf } from "../../foundation/discovery/template-adapter.mjs";
@@ -46,6 +46,7 @@ export {
46
46
  findRelatedBlocks,
47
47
  findShowcase,
48
48
  extractComponents,
49
+ pkgOf,
49
50
  } from '../../foundation/discovery/template-adapter.mjs';
50
51
 
51
52
  /**
@@ -61,6 +61,10 @@ export type TemplateListEntry = {
61
61
  */
62
62
  export type TemplateShowResponse = {
63
63
  type: "template.show";
64
+ /**
65
+ * The npm package that owns the template.
66
+ */
67
+ package: string;
64
68
  data: {
65
69
  template: string;
66
70
  description: string;
@@ -75,6 +79,10 @@ export type TemplateShowResponse = {
75
79
  */
76
80
  export type TemplateSkeletonResponse = {
77
81
  type: "template.skeleton";
82
+ /**
83
+ * The npm package that owns the template.
84
+ */
85
+ package: string;
78
86
  data: {
79
87
  template: string;
80
88
  description: string;
@@ -87,6 +95,10 @@ export type TemplateSkeletonResponse = {
87
95
  */
88
96
  export type TemplateCopyResponse = {
89
97
  type: "template.copy";
98
+ /**
99
+ * The npm package that owns the template.
100
+ */
101
+ package: string;
90
102
  data: {
91
103
  template: string;
92
104
  outputDir: string;
@@ -47,6 +47,7 @@
47
47
  * astryx --json template <name>
48
48
  * @typedef {object} TemplateShowResponse
49
49
  * @property {'template.show'} type
50
+ * @property {string} package The npm package that owns the template.
50
51
  * @property {object} data
51
52
  * @property {string} data.template
52
53
  * @property {string} data.description
@@ -60,6 +61,7 @@
60
61
  * astryx --json template <name> --skeleton
61
62
  * @typedef {object} TemplateSkeletonResponse
62
63
  * @property {'template.skeleton'} type
64
+ * @property {string} package The npm package that owns the template.
63
65
  * @property {object} data
64
66
  * @property {string} data.template
65
67
  * @property {string} data.description
@@ -71,6 +73,7 @@
71
73
  * astryx --json template <name> [path]
72
74
  * @typedef {object} TemplateCopyResponse
73
75
  * @property {'template.copy'} type
76
+ * @property {string} package The npm package that owns the template.
74
77
  * @property {object} data
75
78
  * @property {string} data.template
76
79
  * @property {string} data.outputDir
@@ -219,6 +219,7 @@ export function runIntegrationCodemodsStep(versionGroups: Array<{
219
219
  }>;
220
220
  skippedOptional: Array<import("../../authoring/codemod/type").CodemodEntry>;
221
221
  }>;
222
+ export { CORE_PROVIDER_ID as CORE_PACKAGE } from "../../foundation/identity/providers.mjs";
222
223
  export { inspectAgentDocs };
223
224
  export type CoreTransformEntry = {
224
225
  name: string;
@@ -41,6 +41,9 @@ import {resolveProviders} from '../../foundation/integrations/provider-resolutio
41
41
  import {warnOnIntegrationIssues} from '../../foundation/integrations/integration-warnings.mjs';
42
42
  import {logger} from '../logger.mjs';
43
43
 
44
+ /** The package that owns Core's components, hooks, and codemods. */
45
+ export {CORE_PROVIDER_ID as CORE_PACKAGE} from '../../foundation/identity/providers.mjs';
46
+
44
47
  // Re-exported for the run leaf's lightweight agent-docs inspection path
45
48
  // (config_fixable short-circuit, where the full render cannot load config).
46
49
  export {inspectAgentDocs};
@@ -8,7 +8,7 @@
8
8
  * through the shared `logger`. No cwd, no version detection, no side effects.
9
9
  */
10
10
 
11
- import {collectAllCodemods} from '../_adapter.mjs';
11
+ import {CORE_PACKAGE, collectAllCodemods} from '../_adapter.mjs';
12
12
  import {logger} from '../../logger.mjs';
13
13
  import {toAscii} from '../../../assets/codemods/term-log.mjs';
14
14
 
@@ -18,13 +18,19 @@ import {toAscii} from '../../../assets/codemods/term-log.mjs';
18
18
  */
19
19
  export async function list() {
20
20
  const codemods = await collectAllCodemods();
21
- logger.log('Available codemods:');
21
+ logger.log(`Available codemods from ${CORE_PACKAGE}:`);
22
22
  for (const {name, title, pr, optional} of codemods) {
23
23
  logger.log(` ${name} - ${toAscii(title)}${optional ? ' (optional)' : ''} (${pr})`);
24
24
  }
25
25
  logger.log('Done\n');
26
26
  return {
27
27
  type: 'upgrade.list',
28
- data: codemods.map(({name, title, version, optional}) => ({name, title, version, optional})),
28
+ data: codemods.map(({name, title, version, optional}) => ({
29
+ name,
30
+ package: CORE_PACKAGE,
31
+ title,
32
+ version,
33
+ optional,
34
+ })),
29
35
  };
30
36
  }
@@ -10,6 +10,10 @@ export type UpgradeListResponse = {
10
10
  };
11
11
  export type UpgradeListEntry = {
12
12
  name: string;
13
+ /**
14
+ * The npm package that ships the codemod.
15
+ */
16
+ package: string;
13
17
  title: string;
14
18
  version: string;
15
19
  /**
@@ -23,6 +23,7 @@
23
23
  /**
24
24
  * @typedef {object} UpgradeListEntry
25
25
  * @property {string} name
26
+ * @property {string} package The npm package that ships the codemod.
26
27
  * @property {string} title
27
28
  * @property {string} version
28
29
  * @property {boolean} optional True when the codemod runs only if named with `--codemod`.
@@ -169,6 +169,7 @@ export function registerBuild(program) {
169
169
  const full = {
170
170
  fields: [
171
171
  'name',
172
+ 'package',
172
173
  'domain',
173
174
  'displayName',
174
175
  'score',
@@ -220,10 +221,10 @@ export function registerBuild(program) {
220
221
  start,
221
222
  verbose
222
223
  ? {
223
- fields: ['name', 'displayName', 'description', 'command'],
224
+ fields: ['name', 'package', 'displayName', 'description', 'command'],
224
225
  format: {command: formatCliCommand},
225
226
  }
226
- : brief(['name', 'description', 'command']),
227
+ : brief(['name', 'package', 'description', 'command']),
227
228
  ),
228
229
  );
229
230
  if (start.alternatives.length) {
@@ -234,7 +235,7 @@ export function registerBuild(program) {
234
235
  ),
235
236
  records(
236
237
  start.alternatives,
237
- verbose ? full : brief(['name', 'description', 'command']),
238
+ verbose ? full : brief(['name', 'package', 'description', 'command']),
238
239
  ),
239
240
  );
240
241
  }
@@ -249,7 +250,7 @@ export function registerBuild(program) {
249
250
  'Page templates keyword search matched, best first.',
250
251
  )
251
252
  : text(
252
- `Keyword search matched these page templates: ${pages.map(p => p.name).join(', ')}.`,
253
+ `Keyword search matched these page templates: ${pages.map(p => `${p.name} (${p.package})`).join(', ')}.`,
253
254
  ),
254
255
  );
255
256
  if (verbose) out.push(records(pages, full));
@@ -262,7 +263,7 @@ export function registerBuild(program) {
262
263
  ),
263
264
  records(
264
265
  shown(blocks),
265
- verbose ? full : brief(['name', 'description']),
266
+ verbose ? full : brief(['name', 'package', 'description']),
266
267
  ),
267
268
  );
268
269
  }
@@ -275,7 +276,7 @@ export function registerBuild(program) {
275
276
  ? [
276
277
  records(
277
278
  shown(domain),
278
- verbose ? full : brief(['name', 'description']),
279
+ verbose ? full : brief(['name', 'package', 'description']),
279
280
  ),
280
281
  ]
281
282
  : []),
@@ -75,7 +75,7 @@ describe('build kit text fields mirror the JSON keys', () => {
75
75
  expect(data.pages.length).toBeGreaterThan(0);
76
76
  const human = await runCli(['build', 'contact form'], REPO);
77
77
  expect(human.stdout).toContain(
78
- `Keyword search matched these page templates: ${data.pages.map(p => p.name).join(', ')}.`,
78
+ `Keyword search matched these page templates: ${data.pages.map(p => `${p.name} (${p.package})`).join(', ')}.`,
79
79
  );
80
80
  }, SLOW);
81
81
  });
@@ -104,7 +104,7 @@ function componentDetailBlocks(result, requestedName, detail, themeData) {
104
104
  switch (result.type) {
105
105
  case 'component.detail': {
106
106
  /** @type {import('../../formatters/index.mjs').Block[]} */
107
- const out = [];
107
+ const out = [record({package: result.package})];
108
108
  if (result.data.parentDoc) {
109
109
  out.push(record(result.data, {fields: ['parentDoc']}));
110
110
  }
@@ -129,24 +129,37 @@ function componentDetailBlocks(result, requestedName, detail, themeData) {
129
129
  return out;
130
130
  }
131
131
  case 'component.detail.props':
132
- return [code(formatProps({props: result.data}, resolvedName))];
132
+ return [
133
+ record({package: result.package}),
134
+ code(formatProps({props: result.data}, resolvedName)),
135
+ ];
133
136
  case 'component.detail.source':
134
137
  case 'component.detail.showcase':
135
138
  return [code(result.data.source)];
136
139
  case 'component.detail.blocks': {
137
140
  const {showcase, examples, related} = result.data;
141
+ // A block another package owns says which one.
142
+ /** @param {{package: string}} block @param {string} label */
143
+ const owned = (block, label) =>
144
+ block.package === result.package ? label : `${label} (${block.package})`;
138
145
  /** @type {import('../../formatters/index.mjs').Block[]} */
139
- const out = [];
146
+ const out = [record({package: result.package})];
140
147
  if (showcase) {
141
148
  out.push(
142
149
  section('Showcase'),
143
- record(showcase, {fields: ['displayName', 'description']}),
150
+ record(
151
+ {...showcase, displayName: owned(showcase, showcase.displayName)},
152
+ {fields: ['displayName', 'description']},
153
+ ),
144
154
  );
145
155
  }
146
156
  if (examples.length > 0) {
147
157
  out.push(
148
158
  section('Examples'),
149
- records(examples, {fields: ['name', 'description']}),
159
+ records(
160
+ examples.map(block => ({...block, name: owned(block, block.name)})),
161
+ {fields: ['name', 'description']},
162
+ ),
150
163
  );
151
164
  }
152
165
  if (related.length > 0) {
@@ -154,7 +167,7 @@ function componentDetailBlocks(result, requestedName, detail, themeData) {
154
167
  section(
155
168
  `Related: ${related.length} blocks that use ${result.data.component}`,
156
169
  ),
157
- list(related.map(block => block.name)),
170
+ list(related.map(block => owned(block, block.name))),
158
171
  );
159
172
  }
160
173
  if (!showcase && examples.length === 0 && related.length === 0) {
@@ -340,6 +353,12 @@ export function registerComponent(program) {
340
353
  out.push(
341
354
  record(row, {fields: ['selector', 'status']}),
342
355
  section('Result'),
356
+ // A batch is not piped as one file, so a source row names its
357
+ // package here; the other rows name it themselves.
358
+ ...(row.result.type === 'component.detail.source' ||
359
+ row.result.type === 'component.detail.showcase'
360
+ ? [record({package: row.result.package})]
361
+ : []),
343
362
  ...componentDetailBlocks(
344
363
  row.result,
345
364
  row.selector,
@@ -377,6 +396,15 @@ export function registerComponent(program) {
377
396
  case 'component.detail.source':
378
397
  case 'component.detail.showcase':
379
398
  case 'component.detail.blocks':
399
+ // Source and showcase print the file alone so it pipes byte for
400
+ // byte; the package they come from goes to stderr (cli-surface
401
+ // INV28).
402
+ if (
403
+ result.type === 'component.detail.source' ||
404
+ result.type === 'component.detail.showcase'
405
+ ) {
406
+ console.error(`package: ${result.package}`);
407
+ }
380
408
  emit(
381
409
  ...componentDetailBlocks(
382
410
  result,