Class: Trek::Generators::Install::YarnGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Helpers
Defined in:
lib/generators/trek/install/yarn_generator.rb

Constant Summary collapse

YARN_VERSION =
"3.8.7"

Instance Method Summary collapse

Instance Method Details

#add_interactive_tools_pluginObject



44
45
46
# File 'lib/generators/trek/install/yarn_generator.rb', line 44

def add_interactive_tools_plugin
  run "yarn plugin import interactive-tools"
end

#create_yarnrcObject



36
37
38
39
40
41
42
# File 'lib/generators/trek/install/yarn_generator.rb', line 36

def create_yarnrc
  if File.exist?(".yarnrc.yml")
    prepend_to_file ".yarnrc.yml", yarnrc_content
  else
    create_file ".yarnrc.yml", [yarnrc_content, ""].join("\n")
  end
end

#insert_gitignoreObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/trek/install/yarn_generator.rb', line 20

def insert_gitignore
  insert_into_file ".gitignore",
    <<~GITIGNORE

      # Yarn
      .pnp.*
      .yarn/*
      !.yarn/patches
      !.yarn/plugins
      !.yarn/releases
      !.yarn/sdks
      !.yarn/versions
      yarn-error.log
    GITIGNORE
end

#set_versionObject



16
17
18
# File 'lib/generators/trek/install/yarn_generator.rb', line 16

def set_version
  run "yarn set version #{YARN_VERSION}", abort_on_failure: true
end