TEMPLATE_PATH = File.dirname(__FILE__) # Questions wants_react = true#yes?("Would you like to use React for this project?") wants_typescript = true#yes?("Would you like to use TypeScript for this project?") # Entry point if wants_react directory "#{TEMPLATE_PATH}/app/quilt", "app/ui" else directory "#{TEMPLATE_PATH}/app/basic", "app/ui" end # Binaries directory "#{TEMPLATE_PATH}/bin", "bin" chmod "bin", 0755 & ~File.umask, verbose: false # Other append_to_file ".gitignore", <<-EOS.strip_heredoc # Added by sewing_kit /node_modules /public/patckwork EOS # Configuration ## package.json package_json_path = File.expand_path "./package.json", destination_root package_json = File.exists?(package_json_path) ? JSON.parse(File.read(package_json_path)) : Hash.new scripts = package_json.fetch("scripts", Hash.new) unless scripts.key?("lint") scripts["lint"] = wants_typescript ? "tslint ./app" : "eslint ./app --max-warnings 0" end unless scripts.key?("test") scripts["test"] = "" end unless scripts.key?("check") scripts["check"] = "yarn run lint && yarn run test" end unless wants_typescript scripts["eslintConfig"] = { "extends": [ wants_react ? "plugin:shopify/react" : "plugin:shopify/esnext" ] } end package_json["scripts"] = scripts create_file package_json_path, JSON.pretty_generate(package_json, indent: " ") ## other copy_file "#{TEMPLATE_PATH}/sewing-kit.config.js", "config/sewing-kit.config.js" if wants_typescript copy_file "#{TEMPLATE_PATH}/tsconfig.json", "tsconfig.json" copy_file "#{TEMPLATE_PATH}/tslint.json", "tslint.json" empty_directory "config/typescript/modules" else copy_file "#{TEMPLATE_PATH}/.eslintignore", ".eslintignore" end # Dependencies dev_dependencies = %w(webpack@2.2.0 file:../../sewing-kit) if wants_typescript # dev_dependencies.concat(["typescript", "tslint", "tslint-config-shopify"]) dev_dependencies.concat %w(typescript tslint) else dev_dependencies.concat %w(eslint eslint-plugin-shopify) end run "yarn add --dev #{dev_dependencies.join(" ")}" dependencies = [] dependencies.concat %w(react react-dom file:../../quilt) if wants_react run "yarn add #{dependencies.join(" ")}" # Finishing up puts <<-EOS.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 Sewing Kit! EOS