@astryxdesign/cli 0.7.2 → 0.7.3-canary.b1e1936
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 +99 -66
- package/api/build/_adapter.d.mts +58 -0
- package/api/build/_adapter.mjs +115 -3
- package/api/build/blocks/blocks.d.mts +42 -0
- package/api/build/blocks/blocks.mjs +169 -0
- package/api/build/blocks/blocks.test.mjs +108 -0
- package/api/build/blocks/blocks.weights.json +1 -0
- package/api/build/build.mjs +25 -6
- package/api/build/kit/answer.d.mts +14 -0
- package/api/build/kit/answer.mjs +85 -0
- package/api/build/kit/answer.test.mjs +38 -0
- package/api/build/kit/kind.d.mts +25 -0
- package/api/build/kit/kind.mjs +170 -0
- package/api/build/kit/kit.d.mts +2 -4
- package/api/build/kit/kit.mjs +8 -398
- package/api/build/kit/rank.d.mts +3 -32
- package/api/build/kit/rank.mjs +25 -342
- package/api/build/kit/rank.test.mjs +2 -1
- package/api/build/kit/signals.d.mts +60 -0
- package/api/build/kit/signals.mjs +284 -0
- package/api/build/kit/start.d.mts +32 -0
- package/api/build/kit/start.mjs +163 -0
- package/api/build/kit/words.d.mts +72 -0
- package/api/build/kit/words.mjs +202 -0
- package/api/build/tree.d.mts +20 -0
- package/api/build/tree.mjs +52 -0
- package/api/build/tree.test.mjs +177 -0
- package/api/build/tree.weights.json +1 -0
- package/api/discover/_adapter.mjs +36 -9
- package/api/discover/_adapter.test.mjs +42 -0
- package/api/docs/_adapter.mjs +17 -5
- package/api/docs/docs.test.mjs +7 -1
- package/api/integration/authoring-checks.mjs +83 -9
- package/api/integration/pack-check.mjs +14 -1
- package/api/integration/pack-check.test.mjs +18 -0
- package/api/integration/validate-integration-case-disk.test.mjs +111 -0
- package/api/integration/validate-integration-gaps.test.mjs +1672 -0
- package/api/integration/validate-integration.d.mts +9 -1
- package/api/integration/validate-integration.mjs +216 -26
- package/api/integration/validate-integration.type.d.mts +57 -1
- package/api/integration/validate-integration.type.mjs +44 -2
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/search/ORDERING.md +28 -0
- package/api/search/_adapter.d.mts +66 -2
- package/api/search/_adapter.mjs +118 -10
- package/api/search/_candidate-score.d.mts +40 -0
- package/api/search/_candidate-score.mjs +238 -0
- package/api/search/_cards.json +6098 -0
- package/api/search/_compound.d.mts +50 -0
- package/api/search/_compound.mjs +170 -0
- package/api/search/_doc-searcher.d.mts +4 -0
- package/api/search/_doc-searcher.mjs +23 -0
- package/api/search/_doc-searcher.test.mjs +36 -0
- package/api/search/_doc-searcher.weights.json +1 -0
- package/api/search/_doc-text.d.mts +30 -0
- package/api/search/_doc-text.mjs +87 -0
- package/api/search/_entries.d.mts +52 -0
- package/api/search/_entries.mjs +158 -0
- package/api/search/_features.d.mts +35 -0
- package/api/search/_features.mjs +155 -0
- package/api/search/_gather-components.d.mts +26 -0
- package/api/search/_gather-components.mjs +284 -0
- package/api/search/_gather-docs.d.mts +20 -0
- package/api/search/_gather-docs.mjs +254 -0
- package/api/search/_gather-hooks.d.mts +12 -0
- package/api/search/_gather-hooks.mjs +52 -0
- package/api/search/_gather-templates.d.mts +25 -0
- package/api/search/_gather-templates.mjs +107 -0
- package/api/search/_lexical.d.mts +135 -0
- package/api/search/_lexical.mjs +351 -0
- package/api/search/_main-searcher.d.mts +19 -0
- package/api/search/_main-searcher.mjs +115 -0
- package/api/search/_main-searcher.test.mjs +106 -0
- package/api/search/_main-searcher.weights.json +1 -0
- package/api/search/_module-doc.d.mts +32 -0
- package/api/search/_module-doc.mjs +78 -0
- package/api/search/_order.d.mts +32 -0
- package/api/search/_order.mjs +162 -0
- package/api/search/_order.test.mjs +72 -0
- package/api/search/_priority.d.mts +50 -0
- package/api/search/_priority.mjs +139 -0
- package/api/search/_query-words.d.mts +25 -0
- package/api/search/_query-words.mjs +92 -0
- package/api/search/_query.d.mts +65 -0
- package/api/search/_query.mjs +176 -0
- package/api/search/_result.d.mts +97 -0
- package/api/search/_result.mjs +150 -0
- package/api/search/_score.d.mts +60 -0
- package/api/search/_score.mjs +283 -0
- package/api/search/_synonyms.d.mts +21 -0
- package/api/search/_synonyms.mjs +67 -0
- package/api/search/_template-searcher.d.mts +4 -0
- package/api/search/_template-searcher.mjs +23 -0
- package/api/search/_template-searcher.test.mjs +40 -0
- package/api/search/_template-searcher.weights.json +1 -0
- package/api/search/_titles.d.mts +33 -0
- package/api/search/_titles.mjs +65 -0
- package/api/search/_words.d.mts +64 -0
- package/api/search/_words.mjs +157 -0
- package/api/search/search.d.mts +22 -305
- package/api/search/search.doc.mjs +7 -5
- package/api/search/search.mjs +53 -2483
- package/api/search/search.type.d.mts +6 -1
- package/api/search/search.type.mjs +6 -1
- package/api/search/tree.d.mts +15 -0
- package/api/search/tree.mjs +40 -0
- package/api/search/tree.test.mjs +66 -0
- package/api/search/tree.weights.json +1 -0
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +11 -0
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +3 -3
- package/assets/docs/tree/api.doc.mjs +6 -0
- package/assets/docs/tree/host-entry.doc.mjs +128 -0
- package/assets/docs/tree/tokens-data.doc.mjs +2 -2
- package/authoring/debug/parse.d.mts +1 -1
- package/clients/cli/bin/astryx.mjs +7 -78
- package/clients/cli/commands/doctor.mjs +30 -0
- package/clients/cli/run.mjs +108 -0
- package/foundation/config/project.mjs +15 -2
- package/foundation/discovery/component-discovery.d.mts +37 -0
- package/foundation/discovery/component-discovery.mjs +80 -5
- package/foundation/discovery/component-loader.d.mts +1 -1
- package/foundation/discovery/docs-discovery.mjs +14 -1
- package/foundation/discovery/module-exports.d.mts +41 -0
- package/foundation/discovery/module-exports.mjs +253 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +4 -0
- package/foundation/fs/paths.mjs +30 -3
- package/foundation/integrations/computer-integrations.d.mts +6 -3
- package/foundation/integrations/computer-integrations.mjs +38 -9
- package/foundation/integrations/contribution-inventory.d.mts +15 -20
- package/foundation/integrations/contribution-inventory.mjs +41 -5
- package/foundation/integrations/integrations.d.mts +7 -0
- package/foundation/integrations/integrations.mjs +2 -0
- package/foundation/integrations/validate-contributions.d.mts +96 -0
- package/foundation/integrations/validate-contributions.mjs +996 -10
- package/foundation/release/handoff.d.mts +23 -4
- package/foundation/release/handoff.mjs +175 -8
- package/foundation/release/run-context.mjs +14 -0
- package/foundation/response/response-types.doc.mjs +1 -1
- package/foundation/route/route.d.mts +285 -0
- package/foundation/route/route.mjs +324 -0
- package/foundation/route/route.test.mjs +153 -0
- package/foundation/runtime/hosted-runtime.test.mjs +403 -0
- package/foundation/runtime/locked-versions.d.mts +32 -0
- package/foundation/runtime/locked-versions.mjs +65 -0
- package/foundation/runtime/package-root.d.mts +91 -0
- package/foundation/runtime/package-root.mjs +174 -0
- package/foundation/runtime/package-set.d.mts +62 -0
- package/foundation/runtime/package-set.mjs +130 -0
- package/foundation/runtime/package-set.test.mjs +432 -0
- package/host/door-conformance.test.mjs +274 -0
- package/host/index.d.ts +116 -0
- package/host/index.mjs +295 -0
- package/host/index.test.mjs +302 -0
- package/package.json +14 -9
|
@@ -29,6 +29,17 @@ describe('validate-data-token-ownership', () => {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
+
it('reports prebuilt CSS availability without requiring a source compile step', async () => {
|
|
33
|
+
await expect(
|
|
34
|
+
run('const fill = "var(--color-data-categorical-blue)";'),
|
|
35
|
+
).rejects.toThrow(
|
|
36
|
+
/in prebuilt mode, loads @astryxdesign\/core\/astryx\.css/,
|
|
37
|
+
);
|
|
38
|
+
await expect(
|
|
39
|
+
run('.bar { fill: var(--color-data-categorical-blue); }', 'chart.css'),
|
|
40
|
+
).rejects.toThrow(/load @astryxdesign\/core\/astryx\.css in prebuilt mode/);
|
|
41
|
+
});
|
|
42
|
+
|
|
32
43
|
it('leaves fallbacks, dataVars access, and comments unchanged', async () => {
|
|
33
44
|
const source = `
|
|
34
45
|
// var(--color-data-categorical-green)
|
|
@@ -56,7 +56,7 @@ export default function validateDataTokenOwnership(file, api) {
|
|
|
56
56
|
ROOT_DATA_DECLARATION.test(file.source)
|
|
57
57
|
) {
|
|
58
58
|
throw new Error(
|
|
59
|
-
'This generated theme CSS still emits canonical data defaults at :root. Rebuild it with `astryx theme build`; defaults
|
|
59
|
+
'This generated theme CSS still emits canonical data defaults at :root. Rebuild it with `astryx theme build`; defaults come from source-compiled dataVars consumers or @astryxdesign/core/astryx.css in prebuilt mode.',
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
62
|
const uncommented = file.source.replace(CSS_COMMENT, comment =>
|
|
@@ -66,7 +66,7 @@ export default function validateDataTokenOwnership(file, api) {
|
|
|
66
66
|
if (cssMatch) {
|
|
67
67
|
const line = uncommented.slice(0, cssMatch.index).split('\n').length;
|
|
68
68
|
throw new Error(
|
|
69
|
-
`Raw var(${cssMatch[1]}) without a fallback at line ${line} needs
|
|
69
|
+
`Raw var(${cssMatch[1]}) without a fallback at line ${line} needs an availability check: load @astryxdesign/core/astryx.css in prebuilt mode, ensure a source-compiled dataVars consumer retains the group, or add an explicit fallback. CSS-capable code imports dataVars from @astryxdesign/core/theme/dataTokens.stylex.`,
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
72
|
return undefined;
|
|
@@ -95,7 +95,7 @@ export default function validateDataTokenOwnership(file, api) {
|
|
|
95
95
|
if (found) {
|
|
96
96
|
const {token, line} = found;
|
|
97
97
|
throw new Error(
|
|
98
|
-
`Direct var(${token})${line == null ? '' : ` at line ${line}`} needs manual migration: CSS-capable code imports dataVars from @astryxdesign/core/theme/dataTokens.stylex; Canvas and other non-CSS APIs use resolveThemeToken() or useTheme().token().`,
|
|
98
|
+
`Direct var(${token})${line == null ? '' : ` at line ${line}`} needs manual migration: CSS-capable code imports dataVars from @astryxdesign/core/theme/dataTokens.stylex and, in prebuilt mode, loads @astryxdesign/core/astryx.css; Canvas and other non-CSS APIs use resolveThemeToken() or useTheme().token().`,
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
101
|
return undefined;
|
|
@@ -20,6 +20,12 @@ export const docs = {
|
|
|
20
20
|
slots: {
|
|
21
21
|
kinds: {title: 'Reference', accepts: {kinds: ['namespace']}},
|
|
22
22
|
},
|
|
23
|
+
blocks: [
|
|
24
|
+
{
|
|
25
|
+
type: 'prose',
|
|
26
|
+
text: 'To run the whole CLI from your own command-line tool, with its arguments, folder, and command name, use the host entry: {@link generic:host-entry}.',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
23
29
|
adopts: [
|
|
24
30
|
{
|
|
25
31
|
source: {group: 'cli/api', kinds: ['function', 'schema', 'enum']},
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx docs cli/host-entry`: run the CLI from a tool that carries it,
|
|
5
|
+
* through `@astryxdesign/cli/host` (spec AST-081 FR1,
|
|
6
|
+
* architecture:cli-surface INV30).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
|
|
10
|
+
export const docs = {
|
|
11
|
+
type: 'generic',
|
|
12
|
+
name: 'host-entry',
|
|
13
|
+
placement: {parent: 'namespace:cli', slot: 'guides', order: 15},
|
|
14
|
+
title: 'Host entry',
|
|
15
|
+
category: 'guide',
|
|
16
|
+
keywords: [
|
|
17
|
+
'host entry',
|
|
18
|
+
'runHostedCli',
|
|
19
|
+
'@astryxdesign/cli/host',
|
|
20
|
+
'carry the cli',
|
|
21
|
+
'embed the cli',
|
|
22
|
+
'programmatic run',
|
|
23
|
+
'package sets',
|
|
24
|
+
'cliCommand',
|
|
25
|
+
],
|
|
26
|
+
description:
|
|
27
|
+
'Run the Astryx CLI from your own command-line tool: the inputs `runHostedCli` takes, what it returns, and when the process ends instead.',
|
|
28
|
+
sections: [
|
|
29
|
+
{
|
|
30
|
+
id: 'start',
|
|
31
|
+
title: 'Start a run',
|
|
32
|
+
content: [
|
|
33
|
+
{
|
|
34
|
+
type: 'prose',
|
|
35
|
+
text: "A tool that carries the CLI for its own users starts one run per process with `runHostedCli` from `@astryxdesign/cli/host`. The run behaves as the CLI's own command does with the same arguments in the same folder, and the commands it prints start with your tool's command.",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'code',
|
|
39
|
+
lang: 'javascript',
|
|
40
|
+
code: "import {runHostedCli} from '@astryxdesign/cli/host';\n\nconst {status} = await runHostedCli({\n argv: process.argv.slice(2),\n cwd: process.cwd(),\n cliCommand: 'acme astryx',\n});\nprocess.exitCode = status;",
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'options',
|
|
46
|
+
title: 'Options',
|
|
47
|
+
content: [
|
|
48
|
+
{
|
|
49
|
+
type: 'table',
|
|
50
|
+
headers: ['Option', 'Default', 'Meaning'],
|
|
51
|
+
rows: [
|
|
52
|
+
[
|
|
53
|
+
'`argv`',
|
|
54
|
+
'none',
|
|
55
|
+
'The command-line arguments, without the command name.',
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
'`cwd`',
|
|
59
|
+
"the process's working folder",
|
|
60
|
+
'The folder the run works in. It must exist.',
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
'`cliCommand`',
|
|
64
|
+
"the package manager's name",
|
|
65
|
+
'The command your users type, such as `acme astryx`: a non-blank single line of at most 120 characters, with no surrounding spaces.',
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
'`declinedProjectCli`',
|
|
69
|
+
'none',
|
|
70
|
+
"Why you did not run the project's own CLI, such as `untrusted`: a non-blank single line of at most 120 characters. That CLI then never runs.",
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
'`roots`',
|
|
74
|
+
'none',
|
|
75
|
+
'Your package sets, in order of preference: folders whose `node_modules` each hold a CLI, the Core of the same release, and integrations. A run never installs a release; it takes the release a project needs from the first set that holds it.',
|
|
76
|
+
],
|
|
77
|
+
[
|
|
78
|
+
'`integrations`',
|
|
79
|
+
'none',
|
|
80
|
+
'Integrations you approve for use outside a project, by package name.',
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
'`discoverSources`',
|
|
84
|
+
'none',
|
|
85
|
+
"Your own discover sources. `astryx discover` reports each as the host's.",
|
|
86
|
+
],
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
id: 'result',
|
|
93
|
+
title: 'Result and errors',
|
|
94
|
+
content: [
|
|
95
|
+
{
|
|
96
|
+
type: 'list',
|
|
97
|
+
style: 'unordered',
|
|
98
|
+
items: [
|
|
99
|
+
"It resolves with `{status, packages}`: the exit status the CLI's own command would exit with, and each package the run used, with its version and whether it came from the project or a package set.",
|
|
100
|
+
'When another release answers from one of your package sets through its own host entry, that entry runs in the same process with the same inputs, and the call resolves with its result.',
|
|
101
|
+
'It rejects with a `TypeError`, before anything runs, for an unknown option or an invalid value, and with an `Error` when a run already started in the process. Start each run in a new process.',
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: 'process-ends',
|
|
108
|
+
title: 'When the process ends instead',
|
|
109
|
+
content: [
|
|
110
|
+
{
|
|
111
|
+
type: 'prose',
|
|
112
|
+
text: "Like the CLI's own command, a run ends the process with its exit status, and the call never resolves, when it:",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
type: 'list',
|
|
116
|
+
style: 'unordered',
|
|
117
|
+
items: [
|
|
118
|
+
'prints help or the version (`--help`, `-h`, `help`, `--version`, `-V`, `--version --json`);',
|
|
119
|
+
'rejects the command line, such as an unknown command or option;',
|
|
120
|
+
'reports an error it stops on, including every error in `--json` mode;',
|
|
121
|
+
'meets an unexpected error;',
|
|
122
|
+
"hands the run to another CLI's own command: the project's CLI when you pass no `declinedProjectCli`, or a package set whose CLI has no host entry.",
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
@@ -17,14 +17,14 @@ export const docs = {
|
|
|
17
17
|
"order": 20
|
|
18
18
|
},
|
|
19
19
|
"category": "foundations",
|
|
20
|
-
"description": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code.
|
|
20
|
+
"description": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code. Source compilation emits the complete 56-variable group when any member is retained and none for an unused graph. Prebuilt CSS consumers load @astryxdesign/core/astryx.css, which defines the complete group for the already-compiled dataVars entry.",
|
|
21
21
|
"sections": [
|
|
22
22
|
{
|
|
23
23
|
"title": "Data Visualization Tokens",
|
|
24
24
|
"content": [
|
|
25
25
|
{
|
|
26
26
|
"type": "prose",
|
|
27
|
-
"text": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code.
|
|
27
|
+
"text": "Colors for charts and graphs: one categorical accent per series, a neutral for labels and reference lines, and sequential ramps from 5 (darkest) to 1 (lightest) for ordered scales and heatmaps. Import dataVars from @astryxdesign/core/theme/dataTokens.stylex for CSS-capable code. Source compilation emits the complete 56-variable group when any member is retained and none for an unused graph. Prebuilt CSS consumers load @astryxdesign/core/astryx.css, which defines the complete group for the already-compiled dataVars entry."
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
"type": "table",
|
|
@@ -79,9 +79,9 @@ declare const eventSchema: z.ZodObject<{
|
|
|
79
79
|
none: "none";
|
|
80
80
|
component: "component";
|
|
81
81
|
hook: "hook";
|
|
82
|
+
theme: "theme";
|
|
82
83
|
doc: "doc";
|
|
83
84
|
template: "template";
|
|
84
|
-
theme: "theme";
|
|
85
85
|
integration: "integration";
|
|
86
86
|
migration: "migration";
|
|
87
87
|
mixed: "mixed";
|
|
@@ -53,84 +53,13 @@ if (!isNodeVersionSupported(process.versions.node)) {
|
|
|
53
53
|
process.exit(1);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// Global mode:
|
|
57
|
-
// not this copy,
|
|
58
|
-
// astryx.config, integrations, or Core) is loaded
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
await
|
|
56
|
+
// Global mode: the run chooses the release that answers this folder and, when
|
|
57
|
+
// it is not this copy, hands the run to it before anything the project
|
|
58
|
+
// provides (its astryx.config, integrations, or Core) is loaded; only then
|
|
59
|
+
// does it load and dispatch the command. See clients/cli/run.mjs,
|
|
60
|
+
// foundation/release/handoff.mjs, and spec AST-081 FR2 and FR9.
|
|
61
|
+
const {runCli} = await importSrc('run.mjs');
|
|
62
|
+
await runCli({
|
|
62
63
|
cliRoot: join(binDir, '..', '..', '..'),
|
|
63
64
|
argv: process.argv.slice(2),
|
|
64
65
|
});
|
|
65
|
-
|
|
66
|
-
// Imports that transitively load `styleText` must happen AFTER the gate above,
|
|
67
|
-
// so they are dynamically imported here rather than at the top of the module.
|
|
68
|
-
const {
|
|
69
|
-
program,
|
|
70
|
-
loadProjectDebugHandler,
|
|
71
|
-
loadProjectForHelp,
|
|
72
|
-
handleVersionJsonPreflight,
|
|
73
|
-
} = await importSrc('index.mjs');
|
|
74
|
-
const {isJsonMode, toErrorEnvelope} = await importSrc('../../foundation/response/json.mjs');
|
|
75
|
-
const {handleCommanderError} = await importSrc('lib/json-shim.mjs');
|
|
76
|
-
const {setOutcome} = await importSrc('../../foundation/debug/index.mjs');
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Top-level error boundary (contract guarantee #4): an uncaught throw must
|
|
80
|
-
* never reach a --json consumer as a raw stack trace. If we're in JSON mode,
|
|
81
|
-
* convert it to the contract's error envelope on stdout and exit 1; otherwise
|
|
82
|
-
* preserve the normal human-facing behavior.
|
|
83
|
-
*
|
|
84
|
-
* We detect JSON mode two ways: the global flag (set once root options are
|
|
85
|
-
* parsed) and a raw argv check, since a throw can occur during parsing/command
|
|
86
|
-
* load — before the preAction hook engages the flag.
|
|
87
|
-
*/
|
|
88
|
-
function inJsonMode() {
|
|
89
|
-
return isJsonMode() || process.argv.slice(2).includes('--json');
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** @param {unknown} err */
|
|
93
|
-
function handleFatal(err) {
|
|
94
|
-
// CommanderError (parse errors, --help, unknown command) routes
|
|
95
|
-
// through the JSON shim so that a --json consumer always gets a
|
|
96
|
-
// valid envelope and the right exit code. handleCommanderError
|
|
97
|
-
// calls process.exit when it owns the error.
|
|
98
|
-
if (handleCommanderError(err)) return;
|
|
99
|
-
|
|
100
|
-
// Anything still here is an uncaught throw or an unhandled rejection —
|
|
101
|
-
// a bug rather than a user error, and the class of failure most worth
|
|
102
|
-
// having a record of.
|
|
103
|
-
setOutcome('fatal', {exitCode: 1, error: err});
|
|
104
|
-
|
|
105
|
-
if (inJsonMode()) {
|
|
106
|
-
// Only emit if a command didn't already produce an envelope.
|
|
107
|
-
if (!process.__xdsJsonHandled) {
|
|
108
|
-
process.__xdsJsonHandled = true;
|
|
109
|
-
console.log(JSON.stringify(toErrorEnvelope(err), null, 2));
|
|
110
|
-
}
|
|
111
|
-
process.exit(1);
|
|
112
|
-
}
|
|
113
|
-
// Human mode: preserve Commander/Node default-ish behavior.
|
|
114
|
-
console.error(err instanceof Error ? err.stack || err.message : String(err));
|
|
115
|
-
process.exit(1);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
process.on('unhandledRejection', handleFatal);
|
|
119
|
-
process.on('uncaughtException', handleFatal);
|
|
120
|
-
|
|
121
|
-
// Pick up the project's `debug` function before parsing, so parse errors and
|
|
122
|
-
// `--help` — which short-circuit before any hook runs — are reported too.
|
|
123
|
-
await loadProjectDebugHandler();
|
|
124
|
-
// Help prints its commands while Commander parses, so a help run reads the
|
|
125
|
-
// project's declared `cliCommand` here.
|
|
126
|
-
await loadProjectForHelp();
|
|
127
|
-
|
|
128
|
-
// `--version --json` answers and exits without Commander, so it runs here —
|
|
129
|
-
// after the handler exists, or the run would go unrecorded.
|
|
130
|
-
handleVersionJsonPreflight();
|
|
131
|
-
|
|
132
|
-
try {
|
|
133
|
-
await program.parseAsync(process.argv);
|
|
134
|
-
} catch (err) {
|
|
135
|
-
handleFatal(err);
|
|
136
|
-
}
|
|
@@ -179,6 +179,34 @@ function docTypesBlocks(report, failed) {
|
|
|
179
179
|
return blocks;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
/**
|
|
183
|
+
* The component doc names that could not be judged against their sources.
|
|
184
|
+
* @param {import('../../../api/integration/validate-integration.type.mjs').DocNamesReport | undefined} report
|
|
185
|
+
*/
|
|
186
|
+
function docNamesBlocks(report) {
|
|
187
|
+
if (!report || report.unchecked.length === 0) return [];
|
|
188
|
+
return [
|
|
189
|
+
text(
|
|
190
|
+
`[info] Component names not checked: ${report.unchecked.length} doc(s) whose source exports this check cannot read:`,
|
|
191
|
+
),
|
|
192
|
+
records(report.unchecked, {fields: ['file', 'name', 'reason']}),
|
|
193
|
+
];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The block component names this check could not judge.
|
|
198
|
+
* @param {import('../../../api/integration/validate-integration.type.mjs').BlockComponentsReport | undefined} report
|
|
199
|
+
*/
|
|
200
|
+
function blockComponentsBlocks(report) {
|
|
201
|
+
if (!report || report.unchecked.length === 0) return [];
|
|
202
|
+
return [
|
|
203
|
+
text(
|
|
204
|
+
`[info] Block component names not checked: ${report.unchecked.length} name(s) this check could not judge:`,
|
|
205
|
+
),
|
|
206
|
+
records(report.unchecked, {fields: ['file', 'name', 'reason']}),
|
|
207
|
+
];
|
|
208
|
+
}
|
|
209
|
+
|
|
182
210
|
/**
|
|
183
211
|
* @param {import('../../../api/integration/validate-integration.type.mjs').ValidateIntegrationResponse['data']} data
|
|
184
212
|
*/
|
|
@@ -204,6 +232,8 @@ function printIntegrationValidation(data) {
|
|
|
204
232
|
`${warnings} warning${warnings === 1 ? '' : 's'}`,
|
|
205
233
|
),
|
|
206
234
|
...docTypesBlocks(data.docTypes, errors > 0),
|
|
235
|
+
...docNamesBlocks(data.docNames),
|
|
236
|
+
...blockComponentsBlocks(data.blockComponents),
|
|
207
237
|
);
|
|
208
238
|
}
|
|
209
239
|
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file One run of the CLI, after the Node version gate: choose who answers
|
|
5
|
+
* the folder, hand the run off when that is another release (spec AST-081
|
|
6
|
+
* FR2, FR9), then dispatch the command.
|
|
7
|
+
*
|
|
8
|
+
* @input The arguments after `astryx`, read from `process.argv`; the CLI
|
|
9
|
+
* package root; and, for a run a programmatic host started, the reason the
|
|
10
|
+
* host declined the project's own CLI.
|
|
11
|
+
* @output The command's effects. The run owns the process: its exit status is
|
|
12
|
+
* `process.exitCode`, unless a hand-off or a failure exits the process.
|
|
13
|
+
* @position clients/cli — called by `bin/astryx.mjs` and by the host entry
|
|
14
|
+
* (`host/index.mjs`).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Run the CLI once in this process.
|
|
19
|
+
*
|
|
20
|
+
* Every import here is dynamic: modules that load `styleText` must load only
|
|
21
|
+
* after the bin's Node version gate, and the release choice must run before
|
|
22
|
+
* the command modules load, so a run handed to another release loads none of
|
|
23
|
+
* them.
|
|
24
|
+
*
|
|
25
|
+
* @param {{cliRoot: string, argv: string[], declinedProjectCli?: string}} input
|
|
26
|
+
* @returns {Promise<import('../../host/index.js').HostedCliResult | undefined>}
|
|
27
|
+
* resolves when the command has finished; with another release's result
|
|
28
|
+
* when, in a hosted run, that release's host entry answered
|
|
29
|
+
*/
|
|
30
|
+
export async function runCli({cliRoot, argv, declinedProjectCli}) {
|
|
31
|
+
const {startRun} = await import('../../foundation/release/handoff.mjs');
|
|
32
|
+
const answered = await startRun({cliRoot, argv, declinedProjectCli});
|
|
33
|
+
if (answered) return answered;
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
program,
|
|
37
|
+
loadProjectDebugHandler,
|
|
38
|
+
loadProjectForHelp,
|
|
39
|
+
handleVersionJsonPreflight,
|
|
40
|
+
} = await import('./index.mjs');
|
|
41
|
+
const {isJsonMode, toErrorEnvelope} =
|
|
42
|
+
await import('../../foundation/response/json.mjs');
|
|
43
|
+
const {handleCommanderError} = await import('./lib/json-shim.mjs');
|
|
44
|
+
const {setOutcome} = await import('../../foundation/debug/index.mjs');
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Top-level error boundary (contract guarantee #4): an uncaught throw must
|
|
48
|
+
* never reach a --json consumer as a raw stack trace. If we're in JSON mode,
|
|
49
|
+
* convert it to the contract's error envelope on stdout and exit 1;
|
|
50
|
+
* otherwise preserve the normal human-facing behavior.
|
|
51
|
+
*
|
|
52
|
+
* We detect JSON mode two ways: the global flag (set once root options are
|
|
53
|
+
* parsed) and a raw argv check, since a throw can occur during
|
|
54
|
+
* parsing/command load — before the preAction hook engages the flag.
|
|
55
|
+
*/
|
|
56
|
+
function inJsonMode() {
|
|
57
|
+
return isJsonMode() || process.argv.slice(2).includes('--json');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** @param {unknown} err */
|
|
61
|
+
function handleFatal(err) {
|
|
62
|
+
// CommanderError (parse errors, --help, unknown command) routes
|
|
63
|
+
// through the JSON shim so that a --json consumer always gets a
|
|
64
|
+
// valid envelope and the right exit code. handleCommanderError
|
|
65
|
+
// calls process.exit when it owns the error.
|
|
66
|
+
if (handleCommanderError(err)) return;
|
|
67
|
+
|
|
68
|
+
// Anything still here is an uncaught throw or an unhandled rejection —
|
|
69
|
+
// a bug rather than a user error, and the class of failure most worth
|
|
70
|
+
// having a record of.
|
|
71
|
+
setOutcome('fatal', {exitCode: 1, error: err});
|
|
72
|
+
|
|
73
|
+
if (inJsonMode()) {
|
|
74
|
+
// Only emit if a command didn't already produce an envelope.
|
|
75
|
+
if (!process.__xdsJsonHandled) {
|
|
76
|
+
process.__xdsJsonHandled = true;
|
|
77
|
+
console.log(JSON.stringify(toErrorEnvelope(err), null, 2));
|
|
78
|
+
}
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
// Human mode: preserve Commander/Node default-ish behavior.
|
|
82
|
+
console.error(
|
|
83
|
+
err instanceof Error ? err.stack || err.message : String(err),
|
|
84
|
+
);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
process.on('unhandledRejection', handleFatal);
|
|
89
|
+
process.on('uncaughtException', handleFatal);
|
|
90
|
+
|
|
91
|
+
// Pick up the project's `debug` function before parsing, so parse errors
|
|
92
|
+
// and `--help` — which short-circuit before any hook runs — are reported
|
|
93
|
+
// too.
|
|
94
|
+
await loadProjectDebugHandler();
|
|
95
|
+
// Help prints its commands while Commander parses, so a help run reads the
|
|
96
|
+
// project's declared `cliCommand` here.
|
|
97
|
+
await loadProjectForHelp();
|
|
98
|
+
|
|
99
|
+
// `--version --json` answers and exits without Commander, so it runs here —
|
|
100
|
+
// after the handler exists, or the run would go unrecorded.
|
|
101
|
+
handleVersionJsonPreflight();
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
await program.parseAsync(process.argv);
|
|
105
|
+
} catch (err) {
|
|
106
|
+
handleFatal(err);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -89,6 +89,10 @@ import {
|
|
|
89
89
|
} from '../../assets/codemods/integration-discovery.mjs';
|
|
90
90
|
import {validateLoadedIntegration} from '../integrations/validate-contributions.mjs';
|
|
91
91
|
import {recordDeclaredCliCommands} from '../env/cli-command.mjs';
|
|
92
|
+
import {
|
|
93
|
+
hostedRun,
|
|
94
|
+
recordResolvedIntegrations,
|
|
95
|
+
} from '../runtime/package-root.mjs';
|
|
92
96
|
import {
|
|
93
97
|
InMemoryConfigCache,
|
|
94
98
|
cacheKey,
|
|
@@ -121,9 +125,16 @@ function errorMessage(err) {
|
|
|
121
125
|
*/
|
|
122
126
|
export function computerIntegrationCandidates(cwd = process.cwd()) {
|
|
123
127
|
try {
|
|
124
|
-
const
|
|
128
|
+
const outside = isOutsideProject(cwd);
|
|
129
|
+
const cliRoot = outside ? CLI_ROOT : globalCliRoot(cwd);
|
|
125
130
|
return cliRoot
|
|
126
|
-
? scanComputerIntegrations({
|
|
131
|
+
? scanComputerIntegrations({
|
|
132
|
+
cliRoot,
|
|
133
|
+
release: cliVersion(),
|
|
134
|
+
// Outside a project, the integrations a host approves load from the
|
|
135
|
+
// package set that serves the run too (cli-surface INV30).
|
|
136
|
+
approved: outside ? (hostedRun()?.integrations ?? []) : [],
|
|
137
|
+
})
|
|
127
138
|
: [];
|
|
128
139
|
} catch {
|
|
129
140
|
return [];
|
|
@@ -580,6 +591,8 @@ export class Project {
|
|
|
580
591
|
: []),
|
|
581
592
|
]);
|
|
582
593
|
loadedIntegrations = resolution.integrations;
|
|
594
|
+
// A hosted run returns each package it resolved (cli-surface INV30).
|
|
595
|
+
recordResolvedIntegrations(loadedIntegrations);
|
|
583
596
|
// The picker (getCliInvocation) is synchronous, so the commands these
|
|
584
597
|
// integrations declare are recorded here, where they become known.
|
|
585
598
|
recordDeclaredCliCommands(projectDir, loadedIntegrations);
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Whether a component doc is hidden (`hidden: true`), read as discovery
|
|
6
|
+
* reads it: discovery skips a hidden doc.
|
|
7
|
+
* @param {string} docPath
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
export function isHiddenComponentDoc(docPath: string): boolean;
|
|
4
11
|
/**
|
|
5
12
|
* The entry a family doc gives `name` in its `components`, when the doc is not
|
|
6
13
|
* the component's own (Stack's doc for VStack); null otherwise.
|
|
@@ -117,6 +124,36 @@ export function discoverExternalComponentsGrouped(docsDir: string): Record<strin
|
|
|
117
124
|
export function findExternalComponentDoc(docsDir: string, name: string): string | null;
|
|
118
125
|
/** @param {string} docPath */
|
|
119
126
|
export function docStem(docPath: string): string;
|
|
127
|
+
/**
|
|
128
|
+
* The local module a doc's import names: the doc's own `import`, else the
|
|
129
|
+
* subpath its directory publishes, read through the package's `exports` (its
|
|
130
|
+
* `main` when it has none). Undefined when the package directory is unknown;
|
|
131
|
+
* null when the import names another package or resolves to no file.
|
|
132
|
+
*
|
|
133
|
+
* @param {{name?: string, __packageDir?: string, __packageExports?: Record<string, unknown>|null}} integration
|
|
134
|
+
* @param {string} docPath
|
|
135
|
+
* @param {Record<string, any> | null} doc
|
|
136
|
+
* @returns {string | null | undefined}
|
|
137
|
+
*/
|
|
138
|
+
export function importedModule(integration: {
|
|
139
|
+
name?: string;
|
|
140
|
+
__packageDir?: string;
|
|
141
|
+
__packageExports?: Record<string, unknown> | null;
|
|
142
|
+
}, docPath: string, doc: Record<string, any> | null): string | null | undefined;
|
|
143
|
+
/**
|
|
144
|
+
* The file an import of the package's own name resolves to, through its
|
|
145
|
+
* package.json `exports` (or `main` when it has none): `@acme/kit` or
|
|
146
|
+
* `@acme/kit/widget`. Null when the specifier names another package, or the
|
|
147
|
+
* package publishes nothing at it.
|
|
148
|
+
* @param {{name?: string, __packageDir?: string, __packageExports?: Record<string, unknown> | null}} integration
|
|
149
|
+
* @param {string} specifier
|
|
150
|
+
* @returns {string | null}
|
|
151
|
+
*/
|
|
152
|
+
export function ownPackageModule(integration: {
|
|
153
|
+
name?: string;
|
|
154
|
+
__packageDir?: string;
|
|
155
|
+
__packageExports?: Record<string, unknown> | null;
|
|
156
|
+
}, specifier: string): string | null;
|
|
120
157
|
/**
|
|
121
158
|
* The `.tsx` file in `folder`, or below it, that declares `name`, taking files
|
|
122
159
|
* in path order: the source of a member whose import never reaches a `.tsx`
|