Class: Fastlane::Actions::YarnAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/yarn/actions/yarn_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



30
31
32
# File 'lib/fastlane/plugin/yarn/actions/yarn_action.rb', line 30

def self.authors
  ["Josh Lesch"]
end

.available_optionsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/fastlane/plugin/yarn/actions/yarn_action.rb', line 43

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :flags,
                                 env_name: "YARN_FLAGS",
                                 description: "Flags you want Yarn to perform as listed in package.json file",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :command,
                                 env_name: "YARN_COMMAND",
                                 description: "Command you want Yarn to perform, e.g. 'add' or 'upgrade'",
                                 optional: true,
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :package_path,
                                 env_name: "PACKAGE_PATH",
                                 description: "Path to package.json file",
                                 optional: true,
                                 type: String,
                                 conflicting_options: [:project_root]),
    FastlaneCore::ConfigItem.new(key: :project_root,
                                 env_name: "PROJECT_ROOT",
                                 description: "Folder hosting the package.json",
                                 optional: true,
                                 type: String,
                                 conflicting_options: [:package_path]),
    FastlaneCore::ConfigItem.new(key: :options,
                                 env_name: "YARN_OPTIONS",
                                 description: "Options to pass to Yarn",
                                 optional: true,
                                 is_string: false,
                                 verify_block: ->(value) {
                                  case value when String; when Array;
                                    else  UI.user_error! "Invalid option: #{value.inspect}, must be an Array or String"
                                  end
                                    }),
    FastlaneCore::ConfigItem.new(key: :auto_install_dependencies,
                                 env_name: "AUTO_INSTALL_DEPENDENCIES",
                                 description: "Runs yarn install before executing any yarn command",
                                 optional: true,
                                 default_value: false,
                                 is_string: false)
  ]
end

.descriptionObject



26
27
28
# File 'lib/fastlane/plugin/yarn/actions/yarn_action.rb', line 26

def self.description
  "Execute Yarn commands from your Fastfile"
end

.detailsObject



38
39
40
41
# File 'lib/fastlane/plugin/yarn/actions/yarn_action.rb', line 38

def self.details
  # Optional:
  "Execute Yarn commands from your Fastfile"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
90
91
92
93
# File 'lib/fastlane/plugin/yarn/actions/yarn_action.rb', line 87

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



34
35
36
# File 'lib/fastlane/plugin/yarn/actions/yarn_action.rb', line 34

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fastlane/plugin/yarn/actions/yarn_action.rb', line 4

def self.run(params)
  flags = params[:flags]
  command = params[:command]
  options = params[:options]
  package_path = params[:package_path]
  project_root = params[:project_root]

  # create a new object from yarn helper
  yarn = Helper::YarnHelper.new(package_path: package_path, project_root: project_root)

  # Check if yarn is installed
  yarn.check_install

  if params[:auto_install_dependencies]
    UI.message("Installing dependecies")
    yarn.install_dependencies
  end

  # trigger command
  yarn.trigger(command: command, flags: flags, options: options)
end