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:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: bdd36d163cb4d1210f6680782fd4338aca9d3c2273fbcfab9ee90cfec91af2b9
         | 
| 4 | 
            +
              data.tar.gz: 1444cac70cd8990f48df0a80579bf0da629898a9f71a2f4082a8bdd4b19a66d3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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 | 
            -
                   | 
| 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 | 
            -
             | 
| 57 | 
            -
             | 
| 65 | 
            +
                  logger = ActiveSupport::Logger.new($stdout)
         | 
| 66 | 
            +
                  logger.warn <<~WARNING
         | 
| 67 | 
            +
                    ⚠️  DEPRECATION WARNING: create_agent.rb detected in old location!
         | 
| 58 68 |  | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 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 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 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 | 
            -
             | 
| 76 | 
            +
                    This will become a hard requirement in a future version.
         | 
| 77 | 
            +
                  WARNING
         | 
| 78 | 
            +
                end
         | 
| 68 79 |  | 
| 69 | 
            -
             | 
| 70 | 
            -
                  Rails. | 
| 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 | 
            -
                   | 
| 73 | 
            -
             | 
| 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 | 
            -
             | 
| 81 | 
            -
                   | 
| 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?
         |