@astryxdesign/cli 0.7.0-canary.21875fc → 0.7.0-canary.291c4e9
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 +79 -84
- package/api/build/build.mjs +9 -0
- package/api/component/_adapter.d.mts +2 -0
- package/api/component/_adapter.mjs +3 -1
- package/api/component/component.doc.mjs +5 -1
- package/api/docs/compiled-topics.test.mjs +16 -0
- package/api/doctor/doctor.doc.mjs +1 -1
- package/api/doctor/doctor.test.mjs +28 -0
- package/api/doctor/theme-checks.mjs +10 -10
- package/api/doctor/theme-checks.test.mjs +5 -4
- package/api/gap-report/gap-report.doc.mjs +1 -1
- package/api/gap-report/gap-report.mjs +15 -0
- package/api/gap-report/gap-report.test.mjs +1 -1
- package/api/index.d.mts +0 -2
- package/api/index.mjs +0 -2
- package/api/init/init.doc.mjs +5 -1
- package/api/init/init.mjs +22 -0
- package/api/init/init.type.d.mts +4 -1
- package/api/init/init.type.mjs +1 -1
- package/api/init/remove/remove.mjs +8 -3
- package/api/init/remove/remove.test.mjs +12 -0
- package/api/init/run/run.d.mts +1 -1
- package/api/init/run/run.mjs +3 -3
- package/api/integration/pack-check.test.mjs +8 -0
- package/api/integration/validate-integration.d.mts +4 -0
- package/api/integration/validate-integration.mjs +5 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/json/index.ts +0 -1
- package/api/search/search.doc.mjs +1 -1
- package/api/search/search.mjs +1 -1
- package/api/search/search.test.mjs +1 -1
- package/api/search/search.type.d.mts +1 -1
- package/api/search/search.type.mjs +1 -1
- package/api/template/list/list.mjs +23 -2
- package/api/template/list/list.test.mjs +52 -0
- package/api/template/template-integration.test.mjs +37 -100
- package/api/template/template.doc.mjs +8 -3
- package/api/template/template.mjs +45 -0
- package/api/template/template.type.mjs +1 -1
- package/api/theme/_adapter.mjs +3 -3
- package/api/theme/add/add.d.mts +11 -5
- package/api/theme/add/add.mjs +19 -192
- package/api/theme/add/add.test.mjs +68 -258
- package/api/theme/add/add.types.test.mjs +0 -1
- package/api/theme/build/build.d.mts +3 -4
- package/api/theme/build/build.mjs +26 -65
- package/api/theme/build/build.test.mjs +11 -24
- package/api/theme/build/family.mjs +1 -1
- package/api/theme/eject/eject.copy-compat.test.mjs +168 -0
- package/api/theme/integration-themes.test.mjs +3 -3
- package/api/theme/remove/remove.test.mjs +1 -1
- package/api/theme/targets/targets.test.mjs +0 -4
- package/api/theme/template/template.mjs +1 -1
- package/api/theme/theme.type.d.mts +1 -30
- package/api/theme/theme.type.mjs +3 -13
- package/api/theme/themeAdd.doc.mjs +19 -27
- package/api/theme/themeTargets.doc.mjs +3 -4
- package/api/theme/themeTemplate.doc.mjs +1 -1
- package/api/theme/use/use.test.mjs +1 -1
- package/api/upgrade/upgrade.doc.mjs +1 -1
- package/api/upgrade/upgrade.mjs +19 -0
- package/assets/codemods/transforms/next/__tests__/migrate-deprecated-theme-surface.test.mjs +322 -0
- package/assets/codemods/transforms/next/__tests__/migrate-field-input-styling.test.mjs +108 -0
- package/assets/codemods/transforms/next/__tests__/validate-data-token-ownership.test.mjs +84 -0
- package/assets/codemods/transforms/next/index.mjs +27 -1
- package/assets/codemods/transforms/next/migrate-deprecated-theme-surface-v0.6-data.mjs +229 -0
- package/assets/codemods/transforms/next/migrate-deprecated-theme-surface.mjs +624 -0
- package/assets/codemods/transforms/next/migrate-field-input-styling.mjs +198 -0
- package/assets/codemods/transforms/next/validate-data-token-ownership.mjs +102 -0
- package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +38 -18
- package/assets/docs/author-a-theme.doc.mjs +5 -5
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +2 -2
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +2 -2
- package/assets/docs/tree/fonts-and-assets.doc.mjs +3 -3
- package/assets/docs/tree/styling-advanced.doc.mjs +21 -14
- package/assets/docs/tree/themes.doc.mjs +1 -1
- package/assets/docs/tree/tokens-data.doc.mjs +2 -2
- package/assets/docs/tree/tokens-usage.doc.mjs +1 -1
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +2 -2
- package/assets/docs/tree/versioning.doc.mjs +1 -4
- package/assets/docs/use-a-theme.doc.mjs +16 -16
- package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorDeadlinePicker.tsx +1 -1
- package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorShowcase.tsx +1 -1
- package/assets/templates/blocks/components/ComplexSelector/ComplexSelectorTreeSearch.tsx +1 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider01ShippedLocale.tsx +1 -1
- package/assets/templates/blocks/components/InternationalizationProvider/InternationalizationProvider02Overrides.tsx +1 -1
- package/assets/templates/blocks/components/Selector/SelectorClearable.tsx +1 -1
- package/assets/templates/blocks/components/Selector/SelectorOptionDescriptions.tsx +2 -2
- package/assets/templates/blocks/components/Selector/SelectorShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Selector/SelectorWithSections.tsx +1 -1
- package/assets/templates/blocks/components/SelectorOption/SelectorOptionBasic.tsx +1 -1
- package/assets/templates/blocks/components/SelectorOption/SelectorOptionShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Slider/SliderFormattedValue.tsx +1 -1
- package/assets/templates/blocks/components/Slider/SliderRangeSlider.tsx +1 -1
- package/assets/templates/blocks/components/Slider/SliderShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Slider/SliderWithMarks.tsx +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerClear.tsx +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerCreatable.tsx +2 -2
- package/assets/templates/blocks/components/Tokenizer/TokenizerEndContent.tsx +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerIcon.tsx +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerMaxEntries.tsx +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerOverflow.tsx +2 -2
- package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerStates.tsx +4 -4
- package/assets/templates/blocks/components/Toolbar/ToolbarTableFilter.tsx +1 -1
- package/assets/templates/pages/canvas-editor/page.tsx +2 -2
- package/assets/templates/pages/form-wizard-vertical/page.tsx +1 -1
- package/assets/templates/pages/payment-form/page.tsx +1 -1
- package/assets/templates/pages/table-filter/page.tsx +3 -3
- package/assets/templates/pages/theme-showcase/page.tsx +2 -2
- package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +10 -9
- package/authoring/debug/type.ts +2 -2
- package/authoring/doctypes/base/type.ts +0 -9
- package/authoring/integration/integration.doc.mjs +1 -1
- package/clients/cli/command-result-coverage.test.mjs +1 -1
- package/clients/cli/commands/build-theme.adaptations.test.mjs +4 -0
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +35 -8
- package/clients/cli/commands/build-theme.color-scheme.test.mjs +10 -6
- package/clients/cli/commands/build-theme.data-tokens.test.mjs +23 -75
- package/clients/cli/commands/build-theme.mjs +31 -67
- package/clients/cli/commands/build-theme.registry.test.mjs +0 -10
- package/clients/cli/commands/build.doc.mjs +1 -1
- package/clients/cli/commands/build.mjs +1 -1
- package/clients/cli/commands/component-ownership.test.mjs +2 -2
- package/clients/cli/commands/debug-result-summary.test.mjs +0 -16
- package/clients/cli/commands/discover.mjs +2 -1
- package/clients/cli/commands/doctor.mjs +5 -2
- package/clients/cli/commands/empty-argument.test.mjs +16 -0
- package/clients/cli/commands/gap-report.doc.mjs +1 -1
- package/clients/cli/commands/gap-report.test.mjs +2 -2
- package/clients/cli/commands/init.doc.mjs +4 -4
- package/clients/cli/commands/init.flag-help.test.mjs +7 -10
- package/clients/cli/commands/init.next-steps.test.mjs +1 -1
- package/clients/cli/commands/integration.mjs +2 -1
- package/clients/cli/commands/option-pair-refusals.test.mjs +37 -0
- package/clients/cli/commands/search.test.mjs +1 -1
- package/clients/cli/commands/silent-success-refusals.test.mjs +15 -0
- package/clients/cli/commands/swizzle.mjs +4 -1
- package/clients/cli/commands/template.doc.mjs +4 -4
- package/clients/cli/commands/template.flag-help.test.mjs +18 -11
- package/clients/cli/commands/template.mjs +7 -1
- package/clients/cli/commands/text-json-parity.test.mjs +0 -17
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +142 -49
- package/clients/cli/commands/theme-add.doc.mjs +10 -17
- package/clients/cli/commands/theme-list.behavior.test.mjs +2 -1
- package/clients/cli/commands/theme-targets.behavior.test.mjs +8 -6
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/theme.doc.mjs +2 -2
- package/clients/cli/commands/upgrade.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.flag-help.test.mjs +7 -11
- package/clients/cli/commands/validate-nothing-exits-nonzero.test.mjs +67 -0
- package/clients/cli/index.mjs +0 -4
- package/clients/cli/lib/cli-error.mjs +19 -0
- package/clients/cli/lib/component-format.mjs +111 -57
- package/clients/cli/lib/component-format.test.mjs +28 -39
- package/clients/cli/lib/doc-text-ascii.test.mjs +5 -2
- package/clients/cli/lib/exit-codes.test.mjs +0 -7
- package/clients/cli/lib/json-shim.test.mjs +0 -24
- package/foundation/agent-docs/agent-docs.d.mts +2 -1
- package/foundation/agent-docs/agent-docs.mjs +6 -1
- package/foundation/agent-docs/app-theme-workflow.test.mjs +3 -0
- package/foundation/config/theme-state.mjs +3 -3
- package/foundation/debug/debug-fields.test.mjs +13 -35
- package/foundation/debug/event.mjs +13 -78
- package/foundation/debug/privacy-contract.test.mjs +20 -12
- package/foundation/debug/redact.d.mts +2 -2
- package/foundation/debug/redact.mjs +2 -2
- package/foundation/discovery/template-needs.mjs +93 -11
- package/foundation/discovery/template-needs.test.mjs +106 -3
- package/foundation/discovery/theme-imports.mjs +1 -1
- package/foundation/discovery/theming-targets.d.mts +1 -20
- package/foundation/discovery/theming-targets.mjs +1 -38
- package/foundation/discovery/theming-targets.test.mjs +9 -175
- package/foundation/doc-compiler/doc-loads.test.mjs +0 -12
- package/foundation/env/package-manager.d.mts +13 -0
- package/foundation/env/package-manager.mjs +106 -63
- package/foundation/response/error-codes.doc.mjs +1 -1
- package/foundation/response/response-types.doc.mjs +11 -31
- package/foundation/response/response-types.doc.test.mjs +36 -14
- package/foundation/response/response.doc.mjs +1 -1
- package/foundation/xle/browser.d.mts +2 -2
- package/foundation/xle/browser.mjs +2 -2
- package/foundation/xle/expand.mjs +1 -1
- package/foundation/xle/print.mjs +1 -1
- package/package.json +9 -9
- package/api/layout/_adapter.d.mts +0 -34
- package/api/layout/_adapter.mjs +0 -148
- package/api/layout/check/check.d.mts +0 -17
- package/api/layout/check/check.mjs +0 -41
- package/api/layout/expand/expand.d.mts +0 -23
- package/api/layout/expand/expand.mjs +0 -161
- package/api/layout/expand/expand.path-safety.test.mjs +0 -53
- package/api/layout/expand/expand.receipt.test.mjs +0 -74
- package/api/layout/grammar/grammar.d.mts +0 -14
- package/api/layout/grammar/grammar.mjs +0 -88
- package/api/layout/layout.d.mts +0 -6
- package/api/layout/layout.mjs +0 -17
- package/api/layout/layout.test.mjs +0 -297
- package/api/layout/layout.type.d.mts +0 -90
- package/api/layout/layout.type.mjs +0 -104
- package/api/layout/layoutCheck.doc.d.mts +0 -11
- package/api/layout/layoutCheck.doc.mjs +0 -85
- package/api/layout/layoutExpand.doc.d.mts +0 -11
- package/api/layout/layoutExpand.doc.mjs +0 -107
- package/api/layout/layoutGrammar.doc.d.mts +0 -11
- package/api/layout/layoutGrammar.doc.mjs +0 -57
- package/api/theme/add/add.binary.test.mjs +0 -157
- package/api/theme/add/add.rollback.test.mjs +0 -158
- package/api/theme/add/add.staging.test.mjs +0 -83
- package/clients/cli/commands/layout-check.doc.mjs +0 -67
- package/clients/cli/commands/layout-expand.doc.mjs +0 -87
- package/clients/cli/commands/layout-grammar.doc.mjs +0 -32
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +0 -140
- package/clients/cli/commands/layout.doc.mjs +0 -36
- package/clients/cli/commands/layout.error-codes.test.mjs +0 -66
- package/clients/cli/commands/layout.exit-parity.test.mjs +0 -41
- package/clients/cli/commands/layout.expand-receipt.test.mjs +0 -94
- package/clients/cli/commands/layout.mjs +0 -327
- package/clients/cli/commands/layout.path-help.test.mjs +0 -33
- package/clients/cli/commands/layout.stdin-cap.test.mjs +0 -47
- package/clients/cli/commands/layout.text-fields.test.mjs +0 -39
|
@@ -8,26 +8,19 @@ export const doc = {
|
|
|
8
8
|
name: 'theme add',
|
|
9
9
|
displayName: 'astryx theme add',
|
|
10
10
|
namespace: 'cli/commands',
|
|
11
|
-
summary:
|
|
11
|
+
summary:
|
|
12
|
+
"Add a built theme to the app. To copy a theme's source as an editable fork, run `theme eject <slug> [path] [--overwrite]`.",
|
|
12
13
|
description:
|
|
13
|
-
|
|
14
|
+
"Records the theme in the generated app module and imports its built module and stylesheets. --import remains accepted as a compatibility no-op. To copy a theme's source as an editable fork, run `theme eject <slug> [path] [--overwrite]`. A bare command or --list delegates to themeListCopySources(), whose released JSON bytes stay unchanged while its text names the current add and eject commands; use --package when owners share a slug.",
|
|
14
15
|
fn: 'themeAdd',
|
|
15
|
-
args: [
|
|
16
|
-
{name: 'slug', param: 'slug', required: false},
|
|
17
|
-
{name: 'path', param: 'options.targetPath', required: false},
|
|
18
|
-
],
|
|
16
|
+
args: [{name: 'slug', param: 'slug', required: false}],
|
|
19
17
|
options: [
|
|
20
|
-
{
|
|
21
|
-
flag: '-f, --overwrite',
|
|
22
|
-
param: 'options.overwrite',
|
|
23
|
-
description: 'Replace copied files. Cannot be combined with --import',
|
|
24
|
-
},
|
|
25
18
|
{flag: '--list', description: 'List available themes'},
|
|
26
19
|
{
|
|
27
20
|
flag: '--import',
|
|
28
21
|
param: 'options.import',
|
|
29
22
|
description:
|
|
30
|
-
'
|
|
23
|
+
'Compatibility no-op; the built theme is added with or without this flag',
|
|
31
24
|
},
|
|
32
25
|
{
|
|
33
26
|
flag: '--package <package>',
|
|
@@ -37,19 +30,19 @@ export const doc = {
|
|
|
37
30
|
],
|
|
38
31
|
examples: [
|
|
39
32
|
{
|
|
40
|
-
label: '
|
|
41
|
-
cli: 'astryx theme add ocean
|
|
33
|
+
label: 'Add a built theme to the app',
|
|
34
|
+
cli: 'astryx theme add ocean',
|
|
42
35
|
},
|
|
43
36
|
{
|
|
44
37
|
label: 'Select a package theme over a local theme',
|
|
45
|
-
cli: 'astryx theme add ocean --
|
|
38
|
+
cli: 'astryx theme add ocean --package @acme/themes',
|
|
46
39
|
},
|
|
47
40
|
],
|
|
48
41
|
exitCodes: [
|
|
49
|
-
{code: 0, when: 'the theme is listed
|
|
42
|
+
{code: 0, when: 'the theme is listed or added'},
|
|
50
43
|
{
|
|
51
44
|
code: 1,
|
|
52
|
-
when: 'the theme, its
|
|
45
|
+
when: 'the theme, its built imports, its record, or the option combination is invalid',
|
|
53
46
|
},
|
|
54
47
|
],
|
|
55
48
|
related: ['theme list', 'theme remove', 'theme use', 'theme eject'],
|
|
@@ -29,7 +29,8 @@ describe('astryx theme list', () => {
|
|
|
29
29
|
expect(status).toBe(0);
|
|
30
30
|
expect(stdout).toMatch(/^slug:\s+neutral$/m);
|
|
31
31
|
expect(stdout).toMatch(/^package:\s+@astryxdesign\/cli$/m);
|
|
32
|
-
expect(stdout).toMatch(/Import one: .*theme add <slug
|
|
32
|
+
expect(stdout).toMatch(/Import one: .*theme add <slug>/m);
|
|
33
|
+
expect(stdout).not.toContain('theme add <slug> --import');
|
|
33
34
|
expect(stdout).toMatch(/Fork source: .*theme eject <slug>/m);
|
|
34
35
|
expect(stdout).toMatch(/More themes in packages you could add: .*discover theme$/m);
|
|
35
36
|
});
|
|
@@ -18,19 +18,21 @@ describe('astryx theme targets', () => {
|
|
|
18
18
|
|
|
19
19
|
expect(status).toBe(0);
|
|
20
20
|
// Inline layout: key component - props - states - className
|
|
21
|
-
expect(stdout).toMatch(
|
|
22
|
-
|
|
21
|
+
expect(stdout).toMatch(
|
|
22
|
+
/^switch\s+Switch - size - checked, disabled - astryx-switch$/m,
|
|
23
|
+
);
|
|
24
|
+
expect(stdout).toMatch(
|
|
25
|
+
/^switch-thumb\s+Switch - size - checked - astryx-switch-thumb$/m,
|
|
26
|
+
);
|
|
23
27
|
expect(stdout).toMatch(/4 across 1 component/);
|
|
24
28
|
});
|
|
25
29
|
|
|
26
|
-
it('
|
|
30
|
+
it('omits removed aliases from the target list', async () => {
|
|
27
31
|
const {status, stdout} = await runCli(['theme', 'targets', 'Popover']);
|
|
28
32
|
|
|
29
33
|
expect(status).toBe(0);
|
|
30
34
|
expect(stdout).toMatch(/^popover\s{2,}Popover/m);
|
|
31
|
-
expect(stdout).
|
|
32
|
-
/^popover-surface\s{2,}Popover - astryx-popover-surface - deprecated; use popover$/m,
|
|
33
|
-
);
|
|
35
|
+
expect(stdout).not.toContain('popover-surface');
|
|
34
36
|
});
|
|
35
37
|
|
|
36
38
|
it('lists the whole surface when unfiltered', async () => {
|
|
@@ -19,7 +19,7 @@ export const doc = {
|
|
|
19
19
|
'Writes theme.template.ts: the annotated reference for the whole theme surface, covering every ' +
|
|
20
20
|
'defineTheme field, the token families, the component override syntax, and how a theme is ' +
|
|
21
21
|
'consumed, naming the CLI command that prints the authoritative reference for each. Read ' +
|
|
22
|
-
'it, copy what you need into your own theme file, delete it. Use `theme add <slug
|
|
22
|
+
'it, copy what you need into your own theme file, delete it. Use `theme add <slug>` to ' +
|
|
23
23
|
'use an installed built theme, extend that theme for ordinary customization, or use ' +
|
|
24
24
|
'`theme eject <slug>` for a complete source fork. Leaves an existing file untouched unless --overwrite.',
|
|
25
25
|
fn: 'themeTemplate',
|
|
@@ -13,7 +13,7 @@ export const doc = {
|
|
|
13
13
|
namespace: 'cli/commands',
|
|
14
14
|
summary: 'Add, switch, build, and author themes',
|
|
15
15
|
description:
|
|
16
|
-
'The theme command group.
|
|
16
|
+
'The theme command group. Add built themes to an app, choose its default, remove them, list available and added themes, or eject source to make a local fork. The authoring commands build themes, generate palettes, write the annotated template, and list component theme targets.',
|
|
17
17
|
subcommands: [
|
|
18
18
|
'build',
|
|
19
19
|
'list',
|
|
@@ -27,7 +27,7 @@ export const doc = {
|
|
|
27
27
|
],
|
|
28
28
|
examples: [
|
|
29
29
|
{label: 'List available and added themes', cli: 'astryx theme list'},
|
|
30
|
-
{label: 'Import a theme into the app', cli: 'astryx theme add ocean
|
|
30
|
+
{label: 'Import a theme into the app', cli: 'astryx theme add ocean'},
|
|
31
31
|
{label: 'Choose the default', cli: 'astryx theme use ocean'},
|
|
32
32
|
{label: 'Fork source to customize', cli: 'astryx theme eject ocean'},
|
|
33
33
|
{
|
|
@@ -90,7 +90,7 @@ export const doc = {
|
|
|
90
90
|
flag: '--list',
|
|
91
91
|
param: 'options.list',
|
|
92
92
|
description:
|
|
93
|
-
'List available codemods and do nothing else. Every other flag is
|
|
93
|
+
'List available codemods and do nothing else. Every other flag is refused, as is --registry (exit 1)',
|
|
94
94
|
default: false,
|
|
95
95
|
},
|
|
96
96
|
],
|
|
@@ -79,22 +79,18 @@ const MIGRATION_FLAGS = [
|
|
|
79
79
|
describe('astryx upgrade flag interactions', () => {
|
|
80
80
|
it('--list: help says it ignores every other flag but --registry, and it does', async () => {
|
|
81
81
|
const options = await upgradeOptions();
|
|
82
|
-
expect(options['--list']).toMatch(/Every other flag is
|
|
82
|
+
expect(options['--list']).toMatch(/Every other flag is refused, as is --registry/);
|
|
83
83
|
|
|
84
84
|
installPackage('@astryxdesign/core', '0.6.0');
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
'--from',
|
|
88
|
-
'bogus',
|
|
89
|
-
'--codemod',
|
|
90
|
-
'bogus',
|
|
91
|
-
'--apply',
|
|
92
|
-
'--path',
|
|
93
|
-
'../outside',
|
|
94
|
-
]);
|
|
85
|
+
|
|
86
|
+
const listed = await upgradeJson(['--list']);
|
|
95
87
|
expect(listed.status).toBe(0);
|
|
96
88
|
expect(listed.envelope.type).toBe('upgrade.list');
|
|
97
89
|
|
|
90
|
+
const withFlags = await upgradeJson(['--list', '--from', 'bogus']);
|
|
91
|
+
expect(withFlags.status).toBe(1);
|
|
92
|
+
expect(withFlags.envelope.code).toBe('ERR_INVALID_ARGUMENT');
|
|
93
|
+
|
|
98
94
|
const refused = await upgradeJson(['--list', '--registry']);
|
|
99
95
|
expect(refused.status).toBe(1);
|
|
100
96
|
expect(refused.envelope.code).toBe('ERR_INVALID_ARGUMENT');
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
import {describe, it, expect, beforeEach, afterEach} from 'vitest';
|
|
3
|
+
import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path';
|
|
4
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
5
|
+
import {validateIntegration} from '../../../api/integration/validate-integration.mjs';
|
|
6
|
+
import {integrationTemplateConflicts, integrationComponentConflicts, integrationDocConflicts} from '../../../api/integration/authoring-checks.mjs';
|
|
7
|
+
let dir;
|
|
8
|
+
beforeEach(() => { dir = fs.mkdtempSync(path.join(os.tmpdir(),'astryx-val-')); });
|
|
9
|
+
afterEach(() => fs.rmSync(dir, {recursive:true,force:true}));
|
|
10
|
+
const json = async a => { const {status,stdout}=await runCli(['--json',...a],{cwd:dir}); return {status,body:JSON.parse(stdout)}; };
|
|
11
|
+
const text = async a => runCli(a, {cwd: dir});
|
|
12
|
+
|
|
13
|
+
describe('doctor integration validate exit codes (IFIX-0008)', () => {
|
|
14
|
+
it('exits 1 with no package.json (JSON has no_package issue)', async () => {
|
|
15
|
+
const {status, body} = await json(['doctor','integration','validate']);
|
|
16
|
+
expect(status).toBe(1);
|
|
17
|
+
expect(body.data.validated).toBe(false);
|
|
18
|
+
expect(body.data.issues).toEqual([
|
|
19
|
+
expect.objectContaining({code: 'no_package', severity: 'error'}),
|
|
20
|
+
]);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('text mode says no package.json when there is none', async () => {
|
|
24
|
+
const {status, stdout} = await text(['doctor','integration','validate']);
|
|
25
|
+
expect(status).toBe(1);
|
|
26
|
+
expect(stdout).toContain('no package.json found');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('exits 0 with package.json but no manifest (byte-identical to published)', async () => {
|
|
30
|
+
fs.writeFileSync(path.join(dir,'package.json'), JSON.stringify({name:'myapp',version:'1.0.0'}));
|
|
31
|
+
const {status, body} = await json(['doctor','integration','validate']);
|
|
32
|
+
expect(status).toBe(0);
|
|
33
|
+
expect(body.data).toEqual({validated: false, name: null, version: null, issues: []});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('text mode says no manifest when package.json exists', async () => {
|
|
37
|
+
fs.writeFileSync(path.join(dir,'package.json'), JSON.stringify({name:'myapp',version:'1.0.0'}));
|
|
38
|
+
const {status, stdout} = await text(['doctor','integration','validate']);
|
|
39
|
+
expect(status).toBe(0);
|
|
40
|
+
expect(stdout).toContain('no astryx.integration');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('exported API returns the no_package issue', async () => {
|
|
44
|
+
const result = await validateIntegration(undefined, {cwd: dir});
|
|
45
|
+
expect(result.type).toBe('integration.validate');
|
|
46
|
+
expect(result.data.validated).toBe(false);
|
|
47
|
+
expect(result.data.issues).toEqual([
|
|
48
|
+
expect.objectContaining({code: 'no_package', severity: 'error'}),
|
|
49
|
+
]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('integration verify exits 1 with a data envelope', async () => {
|
|
53
|
+
const {status, body} = await json(['integration','verify']);
|
|
54
|
+
expect(status).toBe(1);
|
|
55
|
+
expect(body.type).toBe('integration.pack-check');
|
|
56
|
+
expect(body.data.issues.some(i => i.code === 'no_package')).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('sibling commands stay unchanged with no package.json', async () => {
|
|
60
|
+
for (const sub of ['templates', 'components', 'docs']) {
|
|
61
|
+
const {status, body} = await json(['doctor','integration', sub]);
|
|
62
|
+
expect(status, `doctor integration ${sub}`).toBe(0);
|
|
63
|
+
expect(body.data.validated).toBe(false);
|
|
64
|
+
expect(body.data.issues).toEqual([]);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
package/clients/cli/index.mjs
CHANGED
|
@@ -107,9 +107,6 @@ export const JSON_SUPPORTED = new Set([
|
|
|
107
107
|
'doctor integration templates',
|
|
108
108
|
'doctor integration components',
|
|
109
109
|
'doctor integration docs',
|
|
110
|
-
'layout expand',
|
|
111
|
-
'layout check',
|
|
112
|
-
'layout grammar',
|
|
113
110
|
]);
|
|
114
111
|
|
|
115
112
|
/**
|
|
@@ -268,7 +265,6 @@ const commands = [
|
|
|
268
265
|
{name: 'gap-report', path: './commands/gap-report.mjs', register: 'registerGapReport'},
|
|
269
266
|
// agent-docs folded into init — functions still importable from agent-docs.mjs
|
|
270
267
|
{name: 'template', path: './commands/template.mjs', register: 'registerTemplate'},
|
|
271
|
-
{name: 'layout', path: './commands/layout.mjs', register: 'registerLayout'},
|
|
272
268
|
{name: 'upgrade', path: './commands/upgrade.mjs', register: 'registerUpgrade'},
|
|
273
269
|
{name: 'theme', path: './commands/build-theme.mjs', register: 'registerTheme'},
|
|
274
270
|
{name: 'integration', path: './commands/integration.mjs', register: 'registerIntegration'},
|
|
@@ -135,6 +135,25 @@ export function cliError(message, options = {}) {
|
|
|
135
135
|
return /** @type {never} */ (undefined);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Reject a positional argument the user typed as `""`.
|
|
140
|
+
*
|
|
141
|
+
* @param {string} name the argument as the help spells it, without brackets
|
|
142
|
+
* @param {unknown} value what Commander passed
|
|
143
|
+
* @param {string} command the command as a user types it, e.g. `astryx template`
|
|
144
|
+
* @returns {void} returns only when the argument is not an empty string
|
|
145
|
+
*/
|
|
146
|
+
export function rejectEmptyArgument(name, value, command) {
|
|
147
|
+
if (typeof value !== 'string' || value.length > 0) return;
|
|
148
|
+
cliError(
|
|
149
|
+
`Argument <${name}> is an empty string. ` +
|
|
150
|
+
'An empty argument is not the same as an omitted one, and ignoring it ' +
|
|
151
|
+
'would silently discard the rest of the command: pass a value, or leave ' +
|
|
152
|
+
`<${name}> out of \`${command}\` entirely.`,
|
|
153
|
+
{code: ERROR_CODES.ERR_INVALID_ARGUMENT},
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
138
157
|
/**
|
|
139
158
|
* Clean exit. Mostly a marker for intent — `process.exit(0)` works fine,
|
|
140
159
|
* but using cliExit at success boundaries makes greps for "exit policy"
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
* @file Component doc formatting — render ComponentDoc objects to text
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
discoverComponents,
|
|
9
|
+
findComponentReadme,
|
|
10
|
+
resolveImportPath,
|
|
11
|
+
} from '../../../foundation/discovery/component-discovery.mjs';
|
|
8
12
|
import {loadDocs} from '../../../foundation/discovery/component-loader.mjs';
|
|
9
13
|
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
10
14
|
|
|
@@ -26,15 +30,6 @@ function targetKey(target) {
|
|
|
26
30
|
return target.className.replace(/^astryx-/, '');
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
/**
|
|
30
|
-
* Keep deprecated targets visible in reference tables while excluding them from
|
|
31
|
-
* snippets readers copy into newly authored themes.
|
|
32
|
-
* @param {import('@astryxdesign/cli/authoring').ComponentThemingTarget[]} targets
|
|
33
|
-
*/
|
|
34
|
-
function canonicalTargets(targets) {
|
|
35
|
-
return targets.filter(target => target.deprecatedFor == null);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
33
|
/** @param {string} name @returns {string} */
|
|
39
34
|
function dataAttrForName(name) {
|
|
40
35
|
return `data-${name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()}`;
|
|
@@ -117,7 +112,9 @@ function formatSubComponent(comp) {
|
|
|
117
112
|
if (table) {
|
|
118
113
|
out.push(table + '\n');
|
|
119
114
|
} else {
|
|
120
|
-
out.push(
|
|
115
|
+
out.push(
|
|
116
|
+
`See \`${getCliInvocation()} component ${comp.name}\` for props and usage.\n`,
|
|
117
|
+
);
|
|
121
118
|
}
|
|
122
119
|
return out;
|
|
123
120
|
}
|
|
@@ -136,8 +133,10 @@ function getTargetVariants(target, docs) {
|
|
|
136
133
|
|
|
137
134
|
// If variant is a visualProp, try to resolve the actual variant values from props
|
|
138
135
|
if (target.visualProps.includes('variant')) {
|
|
139
|
-
const allProps = docs.props ||
|
|
140
|
-
const variantProp = allProps.find(
|
|
136
|
+
const allProps = docs.props || docs.components?.[0]?.props || [];
|
|
137
|
+
const variantProp = allProps.find(
|
|
138
|
+
(/** @type {any} */ p) => p.name === 'variant',
|
|
139
|
+
);
|
|
141
140
|
if (variantProp && variantProp.type.includes('|')) {
|
|
142
141
|
return variantProp.type
|
|
143
142
|
.replace(/['"]/g, '')
|
|
@@ -172,8 +171,12 @@ function formatTargetsTable(docs, themeData) {
|
|
|
172
171
|
|
|
173
172
|
/** @type {string[]} */
|
|
174
173
|
const lines = [];
|
|
175
|
-
lines.push(
|
|
176
|
-
|
|
174
|
+
lines.push(
|
|
175
|
+
'| Component class | Preferred data attributes | Props | States |',
|
|
176
|
+
);
|
|
177
|
+
lines.push(
|
|
178
|
+
'|-----------------|---------------------------|-------|--------|',
|
|
179
|
+
);
|
|
177
180
|
|
|
178
181
|
for (const target of docs.theming.targets) {
|
|
179
182
|
const coreVariants = getTargetVariants(target, docs);
|
|
@@ -194,11 +197,11 @@ function formatTargetsTable(docs, themeData) {
|
|
|
194
197
|
const statesStr = states.length > 0 ? states.join(', ') : '-';
|
|
195
198
|
const dataAttrs = getTargetDataAttributes(target);
|
|
196
199
|
const dataAttrsStr =
|
|
197
|
-
dataAttrs.length > 0
|
|
200
|
+
dataAttrs.length > 0
|
|
201
|
+
? dataAttrs.map(attr => `\`${attr}\``).join(', ')
|
|
202
|
+
: '-';
|
|
198
203
|
|
|
199
|
-
const className = target.
|
|
200
|
-
? `\`${target.className}\` _(deprecated; use \`${target.deprecatedFor}\`)_`
|
|
201
|
-
: `\`${target.className}\``;
|
|
204
|
+
const className = `\`${target.className}\``;
|
|
202
205
|
lines.push(
|
|
203
206
|
`| ${className} | ${dataAttrsStr} | ${variantsStr} | ${statesStr} |`,
|
|
204
207
|
);
|
|
@@ -229,7 +232,9 @@ export function formatFull(docs, options = {}) {
|
|
|
229
232
|
// agents to conflate the primary with a sub-component and hallucinate props
|
|
230
233
|
// (origin/main #2860). Bare name per the un-prefix migration (P5a).
|
|
231
234
|
const displayName = docs.name;
|
|
232
|
-
sections.push(
|
|
235
|
+
sections.push(
|
|
236
|
+
`**Import:** \`import {${displayName}} from '${options.importHint}';\`\n`,
|
|
237
|
+
);
|
|
233
238
|
}
|
|
234
239
|
|
|
235
240
|
if (docs.usage?.anatomy?.length) {
|
|
@@ -238,7 +243,9 @@ export function formatFull(docs, options = {}) {
|
|
|
238
243
|
sections.push('|---------|----------|-------------|');
|
|
239
244
|
for (const el of docs.usage.anatomy) {
|
|
240
245
|
const req = el.required ? 'Yes' : 'No';
|
|
241
|
-
sections.push(
|
|
246
|
+
sections.push(
|
|
247
|
+
`| ${mdCell(el.name)} | ${req} | ${mdCell(el.description)} |`,
|
|
248
|
+
);
|
|
242
249
|
}
|
|
243
250
|
sections.push('');
|
|
244
251
|
}
|
|
@@ -246,7 +253,7 @@ export function formatFull(docs, options = {}) {
|
|
|
246
253
|
if (docs.usage?.bestPractices?.length) {
|
|
247
254
|
sections.push('## Best Practices\n');
|
|
248
255
|
for (const bp of docs.usage.bestPractices) {
|
|
249
|
-
const badge = bp.guidance ? '**Do:**' :
|
|
256
|
+
const badge = bp.guidance ? '**Do:**' : "**Don't:**";
|
|
250
257
|
sections.push(`- ${badge} ${bp.description}`);
|
|
251
258
|
}
|
|
252
259
|
sections.push('');
|
|
@@ -283,24 +290,30 @@ export function formatFull(docs, options = {}) {
|
|
|
283
290
|
}
|
|
284
291
|
|
|
285
292
|
if (docs.theming) {
|
|
286
|
-
const {
|
|
293
|
+
const {themeData = null} = options;
|
|
287
294
|
sections.push('## Theming\n');
|
|
288
|
-
// Targets table with theme variant merging
|
|
295
|
+
// Targets table with theme variant merging
|
|
289
296
|
if (docs.theming.targets?.length) {
|
|
290
297
|
const targetsTable = formatTargetsTable(docs, themeData);
|
|
291
298
|
sections.push(targetsTable + '\n');
|
|
292
299
|
|
|
293
300
|
// Note about theme variants if any are present
|
|
294
301
|
if (themeData?.variants) {
|
|
295
|
-
const componentKeys = docs.theming.targets.map((/** @type {any} */ t) =>
|
|
296
|
-
|
|
302
|
+
const componentKeys = docs.theming.targets.map((/** @type {any} */ t) =>
|
|
303
|
+
targetKey(t),
|
|
304
|
+
);
|
|
305
|
+
const hasThemeVariants = componentKeys.some(
|
|
306
|
+
(/** @type {any} */ k) => themeData.variants[k]?.length > 0,
|
|
307
|
+
);
|
|
297
308
|
if (hasThemeVariants) {
|
|
298
|
-
sections.push(
|
|
309
|
+
sections.push(
|
|
310
|
+
`_\\* = custom variant from ${themeData.name || 'active'} theme_\n`,
|
|
311
|
+
);
|
|
299
312
|
}
|
|
300
313
|
}
|
|
301
314
|
|
|
302
315
|
// Generate defineTheme example with canonical component selectors only.
|
|
303
|
-
const exampleTargets =
|
|
316
|
+
const exampleTargets = docs.theming.targets;
|
|
304
317
|
if (exampleTargets.length > 0) {
|
|
305
318
|
const exampleLines = ['Override in defineTheme:\n```ts\ncomponents: {'];
|
|
306
319
|
const rootTarget = exampleTargets[0];
|
|
@@ -309,7 +322,9 @@ export function formatFull(docs, options = {}) {
|
|
|
309
322
|
exampleLines.push(` base: { /* CSS properties */ },`);
|
|
310
323
|
if (rootTarget.visualProps?.length) {
|
|
311
324
|
const firstVariant = rootTarget.visualProps[0];
|
|
312
|
-
exampleLines.push(
|
|
325
|
+
exampleLines.push(
|
|
326
|
+
` '${firstVariant}:value': { /* variant-specific */ },`,
|
|
327
|
+
);
|
|
313
328
|
}
|
|
314
329
|
if (rootTarget.states?.length) {
|
|
315
330
|
const firstState = rootTarget.states[0];
|
|
@@ -339,10 +354,14 @@ export function formatFull(docs, options = {}) {
|
|
|
339
354
|
|
|
340
355
|
// Component CSS vars — split into public (directly settable) and private (set via derived)
|
|
341
356
|
if (docs.theming?.vars?.length) {
|
|
342
|
-
const publicVars = docs.theming.vars.filter(
|
|
357
|
+
const publicVars = docs.theming.vars.filter(
|
|
358
|
+
(/** @type {any} */ v) => !v.private && !v.derived,
|
|
359
|
+
);
|
|
343
360
|
|
|
344
361
|
if (publicVars.length > 0) {
|
|
345
|
-
sections.push(
|
|
362
|
+
sections.push(
|
|
363
|
+
'**Themeable CSS variables** - additional properties that can be overridden in `defineTheme` component overrides.\n',
|
|
364
|
+
);
|
|
346
365
|
const varLines = [];
|
|
347
366
|
varLines.push('| CSS Variable | Default | Description |');
|
|
348
367
|
varLines.push('|-------------|---------|-------------|');
|
|
@@ -356,25 +375,37 @@ export function formatFull(docs, options = {}) {
|
|
|
356
375
|
|
|
357
376
|
// Show derived property examples — the recommended way to theme
|
|
358
377
|
if (docs.theming?.derived?.length) {
|
|
359
|
-
const canonical =
|
|
360
|
-
const varsKey = canonical.length
|
|
378
|
+
const canonical = docs.theming.targets || [];
|
|
379
|
+
const varsKey = canonical.length
|
|
380
|
+
? targetKey(canonical[0])
|
|
381
|
+
: docs.theming.componentKey || '';
|
|
361
382
|
const derivedExamples = docs.theming.derived
|
|
362
383
|
.filter((/** @type {any} */ d) => d.vars?.length)
|
|
363
384
|
.map((/** @type {any} */ d) => ` ${d.property}: '...',`)
|
|
364
385
|
.join('\n');
|
|
365
386
|
const expandExamples = docs.theming.derived
|
|
366
387
|
.filter((/** @type {any} */ d) => d.expand === 'container')
|
|
367
|
-
.map(
|
|
388
|
+
.map(
|
|
389
|
+
(/** @type {any} */ d) =>
|
|
390
|
+
` ${d.property}: '...', // expands to container layout tokens`,
|
|
391
|
+
)
|
|
392
|
+
.join('\n');
|
|
393
|
+
const allExamples = [derivedExamples, expandExamples]
|
|
394
|
+
.filter(Boolean)
|
|
368
395
|
.join('\n');
|
|
369
|
-
const allExamples = [derivedExamples, expandExamples].filter(Boolean).join('\n');
|
|
370
396
|
if (allExamples) {
|
|
371
|
-
sections.push(
|
|
397
|
+
sections.push(
|
|
398
|
+
'Some properties are set via standard CSS in component overrides:\n```ts\ncomponents: {\n ' +
|
|
399
|
+
varsKey +
|
|
400
|
+
': {\n base: {\n' +
|
|
401
|
+
allExamples +
|
|
402
|
+
'\n },\n },\n}\n```\n',
|
|
403
|
+
);
|
|
372
404
|
}
|
|
373
405
|
}
|
|
374
406
|
}
|
|
375
407
|
}
|
|
376
408
|
|
|
377
|
-
|
|
378
409
|
return sections.join('\n');
|
|
379
410
|
}
|
|
380
411
|
|
|
@@ -401,21 +432,29 @@ export function formatCompact(docs, componentName, importHint) {
|
|
|
401
432
|
sections.push(desc + '\n');
|
|
402
433
|
|
|
403
434
|
if (docs.usage?.anatomy?.length) {
|
|
404
|
-
sections.push(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
435
|
+
sections.push(
|
|
436
|
+
'Anatomy: ' +
|
|
437
|
+
docs.usage.anatomy
|
|
438
|
+
.map((/** @type {any} */ el) => {
|
|
439
|
+
const req = el.required ? '' : ' (optional)';
|
|
440
|
+
return `${el.name}${req}`;
|
|
441
|
+
})
|
|
442
|
+
.join(', ') +
|
|
443
|
+
'\n',
|
|
444
|
+
);
|
|
408
445
|
}
|
|
409
446
|
|
|
410
447
|
if (importHint) {
|
|
411
448
|
sections.push('## Import\n');
|
|
412
|
-
sections.push(
|
|
449
|
+
sections.push(
|
|
450
|
+
`\`\`\`tsx\nimport { ${displayName} } from '${importHint}';\n\`\`\`\n`,
|
|
451
|
+
);
|
|
413
452
|
}
|
|
414
453
|
|
|
415
454
|
if (docs.usage?.bestPractices?.length) {
|
|
416
455
|
sections.push('## Best Practices\n');
|
|
417
456
|
for (const bp of docs.usage.bestPractices) {
|
|
418
|
-
const badge = bp.guidance ? '**Do:**' :
|
|
457
|
+
const badge = bp.guidance ? '**Do:**' : "**Don't:**";
|
|
419
458
|
sections.push(`- ${badge} ${bp.description}`);
|
|
420
459
|
}
|
|
421
460
|
sections.push('');
|
|
@@ -453,7 +492,12 @@ export function formatCompact(docs, componentName, importHint) {
|
|
|
453
492
|
propLines.push('| CSS Property | Sets |');
|
|
454
493
|
propLines.push('|-------------|------|');
|
|
455
494
|
for (const d of docs.theming.derived) {
|
|
456
|
-
const target =
|
|
495
|
+
const target =
|
|
496
|
+
d.expand === 'container'
|
|
497
|
+
? 'container layout tokens'
|
|
498
|
+
: (d.vars || [])
|
|
499
|
+
.map((/** @type {any} */ v) => `\`${mdCell(v)}\``)
|
|
500
|
+
.join(', ');
|
|
457
501
|
propLines.push(`| \`${mdCell(d.property)}\` | ${target} |`);
|
|
458
502
|
}
|
|
459
503
|
sections.push(propLines.join('\n') + '\n');
|
|
@@ -504,7 +548,9 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
|
|
|
504
548
|
if ('props' in docs) {
|
|
505
549
|
props = docs.props;
|
|
506
550
|
} else if ('components' in docs) {
|
|
507
|
-
const entry = docs.components.find(
|
|
551
|
+
const entry = docs.components.find(
|
|
552
|
+
(/** @type {any} */ c) => c.name === displayName,
|
|
553
|
+
);
|
|
508
554
|
if (entry) {
|
|
509
555
|
props = entry.props;
|
|
510
556
|
description = entry.description;
|
|
@@ -549,9 +595,7 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
|
|
|
549
595
|
// Description (shortened)
|
|
550
596
|
if (description) {
|
|
551
597
|
const shortDesc =
|
|
552
|
-
description.length > 80
|
|
553
|
-
? description.slice(0, 77) + '...'
|
|
554
|
-
: description;
|
|
598
|
+
description.length > 80 ? description.slice(0, 77) + '...' : description;
|
|
555
599
|
output.push(` ${shortDesc}`);
|
|
556
600
|
}
|
|
557
601
|
|
|
@@ -569,25 +613,33 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
|
|
|
569
613
|
// Derived properties (if any)
|
|
570
614
|
if (docs.theming?.derived?.length) {
|
|
571
615
|
const derivedNames = docs.theming.derived
|
|
572
|
-
.map((/** @type {any} */ d) =>
|
|
616
|
+
.map((/** @type {any} */ d) =>
|
|
617
|
+
d.expand === 'container'
|
|
618
|
+
? `${d.property} -> container tokens`
|
|
619
|
+
: `${d.property} -> ${(d.vars || []).join(', ')}`,
|
|
620
|
+
)
|
|
573
621
|
.join('; ');
|
|
574
622
|
output.push(` Derived: ${derivedNames}`);
|
|
575
623
|
}
|
|
576
624
|
|
|
577
|
-
// Theme targets (component class, preferred data attrs, props, states) with theme variant merging
|
|
625
|
+
// Theme targets (component class, preferred data attrs, props, states) with theme variant merging
|
|
578
626
|
if (docs.theming?.targets?.length) {
|
|
579
|
-
const {
|
|
627
|
+
const {themeData = null} = options;
|
|
580
628
|
const targetParts = docs.theming.targets.map((/** @type {any} */ t) => {
|
|
581
629
|
const parts = [t.className];
|
|
582
|
-
if (t.deprecatedFor) parts.push(`deprecated->${t.deprecatedFor}`);
|
|
583
630
|
const dataAttrs = getTargetDataAttributes(t);
|
|
584
|
-
if (dataAttrs.length)
|
|
585
|
-
|
|
631
|
+
if (dataAttrs.length)
|
|
632
|
+
parts.push(`preferred attrs: ${dataAttrs.join(', ')}`);
|
|
633
|
+
if (t.visualProps?.length)
|
|
634
|
+
parts.push(`variants: ${t.visualProps.join(', ')}`);
|
|
586
635
|
if (t.states?.length) parts.push(`states: ${t.states.join(', ')}`);
|
|
587
636
|
// Merge theme variants
|
|
588
637
|
const componentKey = targetKey(t);
|
|
589
638
|
const themeVars = themeData?.variants?.[componentKey];
|
|
590
|
-
if (themeVars?.length)
|
|
639
|
+
if (themeVars?.length)
|
|
640
|
+
parts.push(
|
|
641
|
+
`theme: ${themeVars.map((/** @type {any} */ v) => v + '*').join(', ')}`,
|
|
642
|
+
);
|
|
591
643
|
return parts.join(' ');
|
|
592
644
|
});
|
|
593
645
|
output.push(` Targets: ${targetParts.join(' | ')}`);
|
|
@@ -602,7 +654,9 @@ export function formatBrief(docs, componentName, importHint, options = {}) {
|
|
|
602
654
|
if (examples.length > 0) {
|
|
603
655
|
const code = examples[0].code;
|
|
604
656
|
const codeLine =
|
|
605
|
-
code
|
|
657
|
+
code
|
|
658
|
+
.split('\n')
|
|
659
|
+
.find((/** @type {string} */ l) => l.trim().startsWith('<XDS')) ||
|
|
606
660
|
code.split('\n')[0];
|
|
607
661
|
output.push(` ${codeLine.trim()}`);
|
|
608
662
|
}
|
|
@@ -682,7 +736,7 @@ export async function formatBriefAll(
|
|
|
682
736
|
if (readmePath && readmePath.endsWith('.doc.mjs')) {
|
|
683
737
|
const docs = await loadDocs(readmePath, {zh, lang});
|
|
684
738
|
const importPath = resolveImportPath(coreDir, comp);
|
|
685
|
-
output.push(formatBrief(docs, comp, importPath, {
|
|
739
|
+
output.push(formatBrief(docs, comp, importPath, {themeData}));
|
|
686
740
|
} else {
|
|
687
741
|
output.push(`${comp}\n (no docs)\n`);
|
|
688
742
|
}
|