@astryxdesign/cli 0.6.6-canary.fcf255b → 0.6.6-canary.ffa4f72
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/component/component-replacement.test.mjs +12 -0
- package/api/component/component.doc.mjs +5 -2
- package/api/docs/_adapter.mjs +48 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/section/section.d.mts +44 -0
- package/api/docs/detail/section/section.mjs +164 -13
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +28 -17
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.mjs +11 -16
- package/api/docs/docs.test.mjs +9 -10
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +2 -2
- package/api/docs/namespace-section.test.mjs +260 -0
- package/api/docs/token-tables.test.mjs +93 -0
- package/api/doctor/_adapter.d.mts +7 -0
- package/api/doctor/_adapter.mjs +48 -0
- package/api/doctor/doctor.d.mts +6 -0
- package/api/doctor/doctor.mjs +154 -43
- package/api/doctor/doctor.test.mjs +104 -0
- 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/gap-report/gap-report.doc.mjs +2 -1
- package/api/init/run/run.mjs +1 -0
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -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 +44 -0
- package/api/search/search.domain-priority.test.mjs +261 -0
- package/api/search/search.mjs +191 -29
- package/api/swizzle/swizzle.doc.mjs +5 -2
- 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 +19 -14
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/principles.doc.dense.mjs +3 -3
- package/assets/docs/principles.doc.mjs +4 -4
- package/assets/docs/principles.doc.zh.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +5 -5
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/component-migration.doc.mjs +107 -0
- package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
- package/assets/docs/tree/font-setup.doc.mjs +122 -0
- package/assets/docs/tree/headers-and-footers.doc.mjs +0 -1
- package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
- package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
- package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
- package/assets/docs/tree/internationalization.doc.mjs +29 -0
- package/assets/docs/tree/layout.doc.mjs +23 -0
- package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
- package/assets/docs/tree/migration-verification.doc.mjs +67 -0
- package/assets/docs/tree/migration.doc.mjs +28 -0
- package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
- package/assets/docs/tree/other-libraries.doc.mjs +218 -0
- package/assets/docs/tree/responsive.doc.mjs +0 -4
- package/assets/docs/tree/scaffold.doc.mjs +0 -5
- package/assets/docs/tree/side-panels.doc.mjs +0 -1
- package/assets/docs/tree/structure.doc.mjs +0 -4
- package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
- package/assets/docs/tree/styling-basics.doc.mjs +181 -0
- package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
- package/assets/docs/tree/styling.doc.mjs +29 -0
- package/assets/docs/tree/tailwind.doc.mjs +65 -0
- package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
- package/assets/docs/tree/tokens-border.doc.mjs +46 -0
- package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-color.doc.mjs +438 -0
- package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-data.doc.mjs +323 -0
- package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
- package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
- package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
- package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
- package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
- package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
- package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.mjs +54 -0
- package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
- package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
- package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
- package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
- package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
- package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
- package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens.doc.mjs +28 -0
- package/assets/docs/tree/type-scale.doc.mjs +147 -0
- package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
- package/assets/docs/tree/typography.doc.mjs +29 -0
- package/assets/docs/use-a-theme.doc.mjs +162 -47
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -1
- package/assets/theme.template.ts +4 -3
- 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/component/index.mjs +4 -1
- package/clients/cli/commands/component-replacement.text.test.mjs +45 -0
- package/clients/cli/commands/docs.doc.mjs +2 -1
- package/clients/cli/commands/docs.test.mjs +16 -13
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +50 -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.mjs +13 -3
- 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 +18 -2
- package/foundation/agent-docs/agent-docs.test.mjs +18 -0
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- 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/doc-compiler/bundle.mjs +52 -1
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
- package/foundation/doc-compiler/tree.d.mts +10 -0
- package/foundation/doc-compiler/tree.mjs +22 -0
- package/foundation/doc-compiler/tree.test.mjs +3 -2
- package/foundation/env/package-manager.d.mts +31 -8
- package/foundation/env/package-manager.mjs +120 -13
- package/foundation/env/package-manager.test.mjs +174 -1
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- package/foundation/response/response-types.doc.mjs +4 -4
- package/package.json +9 -9
- package/assets/docs/styling-libraries.doc.mjs +0 -469
- package/assets/docs/styling.doc.mjs +0 -412
- package/assets/docs/tokens.doc.dense.mjs +0 -15
- package/assets/docs/tokens.doc.mjs +0 -1491
- package/assets/docs/tokens.doc.zh.mjs +0 -15
- package/assets/docs/typography.doc.mjs +0 -286
|
@@ -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'),
|
|
@@ -638,20 +638,30 @@ export function formatProps(docs, componentName) {
|
|
|
638
638
|
* Format brief summaries for ALL components in one output.
|
|
639
639
|
* `replacements` maps a replaced Core name to the full list entry of the
|
|
640
640
|
* integration component that takes its slot; that entry is printed in its
|
|
641
|
-
* place, naming its package.
|
|
641
|
+
* place, naming its package. `categories`, when given, limits the output to
|
|
642
|
+
* those group keys (the keys of the list result it renders), so the text shows
|
|
643
|
+
* the same groups as the JSON and `replacements` covers every slot it prints.
|
|
642
644
|
* @param {string} coreDir
|
|
643
|
-
* @param {{zh?: boolean, lang?: string, themeData?: any, replacements?: Map<string, any
|
|
645
|
+
* @param {{zh?: boolean, lang?: string, themeData?: any, replacements?: Map<string, any>, categories?: string[]}} [options]
|
|
644
646
|
* @returns {Promise<string>}
|
|
645
647
|
*/
|
|
646
648
|
export async function formatBriefAll(
|
|
647
649
|
coreDir,
|
|
648
|
-
{
|
|
650
|
+
{
|
|
651
|
+
zh = false,
|
|
652
|
+
lang,
|
|
653
|
+
themeData = null,
|
|
654
|
+
replacements = new Map(),
|
|
655
|
+
categories,
|
|
656
|
+
} = {},
|
|
649
657
|
) {
|
|
650
658
|
const components = discoverComponents(coreDir);
|
|
659
|
+
const shown = categories ? new Set(categories) : null;
|
|
651
660
|
/** @type {string[]} */
|
|
652
661
|
const output = [];
|
|
653
662
|
|
|
654
663
|
for (const [key, comps] of Object.entries(components)) {
|
|
664
|
+
if (shown && !shown.has(key)) continue;
|
|
655
665
|
const isUngrouped = comps.length === 1 && comps[0] === key;
|
|
656
666
|
if (!isUngrouped) {
|
|
657
667
|
output.push(`## ${key}\n`);
|
|
@@ -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 ?? '';
|
|
@@ -26,6 +26,7 @@ import {assertWithin, PathSafetyError} from '../fs/path-safety.mjs';
|
|
|
26
26
|
import {getCliInvocation} from '../env/package-manager.mjs';
|
|
27
27
|
import {discoverComponents} from '../discovery/component-discovery.mjs';
|
|
28
28
|
import {Project} from '../config/project.mjs';
|
|
29
|
+
import {cliRootNamespaceNames} from '../doc-compiler/tree.mjs';
|
|
29
30
|
import {humanLog} from '../response/json.mjs';
|
|
30
31
|
import {ERROR_CODES} from '../response/error-codes.mjs';
|
|
31
32
|
import {
|
|
@@ -335,6 +336,9 @@ export function detectStylingSystem(targetDir) {
|
|
|
335
336
|
// Key off a StyleX *compiler* plugin — the runtime alone won't render.
|
|
336
337
|
const stylexCompilers = [
|
|
337
338
|
'@stylexjs/babel-plugin',
|
|
339
|
+
'@stylexjs/rollup-plugin',
|
|
340
|
+
'@stylexjs/webpack-plugin',
|
|
341
|
+
'@stylexjs/nextjs-plugin',
|
|
338
342
|
'vite-plugin-stylex',
|
|
339
343
|
'unplugin-stylex',
|
|
340
344
|
'@stylexswc/unplugin',
|
|
@@ -452,7 +456,7 @@ export function generateCompressedIndex(
|
|
|
452
456
|
} else if (stylingSystem === 'tailwind') {
|
|
453
457
|
lines.push('- Style with component props first, then Tailwind utilities backed by tokens. No raw hex/px.');
|
|
454
458
|
} 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.");
|
|
459
|
+
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
460
|
}
|
|
457
461
|
lines.push('- Palettes and custom colors go through the theme, never :root overrides. See `astryx docs theme`.');
|
|
458
462
|
// Self-check — post-generation pass. Validated via vibe tests (internal/vibe-tests/
|
|
@@ -484,6 +488,7 @@ export function generateCompressedIndex(
|
|
|
484
488
|
.map(f => f.match(/^([\w-]+)\.doc\.mjs$/))
|
|
485
489
|
.filter(/** @returns {m is RegExpMatchArray} */ (m) => m != null)
|
|
486
490
|
.map(m => m[1])
|
|
491
|
+
.concat(cliRootNamespaceNames())
|
|
487
492
|
.sort()
|
|
488
493
|
: []);
|
|
489
494
|
if (resolvedTopics.length > 0) {
|
|
@@ -552,7 +557,18 @@ export async function renderAgentDocsBlock(
|
|
|
552
557
|
`Cannot render agent docs because integration ${packageLabel} has invalid agentDocs: ${invalidAgentDocs.__agentDocsError}`,
|
|
553
558
|
);
|
|
554
559
|
}
|
|
555
|
-
const
|
|
560
|
+
const catalog = await project.docs();
|
|
561
|
+
// Every name `astryx docs <name>` opens: the flat topics, and each root
|
|
562
|
+
// namespace of the docs tree (a topic split into guides keeps its name).
|
|
563
|
+
const topics = [
|
|
564
|
+
...catalog.names(),
|
|
565
|
+
...cliRootNamespaceNames(),
|
|
566
|
+
...catalog.treeInputs.flatMap(inputs =>
|
|
567
|
+
inputs.namespaces
|
|
568
|
+
.filter(input => !input.doc?.placement?.parent)
|
|
569
|
+
.map(input => input.doc.name),
|
|
570
|
+
),
|
|
571
|
+
];
|
|
556
572
|
const agentDocs = project.loadedIntegrations.flatMap(integration => {
|
|
557
573
|
const append = integration.agentDocs?.append ?? [];
|
|
558
574
|
if (append.length === 0) return [];
|
|
@@ -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');
|
|
@@ -432,7 +432,7 @@ describe('Project discovery', () => {
|
|
|
432
432
|
package: '@acme/widgets',
|
|
433
433
|
});
|
|
434
434
|
// The CLI's own topics are still there.
|
|
435
|
-
expect(catalog.resolve('
|
|
435
|
+
expect(catalog.resolve('color').package).toBe('@astryxdesign/cli');
|
|
436
436
|
expect(await project.issues()).toEqual([]);
|
|
437
437
|
});
|
|
438
438
|
|
|
@@ -65,7 +65,7 @@ describe('discoverBuiltinTopics', () => {
|
|
|
65
65
|
it("finds the CLI's own topics and not their localization overlays", () => {
|
|
66
66
|
const topics = discoverBuiltinTopics();
|
|
67
67
|
expect(Object.keys(topics).length).toBeGreaterThan(0);
|
|
68
|
-
expect(topics.
|
|
68
|
+
expect(topics.color).toMatch(/assets[/\\]docs[/\\]color\.doc\.mjs$/);
|
|
69
69
|
for (const name of Object.keys(topics)) {
|
|
70
70
|
expect(name).not.toMatch(/\.(zh|dense)$/);
|
|
71
71
|
}
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Analyze what a scaffolded template needs that the target project lacks.
|
|
5
|
+
*
|
|
6
|
+
* Derives needs from the template's own source — its bare import specifiers —
|
|
7
|
+
* rather than from a hand-maintained list. Every import that is not an Astryx
|
|
8
|
+
* package, react/react-dom, or @stylexjs/stylex is external; the source is the
|
|
9
|
+
* only authority on what a template uses.
|
|
10
|
+
*
|
|
11
|
+
* Shared between `api/template/copy` (the scaffold receipt) and
|
|
12
|
+
* `api/build/kit` (the start recommendation).
|
|
13
|
+
*
|
|
14
|
+
* @position packages/cli/foundation/discovery — template discovery helpers;
|
|
15
|
+
* consumed by the template and build API leaves.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import * as fs from 'node:fs';
|
|
19
|
+
import * as path from 'node:path';
|
|
20
|
+
import module from 'node:module';
|
|
21
|
+
import {CLI_ROOT} from '../fs/paths.mjs';
|
|
22
|
+
import {detectStylingSystem} from '../agent-docs/agent-docs.mjs';
|
|
23
|
+
|
|
24
|
+
// ── Known packages that a template may import without the user installing them.
|
|
25
|
+
// react and react-dom are the framework; @astryxdesign/* is the design system
|
|
26
|
+
// the CLI already told the user to install; @stylexjs/stylex is a peer of Core.
|
|
27
|
+
const FRAMEWORK_PREFIXES = ['react', 'react-dom'];
|
|
28
|
+
const DESIGN_SYSTEM_SCOPE = '@astryxdesign/';
|
|
29
|
+
const STYLEX_RUNTIME = '@stylexjs/stylex';
|
|
30
|
+
|
|
31
|
+
// Node builtins: anything with a `node:` prefix or in builtinModules.
|
|
32
|
+
const NODE_BUILTINS = new Set(module.builtinModules);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Extract bare (non-relative) package names from ES import statements.
|
|
36
|
+
*
|
|
37
|
+
* @param {string} source Template source code
|
|
38
|
+
* @returns {Set<string>} Unique package names (scoped packages normalized to
|
|
39
|
+
* `@scope/name`, unscoped to the first path segment).
|
|
40
|
+
*/
|
|
41
|
+
export function extractImportedPackages(source) {
|
|
42
|
+
// Matches `import … from '<specifier>'`, `import '<specifier>'`, and
|
|
43
|
+
// dynamic `import('<specifier>')`. Only bare specifiers (not starting with
|
|
44
|
+
// `.` or `/`).
|
|
45
|
+
const re = /(?:from\s+|import\s*\(?)['"]((?:@[^/'"]+\/)?[^./'"@][^'"]*)['"]/g;
|
|
46
|
+
/** @type {Set<string>} */
|
|
47
|
+
const pkgs = new Set();
|
|
48
|
+
let m;
|
|
49
|
+
while ((m = re.exec(source)) !== null) {
|
|
50
|
+
const spec = m[1];
|
|
51
|
+
// Skip Node builtins: `node:fs`, `fs`, `fs/promises`, etc.
|
|
52
|
+
if (spec.startsWith('node:')) continue;
|
|
53
|
+
const name = spec.startsWith('@')
|
|
54
|
+
? spec.split('/').slice(0, 2).join('/')
|
|
55
|
+
: spec.split('/')[0];
|
|
56
|
+
if (NODE_BUILTINS.has(name)) continue;
|
|
57
|
+
pkgs.add(name);
|
|
58
|
+
}
|
|
59
|
+
return pkgs;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Detect which package manager the project uses, from its lockfile.
|
|
64
|
+
* @param {string} cwd Project root
|
|
65
|
+
* @returns {'pnpm add' | 'yarn add' | 'bun add' | 'npm install'}
|
|
66
|
+
*/
|
|
67
|
+
function detectInstallCommand(cwd) {
|
|
68
|
+
if (fs.existsSync(path.join(cwd, 'pnpm-lock.yaml'))) return 'pnpm add';
|
|
69
|
+
if (fs.existsSync(path.join(cwd, 'yarn.lock'))) return 'yarn add';
|
|
70
|
+
if (fs.existsSync(path.join(cwd, 'bun.lockb'))) return 'bun add';
|
|
71
|
+
return 'npm install';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Read the CLI package's own devDependencies for authoritative version ranges
|
|
76
|
+
* of external packages the templates use.
|
|
77
|
+
* @returns {Record<string, string>}
|
|
78
|
+
*/
|
|
79
|
+
function cliPackageRanges() {
|
|
80
|
+
try {
|
|
81
|
+
const pkgPath = path.join(CLI_ROOT, 'package.json');
|
|
82
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
83
|
+
return {...pkg.devDependencies};
|
|
84
|
+
} catch {
|
|
85
|
+
return {};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Analyze what a template source needs that the target project lacks.
|
|
91
|
+
*
|
|
92
|
+
* Returns a `notes` array of human-readable setup notes, a structured
|
|
93
|
+
* `missingPackages` list, and an `installCommand` string ready to print.
|
|
94
|
+
* Each note is one actionable line.
|
|
95
|
+
*
|
|
96
|
+
* @param {string} source Template source code
|
|
97
|
+
* @param {string} cwd Target project directory
|
|
98
|
+
* @returns {{
|
|
99
|
+
* notes: string[],
|
|
100
|
+
* missingPackages: string[],
|
|
101
|
+
* installCommand: string | null,
|
|
102
|
+
* }}
|
|
103
|
+
*/
|
|
104
|
+
export function analyzeTemplateNeeds(source, cwd) {
|
|
105
|
+
const imported = extractImportedPackages(source);
|
|
106
|
+
|
|
107
|
+
// ── External packages (not framework / design system / stylex runtime) ──
|
|
108
|
+
const external = [...imported].filter(
|
|
109
|
+
name =>
|
|
110
|
+
!FRAMEWORK_PREFIXES.includes(name) &&
|
|
111
|
+
!name.startsWith(DESIGN_SYSTEM_SCOPE) &&
|
|
112
|
+
name !== STYLEX_RUNTIME,
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Read the project's installed packages.
|
|
116
|
+
/** @type {Record<string, string>} */
|
|
117
|
+
let projectDeps = {};
|
|
118
|
+
try {
|
|
119
|
+
const pkg = JSON.parse(
|
|
120
|
+
fs.readFileSync(path.join(cwd, 'package.json'), 'utf-8'),
|
|
121
|
+
);
|
|
122
|
+
projectDeps = {...pkg.dependencies, ...pkg.devDependencies};
|
|
123
|
+
} catch {
|
|
124
|
+
// No package.json or unreadable — treat everything as missing.
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const missing = external.filter(p => !(p in projectDeps));
|
|
128
|
+
|
|
129
|
+
// Build the install command with version ranges from the CLI workspace.
|
|
130
|
+
let installCommand = null;
|
|
131
|
+
if (missing.length > 0) {
|
|
132
|
+
const pm = detectInstallCommand(cwd);
|
|
133
|
+
const ranges = cliPackageRanges();
|
|
134
|
+
const specs = missing.map(p => (ranges[p] ? `${p}@"${ranges[p]}"` : p));
|
|
135
|
+
installCommand = `${pm} ${specs.join(' ')}`;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ── StyleX compiler ────────────────────────────────────────────────────
|
|
139
|
+
const usesStylex = imported.has(STYLEX_RUNTIME);
|
|
140
|
+
const stylexCompilerNeeded =
|
|
141
|
+
usesStylex && detectStylingSystem(cwd) !== 'stylex';
|
|
142
|
+
|
|
143
|
+
// ── Notes ──────────────────────────────────────────────────────────────
|
|
144
|
+
/** @type {string[]} */
|
|
145
|
+
const notes = [];
|
|
146
|
+
if (missing.length > 0) {
|
|
147
|
+
notes.push(`Install missing dependencies: ${installCommand}`);
|
|
148
|
+
}
|
|
149
|
+
if (stylexCompilerNeeded) {
|
|
150
|
+
notes.push(
|
|
151
|
+
'This template uses StyleX. Your project needs a StyleX compiler plugin \u2014 see `astryx docs styling-overview` for setup steps.',
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return {notes, missingPackages: missing, installCommand};
|
|
156
|
+
}
|