@csszyx/cli 0.1.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 +61 -0
- package/dist/index.d.ts +161 -0
- package/dist/index.js +3125 -0
- package/package.json +66 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @csszyx/cli
|
|
2
|
+
|
|
3
|
+
> Command-line tools for csszyx.
|
|
4
|
+
|
|
5
|
+
Review usage stats, diagnose issues, and initialize projects.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @csszyx/cli
|
|
11
|
+
# or run via npx
|
|
12
|
+
npx csszyx <command>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Commands
|
|
16
|
+
|
|
17
|
+
### `init`
|
|
18
|
+
|
|
19
|
+
Initialize csszyx in a new or existing project.
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx csszyx init
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### `doctor`
|
|
26
|
+
|
|
27
|
+
Diagnose configuration and mangling issues.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx csszyx doctor
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### `audit`
|
|
34
|
+
|
|
35
|
+
View performance statistics and mangle compression rates.
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx csszyx audit
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### `generate-types`
|
|
42
|
+
|
|
43
|
+
Generate TypeScript definitions from your `tailwind.config.js`.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx csszyx generate-types
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### `migrate`
|
|
50
|
+
|
|
51
|
+
Convert Tailwind `className="..."` to csszyx `sz={...}` props. Phase 1 supports static string classNames.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx csszyx migrate src/
|
|
55
|
+
npx csszyx migrate --dry-run # preview changes
|
|
56
|
+
npx csszyx migrate --ignore "*.test.*" # skip test files
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT © [csszyx contributors](https://github.com/nguyennhutien/csszyx)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CLI command: generate-types
|
|
4
|
+
*
|
|
5
|
+
* Scans tailwind.config.js and generates strict TypeScript types
|
|
6
|
+
* for the csszyx sz prop.
|
|
7
|
+
*
|
|
8
|
+
* @module commands/generate-types
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Command options for generate-types.
|
|
12
|
+
*/
|
|
13
|
+
interface GenerateTypesOptions {
|
|
14
|
+
/** Path to tailwind.config.js (auto-detect if not specified) */
|
|
15
|
+
config?: string;
|
|
16
|
+
/** Output file path (default: ./csszyx.d.ts) */
|
|
17
|
+
output?: string;
|
|
18
|
+
/** Current working directory */
|
|
19
|
+
cwd?: string;
|
|
20
|
+
/** Silent mode (no output) */
|
|
21
|
+
silent?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Execute the generate-types command.
|
|
25
|
+
*
|
|
26
|
+
* @param {GenerateTypesOptions} options - Command options
|
|
27
|
+
* @returns {Promise<void>}
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* await generateTypes({ config: './tailwind.config.js', output: './src/csszyx.d.ts' });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare function generateTypes(options?: GenerateTypesOptions): Promise<void>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Tailwind CSS configuration scanner.
|
|
38
|
+
*
|
|
39
|
+
* Scans and resolves tailwind.config.js to extract theme values
|
|
40
|
+
* for TypeScript type generation.
|
|
41
|
+
*
|
|
42
|
+
* @module scanner/tailwind-scanner
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Resolved Tailwind theme structure.
|
|
46
|
+
*/
|
|
47
|
+
interface ResolvedTheme {
|
|
48
|
+
colors: Record<string, string | Record<string, string>>;
|
|
49
|
+
spacing: Record<string, string>;
|
|
50
|
+
screens: Record<string, string>;
|
|
51
|
+
fontFamily: Record<string, string[]>;
|
|
52
|
+
fontSize: Record<string, string | [string, Record<string, string>]>;
|
|
53
|
+
fontWeight: Record<string, string>;
|
|
54
|
+
borderRadius: Record<string, string>;
|
|
55
|
+
boxShadow: Record<string, string>;
|
|
56
|
+
opacity: Record<string, string>;
|
|
57
|
+
zIndex: Record<string, string>;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Scanner result containing resolved theme and metadata.
|
|
62
|
+
*/
|
|
63
|
+
interface ScanResult {
|
|
64
|
+
theme: ResolvedTheme;
|
|
65
|
+
configPath: string;
|
|
66
|
+
hasCustomColors: boolean;
|
|
67
|
+
hasCustomSpacing: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Find the Tailwind config file in the given directory.
|
|
71
|
+
*
|
|
72
|
+
* @param {string} cwd - Current working directory
|
|
73
|
+
* @returns {string | null} Path to config file or null if not found
|
|
74
|
+
*/
|
|
75
|
+
declare function findConfigFile(cwd: string): string | null;
|
|
76
|
+
/**
|
|
77
|
+
* Load and resolve Tailwind configuration.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} configPath - Path to tailwind.config.js/ts
|
|
80
|
+
* @returns {Promise<ScanResult>} Resolved theme and metadata
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* const result = await scanTailwindConfig('./tailwind.config.js');
|
|
85
|
+
* console.log(result.theme.colors);
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare function scanTailwindConfig(configPath: string): Promise<ScanResult>;
|
|
89
|
+
/**
|
|
90
|
+
* Extract flat color names from nested color object.
|
|
91
|
+
*
|
|
92
|
+
* @param {Record<string, unknown>} colors - Tailwind colors object
|
|
93
|
+
* @returns {string[]} Flat array of color class names (e.g., 'red-500', 'blue-100')
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const colors = { red: { 500: '#f00', 600: '#c00' }, white: '#fff' };
|
|
98
|
+
* flattenColors(colors); // ['red-500', 'red-600', 'white']
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function flattenColors(colors: Record<string, string | Record<string, string>>): string[];
|
|
102
|
+
/**
|
|
103
|
+
* Extract spacing values as strings.
|
|
104
|
+
*
|
|
105
|
+
* @param {Record<string, string>} spacing - Tailwind spacing object
|
|
106
|
+
* @returns {string[]} Array of spacing keys (e.g., '0', '1', '2', 'px')
|
|
107
|
+
*/
|
|
108
|
+
declare function extractSpacingKeys(spacing: Record<string, string>): string[];
|
|
109
|
+
/**
|
|
110
|
+
* Extract screen breakpoint names.
|
|
111
|
+
*
|
|
112
|
+
* @param {Record<string, string>} screens - Tailwind screens object
|
|
113
|
+
* @returns {string[]} Array of screen names (e.g., 'sm', 'md', 'lg')
|
|
114
|
+
*/
|
|
115
|
+
declare function extractScreenKeys(screens: Record<string, string>): string[];
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* TypeScript declaration generator for csszyx.
|
|
119
|
+
*
|
|
120
|
+
* Generates strict TypeScript types from resolved Tailwind configuration
|
|
121
|
+
* using declaration merging to override the base SzObject interface.
|
|
122
|
+
*
|
|
123
|
+
* @module generator/type-generator
|
|
124
|
+
*/
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Type generation options.
|
|
128
|
+
*/
|
|
129
|
+
interface GeneratorOptions {
|
|
130
|
+
/** Output file path (default: ./csszyx.d.ts) */
|
|
131
|
+
output?: string;
|
|
132
|
+
/** Include comments in generated file */
|
|
133
|
+
includeComments?: boolean;
|
|
134
|
+
/** Include deprecated/legacy properties */
|
|
135
|
+
includeLegacy?: boolean;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Generate TypeScript declarations from resolved Tailwind theme.
|
|
139
|
+
*
|
|
140
|
+
* @param {ResolvedTheme} theme - Resolved Tailwind theme
|
|
141
|
+
* @param {GeneratorOptions} options - Generation options
|
|
142
|
+
* @returns {string} Generated TypeScript declaration content
|
|
143
|
+
*/
|
|
144
|
+
declare function generateTypeDeclarations(theme: ResolvedTheme, options?: GeneratorOptions): string;
|
|
145
|
+
/**
|
|
146
|
+
* Write generated declarations to file.
|
|
147
|
+
*
|
|
148
|
+
* @param {string} content - Generated TypeScript content
|
|
149
|
+
* @param {string} outputPath - Output file path
|
|
150
|
+
*/
|
|
151
|
+
declare function writeDeclarationFile(content: string, outputPath: string): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* Generate type declarations from Tailwind theme and write to file.
|
|
154
|
+
*
|
|
155
|
+
* @param {ResolvedTheme} theme - Resolved Tailwind theme
|
|
156
|
+
* @param {GeneratorOptions} options - Generation options
|
|
157
|
+
* @returns {Promise<string>} Path to generated file
|
|
158
|
+
*/
|
|
159
|
+
declare function generateAndWriteTypes(theme: ResolvedTheme, options?: GeneratorOptions): Promise<string>;
|
|
160
|
+
|
|
161
|
+
export { type GenerateTypesOptions, type GeneratorOptions, type ResolvedTheme, type ScanResult, extractScreenKeys, extractSpacingKeys, findConfigFile, flattenColors, generateAndWriteTypes, generateTypeDeclarations, generateTypes, scanTailwindConfig, writeDeclarationFile };
|