Class: WebpackRails::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/webpack_rails/install_generator.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#add_foreman_to_gemfileObject



8
9
10
# File 'lib/generators/webpack_rails/install_generator.rb', line 8

def add_foreman_to_gemfile
  gem 'foreman'
end

#add_to_gitignoreObject



33
34
35
36
37
38
39
40
41
# File 'lib/generators/webpack_rails/install_generator.rb', line 33

def add_to_gitignore
  append_to_file ".gitignore" do
    "    # Added by webpack-rails\n    /node_modules\n    /public/webpack\n    EOF\n  end\nend\n".strip_heredoc

#copy_package_jsonObject



16
17
18
# File 'lib/generators/webpack_rails/install_generator.rb', line 16

def copy_package_json
  copy_file "package.json", "package.json"
end

#copy_procfileObject



12
13
14
# File 'lib/generators/webpack_rails/install_generator.rb', line 12

def copy_procfile
  copy_file "Procfile", "Procfile"
end

#copy_webpack_confObject



20
21
22
# File 'lib/generators/webpack_rails/install_generator.rb', line 20

def copy_webpack_conf
  copy_file "webpack.config.js", "config/webpack.config.js"
end

#create_webpack_application_jsObject



24
25
26
27
28
29
30
31
# File 'lib/generators/webpack_rails/install_generator.rb', line 24

def create_webpack_application_js
  empty_directory "webpack"
  create_file "webpack/application.js" do
    "    console.log(\"Hello world!\");\n    EOF\n  end\nend\n".strip_heredoc

#run_bundle_installObject



47
48
49
# File 'lib/generators/webpack_rails/install_generator.rb', line 47

def run_bundle_install
  run "bundle install" if yes?("Would you like us to run 'bundle install' for you?")
end

#run_npm_installObject



43
44
45
# File 'lib/generators/webpack_rails/install_generator.rb', line 43

def run_npm_install
  run "npm install" if yes?("Would you like us to run 'npm install' for you?")
end

#whats_nextObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/generators/webpack_rails/install_generator.rb', line 51

def whats_next
  puts "\n    We've set up the basics of webpack-rails for you, but you'll still\n    need to:\n\n      1. Add the 'application' entry point in to your layout, and\n      2. Run 'foreman start' to run the webpack-dev-server and rails server\n\n    See the README.md for this gem at\n    https://github.com/mipearson/webpack-rails/blob/master/README.md\n    for more info.\n\n    Thanks for using webpack-rails!\n\n  EOF\nend\n".strip_heredoc