module Patchwork class InstallGenerator < ::Rails::Generators::Base attr_accessor :wants_react attr_accessor :wants_typescript source_root File.expand_path("./templates", __FILE__) desc "Install everything you need for a basic Patchwork integration" def add_webpack_rails_to_gemfile gem 'webpack-rails' end # def ask_about_react # wants_react = yes?("Would you like to use React for this project?") # wants_typescript = yes?("Would you like to use TypeScript for this project?") # end def augment_package_json # TODO: linting, tests, build end # def copy_webpack_config # copy_file "sewing-kit.config.js", "config/sewing-kit.config.js" # end # def copy_typescript_config # return unless wants_typescript # copy_file "tsconfig.json", "tsconfig.json" # end def create_entry_point empty_directory "app/ui" elsif wants_react directory "app/quilt", "app/ui" else directory "app/basic", "app/ui" end end # def add_to_gitignore # append_to_file ".gitignore" do # <<-EOF.strip_heredoc # # Added by patchwork # /node_modules # /public/webpack # EOF # end # end # def install_javascript_dependencies # dependencies = ["webpack", "@shopify/patchwork"] # dependencies.concat(["react", "react-dom", "@shopify/quilt"]) if wants_react # run "yarn add --dev #{dependencies.join(" ")}" # end # def run_bundle_install # run "bundle install" if yes?("Would you like us to run 'bundle install' for you?") # end # def whats_next # puts <<-EOF.strip_heredoc # We've set up the basics of a modern FED stack for you, but you'll still # need to: # 1. Add the 'main' entry point in to your layout, and # 2. Run 'foreman start' to run the webpack-dev-server and rails server # Thanks for using Patchwork! # EOF # end # end end