stimulus-audit 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d97ee4d76118febf8f6d72f4434bdcef35e925dd5871bbc624bfb221e0cd0fd3
4
- data.tar.gz: a54d0519141cced0080073a8713ae0d923e0452b0203817543cc1b99ed95c44d
3
+ metadata.gz: dca7ccc3e9aa70d2569f5dac251cd6ffb735904a26a5ae47d08acb0795f31f74
4
+ data.tar.gz: b11fe5d83255fc3ae5951953e7b7c15c3420c2ed134d5d499bd32de4db17a632
5
5
  SHA512:
6
- metadata.gz: '0458a1420dfd0419ceefe18b4a70e8ba676690c99e700b21a594cedf7d397f41ac884555233fb6bf6dccf9e13bfc48f7f7f54b3dcd5cb30badb71ce387f42b89'
7
- data.tar.gz: 67e254902d28bdf8abfa7d268cc6f603ffe6893420c7fab4652d9eed3b2cac0c5cd8899cf0387da938b25fb007db7fff8068f70215b7a4164da4d1108222a459
6
+ metadata.gz: 01a291f6c08a66ec9a1e3f08b6fc4ed8995cccd1a171fbbbf70f935eb08d5dc097d0641082eb2156052fe0ccfd86e45f0198ec545c19f213c9f820798f79a6af
7
+ data.tar.gz: a8250cd99d2edaf96b2a89f0dcbbe64d21e8c47707e9e72a3f506f932665e6c7061ccd14a5b9cc2a3782e0848ea607b66904f3639233eca80383ca2b78a7ad6c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
- ## [Unreleased]
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
2
3
 
3
- ## [0.1.0] - 2024-12-11
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:audit
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 stimulus:scan[controller_name]
59
+ rails audit:scan[controller_name]
60
60
  ```
61
61
 
62
62
  Example:
63
63
  ```bash
64
- rails stimulus:scan[products]
65
- rails stimulus:scan[users--name] # For namespaced controllers
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: "users--name list toggle"
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('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
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('app/javascript/controllers/**/*.{js,ts}').to_s
21
+ base_path.join("app/javascript/controllers/**/*.{js,ts}").to_s
22
22
  ]
23
23
  end
24
24
  end
@@ -5,5 +5,9 @@ module StimulusAudit
5
5
  rake_tasks do
6
6
  load "tasks/stimulus_audit.rake"
7
7
  end
8
+
9
+ initializer "stimulus-audit.setup" do
10
+ require "stimulus_audit"
11
+ end
8
12
  end
9
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StimulusAudit
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -1,15 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'set'
4
- require 'pathname'
5
- require "stimulus_audit/version"
6
- require "stimulus_audit/configuration"
7
- require "stimulus_audit/auditor"
8
- require "stimulus_audit/scanner"
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 "stimulus_audit/railtie"
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 :stimulus do
3
+ namespace :audit do
4
4
  desc "Audit Stimulus controllers usage and find orphaned controllers"
5
- task audit: :environment do
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 stimulus:scan[users--name])"
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 stimulus:scan[controller_name]"
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Toby
7
+ - Your Name
8
8
  autorequire:
9
- bindir: exe
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
- - sig/stimulus_audit.rbs
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/yourusername/stimulus-audit
39
- source_code_uri: https://github.com/yourusername/stimulus-audit
40
- allowed_push_host: https://rubygems.org
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
@@ -1,13 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.6
3
-
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
7
-
8
- Style/StringLiteralsInInterpolation:
9
- Enabled: true
10
- EnforcedStyle: double_quotes
11
-
12
- Layout/LineLength:
13
- Max: 120
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "minitest/test_task"
5
-
6
- Minitest::TestTask.create
7
-
8
- require "rubocop/rake_task"
9
-
10
- RuboCop::RakeTask.new
11
-
12
- task default: %i[test rubocop]
@@ -1,4 +0,0 @@
1
- module StimulusAudit
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end