@astryxdesign/cli 0.1.4-canary.1f25f25 → 0.1.4-canary.20ae2bc
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/package.json +9 -14
- package/src/commands/build-theme.mjs +13 -110
- package/templates/pages/table-page-chart/page.tsx +13 -3
- package/templates/pages/table-page-shoe-store-heatmap/page.tsx +18 -4
- package/src/commands/build-theme.variants.test.mjs +0 -204
- package/templates/blocks/components/CodeBlock/CodeBlockTerminal.doc.mjs +0 -14
- package/templates/blocks/components/CodeBlock/CodeBlockTerminal.tsx +0 -24
- package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.doc.mjs +0 -13
- package/templates/blocks/components/Collapsible/CollapsibleDividedAccordion.tsx +0 -33
- package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.doc.mjs +0 -15
- package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.tsx +0 -47
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.1.4-canary.
|
|
3
|
+
"version": "0.1.4-canary.20ae2bc",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -75,16 +75,12 @@
|
|
|
75
75
|
"zod": "^4.4.3"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@astryxdesign/
|
|
79
|
-
"@astryxdesign/
|
|
80
|
-
"@astryxdesign/
|
|
81
|
-
"
|
|
82
|
-
"gpt-tokenizer": "^3.4.0"
|
|
78
|
+
"@astryxdesign/core": "0.1.4-canary.20ae2bc",
|
|
79
|
+
"@astryxdesign/lab": "0.1.4-canary.20ae2bc",
|
|
80
|
+
"@astryxdesign/theme-neutral": "0.1.4-canary.20ae2bc",
|
|
81
|
+
"gpt-tokenizer": "^2.0.0"
|
|
83
82
|
},
|
|
84
83
|
"peerDependenciesMeta": {
|
|
85
|
-
"@astryxdesign/charts": {
|
|
86
|
-
"optional": true
|
|
87
|
-
},
|
|
88
84
|
"@astryxdesign/core": {
|
|
89
85
|
"optional": true
|
|
90
86
|
},
|
|
@@ -96,11 +92,10 @@
|
|
|
96
92
|
}
|
|
97
93
|
},
|
|
98
94
|
"devDependencies": {
|
|
99
|
-
"@astryxdesign/
|
|
100
|
-
"@astryxdesign/
|
|
101
|
-
"@astryxdesign/
|
|
102
|
-
"
|
|
103
|
-
"gpt-tokenizer": "^3.4.0"
|
|
95
|
+
"@astryxdesign/core": "0.1.4-canary.20ae2bc",
|
|
96
|
+
"@astryxdesign/lab": "0.1.4-canary.20ae2bc",
|
|
97
|
+
"@astryxdesign/theme-neutral": "0.1.4-canary.20ae2bc",
|
|
98
|
+
"gpt-tokenizer": "^2.0.0"
|
|
104
99
|
},
|
|
105
100
|
"scripts": {
|
|
106
101
|
"astryx": "node bin/astryx.mjs",
|
|
@@ -175,85 +175,14 @@ async function getKnownValues(componentName) {
|
|
|
175
175
|
return _knownValuesCache.get(componentName);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
/**
|
|
179
|
-
* Resolve `@astryxdesign/core`'s package root relative to the CLI package. Core
|
|
180
|
-
* and the CLI ship as siblings (`@astryxdesign/core`, `@astryxdesign/cli`), so
|
|
181
|
-
* `../../../core` from `src/commands/` reaches core whether installed from npm
|
|
182
|
-
* or run inside the monorepo. Returns null if it can't be found.
|
|
183
|
-
*/
|
|
184
|
-
function resolveCoreRoot() {
|
|
185
|
-
const cliDir = path.dirname(fileURLToPath(import.meta.url));
|
|
186
|
-
const coreRoot = path.resolve(cliDir, '../../../core');
|
|
187
|
-
return fs.existsSync(coreRoot) ? coreRoot : null;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Read the type declarations `@astryxdesign/core/<Component>` exposes so we can
|
|
192
|
-
* check whether a given augmentation-target interface actually exists before
|
|
193
|
-
* generating a module augmentation against it.
|
|
194
|
-
*
|
|
195
|
-
* Reads the shipped `dist/<Component>/index.d.ts` (what a consumer's TypeScript
|
|
196
|
-
* actually sees), falling back to the `src/<Component>/index.ts` in the
|
|
197
|
-
* monorepo. Returns the file contents, or '' if nothing is found.
|
|
198
|
-
*/
|
|
199
|
-
const _componentDeclCache = new Map();
|
|
200
|
-
function readComponentDeclarations(pascalName) {
|
|
201
|
-
if (_componentDeclCache.has(pascalName)) {
|
|
202
|
-
return _componentDeclCache.get(pascalName);
|
|
203
|
-
}
|
|
204
|
-
let contents = '';
|
|
205
|
-
const coreRoot = resolveCoreRoot();
|
|
206
|
-
if (coreRoot) {
|
|
207
|
-
const candidates = [
|
|
208
|
-
path.join(coreRoot, 'dist', pascalName, 'index.d.ts'),
|
|
209
|
-
path.join(coreRoot, 'src', pascalName, 'index.ts'),
|
|
210
|
-
];
|
|
211
|
-
for (const file of candidates) {
|
|
212
|
-
try {
|
|
213
|
-
if (fs.existsSync(file)) {
|
|
214
|
-
contents = fs.readFileSync(file, 'utf-8');
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
} catch {
|
|
218
|
-
// ignore and try the next candidate
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
_componentDeclCache.set(pascalName, contents);
|
|
223
|
-
return contents;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Determine whether `@astryxdesign/core/<Component>` exports an interface named
|
|
228
|
-
* `interfaceName` that can be augmented via module augmentation.
|
|
229
|
-
*
|
|
230
|
-
* Only interfaces are extension points — closed literal-union types (e.g.
|
|
231
|
-
* `HeadingType`, `ButtonSize`) are NOT augmentable, so a generated augmentation
|
|
232
|
-
* against them is dead code. We check that the name is exported (directly or
|
|
233
|
-
* re-exported) as a type/interface.
|
|
234
|
-
*/
|
|
235
|
-
function componentHasAugmentableInterface(pascalName, interfaceName) {
|
|
236
|
-
const decl = readComponentDeclarations(pascalName);
|
|
237
|
-
if (!decl) return false;
|
|
238
|
-
// Word-boundary match so `ButtonVariantMap` doesn't match `XButtonVariantMap`.
|
|
239
|
-
const re = new RegExp(`\\b${interfaceName}\\b`);
|
|
240
|
-
return re.test(decl);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
178
|
/**
|
|
244
179
|
* Generate TypeScript declaration content with module augmentation for custom
|
|
245
180
|
* component prop values found in the theme's `components` keys. Reads known
|
|
246
181
|
* values from doc files to filter out base prop values.
|
|
247
182
|
*
|
|
248
|
-
* Interface naming convention: PascalCase(component) + PascalCase(prop) + Map
|
|
249
|
-
* banner + status →
|
|
250
|
-
* button + variant →
|
|
251
|
-
*
|
|
252
|
-
* An augmentation is only emitted when `@astryxdesign/core/<Component>` actually
|
|
253
|
-
* exports a matching interface. Props backed by closed literal-union types
|
|
254
|
-
* (e.g. Button `size`, Heading `type`/`level`) have no augmentation point, so
|
|
255
|
-
* generating a `declare module` block for them would be dead code — those are
|
|
256
|
-
* skipped.
|
|
183
|
+
* Interface naming convention: Astryx + PascalCase(component) + PascalCase(prop) + Map
|
|
184
|
+
* banner + status → XDSBannerStatusMap
|
|
185
|
+
* button + variant → XDSButtonVariantMap
|
|
257
186
|
*
|
|
258
187
|
* @param {object} themeDef - Theme definition (resolved by defineTheme)
|
|
259
188
|
* @returns {Promise<string|null>} TypeScript declaration content, or null if no augmentations needed
|
|
@@ -305,14 +234,7 @@ async function generateVariantDeclarationsAsync(themeDef) {
|
|
|
305
234
|
const pascal = toPascalCase(component);
|
|
306
235
|
const propPascal = prop.charAt(0).toUpperCase() + prop.slice(1);
|
|
307
236
|
const modulePath = `@astryxdesign/core/${pascal}`;
|
|
308
|
-
const interfaceName =
|
|
309
|
-
|
|
310
|
-
// Only augment interfaces that actually exist as an extension point in
|
|
311
|
-
// core. Props backed by closed literal-union types (e.g. Button `size`,
|
|
312
|
-
// Heading `type`/`level`) have no `*Map` interface — a `declare module`
|
|
313
|
-
// block against a non-existent interface just creates a new, unused
|
|
314
|
-
// interface and never extends the component's prop union, so skip it.
|
|
315
|
-
if (!componentHasAugmentableInterface(pascal, interfaceName)) continue;
|
|
237
|
+
const interfaceName = `XDS${pascal}${propPascal}Map`;
|
|
316
238
|
|
|
317
239
|
sections.push(`declare module '${modulePath}' {`);
|
|
318
240
|
sections.push(` interface ${interfaceName} {`);
|
|
@@ -325,13 +247,6 @@ async function generateVariantDeclarationsAsync(themeDef) {
|
|
|
325
247
|
}
|
|
326
248
|
}
|
|
327
249
|
|
|
328
|
-
// If every custom value targeted a non-augmentable prop, there's nothing to
|
|
329
|
-
// emit beyond the header — return null so no `.variants.d.ts` is written.
|
|
330
|
-
const hasEmittedAugmentation = sections.some(line =>
|
|
331
|
-
line.startsWith('declare module'),
|
|
332
|
-
);
|
|
333
|
-
if (!hasEmittedAugmentation) return null;
|
|
334
|
-
|
|
335
250
|
return sections.join('\n');
|
|
336
251
|
}
|
|
337
252
|
|
|
@@ -518,21 +433,13 @@ ${iconReExport}`;
|
|
|
518
433
|
/**
|
|
519
434
|
* Generate TypeScript declarations for a built theme module.
|
|
520
435
|
*/
|
|
521
|
-
function generateBuiltTypes(themeDef, iconInfo
|
|
436
|
+
function generateBuiltTypes(themeDef, iconInfo) {
|
|
522
437
|
const iconType = iconInfo
|
|
523
438
|
? `import type { IconRegistry } from '@astryxdesign/core/Icon';
|
|
524
439
|
export declare const ${iconInfo.exportName}: IconRegistry;
|
|
525
440
|
`
|
|
526
441
|
: '';
|
|
527
|
-
|
|
528
|
-
// theme's types also loads the module augmentations (otherwise the
|
|
529
|
-
// `.variants.d.ts` is emitted but never referenced, and the custom variants
|
|
530
|
-
// never widen the component prop unions for consumers).
|
|
531
|
-
const variantsRef = variantsFileName
|
|
532
|
-
? `/// <reference path="./${variantsFileName}" />
|
|
533
|
-
`
|
|
534
|
-
: '';
|
|
535
|
-
return `${variantsRef}import type { DefinedTheme } from '@astryxdesign/core/theme';
|
|
442
|
+
return `import type { DefinedTheme } from '@astryxdesign/core/theme';
|
|
536
443
|
${iconType}export declare const ${toIdentifier(themeDef.name)}Theme: DefinedTheme;
|
|
537
444
|
`;
|
|
538
445
|
}
|
|
@@ -987,23 +894,19 @@ export function registerTheme(program) {
|
|
|
987
894
|
|
|
988
895
|
const iconInfo = extractIconInfo(filePath);
|
|
989
896
|
|
|
990
|
-
//
|
|
991
|
-
|
|
897
|
+
// Generate all file contents in memory first.
|
|
898
|
+
const cssContent = generatedHeader(sourceRelative, 'css', buildCommand) + css;
|
|
899
|
+
const jsContent = generatedHeader(sourceRelative, 'js', buildCommand) + generateBuiltModule(resolvedTheme || themeDef, iconInfo);
|
|
900
|
+
const dtsContent = generatedHeader(sourceRelative, 'ts', buildCommand) + generateBuiltTypes(themeDef, iconInfo);
|
|
901
|
+
|
|
902
|
+
// Type augmentation .d.ts if theme has custom prop values
|
|
992
903
|
const augmentationSource = resolvedTheme || themeDef;
|
|
993
904
|
const variantDecl = await generateVariantDeclarationsAsync(augmentationSource);
|
|
994
|
-
const
|
|
995
|
-
const variantDtsPath = variantDecl ? path.join(outDir, variantsFileName) : null;
|
|
905
|
+
const variantDtsPath = variantDecl ? path.join(outDir, `${baseName}.variants.d.ts`) : null;
|
|
996
906
|
const variantContent = variantDecl
|
|
997
907
|
? generatedHeader(sourceRelative, 'ts', buildCommand) + variantDecl
|
|
998
908
|
: null;
|
|
999
909
|
|
|
1000
|
-
// Generate all file contents in memory first. The main .d.ts references
|
|
1001
|
-
// the variants file (when present) via a triple-slash directive so
|
|
1002
|
-
// importing the theme also loads the custom-variant augmentations.
|
|
1003
|
-
const cssContent = generatedHeader(sourceRelative, 'css', buildCommand) + css;
|
|
1004
|
-
const jsContent = generatedHeader(sourceRelative, 'js', buildCommand) + generateBuiltModule(resolvedTheme || themeDef, iconInfo);
|
|
1005
|
-
const dtsContent = generatedHeader(sourceRelative, 'ts', buildCommand) + generateBuiltTypes(themeDef, iconInfo, variantsFileName);
|
|
1006
|
-
|
|
1007
910
|
// Atomic-ish write: stage every file as `<dest>.tmp`, then rename
|
|
1008
911
|
// each into place. If any stage step fails we clean up partials and
|
|
1009
912
|
// exit; if a rename fails mid-way we still have the originals (or
|
|
@@ -19,7 +19,13 @@ import {Link} from '@astryxdesign/core/Link';
|
|
|
19
19
|
import {Thumbnail} from '@astryxdesign/core/Thumbnail';
|
|
20
20
|
import {Table, proportional, pixel} from '@astryxdesign/core/Table';
|
|
21
21
|
import type {TableColumn} from '@astryxdesign/core/Table';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
ChartV2 as Chart,
|
|
24
|
+
ChartGrid,
|
|
25
|
+
ChartAxis,
|
|
26
|
+
area,
|
|
27
|
+
line,
|
|
28
|
+
} from '@astryxdesign/lab';
|
|
23
29
|
import {
|
|
24
30
|
FunnelIcon,
|
|
25
31
|
ArrowDownTrayIcon,
|
|
@@ -475,13 +481,17 @@ const columns: TableColumn<OrderRow>[] = [
|
|
|
475
481
|
key: 'amount',
|
|
476
482
|
header: 'Amount',
|
|
477
483
|
width: pixel(90),
|
|
478
|
-
renderCell: (item: OrderRow) =>
|
|
484
|
+
renderCell: (item: OrderRow) => (
|
|
485
|
+
<Text type="body">${item.amount}</Text>
|
|
486
|
+
),
|
|
479
487
|
},
|
|
480
488
|
{
|
|
481
489
|
key: 'customer',
|
|
482
490
|
header: 'Customer',
|
|
483
491
|
width: proportional(2),
|
|
484
|
-
renderCell: (item: OrderRow) =>
|
|
492
|
+
renderCell: (item: OrderRow) => (
|
|
493
|
+
<Text type="body">{item.customer}</Text>
|
|
494
|
+
),
|
|
485
495
|
},
|
|
486
496
|
{
|
|
487
497
|
key: 'email',
|
|
@@ -19,7 +19,13 @@ import {Link} from '@astryxdesign/core/Link';
|
|
|
19
19
|
import {Thumbnail} from '@astryxdesign/core/Thumbnail';
|
|
20
20
|
import {Table, proportional, pixel} from '@astryxdesign/core/Table';
|
|
21
21
|
import type {TableColumn} from '@astryxdesign/core/Table';
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
ChartV2 as Chart,
|
|
24
|
+
ChartGrid,
|
|
25
|
+
ChartAxis,
|
|
26
|
+
area,
|
|
27
|
+
line,
|
|
28
|
+
} from '@astryxdesign/lab';
|
|
23
29
|
import {
|
|
24
30
|
FunnelIcon,
|
|
25
31
|
ArrowDownTrayIcon,
|
|
@@ -29,7 +35,11 @@ import {
|
|
|
29
35
|
// ============= DATA =============
|
|
30
36
|
|
|
31
37
|
type ProductCategory =
|
|
32
|
-
|
|
38
|
+
| 'Running'
|
|
39
|
+
| 'Lifestyle'
|
|
40
|
+
| 'Basketball'
|
|
41
|
+
| 'Training'
|
|
42
|
+
| 'Skateboarding';
|
|
33
43
|
|
|
34
44
|
function shoeSvg(bg: string, accent: string) {
|
|
35
45
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect width="100" height="100" rx="12" fill="${bg}"/><g transform="translate(22.5, 22.5) scale(2.29)" fill="none" stroke="${accent}" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m15 10.42 4.8-5.07"/><path d="M19 18h3"/><path d="M9.5 22 21.414 9.415A2 2 0 0 0 21.2 6.4l-5.61-4.208A1 1 0 0 0 14 3v2a2 2 0 0 1-1.394 1.906L8.677 8.053A1 1 0 0 0 8 9c-.155 6.393-2.082 9-4 9a2 2 0 0 0 0 4h14"/></g></svg>`;
|
|
@@ -829,13 +839,17 @@ const columns: TableColumn<OrderRow>[] = [
|
|
|
829
839
|
key: 'amount',
|
|
830
840
|
header: 'Amount',
|
|
831
841
|
width: pixel(90),
|
|
832
|
-
renderCell: (item: OrderRow) =>
|
|
842
|
+
renderCell: (item: OrderRow) => (
|
|
843
|
+
<Text type="body">${item.amount}</Text>
|
|
844
|
+
),
|
|
833
845
|
},
|
|
834
846
|
{
|
|
835
847
|
key: 'customer',
|
|
836
848
|
header: 'Customer',
|
|
837
849
|
width: proportional(2),
|
|
838
|
-
renderCell: (item: OrderRow) =>
|
|
850
|
+
renderCell: (item: OrderRow) => (
|
|
851
|
+
<Text type="body">{item.customer}</Text>
|
|
852
|
+
),
|
|
839
853
|
},
|
|
840
854
|
{
|
|
841
855
|
key: 'email',
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @file Regression test for the custom-variant type augmentations emitted by
|
|
5
|
-
* `astryx theme build` (#3391 companion: #3371).
|
|
6
|
-
*
|
|
7
|
-
* When a theme declares a custom component prop value (e.g.
|
|
8
|
-
* `button['variant:accentOutline']`), the build emits a `<name>.variants.d.ts`
|
|
9
|
-
* with a module augmentation so the custom value type-checks. This suite pins
|
|
10
|
-
* the two bugs that made that augmentation dead code:
|
|
11
|
-
*
|
|
12
|
-
* 1. The augmentation targeted a non-existent, `XDS`-prefixed interface
|
|
13
|
-
* (`XDSButtonVariantMap`) instead of core's real `ButtonVariantMap`, so it
|
|
14
|
-
* created a new unused interface and never widened the prop union.
|
|
15
|
-
* 2. Props with no augmentation point (closed literal-union types such as
|
|
16
|
-
* Button `size` or Heading `type`/`level`) still got a `declare module`
|
|
17
|
-
* block against a `*Map` interface that doesn't exist.
|
|
18
|
-
* 3. The generated `.variants.d.ts` was never referenced by the main
|
|
19
|
-
* `<name>.d.ts`, so even a correct augmentation never loaded.
|
|
20
|
-
*
|
|
21
|
-
* Building `astryx theme build` requires a compiled @astryxdesign/core, so this
|
|
22
|
-
* suite builds core once in beforeAll (mirrors build-theme.prose.test.mjs).
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import {describe, it, expect, beforeAll, beforeEach, afterEach} from 'vitest';
|
|
26
|
-
import {execFileSync} from 'node:child_process';
|
|
27
|
-
import * as fs from 'node:fs';
|
|
28
|
-
import * as path from 'node:path';
|
|
29
|
-
import * as os from 'node:os';
|
|
30
|
-
import {fileURLToPath} from 'node:url';
|
|
31
|
-
|
|
32
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
33
|
-
const CLI_BIN = path.resolve(__dirname, '../../bin/astryx.mjs');
|
|
34
|
-
const REPO_ROOT = path.resolve(__dirname, '../../../..');
|
|
35
|
-
const CORE_THEME_ENTRY = path.join(
|
|
36
|
-
REPO_ROOT,
|
|
37
|
-
'packages/core/dist/theme/index.js',
|
|
38
|
-
);
|
|
39
|
-
// The fix reads core's shipped component declarations to decide whether an
|
|
40
|
-
// interface is augmentable; those .d.ts files come from the same core build.
|
|
41
|
-
const CORE_BUTTON_DTS = path.join(
|
|
42
|
-
REPO_ROOT,
|
|
43
|
-
'packages/core/dist/Button/index.d.ts',
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
function runCli(args, cwd) {
|
|
47
|
-
try {
|
|
48
|
-
const out = execFileSync('node', [CLI_BIN, ...args], {
|
|
49
|
-
cwd,
|
|
50
|
-
encoding: 'utf-8',
|
|
51
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
52
|
-
env: {...process.env, FORCE_COLOR: '0'},
|
|
53
|
-
});
|
|
54
|
-
return {code: 0, stdout: out, stderr: ''};
|
|
55
|
-
} catch (e) {
|
|
56
|
-
return {
|
|
57
|
-
code: e.status ?? 1,
|
|
58
|
-
stdout: e.stdout?.toString() ?? '',
|
|
59
|
-
stderr: e.stderr?.toString() ?? '',
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function writeTheme(dir, contents) {
|
|
65
|
-
fs.mkdirSync(dir, {recursive: true});
|
|
66
|
-
const file = path.join(dir, 'variants-theme.mjs');
|
|
67
|
-
fs.writeFileSync(file, contents);
|
|
68
|
-
return file;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
beforeAll(() => {
|
|
72
|
-
if (!fs.existsSync(CORE_THEME_ENTRY) || !fs.existsSync(CORE_BUTTON_DTS)) {
|
|
73
|
-
execFileSync('pnpm', ['-F', '@astryxdesign/core', 'build'], {
|
|
74
|
-
cwd: REPO_ROOT,
|
|
75
|
-
stdio: 'pipe',
|
|
76
|
-
timeout: 180_000,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}, 200_000);
|
|
80
|
-
|
|
81
|
-
let tmpDir;
|
|
82
|
-
beforeEach(() => {
|
|
83
|
-
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-build-theme-variants-'));
|
|
84
|
-
});
|
|
85
|
-
afterEach(() => {
|
|
86
|
-
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe('theme build custom-variant augmentations', () => {
|
|
90
|
-
it('targets the real (un-prefixed) core interface for a custom variant', () => {
|
|
91
|
-
const themeFile = writeTheme(
|
|
92
|
-
tmpDir,
|
|
93
|
-
`export default {
|
|
94
|
-
name: 'variants-theme',
|
|
95
|
-
tokens: { '--color-bg': '#fff' },
|
|
96
|
-
components: {
|
|
97
|
-
button: { 'variant:accentOutline': { backgroundColor: 'transparent' } },
|
|
98
|
-
},
|
|
99
|
-
};\n`,
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
const result = runCli(
|
|
103
|
-
['theme', 'build', path.relative(tmpDir, themeFile)],
|
|
104
|
-
tmpDir,
|
|
105
|
-
);
|
|
106
|
-
expect(result.code).toBe(0);
|
|
107
|
-
|
|
108
|
-
const variantsPath = path.join(tmpDir, 'variants-theme.variants.d.ts');
|
|
109
|
-
expect(fs.existsSync(variantsPath)).toBe(true);
|
|
110
|
-
const dts = fs.readFileSync(variantsPath, 'utf-8');
|
|
111
|
-
|
|
112
|
-
// Targets core's actual augmentation point…
|
|
113
|
-
expect(dts).toContain("declare module '@astryxdesign/core/Button'");
|
|
114
|
-
expect(dts).toMatch(/interface ButtonVariantMap\b/);
|
|
115
|
-
expect(dts).toContain("'accentOutline': true;");
|
|
116
|
-
// …and NOT the old, non-existent XDS-prefixed interface.
|
|
117
|
-
expect(dts).not.toMatch(/XDSButtonVariantMap/);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('skips props with no augmentation point (Button size, Heading type)', () => {
|
|
121
|
-
const themeFile = writeTheme(
|
|
122
|
-
tmpDir,
|
|
123
|
-
`export default {
|
|
124
|
-
name: 'variants-theme',
|
|
125
|
-
tokens: { '--color-bg': '#fff' },
|
|
126
|
-
components: {
|
|
127
|
-
button: {
|
|
128
|
-
'variant:accentOutline': { backgroundColor: 'transparent' },
|
|
129
|
-
'size:jumbo': { paddingBlock: '40px' },
|
|
130
|
-
},
|
|
131
|
-
heading: { 'type:hero': { fontSize: '80px' } },
|
|
132
|
-
},
|
|
133
|
-
};\n`,
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
const result = runCli(
|
|
137
|
-
['theme', 'build', path.relative(tmpDir, themeFile)],
|
|
138
|
-
tmpDir,
|
|
139
|
-
);
|
|
140
|
-
expect(result.code).toBe(0);
|
|
141
|
-
|
|
142
|
-
const variantsPath = path.join(tmpDir, 'variants-theme.variants.d.ts');
|
|
143
|
-
expect(fs.existsSync(variantsPath)).toBe(true);
|
|
144
|
-
const dts = fs.readFileSync(variantsPath, 'utf-8');
|
|
145
|
-
|
|
146
|
-
// The augmentable variant is emitted…
|
|
147
|
-
expect(dts).toMatch(/interface ButtonVariantMap\b/);
|
|
148
|
-
// …but closed literal-union props get no dead augmentation.
|
|
149
|
-
expect(dts).not.toMatch(/ButtonSizeMap/);
|
|
150
|
-
expect(dts).not.toMatch(/HeadingTypeMap/);
|
|
151
|
-
expect(dts).not.toContain("declare module '@astryxdesign/core/Heading'");
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('does not emit a .variants.d.ts when every custom value is non-augmentable', () => {
|
|
155
|
-
const themeFile = writeTheme(
|
|
156
|
-
tmpDir,
|
|
157
|
-
`export default {
|
|
158
|
-
name: 'variants-theme',
|
|
159
|
-
tokens: { '--color-bg': '#fff' },
|
|
160
|
-
components: {
|
|
161
|
-
button: { 'size:jumbo': { paddingBlock: '40px' } },
|
|
162
|
-
},
|
|
163
|
-
};\n`,
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const result = runCli(
|
|
167
|
-
['theme', 'build', path.relative(tmpDir, themeFile)],
|
|
168
|
-
tmpDir,
|
|
169
|
-
);
|
|
170
|
-
expect(result.code).toBe(0);
|
|
171
|
-
expect(
|
|
172
|
-
fs.existsSync(path.join(tmpDir, 'variants-theme.variants.d.ts')),
|
|
173
|
-
).toBe(false);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('references the variants file from the main .d.ts so the augmentation loads', () => {
|
|
177
|
-
const themeFile = writeTheme(
|
|
178
|
-
tmpDir,
|
|
179
|
-
`export default {
|
|
180
|
-
name: 'variants-theme',
|
|
181
|
-
tokens: { '--color-bg': '#fff' },
|
|
182
|
-
components: {
|
|
183
|
-
button: { 'variant:accentOutline': { backgroundColor: 'transparent' } },
|
|
184
|
-
},
|
|
185
|
-
};\n`,
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
const result = runCli(
|
|
189
|
-
['theme', 'build', path.relative(tmpDir, themeFile)],
|
|
190
|
-
tmpDir,
|
|
191
|
-
);
|
|
192
|
-
expect(result.code).toBe(0);
|
|
193
|
-
|
|
194
|
-
const dts = fs.readFileSync(
|
|
195
|
-
path.join(tmpDir, 'variants-theme.d.ts'),
|
|
196
|
-
'utf-8',
|
|
197
|
-
);
|
|
198
|
-
// A triple-slash reference to the variants file, so importing the theme's
|
|
199
|
-
// types also loads the module augmentation.
|
|
200
|
-
expect(dts).toMatch(
|
|
201
|
-
/\/\/\/\s*<reference path="\.\/variants-theme\.variants\.d\.ts"\s*\/>/,
|
|
202
|
-
);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
|
|
4
|
-
export const doc = {
|
|
5
|
-
type: 'block',
|
|
6
|
-
exampleFor: 'CodeBlock',
|
|
7
|
-
name: 'Code — Terminal',
|
|
8
|
-
displayName: 'Code — Terminal',
|
|
9
|
-
description:
|
|
10
|
-
'A dark terminal-style command block: a bash CodeBlock wrapped in SyntaxTheme with the GitHub Dark preset, copy button on, and no line numbers. Use for shell sessions or CLI output that should read as a terminal even on light pages — reach for a dark syntax preset instead of hand-rolling a dark box with custom CSS.',
|
|
11
|
-
isReady: true,
|
|
12
|
-
aspectRatio: 16 / 9,
|
|
13
|
-
componentsUsed: ['CodeBlock', 'SyntaxTheme'],
|
|
14
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
import {SyntaxTheme} from '@astryxdesign/core/theme';
|
|
6
|
-
import {githubDark} from '@astryxdesign/core/theme/syntax';
|
|
7
|
-
import {CodeBlock} from '@astryxdesign/core/CodeBlock';
|
|
8
|
-
|
|
9
|
-
const commands = `$ astryx init --features agents
|
|
10
|
-
✓ AI agent docs installed → .claude/CLAUDE.md
|
|
11
|
-
$ pnpm astryx component CodeBlock --dense`;
|
|
12
|
-
|
|
13
|
-
export default function CodeBlockTerminal() {
|
|
14
|
-
return (
|
|
15
|
-
<SyntaxTheme theme={githubDark}>
|
|
16
|
-
<CodeBlock
|
|
17
|
-
code={commands}
|
|
18
|
-
language="bash"
|
|
19
|
-
hasCopyButton
|
|
20
|
-
style={{width: '100%', maxWidth: 480}}
|
|
21
|
-
/>
|
|
22
|
-
</SyntaxTheme>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
|
|
4
|
-
export const doc = {
|
|
5
|
-
type: 'block',
|
|
6
|
-
exampleFor: 'Collapsible',
|
|
7
|
-
name: 'Collapsible — Divided Accordion',
|
|
8
|
-
displayName: 'Collapsible — Divided Accordion',
|
|
9
|
-
description: 'FAQ-style accordion using the dividers prop on CollapsibleGroup: built-in row hairlines and density padding with zero custom CSS. Use for FAQs, settings lists, and nav sections.',
|
|
10
|
-
isReady: true,
|
|
11
|
-
aspectRatio: 4 / 3,
|
|
12
|
-
componentsUsed: ['Collapsible', 'CollapsibleGroup', 'Text'],
|
|
13
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
import {Collapsible, CollapsibleGroup} from '@astryxdesign/core/Collapsible';
|
|
6
|
-
import {Text} from '@astryxdesign/core/Text';
|
|
7
|
-
|
|
8
|
-
export default function CollapsibleDividedAccordion() {
|
|
9
|
-
return (
|
|
10
|
-
<div style={{width: '100%', maxWidth: 400}}>
|
|
11
|
-
<CollapsibleGroup type="single" dividers="between" defaultValue="reset">
|
|
12
|
-
<Collapsible trigger="How do I reset my password?" value="reset">
|
|
13
|
-
<Text type="body">
|
|
14
|
-
Go to Settings → Security → Change Password. You'll receive a
|
|
15
|
-
confirmation email within a few minutes.
|
|
16
|
-
</Text>
|
|
17
|
-
</Collapsible>
|
|
18
|
-
<Collapsible trigger="Can I change my username?" value="username">
|
|
19
|
-
<Text type="body">
|
|
20
|
-
Usernames can be changed once every 30 days from your profile
|
|
21
|
-
settings.
|
|
22
|
-
</Text>
|
|
23
|
-
</Collapsible>
|
|
24
|
-
<Collapsible trigger="How do I delete my account?" value="delete">
|
|
25
|
-
<Text type="body">
|
|
26
|
-
Account deletion is permanent. Your data will be removed within 30
|
|
27
|
-
days.
|
|
28
|
-
</Text>
|
|
29
|
-
</Collapsible>
|
|
30
|
-
</CollapsibleGroup>
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
|
|
4
|
-
export const doc = {
|
|
5
|
-
type: 'block',
|
|
6
|
-
exampleFor: 'NavHeadingMenu',
|
|
7
|
-
name: 'NavHeadingMenu',
|
|
8
|
-
displayName: 'Nav Heading Menu',
|
|
9
|
-
description:
|
|
10
|
-
'NavHeadingMenu passed as the menu prop of SideNavHeading, letting the heading act as a product switcher popover trigger.',
|
|
11
|
-
isReady: true,
|
|
12
|
-
isShowcase: true,
|
|
13
|
-
aspectRatio: 4 / 3,
|
|
14
|
-
componentsUsed: ['SideNav', 'SideNavHeading', 'NavHeadingMenu', 'NavHeadingMenuItem'],
|
|
15
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
-
|
|
3
|
-
'use client';
|
|
4
|
-
|
|
5
|
-
import {SideNav, SideNavHeading} from '@astryxdesign/core/SideNav';
|
|
6
|
-
import {NavHeadingMenu, NavHeadingMenuItem} from '@astryxdesign/core/NavMenu';
|
|
7
|
-
|
|
8
|
-
function AppIcon() {
|
|
9
|
-
return (
|
|
10
|
-
<svg
|
|
11
|
-
width="20"
|
|
12
|
-
height="20"
|
|
13
|
-
viewBox="0 0 24 24"
|
|
14
|
-
fill="none"
|
|
15
|
-
stroke="currentColor"
|
|
16
|
-
strokeWidth="1.5">
|
|
17
|
-
<path
|
|
18
|
-
strokeLinecap="round"
|
|
19
|
-
strokeLinejoin="round"
|
|
20
|
-
d="M3.75 6A2.25 2.25 0 0 1 6 3.75h2.25A2.25 2.25 0 0 1 10.5 6v2.25a2.25 2.25 0 0 1-2.25 2.25H6a2.25 2.25 0 0 1-2.25-2.25V6ZM3.75 15.75A2.25 2.25 0 0 1 6 13.5h2.25a2.25 2.25 0 0 1 2.25 2.25V18a2.25 2.25 0 0 1-2.25 2.25H6A2.25 2.25 0 0 1 3.75 18v-2.25ZM13.5 6a2.25 2.25 0 0 1 2.25-2.25H18A2.25 2.25 0 0 1 20.25 6v2.25A2.25 2.25 0 0 1 18 10.5h-2.25a2.25 2.25 0 0 1-2.25-2.25V6ZM13.5 15.75a2.25 2.25 0 0 1 2.25-2.25H18a2.25 2.25 0 0 1 2.25 2.25V18A2.25 2.25 0 0 1 18 20.25h-2.25a2.25 2.25 0 0 1-2.25-2.25v-2.25Z"
|
|
21
|
-
/>
|
|
22
|
-
</svg>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default function NavHeadingMenuShowcase() {
|
|
27
|
-
return (
|
|
28
|
-
<div style={{height: 100}}>
|
|
29
|
-
<SideNav
|
|
30
|
-
header={
|
|
31
|
-
<SideNavHeading
|
|
32
|
-
heading="Acme Platform"
|
|
33
|
-
icon={<AppIcon />}
|
|
34
|
-
menu={
|
|
35
|
-
<NavHeadingMenu size="lg">
|
|
36
|
-
<NavHeadingMenuItem label="Dashboard" href="/dashboard" />
|
|
37
|
-
<NavHeadingMenuItem label="Analytics" href="/analytics" />
|
|
38
|
-
<NavHeadingMenuItem label="Settings" href="/settings" />
|
|
39
|
-
</NavHeadingMenu>
|
|
40
|
-
}
|
|
41
|
-
/>
|
|
42
|
-
}>
|
|
43
|
-
{null}
|
|
44
|
-
</SideNav>
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
}
|