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
- #add_routes ⇒ Object
- #create_app_entrypoint ⇒ Object
- #create_ruflet_yaml ⇒ Object
- #download_prebuilt_client ⇒ Object
- #print_install_status ⇒ Object
Instance Method Details
#add_desktop_flag_to_binstubs ⇒ Object
40 41 42 43 44 45 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 40 def add_desktop_flag_to_binstubs return unless desktop_requested? install_desktop_flag_bootstrap("bin/rails") install_desktop_flag_bootstrap("bin/dev") end |
#add_routes ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 30 def add_routes target = File.join(destination_root, "config/routes.rb") return unless File.file?(target) route = Ruflet::Rails::InstallSupport.route_snippet(entrypoint: entrypoint_path) return if File.read(target).include?(route) insert_into_file target, " #{route}\n", after: /Rails\.application\.routes\.draw do\s*\n/ end |
#create_app_entrypoint ⇒ Object
16 17 18 19 20 21 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 16 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
23 24 25 26 27 28 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 23 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
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 47 def download_prebuilt_client client = requested_client @web_client_published = false return if client == "none" if %w[web all].include?(client) @web_client_published = Ruflet::Rails::InstallSupport.publish_web_build(destination_root) if @web_client_published say "Ruflet web build copied from build/web to public/#{Ruflet::Rails::InstallSupport.default_web_public_path}" return if client == "web" end end require "ruflet/cli" exit_code = Dir.chdir(destination_root) do Ruflet::CLI.command_update([client]) end unless exit_code.to_i.zero? @client_download_failed = true say_status(:warn, "Ruflet client download failed; install files were generated and build/update steps are printed below", :yellow) return end return unless %w[web all].include?(client) published = Ruflet::Rails::InstallSupport.publish_prebuilt_web_client(destination_root) @web_client_published = published if published say "Ruflet web client published at /#{Ruflet::Rails::InstallSupport.default_web_public_path}/" else say_status(:warn, "Ruflet web client downloaded, but no prebuilt web index.html was found to publish", :yellow) end rescue StandardError => e @client_download_failed = true say_status(:warn, "Ruflet client download failed: #{e.class}: #{e.}", :yellow) end |
#print_install_status ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/generators/ruflet/install/install_generator.rb', line 84 def print_install_status Ruflet::Rails::InstallSupport.install_next_steps( target: install_target, entrypoint: entrypoint_path, client: requested_client, web_published: !!@web_client_published ).each { |line| say line } end |