@astryxdesign/cli 0.1.4-canary.3d64ef2 → 0.1.4-canary.4652bff

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.
@@ -344,7 +344,7 @@ const styles = stylex.create({
344
344
  content: [
345
345
  {
346
346
  type: 'prose',
347
- text: 'Astryx components ship pre-compiled, so consuming the published package needs no StyleX setup. But `astryx swizzle <Component>` copies the raw StyleX *source* into your app, and StyleX source requires a build-time StyleX compiler to produce atomic CSS. Without one the component compiles but renders completely unstyled no error, no warning. If a swizzled component looks unstyled, a missing StyleX compiler is almost always why. The same applies if you author your own StyleX with `stylex.create()`.',
347
+ text: 'Astryx components ship pre-compiled, so consuming the published package needs no StyleX setup. But `astryx swizzle <Component>` copies the raw StyleX *source* into your app, and StyleX source requires a build-time StyleX compiler to produce atomic CSS. Without one the component compiles but renders completely unstyled: no error, no warning. If a swizzled component looks unstyled, a missing StyleX compiler is almost always why. The same applies if you author your own StyleX with `stylex.create()`.',
348
348
  },
349
349
  {
350
350
  type: 'table',
@@ -353,12 +353,12 @@ const styles = stylex.create({
353
353
  ['Webpack', '@stylexjs/webpack-plugin'],
354
354
  ['Vite / Rollup', '@stylexjs/rollup-plugin (or a community Vite plugin)'],
355
355
  ['Babel (any bundler)', '@stylexjs/babel-plugin + @stylexjs/postcss-plugin'],
356
- ['Next.js (App Router, SWC)', 'An SWC-based transform see the Next.js note below'],
356
+ ['Next.js (App Router, SWC)', 'An SWC-based transform; see the Next.js note below'],
357
357
  ],
358
358
  },
359
359
  {
360
360
  type: 'prose',
361
- text: 'Next.js (App Router) is the sharp edge. StyleX\u2019s canonical compiler is a Babel plugin, but introducing a Babel config in Next.js disables the SWC compiler, which in turn breaks SWC-dependent features like `next/font`. So the "obvious" Babel setup is actively incompatible with a standard Next 15 App Router app.',
361
+ text: 'Next.js (App Router) is the sharp edge. StyleX\'s canonical compiler is a Babel plugin, but introducing a Babel config in Next.js disables the SWC compiler, which in turn breaks SWC-dependent features like `next/font`. So the "obvious" Babel setup is actively incompatible with a standard Next 15 App Router app.',
362
362
  },
363
363
  {
364
364
  type: 'prose',
@@ -367,7 +367,7 @@ const styles = stylex.create({
367
367
  {
368
368
  type: 'code',
369
369
  lang: 'js',
370
- label: 'next.config.mjs SWC-based StyleX transform (keeps next/font working)',
370
+ label: 'next.config.mjs: SWC-based StyleX transform (keeps next/font working)',
371
371
  code: `import stylexPlugin from '@stylexswc/nextjs-plugin';
372
372
 
373
373
  export default stylexPlugin({
@@ -385,8 +385,8 @@ export default stylexPlugin({
385
385
  style: 'unordered',
386
386
  items: [
387
387
  'Symptom of a missing compiler: swizzled component renders with no styles, but no build or runtime error.',
388
- 'Do NOT add @stylexjs/babel-plugin to a Next.js App Router app it disables SWC and breaks next/font.',
389
- 'Pure theming (defineTheme + astryx theme build) needs NO StyleX compiler only swizzled/authored StyleX source does.',
388
+ 'Do NOT add @stylexjs/babel-plugin to a Next.js App Router app; it disables SWC and breaks next/font.',
389
+ 'Pure theming (defineTheme + astryx theme build) needs NO StyleX compiler; only swizzled/authored StyleX source does.',
390
390
  ],
391
391
  },
392
392
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/cli",
3
- "version": "0.1.4-canary.3d64ef2",
3
+ "version": "0.1.4-canary.4652bff",
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",
@@ -68,17 +68,17 @@
68
68
  "CHANGELOG.md"
69
69
  ],
70
70
  "dependencies": {
71
- "@clack/prompts": "^1.5.1",
71
+ "@clack/prompts": "^1.7.0",
72
72
  "commander": "^12.1.0",
73
73
  "jiti": "^2.7.0",
74
74
  "jscodeshift": "^17.3.0",
75
75
  "zod": "^4.4.3"
76
76
  },
77
77
  "peerDependencies": {
78
- "@astryxdesign/charts": "0.1.4-canary.3d64ef2",
79
- "@astryxdesign/core": "0.1.4-canary.3d64ef2",
80
- "@astryxdesign/lab": "0.1.4-canary.3d64ef2",
81
- "@astryxdesign/theme-neutral": "0.1.4-canary.3d64ef2",
78
+ "@astryxdesign/charts": "0.1.4-canary.4652bff",
79
+ "@astryxdesign/core": "0.1.4-canary.4652bff",
80
+ "@astryxdesign/lab": "0.1.4-canary.4652bff",
81
+ "@astryxdesign/theme-neutral": "0.1.4-canary.4652bff",
82
82
  "gpt-tokenizer": "^3.4.0"
83
83
  },
84
84
  "peerDependenciesMeta": {
@@ -96,10 +96,10 @@
96
96
  }
97
97
  },
98
98
  "devDependencies": {
99
- "@astryxdesign/charts": "0.1.4-canary.3d64ef2",
100
- "@astryxdesign/core": "0.1.4-canary.3d64ef2",
101
- "@astryxdesign/lab": "0.1.4-canary.3d64ef2",
102
- "@astryxdesign/theme-neutral": "0.1.4-canary.3d64ef2",
99
+ "@astryxdesign/charts": "0.1.4-canary.4652bff",
100
+ "@astryxdesign/core": "0.1.4-canary.4652bff",
101
+ "@astryxdesign/lab": "0.1.4-canary.4652bff",
102
+ "@astryxdesign/theme-neutral": "0.1.4-canary.4652bff",
103
103
  "gpt-tokenizer": "^3.4.0"
104
104
  },
105
105
  "scripts": {
@@ -0,0 +1,153 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file Regression test for the `color-scheme` declaration `astryx theme build`
5
+ * emits alongside `light-dark()` token output (see #3658).
6
+ *
7
+ * `astryx theme build` injects a `color-scheme` declaration into
8
+ * `@layer astryx-theme` whenever the generated CSS contains `light-dark()`,
9
+ * so LightningCSS/browsers can resolve it. That declaration must mirror
10
+ * reset.css's own `html[data-theme]` -> `color-scheme` mapping (a bare
11
+ * `:root { color-scheme: light dark; }` alone permanently pins the page to
12
+ * "light dark", defeating `<Theme mode="light|dark">` forcing regardless of
13
+ * `@layer astryx-theme` being declared after `@layer reset` in layer order):
14
+ *
15
+ * :root { color-scheme: light dark; }
16
+ * html[data-theme="light"] { color-scheme: light; }
17
+ * html[data-theme="dark"] { color-scheme: dark; }
18
+ *
19
+ * Themes that never use `light-dark()` have no `color-scheme` ambiguity to
20
+ * resolve, so none of the three rules should be emitted for them.
21
+ *
22
+ * Building `astryx theme build` requires a compiled @astryxdesign/core (there is no in-CLI
23
+ * fallback generator), so this suite builds core once in beforeAll via the
24
+ * shared ensureCoreBuilt() helper — which serializes concurrent Vitest workers
25
+ * behind a lock — to stay self-sufficient regardless of CI job ordering.
26
+ */
27
+
28
+ import {describe, it, expect, beforeAll, beforeEach, afterEach} from 'vitest';
29
+ import {execFileSync} from 'node:child_process';
30
+ import * as fs from 'node:fs';
31
+ import * as path from 'node:path';
32
+ import * as os from 'node:os';
33
+ import {fileURLToPath} from 'node:url';
34
+ import {ensureCoreBuilt} from './ensure-core-built.mjs';
35
+
36
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
37
+ const CLI_BIN = path.resolve(__dirname, '../../bin/astryx.mjs');
38
+
39
+ const COLOR_SCHEME_ROOT_DECL = ':root { color-scheme: light dark; }';
40
+ const COLOR_SCHEME_LIGHT_DECL = 'html[data-theme="light"] { color-scheme: light; }';
41
+ const COLOR_SCHEME_DARK_DECL = 'html[data-theme="dark"] { color-scheme: dark; }';
42
+
43
+ function runCli(args, cwd) {
44
+ try {
45
+ const out = execFileSync('node', [CLI_BIN, ...args], {
46
+ cwd,
47
+ encoding: 'utf-8',
48
+ stdio: ['ignore', 'pipe', 'pipe'],
49
+ env: {...process.env, FORCE_COLOR: '0'},
50
+ });
51
+ return {code: 0, stdout: out, stderr: ''};
52
+ } catch (e) {
53
+ return {
54
+ code: e.status ?? 1,
55
+ stdout: e.stdout?.toString() ?? '',
56
+ stderr: e.stderr?.toString() ?? '',
57
+ };
58
+ }
59
+ }
60
+
61
+ function writeTheme(dir, name, tokens) {
62
+ fs.mkdirSync(dir, {recursive: true});
63
+ // The CLI writes <basename>.css next to the source file, so use the
64
+ // theme name as the filename for unambiguous fixtures.
65
+ const file = path.join(dir, `${name}.mjs`);
66
+ fs.writeFileSync(
67
+ file,
68
+ `export default { name: ${JSON.stringify(name)}, tokens: ${JSON.stringify(tokens)} };\n`,
69
+ );
70
+ return file;
71
+ }
72
+
73
+ // `astryx theme build` imports the compiled @astryxdesign/core/theme entry. Build core
74
+ // once if it isn't already present so the suite works in any CI job.
75
+ beforeAll(() => {
76
+ ensureCoreBuilt();
77
+ }, 200_000);
78
+
79
+ let tmpDir;
80
+ beforeEach(() => {
81
+ tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-build-theme-color-scheme-'));
82
+ });
83
+ afterEach(() => {
84
+ fs.rmSync(tmpDir, {recursive: true, force: true});
85
+ });
86
+
87
+ describe('theme build color-scheme output', () => {
88
+ it('emits the mode-aware color-scheme rules in @layer astryx-theme for a light-dark() theme', () => {
89
+ const project = path.join(tmpDir, 'project');
90
+ const themesDir = path.join(project, 'themes');
91
+ // A raw light-dark() token value is what triggers the color-scheme
92
+ // injection in build-theme.mjs (it checks the generated CSS for the
93
+ // literal substring). `defineTheme.test.ts` already covers the separate
94
+ // [light, dark] tuple -> light-dark() conversion; this fixture writes
95
+ // the string directly so this test stays focused on the CLI's own
96
+ // color-scheme decision, not on that conversion.
97
+ const themeFile = writeTheme(themesDir, 'with-light-dark', {
98
+ '--color-accent': 'light-dark(#0077B6, #48CAE4)',
99
+ });
100
+
101
+ const result = runCli(
102
+ ['theme', 'build', path.relative(project, themeFile)],
103
+ project,
104
+ );
105
+
106
+ expect(result.code).toBe(0);
107
+
108
+ const cssPath = path.join(themesDir, 'with-light-dark.css');
109
+ expect(fs.existsSync(cssPath)).toBe(true);
110
+ const css = fs.readFileSync(cssPath, 'utf-8');
111
+
112
+ expect(css).toContain('light-dark(#0077B6, #48CAE4)');
113
+
114
+ // All 3 rules must be present...
115
+ expect(css).toContain(COLOR_SCHEME_ROOT_DECL);
116
+ expect(css).toContain(COLOR_SCHEME_LIGHT_DECL);
117
+ expect(css).toContain(COLOR_SCHEME_DARK_DECL);
118
+
119
+ // ...and specifically inside @layer astryx-theme, not @layer reset (the
120
+ // declaration must sit alongside the light-dark() token/component output
121
+ // it resolves, not the zero-specificity prose defaults).
122
+ const themeLayerStart = css.indexOf('@layer astryx-theme');
123
+ expect(themeLayerStart).toBeGreaterThanOrEqual(0);
124
+ const themeLayerBody = css.slice(themeLayerStart);
125
+ expect(themeLayerBody).toContain(COLOR_SCHEME_ROOT_DECL);
126
+ expect(themeLayerBody).toContain(COLOR_SCHEME_LIGHT_DECL);
127
+ expect(themeLayerBody).toContain(COLOR_SCHEME_DARK_DECL);
128
+ });
129
+
130
+ it('omits all color-scheme rules for a theme with no light-dark() tokens', () => {
131
+ const project = path.join(tmpDir, 'project');
132
+ const themesDir = path.join(project, 'themes');
133
+ const themeFile = writeTheme(themesDir, 'no-light-dark', {
134
+ '--color-accent': '#0077B6',
135
+ });
136
+
137
+ const result = runCli(
138
+ ['theme', 'build', path.relative(project, themeFile)],
139
+ project,
140
+ );
141
+
142
+ expect(result.code).toBe(0);
143
+
144
+ const cssPath = path.join(themesDir, 'no-light-dark.css');
145
+ expect(fs.existsSync(cssPath)).toBe(true);
146
+ const css = fs.readFileSync(cssPath, 'utf-8');
147
+
148
+ expect(css).not.toContain('light-dark(');
149
+ expect(css).not.toContain(COLOR_SCHEME_ROOT_DECL);
150
+ expect(css).not.toContain(COLOR_SCHEME_LIGHT_DECL);
151
+ expect(css).not.toContain(COLOR_SCHEME_DARK_DECL);
152
+ });
153
+ });
@@ -939,8 +939,15 @@ export function registerTheme(program) {
939
939
  if (component.length > 0) {
940
940
  const componentInner = component.join('\n\n');
941
941
  const componentScope = `@scope (${scopeSelector}) to (${scopeTo}) {\n${componentInner}\n}`;
942
+ // light-dark() needs a color-scheme declaration in this bundle, but a
943
+ // bare `:root { color-scheme: light dark }` outranks reset.css's
944
+ // `html[data-theme]` mapping (astryx-theme layer comes after reset),
945
+ // silently defeating `<Theme mode>` forcing on <html>. Mirror the
946
+ // attribute-keyed mapping so the declaration follows the active mode.
942
947
  const colorSchemeDecl = componentScope.includes('light-dark(')
943
- ? ' :root { color-scheme: light dark; }\n\n'
948
+ ? ' :root { color-scheme: light dark; }\n' +
949
+ ' html[data-theme="light"] { color-scheme: light; }\n' +
950
+ ' html[data-theme="dark"] { color-scheme: dark; }\n\n'
944
951
  : '';
945
952
  cssParts.push(
946
953
  `@layer astryx-theme {\n${colorSchemeDecl}${componentScope}\n}`,
@@ -28,20 +28,10 @@ import * as fs from 'node:fs';
28
28
  import * as path from 'node:path';
29
29
  import * as os from 'node:os';
30
30
  import {fileURLToPath} from 'node:url';
31
+ import {ensureCoreBuilt} from './ensure-core-built.mjs';
31
32
 
32
33
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
33
34
  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
35
 
46
36
  function runCli(args, cwd) {
47
37
  try {
@@ -68,14 +58,13 @@ function writeTheme(dir, contents) {
68
58
  return file;
69
59
  }
70
60
 
61
+ // Build core through the shared lock helper — this suite previously ran its
62
+ // own unguarded `if (!exists) pnpm -F core build`, and when Vitest scheduled
63
+ // it alongside the other build-theme suites on a fresh checkout, the
64
+ // concurrent builds collided on packages/core/dist (core's build starts by
65
+ // wiping dist), nondeterministically breaking whichever suite was mid-read.
71
66
  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
- }
67
+ ensureCoreBuilt();
79
68
  }, 200_000);
80
69
 
81
70
  let tmpDir;
@@ -2,34 +2,36 @@
2
2
 
3
3
  'use client';
4
4
 
5
- import {Collapsible} from '@astryxdesign/core/Collapsible';
5
+ import {Collapsible, CollapsibleGroup} from '@astryxdesign/core/Collapsible';
6
6
  import {Divider} from '@astryxdesign/core/Divider';
7
7
  import {Text} from '@astryxdesign/core/Text';
8
8
  import {VStack} from '@astryxdesign/core/Layout';
9
9
 
10
10
  export default function CollapsibleWithoutCard() {
11
11
  return (
12
- <VStack gap={3} style={{width: '100%', maxWidth: 400}}>
13
- <Collapsible trigger="Deployment Details">
14
- <Text type="body">
15
- Last deployed on April 18, 2026 at 3:42 PM by Sarah Chen. Build
16
- duration was 2m 14s with zero warnings.
17
- </Text>
18
- </Collapsible>
19
- <Divider />
20
- <Collapsible trigger="Environment Variables" defaultIsOpen={false}>
21
- <Text type="body">
22
- 12 variables configured. Last updated March 30, 2026. All secrets are
23
- encrypted at rest with AES-256.
24
- </Text>
25
- </Collapsible>
26
- <Divider />
27
- <Collapsible trigger="Build Logs" defaultIsOpen={false}>
28
- <Text type="body">
29
- Build completed successfully. 847 modules compiled, 0 errors, 0
30
- warnings. Bundle size: 142 KB gzipped.
31
- </Text>
32
- </Collapsible>
33
- </VStack>
12
+ <CollapsibleGroup type="single" defaultValue="deployment">
13
+ <VStack gap={3} style={{width: '100%', maxWidth: 400}}>
14
+ <Collapsible trigger="Deployment Details" value="deployment">
15
+ <Text type="body">
16
+ Last deployed on April 18, 2026 at 3:42 PM by Sarah Chen. Build
17
+ duration was 2m 14s with zero warnings.
18
+ </Text>
19
+ </Collapsible>
20
+ <Divider />
21
+ <Collapsible trigger="Environment Variables" value="environment">
22
+ <Text type="body">
23
+ 12 variables configured. Last updated March 30, 2026. All secrets
24
+ are encrypted at rest with AES-256.
25
+ </Text>
26
+ </Collapsible>
27
+ <Divider />
28
+ <Collapsible trigger="Build Logs" value="logs">
29
+ <Text type="body">
30
+ Build completed successfully. 847 modules compiled, 0 errors, 0
31
+ warnings. Bundle size: 142 KB gzipped.
32
+ </Text>
33
+ </Collapsible>
34
+ </VStack>
35
+ </CollapsibleGroup>
34
36
  );
35
37
  }
@@ -110,7 +110,7 @@ export default function ClassicGalleryTemplate() {
110
110
 
111
111
  return (
112
112
  <Layout
113
- height="auto"
113
+ height="fill"
114
114
  content={
115
115
  <LayoutContent padding={0}>
116
116
  <Center axis="horizontal">
@@ -729,7 +729,7 @@ function TableCard<T extends {id: string}>({
729
729
  export default function DashboardTemplate() {
730
730
  return (
731
731
  <Layout
732
- height="auto"
732
+ height="fill"
733
733
  content={
734
734
  <LayoutContent padding={6}>
735
735
  <VStack gap={6}>
@@ -209,7 +209,7 @@ const COMPONENT_CATEGORIES = [
209
209
  export default function DocumentationOverviewPage() {
210
210
  return (
211
211
  <Layout
212
- height="auto"
212
+ height="fill"
213
213
  contentWidth={1200}
214
214
  content={
215
215
  <LayoutContent padding={8}>