Sha256: 8f776f29139e9f402c2016b546cf7846ed2f4d7144fd20e41f58ad48a4a3ed9e
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
# frozen_string_literal: true module SewingKit class InstallGenerator < Rails::Generators::Base source_root File.expand_path('templates', __dir__) desc "Adds the configuration files for a sewing-kit powered front-end." class_option :skip_yarn, type: :boolean, default: false class_option :javascript_path, type: :string, default: 'app/ui' # We don't specify a default here because we want to fallback dynamically class_option :uses_dev, type: :boolean def initialize(args, *opts) super(args, *opts) @application_name = Project.app_name @javascript_path = options[:javascript_path] if Project.uses_webpacker? warn " WARNING: We've detected you currently have webpacker config at config/webpacker.yml. You may experience conflicts between sewing-kit and webpacker's behaviour as build tools. If your app was made with `rails new`, try rerunning it with `--skip-webpack-install --skip-javascript` " end end def create_config_files say "Creating JS tooling config files" copy_file("editorconfig", ".editorconfig") copy_file("eslintignore", ".eslintignore") copy_file("prettierignore", ".prettierignore") template("package.json.erb", "package.json") template("tsconfig.json.erb", "tsconfig.json") template("sewing-kit.config.ts.erb", "config/sewing-kit.config.ts") end def install_js_dependencies return if options.skip_yarn? say "Installing javascript dependencies" system("yarn add @shopify/sewing-kit") system("yarn add typescript") end class Project def self.app_name Rails.application.class.module_parent.to_s.underscore end def self.uses_dev? File.exist?('dev.yml') end def self.uses_webpacker? File.exist?('config/webpacker.yml') end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sewing_kit-0.128.0 | lib/generators/sewing_kit/install_generator.rb |