@astryxdesign/cli 0.1.4-canary.ff77e1c → 0.1.4
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/CHANGELOG.md +1 -2
- package/docs/getting-started.doc.mjs +0 -4
- package/docs/migration.doc.mjs +0 -134
- package/docs/styling.doc.mjs +0 -53
- package/docs/working-with-ai.doc.mjs +1 -1
- package/package.json +10 -15
- package/src/api/component.mjs +1 -2
- package/src/api/doctor.mjs +2 -13
- package/src/api/template.mjs +3 -14
- package/src/codemods/__tests__/registry.test.mjs +0 -1
- package/src/codemods/__tests__/runner.test.mjs +0 -38
- package/src/codemods/registry.mjs +0 -1
- package/src/codemods/runner.mjs +0 -2
- package/src/commands/agent-docs.mjs +6 -9
- package/src/commands/agent-docs.test.mjs +0 -33
- package/src/commands/build-theme.mjs +14 -112
- package/src/commands/component-resolution.test.mjs +4 -4
- package/src/commands/doctor.test.mjs +0 -34
- package/src/commands/init.mjs +1 -1
- package/src/commands/swizzle.mjs +0 -34
- package/src/commands/swizzle.routing.test.mjs +0 -67
- package/src/lib/component-discovery.mjs +4 -8
- package/templates/blocks/components/AspectRatio/AspectRatioCircleImage.tsx +6 -1
- package/templates/blocks/components/AspectRatio/AspectRatioImageGallery.tsx +7 -2
- package/templates/blocks/components/AspectRatio/AspectRatioShowcase.tsx +5 -2
- package/templates/blocks/components/AspectRatio/AspectRatioSquareImage.tsx +6 -1
- package/templates/blocks/components/AspectRatio/AspectRatioWidescreen.tsx +6 -1
- package/templates/blocks/components/Collapsible/CollapsibleWithoutCard.tsx +23 -25
- package/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupShowcase.tsx +48 -27
- package/templates/blocks/components/CommandPaletteItem/CommandPaletteItemShowcase.tsx +54 -31
- 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/kanban-board/page.tsx +13 -37
- package/templates/pages/mixed-gallery/page.tsx +1 -1
- package/templates/pages/payment-form/page.tsx +6 -2
- package/templates/pages/product-detail/page.tsx +11 -3
- 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 +14 -4
- package/templates/pages/table-page-heatmap-status/page.tsx +1 -1
- package/templates/pages/table-page-shoe-store-heatmap/page.tsx +19 -5
- package/src/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +0 -93
- package/src/codemods/transforms/v0.1.5/index.mjs +0 -19
- package/src/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +0 -140
- package/src/commands/build-theme.color-scheme.test.mjs +0 -153
- package/src/commands/build-theme.variants.test.mjs +0 -193
- package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.doc.mjs +0 -14
- package/templates/blocks/components/BaseTypeahead/BaseTypeaheadCustomSearch.tsx +0 -58
- 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/CommandPaletteInput/CommandPaletteInputBasic.doc.mjs +0 -15
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.tsx +0 -39
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.doc.mjs +0 -15
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.tsx +0 -39
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.doc.mjs +0 -15
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +0 -27
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.doc.mjs +0 -15
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +0 -38
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.doc.mjs +0 -14
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.tsx +0 -44
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.doc.mjs +0 -15
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.tsx +0 -107
- package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.doc.mjs +0 -15
- package/templates/blocks/components/NavHeadingMenu/NavHeadingMenuShowcase.tsx +0 -47
- package/templates/pages/incident-console/page.tsx +0 -580
- package/templates/pages/incident-console/template.doc.mjs +0 -12
- package/templates/pages/messaging-shell/page.tsx +0 -676
- package/templates/pages/messaging-shell/template.doc.mjs +0 -12
|
@@ -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
|
}
|
|
@@ -939,9 +846,8 @@ export function registerTheme(program) {
|
|
|
939
846
|
if (component.length > 0) {
|
|
940
847
|
const componentInner = component.join('\n\n');
|
|
941
848
|
const componentScope = `@scope (${scopeSelector}) to (${scopeTo}) {\n${componentInner}\n}`;
|
|
942
|
-
// #3658: also emit attribute-specific rules so <Theme mode> can override color-scheme
|
|
943
849
|
const colorSchemeDecl = componentScope.includes('light-dark(')
|
|
944
|
-
? ' :root { color-scheme: light dark; }\n
|
|
850
|
+
? ' :root { color-scheme: light dark; }\n\n'
|
|
945
851
|
: '';
|
|
946
852
|
cssParts.push(
|
|
947
853
|
`@layer astryx-theme {\n${colorSchemeDecl}${componentScope}\n}`,
|
|
@@ -988,23 +894,19 @@ export function registerTheme(program) {
|
|
|
988
894
|
|
|
989
895
|
const iconInfo = extractIconInfo(filePath);
|
|
990
896
|
|
|
991
|
-
//
|
|
992
|
-
|
|
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
|
|
993
903
|
const augmentationSource = resolvedTheme || themeDef;
|
|
994
904
|
const variantDecl = await generateVariantDeclarationsAsync(augmentationSource);
|
|
995
|
-
const
|
|
996
|
-
const variantDtsPath = variantDecl ? path.join(outDir, variantsFileName) : null;
|
|
905
|
+
const variantDtsPath = variantDecl ? path.join(outDir, `${baseName}.variants.d.ts`) : null;
|
|
997
906
|
const variantContent = variantDecl
|
|
998
907
|
? generatedHeader(sourceRelative, 'ts', buildCommand) + variantDecl
|
|
999
908
|
: null;
|
|
1000
909
|
|
|
1001
|
-
// Generate all file contents in memory first. The main .d.ts references
|
|
1002
|
-
// the variants file (when present) via a triple-slash directive so
|
|
1003
|
-
// importing the theme also loads the custom-variant augmentations.
|
|
1004
|
-
const cssContent = generatedHeader(sourceRelative, 'css', buildCommand) + css;
|
|
1005
|
-
const jsContent = generatedHeader(sourceRelative, 'js', buildCommand) + generateBuiltModule(resolvedTheme || themeDef, iconInfo);
|
|
1006
|
-
const dtsContent = generatedHeader(sourceRelative, 'ts', buildCommand) + generateBuiltTypes(themeDef, iconInfo, variantsFileName);
|
|
1007
|
-
|
|
1008
910
|
// Atomic-ish write: stage every file as `<dest>.tmp`, then rename
|
|
1009
911
|
// each into place. If any stage step fails we clean up partials and
|
|
1010
912
|
// exit; if a rename fails mid-way we still have the originals (or
|
|
@@ -78,13 +78,13 @@ describe('findShowcase() priority', () => {
|
|
|
78
78
|
it('Badge resolves to Badge dir, not a sibling that uses Badge', async () => {
|
|
79
79
|
const result = await findShowcase('Badge');
|
|
80
80
|
expect(result).not.toBeNull();
|
|
81
|
-
expect(result.filePath).toMatch(
|
|
81
|
+
expect(result.filePath).toMatch(/\/Badge\//);
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
it('Avatar resolves to Avatar dir, not AvatarStatusDot', async () => {
|
|
85
85
|
const result = await findShowcase('Avatar');
|
|
86
86
|
expect(result).not.toBeNull();
|
|
87
|
-
expect(result.filePath).toMatch(
|
|
87
|
+
expect(result.filePath).toMatch(/\/Avatar\//);
|
|
88
88
|
expect(result.filePath).not.toMatch(/AvatarStatusDot/);
|
|
89
89
|
});
|
|
90
90
|
|
|
@@ -92,7 +92,7 @@ describe('findShowcase() priority', () => {
|
|
|
92
92
|
const result = await findShowcase('ClickableCard');
|
|
93
93
|
expect(result).not.toBeNull();
|
|
94
94
|
expect(result.name).toBe('ClickableCard');
|
|
95
|
-
expect(result.filePath).toMatch(
|
|
95
|
+
expect(result.filePath).toMatch(/\/Card\//);
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
it('SelectableCard resolves via componentsUsed in Card/', async () => {
|
|
@@ -104,7 +104,7 @@ describe('findShowcase() priority', () => {
|
|
|
104
104
|
it('Stack resolves to Stack dir despite componentsUsed elsewhere', async () => {
|
|
105
105
|
const result = await findShowcase('Stack');
|
|
106
106
|
expect(result).not.toBeNull();
|
|
107
|
-
expect(result.filePath).toMatch(
|
|
107
|
+
expect(result.filePath).toMatch(/\/Stack\//);
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
it('returns null for nonexistent component', async () => {
|
|
@@ -63,33 +63,6 @@ function installPkg(name, version = '1.0.0') {
|
|
|
63
63
|
return dir;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
* Mirror pnpm's layout: the real package lives under node_modules/.pnpm and
|
|
68
|
-
* the entry in the scope directory is a symlink to it.
|
|
69
|
-
*/
|
|
70
|
-
function installPkgPnpmStyle(name, version = '1.0.0') {
|
|
71
|
-
const realDir = path.join(
|
|
72
|
-
tmpDir,
|
|
73
|
-
'node_modules',
|
|
74
|
-
'.pnpm',
|
|
75
|
-
`${name.replace('/', '+')}@${version}`,
|
|
76
|
-
'node_modules',
|
|
77
|
-
...name.split('/'),
|
|
78
|
-
);
|
|
79
|
-
fs.mkdirSync(realDir, {recursive: true});
|
|
80
|
-
fs.writeFileSync(
|
|
81
|
-
path.join(realDir, 'package.json'),
|
|
82
|
-
JSON.stringify({name, version, main: 'index.js'}),
|
|
83
|
-
);
|
|
84
|
-
fs.writeFileSync(path.join(realDir, 'index.js'), 'module.exports = {};');
|
|
85
|
-
const linkPath = path.join(tmpDir, 'node_modules', ...name.split('/'));
|
|
86
|
-
fs.mkdirSync(path.dirname(linkPath), {recursive: true});
|
|
87
|
-
// 'junction' keeps this working on Windows without elevated permissions;
|
|
88
|
-
// it is ignored on posix.
|
|
89
|
-
fs.symlinkSync(realDir, linkPath, 'junction');
|
|
90
|
-
return linkPath;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
66
|
function find(checks, id) {
|
|
94
67
|
return checks.find(c => c.id === id);
|
|
95
68
|
}
|
|
@@ -146,13 +119,6 @@ describe('doctor — individual checks', () => {
|
|
|
146
119
|
expect(res.status).toBe('pass');
|
|
147
120
|
});
|
|
148
121
|
|
|
149
|
-
it('themes: detects pnpm-style symlinked theme packages (#3530)', () => {
|
|
150
|
-
installPkgPnpmStyle('@astryxdesign/theme-neutral', '0.1.2');
|
|
151
|
-
const res = checkThemes({cwd: tmpDir, configTheme: 'default'});
|
|
152
|
-
expect(res.status).toBe('pass');
|
|
153
|
-
expect(res.message).toContain('@astryxdesign/theme-neutral');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
122
|
it('config: INFO when no astryx.config.mjs', async () => {
|
|
157
123
|
const res = await checkConfig({cwd: tmpDir, configPath: null});
|
|
158
124
|
expect(res.status).toBe('info');
|
package/src/commands/init.mjs
CHANGED
|
@@ -198,7 +198,7 @@ export function registerInit(program) {
|
|
|
198
198
|
.option('--features <list>', 'Comma-separated features to install (agents, theme, template)')
|
|
199
199
|
.option('--all', 'Install all features, no prompts')
|
|
200
200
|
.option('--remove-agents', 'Remove AI agent docs from all agent doc files')
|
|
201
|
-
.option('--agent <tool>', 'Target AI tool for agent docs: claude, cursor, codex,
|
|
201
|
+
.option('--agent <tool>', 'Target AI tool for agent docs: claude, cursor, codex, all')
|
|
202
202
|
.option('--agent-docs-path <path...>', 'Explicit file path(s) for agent docs')
|
|
203
203
|
.action(async (options) => {
|
|
204
204
|
const targetDir = process.cwd();
|
package/src/commands/swizzle.mjs
CHANGED
|
@@ -26,7 +26,6 @@ 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';
|
|
30
29
|
import {Project} from '../lib/project.mjs';
|
|
31
30
|
import {
|
|
32
31
|
CORE_PACKAGE,
|
|
@@ -340,10 +339,6 @@ export function registerSwizzle(program) {
|
|
|
340
339
|
// Copy all non-test, non-doc, non-README files
|
|
341
340
|
const files = fs.readdirSync(componentDir);
|
|
342
341
|
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;
|
|
347
342
|
|
|
348
343
|
for (const file of files) {
|
|
349
344
|
// Skip test files, doc files, and README
|
|
@@ -360,13 +355,6 @@ export function registerSwizzle(program) {
|
|
|
360
355
|
content = rewriteImports(content, owner.ownerPackage);
|
|
361
356
|
}
|
|
362
357
|
|
|
363
|
-
if (
|
|
364
|
-
(file.endsWith('.ts') || file.endsWith('.tsx')) &&
|
|
365
|
-
content.includes('@stylexjs/stylex')
|
|
366
|
-
) {
|
|
367
|
-
usesStyleX = true;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
358
|
fs.writeFileSync(path.join(outputDir, file), content);
|
|
371
359
|
copied++;
|
|
372
360
|
}
|
|
@@ -388,7 +376,6 @@ export function registerSwizzle(program) {
|
|
|
388
376
|
outputDir: relOutput,
|
|
389
377
|
filesCopied: copied,
|
|
390
378
|
files: copiedFiles.map(f => f),
|
|
391
|
-
usesStyleX,
|
|
392
379
|
};
|
|
393
380
|
if (feedback) payload.feedback = feedback;
|
|
394
381
|
return jsonOut('swizzle.copy', payload);
|
|
@@ -400,27 +387,6 @@ export function registerSwizzle(program) {
|
|
|
400
387
|
);
|
|
401
388
|
humanLog('You can now customize the component source freely.\n');
|
|
402
389
|
|
|
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
|
-
|
|
424
390
|
// Maintainer feedback note. If we couldn't swizzle cleanly, the team
|
|
425
391
|
// wants to know — point users at the issue tracker. Skipped when the
|
|
426
392
|
// owning package ships no issues URL.
|
|
@@ -277,70 +277,3 @@ 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
|
-
});
|
|
@@ -335,13 +335,10 @@ export function resolveImportPath(coreDir, componentName) {
|
|
|
335
335
|
? JSON.parse(fs.readFileSync(pkgPath, 'utf-8'))
|
|
336
336
|
: null;
|
|
337
337
|
|
|
338
|
-
const exportKeys = Object.keys(pkg?.exports || {});
|
|
339
|
-
|
|
340
338
|
// Priority 1: exact subpath export matching the component name (e.g. ./Heading)
|
|
341
339
|
// This allows convenience re-export directories to win over the source directory.
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
return `@astryxdesign/core/${exactMatch.slice(2)}`;
|
|
340
|
+
if (pkg?.exports?.[`./${componentName}`]) {
|
|
341
|
+
return `@astryxdesign/core/${componentName}`;
|
|
345
342
|
}
|
|
346
343
|
|
|
347
344
|
const sourcePath = findComponentSource(coreDir, componentName);
|
|
@@ -351,9 +348,8 @@ export function resolveImportPath(coreDir, componentName) {
|
|
|
351
348
|
const relToSrc = path.relative(srcDir, sourcePath);
|
|
352
349
|
const topDir = relToSrc.split(path.sep)[0];
|
|
353
350
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
return `@astryxdesign/core/${topMatch.slice(2)}`;
|
|
351
|
+
if (pkg?.exports?.[`./${topDir}`]) {
|
|
352
|
+
return `@astryxdesign/core/${topDir}`;
|
|
357
353
|
}
|
|
358
354
|
|
|
359
355
|
return '@astryxdesign/core';
|
|
@@ -8,10 +8,15 @@ import {Center} from '@astryxdesign/core/Center';
|
|
|
8
8
|
export default function AspectRatioCircleImage() {
|
|
9
9
|
return (
|
|
10
10
|
<Center width={300}>
|
|
11
|
-
<AspectRatio ratio={1} shape="ellipse"
|
|
11
|
+
<AspectRatio ratio={1} shape="ellipse">
|
|
12
12
|
<img
|
|
13
13
|
src="https://lookaside.facebook.com/assets/astryx/light-home-square-1.png"
|
|
14
14
|
alt="Circular image"
|
|
15
|
+
style={{
|
|
16
|
+
width: '100%',
|
|
17
|
+
height: '100%',
|
|
18
|
+
objectFit: 'cover',
|
|
19
|
+
}}
|
|
15
20
|
/>
|
|
16
21
|
</AspectRatio>
|
|
17
22
|
</Center>
|
|
@@ -25,11 +25,16 @@ export default function AspectRatioImageGallery() {
|
|
|
25
25
|
<Center width={600}>
|
|
26
26
|
<Grid columns={3} gap={4} width="100%">
|
|
27
27
|
{images.map(({id, alt}) => (
|
|
28
|
-
<AspectRatio key={id} ratio={4 / 3}
|
|
28
|
+
<AspectRatio key={id} ratio={4 / 3}>
|
|
29
29
|
<img
|
|
30
30
|
src="https://lookaside.facebook.com/assets/astryx/illustrative-horizontal-1.png"
|
|
31
31
|
alt={alt}
|
|
32
|
-
style={{
|
|
32
|
+
style={{
|
|
33
|
+
width: '100%',
|
|
34
|
+
height: '100%',
|
|
35
|
+
objectFit: 'cover',
|
|
36
|
+
borderRadius: 8,
|
|
37
|
+
}}
|
|
33
38
|
/>
|
|
34
39
|
</AspectRatio>
|
|
35
40
|
))}
|
|
@@ -34,13 +34,16 @@ export default function AspectRatioShowcase() {
|
|
|
34
34
|
<VStack key={label} gap={2} hAlign="center">
|
|
35
35
|
<AspectRatio
|
|
36
36
|
ratio={ratio}
|
|
37
|
-
fit="cover"
|
|
38
37
|
style={{
|
|
39
38
|
height: 120,
|
|
40
39
|
width: 'auto',
|
|
41
40
|
borderRadius: 'var(--radius-container)',
|
|
42
41
|
}}>
|
|
43
|
-
<img
|
|
42
|
+
<img
|
|
43
|
+
src={src}
|
|
44
|
+
alt={alt}
|
|
45
|
+
style={{width: '100%', height: '100%', objectFit: 'cover'}}
|
|
46
|
+
/>
|
|
44
47
|
</AspectRatio>
|
|
45
48
|
<Text type="supporting" color="secondary">
|
|
46
49
|
{label}
|
|
@@ -8,10 +8,15 @@ import {Center} from '@astryxdesign/core/Center';
|
|
|
8
8
|
export default function AspectRatioSquareImage() {
|
|
9
9
|
return (
|
|
10
10
|
<Center width={300}>
|
|
11
|
-
<AspectRatio ratio={1}
|
|
11
|
+
<AspectRatio ratio={1}>
|
|
12
12
|
<img
|
|
13
13
|
src="https://lookaside.facebook.com/assets/astryx/light-home-square-1.png"
|
|
14
14
|
alt="1:1 square"
|
|
15
|
+
style={{
|
|
16
|
+
width: '100%',
|
|
17
|
+
height: '100%',
|
|
18
|
+
objectFit: 'cover',
|
|
19
|
+
}}
|
|
15
20
|
/>
|
|
16
21
|
</AspectRatio>
|
|
17
22
|
</Center>
|
|
@@ -8,10 +8,15 @@ import {Center} from '@astryxdesign/core/Center';
|
|
|
8
8
|
export default function AspectRatioWidescreen() {
|
|
9
9
|
return (
|
|
10
10
|
<Center width={600}>
|
|
11
|
-
<AspectRatio ratio={16 / 9}
|
|
11
|
+
<AspectRatio ratio={16 / 9}>
|
|
12
12
|
<img
|
|
13
13
|
src="https://lookaside.facebook.com/assets/astryx/light-scene-horizontal-1.png"
|
|
14
14
|
alt="16:9 widescreen"
|
|
15
|
+
style={{
|
|
16
|
+
width: '100%',
|
|
17
|
+
height: '100%',
|
|
18
|
+
objectFit: 'cover',
|
|
19
|
+
}}
|
|
15
20
|
/>
|
|
16
21
|
</AspectRatio>
|
|
17
22
|
</Center>
|
|
@@ -2,36 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
'use client';
|
|
4
4
|
|
|
5
|
-
import {Collapsible
|
|
5
|
+
import {Collapsible} 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
|
-
|
|
34
|
-
</VStack>
|
|
35
|
-
</CollapsibleGroup>
|
|
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>
|
|
36
34
|
);
|
|
37
35
|
}
|