Class: Vueport::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Vueport::InstallGenerator
- Defined in:
- lib/generators/vueport/install_generator.rb
Instance Method Summary collapse
- #add_to_gitignore ⇒ Object
- #add_webpack_rails ⇒ Object
- #copy_config_files ⇒ Object
- #copy_eslint ⇒ Object
- #copy_package_json ⇒ Object
- #copy_renderer_files ⇒ Object
- #create_setup_files ⇒ Object
- #run_bundle_install ⇒ Object
- #run_npm_install ⇒ Object
- #update_procfile ⇒ Object
-
#whats_next ⇒ Object
rubocop:disable Metrics/MethodLength.
Instance Method Details
#add_to_gitignore ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/generators/vueport/install_generator.rb', line 12 def add_to_gitignore append_to_file '.gitignore' do <<-EOF.strip_heredoc # Added by vueport /node_modules /public/webpack /npm-debug.log /renderer/node_modules /renderer/npm-debug.log /renderer/bundle.server.js EOF end end |
#add_webpack_rails ⇒ Object
7 8 9 10 |
# File 'lib/generators/vueport/install_generator.rb', line 7 def add_webpack_rails gem 'webpack-rails' gem 'foreman' end |
#copy_config_files ⇒ Object
36 37 38 |
# File 'lib/generators/vueport/install_generator.rb', line 36 def copy_config_files directory 'vueport', 'config/vueport' end |
#copy_eslint ⇒ Object
31 32 33 34 |
# File 'lib/generators/vueport/install_generator.rb', line 31 def copy_eslint copy_file '.eslintrc.js' copy_file '.eslintignore' end |
#copy_package_json ⇒ Object
27 28 29 |
# File 'lib/generators/vueport/install_generator.rb', line 27 def copy_package_json copy_file 'package.json' end |
#copy_renderer_files ⇒ Object
40 41 42 |
# File 'lib/generators/vueport/install_generator.rb', line 40 def copy_renderer_files directory 'renderer' end |
#create_setup_files ⇒ Object
49 50 51 52 53 |
# File 'lib/generators/vueport/install_generator.rb', line 49 def create_setup_files directory 'webpack' copy_file '.babelrc' empty_directory 'app/components' end |
#run_bundle_install ⇒ Object
65 66 67 |
# File 'lib/generators/vueport/install_generator.rb', line 65 def run_bundle_install run 'bundle install' if yes?("Would you like me to run 'bundle install' for you? [y/N]") end |
#run_npm_install ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/generators/vueport/install_generator.rb', line 55 def run_npm_install if yarn? && yes?("Would you like me to run 'yarn' for you? [y/N]") run 'yarn' run 'cd renderer && yarn' elsif !yarn? && yes?("Would you like me to run 'npm install' for you? [y/N]") run 'npm i' run 'cd renderer && npm i' end end |
#update_procfile ⇒ Object
44 45 46 47 |
# File 'lib/generators/vueport/install_generator.rb', line 44 def update_procfile copy_file 'Procfile.dev' copy_file 'Procfile' end |
#whats_next ⇒ Object
rubocop:disable Metrics/MethodLength
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/generators/vueport/install_generator.rb', line 70 def whats_next say '' say 'All done!', :green say '' say "I've added a few things here and there to set you up using Vue in your Rails app." say "Now you're already to create your first Vue component in app/components." say '' say 'To run the webpack-dev-server and rails server:' say 'foreman start -f Procfile.dev', :yellow say '' say 'For more info, see the README.md for this gem at:' say 'https://github.com/samtgarson/vueport', :blue say '' say 'Thanks for using Vueport!' end |