command_deck 0.2.0 → 0.3.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: 2d7607e2931f95aa4dfd89508fce37ab2d9b769c4e5463692d9a6d1a8e420861
4
- data.tar.gz: 8efb1447f274e41cb071524d92e2e718349fe0b90dd32124db4e6daa60fcfb8f
3
+ metadata.gz: 403635cfced62de1e01f415368f926475937db69e83dda253283113d4f76f9cb
4
+ data.tar.gz: edf5c2cc7371c6dd4da4a4a577292db53a821f2345c54631c16340323c20a7e6
5
5
  SHA512:
6
- metadata.gz: ded56cf9f23174bdc5406d70ec1bf66788706708aae8edc84c8af9f87882f6ec6bd728b62c5f511eb9139776822a6a8645d9548b71145920bd6f073c9d3079e6
7
- data.tar.gz: 20bcfcca9de31c7da07fb6b36630bd6dd7b1151cc1eda6c89d45332b55c5ff2a1169a8a774fa57e7128fe034719983d6c1c0f6c86e831fb504682012b5aa9ef9
6
+ metadata.gz: d27d8c3b933ea5069861055644f5db6122fde71de4207ad2fd7c32ff6fbb56110de8c3632983cc0cd387680c6c88d8d65d6ef10ca634ea6904e4d797d533d9bd
7
+ data.tar.gz: 31a9bab9bd5bf4025b292c565c0f04118fc09eb51d3473dabe671b523885966f91374a5c840d4fce710a10132ff3c276cba670ccb8cf4169efcae1107cea30ae
data/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [0.3.0] - 2025-10-10
4
+
5
+ ### Added
6
+
7
+ - **Auto-discovery**: Panels can now be defined in any `command_deck` directory (e.g., `app/command_deck`, `packs/**/command_deck`)
8
+ - **Automatic middleware insertion**: Middleware is now auto-injected when `COMMAND_DECK_ENABLED=true` in development
9
+ - **Flexible namespacing**: Use any namespace that matches your project structure (e.g., `CommandDeck::Panels`, `DevTools::Panels`)
10
+
11
+ ### Changed
12
+
13
+ - **Zero configuration required in application.rb**: No need to manually add autoload paths or middleware
14
+ - Improved documentation with examples for modularized monoliths (packwerk/pack-rails)
15
+ - Recommended gem group changed to `:development, :test` for better Sorbet/Tapioca compatibility
16
+
17
+ ### Migration from 0.2.0
18
+
19
+ **Before (0.2.0):**
20
+
21
+ ```ruby
22
+ # config/application.rb
23
+ config.middleware.insert_after ActionDispatch::DebugExceptions, CommandDeck::Middleware if Rails.env.development?
24
+
25
+ # app/command_deck/panels/global.rb
26
+ module Panels
27
+ class Global < CommandDeck::BasePanel
28
+ # ...
29
+ end
30
+ end
31
+ ```
32
+
33
+ **After (0.3.0):**
34
+
35
+ ```ruby
36
+ # config/application.rb - NO CONFIG NEEDED!
37
+ # Just set COMMAND_DECK_ENABLED=true in your .env
38
+
39
+ # app/command_deck/panels/global.rb
40
+ module CommandDeck::Panels # More descriptive namespace
41
+ class Global < CommandDeck::BasePanel
42
+ # ...
43
+ end
44
+ end
45
+ ```
46
+
3
47
  ## [0.2.0] - 2025-10-09
4
48
 
5
49
  ### Breaking Changes
data/CONTRIBUTING.md CHANGED
@@ -58,6 +58,33 @@ bundle exec rubocop -A
58
58
  - Provide steps to reproduce
59
59
  - Include relevant code samples
60
60
 
61
+ ## Releasing a New Version
62
+
63
+ **Prerequisites:**
64
+
65
+ - Update `lib/command_deck/version.rb` with the new version
66
+ - Update `CHANGELOG.md` with changes
67
+ - Commit all changes
68
+ - Be on the `master` branch with a clean working directory
69
+
70
+ **Release:**
71
+
72
+ ```bash
73
+ bin/release
74
+ ```
75
+
76
+ This script will:
77
+
78
+ 1. Run tests and RuboCop
79
+ 2. Build the gem
80
+ 3. Create a git tag
81
+ 4. Push to GitHub
82
+ 5. Publish to RubyGems
83
+
84
+ **Manual steps after release:**
85
+
86
+ - Create a GitHub release with the CHANGELOG content.
87
+
61
88
  ## Questions?
62
89
 
63
90
  Feel free to open an issue for questions or discussions.
data/README.md CHANGED
@@ -11,8 +11,8 @@ Define panels/tabs/actions with a minimal class-based DSL. Each action can decla
11
11
  Add the gem to your application:
12
12
 
13
13
  ```ruby
14
- # Gemfile (development only recommended)
15
- group :development do
14
+ # Gemfile (development and test recommended for Sorbet/Tapioca)
15
+ group :development, :test do
16
16
  gem 'command_deck'
17
17
  end
18
18
  ```
@@ -21,30 +21,30 @@ Mount the engine:
21
21
 
22
22
  ```ruby
23
23
  # config/routes.rb
24
- mount CommandDeck::Engine => '/command_deck' if Rails.env.development?
24
+ mount CommandDeck::Engine => '/command_deck' if defined?(CommandDeck::Engine)
25
25
  ```
26
26
 
27
- Add middleware to inject the floating panel:
27
+ Enable it in your development environment:
28
28
 
