@astryxdesign/cli 0.1.4-canary.fce2e7b → 0.1.4-canary.ff77e1c
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 +2 -1
- package/docs/getting-started.doc.mjs +4 -0
- package/docs/migration.doc.mjs +134 -0
- package/docs/styling.doc.mjs +53 -0
- package/docs/working-with-ai.doc.mjs +1 -1
- package/package.json +13 -8
- package/src/api/doctor.mjs +13 -2
- package/src/codemods/__tests__/registry.test.mjs +1 -0
- package/src/codemods/__tests__/runner.test.mjs +38 -0
- package/src/codemods/registry.mjs +1 -0
- package/src/codemods/runner.mjs +2 -0
- package/src/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +93 -0
- package/src/codemods/transforms/v0.1.5/index.mjs +19 -0
- package/src/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +140 -0
- package/src/commands/agent-docs.mjs +7 -5
- package/src/commands/agent-docs.test.mjs +33 -0
- package/src/commands/build-theme.color-scheme.test.mjs +153 -0
- package/src/commands/build-theme.mjs +2 -1
- package/src/commands/build-theme.variants.test.mjs +7 -18
- package/src/commands/doctor.test.mjs +34 -0
- package/src/commands/init.mjs +1 -1
- package/src/commands/swizzle.mjs +34 -0
- package/src/commands/swizzle.routing.test.mjs +67 -0
- package/templates/blocks/components/AspectRatio/AspectRatioCircleImage.tsx +1 -6
- package/templates/blocks/components/AspectRatio/AspectRatioImageGallery.tsx +2 -7
- package/templates/blocks/components/AspectRatio/AspectRatioShowcase.tsx +2 -5
- package/templates/blocks/components/AspectRatio/AspectRatioSquareImage.tsx +1 -6
- package/templates/blocks/components/AspectRatio/AspectRatioWidescreen.tsx +1 -6
- package/templates/blocks/components/CodeBlock/CodeBlockTerminal.doc.mjs +1 -1
- package/templates/blocks/components/Collapsible/CollapsibleWithoutCard.tsx +25 -23
- package/templates/blocks/components/CommandPaletteGroup/CommandPaletteGroupShowcase.tsx +27 -48
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.doc.mjs +15 -0
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputBasic.tsx +39 -0
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.doc.mjs +15 -0
- package/templates/blocks/components/CommandPaletteInput/CommandPaletteInputShowcase.tsx +39 -0
- package/templates/blocks/components/CommandPaletteItem/CommandPaletteItemShowcase.tsx +31 -54
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.doc.mjs +15 -0
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListBasic.tsx +27 -0
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.doc.mjs +15 -0
- package/templates/blocks/components/CommandPaletteList/CommandPaletteListShowcase.tsx +38 -0
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.doc.mjs +14 -0
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemBasic.tsx +44 -0
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.doc.mjs +15 -0
- package/templates/blocks/components/ContextMenuItem/ContextMenuItemShowcase.tsx +107 -0
- 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/kanban-board/page.tsx +37 -13
- 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 +4 -14
- package/templates/pages/table-page-heatmap-status/page.tsx +1 -1
- package/templates/pages/table-page-shoe-store-heatmap/page.tsx +5 -19
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
* - Claude Code: CLAUDE.md (root) or .claude/CLAUDE.md
|
|
10
10
|
* - Cursor: .cursorrules
|
|
11
11
|
* - Codex/generic: AGENTS.md
|
|
12
|
+
* - Hermes Agent: .hermes.md or HERMES.md (existing), else AGENTS.md
|
|
12
13
|
*
|
|
13
14
|
* Auto-detect: discovers existing files and updates them in place.
|
|
14
15
|
* Default (no existing files): creates .claude/CLAUDE.md.
|
|
15
16
|
*
|
|
16
|
-
* --agent <tool>: target a specific tool preset (claude, cursor, codex, all)
|
|
17
|
+
* --agent <tool>: target a specific tool preset (claude, cursor, codex, hermes, all)
|
|
17
18
|
* --agent-docs-path <path>: explicit file path(s)
|
|
18
19
|
*/
|
|
19
20
|
|
|
@@ -46,6 +47,7 @@ const AGENT_PRESETS = {
|
|
|
46
47
|
claude: [CLAUDE_MD, CLAUDE_DIR_MD],
|
|
47
48
|
cursor: ['.cursorrules', AGENTS_MD],
|
|
48
49
|
codex: [AGENTS_MD],
|
|
50
|
+
hermes: ['.hermes.md', 'HERMES.md', AGENTS_MD],
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
/**
|
|
@@ -64,7 +66,7 @@ export function discoverAgentDocs(targetDir) {
|
|
|
64
66
|
* Searches for existing files first, falls back to default creation path.
|
|
65
67
|
*
|
|
66
68
|
* @param {string} targetDir
|
|
67
|
-
* @param {string} agent - Preset name: 'claude', 'cursor', 'codex', 'all'
|
|
69
|
+
* @param {string} agent - Preset name: 'claude', 'cursor', 'codex', 'hermes', 'all'
|
|
68
70
|
* @returns {{inject: string[], create: string[]}} Files to inject into vs create fresh
|
|
69
71
|
*/
|
|
70
72
|
export function resolveAgentPaths(targetDir, agent) {
|
|
@@ -386,7 +388,7 @@ export function removeAgentDocs(targetDir) {
|
|
|
386
388
|
* @param {object} [options]
|
|
387
389
|
* @param {boolean} [options.zh]
|
|
388
390
|
* @param {string} [options.lang]
|
|
389
|
-
* @param {string} [options.agent] - Tool preset: 'claude', 'cursor', 'codex', 'all'
|
|
391
|
+
* @param {string} [options.agent] - Tool preset: 'claude', 'cursor', 'codex', 'hermes', 'all'
|
|
390
392
|
* @param {string[]} [options.paths] - Explicit paths (overrides agent/auto-detect)
|
|
391
393
|
* @param {boolean} [options.onlyReplace] - Only update files that already have Astryx markers (for upgrades)
|
|
392
394
|
* @returns {string[]} List of files written
|
|
@@ -468,14 +470,14 @@ export function installAgentDocs(targetDir, {zh = false, lang, agent, paths, onl
|
|
|
468
470
|
return written;
|
|
469
471
|
}
|
|
470
472
|
|
|
471
|
-
const VALID_AGENTS = ['claude', 'cursor', 'codex', 'all'];
|
|
473
|
+
const VALID_AGENTS = ['claude', 'cursor', 'codex', 'hermes', 'all'];
|
|
472
474
|
|
|
473
475
|
export function registerAgentDocs(program) {
|
|
474
476
|
program
|
|
475
477
|
.command('agent-docs')
|
|
476
478
|
.description('Install/update the component index for AI coding agents')
|
|
477
479
|
.option('--remove', 'Remove the design system section from all agent doc files')
|
|
478
|
-
.option('--agent <tool>', 'Target tool: claude, cursor, codex, all')
|
|
480
|
+
.option('--agent <tool>', 'Target tool: claude, cursor, codex, hermes, all')
|
|
479
481
|
.option('--agent-docs-path <path...>', 'Explicit file path(s) to write to')
|
|
480
482
|
.action(options => {
|
|
481
483
|
const targetDir = process.cwd();
|
|
@@ -449,6 +449,17 @@ describe('installAgentDocs', () => {
|
|
|
449
449
|
expect(fs.existsSync(path.join(tmpDir, 'AGENTS.md'))).toBe(true);
|
|
450
450
|
});
|
|
451
451
|
|
|
452
|
+
it('respects --agent hermes preset: creates AGENTS.md', () => {
|
|
453
|
+
setupCorePackage(tmpDir);
|
|
454
|
+
|
|
455
|
+
const written = installAgentDocs(tmpDir, {agent: 'hermes'});
|
|
456
|
+
|
|
457
|
+
expect(written).toEqual(['AGENTS.md']);
|
|
458
|
+
const content = fs.readFileSync(path.join(tmpDir, 'AGENTS.md'), 'utf-8');
|
|
459
|
+
expect(content).toContain('<!-- ASTRYX:START -->');
|
|
460
|
+
expect(fs.existsSync(path.join(tmpDir, '.claude'))).toBe(false);
|
|
461
|
+
});
|
|
462
|
+
|
|
452
463
|
it('respects explicit --paths', () => {
|
|
453
464
|
setupCorePackage(tmpDir);
|
|
454
465
|
|
|
@@ -548,4 +559,26 @@ describe('resolveAgentPaths', () => {
|
|
|
548
559
|
expect(result.create).toContain('AGENTS.md');
|
|
549
560
|
expect(result.create).toContain('.claude/CLAUDE.md');
|
|
550
561
|
});
|
|
562
|
+
|
|
563
|
+
it('hermes preset creates AGENTS.md when nothing exists', () => {
|
|
564
|
+
const result = resolveAgentPaths(tmpDir, 'hermes');
|
|
565
|
+
expect(result).toEqual({inject: [], create: ['AGENTS.md']});
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
it('hermes preset finds existing .hermes.md', () => {
|
|
569
|
+
fs.writeFileSync(path.join(tmpDir, '.hermes.md'), '');
|
|
570
|
+
const result = resolveAgentPaths(tmpDir, 'hermes');
|
|
571
|
+
expect(result).toEqual({inject: ['.hermes.md'], create: []});
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
it('hermes preset finds existing HERMES.md when no .hermes.md', () => {
|
|
575
|
+
fs.writeFileSync(path.join(tmpDir, 'HERMES.md'), '');
|
|
576
|
+
const result = resolveAgentPaths(tmpDir, 'hermes');
|
|
577
|
+
expect(result).toEqual({inject: ['HERMES.md'], create: []});
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
it('claude preset still creates .claude/CLAUDE.md when nothing exists (hermes is additive)', () => {
|
|
581
|
+
const result = resolveAgentPaths(tmpDir, 'claude');
|
|
582
|
+
expect(result).toEqual({inject: [], create: ['.claude/CLAUDE.md']});
|
|
583
|
+
});
|
|
551
584
|
});
|
|
@@ -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,9 @@ 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
|
+
// #3658: also emit attribute-specific rules so <Theme mode> can override color-scheme
|
|
942
943
|
const colorSchemeDecl = componentScope.includes('light-dark(')
|
|
943
|
-
? ' :root { color-scheme: light dark; }\n\n'
|
|
944
|
+
? ' :root { color-scheme: light dark; }\n html[data-theme="light"] { color-scheme: light; }\n html[data-theme="dark"] { color-scheme: dark; }\n\n'
|
|
944
945
|
: '';
|
|
945
946
|
cssParts.push(
|
|
946
947
|
`@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;
|
|
@@ -63,6 +63,33 @@ 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
|
+
|
|
66
93
|
function find(checks, id) {
|
|
67
94
|
return checks.find(c => c.id === id);
|
|
68
95
|
}
|
|
@@ -119,6 +146,13 @@ describe('doctor — individual checks', () => {
|
|
|
119
146
|
expect(res.status).toBe('pass');
|
|
120
147
|
});
|
|
121
148
|
|
|
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
|
+
|
|
122
156
|
it('config: INFO when no astryx.config.mjs', async () => {
|
|
123
157
|
const res = await checkConfig({cwd: tmpDir, configPath: null});
|
|
124
158
|
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, all')
|
|
201
|
+
.option('--agent <tool>', 'Target AI tool for agent docs: claude, cursor, codex, hermes, 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,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
|
+
});
|
|
@@ -8,15 +8,10 @@ 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" fit="cover">
|
|
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
|
-
}}
|
|
20
15
|
/>
|
|
21
16
|
</AspectRatio>
|
|
22
17
|
</Center>
|
|
@@ -25,16 +25,11 @@ 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} fit="cover">
|
|
29
29
|
<img
|
|
30
30
|
src="https://lookaside.facebook.com/assets/astryx/illustrative-horizontal-1.png"
|
|
31
31
|
alt={alt}
|
|
32
|
-
style={{
|
|
33
|
-
width: '100%',
|
|
34
|
-
height: '100%',
|
|
35
|
-
objectFit: 'cover',
|
|
36
|
-
borderRadius: 8,
|
|
37
|
-
}}
|
|
32
|
+
style={{borderRadius: 8}}
|
|
38
33
|
/>
|
|
39
34
|
</AspectRatio>
|
|
40
35
|
))}
|
|
@@ -34,16 +34,13 @@ export default function AspectRatioShowcase() {
|
|
|
34
34
|
<VStack key={label} gap={2} hAlign="center">
|
|
35
35
|
<AspectRatio
|
|
36
36
|
ratio={ratio}
|
|
37
|
+
fit="cover"
|
|
37
38
|
style={{
|
|
38
39
|
height: 120,
|
|
39
40
|
width: 'auto',
|
|
40
41
|
borderRadius: 'var(--radius-container)',
|
|
41
42
|
}}>
|
|
42
|
-
<img
|
|
43
|
-
src={src}
|
|
44
|
-
alt={alt}
|
|
45
|
-
style={{width: '100%', height: '100%', objectFit: 'cover'}}
|
|
46
|
-
/>
|
|
43
|
+
<img src={src} alt={alt} />
|
|
47
44
|
</AspectRatio>
|
|
48
45
|
<Text type="supporting" color="secondary">
|
|
49
46
|
{label}
|
|
@@ -8,15 +8,10 @@ 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} fit="cover">
|
|
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
|
-
}}
|
|
20
15
|
/>
|
|
21
16
|
</AspectRatio>
|
|
22
17
|
</Center>
|
|
@@ -8,15 +8,10 @@ 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} fit="cover">
|
|
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
|
-
}}
|
|
20
15
|
/>
|
|
21
16
|
</AspectRatio>
|
|
22
17
|
</Center>
|
|
@@ -7,7 +7,7 @@ export const doc = {
|
|
|
7
7
|
name: 'Code — Terminal',
|
|
8
8
|
displayName: 'Code — Terminal',
|
|
9
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
|
|
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
11
|
isReady: true,
|
|
12
12
|
aspectRatio: 16 / 9,
|
|
13
13
|
componentsUsed: ['CodeBlock', 'SyntaxTheme'],
|