module SvelteOnRails::Installer::Utils
def self.route_exists?(target_route)
def self.route_exists?(target_route) # check if exists # Ensure the Rails environment is loaded # require File.expand_path("../config/environment", __dir__) # Get all routes from the Rails application routes = Rails.application.routes.routes # Check if the route exists routes.any? do |route| # Extract the path spec and remove any optional parts or constraints path = route.path.spec.to_s # Clean up the path to match the format (remove leading/trailing slashes, etc.) cleaned_path = path.gsub(/\(.*\)/, "").gsub(/^\/|\/$/, "") # Check if the cleaned path matches the target route cleaned_path == target_route end end