29
- ```ruby
30
- # config/application.rb
31
-
32
- module YourApp
33
- class Application < Rails::Application
34
- # ... other config ...
35
-
36
- config.middleware.insert_after ActionDispatch::DebugExceptions, CommandDeck::Middleware if Rails.env.development?
37
- end
38
- end
29
+ ```bash
30
+ # .env.development.local (or your environment config)
31
+ COMMAND_DECK_ENABLED=true
39
32
  ```
40
33
 
34
+ **That's it!** The gem automatically:
35
+
36
+ - Discovers panel files in `app/command_deck/**/*.rb` and `packs/**/command_deck/**/*.rb`
37
+ - Adds them to autoload paths
38
+ - Inserts middleware when `COMMAND_DECK_ENABLED=true` in development
39
+ - Stays completely inactive in production
40
+
41
41
  ## Define actions
42
42
 
43
- Create panel classes in `app/command_deck/panels/*.rb`:
43
+ Create panel classes anywhere under a `command_deck` directory. Use descriptive namespaces:
44
44
 
45
45
  ```ruby
46
46
  # app/command_deck/panels/utilities.rb
47
- module Panels
47
+ module CommandDeck::Panels
48
48
  class Utilities < CommandDeck::BasePanel
49
49
  panel 'Utilities' do
50
50
  tab 'Demo' do
@@ -76,7 +76,29 @@ module Panels
76
76
  end
77
77
  ```
78
78
 
79
- This creates a panel with a tab and two actions. File path matches constant: `app/command_deck/panels/utilities.rb` → `Panels::Utilities`
79
+ ### For modularized monoliths (packwerk/pack-rails)
80
+
81
+ You can organize panels within your packs:
82
+
83
+ ```ruby
84
+ # packs/dev_tools/command_deck/panels/database.rb
85
+ module DevTools::Panels
86
+ class Database < CommandDeck::BasePanel
87
+ panel 'Database Tools' do
88
+ tab 'Maintenance' do
89
+ action 'Rebuild Cache', key: 'db.rebuild_cache' do
90
+ perform do |_p, _ctx|
91
+ Rails.cache.clear
92
+ { ok: true, message: 'Cache cleared' }
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ ```
100
+
101
+ The gem auto-discovers panels in any `command_deck` directory under your app or packs. Use namespaces that match your project structure.
80
102
 
81
103
  ![Demo](public/img/demo.png)
82
104
 
@@ -3,8 +3,15 @@
3
3
  module CommandDeck
4
4
  # Base class for panel definitions.
5
5
  #
6
- # Example:
7
- # module Panels
6
+ # Panels can be defined anywhere under a `command_deck` directory.
7
+ # The gem will auto-discover panels in:
8
+ # - app/command_deck/**/*.rb
9
+ # - packs/**/command_deck/**/*.rb
10
+ #
11
+ # Use descriptive namespaces that match your project structure.
12
+ #
13
+ # Example in app/command_deck/panels/global.rb:
14
+ # module CommandDeck::Panels
8
15
  # class Global < CommandDeck::BasePanel
9
16
  # panel "Global Tools" do
10
17
  # tab "Update" do
@@ -9,8 +9,9 @@ module CommandDeck
9
9
  isolate_namespace CommandDeck
10
10
 
11
11
  initializer "command_deck.add_autoload_paths", before: :set_autoload_paths do |app|
12
- panels_path = Rails.root.join("app/command_deck")
13
- app.config.autoload_paths << panels_path.to_s if panels_path.exist?
12
+ discover_panel_paths.each do |path|
13
+ app.config.autoload_paths << path.to_s unless app.config.autoload_paths.include?(path.to_s)
14
+ end
14
15
  end
15
16
 
16
17
  initializer "command_deck.mount_point" do
@@ -22,20 +23,43 @@ module CommandDeck
22
23
  CommandDeck::Middleware.mount_point = mp
23
24
  end
24
25
 
26
+ initializer "command_deck.middleware", after: :load_config_initializers do |app|
27
+ next unless Rails.env.development?
28
+ next unless ENV.fetch("COMMAND_DECK_ENABLED", "false") == "true"
29
+
30
+ unless app.config.middleware.include?(CommandDeck::Middleware)
31
+ app.config.middleware.insert_after(
32
+ ActionDispatch::DebugExceptions,
33
+ CommandDeck::Middleware
34
+ )
35
+ end
36
+ end
37
+
25
38
  config.to_prepare do
26
39
  next unless Rails.env.development?
27
40
 
28
41
  CommandDeck::Registry.clear!
42
+ CommandDeck.register_all_panels!
43
+ end
44
+
45
+ class << self
46
+ private
29
47
 
30
- if defined?(Panels)
31
- Panels.constants.each do |const_name|
32
- Panels.const_get(const_name)
33
- rescue NameError => e
34
- Rails.logger.warn "[CommandDeck] Could not load panel: #{e.message}"
35
- end
48
+ def discover_panel_paths
49
+ [discover_app_panels, discover_pack_panels].flatten.compact.uniq
36
50
  end
37
51
 
38
- CommandDeck.register_all_panels!
52
+ def discover_app_panels
53
+ path = Rails.root.join("app/command_deck")
54
+ path if path.exist?
55
+ end
56
+
57
+ def discover_pack_panels
58
+ packs_path = Rails.root.join("packs")
59
+ return [] unless packs_path.exist?
60
+
61
+ Dir.glob(packs_path.join("**/command_deck")).select { |dir| Pathname.new(dir).directory? }
62
+ end
39
63
  end
40
64
  end
41
65
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommandDeck
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_deck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - crowrojas