@astryxdesign/cli 0.1.4-canary.d209405 → 0.1.4-canary.d324805
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/docs/styling.doc.mjs +53 -0
- package/package.json +9 -9
- package/src/commands/build-theme.color-scheme.test.mjs +153 -0
- package/src/commands/build-theme.mjs +8 -1
- package/src/commands/build-theme.variants.test.mjs +7 -18
- package/src/commands/swizzle.mjs +34 -0
- package/src/commands/swizzle.routing.test.mjs +67 -0
- package/templates/blocks/components/Collapsible/CollapsibleWithoutCard.tsx +25 -23
- package/templates/pages/classic-gallery/page.tsx +1 -1
- package/templates/pages/dashboard/page.tsx +1 -1
- package/templates/pages/documentation/page.tsx +1 -1
- package/templates/pages/incident-console/page.tsx +580 -0
- package/templates/pages/incident-console/template.doc.mjs +12 -0
- package/templates/pages/messaging-shell/page.tsx +676 -0
- package/templates/pages/messaging-shell/template.doc.mjs +12 -0
- package/templates/pages/mixed-gallery/page.tsx +1 -1
- package/templates/pages/payment-form/page.tsx +2 -6
- package/templates/pages/product-detail/page.tsx +3 -11
- package/templates/pages/product-gallery/page.tsx +1 -1
- package/templates/pages/settings/page.tsx +1 -1
- package/templates/pages/side-gallery/page.tsx +1 -1
- package/templates/pages/table-page/page.tsx +1 -1
- package/templates/pages/table-page-chart/page.tsx +1 -1
- package/templates/pages/table-page-heatmap-status/page.tsx +1 -1
- package/templates/pages/table-page-shoe-store-heatmap/page.tsx +1 -1
package/docs/styling.doc.mjs
CHANGED
|
@@ -338,6 +338,59 @@ const styles = stylex.create({
|
|
|
338
338
|
},
|
|
339
339
|
],
|
|
340
340
|
},
|
|
341
|
+
{
|
|
342
|
+
title: 'StyleX Build Setup (required for swizzled components)',
|
|
343
|
+
category: 'guide',
|
|
344
|
+
content: [
|
|
345
|
+
{
|
|
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()`.',
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
type: 'table',
|
|
351
|
+
headers: ['Bundler', 'StyleX plugin'],
|
|
352
|
+
rows: [
|
|
353
|
+
['Webpack', '@stylexjs/webpack-plugin'],
|
|
354
|
+
['Vite / Rollup', '@stylexjs/rollup-plugin (or a community Vite plugin)'],
|
|
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'],
|
|
357
|
+
],
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
type: 'prose',
|
|
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
|
+
},
|
|
363
|
+
{
|
|
364
|
+
type: 'prose',
|
|
365
|
+
text: 'The working path on Next.js is an SWC-based StyleX transform (e.g. the community `@stylexswc/nextjs-plugin`) wired into `next.config`, which keeps SWC and `next/font` intact. See the example app `apps/example-nextjs-stylex` in the repo for a complete, working Next.js + StyleX + SWC configuration.',
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
type: 'code',
|
|
369
|
+
lang: 'js',
|
|
370
|
+
label: 'next.config.mjs: SWC-based StyleX transform (keeps next/font working)',
|
|
371
|
+
code: `import stylexPlugin from '@stylexswc/nextjs-plugin';
|
|
372
|
+
|
|
373
|
+
export default stylexPlugin({
|
|
374
|
+
rsOptions: {
|
|
375
|
+
// Resolve @astryxdesign/core's StyleX so swizzled component source compiles.
|
|
376
|
+
aliases: {'@/*': ['./src/*']},
|
|
377
|
+
unstable_moduleResolution: {type: 'commonJS'},
|
|
378
|
+
},
|
|
379
|
+
})({
|
|
380
|
+
// your existing Next.js config
|
|
381
|
+
});`,
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
type: 'list',
|
|
385
|
+
style: 'unordered',
|
|
386
|
+
items: [
|
|
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.',
|
|
390
|
+
],
|
|
391
|
+
},
|
|
392
|
+
],
|
|
393
|
+
},
|
|
341
394
|
{
|
|
342
395
|
title: 'What NOT to Do',
|
|
343
396
|
category: 'guide',
|
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.d324805",
|
|
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,10 +75,10 @@
|
|
|
75
75
|
"zod": "^4.4.3"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@astryxdesign/charts": "0.1.4-canary.
|
|
79
|
-
"@astryxdesign/core": "0.1.4-canary.
|
|
80
|
-
"@astryxdesign/lab": "0.1.4-canary.
|
|
81
|
-
"@astryxdesign/theme-neutral": "0.1.4-canary.
|
|
78
|
+
"@astryxdesign/charts": "0.1.4-canary.d324805",
|
|
79
|
+
"@astryxdesign/core": "0.1.4-canary.d324805",
|
|
80
|
+
"@astryxdesign/lab": "0.1.4-canary.d324805",
|
|
81
|
+
"@astryxdesign/theme-neutral": "0.1.4-canary.d324805",
|
|
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.
|
|
100
|
-
"@astryxdesign/core": "0.1.4-canary.
|
|
101
|
-
"@astryxdesign/lab": "0.1.4-canary.
|
|
102
|
-
"@astryxdesign/theme-neutral": "0.1.4-canary.
|
|
99
|
+
"@astryxdesign/charts": "0.1.4-canary.d324805",
|
|
100
|
+
"@astryxdesign/core": "0.1.4-canary.d324805",
|
|
101
|
+
"@astryxdesign/lab": "0.1.4-canary.d324805",
|
|
102
|
+
"@astryxdesign/theme-neutral": "0.1.4-canary.d324805",
|
|
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
|
|
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
|
-
|
|
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;
|
package/src/commands/swizzle.mjs
CHANGED
|
@@ -26,6 +26,7 @@ import {jsonOut, humanLog} from '../lib/json.mjs';
|
|
|
26
26
|
import {cliError} from '../lib/cli-error.mjs';
|
|
27
27
|
import {ERROR_CODES} from '../lib/error-codes.mjs';
|
|
28
28
|
import {checkGhCli} from '../utils/github.mjs';
|
|
29
|
+
import {getRunPrefix} from '../utils/package-manager.mjs';
|
|
29
30
|
import {Project} from '../lib/project.mjs';
|
|
30
31
|
import {
|
|
31
32
|
CORE_PACKAGE,
|
|
@@ -339,6 +340,10 @@ export function registerSwizzle(program) {
|
|
|
339
340
|
// Copy all non-test, non-doc, non-README files
|
|
340
341
|
const files = fs.readdirSync(componentDir);
|
|
341
342
|
let copied = 0;
|
|
343
|
+
// Track whether any copied source uses StyleX. Swizzled StyleX source
|
|
344
|
+
// needs a build-time StyleX compiler in the consumer's app or it renders
|
|
345
|
+
// unstyled with no error — so we surface a setup note after copying.
|
|
346
|
+
let usesStyleX = false;
|
|
342
347
|
|
|
343
348
|
for (const file of files) {
|
|
344
349
|
// Skip test files, doc files, and README
|
|
@@ -355,6 +360,13 @@ export function registerSwizzle(program) {
|
|
|
355
360
|
content = rewriteImports(content, owner.ownerPackage);
|
|
356
361
|
}
|
|
357
362
|
|
|
363
|
+
if (
|
|
364
|
+
(file.endsWith('.ts') || file.endsWith('.tsx')) &&
|
|
365
|
+
content.includes('@stylexjs/stylex')
|
|
366
|
+
) {
|
|
367
|
+
usesStyleX = true;
|
|
368
|
+
}
|
|
369
|
+
|
|
358
370
|
fs.writeFileSync(path.join(outputDir, file), content);
|
|
359
371
|
copied++;
|
|
360
372
|
}
|
|
@@ -376,6 +388,7 @@ export function registerSwizzle(program) {
|
|
|
376
388
|
outputDir: relOutput,
|
|
377
389
|
filesCopied: copied,
|
|
378
390
|
files: copiedFiles.map(f => f),
|
|
391
|
+
usesStyleX,
|
|
379
392
|
};
|
|
380
393
|
if (feedback) payload.feedback = feedback;
|
|
381
394
|
return jsonOut('swizzle.copy', payload);
|
|
@@ -387,6 +400,27 @@ export function registerSwizzle(program) {
|
|
|
387
400
|
);
|
|
388
401
|
humanLog('You can now customize the component source freely.\n');
|
|
389
402
|
|
|
403
|
+
// StyleX build requirement. Swizzled components ship raw StyleX source,
|
|
404
|
+
// which needs a build-time StyleX compiler in the consumer's app to
|
|
405
|
+
// produce atomic CSS. Without it the component compiles but renders
|
|
406
|
+
// unstyled, with no error — a confusing silent failure, so call it out.
|
|
407
|
+
if (usesStyleX) {
|
|
408
|
+
humanLog(
|
|
409
|
+
'⚠ These components use StyleX and require a StyleX compiler in your build.',
|
|
410
|
+
);
|
|
411
|
+
humanLog(
|
|
412
|
+
' Without one they render unstyled (no error). See setup per framework:',
|
|
413
|
+
);
|
|
414
|
+
humanLog(` ${getRunPrefix()} astryx docs styling`);
|
|
415
|
+
humanLog(
|
|
416
|
+
' Next.js note: the StyleX Babel plugin disables SWC and breaks next/font —',
|
|
417
|
+
);
|
|
418
|
+
humanLog(
|
|
419
|
+
' use an SWC-based StyleX transform instead (covered in the guide).',
|
|
420
|
+
);
|
|
421
|
+
humanLog('');
|
|
422
|
+
}
|
|
423
|
+
|
|
390
424
|
// Maintainer feedback note. If we couldn't swizzle cleanly, the team
|
|
391
425
|
// wants to know — point users at the issue tracker. Skipped when the
|
|
392
426
|
// owning package ships no issues URL.
|
|
@@ -277,3 +277,70 @@ describe('swizzle — ambiguous ownership', () => {
|
|
|
277
277
|
expect(out).toContain(`from '@astryxdesign/core/theme'`);
|
|
278
278
|
});
|
|
279
279
|
});
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Build a fake @astryxdesign/core with a component that imports StyleX directly
|
|
283
|
+
* (so the swizzle StyleX-build note should fire) and one that doesn't.
|
|
284
|
+
*/
|
|
285
|
+
function buildStyleXCore(project) {
|
|
286
|
+
const core = path.join(project, 'node_modules', '@astryxdesign', 'core');
|
|
287
|
+
// StyleX component.
|
|
288
|
+
const styledDir = path.join(core, 'src', 'Styled');
|
|
289
|
+
fs.mkdirSync(styledDir, {recursive: true});
|
|
290
|
+
fs.writeFileSync(
|
|
291
|
+
path.join(core, 'package.json'),
|
|
292
|
+
'{"name":"@astryxdesign/core","version":"0.0.13"}',
|
|
293
|
+
);
|
|
294
|
+
fs.writeFileSync(
|
|
295
|
+
path.join(styledDir, 'Styled.tsx'),
|
|
296
|
+
[
|
|
297
|
+
`import * as stylex from '@stylexjs/stylex';`,
|
|
298
|
+
`const styles = stylex.create({base: {color: 'red'}});`,
|
|
299
|
+
`export const Styled = () => null;`,
|
|
300
|
+
'',
|
|
301
|
+
].join('\n'),
|
|
302
|
+
);
|
|
303
|
+
// Plain component (no StyleX).
|
|
304
|
+
const plainDir = path.join(core, 'src', 'Plain');
|
|
305
|
+
fs.mkdirSync(plainDir, {recursive: true});
|
|
306
|
+
fs.writeFileSync(
|
|
307
|
+
path.join(plainDir, 'Plain.tsx'),
|
|
308
|
+
`export const Plain = () => null;\n`,
|
|
309
|
+
);
|
|
310
|
+
return core;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
describe('swizzle — StyleX build setup note (#3373)', () => {
|
|
314
|
+
it('reports usesStyleX and prints a setup note for StyleX components', () => {
|
|
315
|
+
buildStyleXCore(project);
|
|
316
|
+
writeProjectPackageJson(project);
|
|
317
|
+
|
|
318
|
+
// JSON payload carries the machine-readable flag.
|
|
319
|
+
const jsonResult = runCli(['--json', 'swizzle', 'Styled', '-f'], project);
|
|
320
|
+
expect(jsonResult.code).toBe(0);
|
|
321
|
+
const env = JSON.parse(jsonResult.stdout);
|
|
322
|
+
expect(env.data.usesStyleX).toBe(true);
|
|
323
|
+
|
|
324
|
+
// Human output surfaces the compiler requirement + Next.js caveat.
|
|
325
|
+
const humanResult = runCli(['swizzle', 'Styled', '-f'], project);
|
|
326
|
+
expect(humanResult.code).toBe(0);
|
|
327
|
+
expect(humanResult.stdout).toMatch(/StyleX compiler/i);
|
|
328
|
+
expect(humanResult.stdout).toMatch(/unstyled/i);
|
|
329
|
+
expect(humanResult.stdout).toMatch(/next\/font/i);
|
|
330
|
+
expect(humanResult.stdout).toMatch(/astryx docs styling/);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it('does not print the StyleX note for components without StyleX', () => {
|
|
334
|
+
buildStyleXCore(project);
|
|
335
|
+
writeProjectPackageJson(project);
|
|
336
|
+
|
|
337
|
+
const jsonResult = runCli(['--json', 'swizzle', 'Plain', '-f'], project);
|
|
338
|
+
expect(jsonResult.code).toBe(0);
|
|
339
|
+
const env = JSON.parse(jsonResult.stdout);
|
|
340
|
+
expect(env.data.usesStyleX).toBe(false);
|
|
341
|
+
|
|
342
|
+
const humanResult = runCli(['swizzle', 'Plain', '-f'], project);
|
|
343
|
+
expect(humanResult.code).toBe(0);
|
|
344
|
+
expect(humanResult.stdout).not.toMatch(/StyleX compiler/i);
|
|
345
|
+
});
|
|
346
|
+
});
|
|
@@ -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
|
-
<
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
}
|