@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
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file FunctionDoc for `layoutExpand()` / `astryx layout expand`. Colocated
|
|
5
|
-
* with the API function it documents; the response-shape source of truth stays
|
|
6
|
-
* in `layout.type.mjs`.
|
|
7
|
-
* @position packages/cli/api/layout — function documentation
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
|
|
11
|
-
export const doc = {
|
|
12
|
-
type: 'function',
|
|
13
|
-
kind: 'api',
|
|
14
|
-
name: 'layoutExpand',
|
|
15
|
-
namespace: 'cli/api',
|
|
16
|
-
displayName: 'layoutExpand()',
|
|
17
|
-
summary: 'Expand a validated layout expression into XDS TSX.',
|
|
18
|
-
description:
|
|
19
|
-
'The generator behind `astryx layout expand`. Parses and validates a compressed XLE/XLO ' +
|
|
20
|
-
'expression, then expands it into ready-to-use XDS TSX, auto-routing structural children ' +
|
|
21
|
-
'into the right slots, scaffolding typed useState for interactive controls, and splicing or ' +
|
|
22
|
-
'importing any referenced template blocks. Returns the code (and metadata) in a layout.expand ' +
|
|
23
|
-
'envelope, optionally writing it to a path within cwd. **Deprecated (DEP-0006).** Use `build`, `template`, and `docs layout` instead. This function will be removed in a future minor release.',
|
|
24
|
-
importPath: '@astryxdesign/cli/api',
|
|
25
|
-
signature:
|
|
26
|
-
'layoutExpand(expression: string, options?: LayoutExpandOptions): Promise<LayoutExpandResponse>',
|
|
27
|
-
keywords: ['layout', 'expand', 'xle', 'xlo', 'tsx', 'scaffold', 'generate'],
|
|
28
|
-
params: [
|
|
29
|
-
{
|
|
30
|
-
name: 'expression',
|
|
31
|
-
type: 'string',
|
|
32
|
-
description:
|
|
33
|
-
'The layout expression to expand (XLE compact or XLO outline form).',
|
|
34
|
-
required: true,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: 'options.targetPath',
|
|
38
|
-
type: 'string',
|
|
39
|
-
description:
|
|
40
|
-
'Write the generated TSX here (validated to stay within cwd). A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is used as-is; any other path is a directory that gets <name>.tsx. An existing file is replaced. Omit to return the code without writing.',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'options.form',
|
|
44
|
-
type: "'compact' | 'outline' | 'auto'",
|
|
45
|
-
description:
|
|
46
|
-
'Force which input surface the expression is parsed as, or auto-detect it.',
|
|
47
|
-
default: "'auto'",
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: 'options.loose',
|
|
51
|
-
type: 'boolean',
|
|
52
|
-
description:
|
|
53
|
-
'Downgrade unknown {hint} references to TODO warnings instead of hard errors.',
|
|
54
|
-
default: 'false',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: 'options.name',
|
|
58
|
-
type: 'string',
|
|
59
|
-
description: 'PascalCase name for the generated component.',
|
|
60
|
-
default: "'GeneratedLayout'",
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: 'options.cwd',
|
|
64
|
-
type: 'string',
|
|
65
|
-
description:
|
|
66
|
-
'Directory the block catalog, registry, and target path resolve against.',
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
returns: [
|
|
70
|
-
{
|
|
71
|
-
type: 'layout.expand',
|
|
72
|
-
description:
|
|
73
|
-
'The expansion: the parsed form, the generated TSX code, componentsUsed, states (count of useState hooks scaffolded), todos, blocksReferenced (each {name, mode}), warnings, written (the relative output path, or null when nothing was written), and demoMediaReplaced (how many Astryx demo media references in the spliced template blocks, such as images, posters and videos, were replaced with placeholders for you to swap for your own media).',
|
|
74
|
-
},
|
|
75
|
-
],
|
|
76
|
-
throws: [
|
|
77
|
-
{
|
|
78
|
-
code: 'ERR_INVALID_ARGUMENT',
|
|
79
|
-
when: 'the expression is empty, or name is not a PascalCase identifier',
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
code: 'ERR_INVALID_OPTION',
|
|
83
|
-
when: 'form is not one of "compact", "outline", or "auto"',
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
code: 'ERR_LAYOUT_PARSE',
|
|
87
|
-
when: 'the expression has a syntax error (reported with line/col)',
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
code: 'ERR_LAYOUT_INVALID',
|
|
91
|
-
when: 'the expression parses but fails validation (unknown component/prop/enum/block)',
|
|
92
|
-
},
|
|
93
|
-
{code: 'ERR_PATH_TRAVERSAL', when: 'the target path escapes cwd'},
|
|
94
|
-
],
|
|
95
|
-
examples: [
|
|
96
|
-
{
|
|
97
|
-
label: 'Expand to TSX',
|
|
98
|
-
code: 'const r = await layoutExpand(\'VStack[g4] > Heading"Title" + Text"Body"\');',
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
label: 'Write to a file',
|
|
102
|
-
code: "await layoutExpand('Card > Text\"Hi\"', {targetPath: 'src/Generated.tsx', name: 'Generated'});",
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
command: 'layout expand',
|
|
106
|
-
related: ['layoutCheck', 'layoutGrammar'],
|
|
107
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
|
-
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @file FunctionDoc for `layoutGrammar()` / `astryx layout grammar`. Colocated
|
|
6
|
-
* with the API function it documents; the response-shape source of truth stays
|
|
7
|
-
* in `layout.type.mjs`.
|
|
8
|
-
* @position packages/cli/api/layout — function documentation
|
|
9
|
-
*/
|
|
10
|
-
/** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
|
|
11
|
-
export const doc: import("@astryxdesign/cli/authoring").FunctionDoc;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file FunctionDoc for `layoutGrammar()` / `astryx layout grammar`. Colocated
|
|
5
|
-
* with the API function it documents; the response-shape source of truth stays
|
|
6
|
-
* in `layout.type.mjs`.
|
|
7
|
-
* @position packages/cli/api/layout — function documentation
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/** @type {import('@astryxdesign/cli/authoring').FunctionDoc} */
|
|
11
|
-
export const doc = {
|
|
12
|
-
type: 'function',
|
|
13
|
-
kind: 'api',
|
|
14
|
-
name: 'layoutGrammar',
|
|
15
|
-
namespace: 'cli/api',
|
|
16
|
-
displayName: 'layoutGrammar()',
|
|
17
|
-
summary: 'Return the XLE/XLO grammar cheatsheet for this install.',
|
|
18
|
-
description:
|
|
19
|
-
'The reference behind `astryx layout grammar`: the agent cheatsheet for writing XLE/XLO ' +
|
|
20
|
-
"layout expressions, with the alias table generated from this branch's registry rather than " +
|
|
21
|
-
'hand-maintained, so short names always reflect the components actually installed. **Deprecated (DEP-0006).** Use `build`, `template`, and `docs layout` instead. This function will be removed in a future minor release.',
|
|
22
|
-
importPath: '@astryxdesign/cli/api',
|
|
23
|
-
signature:
|
|
24
|
-
'layoutGrammar(options?: LayoutGrammarOptions): Promise<LayoutGrammarResponse>',
|
|
25
|
-
keywords: [
|
|
26
|
-
'layout',
|
|
27
|
-
'grammar',
|
|
28
|
-
'cheatsheet',
|
|
29
|
-
'xle',
|
|
30
|
-
'xlo',
|
|
31
|
-
'aliases',
|
|
32
|
-
'reference',
|
|
33
|
-
],
|
|
34
|
-
params: [
|
|
35
|
-
{
|
|
36
|
-
name: 'options.cwd',
|
|
37
|
-
type: 'string',
|
|
38
|
-
description:
|
|
39
|
-
'Directory the component registry (and its alias table) resolves against.',
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
returns: [
|
|
43
|
-
{
|
|
44
|
-
type: 'layout.grammar',
|
|
45
|
-
description:
|
|
46
|
-
"The cheatsheet: a text field with the full grammar reference, plus an aliases map (short name → canonical component) generated from this install's registry.",
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
examples: [
|
|
50
|
-
{
|
|
51
|
-
label: 'Get the cheatsheet',
|
|
52
|
-
code: 'const {data} = await layoutGrammar();',
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
command: 'layout grammar',
|
|
56
|
-
related: ['layoutExpand', 'layoutCheck'],
|
|
57
|
-
};
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
4
|
-
import * as fs from 'node:fs';
|
|
5
|
-
import * as os from 'node:os';
|
|
6
|
-
import * as path from 'node:path';
|
|
7
|
-
import {themeAdd} from './add.mjs';
|
|
8
|
-
import {themeEject} from '../eject/eject.mjs';
|
|
9
|
-
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
10
|
-
|
|
11
|
-
const HEADER = '// Copyright (c) Meta Platforms, Inc. and affiliates.\n\n';
|
|
12
|
-
|
|
13
|
-
let tmpDir;
|
|
14
|
-
|
|
15
|
-
/** Every byte value, so any lossy text decoding shows up as a changed file. */
|
|
16
|
-
const FONT_BYTES = Buffer.concat([
|
|
17
|
-
Buffer.from('wOF2'),
|
|
18
|
-
Buffer.from(Array.from({length: 256}, (_, byte) => byte)),
|
|
19
|
-
]);
|
|
20
|
-
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-themeadd-binary-'));
|
|
23
|
-
fs.writeFileSync(
|
|
24
|
-
path.join(tmpDir, 'package.json'),
|
|
25
|
-
JSON.stringify({
|
|
26
|
-
name: 'consumer',
|
|
27
|
-
dependencies: {'@acme/themes': '^1.0.0'},
|
|
28
|
-
}),
|
|
29
|
-
);
|
|
30
|
-
const packageDir = path.join(tmpDir, 'node_modules', '@acme', 'themes');
|
|
31
|
-
const themeDir = path.join(packageDir, 'themes', 'ocean');
|
|
32
|
-
fs.mkdirSync(path.join(themeDir, 'fonts'), {recursive: true});
|
|
33
|
-
fs.mkdirSync(path.join(themeDir, 'tokens'), {recursive: true});
|
|
34
|
-
fs.writeFileSync(
|
|
35
|
-
path.join(packageDir, 'package.json'),
|
|
36
|
-
JSON.stringify({name: '@acme/themes', version: '1.0.0'}),
|
|
37
|
-
);
|
|
38
|
-
fs.writeFileSync(
|
|
39
|
-
path.join(packageDir, 'astryx.integration.mjs'),
|
|
40
|
-
"export default {themes: './themes'};\n",
|
|
41
|
-
);
|
|
42
|
-
fs.writeFileSync(
|
|
43
|
-
path.join(themeDir, 'oceanTheme.doc.mjs'),
|
|
44
|
-
`/** @type {import('@astryxdesign/cli/authoring').ThemeDoc} */
|
|
45
|
-
export default {type: 'theme', name: 'ocean', displayName: 'Ocean', description: 'Integration theme that ships a font.', maintained: true};
|
|
46
|
-
`,
|
|
47
|
-
);
|
|
48
|
-
fs.writeFileSync(
|
|
49
|
-
path.join(themeDir, 'oceanTheme.ts'),
|
|
50
|
-
`${HEADER}export const oceanTheme = {};\n`,
|
|
51
|
-
);
|
|
52
|
-
fs.writeFileSync(
|
|
53
|
-
path.join(themeDir, 'icons.tsx'),
|
|
54
|
-
'export const oceanIcons = {};\n',
|
|
55
|
-
);
|
|
56
|
-
fs.writeFileSync(path.join(themeDir, 'fonts', 'ocean.woff2'), FONT_BYTES);
|
|
57
|
-
fs.writeFileSync(
|
|
58
|
-
path.join(themeDir, 'tokens', 'colors.ts'),
|
|
59
|
-
"export const oceanBlue = '#0064e0';\n",
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
afterEach(() => {
|
|
64
|
-
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe('themeAdd keeps the released source-copy inventory', () => {
|
|
68
|
-
it('copies binary bytes and the integration authoring descriptor', async () => {
|
|
69
|
-
const result = await themeAdd('ocean', {
|
|
70
|
-
cwd: tmpDir,
|
|
71
|
-
package: '@acme/themes',
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
expect(result.data.files).toEqual([
|
|
75
|
-
'oceanTheme.ts',
|
|
76
|
-
'fonts/ocean.woff2',
|
|
77
|
-
'icons.tsx',
|
|
78
|
-
'oceanTheme.doc.mjs',
|
|
79
|
-
'tokens/colors.ts',
|
|
80
|
-
]);
|
|
81
|
-
const copied = fs.readFileSync(
|
|
82
|
-
path.join(tmpDir, 'src', 'themes', 'ocean', 'fonts', 'ocean.woff2'),
|
|
83
|
-
);
|
|
84
|
-
expect(copied.equals(FONT_BYTES)).toBe(true);
|
|
85
|
-
expect(
|
|
86
|
-
fs.readFileSync(
|
|
87
|
-
path.join(tmpDir, 'src', 'themes', 'ocean', 'oceanTheme.doc.mjs'),
|
|
88
|
-
'utf-8',
|
|
89
|
-
),
|
|
90
|
-
).toContain("name: 'ocean'");
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('keeps the released nested order in CLI JSON, text, and copied files', async () => {
|
|
94
|
-
const expected = [
|
|
95
|
-
'oceanTheme.ts',
|
|
96
|
-
'fonts/ocean.woff2',
|
|
97
|
-
'icons.tsx',
|
|
98
|
-
'oceanTheme.doc.mjs',
|
|
99
|
-
'tokens/colors.ts',
|
|
100
|
-
];
|
|
101
|
-
const json = await runCli(
|
|
102
|
-
['theme', 'add', 'ocean', '--package', '@acme/themes', '--json'],
|
|
103
|
-
tmpDir,
|
|
104
|
-
);
|
|
105
|
-
expect(json.status, json.stderr).toBe(0);
|
|
106
|
-
expect(JSON.parse(json.stdout).data.files).toEqual(expected);
|
|
107
|
-
for (const file of expected) {
|
|
108
|
-
expect(
|
|
109
|
-
fs.existsSync(path.join(tmpDir, 'src', 'themes', 'ocean', file)),
|
|
110
|
-
).toBe(true);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
fs.rmSync(path.join(tmpDir, 'src'), {recursive: true, force: true});
|
|
114
|
-
const text = await runCli(
|
|
115
|
-
['theme', 'add', 'ocean', '--package', '@acme/themes'],
|
|
116
|
-
tmpDir,
|
|
117
|
-
);
|
|
118
|
-
expect(text.status, text.stderr).toBe(0);
|
|
119
|
-
const positions = expected.map(file =>
|
|
120
|
-
text.stdout.indexOf(`src/themes/ocean/${file}`),
|
|
121
|
-
);
|
|
122
|
-
expect(positions.every(position => position >= 0)).toBe(true);
|
|
123
|
-
expect(positions).toEqual([...positions].sort((a, b) => a - b));
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
describe('themeEject copies every file of the theme', () => {
|
|
128
|
-
it('copies a binary file byte for byte', async () => {
|
|
129
|
-
const result = await themeEject('ocean', {
|
|
130
|
-
cwd: tmpDir,
|
|
131
|
-
package: '@acme/themes',
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
expect(result.data.files).toEqual([
|
|
135
|
-
'oceanTheme.ts',
|
|
136
|
-
'oceanTheme.doc.mjs',
|
|
137
|
-
'fonts/ocean.woff2',
|
|
138
|
-
'icons.tsx',
|
|
139
|
-
'tokens/colors.ts',
|
|
140
|
-
]);
|
|
141
|
-
const copied = fs.readFileSync(
|
|
142
|
-
path.join(tmpDir, 'src', 'themes', 'ocean', 'fonts', 'ocean.woff2'),
|
|
143
|
-
);
|
|
144
|
-
expect(copied.equals(FONT_BYTES)).toBe(true);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('still strips the repo header from a text source', async () => {
|
|
148
|
-
await themeEject('ocean', {cwd: tmpDir, package: '@acme/themes'});
|
|
149
|
-
|
|
150
|
-
expect(
|
|
151
|
-
fs.readFileSync(
|
|
152
|
-
path.join(tmpDir, 'src', 'themes', 'ocean', 'oceanTheme.ts'),
|
|
153
|
-
'utf-8',
|
|
154
|
-
),
|
|
155
|
-
).toBe('export const oceanTheme = {};\n');
|
|
156
|
-
});
|
|
157
|
-
});
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* `theme eject` writes a theme as one transaction: when a later file fails to
|
|
5
|
-
* publish, every file it already replaced gets its previous bytes back and
|
|
6
|
-
* every file it created is removed. Publishing is forced to fail by wrapping
|
|
7
|
-
* the two calls that publish a staged file: `linkSync` for a new file and
|
|
8
|
-
* `renameSync` for a replacement.
|
|
9
|
-
*
|
|
10
|
-
* Separate file because vi.mock is hoisted and affects the whole module.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
|
14
|
-
import * as os from 'node:os';
|
|
15
|
-
import * as path from 'node:path';
|
|
16
|
-
|
|
17
|
-
const failures = vi.hoisted(() => ({
|
|
18
|
-
/** Fail the Nth staged-file publish (1-based); 0 disables. */
|
|
19
|
-
publish: 0,
|
|
20
|
-
/** Also fail every rollback restore. */
|
|
21
|
-
restore: false,
|
|
22
|
-
count: 0,
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
vi.mock('node:fs', async importOriginal => {
|
|
26
|
-
const actual = /** @type {typeof import('node:fs')} */ (
|
|
27
|
-
await importOriginal()
|
|
28
|
-
);
|
|
29
|
-
/** @param {string} source */
|
|
30
|
-
const isStaged = source => path.basename(String(source)).includes('.tmp');
|
|
31
|
-
/** @param {string} source */
|
|
32
|
-
const isRestore = source =>
|
|
33
|
-
path.basename(String(source)).includes('.restore-');
|
|
34
|
-
/** @param {string} source @param {string} op */
|
|
35
|
-
const maybeFail = (source, op) => {
|
|
36
|
-
if (isStaged(source) && failures.publish > 0) {
|
|
37
|
-
failures.count++;
|
|
38
|
-
if (failures.count === failures.publish) {
|
|
39
|
-
throw Object.assign(new Error(`EIO: forced ${op} failure`), {
|
|
40
|
-
code: 'EIO',
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (isRestore(source) && failures.restore) {
|
|
45
|
-
throw Object.assign(new Error(`EIO: forced restore failure`), {
|
|
46
|
-
code: 'EIO',
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
return {
|
|
51
|
-
...actual,
|
|
52
|
-
linkSync: vi.fn((source, destination) => {
|
|
53
|
-
maybeFail(source, 'link');
|
|
54
|
-
return actual.linkSync(source, destination);
|
|
55
|
-
}),
|
|
56
|
-
renameSync: vi.fn((source, destination) => {
|
|
57
|
-
maybeFail(source, 'rename');
|
|
58
|
-
return actual.renameSync(source, destination);
|
|
59
|
-
}),
|
|
60
|
-
};
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const fs = await import('node:fs');
|
|
64
|
-
const {themeEject} = await import('../eject/eject.mjs');
|
|
65
|
-
const {listThemes} = await import('../_adapter.mjs');
|
|
66
|
-
|
|
67
|
-
let tmpDir;
|
|
68
|
-
|
|
69
|
-
beforeEach(() => {
|
|
70
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-themeeject-rollback-'));
|
|
71
|
-
failures.publish = 0;
|
|
72
|
-
failures.restore = false;
|
|
73
|
-
failures.count = 0;
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
afterEach(() => {
|
|
77
|
-
failures.publish = 0;
|
|
78
|
-
failures.restore = false;
|
|
79
|
-
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
function stoneFiles() {
|
|
83
|
-
const theme = listThemes().find(entry => entry.slug === 'stone');
|
|
84
|
-
if (!theme) throw new Error('missing bundled theme stone');
|
|
85
|
-
expect(theme.files.length).toBeGreaterThanOrEqual(2);
|
|
86
|
-
return theme.files.map(name =>
|
|
87
|
-
path.join(tmpDir, 'src', 'themes', 'stone', name),
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** Entries staging or rollback left behind in the theme directory. */
|
|
92
|
-
function strays() {
|
|
93
|
-
const dir = path.join(tmpDir, 'src', 'themes', 'stone');
|
|
94
|
-
if (!fs.existsSync(dir)) return [];
|
|
95
|
-
return fs
|
|
96
|
-
.readdirSync(dir, {recursive: true})
|
|
97
|
-
.map(String)
|
|
98
|
-
.filter(name => name.includes('.tmp') || name.includes('.restore-'));
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
describe('themeEject rolls back a partial write', () => {
|
|
102
|
-
it('removes every created file when the second publish fails', async () => {
|
|
103
|
-
const files = stoneFiles();
|
|
104
|
-
failures.publish = 2;
|
|
105
|
-
|
|
106
|
-
await expect(themeEject('stone', {cwd: tmpDir})).rejects.toMatchObject({
|
|
107
|
-
code: 'ERR_WRITE_FAILED',
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
for (const file of files) expect(fs.existsSync(file)).toBe(false);
|
|
111
|
-
expect(strays()).toEqual([]);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('restores every replaced byte when the second publish fails', async () => {
|
|
115
|
-
const files = stoneFiles();
|
|
116
|
-
fs.mkdirSync(path.dirname(files[0]), {recursive: true});
|
|
117
|
-
const before = Buffer.from([0x00, 0xff, 0x0a, 0x62, 0x65, 0x66]);
|
|
118
|
-
fs.writeFileSync(files[0], before);
|
|
119
|
-
failures.publish = 2;
|
|
120
|
-
|
|
121
|
-
await expect(
|
|
122
|
-
themeEject('stone', {cwd: tmpDir, overwrite: true}),
|
|
123
|
-
).rejects.toMatchObject({code: 'ERR_WRITE_FAILED'});
|
|
124
|
-
|
|
125
|
-
expect(fs.readFileSync(files[0]).equals(before)).toBe(true);
|
|
126
|
-
for (const file of files.slice(1)) expect(fs.existsSync(file)).toBe(false);
|
|
127
|
-
expect(strays()).toEqual([]);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it('names a file it could not restore', async () => {
|
|
131
|
-
const files = stoneFiles();
|
|
132
|
-
fs.mkdirSync(path.dirname(files[0]), {recursive: true});
|
|
133
|
-
fs.writeFileSync(files[0], 'before\n');
|
|
134
|
-
failures.publish = 2;
|
|
135
|
-
failures.restore = true;
|
|
136
|
-
|
|
137
|
-
let error;
|
|
138
|
-
try {
|
|
139
|
-
await themeEject('stone', {cwd: tmpDir, overwrite: true});
|
|
140
|
-
} catch (caught) {
|
|
141
|
-
error = caught;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
expect(error?.code).toBe('ERR_WRITE_FAILED');
|
|
145
|
-
expect(error?.message).toContain('Could not restore');
|
|
146
|
-
expect(error?.message).toContain(files[0]);
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('writes every file when nothing fails', async () => {
|
|
150
|
-
const files = stoneFiles();
|
|
151
|
-
|
|
152
|
-
const result = await themeEject('stone', {cwd: tmpDir});
|
|
153
|
-
|
|
154
|
-
expect(result.type).toBe('theme.eject');
|
|
155
|
-
for (const file of files) expect(fs.existsSync(file)).toBe(true);
|
|
156
|
-
expect(strays()).toEqual([]);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
4
|
-
import * as fs from 'node:fs';
|
|
5
|
-
import * as os from 'node:os';
|
|
6
|
-
import * as path from 'node:path';
|
|
7
|
-
import {themeEject} from '../eject/eject.mjs';
|
|
8
|
-
import {listThemes} from '../_adapter.mjs';
|
|
9
|
-
|
|
10
|
-
let tmpDir;
|
|
11
|
-
let outsideDir;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-themeeject-staging-'));
|
|
15
|
-
outsideDir = fs.mkdtempSync(
|
|
16
|
-
path.join(os.tmpdir(), 'astryx-themeeject-outside-'),
|
|
17
|
-
);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
afterEach(() => {
|
|
21
|
-
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
22
|
-
fs.rmSync(outsideDir, {recursive: true, force: true});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Where `theme eject` writes the first file of `slug`.
|
|
27
|
-
* @param {string} slug
|
|
28
|
-
*/
|
|
29
|
-
function firstDestination(slug) {
|
|
30
|
-
const theme = listThemes().find(entry => entry.slug === slug);
|
|
31
|
-
if (!theme) throw new Error(`missing bundled theme ${slug}`);
|
|
32
|
-
const dest = path.join(tmpDir, 'src', 'themes', slug, theme.files[0]);
|
|
33
|
-
fs.mkdirSync(path.dirname(dest), {recursive: true});
|
|
34
|
-
return dest;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Staging names are unpredictable and created exclusively, so an entry planted
|
|
38
|
-
// at a predictable name beside the destination is never written through.
|
|
39
|
-
describe('themeEject staging writes stay inside the project', () => {
|
|
40
|
-
it('never writes through a link planted at a predictable staging name', async () => {
|
|
41
|
-
const victim = path.join(outsideDir, 'victim.txt');
|
|
42
|
-
fs.writeFileSync(victim, 'outside\n');
|
|
43
|
-
const dest = firstDestination('stone');
|
|
44
|
-
fs.symlinkSync(victim, `${dest}.${process.pid}.tmp`);
|
|
45
|
-
|
|
46
|
-
await themeEject('stone', {cwd: tmpDir});
|
|
47
|
-
|
|
48
|
-
expect(fs.readFileSync(victim, 'utf-8')).toBe('outside\n');
|
|
49
|
-
expect(fs.lstatSync(dest).isFile()).toBe(true);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('never creates a file through a dangling link at a predictable staging name', async () => {
|
|
53
|
-
const victim = path.join(outsideDir, 'created.txt');
|
|
54
|
-
fs.symlinkSync(victim, `${firstDestination('stone')}.${process.pid}.tmp`);
|
|
55
|
-
|
|
56
|
-
await themeEject('stone', {cwd: tmpDir});
|
|
57
|
-
|
|
58
|
-
expect(fs.existsSync(victim)).toBe(false);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('refuses to replace a destination that links outside the project', async () => {
|
|
62
|
-
const victim = path.join(outsideDir, 'victim.txt');
|
|
63
|
-
fs.writeFileSync(victim, 'outside\n');
|
|
64
|
-
const dest = firstDestination('stone');
|
|
65
|
-
fs.symlinkSync(victim, dest);
|
|
66
|
-
|
|
67
|
-
await expect(
|
|
68
|
-
themeEject('stone', {cwd: tmpDir, overwrite: true}),
|
|
69
|
-
).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
|
|
70
|
-
expect(fs.readFileSync(victim, 'utf-8')).toBe('outside\n');
|
|
71
|
-
expect(fs.lstatSync(dest).isSymbolicLink()).toBe(true);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('never creates a file through a dangling destination link', async () => {
|
|
75
|
-
const victim = path.join(outsideDir, 'created.txt');
|
|
76
|
-
fs.symlinkSync(victim, firstDestination('stone'));
|
|
77
|
-
|
|
78
|
-
await expect(themeEject('stone', {cwd: tmpDir})).rejects.toMatchObject({
|
|
79
|
-
code: 'ERR_PATH_TRAVERSAL',
|
|
80
|
-
});
|
|
81
|
-
expect(fs.existsSync(victim)).toBe(false);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file CommandDoc for `astryx layout check`. The terminal binding of the
|
|
5
|
-
* `layoutCheck()` function (referenced via `fn`); its args/flags map to that
|
|
6
|
-
* function's params so a converter can build Commander config + --help from one
|
|
7
|
-
* source of truth.
|
|
8
|
-
* @position packages/cli/clients/cli/commands — command documentation
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
12
|
-
export const doc = {
|
|
13
|
-
type: 'command',
|
|
14
|
-
name: 'layout check',
|
|
15
|
-
displayName: 'astryx layout check',
|
|
16
|
-
namespace: 'cli/commands',
|
|
17
|
-
summary:
|
|
18
|
-
'Validate a layout expression and echo canonical compact/outline forms',
|
|
19
|
-
description:
|
|
20
|
-
'Parses and validates a compressed XLE/XLO expression without generating any TSX, and ' +
|
|
21
|
-
'echoes it back in both canonical surfaces (compact and outline). An invalid but ' +
|
|
22
|
-
'parseable expression is reported with line/col and suggestions, and exits non-zero.',
|
|
23
|
-
fn: 'layoutCheck',
|
|
24
|
-
args: [
|
|
25
|
-
{
|
|
26
|
-
name: 'expression',
|
|
27
|
-
param: 'expression',
|
|
28
|
-
required: false,
|
|
29
|
-
description:
|
|
30
|
-
'The XLE/XLO expression. Pass - to read it from stdin; --file reads it from a file instead.',
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
options: [
|
|
34
|
-
{
|
|
35
|
-
flag: '--file <file>',
|
|
36
|
-
description: 'Read the expression from a file (used instead of the argument when both are given)',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
flag: '--form <form>',
|
|
40
|
-
param: 'options.form',
|
|
41
|
-
choices: ['compact', 'outline', 'auto'],
|
|
42
|
-
default: 'auto',
|
|
43
|
-
description: 'Input surface: compact, outline, or auto',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
flag: '--loose',
|
|
47
|
-
param: 'options.loose',
|
|
48
|
-
description: 'Downgrade unknown {block} hints to TODO placeholders',
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
examples: [
|
|
52
|
-
{
|
|
53
|
-
label: 'Validate an expression',
|
|
54
|
-
cli: "astryx layout check 'A[cp6] > L > LC > S[p6]' --json",
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
exitCodes: [
|
|
58
|
-
{code: 0, when: 'the expression is valid'},
|
|
59
|
-
{
|
|
60
|
-
code: 1,
|
|
61
|
-
when: 'the expression is invalid, empty or over 5 MB (from stdin or --file), has a syntax error, or a bad --form',
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
deprecated: 'DEP-0006: Use `astryx build` to start from a template, `astryx template` to scaffold, and `astryx docs layout` for guidance.',
|
|
65
|
-
notes: [{"type": "prose", "text": "**Deprecated (DEP-0006).** Use `astryx build` to choose the template to start from, `astryx template` to scaffold it, and `astryx docs layout` for layout guidance. This command will be removed in a future minor release."}],
|
|
66
|
-
related: ['layout expand', 'layout grammar'],
|
|
67
|
-
};
|