@csszyx/cli 0.3.0 → 0.4.0
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/README.md +13 -1
- package/dist/index.d.ts +78 -1
- package/dist/index.js +1209 -88
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -40,10 +40,22 @@ npx csszyx audit
|
|
|
40
40
|
|
|
41
41
|
### `generate-types`
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
> **Not applicable for Tailwind v4 projects.**
|
|
44
|
+
>
|
|
45
|
+
> CSSzyx requires Tailwind v4, which replaces `tailwind.config.js` with `@theme {}` blocks
|
|
46
|
+
> in CSS. This command uses Tailwind v3's `resolveConfig()` API to parse JS config files —
|
|
47
|
+
> that API does not exist in v4.
|
|
48
|
+
>
|
|
49
|
+
> For v4 projects, use the plugin's `build.scanCss` option instead. See
|
|
50
|
+
> [Plugin Config docs](/docs/reference/config).
|
|
51
|
+
>
|
|
52
|
+
> This command is kept for potential future Tailwind v3 compatibility support.
|
|
53
|
+
> If your project needs it, open an issue.
|
|
44
54
|
|
|
45
55
|
```bash
|
|
46
56
|
npx csszyx generate-types
|
|
57
|
+
npx csszyx generate-types --config ./path/to/tailwind.config.js
|
|
58
|
+
npx csszyx generate-types --output ./src/csszyx.d.ts
|
|
47
59
|
```
|
|
48
60
|
|
|
49
61
|
### `migrate`
|
package/dist/index.d.ts
CHANGED
|
@@ -158,4 +158,81 @@ declare function writeDeclarationFile(content: string, outputPath: string): Prom
|
|
|
158
158
|
*/
|
|
159
159
|
declare function generateAndWriteTypes(theme: ResolvedTheme, options?: GeneratorOptions): Promise<string>;
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
/**
|
|
162
|
+
* A single entry in .csszyx-todo.json. Possible values:
|
|
163
|
+
* - `Record<string, unknown>` — direct sz object mapping ({ p: 4, bg: 'blue-500' })
|
|
164
|
+
* - `string` — Tailwind class string to auto-convert, or a "sz:" directive
|
|
165
|
+
* ('sz:todo' | 'sz:keep' | 'sz:remove')
|
|
166
|
+
* - `null | false` — treated as 'sz:todo' (unresolved, for backwards compat)
|
|
167
|
+
*/
|
|
168
|
+
type CsszyxTodoEntry = Record<string, unknown> | string | null | false;
|
|
169
|
+
/**
|
|
170
|
+
* Shape of .csszyx-todo.json — a map from Tailwind class names to resolution entries.
|
|
171
|
+
*/
|
|
172
|
+
type CsszyxTodoMap = Record<string, CsszyxTodoEntry>;
|
|
173
|
+
/**
|
|
174
|
+
* Convert a full className string into a single merged sz object.
|
|
175
|
+
* Returns the sz object plus any unrecognized classes and classes to keep in className.
|
|
176
|
+
*
|
|
177
|
+
* @param {string} className - The full Tailwind class string
|
|
178
|
+
* @param {CsszyxTodoMap} [customMap] - Optional csszyx-todo.json mapping
|
|
179
|
+
* @returns {{ szObject, unrecognized, keepInClassName }} Merged sz object, unrecognized, and "sz:keep" classes
|
|
180
|
+
*/
|
|
181
|
+
declare function classNameToSzObject(className: string, customMap?: CsszyxTodoMap): {
|
|
182
|
+
szObject: Record<string, unknown>;
|
|
183
|
+
unrecognized: string[];
|
|
184
|
+
keepInClassName: string[];
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* AST Transformer: Replaces className attributes with sz props.
|
|
189
|
+
*
|
|
190
|
+
* Phase 2: Uses Babel AST traversal for JSX/TSX files. Supports:
|
|
191
|
+
* - Static className="..." (string literals)
|
|
192
|
+
* - className={'...'} (string in expression container)
|
|
193
|
+
* - className={clsx(...)} / cn(...) / twMerge(...)
|
|
194
|
+
* - className={cond ? 'a' : 'b'} (ternary)
|
|
195
|
+
* - className={cond && 'a'} (logical AND)
|
|
196
|
+
* - className={`static ${dynamic}`} (template literals)
|
|
197
|
+
*
|
|
198
|
+
* HTML files use regex (Babel doesn't parse HTML).
|
|
199
|
+
*
|
|
200
|
+
* @module
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Result of source transformation.
|
|
205
|
+
*/
|
|
206
|
+
interface TransformResult {
|
|
207
|
+
code: string;
|
|
208
|
+
changed: boolean;
|
|
209
|
+
warnings: string[];
|
|
210
|
+
stats: {
|
|
211
|
+
classNamesTransformed: number;
|
|
212
|
+
classNamesSkipped: number;
|
|
213
|
+
classesUnrecognized: string[];
|
|
214
|
+
};
|
|
215
|
+
/** Imports that may be unused after migration (e.g., clsx, cn). */
|
|
216
|
+
potentiallyUnusedImports: string[];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Options for source transformation.
|
|
220
|
+
*/
|
|
221
|
+
interface TransformOptions {
|
|
222
|
+
/** If true, injects {/* @sz-todo *\/} comments above nodes with unrecognized classes */
|
|
223
|
+
injectTodos?: boolean;
|
|
224
|
+
/** Map of custom classes to sz objects, used to override unrecognized classes */
|
|
225
|
+
customMap?: CsszyxTodoMap;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Transform a JSX/TSX source file, replacing className with sz props.
|
|
229
|
+
* Uses Babel AST for accurate, context-aware transformation.
|
|
230
|
+
*
|
|
231
|
+
* @param source - Source file content string.
|
|
232
|
+
* @param filePath - Path to the source file (for error messages).
|
|
233
|
+
* @param options - Transformation options.
|
|
234
|
+
* @returns {TransformResult} Transformed code and stats.
|
|
235
|
+
*/
|
|
236
|
+
declare function transformSource(source: string, filePath: string, options?: TransformOptions): TransformResult;
|
|
237
|
+
|
|
238
|
+
export { type CsszyxTodoEntry, type CsszyxTodoMap, type GenerateTypesOptions, type GeneratorOptions, type TransformResult as MigrateResult, type ResolvedTheme, type ScanResult, classNameToSzObject, extractScreenKeys, extractSpacingKeys, findConfigFile, flattenColors, generateAndWriteTypes, generateTypeDeclarations, generateTypes, transformSource as migrateSource, scanTailwindConfig, writeDeclarationFile };
|