cleanwind 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/LICENSE +21 -0
- package/README.md +41 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 cleanwind contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# cleanwind
|
|
2
|
+
|
|
3
|
+
Clean imports and Tailwind CSS class names from the command line.
|
|
4
|
+
|
|
5
|
+
`cleanwind` removes duplicate import specifiers, merges imports from the same
|
|
6
|
+
module, sorts import groups, deduplicates Tailwind CSS classes, sorts utilities,
|
|
7
|
+
and reports conflicting classes.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm add -D cleanwind
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
pnpm cleanwind check
|
|
19
|
+
pnpm cleanwind fix
|
|
20
|
+
pnpm cleanwind fix --staged
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## CLI
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
cleanwind check
|
|
27
|
+
cleanwind check --cwd ./apps/web
|
|
28
|
+
cleanwind check --config ./cleanwind.config.ts
|
|
29
|
+
cleanwind check --write
|
|
30
|
+
cleanwind check --verbose
|
|
31
|
+
|
|
32
|
+
cleanwind fix
|
|
33
|
+
cleanwind fix --staged
|
|
34
|
+
cleanwind fix --check
|
|
35
|
+
cleanwind fix --cwd ./apps/web --verbose
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Packages
|
|
39
|
+
|
|
40
|
+
The CLI uses `@cleanwind/core` internally. Use `@cleanwind/core` directly when
|
|
41
|
+
you want to build custom integrations.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { check, fix } from "@cleanwind/core";
|
|
6
|
+
var program = new Command();
|
|
7
|
+
program.name("cleanwind").description("Clean imports and Tailwind CSS class names.").version("0.1.0");
|
|
8
|
+
program.command("check").description("Check files without writing changes.").option("--cwd <path>", "Working directory").option("--config <path>", "Path to cleanwind config").option("--write", "Write fixes while running check").option("--check", "Force check mode", true).option("--verbose", "Print detailed diagnostics").action(async (options) => {
|
|
9
|
+
const runOptions = toRunOptions(options);
|
|
10
|
+
if (options.write) {
|
|
11
|
+
const result2 = await fix({ ...runOptions, write: true });
|
|
12
|
+
printFixResult(result2, options.verbose ?? false);
|
|
13
|
+
process.exitCode = result2.conflicts.length > 0 ? 1 : 0;
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const result = await check(runOptions);
|
|
17
|
+
printCheckResult(result, options.verbose ?? false);
|
|
18
|
+
process.exitCode = result.ok ? 0 : 1;
|
|
19
|
+
});
|
|
20
|
+
program.command("fix").description("Fix files in place.").option("--cwd <path>", "Working directory").option("--config <path>", "Path to cleanwind config").option("--write", "Write fixes", true).option("--check", "Preview fixes without writing").option("--verbose", "Print detailed diagnostics").option("--staged", "Only fix staged files").action(async (options) => {
|
|
21
|
+
const result = await fix({
|
|
22
|
+
...toRunOptions(options),
|
|
23
|
+
write: options.check ? false : options.write ?? true,
|
|
24
|
+
staged: options.staged ?? false
|
|
25
|
+
});
|
|
26
|
+
printFixResult(result, options.verbose ?? false);
|
|
27
|
+
process.exitCode = result.conflicts.length > 0 ? 1 : 0;
|
|
28
|
+
});
|
|
29
|
+
await program.parseAsync();
|
|
30
|
+
function toRunOptions(options) {
|
|
31
|
+
const runOptions = {};
|
|
32
|
+
if (options.cwd !== void 0) runOptions.cwd = options.cwd;
|
|
33
|
+
if (options.config !== void 0) runOptions.configPath = options.config;
|
|
34
|
+
if (options.write !== void 0) runOptions.write = options.write;
|
|
35
|
+
if (options.check !== void 0) runOptions.check = options.check;
|
|
36
|
+
if (options.verbose !== void 0) runOptions.verbose = options.verbose;
|
|
37
|
+
if (options.staged !== void 0) runOptions.staged = options.staged;
|
|
38
|
+
return runOptions;
|
|
39
|
+
}
|
|
40
|
+
function printCheckResult(result, verbose) {
|
|
41
|
+
if (result.ok) {
|
|
42
|
+
console.log("cleanwind: all files are clean.");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
console.log(`cleanwind: ${result.changedFiles.length} file(s) need cleanup.`);
|
|
46
|
+
printDiagnostics(result, verbose);
|
|
47
|
+
}
|
|
48
|
+
function printFixResult(result, verbose) {
|
|
49
|
+
const written = result.writtenFiles.length;
|
|
50
|
+
const changed = result.changedFiles.length;
|
|
51
|
+
const mode = written > 0 ? "fixed" : "would change";
|
|
52
|
+
console.log(`cleanwind: ${mode} ${written > 0 ? written : changed} file(s).`);
|
|
53
|
+
printDiagnostics(result, verbose);
|
|
54
|
+
}
|
|
55
|
+
function printDiagnostics(result, verbose) {
|
|
56
|
+
for (const conflict of result.conflicts) {
|
|
57
|
+
console.error(
|
|
58
|
+
`${conflict.file}:${conflict.line} ${conflict.suggestion} (${conflict.conflictingClasses.join(" ")})`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
if (!verbose) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
for (const issue of result.issues) {
|
|
65
|
+
console.error(`${issue.file}:${issue.line} [${issue.kind}] ${issue.message}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cleanwind",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Clean imports and Tailwind CSS class names from the command line.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"cleanwind",
|
|
9
|
+
"tailwind",
|
|
10
|
+
"tailwindcss",
|
|
11
|
+
"imports",
|
|
12
|
+
"formatter",
|
|
13
|
+
"cli",
|
|
14
|
+
"typescript"
|
|
15
|
+
],
|
|
16
|
+
"bin": {
|
|
17
|
+
"cleanwind": "dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsup src/index.ts --format esm --clean && tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
35
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@cleanwind/core": "0.1.0",
|
|
39
|
+
"commander": "^12.1.0"
|
|
40
|
+
}
|
|
41
|
+
}
|