@astryxdesign/cli 0.6.4-canary.06c8fa3 → 0.6.4-canary.0e1fbdb
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 +49 -40
- package/api/build/build.doc.mjs +6 -1
- package/api/build/build.test.mjs +22 -0
- package/api/build/kit/kit.mjs +44 -5
- package/api/component/component.doc.mjs +14 -7
- package/api/docs/_adapter.d.mts +8 -3
- package/api/docs/_adapter.mjs +14 -6
- package/api/docs/docOverlays.test.mjs +27 -1
- package/api/docs/docs.doc.mjs +2 -2
- package/api/doctor/doctor.doc.mjs +17 -8
- package/api/doctor/doctor.type.d.mts +1 -1
- package/api/doctor/doctor.type.mjs +1 -1
- package/api/gap-report/gap-report.doc.mjs +19 -10
- package/api/hook/hook.doc.mjs +6 -3
- package/api/index.d.mts +2 -0
- package/api/index.mjs +3 -1
- package/api/init/init.doc.mjs +17 -12
- package/api/integration/add-theme.mjs +22 -1
- package/api/integration/add-theme.test.mjs +34 -0
- package/api/integration/authoring-checks.mjs +2 -2
- package/api/integration/integrationPackCheck.doc.mjs +3 -3
- package/api/integration/pack-check.lifecycle-output.test.mjs +2 -0
- package/api/integration/pack-check.mjs +54 -6
- package/api/integration/pack-check.test.mjs +90 -0
- package/api/integration/pack-check.type.mjs +1 -1
- package/api/json/assertResponse.doc.mjs +1 -1
- package/api/json/index.ts +1 -0
- package/api/json/isError.doc.mjs +1 -1
- package/api/layout/_adapter.d.mts +34 -0
- package/api/layout/_adapter.mjs +148 -0
- package/api/layout/check/check.d.mts +16 -0
- package/api/layout/check/check.mjs +40 -0
- package/api/layout/expand/expand.d.mts +22 -0
- package/api/layout/expand/expand.mjs +155 -0
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.d.mts +13 -0
- package/api/layout/grammar/grammar.mjs +87 -0
- package/api/layout/layout.d.mts +6 -0
- package/api/layout/layout.mjs +17 -0
- package/api/layout/layout.test.mjs +297 -0
- package/api/layout/layout.type.d.mts +89 -0
- package/api/layout/layout.type.mjs +103 -0
- package/api/layout/layoutCheck.doc.d.mts +11 -0
- package/api/layout/layoutCheck.doc.mjs +85 -0
- package/api/layout/layoutExpand.doc.d.mts +11 -0
- package/api/layout/layoutExpand.doc.mjs +107 -0
- package/api/layout/layoutGrammar.doc.d.mts +11 -0
- package/api/layout/layoutGrammar.doc.mjs +57 -0
- package/api/search/search.d.mts +27 -1
- package/api/search/search.doc.mjs +2 -2
- package/api/search/search.mjs +228 -16
- package/api/swizzle/swizzle.doc.mjs +7 -5
- package/api/template/copy/copy.mjs +1 -1
- package/api/template/copy/copy.test.mjs +9 -0
- package/api/template/template-integration.test.mjs +65 -1
- package/api/template/template.doc.mjs +2 -1
- package/api/template/template.mjs +1 -1
- package/api/theme/generateTonalPalette.doc.mjs +1 -2
- package/api/theme/listThemes.doc.mjs +1 -1
- package/api/theme/themeAdd.doc.mjs +9 -10
- package/api/theme/themeBuild.doc.mjs +13 -13
- package/api/theme/themeList.doc.mjs +1 -1
- package/api/theme/themeListAvailable.doc.mjs +2 -1
- package/api/theme/themePaletteGenerate.doc.mjs +15 -8
- package/api/theme/themeTargets.doc.mjs +3 -2
- package/api/theme/themeTemplate.doc.mjs +2 -1
- package/api/upgrade/run/run.mjs +1 -1
- package/api/upgrade/upgrade.doc.mjs +24 -22
- package/assets/docs/README.md +4 -2
- package/assets/docs/browser-support.doc.mjs +11 -11
- package/assets/docs/color.doc.mjs +8 -2
- package/assets/docs/elevation.doc.mjs +6 -4
- package/assets/docs/getting-started.doc.mjs +5 -16
- package/assets/docs/icons.doc.mjs +2 -21
- package/assets/docs/illustrations.doc.mjs +7 -15
- package/assets/docs/layout.doc.dense.mjs +130 -82
- package/assets/docs/layout.doc.mjs +133 -77
- package/assets/docs/migration.doc.mjs +19 -21
- package/assets/docs/motion.doc.mjs +16 -3
- package/assets/docs/principles.doc.dense.mjs +5 -5
- package/assets/docs/principles.doc.mjs +8 -0
- package/assets/docs/principles.doc.zh.mjs +6 -6
- package/assets/docs/shape.doc.mjs +8 -3
- package/assets/docs/spacing.doc.mjs +7 -2
- package/assets/docs/styling-libraries.doc.mjs +6 -2
- package/assets/docs/styling.doc.mjs +19 -23
- package/assets/docs/theme.doc.dense.mjs +58 -18
- package/assets/docs/theme.doc.mjs +56 -46
- package/assets/docs/theme.doc.zh.mjs +9 -8
- package/assets/docs/tokens.doc.dense.mjs +2 -2
- package/assets/docs/tokens.doc.mjs +389 -8
- package/assets/docs/tokens.doc.zh.mjs +2 -2
- package/assets/docs/tree/add-a-component.doc.mjs +75 -0
- package/assets/docs/tree/add-a-theme.doc.mjs +85 -0
- package/assets/docs/tree/add-a-topic.doc.mjs +144 -0
- package/assets/docs/tree/agent-guidance.doc.mjs +138 -0
- package/assets/docs/tree/block-template.doc.mjs +130 -0
- package/assets/docs/tree/build-the-template.doc.mjs +28 -0
- package/assets/docs/tree/building-blocks.doc.mjs +46 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +137 -0
- package/assets/docs/tree/checks.doc.mjs +119 -0
- package/assets/docs/tree/codemods.doc.mjs +147 -0
- package/assets/docs/tree/component-family.doc.mjs +113 -0
- package/assets/docs/tree/component-imports.doc.mjs +69 -0
- package/assets/docs/tree/components.doc.mjs +23 -0
- package/assets/docs/tree/configuration.doc.mjs +23 -0
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +182 -0
- package/assets/docs/tree/define-the-theme.doc.mjs +118 -0
- package/assets/docs/tree/describe-the-component.doc.mjs +57 -0
- package/assets/docs/tree/docs.doc.mjs +21 -0
- package/assets/docs/tree/document-the-template.doc.mjs +28 -0
- package/assets/docs/tree/document-the-theme.doc.mjs +68 -0
- package/assets/docs/tree/export-template-assets.doc.mjs +147 -0
- package/assets/docs/tree/extend-or-replace.doc.mjs +103 -0
- package/assets/docs/tree/fonts-and-assets.doc.mjs +106 -0
- package/assets/docs/tree/generate-a-palette.doc.mjs +66 -0
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +105 -0
- package/assets/docs/tree/help.doc.mjs +16 -0
- package/assets/docs/tree/integrations.doc.mjs +25 -470
- package/assets/docs/tree/links.doc.mjs +98 -0
- package/assets/docs/tree/package-and-test.doc.mjs +32 -0
- package/assets/docs/tree/page-template.doc.mjs +71 -0
- package/assets/docs/tree/publishing.doc.mjs +111 -0
- package/assets/docs/tree/quick-start.doc.mjs +272 -0
- package/assets/docs/tree/replace-a-core-component.doc.mjs +104 -0
- package/assets/docs/tree/replace-a-core-template.doc.mjs +172 -0
- package/assets/docs/tree/sections-and-placement.doc.mjs +108 -0
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +59 -0
- package/assets/docs/tree/ship.doc.mjs +16 -0
- package/assets/docs/tree/short-and-findable.doc.mjs +108 -0
- package/assets/docs/tree/single-component.doc.mjs +165 -0
- package/assets/docs/tree/start-a-template.doc.mjs +143 -0
- package/assets/docs/tree/subcomponent.doc.mjs +115 -0
- package/assets/docs/tree/template-assets.doc.mjs +64 -0
- package/assets/docs/tree/template-doc-overview.doc.mjs +109 -0
- package/assets/docs/tree/template-fonts.doc.mjs +102 -0
- package/assets/docs/tree/template-grading-rubric.doc.mjs +452 -0
- package/assets/docs/tree/template-icons.doc.mjs +97 -0
- package/assets/docs/tree/template-images-media.doc.mjs +127 -0
- package/assets/docs/tree/template-styles.doc.mjs +93 -0
- package/assets/docs/tree/templates.doc.mjs +34 -0
- package/assets/docs/tree/test-in-an-app.doc.mjs +115 -0
- package/assets/docs/tree/test-template-in-app.doc.mjs +128 -0
- package/assets/docs/tree/themes.doc.mjs +39 -0
- package/assets/docs/tree/troubleshooting.doc.mjs +149 -0
- package/assets/docs/tree/upgrading.doc.mjs +103 -0
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +51 -0
- package/assets/docs/tree/verify-packed-template.doc.mjs +77 -0
- package/assets/docs/tree/versioning.doc.mjs +161 -0
- package/assets/docs/tree/write-good-templates.doc.mjs +64 -0
- package/assets/docs/tree/write-the-template-file.doc.mjs +154 -0
- package/assets/docs/typography.doc.mjs +24 -4
- package/assets/docs/working-with-ai.doc.mjs +30 -22
- package/authoring/config/config.doc.mjs +2 -2
- package/authoring/config/type.ts +2 -2
- package/authoring/doctypes/_schema.d.mts +3 -2
- package/authoring/doctypes/_schema.mjs +6 -0
- package/authoring/doctypes/base/graph-fields.doc.mjs +3 -3
- package/authoring/doctypes/base/type.ts +4 -2
- package/authoring/doctypes/command/command.doc.mjs +1 -1
- package/authoring/doctypes/command/type.ts +1 -1
- package/authoring/doctypes/component/component.doc.mjs +6 -0
- package/authoring/doctypes/component/type.ts +8 -0
- package/authoring/doctypes/reference/reference.doc.mjs +7 -0
- package/authoring/doctypes/reference/type.ts +5 -0
- package/authoring/doctypes/schema/schema.doc.mjs +2 -2
- package/authoring/doctypes/template/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +2 -2
- package/authoring/integration/integration.doc.mjs +12 -10
- package/clients/cli/command-result-coverage.test.mjs +7 -7
- package/clients/cli/commands/component.doc.mjs +4 -3
- package/clients/cli/commands/debug-result-summary.test.mjs +2 -2
- package/clients/cli/commands/docs.doc.mjs +1 -1
- package/clients/cli/commands/docs.mjs +60 -17
- package/clients/cli/commands/doctor-integration-docs.doc.mjs +3 -2
- package/clients/cli/commands/doctor-integration.test.mjs +53 -0
- package/clients/cli/commands/doctor.doc.mjs +3 -1
- package/clients/cli/commands/doctor.mjs +49 -5
- package/clients/cli/commands/gap-report.doc.mjs +10 -9
- package/clients/cli/commands/init.doc.mjs +9 -6
- package/clients/cli/commands/integration-add.doc.mjs +9 -9
- package/clients/cli/commands/integration-authoring.test.mjs +61 -10
- package/clients/cli/commands/integration-pack.doc.mjs +5 -9
- package/clients/cli/commands/integration-real-world.test.mjs +1 -1
- package/clients/cli/commands/integration-verify.doc.mjs +22 -0
- package/clients/cli/commands/integration.doc.mjs +4 -4
- package/clients/cli/commands/integration.mjs +74 -43
- package/clients/cli/commands/layout-check.doc.mjs +65 -0
- package/clients/cli/commands/layout-expand.doc.mjs +83 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +30 -0
- package/clients/cli/commands/layout.doc.mjs +34 -0
- package/clients/cli/commands/layout.error-codes.test.mjs +66 -0
- package/clients/cli/commands/layout.exit-parity.test.mjs +41 -0
- package/clients/cli/commands/layout.mjs +275 -0
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/manifest.doc.mjs +1 -1
- package/clients/cli/commands/search.doc.mjs +10 -3
- package/clients/cli/commands/search.mjs +21 -2
- package/clients/cli/commands/search.test.mjs +21 -4
- package/clients/cli/commands/swizzle.doc.mjs +1 -1
- package/clients/cli/commands/template.doc.mjs +1 -1
- package/clients/cli/commands/text-json-parity.test.mjs +24 -1
- package/clients/cli/commands/theme-add.doc.mjs +1 -1
- package/clients/cli/commands/theme-palette-generate.doc.mjs +3 -2
- package/clients/cli/commands/theme-palette.doc.mjs +1 -2
- package/clients/cli/commands/theme-targets.doc.mjs +2 -2
- package/clients/cli/commands/theme.doc.mjs +2 -1
- package/clients/cli/commands/upgrade.doc.mjs +62 -3
- package/clients/cli/index.mjs +32 -6
- package/clients/cli/lib/define-command.mjs +28 -4
- package/clients/cli/lib/define-command.test.mjs +54 -0
- package/clients/cli/lib/exit-codes.test.mjs +25 -2
- package/clients/cli/lib/json-shim.test.mjs +20 -6
- package/clients/cli/lib/manifest.mjs +23 -5
- package/foundation/agent-docs/agent-docs.mjs +1 -1
- package/foundation/discovery/authoring-self-docs.test.mjs +6 -2
- package/foundation/discovery/cli-self-docs.mjs +16 -2
- package/foundation/discovery/cli-self-docs.test.mjs +20 -0
- package/foundation/discovery/docs-discovery.mjs +5 -1
- package/foundation/discovery/docs-discovery.test.mjs +21 -0
- package/foundation/discovery/docs-section-key.d.mts +1 -1
- package/foundation/discovery/docs-section-key.mjs +1 -1
- package/foundation/discovery/template-adapter.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +15 -2
- package/foundation/doc-compiler/inputs.test.mjs +0 -1
- package/foundation/doc-compiler/tree.d.mts +4 -0
- package/foundation/doc-compiler/tree.mjs +6 -1
- package/foundation/integrations/cli-requirement.d.mts +26 -6
- package/foundation/integrations/cli-requirement.mjs +46 -11
- package/foundation/integrations/cli-requirement.test.mjs +7 -2
- package/foundation/integrations/contribution-inventory.mjs +1 -1
- package/foundation/response/error-codes.doc.mjs +6 -8
- package/foundation/response/error-codes.test.mjs +30 -5
- package/foundation/response/response-types.doc.d.mts +4 -3
- package/foundation/response/response-types.doc.mjs +42 -6
- package/foundation/response/response.doc.mjs +11 -10
- package/foundation/xle/browser.d.mts +3 -3
- package/foundation/xle/browser.mjs +3 -3
- package/foundation/xle/expand.mjs +2 -2
- package/foundation/xle/parse.mjs +1 -1
- package/foundation/xle/print.mjs +2 -2
- package/foundation/xle/splice.mjs +1 -1
- package/package.json +9 -9
- package/api/docs/docs.test.mjs +0 -245
- package/api/docs/integration-tree.test.mjs +0 -555
- package/api/docs/integrationDocs.test.mjs +0 -314
- package/api/search/search.test.mjs +0 -530
- package/assets/docs/tree/integrations.test.mjs +0 -62
- package/assets/docs/tree/writing-docs.doc.mjs +0 -286
- package/clients/cli/commands/docs.test.mjs +0 -323
- package/foundation/agent-docs/agent-docs.test.mjs +0 -1159
- package/foundation/doc-compiler/tree.test.mjs +0 -606
|
@@ -8,16 +8,16 @@ export const doc = {
|
|
|
8
8
|
namespace: 'cli/commands',
|
|
9
9
|
summary: 'Author and verify an Astryx integration package',
|
|
10
10
|
description:
|
|
11
|
-
'Add contributions
|
|
12
|
-
subcommands: ['add', 'pack'],
|
|
11
|
+
'Add contributions to your package, then check the packed package the way an app receives it. The guides start at {@link namespace:integrations}.',
|
|
12
|
+
subcommands: ['add', 'verify', 'pack'],
|
|
13
13
|
examples: [
|
|
14
14
|
{
|
|
15
15
|
label: 'Add a component',
|
|
16
16
|
cli: 'astryx integration add component AcmeWidget',
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
label: 'Check the package
|
|
20
|
-
cli: 'astryx integration
|
|
19
|
+
label: 'Check the package before publishing',
|
|
20
|
+
cli: 'astryx integration verify',
|
|
21
21
|
},
|
|
22
22
|
],
|
|
23
23
|
exitCodes: [
|
|
@@ -12,6 +12,7 @@ import {cliError} from '../lib/cli-error.mjs';
|
|
|
12
12
|
import {defineCommand} from '../lib/define-command.mjs';
|
|
13
13
|
import {doc as integrationGroup} from './integration.doc.mjs';
|
|
14
14
|
import {doc as integrationAddCommand} from './integration-add.doc.mjs';
|
|
15
|
+
import {doc as integrationVerifyCommand} from './integration-verify.doc.mjs';
|
|
15
16
|
import {doc as integrationPackCommand} from './integration-pack.doc.mjs';
|
|
16
17
|
import {doc as integrationAddFn} from '../../../api/integration/integrationAdd.doc.mjs';
|
|
17
18
|
import {doc as integrationPackCheckFn} from '../../../api/integration/integrationPackCheck.doc.mjs';
|
|
@@ -24,8 +25,16 @@ import {doc as integrationPackCheckFn} from '../../../api/integration/integratio
|
|
|
24
25
|
*/
|
|
25
26
|
function showGroupOrUnknown(command, label, options, invoked) {
|
|
26
27
|
const extras = invoked?.args ?? [];
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
// allowUnknownOption keeps an unknown flag among the args: a word there is
|
|
29
|
+
// an unknown subcommand, and a flag alone is an unknown option.
|
|
30
|
+
const word = extras.find(arg => !String(arg).startsWith('-'));
|
|
31
|
+
if (word == null && extras.length > 0) {
|
|
32
|
+
return cliError(`unknown option '${String(extras[0])}'`, {
|
|
33
|
+
code: ERROR_CODES.ERR_INVALID_OPTION,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (word != null) {
|
|
37
|
+
return cliError(`unknown subcommand '${label} ${String(word)}'`, {
|
|
29
38
|
suggestions: (command.commands ?? []).map(child => ({
|
|
30
39
|
name: child.name(),
|
|
31
40
|
reason: 'available subcommand',
|
|
@@ -37,6 +46,48 @@ function showGroupOrUnknown(command, label, options, invoked) {
|
|
|
37
46
|
return NO_RESULT_SET;
|
|
38
47
|
}
|
|
39
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Run `integration verify` and print its result, as text or JSON.
|
|
51
|
+
* @param {import('commander').Command} program
|
|
52
|
+
*/
|
|
53
|
+
async function verifyPackage(program) {
|
|
54
|
+
const result = await integrationPackCheck({cwd: process.cwd()});
|
|
55
|
+
if (program.opts().json) {
|
|
56
|
+
jsonOut(result);
|
|
57
|
+
} else {
|
|
58
|
+
const {name, version, packable, tarball, inventory, issues} = result.data;
|
|
59
|
+
const identity = [name, version].filter(Boolean).join('@');
|
|
60
|
+
const blocks = [
|
|
61
|
+
section(
|
|
62
|
+
packable
|
|
63
|
+
? 'Integration package ready'
|
|
64
|
+
: 'Integration package check failed',
|
|
65
|
+
),
|
|
66
|
+
text(`${packable ? '[ok]' : '[fail]'} ${identity || 'local package'}`),
|
|
67
|
+
];
|
|
68
|
+
if (tarball != null) {
|
|
69
|
+
blocks.push(
|
|
70
|
+
text(
|
|
71
|
+
`${tarball.fileCount} packed files; ${inventory.packedFiles}/${inventory.expectedFiles} required files present.`,
|
|
72
|
+
),
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
if (issues.length > 0) {
|
|
76
|
+
blocks.push(
|
|
77
|
+
list(
|
|
78
|
+
issues.map(
|
|
79
|
+
issue =>
|
|
80
|
+
`[${issue.severity === 'error' ? 'fail' : 'warn'}] ${issue.message}`,
|
|
81
|
+
),
|
|
82
|
+
),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
emit(...blocks);
|
|
86
|
+
}
|
|
87
|
+
if (!result.data.packable) process.exitCode = 1;
|
|
88
|
+
return NO_RESULT_SET;
|
|
89
|
+
}
|
|
90
|
+
|
|
40
91
|
/** @param {import('commander').Command} program */
|
|
41
92
|
export function registerIntegration(program) {
|
|
42
93
|
/** @type {import('commander').Command} */
|
|
@@ -45,6 +96,10 @@ export function registerIntegration(program) {
|
|
|
45
96
|
action: (options, command) =>
|
|
46
97
|
showGroupOrUnknown(integration, 'integration', options, command),
|
|
47
98
|
});
|
|
99
|
+
// An unknown subcommand given with a flag reports the unknown subcommand
|
|
100
|
+
// and lists the ones the group has, not the unknown option. Each subcommand
|
|
101
|
+
// still parses its own options.
|
|
102
|
+
integration.allowUnknownOption(true);
|
|
48
103
|
|
|
49
104
|
defineCommand(integration, integrationAddCommand, {
|
|
50
105
|
fn: integrationAddFn,
|
|
@@ -102,53 +157,29 @@ export function registerIntegration(program) {
|
|
|
102
157
|
},
|
|
103
158
|
});
|
|
104
159
|
|
|
160
|
+
defineCommand(integration, integrationVerifyCommand, {
|
|
161
|
+
fn: integrationPackCheckFn,
|
|
162
|
+
action: async () => verifyPackage(program),
|
|
163
|
+
});
|
|
164
|
+
// The name this check had before `integration verify`. It stays as a
|
|
165
|
+
// deprecated alias, listed as one in help, so scripts that call it keep
|
|
166
|
+
// working; it runs the same check with the same output and exit codes.
|
|
105
167
|
defineCommand(integration, integrationPackCommand, {
|
|
106
168
|
fn: integrationPackCheckFn,
|
|
107
169
|
action: async options => {
|
|
108
170
|
if (!options.check) {
|
|
109
|
-
return cliError(
|
|
110
|
-
|
|
111
|
-
|
|
171
|
+
return cliError(
|
|
172
|
+
'Pass --check to verify the integration tarball, or run `astryx integration verify`.',
|
|
173
|
+
{code: ERROR_CODES.ERR_INVALID_ARGUMENT},
|
|
174
|
+
);
|
|
112
175
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
const {name, version, packable, tarball, inventory, issues} =
|
|
119
|
-
result.data;
|
|
120
|
-
const identity = [name, version].filter(Boolean).join('@');
|
|
121
|
-
const blocks = [
|
|
122
|
-
section(
|
|
123
|
-
packable
|
|
124
|
-
? 'Integration package ready'
|
|
125
|
-
: 'Integration package check failed',
|
|
126
|
-
),
|
|
127
|
-
text(
|
|
128
|
-
`${packable ? '[ok]' : '[fail]'} ${identity || 'local package'}`,
|
|
129
|
-
),
|
|
130
|
-
];
|
|
131
|
-
if (tarball != null) {
|
|
132
|
-
blocks.push(
|
|
133
|
-
text(
|
|
134
|
-
`${tarball.fileCount} packed files; ${inventory.packedFiles}/${inventory.expectedFiles} required files present.`,
|
|
135
|
-
),
|
|
136
|
-
);
|
|
137
|
-
}
|
|
138
|
-
if (issues.length > 0) {
|
|
139
|
-
blocks.push(
|
|
140
|
-
list(
|
|
141
|
-
issues.map(
|
|
142
|
-
issue =>
|
|
143
|
-
`[${issue.severity === 'error' ? 'fail' : 'warn'}] ${issue.message}`,
|
|
144
|
-
),
|
|
145
|
-
),
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
emit(...blocks);
|
|
176
|
+
// stderr, and only in text: JSON callers get the same envelope as verify.
|
|
177
|
+
if (!program.opts().json) {
|
|
178
|
+
console.error(
|
|
179
|
+
'Note: `integration pack --check` is deprecated. Run `astryx integration verify`: it runs the same check.',
|
|
180
|
+
);
|
|
149
181
|
}
|
|
150
|
-
|
|
151
|
-
return NO_RESULT_SET;
|
|
182
|
+
return verifyPackage(program);
|
|
152
183
|
},
|
|
153
184
|
});
|
|
154
185
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
related: ['layout expand', 'layout grammar'],
|
|
65
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file CommandDoc for `astryx layout expand`. The terminal binding of the
|
|
5
|
+
* `layoutExpand()` 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 expand',
|
|
15
|
+
displayName: 'astryx layout expand',
|
|
16
|
+
namespace: 'cli/commands',
|
|
17
|
+
summary: 'Expand a layout expression into validated XDS TSX',
|
|
18
|
+
description:
|
|
19
|
+
'Parses and validates a compressed XLE/XLO expression, then expands it into ' +
|
|
20
|
+
'ready-to-use XDS TSX, routing children into slots, scaffolding typed useState for ' +
|
|
21
|
+
'interactive controls, and splicing referenced blocks. Writes to a path, or returns the code.',
|
|
22
|
+
fn: 'layoutExpand',
|
|
23
|
+
args: [
|
|
24
|
+
{
|
|
25
|
+
name: 'expression',
|
|
26
|
+
param: 'expression',
|
|
27
|
+
required: false,
|
|
28
|
+
description:
|
|
29
|
+
'The XLE/XLO expression. Pass - to read it from stdin; --file reads it from a file instead.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'path',
|
|
33
|
+
param: 'options.targetPath',
|
|
34
|
+
required: false,
|
|
35
|
+
description:
|
|
36
|
+
'Where to write the TSX, relative to the project root. A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; ' +
|
|
37
|
+
'any other path is a directory, which receives <Name>.tsx (see --name). An existing file there is replaced. ' +
|
|
38
|
+
'Omit it to print the code.',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
options: [
|
|
42
|
+
{
|
|
43
|
+
flag: '--file <file>',
|
|
44
|
+
description: 'Read the expression from a file (used instead of the argument when both are given)',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
flag: '--form <form>',
|
|
48
|
+
param: 'options.form',
|
|
49
|
+
choices: ['compact', 'outline', 'auto'],
|
|
50
|
+
default: 'auto',
|
|
51
|
+
description: 'Input surface: compact, outline, or auto',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
flag: '--name <name>',
|
|
55
|
+
param: 'options.name',
|
|
56
|
+
default: 'GeneratedLayout',
|
|
57
|
+
description: 'Generated component name (PascalCase)',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
flag: '--loose',
|
|
61
|
+
param: 'options.loose',
|
|
62
|
+
description: 'Downgrade unknown {block} hints to TODO placeholders',
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
examples: [
|
|
66
|
+
{
|
|
67
|
+
label: 'Expand to a file',
|
|
68
|
+
cli: "astryx layout expand 'V[g6] > C{card-callout}*4' ./src/Page.tsx",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
label: 'From a file, named',
|
|
72
|
+
cli: 'astryx layout expand --file layout.xlo --name Dashboard',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
exitCodes: [
|
|
76
|
+
{code: 0, when: 'success'},
|
|
77
|
+
{
|
|
78
|
+
code: 1,
|
|
79
|
+
when: 'a missing, empty or over-5 MB expression (from stdin or --file), a bad --name or --form, a parse/validation error, or a path escape',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
related: ['layout check', 'layout grammar'],
|
|
83
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file CommandDoc for `astryx layout grammar`. The terminal binding of the
|
|
5
|
+
* `layoutGrammar()` function (referenced via `fn`); it carries only CLI-surface
|
|
6
|
+
* facts so a converter can build Commander config + --help from one source of
|
|
7
|
+
* 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 grammar',
|
|
15
|
+
displayName: 'astryx layout grammar',
|
|
16
|
+
namespace: 'cli/commands',
|
|
17
|
+
summary:
|
|
18
|
+
'Print the XLE/XLO cheatsheet (alias table generated from this branch)',
|
|
19
|
+
description:
|
|
20
|
+
'Prints the XLE/XLO grammar cheatsheet for writing layout expressions, with the alias ' +
|
|
21
|
+
"table generated from this install's registry so short names always reflect the " +
|
|
22
|
+
'components actually available.',
|
|
23
|
+
fn: 'layoutGrammar',
|
|
24
|
+
examples: [{label: 'Get the cheatsheet', cli: 'astryx layout grammar'}],
|
|
25
|
+
exitCodes: [
|
|
26
|
+
{code: 0, when: 'success'},
|
|
27
|
+
{code: 1, when: 'the component registry cannot be read'},
|
|
28
|
+
],
|
|
29
|
+
related: ['layout expand', 'layout check'],
|
|
30
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file CommandDoc for the `astryx layout` command group. A parent group with no
|
|
5
|
+
* behavior of its own; it dispatches to the expand/check/grammar subcommands,
|
|
6
|
+
* which carry the actual args, flags, and wrapped functions.
|
|
7
|
+
* @position packages/cli/clients/cli/commands — command documentation
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** @type {import('@astryxdesign/cli/authoring').CommandDoc} */
|
|
11
|
+
export const doc = {
|
|
12
|
+
type: 'command',
|
|
13
|
+
name: 'layout',
|
|
14
|
+
displayName: 'astryx layout',
|
|
15
|
+
namespace: 'cli/commands',
|
|
16
|
+
summary: 'Generate XDS layouts from compressed expressions (XLE/XLO)',
|
|
17
|
+
description:
|
|
18
|
+
'The layout command group. Running astryx layout with no subcommand prints the ' +
|
|
19
|
+
'subcommand list; the work happens in the subcommands: expand an expression into ' +
|
|
20
|
+
'TSX (expand), validate one (check), or print the grammar cheatsheet (grammar).',
|
|
21
|
+
subcommands: ['expand', 'check', 'grammar'],
|
|
22
|
+
examples: [
|
|
23
|
+
{label: 'Print the grammar', cli: 'astryx layout grammar'},
|
|
24
|
+
{
|
|
25
|
+
label: 'Expand to TSX',
|
|
26
|
+
cli: "astryx layout expand 'V[g6] > C{card-callout}*4' ./src/Page.tsx",
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
exitCodes: [
|
|
30
|
+
{code: 0, when: 'a subcommand succeeded, or --help'},
|
|
31
|
+
{code: 1, when: 'no subcommand (help is printed) or an unknown subcommand'},
|
|
32
|
+
],
|
|
33
|
+
related: ['template', 'build'],
|
|
34
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Error-code contract tests for the layout command wrapper. Locks the
|
|
5
|
+
* two foreseeable input errors to STABLE ERR_* codes (never ERR_UNKNOWN or a
|
|
6
|
+
* raw fs errno) and asserts --json/human exit parity:
|
|
7
|
+
* - empty expression → ERR_MISSING_ARGUMENT
|
|
8
|
+
* - --file <missing> → ERR_FILE_NOT_FOUND (not raw ENOENT), no stack leak
|
|
9
|
+
* Spawns the real binary so the bin error boundary is exercised faithfully.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {describe, it, expect} from 'vitest';
|
|
13
|
+
import {spawnSync} from 'node:child_process';
|
|
14
|
+
import * as path from 'node:path';
|
|
15
|
+
import {fileURLToPath} from 'node:url';
|
|
16
|
+
|
|
17
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
const CLI_BIN = path.resolve(__dirname, '../bin/astryx.mjs');
|
|
19
|
+
|
|
20
|
+
function run(args) {
|
|
21
|
+
const res = spawnSync('node', [CLI_BIN, ...args], {
|
|
22
|
+
encoding: 'utf-8',
|
|
23
|
+
timeout: 20_000,
|
|
24
|
+
});
|
|
25
|
+
return {status: res.status, stdout: res.stdout || '', stderr: res.stderr || ''};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
describe('layout --json error codes', () => {
|
|
29
|
+
for (const sub of ['expand', 'check']) {
|
|
30
|
+
it(`layout ${sub} "" → ERR_MISSING_ARGUMENT (not ERR_UNKNOWN)`, () => {
|
|
31
|
+
const r = run(['--json', 'layout', sub, '']);
|
|
32
|
+
expect(r.status).toBe(1);
|
|
33
|
+
const env = JSON.parse(r.stdout);
|
|
34
|
+
expect(env.code).toBe('ERR_MISSING_ARGUMENT');
|
|
35
|
+
expect(r.stderr).toBe('');
|
|
36
|
+
expect(r.stdout).not.toMatch(/\n\s+at /); // no stack frames
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it(`layout ${sub} --file <missing> → ERR_FILE_NOT_FOUND (not ENOENT)`, () => {
|
|
40
|
+
const r = run([
|
|
41
|
+
'--json',
|
|
42
|
+
'layout',
|
|
43
|
+
sub,
|
|
44
|
+
'--file',
|
|
45
|
+
'/tmp/definitely-missing-astryx-xyz.mjs',
|
|
46
|
+
]);
|
|
47
|
+
expect(r.status).toBe(1);
|
|
48
|
+
const env = JSON.parse(r.stdout);
|
|
49
|
+
expect(env.code).toBe('ERR_FILE_NOT_FOUND');
|
|
50
|
+
expect(r.stderr).toBe('');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it(`layout ${sub}: --json and human agree on exit code (empty input)`, () => {
|
|
54
|
+
const human = run(['layout', sub, '']);
|
|
55
|
+
const json = run(['--json', 'layout', sub, '']);
|
|
56
|
+
expect(json.status).toBe(human.status);
|
|
57
|
+
expect(json.status).toBe(1);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it(`layout ${sub} --file <missing> in human mode leaks no stack trace`, () => {
|
|
61
|
+
const r = run(['layout', sub, '--file', '/tmp/definitely-missing-astryx-xyz.mjs']);
|
|
62
|
+
expect(r.status).toBe(1);
|
|
63
|
+
expect(r.stderr).not.toMatch(/\n\s+at /);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file CLI-level tests for `astryx layout check` exit-code parity.
|
|
5
|
+
*
|
|
6
|
+
* The exit code is the contract and must NOT depend on --json vs human mode:
|
|
7
|
+
* an invalid (but parseable) layout exits 1 in BOTH modes so `layout check`
|
|
8
|
+
* works as a CI gate / agent check without parsing stdout. Runs the real
|
|
9
|
+
* program in-process via the shared runCli harness.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import {describe, it, expect} from 'vitest';
|
|
13
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
14
|
+
|
|
15
|
+
const SLOW = 30_000;
|
|
16
|
+
// Parses fine, but references an unknown component -> data.valid: false
|
|
17
|
+
// (a semantic error, surfaced as data, not a thrown ERR_LAYOUT_PARSE).
|
|
18
|
+
const INVALID = 'ZzzUnknownComponent[foo=bar]';
|
|
19
|
+
const VALID = 'K';
|
|
20
|
+
|
|
21
|
+
describe('layout check — exit-code parity (--json vs human)', () => {
|
|
22
|
+
it('human mode exits 1 for an invalid (parseable) expression', async () => {
|
|
23
|
+
const {status} = await runCli(['layout', 'check', INVALID]);
|
|
24
|
+
expect(status).toBe(1);
|
|
25
|
+
}, SLOW);
|
|
26
|
+
|
|
27
|
+
it('--json exits 1 for the SAME invalid expression (modes agree)', async () => {
|
|
28
|
+
const {status, stdout} = await runCli(['layout', 'check', INVALID, '--json']);
|
|
29
|
+
const env = JSON.parse(stdout);
|
|
30
|
+
expect(env.type).toBe('layout.check');
|
|
31
|
+
expect(env.data.valid).toBe(false);
|
|
32
|
+
expect(status).toBe(1);
|
|
33
|
+
}, SLOW);
|
|
34
|
+
|
|
35
|
+
it('a valid expression exits 0 in both modes', async () => {
|
|
36
|
+
expect((await runCli(['layout', 'check', VALID])).status).toBe(0);
|
|
37
|
+
const {status, stdout} = await runCli(['layout', 'check', VALID, '--json']);
|
|
38
|
+
expect(JSON.parse(stdout).data.valid).toBe(true);
|
|
39
|
+
expect(status).toBe(0);
|
|
40
|
+
}, SLOW);
|
|
41
|
+
});
|