Class: Fastlane::Actions::BundleInstallAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/bundle_install.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, deprecated_notes, details, lane_context, method_missing, other_action, output, return_type, return_value, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorObject


54
55
56
# File 'fastlane/lib/fastlane/actions/bundle_install.rb', line 54

def self.author
  ["birmacher", "koglinjg"]
end

.available_optionsObject


66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'fastlane/lib/fastlane/actions/bundle_install.rb', line 66

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :binstubs,
                                 env_name: "FL_BUNDLE_INSTALL_BINSTUBS",
                                 description: "Generate bin stubs for bundled gems to ./bin",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :clean,
                                 env_name: "FL_BUNDLE_INSTALL_CLEAN",
                                 description: "Run bundle clean automatically after install",
                                 is_string: false,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :full_index,
                                 env_name: "FL_BUNDLE_INSTALL_FULL_INDEX",
                                 description: "Use the rubygems modern index instead of the API endpoint",
                                 is_string: false,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :gemfile,
                                 env_name: "FL_BUNDLE_INSTALL_GEMFILE",
                                 description: "Use the specified gemfile instead of Gemfile",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :jobs,
                                 env_name: "FL_BUNDLE_INSTALL_JOBS",
                                 description: "Install gems using parallel workers",
                                 is_string: false,
                                 type: Boolean,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :local,
                                 env_name: "FL_BUNDLE_INSTALL_LOCAL",
                                 description: "Do not attempt to fetch gems remotely and use the gem cache instead",
                                 is_string: false,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :deployment,
                                 env_name: "FL_BUNDLE_INSTALL_DEPLOYMENT",
                                 description: "Install using defaults tuned for deployment and CI environments",
                                 is_string: false,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :no_cache,
                                 env_name: "FL_BUNDLE_INSTALL_NO_CACHE",
                                 description: "Don't update the existing gem cache",
                                 is_string: false,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :no_prune,
                                 env_name: "FL_BUNDLE_INSTALL_NO_PRUNE",
                                 description: "Don't remove stale gems from the cache",
                                 is_string: false,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :path,
                                 env_name: "FL_BUNDLE_INSTALL_PATH",
                                 description: "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :system,
                                 env_name: "FL_BUNDLE_INSTALL_SYSTEM",
                                 description: "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application",
                                 is_string: false,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :quiet,
                                 env_name: "FL_BUNDLE_INSTALL_QUIET",
                                 description: "Only output warnings and errors",
                                 is_string: false,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :retry,
                                 env_name: "FL_BUNDLE_INSTALL_RETRY",
                                 description: "Retry network and git requests that have failed",
                                 is_string: false,
                                 type: Boolean,
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :shebang,
                                 env_name: "FL_BUNDLE_INSTALL_SHEBANG",
                                 description: "Specify a different shebang executable name than the default (usually 'ruby')",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :standalone,
                                 env_name: "FL_BUNDLE_INSTALL_STANDALONE",
                                 description: "Make a bundle that can work without the Bundler runtime",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :trust_policy,
                                 env_name: "FL_BUNDLE_INSTALL_TRUST_POLICY",
                                 description: "Sets level of security when dealing with signed gems. Accepts `LowSecurity`, `MediumSecurity` and `HighSecurity` as values",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :without,
                                 env_name: "FL_BUNDLE_INSTALL_WITHOUT",
                                 description: "Exclude gems that are part of the specified named group",
                                 optional: true),
    FastlaneCore::ConfigItem.new(key: :with,
                                 env_name: "FL_BUNDLE_INSTALL_WITH",
                                 description: "Include gems that are part of the specified named group",
                                 optional: true)
  ]
end

.categoryObject


62
63
64
# File 'fastlane/lib/fastlane/actions/bundle_install.rb', line 62

def self.category
  :misc
end

.descriptionObject


46
47
48
# File 'fastlane/lib/fastlane/actions/bundle_install.rb', line 46

def self.description
  'This action runs `bundle install` (if available)'
end

.example_codeObject


58
59
60
# File 'fastlane/lib/fastlane/actions/bundle_install.rb', line 58

def self.example_code
  nil
end

.gemfile_exists?(params) ⇒ Boolean

rubocop:enable Metrics/PerceivedComplexity

Returns:


35
36
37
38
39
40
41
42
43
44
# File 'fastlane/lib/fastlane/actions/bundle_install.rb', line 35

def self.gemfile_exists?(params)
  possible_gemfiles = ['Gemfile', 'gemfile']
  possible_gemfiles.insert(0, params[:gemfile]) if params[:gemfile]
  possible_gemfiles.each do |gemfile|
    gemfile = File.absolute_path(gemfile)
    return true if File.exist?(gemfile)
    UI.message("Gemfile not found at: '#{gemfile}'")
  end
  return false
end

.is_supported?(platform) ⇒ Boolean

Returns:


50
51
52
# File 'fastlane/lib/fastlane/actions/bundle_install.rb', line 50

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object

rubocop:disable Metrics/PerceivedComplexity


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'fastlane/lib/fastlane/actions/bundle_install.rb', line 5

def self.run(params)
  if gemfile_exists?(params)
    cmd = ['bundle install']

    cmd << "--binstubs #{params[:binstubs]}" if params[:binstubs]
    cmd << "--clean" if params[:clean]
    cmd << "--full-index" if params[:full_index]
    cmd << "--gemfile #{params[:gemfile]}" if params[:gemfile]
    cmd << "--jobs #{params[:jobs]}" if params[:jobs]
    cmd << "--local" if params[:local]
    cmd << "--deployment" if params[:deployment]
    cmd << "--no-cache" if params[:no_cache]
    cmd << "--no_prune" if params[:no_prune]
    cmd << "--path #{params[:path]}" if params[:path]
    cmd << "--system" if params[:system]
    cmd << "--quiet" if params[:quiet]
    cmd << "--retry #{params[:retry]}" if params[:retry]
    cmd << "--shebang" if params[:shebang]
    cmd << "--standalone #{params[:standalone]}" if params[:standalone]
    cmd << "--trust-policy" if params[:trust_policy]
    cmd << "--without #{params[:without]}" if params[:without]
    cmd << "--with #{params[:with]}" if params[:with]

    return sh(cmd.join(' '))
  else
    UI.message("No Gemfile found")
  end
end