forest_admin_rails 1.12.11 → 1.12.12

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: 14239daa21f3456795d8a5f86e379f8290f024a99fea0a9743a4ed9184b577b6
4
- data.tar.gz: 475e7e2ef5c27294e433d8b09ea38c77c29dea40d277bb2785322889095fd94b
3
+ metadata.gz: bdd36d163cb4d1210f6680782fd4338aca9d3c2273fbcfab9ee90cfec91af2b9
4
+ data.tar.gz: 1444cac70cd8990f48df0a80579bf0da629898a9f71a2f4082a8bdd4b19a66d3
5
5
  SHA512:
6
- metadata.gz: 2ba32705f89e4e93e0995c987a389edbcaf2d7efd166ac31589cdc73bdef3189b72828cfba742c86b23807536a803a434d07176cdf768302e0cdea8c4ca832f9
7
- data.tar.gz: e8babcc8148642abd65660b8eca6e83c073d8cf34fb1501f11f99bce839ff77435f43413fb1695f50324a31ecc3ba6d271f73c2299172e64cbca397aa74f3889
6
+ metadata.gz: 84dfe389f748592cc51544ad223f7203da823074bfb5e577c4d49dc96ae2ed3810cc7bc53628a8c0a8a2516e1a0f4557fbe90fda3b504f2710ae5709329e2b96
7
+ data.tar.gz: 74757f2ff05b7c69ba45ef14aa51a60d970a940cc5a033c868305b6195e21054d5b8c37cf399b4406311aeb4c5faa4b49636ef828ccea2a31d28401bfaaa7cc8
@@ -1,31 +1,11 @@
1
+ # Route pre-caching has been moved to engine.rb after agent.build() completes
2
+ #
3
+ # This initializer is kept for informational purposes only
1
4
  if defined?(ForestAdminAgent::Http::Router)
2
5
  cache_disabled = ForestAdminAgent::Http::Router.cache_disabled?
3
6
 
4
7
  if cache_disabled
5
8
  Rails.logger.warn('[ForestAdmin] Route caching is DISABLED - this will impact performance')
6
9
  Rails.logger.warn('[ForestAdmin] To enable caching, remove disable_route_cache: true from configuration')
7
- else
8
- Rails.application.config.after_initialize do
9
- next if defined?(Rake) && Rake.respond_to?(:application) && Rake.application&.top_level_tasks&.any?
10
-
11
- start_time = Time.now
12
- routes = ForestAdminAgent::Http::Router.cached_routes
13
- elapsed = ((Time.now - start_time) * 1000).round(2)
14
-
15
- Rails.logger.info(
16
- "[ForestAdmin] Successfully pre-cached #{routes.size} routes in #{elapsed}ms"
17
- )
18
- rescue StandardError => e
19
- Rails.logger.error(
20
- "[ForestAdmin] CRITICAL: Failed to pre-cache routes: #{e.class} - #{e.message}"
21
- )
22
- Rails.logger.error(e.backtrace.first(10).join("\n"))
23
-
24
- raise e if Rails.env.production?
25
-
26
- Rails.logger.warn(
27
- '[ForestAdmin] Routes will be computed on first request (performance degradation)'
28
- )
29
- end
30
10
  end
31
11
  end
@@ -44,41 +44,64 @@ module ForestAdminRails
44
44
  def load_configuration
45
45
  return unless running_web_server?
46
46
 
47
+ check_create_agent_location
48
+ return unless create_agent_file_exists?
49
+
50
+ # force eager loading models
51
+ Rails.application.eager_load!
52
+
53
+ setup_agent_and_cache_routes
54
+
55
+ sse = ForestAdminAgent::Services::SSECacheInvalidation
56
+ sse.run if ForestAdminRails.config[:instant_cache_refresh]
57
+ end
58
+
59
+ def check_create_agent_location
47
60
  old_path = Rails.root.join('app', 'lib', 'forest_admin_rails', 'create_agent.rb')
48
61
  new_path = Rails.root.join('lib', 'forest_admin_rails', 'create_agent.rb')
49
62
 
50
- # Check for old location and warn user
51
- if File.exist?(old_path) && !File.exist?(new_path)
52
- logger = ActiveSupport::Logger.new($stdout)
53
- logger.warn <<~WARNING
54
- ⚠️ DEPRECATION WARNING: create_agent.rb detected in old location!
63
+ return unless File.exist?(old_path) && !File.exist?(new_path)
55
64
 
56
- The file 'app/lib/forest_admin_rails/create_agent.rb' should now be located at:
57
- 'lib/forest_admin_rails/create_agent.rb'
65
+ logger = ActiveSupport::Logger.new($stdout)
66
+ logger.warn <<~WARNING
67
+ ⚠️ DEPRECATION WARNING: create_agent.rb detected in old location!
58
68
 
59
- Please move your file to the new location:
60
- mkdir -p lib/forest_admin_rails
61
- mv app/lib/forest_admin_rails/create_agent.rb lib/forest_admin_rails/create_agent.rb
69
+ The file 'app/lib/forest_admin_rails/create_agent.rb' should now be located at:
70
+ 'lib/forest_admin_rails/create_agent.rb'
62
71
 
63
- This will become a hard requirement in a future version.
64
- WARNING
65
- end
72
+ Please move your file to the new location:
73
+ mkdir -p lib/forest_admin_rails
74
+ mv app/lib/forest_admin_rails/create_agent.rb lib/forest_admin_rails/create_agent.rb
66
75
 
67
- return unless File.exist?(new_path) || File.exist?(old_path)
76
+ This will become a hard requirement in a future version.
77
+ WARNING
78
+ end
68
79
 
69
- # force eager loading models
70
- Rails.application.eager_load!
80
+ def create_agent_file_exists?
81
+ old_path = Rails.root.join('app', 'lib', 'forest_admin_rails', 'create_agent.rb')
82
+ new_path = Rails.root.join('lib', 'forest_admin_rails', 'create_agent.rb')
71
83
 
72
- begin
73
- ForestAdminRails::CreateAgent.setup!
74
- rescue StandardError => e
75
- logger = ActiveSupport::Logger.new($stdout)
76
- logger.warn 'An error has occurred during setup of the Forest Admin agent.'
77
- raise e.message
78
- end
84
+ File.exist?(new_path) || File.exist?(old_path)
85
+ end
79
86
 
80
- sse = ForestAdminAgent::Services::SSECacheInvalidation
81
- sse.run if ForestAdminRails.config[:instant_cache_refresh]
87
+ def setup_agent_and_cache_routes
88
+ ForestAdminRails::CreateAgent.setup!
89
+ precache_routes
90
+ rescue StandardError => e
91
+ logger = ActiveSupport::Logger.new($stdout)
92
+ logger.warn 'An error has occurred during setup of the Forest Admin agent.'
93
+ raise e.message
94
+ end
95
+
96
+ def precache_routes
97
+ return if ForestAdminAgent::Http::Router.cache_disabled?
98
+
99
+ start_time = Time.now
100
+ routes = ForestAdminAgent::Http::Router.cached_routes
101
+ elapsed = ((Time.now - start_time) * 1000).round(2)
102
+
103
+ logger = ActiveSupport::Logger.new($stdout)
104
+ logger.info("[ForestAdmin] Successfully pre-cached #{routes.size} routes in #{elapsed}ms")
82
105
  end
83
106
 
84
107
  def running_web_server?
@@ -1,3 +1,3 @@
1
1
  module ForestAdminRails
2
- VERSION = "1.12.11"
2
+ VERSION = "1.12.12"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.11
4
+ version: 1.12.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu