Class: MnoEnterprise::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- MnoEnterprise::Generators::InstallGenerator
- Defined in:
- lib/generators/mno_enterprise/install/install_generator.rb
Instance Method Summary collapse
- #copy_initializer ⇒ Object
- #install_summary ⇒ Object
-
#notify_about_routes ⇒ Object
Inject engine routes.
- #setup_admin ⇒ Object
- #setup_assets ⇒ Object
- #setup_frontend ⇒ Object
- #setup_less_development_paths ⇒ Object
- #update_gitignore ⇒ Object
Instance Method Details
#copy_initializer ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/mno_enterprise/install/install_generator.rb', line 14 def copy_initializer # Foreman config template "Procfile" template "Procfile.dev" template ".foreman" template ".healthcheck" template "config/initializers/mno_enterprise.rb" template "config/mno_enterprise_styleguide.yml" template "config/puma.rb", skip: true # Copied from Rails 5 - skip if already existing # Settings template "config/settings.yml", "config/settings.yml" create_file "config/settings.local.yml" directory "config/settings", "config/settings" template "config/application.yml", "config/application.yml" template "config/application.yml", "config/application.sample.yml" template "config/newrelic.yml", "config/newrelic.yml" end |
#install_summary ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/generators/mno_enterprise/install/install_generator.rb', line 121 def install_summary unless [:quiet] say("\n\n") say_status("==> Maestrano Enterprise has been installed ==", nil) say("- You can generate deployment configs by running: 'rails g mno_enterprise:puma_stack'") say("- You can start the server with: 'foreman start'") if @install_frontend say("\n\n") say_status("==> Maestrano Enterprise Angular has been installed", nil) say("- You can quickly customize the platform style in frontend/src/app/stylesheets") say("- You can customize the whole frontend by overriding mno-enterprise-angular in frontend/src/") say("- You can run 'rake mnoe:frontend:dist' to rebuild the frontend after changing frontend/src") end if @install_admin say("\n\n") say_status("==> Maestrano Enterprise Admin Dashboard has been installed", nil) say("- You can access the platform with an admin user (admin_role = 'admin')") end say("\n\n") end end |
#notify_about_routes ⇒ Object
Inject engine routes
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/generators/mno_enterprise/install/install_generator.rb', line 98 def notify_about_routes if (routes_file = destination_path.join('config', 'routes.rb')).file? && (routes_file.read !~ %r{mount\ MnoEnterprise::Engine}) mount = %Q{ # This line mount Maestrano Enterprise routes in your application under /mnoe. # If you would like to change where this engine is mounted, simply change the :at option to something different # # We ask that you don't use the :as option here, as Mnoe relies on it being the default of "mno_enterprise" scope '(:locale)' do mount MnoEnterprise::Engine, at: '/mnoe', as: :mno_enterprise end root to: redirect('mnoe/auth/users/sign_in') } inject_into_file routes_file, mount, after: "Rails.application.routes.draw do\n" end unless [:quiet] say "\n" say "We added the following line to your application's config/routes.rb file:" say " mount MnoEnterprise::Engine, at: '/mnoe'" say " root to: redirect(MnoEnterprise.router.dashboard_path)" end end |
#setup_admin ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/generators/mno_enterprise/install/install_generator.rb', line 87 def setup_admin unless [:skip_admin] say("\n") @install_admin = ask_with_default("Would you like to install Maestrano Enterprise Admin Dashboard (frontend)?") if @install_admin rake "mnoe:admin:install" end end end |
#setup_assets ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/generators/mno_enterprise/install/install_generator.rb', line 36 def setup_assets if defined?(MnoEnterprise::Frontend) # Stylesheets copy_file "stylesheets/main.less", "app/assets/stylesheets/main.less", skip: true # Require main stylesheet file inject_into_file 'app/assets/stylesheets/application.css', before: " */" do " *= require main\n" end # Disable require_tree which breaks the app gsub_file 'app/assets/stylesheets/application.css', /\*= require_tree ./, '* require_tree .' end end |
#setup_frontend ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/generators/mno_enterprise/install/install_generator.rb', line 77 def setup_frontend unless [:skip_frontend] say("\n") @install_frontend = ask_with_default("Would you like to install Maestrano Enterprise Angular (frontend)?") if @install_frontend rake "mnoe:frontend:install" end end end |
#setup_less_development_paths ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/generators/mno_enterprise/install/install_generator.rb', line 51 def setup_less_development_paths if defined?(MnoEnterprise::Frontend) || Rails.env.test? application(nil, env: "development") do "# Reload frontend stylesheets on changes\n config.less.paths << \"\#{Rails.root}/frontend/src/app/stylesheets\"\n" end end end |
#update_gitignore ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/generators/mno_enterprise/install/install_generator.rb', line 59 def update_gitignore create_file '.gitignore' unless File.exists? '.gitignore' append_to_file '.gitignore' do "\n" + "# Ignore application configuration\n" + "config/application.yml\n" + "config/application-*.yml\n" + "config/settings.local.yml\n" + "config/settings/*.local.yml\n" + "config/environments/*.local.yml\n" + "\n" + "# Bower and Node packages\n" + "bower_components\n" + "node_modules\n" end end |