@astryxdesign/cli 0.6.6-canary.fa4c5fc → 0.6.6-canary.fb78fa1
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 +83 -83
- package/api/build/_adapter.d.mts +15 -0
- package/api/build/_adapter.mjs +22 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.type.d.mts +4 -0
- package/api/build/build.type.mjs +1 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +12 -1
- package/api/doctor/_adapter.d.mts +7 -0
- package/api/doctor/_adapter.mjs +48 -0
- package/api/doctor/doctor.mjs +5 -3
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +115 -1
- package/api/doctor/theme-checks.test.mjs +142 -1
- package/api/init/run/run.mjs +1 -0
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +43 -0
- package/api/search/search.domain-priority.test.mjs +247 -0
- package/api/search/search.mjs +170 -29
- package/api/template/copy/copy.mjs +12 -0
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.type.d.mts +3 -0
- package/api/template/template.type.mjs +3 -0
- package/api/theme/build/build.d.mts +70 -0
- package/api/theme/build/build.mjs +205 -41
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/assets/docs/author-a-theme.doc.mjs +13 -8
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/layout.doc.mjs +20 -0
- package/assets/docs/use-a-theme.doc.mjs +6 -3
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +1 -0
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +68 -18
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +1 -0
- package/clients/cli/commands/docs.test.mjs +2 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +17 -1
- package/clients/cli/commands/import-hint-correctness.test.mjs +23 -0
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +1 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.mjs +6 -11
- package/clients/cli/commands/search.test.mjs +6 -2
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.mjs +4 -3
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +9 -6
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/foundation/agent-docs/agent-docs.mjs +4 -1
- package/foundation/agent-docs/agent-docs.test.mjs +18 -0
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/env/package-manager.d.mts +28 -8
- package/foundation/env/package-manager.mjs +49 -10
- package/foundation/env/package-manager.test.mjs +93 -1
- package/foundation/response/response-types.doc.mjs +4 -4
- package/package.json +9 -9
|
@@ -16,7 +16,7 @@ export const doc = {
|
|
|
16
16
|
summary: 'Diagnose Astryx projects and integration packages',
|
|
17
17
|
description:
|
|
18
18
|
'Runs read-only project health diagnostics by default: Node version, @astryxdesign/core ' +
|
|
19
|
-
'install and version alignment, generated app themes when present, earlier copied-theme migration, config, integrations (linked without a config entry, ' +
|
|
19
|
+
'install and version alignment, theme packages, generated app themes when present, earlier copied-theme migration, config, integrations (linked without a config entry, ' +
|
|
20
20
|
'provider identity, contribution issues), agent docs, core peer dependencies, package manager, ' +
|
|
21
21
|
"and the docs the CLI reads. It writes nothing, but loading astryx.config runs that file's code. " +
|
|
22
22
|
'The `integration` subcommands provide authoring checks for one integration package.',
|
|
@@ -168,7 +168,23 @@ describe('doctor — individual checks', () => {
|
|
|
168
168
|
it('agent-docs: INFO when no docs present', () => {
|
|
169
169
|
const res = checkAgentDocs({cwd: tmpDir});
|
|
170
170
|
expect(res.status).toBe('info');
|
|
171
|
-
expect(res.fix).toContain('
|
|
171
|
+
expect(res.fix).toContain('init --features agents');
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
// The npm package named `astryx` is not this CLI: a project without the
|
|
175
|
+
// `astryx` bin gets the scoped package in the fix, one with it keeps the bin.
|
|
176
|
+
it('agent-docs: the fix names the scoped package when the project has no local CLI', () => {
|
|
177
|
+
fs.writeFileSync(path.join(tmpDir, 'package-lock.json'), '{}');
|
|
178
|
+
const res = checkAgentDocs({cwd: tmpDir});
|
|
179
|
+
expect(res.fix).toContain('`npx @astryxdesign/cli init --features agents`');
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('agent-docs: the fix keeps `npx astryx` when the project has a local CLI', () => {
|
|
183
|
+
fs.writeFileSync(path.join(tmpDir, 'package-lock.json'), '{}');
|
|
184
|
+
fs.mkdirSync(path.join(tmpDir, 'node_modules', '.bin'), {recursive: true});
|
|
185
|
+
fs.writeFileSync(path.join(tmpDir, 'node_modules', '.bin', 'astryx'), '');
|
|
186
|
+
const res = checkAgentDocs({cwd: tmpDir});
|
|
187
|
+
expect(res.fix).toContain('`npx astryx init --features agents`');
|
|
172
188
|
});
|
|
173
189
|
|
|
174
190
|
it('agent-docs: WARN when docs exist without XDS markers', () => {
|
|
@@ -248,4 +248,27 @@ describe('import hint correctness', () => {
|
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
});
|
|
251
|
+
|
|
252
|
+
describe('CLI --detail brief text output for a single component', () => {
|
|
253
|
+
it('brief text output names the component and its package', async () => {
|
|
254
|
+
const result = await runCli(['component', 'Button', '--detail', 'brief'], REPO_ROOT);
|
|
255
|
+
expect(result.code).toBe(0);
|
|
256
|
+
expect(result.stdout).toContain('Button');
|
|
257
|
+
expect(result.stdout).toContain('@astryxdesign/core');
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
it('brief text is shorter than compact text', async () => {
|
|
261
|
+
const brief = await runCli(['component', 'Button', '--detail', 'brief'], REPO_ROOT);
|
|
262
|
+
const compact = await runCli(['component', 'Button', '--detail', 'compact'], REPO_ROOT);
|
|
263
|
+
expect(brief.code).toBe(0);
|
|
264
|
+
expect(compact.code).toBe(0);
|
|
265
|
+
expect(brief.stdout.length).toBeLessThan(compact.stdout.length);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('brief text shows the import path in the signature line', async () => {
|
|
269
|
+
const result = await runCli(['component', 'Button', '--detail', 'brief'], REPO_ROOT);
|
|
270
|
+
expect(result.code).toBe(0);
|
|
271
|
+
expect(result.stdout).toContain('@astryxdesign/core/Button');
|
|
272
|
+
});
|
|
273
|
+
});
|
|
251
274
|
});
|
|
@@ -62,5 +62,6 @@ export const doc = {
|
|
|
62
62
|
},
|
|
63
63
|
],
|
|
64
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."}],
|
|
65
66
|
related: ['layout expand', 'layout grammar'],
|
|
66
67
|
};
|
|
@@ -82,5 +82,6 @@ export const doc = {
|
|
|
82
82
|
},
|
|
83
83
|
],
|
|
84
84
|
deprecated: 'DEP-0006: Use `astryx build` to start from a template, `astryx template` to scaffold, and `astryx docs layout` for guidance.',
|
|
85
|
+
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."}],
|
|
85
86
|
related: ['layout check', 'layout grammar'],
|
|
86
87
|
};
|
|
@@ -27,5 +27,6 @@ export const doc = {
|
|
|
27
27
|
{code: 1, when: 'the component registry cannot be read'},
|
|
28
28
|
],
|
|
29
29
|
deprecated: 'DEP-0006: Use `astryx build` to start from a template, `astryx template` to scaffold, and `astryx docs layout` for guidance.',
|
|
30
|
+
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."}],
|
|
30
31
|
related: ['layout expand', 'layout check'],
|
|
31
32
|
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Deprecation lifecycle coverage for the layout command group (DEP-0006).
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the DEP-0005 theme-add-lifecycle tests: pins the JSON
|
|
7
|
+
* `meta.deprecations` entry, the human-mode stderr warning, the help label,
|
|
8
|
+
* and the docs reference pages.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {describe, it, expect} from 'vitest';
|
|
12
|
+
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
13
|
+
|
|
14
|
+
const SLOW = 30_000;
|
|
15
|
+
|
|
16
|
+
describe('layout DEP-0006 lifecycle', () => {
|
|
17
|
+
it('JSON mode carries meta.deprecations with DEP-0006 and its replacements', async () => {
|
|
18
|
+
const result = await runCli(['layout', 'grammar', '--json']);
|
|
19
|
+
expect(result.status).toBe(0);
|
|
20
|
+
const envelope = JSON.parse(result.stdout);
|
|
21
|
+
expect(envelope.meta).toBeDefined();
|
|
22
|
+
expect(envelope.meta.deprecations).toEqual([
|
|
23
|
+
{
|
|
24
|
+
id: 'DEP-0006',
|
|
25
|
+
replacements: ['build', 'template', 'docs layout'],
|
|
26
|
+
},
|
|
27
|
+
]);
|
|
28
|
+
// Canonical data is unchanged
|
|
29
|
+
expect(envelope.type).toBe('layout.grammar');
|
|
30
|
+
expect(envelope.data.text).toBeDefined();
|
|
31
|
+
expect(envelope.data.aliases).toBeDefined();
|
|
32
|
+
}, SLOW);
|
|
33
|
+
|
|
34
|
+
it('human mode emits one stderr deprecation warning', async () => {
|
|
35
|
+
const result = await runCli(['layout', 'grammar']);
|
|
36
|
+
expect(result.status).toBe(0);
|
|
37
|
+
expect(result.stderr).toContain('[DEP-0006]');
|
|
38
|
+
expect(result.stderr).toContain('astryx layout is deprecated');
|
|
39
|
+
expect(result.stderr).toContain('astryx build');
|
|
40
|
+
expect(result.stderr).toContain('astryx template');
|
|
41
|
+
expect(result.stderr).toContain('astryx docs layout');
|
|
42
|
+
}, SLOW);
|
|
43
|
+
|
|
44
|
+
it('JSON mode does NOT emit the stderr warning', async () => {
|
|
45
|
+
const result = await runCli(['layout', 'grammar', '--json']);
|
|
46
|
+
expect(result.stderr).not.toContain('[DEP-0006]');
|
|
47
|
+
}, SLOW);
|
|
48
|
+
|
|
49
|
+
it('layout --help labels the command as deprecated', async () => {
|
|
50
|
+
const result = await runCli(['layout', '--help']);
|
|
51
|
+
expect(result.stdout).toContain('DEPRECATED');
|
|
52
|
+
expect(result.stdout).toContain('DEP-0006');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('layout expand --json carries the same meta.deprecations', async () => {
|
|
56
|
+
const result = await runCli([
|
|
57
|
+
'layout', 'expand', 'V[g6] > C*2', '--json',
|
|
58
|
+
]);
|
|
59
|
+
expect(result.status).toBe(0);
|
|
60
|
+
const envelope = JSON.parse(result.stdout);
|
|
61
|
+
expect(envelope.meta.deprecations).toEqual([
|
|
62
|
+
{
|
|
63
|
+
id: 'DEP-0006',
|
|
64
|
+
replacements: ['build', 'template', 'docs layout'],
|
|
65
|
+
},
|
|
66
|
+
]);
|
|
67
|
+
expect(envelope.type).toBe('layout.expand');
|
|
68
|
+
}, SLOW);
|
|
69
|
+
|
|
70
|
+
it('layout check --json carries the same meta.deprecations', async () => {
|
|
71
|
+
const result = await runCli([
|
|
72
|
+
'layout', 'check', 'V[g6] > C*2', '--json',
|
|
73
|
+
]);
|
|
74
|
+
expect(result.status).toBe(0);
|
|
75
|
+
const envelope = JSON.parse(result.stdout);
|
|
76
|
+
expect(envelope.meta.deprecations).toEqual([
|
|
77
|
+
{
|
|
78
|
+
id: 'DEP-0006',
|
|
79
|
+
replacements: ['build', 'template', 'docs layout'],
|
|
80
|
+
},
|
|
81
|
+
]);
|
|
82
|
+
expect(envelope.type).toBe('layout.check');
|
|
83
|
+
}, SLOW);
|
|
84
|
+
|
|
85
|
+
// FR29d: every reference page names DEP-0006 and the replacements.
|
|
86
|
+
// Removing the label from any single page must fail this test.
|
|
87
|
+
describe('docs reference pages name DEP-0006', () => {
|
|
88
|
+
const COMMAND_PAGES = [
|
|
89
|
+
'cli/commands/layout',
|
|
90
|
+
'cli/commands/layout-expand',
|
|
91
|
+
'cli/commands/layout-check',
|
|
92
|
+
'cli/commands/layout-grammar',
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const FUNCTION_PAGES = [
|
|
96
|
+
'cli/api/functions/layout-expand',
|
|
97
|
+
'cli/api/functions/layout-check',
|
|
98
|
+
'cli/api/functions/layout-grammar',
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
for (const page of COMMAND_PAGES) {
|
|
102
|
+
it(`${page} names DEP-0006 and replacements`, async () => {
|
|
103
|
+
const result = await runCli(['docs', page, '--json']);
|
|
104
|
+
expect(result.status, result.stderr).toBe(0);
|
|
105
|
+
const body = result.stdout;
|
|
106
|
+
expect(body).toContain('DEP-0006');
|
|
107
|
+
expect(body).toContain('build');
|
|
108
|
+
expect(body).toContain('template');
|
|
109
|
+
expect(body).toContain('docs layout');
|
|
110
|
+
}, SLOW);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for (const page of FUNCTION_PAGES) {
|
|
114
|
+
it(`${page} names DEP-0006 and replacements`, async () => {
|
|
115
|
+
const result = await runCli(['docs', page, '--json']);
|
|
116
|
+
expect(result.status, result.stderr).toBe(0);
|
|
117
|
+
const body = result.stdout;
|
|
118
|
+
expect(body).toContain('DEP-0006');
|
|
119
|
+
expect(body).toContain('build');
|
|
120
|
+
expect(body).toContain('template');
|
|
121
|
+
expect(body).toContain('docs layout');
|
|
122
|
+
}, SLOW);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('response-types reference names DEP-0006 in each layout entry description', async () => {
|
|
127
|
+
const result = await runCli(['docs', 'cli/api/enums/response-types', '--json']);
|
|
128
|
+
expect(result.status, result.stderr).toBe(0);
|
|
129
|
+
const envelope = JSON.parse(result.stdout);
|
|
130
|
+
// The enum page has a table in its content; each row is [value, description].
|
|
131
|
+
const tables = envelope.data.content.filter(b => b.type === 'table');
|
|
132
|
+
const rows = tables.flatMap(t => t.rows || []);
|
|
133
|
+
for (const type of ['layout.expand', 'layout.check', 'layout.grammar']) {
|
|
134
|
+
const row = rows.find(r => r[0] && r[0].includes(type));
|
|
135
|
+
expect(row, `${type} not found in response-types table`).toBeDefined();
|
|
136
|
+
expect(row[1], `${type} description missing DEP-0006`).toContain('DEP-0006');
|
|
137
|
+
expect(row[1], `${type} description missing replacements`).toContain('replacement');
|
|
138
|
+
}
|
|
139
|
+
}, SLOW);
|
|
140
|
+
});
|
|
@@ -31,5 +31,6 @@ export const doc = {
|
|
|
31
31
|
{code: 1, when: 'no subcommand (help is printed) or an unknown subcommand'},
|
|
32
32
|
],
|
|
33
33
|
deprecated: 'DEP-0006: Use `astryx build` to start from a template, `astryx template` to scaffold, and `astryx docs layout` for guidance.',
|
|
34
|
+
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."}],
|
|
34
35
|
related: ['template', 'build'],
|
|
35
36
|
};
|
|
@@ -63,17 +63,12 @@ import {NO_RESULT_SET, resultSet} from '../../../foundation/debug/index.mjs';
|
|
|
63
63
|
* DEP-0006: the `astryx layout` command group is deprecated.
|
|
64
64
|
*
|
|
65
65
|
* Human mode: one stderr warning per invocation.
|
|
66
|
-
* JSON mode: `meta.
|
|
66
|
+
* JSON mode: `meta.deprecations` array in the response envelope.
|
|
67
67
|
*/
|
|
68
|
-
const
|
|
68
|
+
const LAYOUT_DEPRECATION = Object.freeze({
|
|
69
69
|
id: 'DEP-0006',
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
'astryx build "<idea>" — choose the template to start from',
|
|
73
|
-
'astryx template <name> <path> — scaffold it',
|
|
74
|
-
'astryx docs layout — layout guidance',
|
|
75
|
-
],
|
|
76
|
-
};
|
|
70
|
+
replacements: ['build', 'template', 'docs layout'],
|
|
71
|
+
});
|
|
77
72
|
|
|
78
73
|
function warnDeprecated() {
|
|
79
74
|
if (!isJsonMode()) {
|
|
@@ -91,10 +86,10 @@ function warnDeprecated() {
|
|
|
91
86
|
* Add deprecation metadata to a JSON response before output.
|
|
92
87
|
* Canonical stdout (type, data) is unchanged; the metadata sits in `meta`.
|
|
93
88
|
* @param {{type: string, data: unknown}} result
|
|
94
|
-
* @returns {{type: string, data: unknown, meta: {
|
|
89
|
+
* @returns {{type: string, data: unknown, meta: {deprecations: [typeof LAYOUT_DEPRECATION]}}}
|
|
95
90
|
*/
|
|
96
91
|
function withDeprecation(result) {
|
|
97
|
-
return {...result, meta: {
|
|
92
|
+
return {...result, meta: {deprecations: [LAYOUT_DEPRECATION]}};
|
|
98
93
|
}
|
|
99
94
|
|
|
100
95
|
/** The largest layout expression read from --file or stdin. */
|
|
@@ -53,7 +53,11 @@ function asText(value) {
|
|
|
53
53
|
* @param {unknown} value
|
|
54
54
|
*/
|
|
55
55
|
function printsField(lines, key, value) {
|
|
56
|
-
|
|
56
|
+
// The text prefixes a command (`command`, `parent`) with the project's
|
|
57
|
+
// invocation (`pnpm exec astryx`, or `pnpm dlx @astryxdesign/cli` where no
|
|
58
|
+
// `astryx` bin is installed), so compare the part after `astryx`.
|
|
59
|
+
const text = asText(value).split('\n')[0].trimEnd();
|
|
60
|
+
const shown = text.replace(/^astryx /, '');
|
|
57
61
|
return lines.some(line => line.startsWith(`${key}:`) && line.trimEnd().endsWith(shown));
|
|
58
62
|
}
|
|
59
63
|
|
|
@@ -282,7 +286,7 @@ describe('search CLI — exit codes + JSON contract', () => {
|
|
|
282
286
|
|
|
283
287
|
it('renders each result as a greppable key: value record', async () => {
|
|
284
288
|
const r = await runCli(['search', 'button'], REPO_ROOT);
|
|
285
|
-
expect(r.stdout).
|
|
289
|
+
expect(r.stdout).toMatch(/^command:\s+\S.*(?:astryx|@astryxdesign\/cli) component Button$/m);
|
|
286
290
|
// Fields mirror the JSON object and are line-greppable.
|
|
287
291
|
expect(r.stdout).toMatch(/^name:\s+Button$/m);
|
|
288
292
|
expect(r.stdout).toMatch(/^domain:\s+component$/m);
|
|
@@ -305,7 +305,8 @@ describe('swizzle — StyleX build setup note (#3373)', () => {
|
|
|
305
305
|
expect(humanResult.stdout).toMatch(/StyleX compiler/i);
|
|
306
306
|
expect(humanResult.stdout).toMatch(/unstyled/i);
|
|
307
307
|
expect(humanResult.stdout).toMatch(/next\/font/i);
|
|
308
|
-
|
|
308
|
+
// The fixture has no `astryx` bin installed, so the note names the scoped package.
|
|
309
|
+
expect(humanResult.stdout).toMatch(/@astryxdesign\/cli docs styling/);
|
|
309
310
|
});
|
|
310
311
|
|
|
311
312
|
it('does not print the StyleX note for components without StyleX', async () => {
|
|
@@ -137,9 +137,9 @@ export function registerTemplate(program) {
|
|
|
137
137
|
return lines.join('\n');
|
|
138
138
|
};
|
|
139
139
|
emit(
|
|
140
|
-
section(`Page Templates (${pages.length})`),
|
|
140
|
+
pages.length > 0 && section(`Page Templates (${pages.length})`),
|
|
141
141
|
pages.length > 0 && text(grouped(pages)),
|
|
142
|
-
section(`Block Templates (${blocks.length})`),
|
|
142
|
+
blocks.length > 0 && section(`Block Templates (${blocks.length})`),
|
|
143
143
|
blocks.length > 0 && text(grouped(blocks)),
|
|
144
144
|
section('Usage'),
|
|
145
145
|
text(
|
|
@@ -220,7 +220,7 @@ export function registerTemplate(program) {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
case 'template.copy': {
|
|
223
|
-
const {outputDir, fileName, demoMediaReplaced} = result.data;
|
|
223
|
+
const {outputDir, fileName, demoMediaReplaced, notes} = result.data;
|
|
224
224
|
const file = `${outputDir}/${fileName}`;
|
|
225
225
|
emit(
|
|
226
226
|
text(`Copied template to ${file}`),
|
|
@@ -230,6 +230,7 @@ export function registerTemplate(program) {
|
|
|
230
230
|
`Replaced ${demoMediaReplaced} Astryx demo media reference${demoMediaReplaced === 1 ? '' : 's'} in ${file}: ` +
|
|
231
231
|
'images now show a neutral placeholder and videos have an empty source. Supply your own media there.',
|
|
232
232
|
),
|
|
233
|
+
...notes.map(/** @param {string} note */ note => text(note)),
|
|
233
234
|
);
|
|
234
235
|
break;
|
|
235
236
|
}
|
|
@@ -7,6 +7,7 @@ import * as fs from 'node:fs';
|
|
|
7
7
|
import * as os from 'node:os';
|
|
8
8
|
import * as path from 'node:path';
|
|
9
9
|
import {runCli} from '../../../test-utils/run-cli.mjs';
|
|
10
|
+
import {getCliInvocation} from '../../../foundation/env/package-manager.mjs';
|
|
10
11
|
|
|
11
12
|
let tmpDir;
|
|
12
13
|
|
|
@@ -35,10 +36,11 @@ describe('theme add compatibility lifecycle', () => {
|
|
|
35
36
|
expect(result.stderr.match(/source copying is deprecated/g)).toHaveLength(
|
|
36
37
|
1,
|
|
37
38
|
);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
);
|
|
39
|
+
// The app has no CLI installed, so the commands name the scoped package.
|
|
40
|
+
const run = getCliInvocation(tmpDir);
|
|
41
|
+
expect(run).toMatch(/ @astryxdesign\/cli$/);
|
|
42
|
+
expect(result.stderr).toContain(`${run} theme eject neutral`);
|
|
43
|
+
expect(result.stderr).toContain(`${run} theme add neutral --import`);
|
|
42
44
|
expect(fs.existsSync(path.join(tmpDir, 'src/themes/neutral'))).toBe(true);
|
|
43
45
|
expect(fs.existsSync(path.join(tmpDir, 'src/astryx-themes.ts'))).toBe(
|
|
44
46
|
false,
|
|
@@ -77,11 +79,12 @@ describe('theme add compatibility lifecycle', () => {
|
|
|
77
79
|
|
|
78
80
|
const textResult = await runCli(['theme', 'add', '--list'], tmpDir);
|
|
79
81
|
expect(textResult.status, textResult.stderr).toBe(0);
|
|
82
|
+
const run = getCliInvocation(tmpDir);
|
|
80
83
|
expect(textResult.stdout).toContain(
|
|
81
|
-
|
|
84
|
+
`Import one: ${run} theme add <slug> --import [--package <package>]`,
|
|
82
85
|
);
|
|
83
86
|
expect(textResult.stdout).toContain(
|
|
84
|
-
|
|
87
|
+
`Fork source: ${run} theme eject <slug> [target-path]`,
|
|
85
88
|
);
|
|
86
89
|
expect(textResult.stdout).not.toContain('theme add <slug> [target-path]');
|
|
87
90
|
expect(textResult.stderr).not.toContain('deprecated');
|
|
@@ -21,7 +21,9 @@ export const doc = {
|
|
|
21
21
|
'theme. --family combines one selected extension tree into the three files named by ' +
|
|
22
22
|
'the required --family-key, ready for one CSS load and identity-only switching. ' +
|
|
23
23
|
'With --check it writes nothing and reports source drift. --icons-specifier keeps ' +
|
|
24
|
-
'its existing generated-module behavior.'
|
|
24
|
+
'its existing generated-module behavior. It prints one line per built theme and ' +
|
|
25
|
+
'one line naming fonts the themes do not load; --detail full adds the install ' +
|
|
26
|
+
'example and the font recipe, once for a batch.',
|
|
25
27
|
fn: 'themeBuild',
|
|
26
28
|
args: [{name: 'files', param: 'file', required: true, variadic: true}],
|
|
27
29
|
options: [
|
|
@@ -187,8 +187,9 @@ describe('upgrade — core codemods run before config load', () => {
|
|
|
187
187
|
|
|
188
188
|
const out = await runHuman(['upgrade', '--from', '0.1.2', '--path', 'src']);
|
|
189
189
|
expect(out).toMatch(/fails strict validation/i);
|
|
190
|
+
// The fixture has no `astryx` bin installed, so the command names the scoped package.
|
|
190
191
|
expect(out).toContain(
|
|
191
|
-
'
|
|
192
|
+
'@astryxdesign/cli upgrade --from 0.1.2 --codemod migrate-layout-components-to-experimental --apply',
|
|
192
193
|
);
|
|
193
194
|
expect(exitCode).not.toBe(1);
|
|
194
195
|
});
|
package/clients/cli/index.mjs
CHANGED
|
@@ -362,7 +362,7 @@ export async function createProgram() {
|
|
|
362
362
|
.addOption(
|
|
363
363
|
new Option(
|
|
364
364
|
'--detail <level>',
|
|
365
|
-
'Detail level for component, hook, and docs tree reads (e.g. docs cli/commands/build). Lists default to brief',
|
|
365
|
+
'Detail level for component, hook, and docs tree reads (e.g. docs cli/commands/build), and for theme build reports. Lists default to brief; theme build prints one line per built theme unless full, which adds the install example and font recipe',
|
|
366
366
|
)
|
|
367
367
|
.choices(['full', 'compact', 'brief'])
|
|
368
368
|
.default('full'),
|
|
@@ -56,7 +56,7 @@ describe('formatFull sub-component rendering', () => {
|
|
|
56
56
|
expect(out).toContain('### XDSRadioListItem');
|
|
57
57
|
expect(out).not.toContain('undefined');
|
|
58
58
|
// Points the reader at the sub-component's own docs instead of a blank.
|
|
59
|
-
expect(out).
|
|
59
|
+
expect(out).toMatch(/(?:astryx|@astryxdesign\/cli) component XDSRadioListItem/);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
it('renders a full props table for a sub-component that has inline props', () => {
|
|
@@ -122,6 +122,10 @@ export function defineCommand(parent, doc, {fn, action} = {}) {
|
|
|
122
122
|
const cmd = parent.command(argSpec ? `${token} ${argSpec}` : token);
|
|
123
123
|
Object.defineProperty(cmd, COMMAND_DOCS, {value: {doc, fn}, configurable: true});
|
|
124
124
|
if (doc.summary) cmd.description(doc.summary);
|
|
125
|
+
if (doc.deprecated) {
|
|
126
|
+
const base = cmd.description() || '';
|
|
127
|
+
cmd.description(`${base} [DEPRECATED: ${doc.deprecated}]`);
|
|
128
|
+
}
|
|
125
129
|
|
|
126
130
|
const paramDesc = (/** @type {string | undefined} */ name) =>
|
|
127
131
|
(fn?.params ?? []).find(p => p.name === name)?.description ?? '';
|
|
@@ -335,6 +335,9 @@ export function detectStylingSystem(targetDir) {
|
|
|
335
335
|
// Key off a StyleX *compiler* plugin — the runtime alone won't render.
|
|
336
336
|
const stylexCompilers = [
|
|
337
337
|
'@stylexjs/babel-plugin',
|
|
338
|
+
'@stylexjs/rollup-plugin',
|
|
339
|
+
'@stylexjs/webpack-plugin',
|
|
340
|
+
'@stylexjs/nextjs-plugin',
|
|
338
341
|
'vite-plugin-stylex',
|
|
339
342
|
'unplugin-stylex',
|
|
340
343
|
'@stylexswc/unplugin',
|
|
@@ -452,7 +455,7 @@ export function generateCompressedIndex(
|
|
|
452
455
|
} else if (stylingSystem === 'tailwind') {
|
|
453
456
|
lines.push('- Style with component props first, then Tailwind utilities backed by tokens. No raw hex/px.');
|
|
454
457
|
} else {
|
|
455
|
-
lines.push("- Style with component props first, then tokens (var(--color-*|--spacing-*|--radius-*)). No raw hex/px. No StyleX/Tailwind compiler here — don't use xstyle/utility classes.");
|
|
458
|
+
lines.push("- Style with component props first, then tokens (var(--color-*|--spacing-*|--radius-*)). No raw hex/px. No StyleX/Tailwind compiler here — don't use xstyle/utility classes directly. Some templates use StyleX and need a compiler plugin; see `astryx docs styling-overview`.");
|
|
456
459
|
}
|
|
457
460
|
lines.push('- Palettes and custom colors go through the theme, never :root overrides. See `astryx docs theme`.');
|
|
458
461
|
// Self-check — post-generation pass. Validated via vibe tests (internal/vibe-tests/
|
|
@@ -89,6 +89,9 @@ describe('generateCompressedIndex', () => {
|
|
|
89
89
|
expect(result).not.toMatch(/xstyle prop/);
|
|
90
90
|
// Must warn that no compiler is present.
|
|
91
91
|
expect(result).toMatch(/No StyleX\/Tailwind compiler/);
|
|
92
|
+
// Must acknowledge that some templates use StyleX and point at the doc.
|
|
93
|
+
expect(result).toMatch(/templates.*StyleX/i);
|
|
94
|
+
expect(result).toMatch(/styling-overview/);
|
|
92
95
|
});
|
|
93
96
|
|
|
94
97
|
it('recommends xstyle when StyleX is configured', () => {
|
|
@@ -371,6 +374,21 @@ describe('detectStylingSystem', () => {
|
|
|
371
374
|
expect(detectStylingSystem(tmpDir)).toBe('stylex');
|
|
372
375
|
});
|
|
373
376
|
|
|
377
|
+
it('detects the official Rollup/Vite plugin', () => {
|
|
378
|
+
writePkg({'@stylexjs/rollup-plugin': '0.10.0'});
|
|
379
|
+
expect(detectStylingSystem(tmpDir)).toBe('stylex');
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it('detects the official Webpack plugin', () => {
|
|
383
|
+
writePkg({'@stylexjs/webpack-plugin': '0.10.0'});
|
|
384
|
+
expect(detectStylingSystem(tmpDir)).toBe('stylex');
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it('detects the official Next.js plugin', () => {
|
|
388
|
+
writePkg({'@stylexjs/nextjs-plugin': '0.10.0'});
|
|
389
|
+
expect(detectStylingSystem(tmpDir)).toBe('stylex');
|
|
390
|
+
});
|
|
391
|
+
|
|
374
392
|
it('detects tailwind when tailwindcss is present', () => {
|
|
375
393
|
writePkg({tailwindcss: '4.0.0'});
|
|
376
394
|
expect(detectStylingSystem(tmpDir)).toBe('tailwind');
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// @generated by scripts/sync-api-types.mjs from the JSDoc in foundation/**/*.mjs.
|
|
2
|
+
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Extract bare (non-relative) package names from ES import statements.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} source Template source code
|
|
8
|
+
* @returns {Set<string>} Unique package names (scoped packages normalized to
|
|
9
|
+
* `@scope/name`, unscoped to the first path segment).
|
|
10
|
+
*/
|
|
11
|
+
export function extractImportedPackages(source: string): Set<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Analyze what a template source needs that the target project lacks.
|
|
14
|
+
*
|
|
15
|
+
* Returns a `notes` array of human-readable setup notes, a structured
|
|
16
|
+
* `missingPackages` list, and an `installCommand` string ready to print.
|
|
17
|
+
* Each note is one actionable line.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} source Template source code
|
|
20
|
+
* @param {string} cwd Target project directory
|
|
21
|
+
* @returns {{
|
|
22
|
+
* notes: string[],
|
|
23
|
+
* missingPackages: string[],
|
|
24
|
+
* installCommand: string | null,
|
|
25
|
+
* }}
|
|
26
|
+
*/
|
|
27
|
+
export function analyzeTemplateNeeds(source: string, cwd: string): {
|
|
28
|
+
notes: string[];
|
|
29
|
+
missingPackages: string[];
|
|
30
|
+
installCommand: string | null;
|
|
31
|
+
};
|