Class: Ruflet::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Ruflet::Generators::InstallGenerator
- Defined in:
- lib/generators/ruflet/install/install_generator.rb
Instance Method Summary collapse
- #add_desktop_flag_to_binstubs ⇒ Object
- #create_app_entrypoint ⇒ Object
- #create_ruflet_yaml ⇒ Object
- #download_prebuilt_client ⇒ Object
- #mount_web_app ⇒ Object
-
#mount_websocket ⇒ Object
Mount the native WebSocket endpoint explicitly in config/routes.rb.
- #print_install_status ⇒ Object
Instance Method Details
#add_desktop_flag_to_binstubs ⇒ Object
49 50 51 52 53 54 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 49 def add_desktop_flag_to_binstubs return unless desktop_requested? install_desktop_flag_bootstrap("bin/rails") install_desktop_flag_bootstrap("bin/dev") end |
#create_app_entrypoint ⇒ Object
15 16 17 18 19 20 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 15 def create_app_entrypoint target = File.join(destination_root, entrypoint_path) return if File.exist?(target) create_file target, Ruflet::Rails::InstallSupport.default_app_template(app_title: app_name) end |
#create_ruflet_yaml ⇒ Object
22 23 24 25 26 27 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 22 def create_ruflet_yaml target = File.join(destination_root, "ruflet.yaml") return if File.exist?(target) create_file target, Ruflet::Rails::InstallSupport.default_ruflet_yaml(app_name: app_name) end |
#download_prebuilt_client ⇒ Object
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 56 def download_prebuilt_client client = requested_client return if client == "none" install_web_client if %w[web all].include?(client) install_desktop_client if %w[desktop all].include?(client) rescue StandardError => e @client_download_failed = true say_status(:warn, "Ruflet client download failed: #{e.class}: #{e.}", :yellow) end |
#mount_web_app ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 39 def mount_web_app return unless web_requested? routes = File.join(destination_root, "config", "routes.rb") return unless File.file?(routes) return if File.read(routes).include?("Ruflet::Rails.web_app(") route Ruflet::Rails::InstallSupport.web_route_snippet(entrypoint: entrypoint_path) end |
#mount_websocket ⇒ Object
Mount the native WebSocket endpoint explicitly in config/routes.rb. Nothing is auto-mounted — the dev owns the route, like any other.
31 32 33 34 35 36 37 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 31 def mount_websocket routes = File.join(destination_root, "config", "routes.rb") return unless File.file?(routes) return if File.read(routes).include?("Ruflet::Rails.app(") route Ruflet::Rails::InstallSupport.route_snippet(entrypoint: entrypoint_path) end |
#print_install_status ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 67 def print_install_status Ruflet::Rails::InstallSupport.install_next_steps( target: install_target, entrypoint: entrypoint_path, client: requested_client ).each { |line| say line } end |