Class: Superglue::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_filesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/generators/superglue/install/install_generator.rb', line 15

def create_files
  remove_file "#{app_js_path}/application.js"

  use_typescript = options["typescript"]
  copy_erb_files

  if use_typescript
    copy_ts_files
  else
    copy_js_files
  end

  say "Copying Superglue initializer"
  copy_file "#{__dir__}/templates/initializer.rb", "config/initializers/superglue.rb"

  say "Copying application.json.props"
  copy_file "#{__dir__}/templates/application.json.props", "app/views/layouts/application.json.props"

  say "Adding required member methods to ApplicationRecord"
  add_member_methods

  say "Enabling jsx rendering defaults"
  insert_jsx_rendering_defaults

  say "Installing Superglue and friends"
  run "yarn add react react-dom @reduxjs/toolkit react-redux @thoughtbot/superglue"

  if use_typescript
    run "yarn add -D @types/react-dom @types/react @types/node @thoughtbot/candy_wrapper"
  end

  say "Superglue is Installed! 🎉", :green
end