stimulus-audit 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -2
- data/README.md +4 -4
- data/lib/stimulus_audit/auditor.rb +5 -3
- data/lib/stimulus_audit/configuration.rb +4 -4
- data/lib/stimulus_audit/railtie.rb +4 -0
- data/lib/stimulus_audit/version.rb +1 -1
- data/lib/stimulus_audit.rb +8 -7
- data/lib/tasks/stimulus_audit.rake +4 -4
- metadata +37 -11
- data/.rubocop.yml +0 -13
- data/Rakefile +0 -12
- data/sig/stimulus_audit.rbs +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dca7ccc3e9aa70d2569f5dac251cd6ffb735904a26a5ae47d08acb0795f31f74
|
4
|
+
data.tar.gz: b11fe5d83255fc3ae5951953e7b7c15c3420c2ed134d5d499bd32de4db17a632
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01a291f6c08a66ec9a1e3f08b6fc4ed8995cccd1a171fbbbf70f935eb08d5dc097d0641082eb2156052fe0ccfd86e45f0198ec545c19f213c9f820798f79a6af
|
7
|
+
data.tar.gz: a8250cd99d2edaf96b2a89f0dcbbe64d21e8c47707e9e72a3f506f932665e6c7061ccd14a5b9cc2a3782e0848ea607b66904f3639233eca80383ca2b78a7ad6c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
2
3
|
|
3
|
-
## [0.
|
4
|
+
## [0.2.0] - 2024-03-11
|
5
|
+
### Changed
|
6
|
+
- Renamed rake tasks to avoid conflicts with stimulus-rails
|
7
|
+
- stimulus:audit is now audit:stimulus
|
8
|
+
- stimulus:scan is now audit:scan
|
4
9
|
|
10
|
+
### Fixed
|
11
|
+
- Fixed gem auto-loading in Rails applications
|
12
|
+
|
13
|
+
## [0.1.1] - 2024-03-11
|
14
|
+
### Fixed
|
15
|
+
- Fixed controller name handling to support underscore to hyphen conversion
|
16
|
+
- Added proper Rails integration via Railtie
|
17
|
+
- Cleaned up gem dependencies
|
18
|
+
|
19
|
+
## [0.1.0] - 2024-03-11
|
20
|
+
### Added
|
5
21
|
- Initial release
|
22
|
+
- Basic controller scanning functionality
|
23
|
+
- Controller usage audit capabilities
|
24
|
+
- Support for namespaced controllers
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ bundle install
|
|
22
22
|
Run an audit to see all defined and used controllers in your application:
|
23
23
|
|
24
24
|
```bash
|
25
|
-
rails stimulus
|
25
|
+
rails audit:stimulus
|
26
26
|
```
|
27
27
|
|
28
28
|
This will show:
|
@@ -56,13 +56,13 @@ Example output:
|
|
56
56
|
Find all uses of a specific controller:
|
57
57
|
|
58
58
|
```bash
|
59
|
-
rails
|
59
|
+
rails audit:scan[controller_name]
|
60
60
|
```
|
61
61
|
|
62
62
|
Example:
|
63
63
|
```bash
|
64
|
-
rails
|
65
|
-
rails
|
64
|
+
rails audit:scan[products]
|
65
|
+
rails audit:scan[users--name] # For namespaced controllers
|
66
66
|
```
|
67
67
|
|
68
68
|
### Configuration
|
@@ -34,8 +34,8 @@ module StimulusAudit
|
|
34
34
|
controller_path = full_path.each_filename.to_a[(controllers_dir + 1)..]
|
35
35
|
# Remove _controller.js from the last component
|
36
36
|
controller_path[-1] = controller_path[-1].sub(/_controller\.(js|ts)$/, "")
|
37
|
-
# Join with -- for namespacing
|
38
|
-
name = controller_path.join("--")
|
37
|
+
# Join with -- for namespacing and convert underscores to hyphens
|
38
|
+
name = controller_path.join("--").gsub("_", "-")
|
39
39
|
controllers << name
|
40
40
|
end
|
41
41
|
end
|
@@ -54,8 +54,10 @@ module StimulusAudit
|
|
54
54
|
content = File.read(file)
|
55
55
|
patterns.each do |pattern|
|
56
56
|
content.scan(pattern) do |match|
|
57
|
-
# Split in case of multiple controllers
|
57
|
+
# Split in case of multiple controllers
|
58
58
|
match[0].split(/\s+/).each do |controller|
|
59
|
+
# Store controller names exactly as they appear in the view
|
60
|
+
# (they should already have hyphens as per Stimulus conventions)
|
59
61
|
controllers << controller
|
60
62
|
end
|
61
63
|
end
|
@@ -12,13 +12,13 @@ module StimulusAudit
|
|
12
12
|
base_path = StimulusAudit.root
|
13
13
|
|
14
14
|
@view_paths = [
|
15
|
-
base_path.join(
|
16
|
-
base_path.join(
|
17
|
-
base_path.join(
|
15
|
+
base_path.join("app/views/**/*.{html,erb,haml}").to_s,
|
16
|
+
base_path.join("app/javascript/**/*.{js,jsx}").to_s,
|
17
|
+
base_path.join("app/components/**/*.{html,erb,haml,rb}").to_s
|
18
18
|
]
|
19
19
|
|
20
20
|
@controller_paths = [
|
21
|
-
base_path.join(
|
21
|
+
base_path.join("app/javascript/controllers/**/*.{js,ts}").to_s
|
22
22
|
]
|
23
23
|
end
|
24
24
|
end
|
data/lib/stimulus_audit.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
require "set"
|
4
|
+
require "pathname"
|
5
|
+
require_relative "stimulus_audit/version"
|
6
|
+
require_relative "stimulus_audit/configuration"
|
7
|
+
require_relative "stimulus_audit/auditor"
|
8
|
+
require_relative "stimulus_audit/scanner"
|
9
9
|
|
10
10
|
if defined?(Rails)
|
11
11
|
require "rails"
|
12
|
-
require
|
12
|
+
require 'stimulus_audit'
|
13
|
+
require "stimulus_audit/railtie"
|
13
14
|
end
|
14
15
|
|
15
16
|
module StimulusAudit
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
namespace :
|
3
|
+
namespace :audit do
|
4
4
|
desc "Audit Stimulus controllers usage and find orphaned controllers"
|
5
|
-
task
|
5
|
+
task stimulus: :environment do
|
6
6
|
StimulusAudit::Auditor.new.audit.to_console
|
7
7
|
end
|
8
8
|
|
9
|
-
desc "Scan files for stimulus controller usage (e.g., rake
|
9
|
+
desc "Scan files for stimulus controller usage (e.g., rake audit:scan[products])"
|
10
10
|
task :scan, [:controller] => :environment do |_, args|
|
11
11
|
controller = args[:controller]
|
12
12
|
if controller.nil? || controller.empty?
|
13
|
-
puts "Please provide a controller name: rake
|
13
|
+
puts "Please provide a controller name: rake audit:scan[controller_name]"
|
14
14
|
next
|
15
15
|
end
|
16
16
|
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stimulus-audit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Your Name
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2024-12-11 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '13.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '13.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
13
41
|
description: A Ruby gem to analyze usage of Stimulus controllers, finding unused controllers
|
14
42
|
and undefined controllers
|
15
43
|
email:
|
@@ -18,11 +46,9 @@ executables: []
|
|
18
46
|
extensions: []
|
19
47
|
extra_rdoc_files: []
|
20
48
|
files:
|
21
|
-
- ".rubocop.yml"
|
22
49
|
- CHANGELOG.md
|
23
50
|
- LICENSE.txt
|
24
51
|
- README.md
|
25
|
-
- Rakefile
|
26
52
|
- lib/stimulus_audit.rb
|
27
53
|
- lib/stimulus_audit/auditor.rb
|
28
54
|
- lib/stimulus_audit/configuration.rb
|
@@ -30,14 +56,14 @@ files:
|
|
30
56
|
- lib/stimulus_audit/scanner.rb
|
31
57
|
- lib/stimulus_audit/version.rb
|
32
58
|
- lib/tasks/stimulus_audit.rake
|
33
|
-
|
34
|
-
homepage: https://github.com/yourusername/stimulus-audit
|
59
|
+
homepage: https://github.com/tobyond/stimulus-audit
|
35
60
|
licenses:
|
36
61
|
- MIT
|
37
62
|
metadata:
|
38
|
-
homepage_uri: https://github.com/
|
39
|
-
|
40
|
-
|
63
|
+
homepage_uri: https://github.com/tobyond/stimulus-audit
|
64
|
+
changelog_uri: https://github.com/tobyond/stimulus-audit/blob/main/CHANGELOG.md
|
65
|
+
source_code_uri: https://github.com/tobyond/stimulus-audit
|
66
|
+
bug_tracker_uri: https://github.com/tobyond/stimulus-audit/issues
|
41
67
|
post_install_message:
|
42
68
|
rdoc_options: []
|
43
69
|
require_paths:
|
data/.rubocop.yml
DELETED
data/Rakefile
DELETED
data/sig/stimulus_audit.rbs
DELETED