@ui-entropy/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/LICENSE +6 -0
- package/README.md +206 -0
- package/README.old.md +138 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +31 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/scan.d.ts +13 -0
- package/dist/commands/scan.d.ts.map +1 -0
- package/dist/commands/scan.js +86 -0
- package/dist/commands/scan.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# @ui-entropy/cli
|
|
2
|
+
|
|
3
|
+
> Professional CSS waste detection for modern teams. Find unused classes, reduce bundle sizes, and keep your stylesheets clean.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@ui-entropy/cli)
|
|
6
|
+
[](https://uientropy.com/license)
|
|
7
|
+
|
|
8
|
+
## ๐ฏ What is UI Entropy?
|
|
9
|
+
|
|
10
|
+
UI Entropy is a **professional developer tool** that scans your codebase to identify unused CSS. Think of it as **SonarQube for your UI** - helping teams maintain code quality, reduce technical debt, and optimize bundle sizes.
|
|
11
|
+
|
|
12
|
+
**What you get:**
|
|
13
|
+
- ๐ **Reduce bundle sizes** by removing dead CSS
|
|
14
|
+
- ๐งน **Keep stylesheets clean** and maintainable
|
|
15
|
+
- ๐ **Track CSS waste** over time
|
|
16
|
+
- โ
**Prevent waste** in CI/CD pipelines
|
|
17
|
+
- ๐ **Team dashboards** _(coming soon)_ - Monitor trends across projects
|
|
18
|
+
|
|
19
|
+
## ๐ฆ Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Install globally
|
|
23
|
+
npm install -g @ui-entropy/cli
|
|
24
|
+
|
|
25
|
+
# Or use with npx
|
|
26
|
+
npx @ui-entropy/cli scan
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## ๐ Quick Start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Scan current directory
|
|
33
|
+
ui-entropy scan
|
|
34
|
+
|
|
35
|
+
# Scan specific project
|
|
36
|
+
ui-entropy scan /path/to/project
|
|
37
|
+
|
|
38
|
+
# Get JSON output
|
|
39
|
+
ui-entropy scan --format json
|
|
40
|
+
|
|
41
|
+
# Set waste threshold for CI
|
|
42
|
+
ui-entropy scan --threshold 50 # Fails if waste > 50%
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## ๐ Example Output
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
๐ Scanning for CSS waste...
|
|
49
|
+
โ Found 3 stylesheets (45.2 KB)
|
|
50
|
+
โ Scanned 89 source files
|
|
51
|
+
|
|
52
|
+
๐ UI Entropy Analysis Report
|
|
53
|
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
54
|
+
|
|
55
|
+
๐ Summary
|
|
56
|
+
Total CSS Size: 45.2 KB
|
|
57
|
+
Total Rules: 1,247
|
|
58
|
+
Files Scanned: 89
|
|
59
|
+
|
|
60
|
+
๐ฏ Selectors
|
|
61
|
+
Total Selectors: 1,247
|
|
62
|
+
Used Selectors: 329 (26%)
|
|
63
|
+
Unused Selectors: 918
|
|
64
|
+
|
|
65
|
+
๐ฐ CSS Waste Analysis
|
|
66
|
+
Waste Percentage: 73.6%
|
|
67
|
+
Estimated Wasted Bytes: 33.3 KB
|
|
68
|
+
|
|
69
|
+
๐จ Top Unused Classes
|
|
70
|
+
1. .navbar-expand-lg
|
|
71
|
+
2. .btn-outline-secondary
|
|
72
|
+
3. .card-footer
|
|
73
|
+
...
|
|
74
|
+
|
|
75
|
+
๐ก CRITICAL WASTE: Significant cleanup needed.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## ๐ ๏ธ CLI Options
|
|
79
|
+
|
|
80
|
+
| Option | Description | Default |
|
|
81
|
+
|--------|-------------|---------|
|
|
82
|
+
| `--format <type>` | Output format: `text`, `json`, `summary` | `text` |
|
|
83
|
+
| `--output <file>` | Save results to file | _(stdout)_ |
|
|
84
|
+
| `--threshold <number>` | Max waste % (exits 1 if exceeded) | _none_ |
|
|
85
|
+
| `--css <pattern>` | CSS file glob pattern | `**/*.css` |
|
|
86
|
+
| `--source <pattern>` | Source file glob pattern | `**/*.{html,js,jsx,ts,tsx,vue}` |
|
|
87
|
+
| `--ignore <pattern>` | Additional ignore patterns | _none_ |
|
|
88
|
+
| `--config <file>` | Config file path | `.ui-entropy.json` |
|
|
89
|
+
|
|
90
|
+
## โ๏ธ Configuration
|
|
91
|
+
|
|
92
|
+
Create `.ui-entropy.json` in your project root:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"cssPattern": "**/*.css",
|
|
97
|
+
"sourcePattern": "**/*.{html,jsx,tsx,vue}",
|
|
98
|
+
"ignorePatterns": [
|
|
99
|
+
"**/*.test.*",
|
|
100
|
+
"storybook/**"
|
|
101
|
+
],
|
|
102
|
+
"threshold": 50
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## ๐ CI/CD Integration
|
|
107
|
+
|
|
108
|
+
### GitHub Actions
|
|
109
|
+
|
|
110
|
+
```yaml
|
|
111
|
+
name: CSS Waste Check
|
|
112
|
+
on: [push, pull_request]
|
|
113
|
+
|
|
114
|
+
jobs:
|
|
115
|
+
ui-entropy:
|
|
116
|
+
runs-on: ubuntu-latest
|
|
117
|
+
steps:
|
|
118
|
+
- uses: actions/checkout@v3
|
|
119
|
+
- uses: actions/setup-node@v3
|
|
120
|
+
- run: npm install -g ui-entropy
|
|
121
|
+
- run: ui-entropy scan --threshold 50 --format summary
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### GitLab CI
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
ui-entropy:
|
|
128
|
+
image: node:20
|
|
129
|
+
script:
|
|
130
|
+
- npm install -g ui-entropy
|
|
131
|
+
- ui-entropy scan --threshold 50 --format summary
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Pre-commit Hook
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{
|
|
138
|
+
"husky": {
|
|
139
|
+
"hooks": {
|
|
140
|
+
"pre-commit": "ui-entropy scan --threshold 50 --format summary"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## ๐ Real-World Results
|
|
147
|
+
|
|
148
|
+
| Project | CSS Size | Waste % | Potential Savings |
|
|
149
|
+
|---------|----------|---------|-------------------|
|
|
150
|
+
| E-commerce Site | 180 KB | 91% | **164 KB** |
|
|
151
|
+
| Marketing Site | 45 KB | 72% | **32 KB** |
|
|
152
|
+
| React Dashboard | 89 KB | 38% | **34 KB** |
|
|
153
|
+
|
|
154
|
+
## ๐บ๏ธ Roadmap
|
|
155
|
+
|
|
156
|
+
**Available Now:**
|
|
157
|
+
- โ
CLI tool for local development
|
|
158
|
+
- โ
GitHub Actions integration
|
|
159
|
+
|
|
160
|
+
**Coming Soon:**
|
|
161
|
+
- ๐ Team dashboard with historical analytics
|
|
162
|
+
- ๐ Multi-project portfolio views
|
|
163
|
+
- ๐ Advanced insights and reporting
|
|
164
|
+
- ๐ Slack/email alerts for waste spikes
|
|
165
|
+
- ๐ Enterprise features and SSO
|
|
166
|
+
|
|
167
|
+
## ๐ก Use Cases
|
|
168
|
+
|
|
169
|
+
- **Before Deployment** - Verify you're not shipping unnecessary CSS
|
|
170
|
+
- **During Refactoring** - Safely identify removable styles
|
|
171
|
+
- **Code Reviews** - Catch CSS bloat in PRs
|
|
172
|
+
- **Performance Audits** - Quick wins for bundle size reduction
|
|
173
|
+
- **Technical Debt** - Quantify and track stylesheet cleanup
|
|
174
|
+
|
|
175
|
+
## ๐ Related Packages
|
|
176
|
+
|
|
177
|
+
- **[@ui-entropy/scanner-core](https://npmjs.com/package/@ui-entropy/scanner-core)** - Programmatic API
|
|
178
|
+
- **UI Entropy Dashboard** _(coming soon)_ - Team analytics platform
|
|
179
|
+
|
|
180
|
+
## ๐ Documentation
|
|
181
|
+
|
|
182
|
+
- [Full Documentation](https://uientropy.com/docs)
|
|
183
|
+
- [API Reference](https://uientropy.com/docs/api)
|
|
184
|
+
- [Configuration Guide](https://uientropy.com/docs/config)
|
|
185
|
+
- [Best Practices](https://uientropy.com/docs/best-practices)
|
|
186
|
+
|
|
187
|
+
## ๐ License
|
|
188
|
+
|
|
189
|
+
Proprietary - See [LICENSE](./LICENSE) file.
|
|
190
|
+
Free tier available. Pro/Team subscriptions for advanced features.
|
|
191
|
+
|
|
192
|
+
## ๐ฌ Support
|
|
193
|
+
|
|
194
|
+
**For CLI usage questions:**
|
|
195
|
+
- ๐ [Documentation](https://uientropy.com/docs)
|
|
196
|
+
- ๐ [Report Issues](https://github.com/ui-entropy/ui-entropy/issues)
|
|
197
|
+
|
|
198
|
+
**For commercial inquiries:**
|
|
199
|
+
- Dashboard beta access
|
|
200
|
+
- Enterprise features
|
|
201
|
+
- Custom integrations
|
|
202
|
+
- Contact: [hello@uientropy.com](mailto:hello@uientropy.com)
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
Built with โค๏ธ and TypeScript for professional development teams.
|
package/README.old.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# UI Entropy CLI
|
|
2
|
+
|
|
3
|
+
A command-line tool for detecting CSS waste in your projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @ui-entropy/cli
|
|
9
|
+
# or
|
|
10
|
+
pnpm add -g @ui-entropy/cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Basic Scan
|
|
16
|
+
|
|
17
|
+
Scan the current directory:
|
|
18
|
+
```bash
|
|
19
|
+
ui-entropy scan
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Scan a specific directory:
|
|
23
|
+
```bash
|
|
24
|
+
ui-entropy scan /path/to/project
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Output Formats
|
|
28
|
+
|
|
29
|
+
**Text Report** (default):
|
|
30
|
+
```bash
|
|
31
|
+
ui-entropy scan --format text
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**JSON Report**:
|
|
35
|
+
```bash
|
|
36
|
+
ui-entropy scan --format json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Summary**:
|
|
40
|
+
```bash
|
|
41
|
+
ui-entropy scan --format summary
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Save Report to File
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
ui-entropy scan --output report.json --format json
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Threshold Check (for CI/CD)
|
|
51
|
+
|
|
52
|
+
Fail if waste exceeds a threshold:
|
|
53
|
+
```bash
|
|
54
|
+
ui-entropy scan --threshold 30
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Exit code will be 1 if waste exceeds 30%.
|
|
58
|
+
|
|
59
|
+
### Custom Patterns
|
|
60
|
+
|
|
61
|
+
Specify custom CSS and source file patterns:
|
|
62
|
+
```bash
|
|
63
|
+
ui-entropy scan \
|
|
64
|
+
--css "**/*.css" "dist/**/*.css" \
|
|
65
|
+
--source "src/**/*.{js,jsx,ts,tsx}" \
|
|
66
|
+
--ignore "node_modules/**" "dist/**"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Configuration File
|
|
70
|
+
|
|
71
|
+
Use a configuration file:
|
|
72
|
+
```bash
|
|
73
|
+
ui-entropy scan --config .ui-entropy.json
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Example `.ui-entropy.json`:
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"cssPatterns": [
|
|
80
|
+
"**/*.css",
|
|
81
|
+
".next/static/css/**/*.css"
|
|
82
|
+
],
|
|
83
|
+
"sourcePatterns": [
|
|
84
|
+
"src/**/*.{js,jsx,ts,tsx}",
|
|
85
|
+
"app/**/*.{js,jsx,ts,tsx}"
|
|
86
|
+
],
|
|
87
|
+
"ignorePatterns": [
|
|
88
|
+
"node_modules/**",
|
|
89
|
+
"dist/**",
|
|
90
|
+
".next/**"
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Options
|
|
96
|
+
|
|
97
|
+
- `-f, --format <format>` - Output format (text, json, summary)
|
|
98
|
+
- `-o, --output <file>` - Save report to file
|
|
99
|
+
- `-c, --config <path>` - Path to config file
|
|
100
|
+
- `--threshold <number>` - Fail if waste exceeds threshold (%)
|
|
101
|
+
- `--css <patterns...>` - CSS file patterns
|
|
102
|
+
- `--source <patterns...>` - Source file patterns
|
|
103
|
+
- `--ignore <patterns...>` - Ignore patterns
|
|
104
|
+
- `--no-color` - Disable colored output
|
|
105
|
+
|
|
106
|
+
## Examples
|
|
107
|
+
|
|
108
|
+
### CI/CD Integration
|
|
109
|
+
|
|
110
|
+
GitHub Actions:
|
|
111
|
+
```yaml
|
|
112
|
+
- name: Check CSS Waste
|
|
113
|
+
run: |
|
|
114
|
+
npx @ui-entropy/cli scan --threshold 40 --format summary
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
GitLab CI:
|
|
118
|
+
```yaml
|
|
119
|
+
css-waste:
|
|
120
|
+
script:
|
|
121
|
+
- npx @ui-entropy/cli scan --threshold 40 --format summary
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Pre-commit Hook
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"husky": {
|
|
129
|
+
"hooks": {
|
|
130
|
+
"pre-commit": "ui-entropy scan --threshold 50 --format summary"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { scanCommand } from './commands/scan.js';
|
|
4
|
+
import { version } from './version.js';
|
|
5
|
+
const program = new Command();
|
|
6
|
+
program
|
|
7
|
+
.name('ui-entropy')
|
|
8
|
+
.description('Detect CSS waste in your projects')
|
|
9
|
+
.version(version);
|
|
10
|
+
// Scan command
|
|
11
|
+
program
|
|
12
|
+
.command('scan')
|
|
13
|
+
.description('Scan a project for CSS waste')
|
|
14
|
+
.argument('[directory]', 'Directory to scan', process.cwd())
|
|
15
|
+
.option('-f, --format <format>', 'Output format (text, json, summary)', 'text')
|
|
16
|
+
.option('-o, --output <file>', 'Save report to file')
|
|
17
|
+
.option('-c, --config <path>', 'Path to config file')
|
|
18
|
+
.option('--threshold <number>', 'Fail if waste exceeds threshold (%)', parseFloat)
|
|
19
|
+
.option('--css <patterns...>', 'CSS file patterns')
|
|
20
|
+
.option('--source <patterns...>', 'Source file patterns')
|
|
21
|
+
.option('--ignore <patterns...>', 'Ignore patterns')
|
|
22
|
+
.option('--no-color', 'Disable colored output')
|
|
23
|
+
.action(scanCommand);
|
|
24
|
+
// Default to scan if no command specified
|
|
25
|
+
program
|
|
26
|
+
.arguments('[directory]')
|
|
27
|
+
.action((directory) => {
|
|
28
|
+
scanCommand(directory || process.cwd(), {});
|
|
29
|
+
});
|
|
30
|
+
program.parse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CAAC;AAC9C,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface ScanCommandOptions {
|
|
2
|
+
format?: 'text' | 'json' | 'summary';
|
|
3
|
+
output?: string;
|
|
4
|
+
config?: string;
|
|
5
|
+
threshold?: number;
|
|
6
|
+
css?: string[];
|
|
7
|
+
source?: string[];
|
|
8
|
+
ignore?: string[];
|
|
9
|
+
color?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function scanCommand(directory: string, options: ScanCommandOptions): Promise<void>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AAMA,UAAU,kBAAkB;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,WAAW,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CA8Ff"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { scan } from 'scanner-core';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import { writeFileSync } from 'fs';
|
|
4
|
+
import ora from 'ora';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
export async function scanCommand(directory, options) {
|
|
7
|
+
const absolutePath = resolve(directory);
|
|
8
|
+
// Start spinner
|
|
9
|
+
const spinner = ora({
|
|
10
|
+
text: chalk.cyan('Scanning files...'),
|
|
11
|
+
color: 'cyan',
|
|
12
|
+
}).start();
|
|
13
|
+
try {
|
|
14
|
+
// Prepare scan options
|
|
15
|
+
const scanOptions = {
|
|
16
|
+
baseDir: absolutePath,
|
|
17
|
+
format: options.format || 'text',
|
|
18
|
+
};
|
|
19
|
+
// Add optional overrides
|
|
20
|
+
if (options.css)
|
|
21
|
+
scanOptions.cssPatterns = options.css;
|
|
22
|
+
if (options.source)
|
|
23
|
+
scanOptions.sourcePatterns = options.source;
|
|
24
|
+
if (options.ignore)
|
|
25
|
+
scanOptions.ignorePatterns = options.ignore;
|
|
26
|
+
// Run scan
|
|
27
|
+
const startTime = Date.now();
|
|
28
|
+
const result = scan(scanOptions);
|
|
29
|
+
const duration = Date.now() - startTime;
|
|
30
|
+
spinner.succeed(chalk.green(`Scan completed in ${duration}ms`));
|
|
31
|
+
// Display results
|
|
32
|
+
console.log('');
|
|
33
|
+
console.log(chalk.bold('๐ Project:'), absolutePath);
|
|
34
|
+
console.log(chalk.bold('๐ Files:'), `${result.files.cssFiles} CSS, ${result.files.sourceFiles} source`);
|
|
35
|
+
// Show warnings if any
|
|
36
|
+
if (result.warnings.length > 0) {
|
|
37
|
+
console.log('');
|
|
38
|
+
console.log(chalk.yellow(`โ ๏ธ ${result.warnings.length} warning(s):`));
|
|
39
|
+
result.warnings.forEach((warning, i) => {
|
|
40
|
+
console.log(chalk.yellow(` ${i + 1}. ${warning.file || 'Unknown file'}`));
|
|
41
|
+
console.log(chalk.gray(` ${warning.message}`));
|
|
42
|
+
if (warning.line) {
|
|
43
|
+
console.log(chalk.gray(` Line ${warning.line}:${warning.column || 0}`));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
console.log('');
|
|
48
|
+
console.log(result.report);
|
|
49
|
+
// Save to file if requested
|
|
50
|
+
if (options.output) {
|
|
51
|
+
writeFileSync(options.output, result.report);
|
|
52
|
+
console.log('');
|
|
53
|
+
console.log(chalk.green('โ'), `Report saved to ${options.output}`);
|
|
54
|
+
}
|
|
55
|
+
// Check threshold
|
|
56
|
+
if (options.threshold !== undefined) {
|
|
57
|
+
const wastePercent = result.analysis.wastePercentage;
|
|
58
|
+
if (wastePercent > options.threshold) {
|
|
59
|
+
console.log('');
|
|
60
|
+
console.log(chalk.red('โ'), `Waste ${wastePercent}% exceeds threshold ${options.threshold}%`);
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
console.log('');
|
|
65
|
+
console.log(chalk.green('โ'), `Waste ${wastePercent}% is below threshold ${options.threshold}%`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
spinner.fail(chalk.red('Scan failed'));
|
|
72
|
+
console.error('');
|
|
73
|
+
console.error(chalk.red('Error:'), error instanceof Error ? error.message : 'Unknown error');
|
|
74
|
+
if (error instanceof Error && error.stack) {
|
|
75
|
+
console.error(chalk.gray(error.stack));
|
|
76
|
+
}
|
|
77
|
+
console.error('');
|
|
78
|
+
console.error(chalk.yellow('Troubleshooting:'));
|
|
79
|
+
console.error(chalk.gray(' โข Make sure the directory contains CSS and source files'));
|
|
80
|
+
console.error(chalk.gray(' โข Check that file patterns match your project structure'));
|
|
81
|
+
console.error(chalk.gray(' โข Try creating a .ui-entropy.json config file'));
|
|
82
|
+
console.error('');
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../src/commands/scan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoB,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,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CAAC;YAC1C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAChD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC,CAAC;QACvF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC,CAAC;QACvF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC,CAAC;QAC7E,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAElB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ui-entropy/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Professional CSS waste detection for modern teams - CLI tool",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"ui-entropy": "./dist/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"test:watch": "vitest",
|
|
15
|
+
"type-check": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"css",
|
|
19
|
+
"waste",
|
|
20
|
+
"unused",
|
|
21
|
+
"optimization",
|
|
22
|
+
"cli",
|
|
23
|
+
"bundle-size",
|
|
24
|
+
"tailwind",
|
|
25
|
+
"css-analysis"
|
|
26
|
+
],
|
|
27
|
+
"author": "UI Entropy",
|
|
28
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
29
|
+
"homepage": "https://uientropy.com",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/ui-entropy/ui-entropy.git",
|
|
33
|
+
"directory": "packages/cli"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/ui-entropy/ui-entropy/issues"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@ui-entropy/scanner-core": "^0.1.0",
|
|
45
|
+
"chalk": "^5.3.0",
|
|
46
|
+
"commander": "^12.1.0",
|
|
47
|
+
"ora": "^8.1.1"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^25.2.3",
|
|
51
|
+
"typescript": "^5.9.3",
|
|
52
|
+
"vitest": "^4.0.18"
|
|
53
|
+
},
|
|
54
|
+
"packageManager": "pnpm@10.30.0"
|
|
55
|
+
}
|