Class: Quilt::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_app_fileObject



14
15
16
17
18
19
20
21
22
# File 'lib/generators/quilt/install_generator.rb', line 14

def create_app_file
  app_path = "app/ui/index.tsx"

  unless File.exist?(app_path)
    copy_file "App.tsx", app_path

    log("React App at #{app_path}", 'wrote')
  end
end

#create_route_fileObject



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/quilt/install_generator.rb', line 24

def create_route_file
  routes_path = "config/routes.rb"

  if File.exist?(routes_path)
    route "mount Quilt::Engine, at: '/'"
  else
    copy_file "routes.rb", routes_path
  end

  say "Added Quilt engine mount"
end

#install_js_dependenciesObject



9
10
11
12
# File 'lib/generators/quilt/install_generator.rb', line 9

def install_js_dependencies
  say "Installing @shopify/react-server and @shopify/sewing-kit dependencies"
  system("yarn add @shopify/sewing-kit @shopify/react-server") unless Rails.env.test?
end