Class: Flame::ViteGenerator
- Inherits:
-
Generators::Base
- Object
- Rails::Generators::Base
- Generators::Base
- Flame::ViteGenerator
- Defined in:
- lib/flame/generators/vite_generator.rb
Instance Method Summary collapse
- #copy_templates ⇒ Object
- #generate_home ⇒ Object
- #generate_root_route ⇒ Object
- #install ⇒ Object
- #install_dev_packages ⇒ Object
- #install_packages ⇒ Object
- #install_standardjs ⇒ Object
Methods inherited from Generators::Base
Instance Method Details
#copy_templates ⇒ Object
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_home ⇒ Object
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_route ⇒ Object
70 71 72 |
# File 'lib/flame/generators/vite_generator.rb', line 70 def generate_root_route route("root to: 'pages#index'") end |
#install ⇒ Object
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_packages ⇒ Object
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_packages ⇒ Object
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_standardjs ⇒ Object
60 61 62 |
# File 'lib/flame/generators/vite_generator.rb', line 60 def install_standardjs template("eslintrc.js", ".eslintrc.js") end |