windclutter 0.0.7 → 0.0.9
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.
- checksums.yaml +4 -4
- data/README.md +55 -24
- data/lib/windclutter/analyser.rb +18 -5
- data/lib/windclutter/cli/commands/analysis.rb +38 -5
- data/lib/windclutter/cli/core.rb +6 -1
- data/lib/windclutter/util/collector.rb +6 -0
- data/lib/windclutter/util/file_handler.rb +1 -1
- data/lib/windclutter/util/sorter.rb +5 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8069052276a087b367d01c2fee3032f5f7d9a6a9cbcaa0dda55e2ea19894305
|
4
|
+
data.tar.gz: b461fbcca0426f7e6b2928428259213d90189d17b33146cd669c06ae65308e42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39a82623e50cbc57c4d6aaaf245f1160b3132f5e93114682bc8b6dcbda39044887cac969ea161ac8163458304da7f42645903840a987c72e7f50c67cdff65dcd
|
7
|
+
data.tar.gz: 824112979e6a312c8ef64bd3c696a77686af174466e4e3fd463a08992d7d7974c548b437269a177967e94f8ed533d8237a680bd42009bd3bd9ea147fd4098118
|
data/README.md
CHANGED
@@ -1,64 +1,95 @@
|
|
1
|
-

|
1
|
+
 [](https://badge.fury.io/rb/windclutter)
|
2
2
|
|
3
|
-
|
3
|
+
<div align="center">
|
4
|
+
<h1>WindClutter</h1>
|
5
|
+
<p>De-cluttering your TailwindCSS.</p>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<p align="center">
|
9
|
+
<a href="https://github.com/Xavier-IV/windclutter/wiki">Wiki</a>
|
10
|
+
·
|
11
|
+
<a href="https://github.com/Xavier-IV/windclutter/wiki/Developer">Developer's Guide</a>
|
12
|
+
<br>
|
13
|
+
<br>
|
14
|
+
</p>
|
15
|
+
|
16
|
+
<hr/>
|
17
|
+
|
18
|
+
## Overview
|
19
|
+
|
20
|
+
You created awesome project.
|
21
|
+
|
22
|
+
It's completed.
|
4
23
|
|
5
|
-
|
24
|
+
Your users are happy.
|
6
25
|
|
7
|
-
|
26
|
+
But now you are left with this question:
|
8
27
|
|
9
|
-
|
28
|
+
> All this TailwindCSS clutter...what should I do with it?
|
29
|
+
|
30
|
+
You know what I'm talking about. Due to rapid development, we prefer to put Tailwind classes directly into your divs.
|
31
|
+
|
32
|
+
As time goes, this clutter grows.
|
10
33
|
|
11
34
|
This tool aim to:
|
12
35
|
|
13
36
|
- Provide analysis of your project
|
14
37
|
- Identify common uses of Tailwind class
|
15
|
-
- Cleanup for large
|
38
|
+
- Cleanup for large projects
|
39
|
+
|
40
|
+
Once your project grows and ready for your users, chances are you are left with
|
41
|
+
humongous task of Tailwind CSS cleanup.
|
42
|
+
|
43
|
+
**Roadmap progress**
|
44
|
+
|
45
|
+
- [x] Project identification/init
|
46
|
+
- [x] Single file analysis
|
47
|
+
- [ ] User own class exclusion (if specified)
|
48
|
+
- [ ] Single file de-cluttering
|
49
|
+
- [ ] Full project analysis
|
50
|
+
- [ ] Full project auto de-clutter
|
16
51
|
|
17
|
-
|
18
|
-
humongous task of Tailwind CSS cleanup. I call this "ejected" states.
|
52
|
+
<hr/>
|
19
53
|
|
20
54
|
## Installation
|
21
55
|
|
22
56
|
```bash
|
23
57
|
# requires ruby 2.7 and above
|
24
58
|
$ gem install windclutter
|
59
|
+
|
60
|
+
$ windclutter install
|
25
61
|
```
|
26
62
|
|
27
63
|
## In Action
|
28
64
|
|
29
|
-
```html
|
30
|
-
<div class="my-class border rounded-md px-4 py-2 bg-primary-100">
|
31
|
-
<!-- -->
|
32
|
-
</div>
|
33
65
|
```
|
66
|
+
$ cd your_project
|
34
67
|
|
35
|
-
|
68
|
+
$ windclutter project use <your_project_name>
|
69
|
+
$ windclutter analysis file src/index.html
|
70
|
+
```
|
36
71
|
|
37
72
|
```html
|
38
|
-
<div class="my-class
|
73
|
+
<div class="my-class border rounded-md px-4 py-2 bg-primary-100">
|
39
74
|
<!-- -->
|
40
75
|
</div>
|
41
76
|
```
|
42
77
|
|
43
|
-
We'll cleanup your html files and organize the CSSes. You can then choose what to name them.
|
44
|
-
|
45
|
-
`adkuioqa = .btn`
|
46
78
|
```
|
47
|
-
|
48
|
-
|
49
|
-
</div>
|
79
|
+
# output
|
80
|
+
{"my-class"=>1, "border"=>1, "rounded-md"=>1, "px-4"=>1, "py-2"=>1, "bg-primary-100"=>1}
|
50
81
|
```
|
51
82
|
|
52
|
-
##
|
83
|
+
## Bleeding Edge!
|
53
84
|
|
54
|
-
This is currently in ideation, but
|
85
|
+
This is currently in ideation, but I can't wait to try this even myself.
|
55
86
|
|
56
|
-
I have a lot of
|
87
|
+
I have a lot of TailwindCSS project that needs cleanup 🤯
|
57
88
|
|
58
89
|
## Contributing
|
59
90
|
|
60
91
|
Take a look into:
|
61
|
-
https://github.com/Xavier-IV/windclutter/wiki
|
92
|
+
https://github.com/Xavier-IV/windclutter/wiki
|
62
93
|
|
63
94
|
|
64
95
|
## Great alternative
|
data/lib/windclutter/analyser.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'windclutter/util/collector'
|
3
4
|
require 'windclutter/util/config'
|
5
|
+
require 'windclutter/util/sorter'
|
6
|
+
require 'windclutter/util/file_handler'
|
4
7
|
|
5
8
|
module WindClutter
|
6
9
|
# Analyser for windclutter
|
@@ -21,12 +24,22 @@ module WindClutter
|
|
21
24
|
content.scan(regex).each do |occurrence|
|
22
25
|
cls = occurrence.to_s.match(occurrence_regex)[1].split(' ')
|
23
26
|
|
24
|
-
cls.each
|
25
|
-
total = collections[c].nil? ? 0 : collections[c]
|
26
|
-
collections[c] = total + 1
|
27
|
-
end
|
27
|
+
cls.each { |k| collect(collections, k, 1) }
|
28
28
|
end
|
29
|
-
collections.
|
29
|
+
sorter(collections).to_h
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.traverse(suffix, limit)
|
33
|
+
collection = {}
|
34
|
+
scanned = FileHandler.scanners(suffix)
|
35
|
+
scanned.each do |file|
|
36
|
+
init(File.open(file).read).each { |k, v| collect(collection, k, v) }
|
37
|
+
end
|
38
|
+
|
39
|
+
sorted = sorter(collection)
|
40
|
+
result = limit.positive? ? sorted.first(limit).to_h : sorted.to_h
|
41
|
+
|
42
|
+
[sorted.count, result, scanned.count]
|
30
43
|
end
|
31
44
|
end
|
32
45
|
end
|
@@ -1,8 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'awesome_print'
|
3
4
|
require 'dry/cli'
|
4
5
|
require 'windclutter/analyser'
|
5
6
|
require 'windclutter/util/file_handler'
|
7
|
+
require 'windclutter/util/collector'
|
8
|
+
require 'windclutter/util/sorter'
|
6
9
|
require 'windclutter/cli/commands/project'
|
7
10
|
require 'windclutter/cli/commands/generate'
|
8
11
|
|
@@ -12,17 +15,47 @@ module WindClutter
|
|
12
15
|
module Analysis
|
13
16
|
# Initiate setup for specified project
|
14
17
|
class FilePath < Dry::CLI::Command
|
18
|
+
include WindClutter
|
15
19
|
include WindClutter::Util
|
16
20
|
|
17
21
|
desc 'Perform CSS analysis of the path'
|
18
|
-
argument :
|
22
|
+
argument :file, aliases: ['-f'], required: true, desc: 'Path of your CSS file to be dump.'
|
19
23
|
|
20
|
-
def call(
|
21
|
-
puts "
|
24
|
+
def call(file:, **)
|
25
|
+
return puts "No file found #{file}".red unless File.file?(file)
|
22
26
|
|
23
|
-
|
27
|
+
puts "Analysing #{file}...".yellow
|
28
|
+
|
29
|
+
content = File.open(FileHandler.scan_one(file))
|
24
30
|
puts 'Done!'.green
|
25
|
-
|
31
|
+
ap Analyser.init(content.read)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Perform full traversal analysis
|
36
|
+
class Traverse < Dry::CLI::Command
|
37
|
+
include WindClutter
|
38
|
+
include WindClutter::Util
|
39
|
+
|
40
|
+
desc 'Perform full traversal analysis'
|
41
|
+
|
42
|
+
argument :suffix, aliases: ['-s'], required: true, desc: 'Suffix of all files to be traversed.'
|
43
|
+
|
44
|
+
option :full, type: :boolean, alias: '-f', default: false, desc: 'Print out whole classes.'
|
45
|
+
|
46
|
+
option :collect, type: :integer, alias: '-c', default: 5, desc: 'Specify how many of result to collect.'
|
47
|
+
|
48
|
+
def call(suffix:, **options)
|
49
|
+
full = options.fetch(:full)
|
50
|
+
collect_count = full ? 0 : options.fetch(:collect).to_i
|
51
|
+
puts "Analysing #{suffix}...".yellow
|
52
|
+
|
53
|
+
total, scanned, file_count = Analyser.traverse(suffix, collect_count)
|
54
|
+
puts "Traversed #{file_count} #{suffix} file(s)... 🎉".green
|
55
|
+
ap scanned
|
56
|
+
return unless collect_count.positive? && (total - collect_count).positive?
|
57
|
+
|
58
|
+
puts "...and #{total - collect_count} more".yellow
|
26
59
|
end
|
27
60
|
end
|
28
61
|
end
|
data/lib/windclutter/cli/core.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'dry/cli'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'bundler/setup'
|
4
6
|
require 'windclutter/util/file_handler'
|
5
7
|
require 'windclutter/cli/commands/project'
|
6
8
|
require 'windclutter/cli/commands/generate'
|
@@ -17,7 +19,9 @@ module WindClutter
|
|
17
19
|
desc 'Print version'
|
18
20
|
|
19
21
|
def call(*)
|
20
|
-
|
22
|
+
gemspec = Gem::Specification.load('windclutter.gemspec')
|
23
|
+
|
24
|
+
puts gemspec.version.to_s
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
@@ -70,6 +74,7 @@ module WindClutter
|
|
70
74
|
|
71
75
|
register 'analysis', aliases: %w[a -a] do |prefix|
|
72
76
|
prefix.register 'file', Commands::Analysis::FilePath, aliases: ['-p']
|
77
|
+
prefix.register 'traverse', Commands::Analysis::Traverse, aliases: ['-t']
|
73
78
|
end
|
74
79
|
|
75
80
|
register 'generate', aliases: ['g'] do |prefix|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: windclutter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zafranudin Zafrin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Your buddy to skyrocket your development with TailwindCSS.
|
14
14
|
email: coffee@zafranudin.dev
|
@@ -28,9 +28,11 @@ files:
|
|
28
28
|
- lib/windclutter/cli/commands/project.rb
|
29
29
|
- lib/windclutter/cli/core.rb
|
30
30
|
- lib/windclutter/processor.rb
|
31
|
+
- lib/windclutter/util/collector.rb
|
31
32
|
- lib/windclutter/util/config.rb
|
32
33
|
- lib/windclutter/util/file_handler.rb
|
33
34
|
- lib/windclutter/util/generator.rb
|
35
|
+
- lib/windclutter/util/sorter.rb
|
34
36
|
- test/fixtures/config_fixture.rb
|
35
37
|
- test/test_windclutter.rb
|
36
38
|
- test/windclutter/test_analyser.rb
|