tailwind-unwind 0.4.0 → 0.5.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 +73 -27
- package/dist/{chunk-UXXIEFP4.js → chunk-RMTZCCPS.js} +385 -100
- package/dist/chunk-RMTZCCPS.js.map +1 -0
- package/dist/cli/index.js +80 -44
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +143 -78
- package/dist/index.js +11 -1
- package/package.json +1 -1
- package/dist/chunk-UXXIEFP4.js.map +0 -1
package/README.md
CHANGED
|
@@ -35,51 +35,75 @@ And generates the CSS for you:
|
|
|
35
35
|
|
|
36
36
|
## Quick start
|
|
37
37
|
|
|
38
|
+
Run from your project root — no paths required (defaults: scan `.`, CSS output `styles.css`):
|
|
39
|
+
|
|
38
40
|
```bash
|
|
39
|
-
# 1.
|
|
40
|
-
npx tailwind-unwind
|
|
41
|
+
# 1. Quick check — extractable duplicates + apply preview
|
|
42
|
+
npx tailwind-unwind check
|
|
41
43
|
|
|
42
44
|
# 2. Generate CSS
|
|
43
|
-
npx tailwind-unwind generate
|
|
45
|
+
npx tailwind-unwind generate
|
|
44
46
|
|
|
45
47
|
# 3. Import styles.css in globals.css, then replace in source files
|
|
46
|
-
npx tailwind-unwind apply
|
|
47
|
-
npx tailwind-unwind apply
|
|
48
|
+
npx tailwind-unwind apply --dry-run # preview first
|
|
49
|
+
npx tailwind-unwind apply # write changes
|
|
48
50
|
```
|
|
49
51
|
|
|
52
|
+
Override defaults with flags (`./src`, `--output src/styles/components.css`) or `tailwind-unwind.config.json`.
|
|
53
|
+
|
|
50
54
|
Install globally (optional):
|
|
51
55
|
|
|
52
56
|
```bash
|
|
53
57
|
npm install -g tailwind-unwind
|
|
54
58
|
```
|
|
55
59
|
|
|
56
|
-
##
|
|
60
|
+
## Commands
|
|
57
61
|
|
|
58
62
|
| Command | What it does |
|
|
59
63
|
|---------|--------------|
|
|
60
|
-
| `
|
|
64
|
+
| `check` | One-shot health check: extractable duplicates + apply dry-run preview. **Start here.** |
|
|
65
|
+
| `analyze` | Detailed report of frequent class combinations. Safe — read-only. |
|
|
61
66
|
| `generate` | Creates a CSS file with `@layer components` + `@apply`. Does not touch your `.tsx` files. |
|
|
62
67
|
| `apply` | Does what `generate` does **and** rewrites matching `className` in source files. |
|
|
68
|
+
| `init` | Generates `tailwind-unwind.config.json` from your project scan. |
|
|
63
69
|
|
|
64
|
-
**Important:** `analyze` looks for frequent patterns (including subsets). `generate
|
|
70
|
+
**Important:** `analyze` looks for frequent patterns (including subsets) with `--min-occurrences 5` by default. `check`, `generate`, and `apply` extract **exact duplicate** class strings with `--min-occurrences 3`.
|
|
65
71
|
|
|
66
72
|
In the analyze report, look for `Extractable: yes` — those patterns can be passed to `generate` / `apply`.
|
|
67
73
|
|
|
74
|
+
### `check` — recommended entry point
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npx tailwind-unwind check
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Shows how many patterns are ready to extract and previews what `apply` would change (without writing files).
|
|
81
|
+
|
|
82
|
+
For CI — fail when duplicates exceed a threshold:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npx tailwind-unwind check --fail-on-extractable 0 # fail if any extractable pattern exists
|
|
86
|
+
npx tailwind-unwind check --format json
|
|
87
|
+
```
|
|
88
|
+
|
|
68
89
|
## Typical workflow
|
|
69
90
|
|
|
70
91
|
```bash
|
|
71
92
|
# Optional: create config from your project
|
|
72
|
-
npx tailwind-unwind init
|
|
93
|
+
npx tailwind-unwind init
|
|
73
94
|
|
|
74
|
-
#
|
|
75
|
-
npx tailwind-unwind
|
|
95
|
+
# Quick overview + dry-run preview
|
|
96
|
+
npx tailwind-unwind check
|
|
97
|
+
|
|
98
|
+
# Detailed report (optional)
|
|
99
|
+
npx tailwind-unwind analyze --format json > report.json
|
|
76
100
|
|
|
77
101
|
# Generate only extractable patterns from the report
|
|
78
|
-
npx tailwind-unwind generate --from-report report.json
|
|
102
|
+
npx tailwind-unwind generate --from-report report.json
|
|
79
103
|
|
|
80
104
|
# Preview replacements, then apply
|
|
81
|
-
npx tailwind-unwind apply
|
|
82
|
-
npx tailwind-unwind apply
|
|
105
|
+
npx tailwind-unwind apply --dry-run
|
|
106
|
+
npx tailwind-unwind apply --prettier
|
|
83
107
|
```
|
|
84
108
|
|
|
85
109
|
## Configuration
|
|
@@ -87,7 +111,7 @@ npx tailwind-unwind apply ./src --output src/styles/components.css --prettier
|
|
|
87
111
|
Create `tailwind-unwind.config.json` manually or run `init`:
|
|
88
112
|
|
|
89
113
|
```bash
|
|
90
|
-
npx tailwind-unwind init
|
|
114
|
+
npx tailwind-unwind init
|
|
91
115
|
```
|
|
92
116
|
|
|
93
117
|
Also supported: `.tailwind-unwindrc`, `tailwind-unwind.config.ts` / `.js`.
|
|
@@ -116,6 +140,8 @@ CLI flags override config values.
|
|
|
116
140
|
Parsed: `cn`, `clsx`, `classnames`, `twMerge`, `cva`, `tv`, template literals.
|
|
117
141
|
Class order does not matter (`flex p-4` = `p-4 flex`).
|
|
118
142
|
|
|
143
|
+
Skipped locations are grouped by reason in the console; use `--verbose-skipped` for the full list.
|
|
144
|
+
|
|
119
145
|
## Generated class names
|
|
120
146
|
|
|
121
147
|
Default prefix is `twu-` to avoid clashes with your existing styles:
|
|
@@ -131,9 +157,11 @@ Override with `--prefix app-` or the `names` field in config.
|
|
|
131
157
|
|
|
132
158
|
| Flag | Commands | Purpose |
|
|
133
159
|
|------|----------|---------|
|
|
160
|
+
| `--fail-on-extractable <n>` | check | Exit 1 when extractable patterns exceed `n` |
|
|
161
|
+
| `--verbose-skipped` | apply, check | List every skipped replacement (default: grouped summary) |
|
|
134
162
|
| `--dry-run` | apply | Preview without writing files |
|
|
135
163
|
| `--prettier` | apply | Format changed files with Prettier |
|
|
136
|
-
| `--format json` | analyze, generate, apply | Output for CI / scripts |
|
|
164
|
+
| `--format json` | analyze, check, generate, apply | Output for CI / scripts |
|
|
137
165
|
| `--changed [ref]` | all | Only git-changed files |
|
|
138
166
|
| `--from-report <file>` | generate, apply | Use analyze JSON output |
|
|
139
167
|
| `--extractable-only` | generate, apply | Only patterns marked extractable |
|
|
@@ -142,33 +170,49 @@ Override with `--prefix app-` or the `names` field in config.
|
|
|
142
170
|
|
|
143
171
|
### Defaults
|
|
144
172
|
|
|
145
|
-
| | analyze | generate / apply |
|
|
146
|
-
|
|
173
|
+
| | analyze | check / generate / apply |
|
|
174
|
+
|--|---------|--------------------------|
|
|
175
|
+
| scan path | `.` (project root) | `.` |
|
|
176
|
+
| `--output` | — | `styles.css` |
|
|
147
177
|
| `--min-occurrences` | 5 | 3 |
|
|
148
178
|
| `--prefix` | — | `twu-` |
|
|
149
179
|
|
|
180
|
+
Config file values override CLI defaults; explicit flags override config.
|
|
181
|
+
|
|
150
182
|
## Programmatic API
|
|
151
183
|
|
|
152
184
|
```typescript
|
|
153
|
-
import {
|
|
154
|
-
|
|
155
|
-
|
|
185
|
+
import {
|
|
186
|
+
checkCommand,
|
|
187
|
+
analyzeCommand,
|
|
188
|
+
generateCommand,
|
|
189
|
+
applyCommand,
|
|
190
|
+
} from 'tailwind-unwind';
|
|
191
|
+
|
|
192
|
+
await checkCommand('.', { output: 'styles.css' });
|
|
193
|
+
await analyzeCommand('.', { format: 'json', extractableMinOccurrences: 3 });
|
|
156
194
|
```
|
|
157
195
|
|
|
158
196
|
Full exports: `walkSourceFiles`, `parseFile`, `findRepeatedClassSets`, `buildComponents`, `loadCommandOptions`, and more.
|
|
159
197
|
|
|
160
|
-
##
|
|
198
|
+
## CI
|
|
199
|
+
|
|
200
|
+
In your app repo — gate PRs on duplicate Tailwind patterns:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
npx tailwind-unwind check --fail-on-extractable 0 --format json
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
GitHub Actions composite action — see [`action.yml`](action.yml):
|
|
161
207
|
|
|
162
208
|
```yaml
|
|
163
|
-
- uses: AVPletnev/tailwind-unwind@v0.
|
|
209
|
+
- uses: AVPletnev/tailwind-unwind@v0.5.0
|
|
164
210
|
with:
|
|
165
|
-
command:
|
|
166
|
-
path: ./src
|
|
211
|
+
command: check
|
|
167
212
|
format: json
|
|
213
|
+
args: --fail-on-extractable 0
|
|
168
214
|
```
|
|
169
215
|
|
|
170
|
-
See [`action.yml`](action.yml) for inputs.
|
|
171
|
-
|
|
172
216
|
## Development
|
|
173
217
|
|
|
174
218
|
```bash
|
|
@@ -176,6 +220,8 @@ git clone https://github.com/AVPletnev/tailwind-unwind.git
|
|
|
176
220
|
cd tailwind-unwind && npm install && npm run build && npm test
|
|
177
221
|
```
|
|
178
222
|
|
|
223
|
+
CI in this repo also runs `check` against `test-project` as a smoke test.
|
|
224
|
+
|
|
179
225
|
## License
|
|
180
226
|
|
|
181
227
|
MIT — see [LICENSE](LICENSE).
|