Class: SewingKit::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/sewing_kit/install_generator.rb

Defined Under Namespace

Classes: Project

Instance Method Summary collapse

Constructor Details

#initialize(args, *opts) ⇒ InstallGenerator

Returns a new instance of InstallGenerator.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/sewing_kit/install_generator.rb', line 15

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

Instance Method Details

#create_config_filesObject



30
31
32
33
34
35
36
37
38
# File 'lib/generators/sewing_kit/install_generator.rb', line 30

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

#install_js_dependenciesObject



40
41
42
43
44
45
46
47
# File 'lib/generators/sewing_kit/install_generator.rb', line 40

def install_js_dependencies
  return if options.skip_yarn?

  say("Installing javascript dependencies")
  # rubocop:disable Layout/LineLength
  system("yarn add @shopify/sewing-kit @shopify/eslint-plugin @shopify/stylelint-plugin @shopify/prettier-config @shopify/typescript-configs typescript")
  # rubocop:enable Layout/LineLength
end