Class: Fastlane::Actions::VerifyIpaFilesAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



32
33
34
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_files_action.rb', line 32

def self.authors
  ['Derek Yang']
end

.available_optionsObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_files_action.rb', line 36

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :ipa_path,
                            env_name: 'VERIFY_IPA_IPA_PATH',
                         description: 'Explicitly set the ipa path',
                            optional: true),
    FastlaneCore::ConfigItem.new(key: :blacklist,
                            env_name: 'VERIFY_IPA_BLACKLIST',
                         description: 'A list of glob patterns that define what files should NOT make their way into the ipa',
                            optional: false,
                                type: Array),
    FastlaneCore::ConfigItem.new(key: :whitelist,
                            env_name: 'VERIFY_IPA_WHITELIST',
                         description: 'A list of glob patterns that are allowed to be included in the ipa',
                            optional: true,
                                type: Array)
  ]
end

.descriptionObject



24
25
26
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_files_action.rb', line 24

def self.description
  'Verify files in ipa file'
end

.detailsObject



28
29
30
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_files_action.rb', line 28

def self.details
  'Make sure no sensible files (e.g. build script or mock data with sensible info) are accidentally included in ipa file'
end

.is_supported?(platform) ⇒ Boolean



55
56
57
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_files_action.rb', line 55

def self.is_supported?(platform)
  [:ios].include?(platform)
end

.run(params) ⇒ Object



4
5
6
7
8
9
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_files_action.rb', line 4

def self.run(params)
  Dir.mktmpdir do |dir|
    app_path = Helper::VerifyIpaHelper.app_path(params, dir)
    self.verify_files(params, app_path)
  end
end

.verify_files(params, app_path) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fastlane/plugin/verify_ipa/actions/verify_ipa_files_action.rb', line 11

def self.verify_files(params, app_path)
  files_on_blacklist = []
  files_on_whitelist = []

  Dir.chdir(app_path) do
    params[:blacklist].each { |pattern| files_on_blacklist << Dir.glob(pattern) }
    params[:whitelist].each { |pattern| files_on_whitelist << Dir.glob(pattern) } if params[:whitelist]

    invalid_files = files_on_blacklist.flatten - files_on_whitelist.flatten
    UI.user_error!("Found files on the blacklist: #{invalid_files}") unless invalid_files.empty?
  end
end