@astryxdesign/cli 0.6.3-canary.22be8db → 0.6.3-canary.2bb99ed
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.
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Ensures `astryx theme build` preserves AST-012 adaptation semantics.
|
|
5
5
|
* Runtime and static output share core's compiler; this suite guards the CLI
|
|
6
|
-
* loading, diagnostics, serialization, and extension boundaries around it
|
|
7
|
-
* including root component overrides underneath adapted typography scales.
|
|
6
|
+
* loading, diagnostics, serialization, and extension boundaries around it.
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
9
|
import {afterEach, beforeAll, beforeEach, describe, expect, it} from 'vitest';
|
|
@@ -95,104 +94,6 @@ describe('theme build adaptations', () => {
|
|
|
95
94
|
);
|
|
96
95
|
});
|
|
97
96
|
|
|
98
|
-
it.each([
|
|
99
|
-
['defined', writeTheme],
|
|
100
|
-
['plain', writePlainTheme],
|
|
101
|
-
])(
|
|
102
|
-
'preserves component pins in %s themes and built extensions',
|
|
103
|
-
async (_kind, write) => {
|
|
104
|
-
const {defineTheme, generateAdaptationCSS, generateThemeCSS} =
|
|
105
|
-
await import('@astryxdesign/core/theme');
|
|
106
|
-
const project = path.join(tmpDir, 'project');
|
|
107
|
-
const themesDir = path.join(project, 'themes');
|
|
108
|
-
const displayFamily =
|
|
109
|
-
'Sarina, "Brush Script MT", "Snell Roundhand", cursive';
|
|
110
|
-
const input = {
|
|
111
|
-
name: 'adaptive-display',
|
|
112
|
-
typography: {
|
|
113
|
-
scale: {base: 16, ratio: 1.25},
|
|
114
|
-
body: {family: 'Outfit', fallbacks: 'sans-serif'},
|
|
115
|
-
},
|
|
116
|
-
components: {
|
|
117
|
-
text: Object.fromEntries(
|
|
118
|
-
['display-1', 'display-2', 'display-3'].map(type => [
|
|
119
|
-
`type:${type}`,
|
|
120
|
-
{fontFamily: displayFamily},
|
|
121
|
-
]),
|
|
122
|
-
),
|
|
123
|
-
button: {base: {borderRadius: '12px'}},
|
|
124
|
-
},
|
|
125
|
-
adaptations: {
|
|
126
|
-
rules: [
|
|
127
|
-
{
|
|
128
|
-
when: {width: {below: 'md'}, pointer: 'coarse'},
|
|
129
|
-
value: {typography: {scale: {base: 14, ratio: 1.2}}},
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
when: {contrast: 'more'},
|
|
133
|
-
value: {
|
|
134
|
-
typography: {scale: {base: 15}},
|
|
135
|
-
components: {
|
|
136
|
-
text: {'type:display-1': {fontFamily: 'monospace'}},
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
const themeFile = write(themesDir, input.name, JSON.stringify(input));
|
|
144
|
-
const result = await build(project, themeFile);
|
|
145
|
-
expect(result.code, result.stderr).toBe(0);
|
|
146
|
-
const css = fs.readFileSync(
|
|
147
|
-
path.join(themesDir, 'adaptive-display.css'),
|
|
148
|
-
'utf8',
|
|
149
|
-
);
|
|
150
|
-
const compact = value => value.replace(/\s+/g, ' ').trim();
|
|
151
|
-
const source = defineTheme(input);
|
|
152
|
-
const runtime = generateThemeCSS(source);
|
|
153
|
-
// The CLI wraps root, adaptation, and surface CSS in separate @layer
|
|
154
|
-
// blocks; their contents and order must still match runtime output.
|
|
155
|
-
const adaptationCSS = generateAdaptationCSS(source).component;
|
|
156
|
-
const [rootCSS, surfaceCSS] = runtime.component.split(adaptationCSS);
|
|
157
|
-
const blocks = [rootCSS, adaptationCSS, surfaceCSS].map(compact);
|
|
158
|
-
let previousIndex = -1;
|
|
159
|
-
for (const block of blocks) {
|
|
160
|
-
expect(compact(css)).toContain(block);
|
|
161
|
-
const index = compact(css).indexOf(block);
|
|
162
|
-
expect(index).toBeGreaterThan(previousIndex);
|
|
163
|
-
previousIndex = index;
|
|
164
|
-
}
|
|
165
|
-
expect(compact(css)).toContain(compact(runtime.prose));
|
|
166
|
-
const scaleBlock = css.slice(
|
|
167
|
-
css.indexOf('@media (width < 768px) and (pointer: coarse)'),
|
|
168
|
-
css.indexOf('@media (prefers-contrast: more)'),
|
|
169
|
-
);
|
|
170
|
-
expect(scaleBlock).toContain('--font-size-base: 0.875rem');
|
|
171
|
-
expect(scaleBlock).not.toContain('.astryx-text');
|
|
172
|
-
expect(scaleBlock).not.toContain('.astryx-heading');
|
|
173
|
-
expect(scaleBlock).not.toContain('.astryx-button');
|
|
174
|
-
expect(css).toContain(`font-family: ${displayFamily};`);
|
|
175
|
-
expect(css).toContain('font-family: monospace;');
|
|
176
|
-
|
|
177
|
-
const {adaptiveDisplayTheme: builtTheme} = await import(
|
|
178
|
-
pathToFileURL(path.join(themesDir, 'adaptive-display.js')).href
|
|
179
|
-
);
|
|
180
|
-
expect(builtTheme.__adaptationRules).toBeUndefined();
|
|
181
|
-
expect(generateThemeCSS(builtTheme)).toEqual(runtime);
|
|
182
|
-
const childInput = {
|
|
183
|
-
name: 'display-child',
|
|
184
|
-
components: {text: {'type:display-2': {fontFamily: 'serif'}}},
|
|
185
|
-
};
|
|
186
|
-
const fromSource = defineTheme({...childInput, extends: source});
|
|
187
|
-
const fromBuilt = defineTheme({...childInput, extends: builtTheme});
|
|
188
|
-
expect(generateThemeCSS(fromBuilt)).toEqual(generateThemeCSS(fromSource));
|
|
189
|
-
expect(fromBuilt.__adaptationRules[0].components).toBeUndefined();
|
|
190
|
-
expect(fromBuilt.components.text['type:display-2'].fontFamily).toBe(
|
|
191
|
-
'serif',
|
|
192
|
-
);
|
|
193
|
-
},
|
|
194
|
-
);
|
|
195
|
-
|
|
196
97
|
it('resolves a plain object whose only input-only field is adaptations', async () => {
|
|
197
98
|
const project = path.join(tmpDir, 'project');
|
|
198
99
|
const themesDir = path.join(project, 'themes');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.6.3-canary.
|
|
3
|
+
"version": "0.6.3-canary.2bb99ed",
|
|
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",
|
|
@@ -101,10 +101,10 @@
|
|
|
101
101
|
"zod": "^4.4.3"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@astryxdesign/charts": "0.6.3-canary.
|
|
105
|
-
"@astryxdesign/core": "0.6.3-canary.
|
|
106
|
-
"@astryxdesign/lab": "0.6.3-canary.
|
|
107
|
-
"@astryxdesign/theme-neutral": "0.6.3-canary.
|
|
104
|
+
"@astryxdesign/charts": "0.6.3-canary.2bb99ed",
|
|
105
|
+
"@astryxdesign/core": "0.6.3-canary.2bb99ed",
|
|
106
|
+
"@astryxdesign/lab": "0.6.3-canary.2bb99ed",
|
|
107
|
+
"@astryxdesign/theme-neutral": "0.6.3-canary.2bb99ed"
|
|
108
108
|
},
|
|
109
109
|
"peerDependenciesMeta": {
|
|
110
110
|
"@astryxdesign/charts": {
|
|
@@ -121,10 +121,10 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"@astryxdesign/charts": "0.6.3-canary.
|
|
125
|
-
"@astryxdesign/core": "0.6.3-canary.
|
|
126
|
-
"@astryxdesign/lab": "0.6.3-canary.
|
|
127
|
-
"@astryxdesign/theme-neutral": "0.6.3-canary.
|
|
124
|
+
"@astryxdesign/charts": "0.6.3-canary.2bb99ed",
|
|
125
|
+
"@astryxdesign/core": "0.6.3-canary.2bb99ed",
|
|
126
|
+
"@astryxdesign/lab": "0.6.3-canary.2bb99ed",
|
|
127
|
+
"@astryxdesign/theme-neutral": "0.6.3-canary.2bb99ed",
|
|
128
128
|
"@heroicons/react": "^2.2.0",
|
|
129
129
|
"@stylexjs/stylex": "^0.19.0",
|
|
130
130
|
"@types/babel__core": "^7.20.5",
|