Class: Flame::ViteGenerator

Inherits:
Generators::Base show all
Defined in:
lib/flame/generators/vite_generator.rb

Instance Method Summary collapse

Methods inherited from Generators::Base

source_root

Instance Method Details

#copy_templatesObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/flame/generators/vite_generator.rb', line 47

def copy_templates
  remove_file "vite.config.js"
  remove_file "vite.config.ts"
  template("vite.config.js", "vite.config.js")
  template("jsconfig.json", "jsconfig.json")
  run("rm -rf app/frontend")
  run("rm -rf db/seeds.rb")
  run("rm app/views/layouts/application.html.haml")
  directory("frontend", "app/frontend")
  template("app/views/layouts/application.html.haml", "app/views/layouts/application.html.haml")
  template("db/seeds.rb", "db/seeds.rb")
end

#generate_homeObject



64
65
66
67
68
# File 'lib/flame/generators/vite_generator.rb', line 64

def generate_home
  generate("controller", "pages", "index", "--skip-routes", "--no-test-framework")
  run("echo '' > app/views/pages/index.html.haml")
  append_to_file("app/views/pages/index.html.haml", "#root\n")
end

#generate_root_routeObject



70
71
72
# File 'lib/flame/generators/vite_generator.rb', line 70

def generate_root_route
  route("root to: 'pages#index'")
end

#installObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/flame/generators/vite_generator.rb', line 5

def install
  run("rm -rf ./package.lock")
  run("yarn init -y")

  run("bundle exec vite install")

  run("rm -rf ./package-lock.json")
  run("rm -rf ./yarn.lock")
  run("rm -rf ./node_modules")
end

#install_dev_packagesObject



37
38
39
40
41
42
43
44
45
# File 'lib/flame/generators/vite_generator.rb', line 37

def install_dev_packages
  packages = %w[
    standard
    @vitejs/plugin-react-swc
    eslint-plugin-react
  ]

  yarn_install_dev(packages)
end

#install_packagesObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/flame/generators/vite_generator.rb', line 16

def install_packages
  packages = %w[
    react
    react-dom
    formik
    yup
    axios
    @reduxjs/toolkit
    react-redux
    react-router-dom
    @mui/material
    @mui/icons-material
    @emotion/react
    @emotion/styled
    react-toastify
    styled-components
    sass
  ]
  yarn_install(packages)
end

#install_standardjsObject



60
61
62
# File 'lib/flame/generators/vite_generator.rb', line 60

def install_standardjs
  template("eslintrc.js", ".eslintrc.js")
end