class DatacraftsIoSkeleton::ReactCreator
Responsible for the creation of rails projects.
Constants
- DEFAULT_FOLDERS
Public Class Methods
new(app_name, options)
click to toggle source
Calls superclass method
# File lib/datacrafts_io_skeleton/react_creator.rb, line 13 def initialize(app_name, options) super() @app_name = app_name # We use it to commit changes. @front_name = "#{app_name}/frontend" @ts = options[:typescipt] end
Public Instance Methods
call()
click to toggle source
# File lib/datacrafts_io_skeleton/react_creator.rb, line 20 def call empty_directory @front_name inside @front_name do create_react_app create_default_folders end copy_config_files run_linters commit("React frontend app was added.") say("React frontend part has built.", :green) end
Private Instance Methods
copy_config_files()
click to toggle source
# File lib/datacrafts_io_skeleton/react_creator.rb, line 46 def copy_config_files copy_file "eslintrc.js", app("frontend/.eslintrc.js") copy_file "stylelintrc.json", app("frontend/.stylelintrc") copy_file "prettierrc.json", app("frontend/.prettierrc.json") end
create_default_folders()
click to toggle source
# File lib/datacrafts_io_skeleton/react_creator.rb, line 42 def create_default_folders DEFAULT_FOLDERS.each(&method(:empty_directory)) end
create_react_app()
click to toggle source
# File lib/datacrafts_io_skeleton/react_creator.rb, line 36 def create_react_app run "npx create-react-app . #{@ts && '--template typescript'}" run "npm i -s #{react_libs}" run "npm install" end
react_libs()
click to toggle source
# File lib/datacrafts_io_skeleton/react_creator.rb, line 57 def react_libs %w[axios prettier @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-config-prettier eslint-plugin-prettier stylelint stylelint-config-standard typescript enzyme @testing-library/react msw].join(" ") end
run_linters()
click to toggle source
# File lib/datacrafts_io_skeleton/react_creator.rb, line 52 def run_linters run "cd #{app('frontend')} && npx eslint --quiet --fix --ext ts,tsx,js,jsx src" run "cd #{app('frontend')} && npx stylelint --fix **/*.css" end