@astryxdesign/cli 0.6.5-canary.4b7cb3a → 0.6.5-canary.4cdaedc
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 +44 -42
- package/api/build/_adapter.d.mts +19 -0
- package/api/build/_adapter.mjs +60 -1
- package/api/build/build.test.mjs +74 -1
- package/api/build/build.type.d.mts +8 -0
- package/api/build/build.type.mjs +2 -0
- package/api/build/kit/kit.mjs +40 -7
- package/api/build/kit/rank.d.mts +8 -0
- package/api/build/kit/rank.mjs +14 -0
- package/api/build/kit/weights.d.mts +82 -0
- package/api/build/kit/weights.json +1 -0
- package/api/build/kit/weights.mjs +305 -0
- package/api/build/kit/weights.test.mjs +190 -0
- package/api/component/_adapter.d.mts +19 -0
- package/api/component/_adapter.mjs +33 -0
- package/api/component/component-replacement.test.mjs +603 -0
- package/api/component/component.mjs +49 -15
- package/api/component/component.type.d.mts +33 -3
- package/api/component/component.type.mjs +10 -3
- package/api/component/detail/blocks/blocks.d.mts +2 -1
- package/api/component/detail/blocks/blocks.mjs +5 -2
- package/api/component/detail/detail.mjs +5 -1
- package/api/component/detail/props/props.d.mts +2 -1
- package/api/component/detail/props/props.mjs +3 -2
- package/api/component/detail/showcase/showcase.d.mts +3 -1
- package/api/component/detail/showcase/showcase.mjs +3 -1
- package/api/component/detail/source/source.d.mts +3 -2
- package/api/component/detail/source/source.mjs +7 -3
- package/api/component/list/list.mjs +128 -10
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +25 -0
- package/api/docs/detail/detail.mjs +19 -3
- package/api/docs/detail/section/section.mjs +7 -1
- package/api/docs/docs.d.mts +6 -0
- package/api/docs/docs.depth.test.mjs +134 -0
- package/api/docs/docs.doc.mjs +31 -2
- package/api/docs/docs.mjs +46 -1
- package/api/docs/docs.test.mjs +1 -1
- package/api/docs/docs.type.d.mts +81 -4
- package/api/docs/docs.type.mjs +41 -4
- package/api/docs/index/index.mjs +11 -2
- package/api/docs/index/index.test.mjs +7 -2
- package/api/docs/node/node.d.mts +28 -3
- package/api/docs/node/node.mjs +149 -23
- package/api/doctor/_adapter.d.mts +43 -0
- package/api/doctor/_adapter.mjs +142 -0
- package/api/doctor/doctor.d.mts +0 -10
- package/api/doctor/doctor.doc.mjs +1 -3
- package/api/doctor/doctor.mjs +6 -123
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +1117 -0
- package/api/doctor/theme-checks.test.mjs +483 -0
- package/api/gap-report/gap-report.mjs +15 -1
- package/api/hook/_adapter.d.mts +1 -0
- package/api/hook/_adapter.mjs +3 -0
- package/api/hook/detail/detail.mjs +2 -2
- package/api/hook/detail/params/params.mjs +2 -2
- package/api/hook/hook.type.d.mts +12 -0
- package/api/hook/hook.type.mjs +3 -0
- package/api/hook/list/list.d.mts +1 -1
- package/api/hook/list/list.mjs +8 -8
- package/api/index.d.mts +1 -1
- package/api/index.mjs +4 -0
- package/api/init/run/run.d.mts +3 -5
- package/api/init/run/run.mjs +10 -11
- package/api/integration/__fixtures__/released-0.6.5-ocean.d.mts +14 -0
- package/api/integration/__fixtures__/released-0.6.5-ocean.mjs +15 -0
- package/api/integration/add-helpers.d.mts +26 -5
- package/api/integration/add-helpers.mjs +50 -5
- package/api/integration/add-theme.mjs +109 -5
- package/api/integration/add-theme.test.mjs +166 -15
- package/api/integration/authoring-checks.mjs +21 -1
- package/api/integration/integrationAddTheme.doc.mjs +1 -1
- package/api/integration/integrationComponentConflicts.doc.mjs +6 -3
- package/api/integration/pack-check.component-replaces.test.mjs +126 -0
- package/api/integration/pack-check.d.mts +10 -0
- package/api/integration/pack-check.lifecycle-output.test.mjs +21 -2
- package/api/integration/pack-check.mjs +483 -1
- package/api/integration/pack-check.test.mjs +568 -8
- package/api/search/search.d.mts +11 -4
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.mjs +106 -53
- package/api/search/search.test.mjs +115 -2
- package/api/search/search.type.d.mts +3 -3
- package/api/search/search.type.mjs +2 -2
- package/api/swizzle/_adapter.d.mts +10 -0
- package/api/swizzle/_adapter.mjs +23 -0
- package/api/swizzle/copy/copy.mjs +22 -2
- package/api/swizzle/list/list.mjs +2 -2
- package/api/swizzle/swizzle.type.d.mts +8 -0
- package/api/swizzle/swizzle.type.mjs +2 -0
- package/api/template/copy/copy.mjs +2 -1
- package/api/template/show/show.mjs +2 -0
- package/api/template/skeleton/skeleton.mjs +2 -1
- package/api/template/template.d.mts +1 -1
- package/api/template/template.mjs +1 -0
- package/api/template/template.type.d.mts +12 -0
- package/api/template/template.type.mjs +3 -0
- package/api/theme/_adapter.d.mts +106 -6
- package/api/theme/_adapter.mjs +679 -18
- package/api/theme/add/add.binary.test.mjs +76 -3
- package/api/theme/add/add.d.mts +5 -9
- package/api/theme/add/add.mjs +87 -64
- package/api/theme/add/add.rollback.test.mjs +9 -9
- package/api/theme/add/add.staging.test.mjs +9 -9
- package/api/theme/add/add.test.mjs +461 -55
- package/api/theme/add/add.types.test.mjs +151 -0
- package/api/theme/build/build.d.mts +26 -2
- package/api/theme/build/build.family.test.mjs +13 -4
- package/api/theme/build/build.mjs +82 -78
- package/api/theme/build/build.test.mjs +30 -0
- package/api/theme/eject/eject.binary.test.mjs +90 -0
- package/api/theme/eject/eject.d.mts +17 -0
- package/api/theme/eject/eject.mjs +65 -0
- package/api/theme/eject/eject.rollback.test.mjs +158 -0
- package/api/theme/eject/eject.staging.test.mjs +83 -0
- package/api/theme/eject/eject.test.mjs +160 -0
- package/api/theme/integration-themes.test.mjs +30 -6
- package/api/theme/list/list.d.mts +10 -0
- package/api/theme/list/list.mjs +75 -7
- package/api/theme/list/list.test.mjs +155 -4
- package/api/theme/remove/remove.d.mts +12 -0
- package/api/theme/remove/remove.mjs +15 -0
- package/api/theme/remove/remove.test.mjs +94 -0
- package/api/theme/template/template.mjs +3 -4
- package/api/theme/theme.d.mts +5 -2
- package/api/theme/theme.mjs +13 -8
- package/api/theme/theme.type.d.mts +101 -2
- package/api/theme/theme.type.mjs +52 -5
- package/api/theme/themeAdd.doc.d.mts +1 -3
- package/api/theme/themeAdd.doc.mjs +35 -22
- package/api/theme/themeBuild.doc.mjs +1 -1
- package/api/theme/themeEject.doc.d.mts +8 -0
- package/api/theme/themeEject.doc.mjs +89 -0
- package/api/theme/themeListAvailable.doc.mjs +4 -4
- package/api/theme/themeListCopySources.doc.d.mts +8 -0
- package/api/theme/themeListCopySources.doc.mjs +60 -0
- package/api/theme/themeRemove.doc.d.mts +6 -0
- package/api/theme/themeRemove.doc.mjs +50 -0
- package/api/theme/themeTemplate.doc.mjs +4 -3
- package/api/theme/themeUse.doc.d.mts +6 -0
- package/api/theme/themeUse.doc.mjs +47 -0
- package/api/theme/use/use.d.mts +12 -0
- package/api/theme/use/use.mjs +15 -0
- package/api/theme/use/use.test.mjs +98 -0
- package/api/upgrade/_adapter.d.mts +1 -0
- package/api/upgrade/_adapter.mjs +3 -0
- package/api/upgrade/list/list.mjs +9 -3
- package/api/upgrade/upgrade.type.d.mts +4 -0
- package/api/upgrade/upgrade.type.mjs +1 -0
- package/assets/codemods/integration-discovery.mjs +1 -1
- package/assets/codemods/integration-discovery.test.mjs +64 -0
- package/assets/codemods/transforms/next/__tests__/migrate-copied-themes-to-descriptors.test.mjs +129 -0
- package/assets/codemods/transforms/next/index.mjs +14 -1
- package/assets/codemods/transforms/next/migrate-copied-themes-to-descriptors.mjs +54 -0
- package/assets/docs/getting-started.doc.mjs +58 -14
- package/assets/docs/principles.doc.dense.mjs +2 -2
- package/assets/docs/principles.doc.mjs +2 -2
- package/assets/docs/principles.doc.zh.mjs +2 -2
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +23 -4
- package/assets/docs/theme.doc.mjs +75 -66
- package/assets/docs/theme.doc.zh.mjs +158 -12
- package/assets/docs/tokens.doc.mjs +3 -3
- package/assets/docs/tree/add-a-theme.doc.mjs +6 -2
- package/assets/docs/tree/checks.doc.mjs +5 -4
- package/assets/docs/tree/document-the-theme.doc.mjs +4 -4
- package/assets/docs/tree/fonts-and-assets.doc.mjs +24 -19
- package/assets/docs/tree/headers-and-footers.doc.mjs +68 -0
- package/assets/docs/tree/layout-spacing.doc.mjs +168 -0
- package/assets/docs/tree/layout.doc.mjs +32 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +21 -4
- package/assets/docs/tree/responsive.doc.mjs +102 -0
- package/assets/docs/tree/scaffold.doc.mjs +145 -0
- package/assets/docs/tree/side-panels.doc.mjs +82 -0
- package/assets/docs/tree/structure.doc.mjs +144 -0
- package/assets/docs/tree/themes.doc.mjs +2 -2
- package/assets/docs/tree/troubleshooting.doc.mjs +4 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +22 -5
- package/assets/docs/tree/versioning.doc.mjs +4 -1
- package/assets/templates/pages/table-collapsible/page.tsx +1474 -0
- package/assets/templates/pages/table-collapsible/template.doc.mjs +12 -0
- package/assets/templates/pages/table-comparison/page.tsx +1449 -0
- package/assets/templates/pages/table-comparison/template.doc.mjs +12 -0
- package/authoring/doctypes/command/command.doc.mjs +5 -0
- package/authoring/doctypes/command/type.ts +2 -0
- package/authoring/doctypes/component/component.doc.mjs +1 -1
- package/authoring/doctypes/component/type.ts +8 -4
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.mjs +266 -27
- package/clients/cli/commands/build.mjs +7 -6
- package/clients/cli/commands/build.text-fields.test.mjs +1 -1
- package/clients/cli/commands/component/index.mjs +88 -12
- package/clients/cli/commands/component-replacement.text.test.mjs +271 -0
- package/clients/cli/commands/component.doc.mjs +9 -2
- package/clients/cli/commands/docs.depth.test.mjs +219 -0
- package/clients/cli/commands/docs.doc.mjs +15 -2
- package/clients/cli/commands/docs.mjs +273 -16
- package/clients/cli/commands/docs.test.mjs +2 -2
- package/clients/cli/commands/doctor-integration-components.doc.mjs +15 -4
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +9 -51
- package/clients/cli/commands/gap-report.doc.mjs +2 -2
- package/clients/cli/commands/hook/index.mjs +7 -2
- package/clients/cli/commands/init.next-steps.test.mjs +18 -23
- package/clients/cli/commands/integration-add.doc.mjs +1 -1
- package/clients/cli/commands/integration-real-world.test.mjs +61 -12
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +1 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.mjs +45 -4
- package/clients/cli/commands/no-prompt-wording.test.mjs +4 -4
- package/clients/cli/commands/search.test.mjs +23 -14
- package/clients/cli/commands/swizzle.doc.mjs +12 -3
- package/clients/cli/commands/swizzle.mjs +2 -1
- package/clients/cli/commands/template.mjs +8 -4
- package/clients/cli/commands/text-json-parity.test.mjs +40 -0
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +129 -0
- package/clients/cli/commands/theme-add.doc.mjs +19 -19
- package/clients/cli/commands/theme-eject.doc.mjs +47 -0
- package/clients/cli/commands/theme-list.behavior.test.mjs +5 -2
- package/clients/cli/commands/theme-list.doc.mjs +2 -2
- package/clients/cli/commands/theme-palette-generate.doc.mjs +1 -2
- package/clients/cli/commands/theme-remove.doc.mjs +22 -0
- package/clients/cli/commands/theme-template.doc.mjs +4 -3
- package/clients/cli/commands/theme-use.doc.mjs +22 -0
- package/clients/cli/commands/theme.doc.mjs +21 -16
- package/clients/cli/commands/upgrade.mjs +1 -1
- package/clients/cli/index.mjs +4 -1
- package/clients/cli/lib/component-format.mjs +19 -2
- package/clients/cli/lib/resolve-theme.mjs +80 -78
- package/clients/cli/lib/resolve-theme.test.mjs +523 -27
- package/foundation/agent-docs/agent-docs.mjs +2 -2
- package/foundation/agent-docs/app-theme-workflow.test.mjs +16 -0
- package/foundation/config/project.d.mts +20 -5
- package/foundation/config/project.mjs +43 -6
- package/foundation/config/theme-private-vars.d.mts +12 -0
- package/foundation/config/theme-private-vars.mjs +107 -0
- package/foundation/config/theme-private-vars.test.mjs +55 -0
- package/foundation/config/theme-state.d.mts +145 -0
- package/foundation/config/theme-state.mjs +417 -0
- package/foundation/config/theme-state.test.mjs +182 -0
- package/foundation/discovery/component-discovery.d.mts +5 -2
- package/foundation/discovery/component-discovery.mjs +12 -6
- package/foundation/discovery/component-replacement.d.mts +91 -0
- package/foundation/discovery/component-replacement.mjs +417 -0
- package/foundation/discovery/component-replacement.test.mjs +480 -0
- package/foundation/discovery/docs-output-budget.d.mts +6 -2
- package/foundation/discovery/docs-output-budget.mjs +2 -1
- package/foundation/discovery/docs-section-key.d.mts +4 -2
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/module-exports.d.mts +10 -0
- package/foundation/discovery/module-exports.mjs +146 -0
- package/foundation/discovery/package-exports.d.mts +29 -0
- package/foundation/discovery/package-exports.mjs +200 -0
- package/foundation/discovery/theme-discovery.d.mts +78 -5
- package/foundation/discovery/theme-discovery.mjs +143 -18
- package/foundation/discovery/theme-discovery.test.mjs +9 -3
- package/foundation/discovery/theme-imports.d.mts +15 -0
- package/foundation/discovery/theme-imports.mjs +217 -0
- package/foundation/discovery/theme-imports.test.mjs +173 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +15 -5
- package/foundation/doc-compiler/inputs.mjs +2 -1
- package/foundation/doc-compiler/lenses.d.mts +4 -2
- package/foundation/doc-compiler/lenses.mjs +1 -1
- package/foundation/doc-compiler/tree.test.mjs +2 -2
- package/foundation/fs/module-loader.d.mts +9 -0
- package/foundation/fs/module-loader.mjs +71 -2
- package/foundation/integrations/cli-requirement.d.mts +22 -0
- package/foundation/integrations/cli-requirement.mjs +31 -0
- package/foundation/integrations/cli-requirement.test.mjs +70 -0
- package/foundation/integrations/contribution-inventory.mjs +3 -3
- package/foundation/response/base.d.ts +9 -3
- package/foundation/response/json.d.mts +7 -4
- package/foundation/response/json.mjs +10 -6
- package/foundation/response/response-types.doc.mjs +38 -23
- package/foundation/response/response.doc.mjs +18 -4
- package/foundation/text/copyright-header.mjs +1 -1
- package/foundation/text/copyright-header.test.mjs +1 -1
- package/package.json +9 -9
- package/assets/docs/layout.doc.dense.mjs +0 -388
- package/assets/docs/layout.doc.mjs +0 -550
|
@@ -93,18 +93,26 @@ function summarize(result) {
|
|
|
93
93
|
* @param {import('../../../../api/component/component.type.mjs').ComponentSingleResponse} result
|
|
94
94
|
* @param {string} requestedName
|
|
95
95
|
* @param {'full'|'compact'|'brief'} detail
|
|
96
|
-
* @param {ReturnType<typeof resolveTheme
|
|
96
|
+
* @param {Awaited<ReturnType<typeof resolveTheme>>} themeData
|
|
97
97
|
* @returns {import('../../formatters/index.mjs').Block[]}
|
|
98
98
|
*/
|
|
99
99
|
function componentDetailBlocks(result, requestedName, detail, themeData) {
|
|
100
|
-
const
|
|
100
|
+
const requested = (requestedName.split('/').pop() ?? requestedName).replace(
|
|
101
101
|
/^XDS/,
|
|
102
102
|
'',
|
|
103
103
|
);
|
|
104
|
+
// A replacement answers to the Core name it replaces (spec:AST-035 FR11),
|
|
105
|
+
// but its package exports it under its own name: print that one.
|
|
106
|
+
const resolvedName =
|
|
107
|
+
result.type === 'component.detail' &&
|
|
108
|
+
typeof result.data.name === 'string' &&
|
|
109
|
+
result.data.replaces === requested
|
|
110
|
+
? result.data.name
|
|
111
|
+
: requested;
|
|
104
112
|
switch (result.type) {
|
|
105
113
|
case 'component.detail': {
|
|
106
114
|
/** @type {import('../../formatters/index.mjs').Block[]} */
|
|
107
|
-
const out = [];
|
|
115
|
+
const out = [record({package: result.package})];
|
|
108
116
|
if (result.data.parentDoc) {
|
|
109
117
|
out.push(record(result.data, {fields: ['parentDoc']}));
|
|
110
118
|
}
|
|
@@ -129,24 +137,37 @@ function componentDetailBlocks(result, requestedName, detail, themeData) {
|
|
|
129
137
|
return out;
|
|
130
138
|
}
|
|
131
139
|
case 'component.detail.props':
|
|
132
|
-
return [
|
|
140
|
+
return [
|
|
141
|
+
record({package: result.package}),
|
|
142
|
+
code(formatProps({props: result.data}, resolvedName)),
|
|
143
|
+
];
|
|
133
144
|
case 'component.detail.source':
|
|
134
145
|
case 'component.detail.showcase':
|
|
135
146
|
return [code(result.data.source)];
|
|
136
147
|
case 'component.detail.blocks': {
|
|
137
148
|
const {showcase, examples, related} = result.data;
|
|
149
|
+
// A block another package owns says which one.
|
|
150
|
+
/** @param {{package: string}} block @param {string} label */
|
|
151
|
+
const owned = (block, label) =>
|
|
152
|
+
block.package === result.package ? label : `${label} (${block.package})`;
|
|
138
153
|
/** @type {import('../../formatters/index.mjs').Block[]} */
|
|
139
|
-
const out = [];
|
|
154
|
+
const out = [record({package: result.package})];
|
|
140
155
|
if (showcase) {
|
|
141
156
|
out.push(
|
|
142
157
|
section('Showcase'),
|
|
143
|
-
record(
|
|
158
|
+
record(
|
|
159
|
+
{...showcase, displayName: owned(showcase, showcase.displayName)},
|
|
160
|
+
{fields: ['displayName', 'description']},
|
|
161
|
+
),
|
|
144
162
|
);
|
|
145
163
|
}
|
|
146
164
|
if (examples.length > 0) {
|
|
147
165
|
out.push(
|
|
148
166
|
section('Examples'),
|
|
149
|
-
records(
|
|
167
|
+
records(
|
|
168
|
+
examples.map(block => ({...block, name: owned(block, block.name)})),
|
|
169
|
+
{fields: ['name', 'description']},
|
|
170
|
+
),
|
|
150
171
|
);
|
|
151
172
|
}
|
|
152
173
|
if (related.length > 0) {
|
|
@@ -154,7 +175,7 @@ function componentDetailBlocks(result, requestedName, detail, themeData) {
|
|
|
154
175
|
section(
|
|
155
176
|
`Related: ${related.length} blocks that use ${result.data.component}`,
|
|
156
177
|
),
|
|
157
|
-
list(related.map(block => block.name)),
|
|
178
|
+
list(related.map(block => owned(block, block.name))),
|
|
158
179
|
);
|
|
159
180
|
}
|
|
160
181
|
if (!showcase && examples.length === 0 && related.length === 0) {
|
|
@@ -242,7 +263,18 @@ export function registerComponent(program) {
|
|
|
242
263
|
// The api layer already resolved against core (result exists), so core is
|
|
243
264
|
// present on this path; narrow away the null branch findCoreDir allows.
|
|
244
265
|
const coreDir = /** @type {string} */ (findCoreDir(process.cwd()));
|
|
245
|
-
|
|
266
|
+
let themeData;
|
|
267
|
+
try {
|
|
268
|
+
themeData = await resolveTheme(process.cwd());
|
|
269
|
+
} catch (error) {
|
|
270
|
+
const message =
|
|
271
|
+
error instanceof Error
|
|
272
|
+
? error.message.split('\n', 1)[0]?.trim() || error.name
|
|
273
|
+
: String(error);
|
|
274
|
+
return cliError(`Could not load the recorded theme: ${message}`, {
|
|
275
|
+
code: ERROR_CODES.ERR_THEME_LOAD,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
246
278
|
|
|
247
279
|
// Footer shared by the compact + names list views (prose → text()).
|
|
248
280
|
const listFooter = text(
|
|
@@ -258,8 +290,31 @@ export function registerComponent(program) {
|
|
|
258
290
|
// in result.data.detail and the grouped map in result.data.components.
|
|
259
291
|
if (result.data.detail === 'full') {
|
|
260
292
|
// --detail full — dense per-component docs (signature, props, theming,
|
|
261
|
-
// examples). Verbatim doc block from the shared formatter.
|
|
262
|
-
|
|
293
|
+
// examples). Verbatim doc block from the shared formatter. A Core slot
|
|
294
|
+
// an integration component replaces prints that component, from the
|
|
295
|
+
// list result (spec:AST-035 FR11).
|
|
296
|
+
/** @type {Map<string, any>} */
|
|
297
|
+
const replacements = new Map();
|
|
298
|
+
for (const items of Object.values(result.data.components)) {
|
|
299
|
+
for (const item of /** @type {any[]} */ (items)) {
|
|
300
|
+
if (
|
|
301
|
+
item.package !== '@astryxdesign/core' &&
|
|
302
|
+
typeof item.replaces === 'string'
|
|
303
|
+
) {
|
|
304
|
+
replacements.set(item.replaces, item);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
emit(
|
|
309
|
+
code(
|
|
310
|
+
await formatBriefAll(coreDir, {
|
|
311
|
+
zh,
|
|
312
|
+
lang,
|
|
313
|
+
themeData,
|
|
314
|
+
replacements,
|
|
315
|
+
}),
|
|
316
|
+
),
|
|
317
|
+
);
|
|
263
318
|
break;
|
|
264
319
|
}
|
|
265
320
|
|
|
@@ -275,7 +330,13 @@ export function registerComponent(program) {
|
|
|
275
330
|
const isUngrouped =
|
|
276
331
|
entries.length === 1 && items.length === 1 && items[0]?.name === cat;
|
|
277
332
|
if (!isUngrouped) out.push(section(cat));
|
|
278
|
-
|
|
333
|
+
// An entry from another package says which one (cli-surface INV28).
|
|
334
|
+
const named = items.map(item =>
|
|
335
|
+
item.package === '@astryxdesign/core'
|
|
336
|
+
? item
|
|
337
|
+
: {...item, import: `${item.import} [${item.package}]`},
|
|
338
|
+
);
|
|
339
|
+
out.push(records(named, {fields: ['name', 'import', 'description']}));
|
|
279
340
|
}
|
|
280
341
|
out.push(listFooter);
|
|
281
342
|
emit(...out);
|
|
@@ -340,6 +401,12 @@ export function registerComponent(program) {
|
|
|
340
401
|
out.push(
|
|
341
402
|
record(row, {fields: ['selector', 'status']}),
|
|
342
403
|
section('Result'),
|
|
404
|
+
// A batch is not piped as one file, so a source row names its
|
|
405
|
+
// package here; the other rows name it themselves.
|
|
406
|
+
...(row.result.type === 'component.detail.source' ||
|
|
407
|
+
row.result.type === 'component.detail.showcase'
|
|
408
|
+
? [record({package: row.result.package})]
|
|
409
|
+
: []),
|
|
343
410
|
...componentDetailBlocks(
|
|
344
411
|
row.result,
|
|
345
412
|
row.selector,
|
|
@@ -377,6 +444,15 @@ export function registerComponent(program) {
|
|
|
377
444
|
case 'component.detail.source':
|
|
378
445
|
case 'component.detail.showcase':
|
|
379
446
|
case 'component.detail.blocks':
|
|
447
|
+
// Source and showcase print the file alone so it pipes byte for
|
|
448
|
+
// byte; the package they come from goes to stderr (cli-surface
|
|
449
|
+
// INV28).
|
|
450
|
+
if (
|
|
451
|
+
result.type === 'component.detail.source' ||
|
|
452
|
+
result.type === 'component.detail.showcase'
|
|
453
|
+
) {
|
|
454
|
+
console.error(`package: ${result.package}`);
|
|
455
|
+
}
|
|
380
456
|
emit(
|
|
381
457
|
...componentDetailBlocks(
|
|
382
458
|
result,
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Component replacement in text mode (spec:AST-035 FR11, FR13, FR15;
|
|
5
|
+
* architecture:cli-surface INV28): what a person sees from the real CLI for a
|
|
6
|
+
* replaced Core component, at every detail level, single, batch, and list,
|
|
7
|
+
* plus the help that documents it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {afterAll, beforeAll, describe, expect, it, vi} from 'vitest';
|
|
11
|
+
import * as fs from 'node:fs';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
14
|
+
import {COMPONENT_REPLACES_CLI} from '../../../foundation/integrations/cli-requirement.mjs';
|
|
15
|
+
|
|
16
|
+
vi.setConfig({testTimeout: 60_000, hookTimeout: 60_000});
|
|
17
|
+
|
|
18
|
+
const FLOOR = {'@astryxdesign/cli': `>=${COMPONENT_REPLACES_CLI}`};
|
|
19
|
+
|
|
20
|
+
let tmpDir;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {string} name
|
|
24
|
+
* @param {Array<{name: string, replaces?: string}>} components
|
|
25
|
+
* @param {Record<string, string>} [peers]
|
|
26
|
+
*/
|
|
27
|
+
function writeIntegration(name, components, peers) {
|
|
28
|
+
const pkgDir = path.join(tmpDir, 'node_modules', ...name.split('/'));
|
|
29
|
+
const componentsDir = path.join(pkgDir, 'components');
|
|
30
|
+
fs.mkdirSync(componentsDir, {recursive: true});
|
|
31
|
+
fs.writeFileSync(
|
|
32
|
+
path.join(pkgDir, 'package.json'),
|
|
33
|
+
JSON.stringify({
|
|
34
|
+
name,
|
|
35
|
+
version: '1.0.0',
|
|
36
|
+
...(peers ? {peerDependencies: peers} : {}),
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
fs.writeFileSync(
|
|
40
|
+
path.join(pkgDir, 'astryx.integration.mjs'),
|
|
41
|
+
"export default {components: './components'};\n",
|
|
42
|
+
);
|
|
43
|
+
for (const component of components) {
|
|
44
|
+
fs.writeFileSync(
|
|
45
|
+
path.join(componentsDir, `${component.name}.doc.mjs`),
|
|
46
|
+
`export default ${JSON.stringify({
|
|
47
|
+
type: 'component',
|
|
48
|
+
name: component.name,
|
|
49
|
+
displayName: component.name,
|
|
50
|
+
...(component.replaces ? {replaces: component.replaces} : {}),
|
|
51
|
+
import: `${name}/components/${component.name}`,
|
|
52
|
+
usage: {description: `${component.name} for Acme apps.`},
|
|
53
|
+
props: [],
|
|
54
|
+
})};\n`,
|
|
55
|
+
);
|
|
56
|
+
fs.writeFileSync(
|
|
57
|
+
path.join(componentsDir, `${component.name}.tsx`),
|
|
58
|
+
`export function ${component.name}() { return null; }\n`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
beforeAll(() => {
|
|
64
|
+
// Under the repository so the project resolves the workspace's Core.
|
|
65
|
+
tmpDir = fs.mkdtempSync(
|
|
66
|
+
path.join(process.cwd(), '.astryx-component-replacement-text-'),
|
|
67
|
+
);
|
|
68
|
+
writeIntegration(
|
|
69
|
+
'@acme/nav',
|
|
70
|
+
[{name: 'AcmeSideNav', replaces: 'SideNav'}],
|
|
71
|
+
FLOOR,
|
|
72
|
+
);
|
|
73
|
+
writeIntegration('@acme/old', [{name: 'OldTopNav', replaces: 'TopNav'}]);
|
|
74
|
+
writeIntegration(
|
|
75
|
+
'@acme/bad',
|
|
76
|
+
[{name: 'BadThing', replaces: 'NoSuchComponent'}],
|
|
77
|
+
FLOOR,
|
|
78
|
+
);
|
|
79
|
+
fs.writeFileSync(
|
|
80
|
+
path.join(tmpDir, 'package.json'),
|
|
81
|
+
JSON.stringify({
|
|
82
|
+
name: 'consumer',
|
|
83
|
+
version: '1.0.0',
|
|
84
|
+
dependencies: {
|
|
85
|
+
'@acme/nav': '1.0.0',
|
|
86
|
+
'@acme/old': '1.0.0',
|
|
87
|
+
'@acme/bad': '1.0.0',
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
afterAll(() => {
|
|
94
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const IMPORT =
|
|
98
|
+
"import { AcmeSideNav } from '@acme/nav/components/AcmeSideNav';";
|
|
99
|
+
|
|
100
|
+
describe('component detail text', () => {
|
|
101
|
+
it('prints the replacement at full detail, naming its package', async () => {
|
|
102
|
+
const run = await runCli(['component', 'SideNav'], {cwd: tmpDir});
|
|
103
|
+
expect(run.status, run.stderr).toBe(0);
|
|
104
|
+
expect(run.stdout).toContain('package: @acme/nav');
|
|
105
|
+
expect(run.stdout).toContain('# AcmeSideNav');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('imports the export the package has at compact detail', async () => {
|
|
109
|
+
const run = await runCli(['component', 'SideNav', '--detail', 'compact'], {
|
|
110
|
+
cwd: tmpDir,
|
|
111
|
+
});
|
|
112
|
+
expect(run.status, run.stderr).toBe(0);
|
|
113
|
+
expect(run.stdout).toContain(IMPORT);
|
|
114
|
+
expect(run.stdout).not.toContain('import { SideNav }');
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('names the export the package has at brief detail', async () => {
|
|
118
|
+
const run = await runCli(['component', 'SideNav', '--detail', 'brief'], {
|
|
119
|
+
cwd: tmpDir,
|
|
120
|
+
});
|
|
121
|
+
expect(run.status, run.stderr).toBe(0);
|
|
122
|
+
expect(run.stdout).toMatch(
|
|
123
|
+
/^AcmeSideNav {2}<- from '@acme\/nav\/components\/AcmeSideNav'/m,
|
|
124
|
+
);
|
|
125
|
+
expect(run.stdout).not.toMatch(/^SideNav {2}<- from '@acme/m);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('answers to the Core name qualified by the replacing package', async () => {
|
|
129
|
+
const run = await runCli(
|
|
130
|
+
['component', '@acme/nav/SideNav', '--detail', 'compact'],
|
|
131
|
+
{
|
|
132
|
+
cwd: tmpDir,
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
expect(run.status, run.stderr).toBe(0);
|
|
136
|
+
expect(run.stdout).toContain(IMPORT);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('keeps the Core original behind --package @astryxdesign/core', async () => {
|
|
140
|
+
const run = await runCli(
|
|
141
|
+
[
|
|
142
|
+
'component',
|
|
143
|
+
'SideNav',
|
|
144
|
+
'--package',
|
|
145
|
+
'@astryxdesign/core',
|
|
146
|
+
'--detail',
|
|
147
|
+
'compact',
|
|
148
|
+
],
|
|
149
|
+
{cwd: tmpDir},
|
|
150
|
+
);
|
|
151
|
+
expect(run.status, run.stderr).toBe(0);
|
|
152
|
+
expect(run.stdout).toContain('package: @astryxdesign/core');
|
|
153
|
+
expect(run.stdout).toContain("from '@astryxdesign/core/SideNav'");
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('component batch text', () => {
|
|
158
|
+
it.each(['compact', 'brief'])(
|
|
159
|
+
'uses the replacement export at %s detail',
|
|
160
|
+
async detail => {
|
|
161
|
+
const run = await runCli(
|
|
162
|
+
['component', 'SideNav', 'Button', '--detail', detail],
|
|
163
|
+
{
|
|
164
|
+
cwd: tmpDir,
|
|
165
|
+
},
|
|
166
|
+
);
|
|
167
|
+
expect(run.status, run.stderr).toBe(0);
|
|
168
|
+
expect(run.stdout).toContain('AcmeSideNav');
|
|
169
|
+
expect(run.stdout).toContain("'@acme/nav/components/AcmeSideNav'");
|
|
170
|
+
expect(run.stdout).not.toContain('import { SideNav }');
|
|
171
|
+
expect(run.stdout).not.toMatch(/^SideNav {2}<- from '@acme/m);
|
|
172
|
+
},
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
describe('component list text', () => {
|
|
177
|
+
it('lists the replacement once, with its package, at brief detail', async () => {
|
|
178
|
+
const run = await runCli(['component', '--list'], {cwd: tmpDir});
|
|
179
|
+
expect(run.status, run.stderr).toBe(0);
|
|
180
|
+
expect(run.stdout).toContain('name: AcmeSideNav');
|
|
181
|
+
expect(run.stdout).toContain(
|
|
182
|
+
'@acme/nav/components/AcmeSideNav [@acme/nav]',
|
|
183
|
+
);
|
|
184
|
+
expect(run.stdout.match(/name: {3}AcmeSideNav\n/g)).toHaveLength(1);
|
|
185
|
+
expect(run.stdout).not.toMatch(/name: {3}SideNav\n/);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('names the replacement package at compact detail', async () => {
|
|
189
|
+
const run = await runCli(['component', '--list', '--detail', 'compact'], {
|
|
190
|
+
cwd: tmpDir,
|
|
191
|
+
});
|
|
192
|
+
expect(run.status, run.stderr).toBe(0);
|
|
193
|
+
expect(run.stdout).toContain(
|
|
194
|
+
'@acme/nav/components/AcmeSideNav [@acme/nav]',
|
|
195
|
+
);
|
|
196
|
+
expect(run.stdout).not.toMatch(/name: +SideNav\n/);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('prints the replacement in the Core slot at full detail', async () => {
|
|
200
|
+
const run = await runCli(['component', '--list', '--detail', 'full'], {
|
|
201
|
+
cwd: tmpDir,
|
|
202
|
+
});
|
|
203
|
+
expect(run.status, run.stderr).toBe(0);
|
|
204
|
+
expect(run.stdout).toMatch(
|
|
205
|
+
/^AcmeSideNav {2}<- from '@acme\/nav\/components\/AcmeSideNav' {2}\[@acme\/nav\]$/m,
|
|
206
|
+
);
|
|
207
|
+
expect(run.stdout).not.toMatch(/^SideNav[( ]/m);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it.each(['brief', 'compact', 'full'])(
|
|
211
|
+
'keeps the replacement in its category at %s detail',
|
|
212
|
+
async detail => {
|
|
213
|
+
const run = await runCli(
|
|
214
|
+
['component', '--category', 'Navigation', '--detail', detail],
|
|
215
|
+
{cwd: tmpDir},
|
|
216
|
+
);
|
|
217
|
+
expect(run.status, run.stderr).toBe(0);
|
|
218
|
+
expect(run.stdout).toContain('AcmeSideNav');
|
|
219
|
+
},
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe('help documents the replacement', () => {
|
|
224
|
+
it.each([
|
|
225
|
+
[
|
|
226
|
+
['component', '--help'],
|
|
227
|
+
['replaced by an integration component', '--package @astryxdesign/core'],
|
|
228
|
+
],
|
|
229
|
+
[
|
|
230
|
+
['swizzle', '--help'],
|
|
231
|
+
['replaces', '--package @astryxdesign/core', '--list'],
|
|
232
|
+
],
|
|
233
|
+
[
|
|
234
|
+
['gap-report', '--help'],
|
|
235
|
+
['the integration whose component replaces the named Core component'],
|
|
236
|
+
],
|
|
237
|
+
[
|
|
238
|
+
['doctor', 'integration', 'components', '--help'],
|
|
239
|
+
['replaces', 'an invalid replaces'],
|
|
240
|
+
],
|
|
241
|
+
])('%s', async (args, needles) => {
|
|
242
|
+
const run = await runCli(/** @type {string[]} */ (args), {cwd: tmpDir});
|
|
243
|
+
const help = run.stdout + run.stderr;
|
|
244
|
+
for (const needle of needles) expect(help).toContain(needle);
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
describe('doctor integration components text and exit codes', () => {
|
|
249
|
+
it('exits 1 for an invalid replaces in a package with the floor', async () => {
|
|
250
|
+
const run = await runCli(
|
|
251
|
+
['doctor', 'integration', 'components', '@acme/bad'],
|
|
252
|
+
{
|
|
253
|
+
cwd: tmpDir,
|
|
254
|
+
},
|
|
255
|
+
);
|
|
256
|
+
expect(run.status).toBe(1);
|
|
257
|
+
expect(run.stdout).toContain('missing_component_replacement_target');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('warns and exits 0 for a package without the floor', async () => {
|
|
261
|
+
const run = await runCli(
|
|
262
|
+
['doctor', 'integration', 'components', '@acme/old'],
|
|
263
|
+
{
|
|
264
|
+
cwd: tmpDir,
|
|
265
|
+
},
|
|
266
|
+
);
|
|
267
|
+
expect(run.status, run.stdout).toBe(0);
|
|
268
|
+
expect(run.stdout).toContain('inactive_component_replacement');
|
|
269
|
+
expect(run.stdout).toContain(`">=${COMPONENT_REPLACES_CLI}"`);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
@@ -21,7 +21,10 @@ export const doc = {
|
|
|
21
21
|
"Use 'Button', 'widgets/Button', '@acme/widgets/Button', or " +
|
|
22
22
|
"'@acme/widgets@1.2.3/Button'. A version applies to the package and must match the " +
|
|
23
23
|
'installed version. Boolean flags narrow every resolved component to just its props, ' +
|
|
24
|
-
'source, showcase, or example blocks.'
|
|
24
|
+
'source, showcase, or example blocks. An integration component that replaces a Core ' +
|
|
25
|
+
'component (its doc sets replaces, and its package declares the CLI range that turns ' +
|
|
26
|
+
'replacement on) answers to the Core name in detail, batch, and list views; use ' +
|
|
27
|
+
'--package @astryxdesign/core for the original.',
|
|
25
28
|
fn: 'component',
|
|
26
29
|
args: [
|
|
27
30
|
{
|
|
@@ -69,7 +72,7 @@ export const doc = {
|
|
|
69
72
|
flag: '--package <name>',
|
|
70
73
|
param: 'options.package',
|
|
71
74
|
description:
|
|
72
|
-
'Scope lookup to an external package (e.g. @acme/xds-widgets)',
|
|
75
|
+
'Scope lookup to an external package (e.g. @acme/xds-widgets). Use @astryxdesign/core to select an original replaced by an integration component.',
|
|
73
76
|
},
|
|
74
77
|
],
|
|
75
78
|
examples: [
|
|
@@ -82,6 +85,10 @@ export const doc = {
|
|
|
82
85
|
label: 'Props table as JSON',
|
|
83
86
|
cli: 'astryx component Button --props --json',
|
|
84
87
|
},
|
|
88
|
+
{
|
|
89
|
+
label: 'Select a replaced Core original',
|
|
90
|
+
cli: 'astryx component SideNav --package @astryxdesign/core',
|
|
91
|
+
},
|
|
85
92
|
],
|
|
86
93
|
exitCodes: [
|
|
87
94
|
{code: 0, when: 'success'},
|