Class: CredentialsManager::AppfileConfig
- Inherits:
-
Object
- Object
- CredentialsManager::AppfileConfig
- Defined in:
- lib/credentials_manager/appfile_config.rb
Overview
Access the content of the app file (e.g. app identifier and Apple ID)
Class Method Summary collapse
Instance Method Summary collapse
-
#app_identifier(*args, &block) ⇒ Object
iOS.
- #apple_dev_portal_id(*args, &block) ⇒ Object
- #apple_id(*args, &block) ⇒ Object
- #data ⇒ Object
- #fallback_to_default_values ⇒ Object
-
#for_lane(lane_name) ⇒ Object
Override Appfile configuration for a specific lane.
-
#for_platform(platform_name) ⇒ Object
Override Appfile configuration for a specific platform.
-
#initialize(path = nil) ⇒ AppfileConfig
constructor
A new instance of AppfileConfig.
- #issuer(*args, &block) ⇒ Object
-
#itc_team_id(*args, &block) ⇒ Object
iTunes Connect.
- #itc_team_name(*args, &block) ⇒ Object
- #itunes_connect_id(*args, &block) ⇒ Object
-
#json_key_file(*args, &block) ⇒ Object
Android.
- #keyfile(*args, &block) ⇒ Object
- #package_name(*args, &block) ⇒ Object
- #print_debug_information(path: nil) ⇒ Object
-
#team_id(*args, &block) ⇒ Object
Developer Portal.
- #team_name(*args, &block) ⇒ Object
Constructor Details
#initialize(path = nil) ⇒ AppfileConfig
Returns a new instance of AppfileConfig.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/credentials_manager/appfile_config.rb', line 23 def initialize(path = nil) if path raise "Could not find Appfile at path '#{path}'".red unless File.exist?(File.(path)) end path ||= self.class.default_path if path and File.exist?(path) # it might not exist, we still want to use the default values full_path = File.(path) Dir.chdir(File.('..', path)) do content = File.read(full_path) # From https://github.com/orta/danger/blob/master/lib/danger/Dangerfile.rb if content.tr!('“”‘’‛', %(""''')) puts "Your #{File.basename(path)} has had smart quotes sanitised. " \ 'To avoid issues in the future, you should not use ' \ 'TextEdit for editing it. If you are not using TextEdit, ' \ 'you should turn off smart quotes in your editor of choice.'.red end # rubocop:disable Lint/Eval eval(content) # rubocop:enable Lint/Eval print_debug_information(path: full_path) if $verbose end end fallback_to_default_values end |
Class Method Details
.already_printed_debug_information ⇒ Object
71 72 73 |
# File 'lib/credentials_manager/appfile_config.rb', line 71 def self.already_printed_debug_information @already_printed_debug_information ||= {} end |
.default_path ⇒ Object
16 17 18 19 20 21 |
# File 'lib/credentials_manager/appfile_config.rb', line 16 def self.default_path ["./fastlane/Appfile", "./.fastlane/Appfile", "./Appfile"].each do |current| return current if File.exist? current end nil end |
.try_fetch_value(key) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/credentials_manager/appfile_config.rb', line 4 def self.try_fetch_value(key) # We need to load the file every time we call this method # to support the `for_lane` keyword begin return self.new.data[key] rescue => ex puts ex.to_s return nil end nil end |
Instance Method Details
#app_identifier(*args, &block) ⇒ Object
iOS
86 87 88 |
# File 'lib/credentials_manager/appfile_config.rb', line 86 def app_identifier(*args, &block) setter(:app_identifier, *args, &block) end |
#apple_dev_portal_id(*args, &block) ⇒ Object
94 95 96 |
# File 'lib/credentials_manager/appfile_config.rb', line 94 def apple_dev_portal_id(*args, &block) setter(:apple_dev_portal_id, *args, &block) end |
#apple_id(*args, &block) ⇒ Object
90 91 92 |
# File 'lib/credentials_manager/appfile_config.rb', line 90 def apple_id(*args, &block) setter(:apple_id, *args, &block) end |
#data ⇒ Object
79 80 81 |
# File 'lib/credentials_manager/appfile_config.rb', line 79 def data @data ||= {} end |
#fallback_to_default_values ⇒ Object
75 76 77 |
# File 'lib/credentials_manager/appfile_config.rb', line 75 def fallback_to_default_values data[:apple_id] ||= ENV["FASTLANE_USER"] || ENV["DELIVER_USER"] end |
#for_lane(lane_name) ⇒ Object
Override Appfile configuration for a specific lane.
lane_name - Symbol representing a lane name. (Can be either :name, ‘name’ or ‘platform name’) block - Block to execute to override configuration values.
Discussion If received lane name does not match the lane name available as environment variable, no changes will
be applied.
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/credentials_manager/appfile_config.rb', line 146 def for_lane(lane_name) if lane_name.to_s.split(" ").count > 1 # That's the legacy syntax 'platform name' puts "You use deprecated syntax '#{lane_name}' in your Appfile.".yellow puts "Please follow the Appfile guide: https://github.com/fastlane/fastlane/blob/master/docs/Appfile.md".yellow platform, lane_name = lane_name.split(" ") return unless platform == ENV["FASTLANE_PLATFORM_NAME"] # the lane name will be verified below end if ENV["FASTLANE_LANE_NAME"] == lane_name.to_s yield end end |
#for_platform(platform_name) ⇒ Object
Override Appfile configuration for a specific platform.
platform_name - Symbol representing a platform name. block - Block to execute to override configuration values.
Discussion If received paltform name does not match the platform name available as environment variable, no changes will
be applied.
169 170 171 172 173 |
# File 'lib/credentials_manager/appfile_config.rb', line 169 def for_platform(platform_name) if ENV["FASTLANE_PLATFORM_NAME"] == platform_name.to_s yield end end |
#issuer(*args, &block) ⇒ Object
125 126 127 128 |
# File 'lib/credentials_manager/appfile_config.rb', line 125 def issuer(*args, &block) puts "Appfile: DEPRECATED issuer: use json_key_file instead".red setter(:issuer, *args, &block) end |
#itc_team_id(*args, &block) ⇒ Object
iTunes Connect
112 113 114 |
# File 'lib/credentials_manager/appfile_config.rb', line 112 def itc_team_id(*args, &block) setter(:itc_team_id, *args, &block) end |
#itc_team_name(*args, &block) ⇒ Object
116 117 118 |
# File 'lib/credentials_manager/appfile_config.rb', line 116 def itc_team_name(*args, &block) setter(:itc_team_name, *args, &block) end |
#itunes_connect_id(*args, &block) ⇒ Object
98 99 100 |
# File 'lib/credentials_manager/appfile_config.rb', line 98 def itunes_connect_id(*args, &block) setter(:itunes_connect_id, *args, &block) end |
#json_key_file(*args, &block) ⇒ Object
Android
121 122 123 |
# File 'lib/credentials_manager/appfile_config.rb', line 121 def json_key_file(*args, &block) setter(:json_key_file, *args, &block) end |
#keyfile(*args, &block) ⇒ Object
134 135 136 137 |
# File 'lib/credentials_manager/appfile_config.rb', line 134 def keyfile(*args, &block) puts "Appfile: DEPRECATED keyfile: use json_key_file instead".red setter(:keyfile, *args, &block) end |
#package_name(*args, &block) ⇒ Object
130 131 132 |
# File 'lib/credentials_manager/appfile_config.rb', line 130 def package_name(*args, &block) setter(:package_name, *args, &block) end |
#print_debug_information(path: nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/credentials_manager/appfile_config.rb', line 54 def print_debug_information(path: nil) self.class.already_printed_debug_information ||= {} return if self.class.already_printed_debug_information[self.data] # self.class.already_printed_debug_information is a hash, we use to detect if we already printed this data # this is necessary, as on the course of a fastlane run, the values might change, e.g. when using # the `for_lane` keyword. puts "Successfully loaded Appfile at path '#{path}'".yellow self.data.each do |key, value| puts "- #{key.to_s.cyan}: '#{value.to_s.green}'" end puts "-------" self.class.already_printed_debug_information[self.data] = true end |
#team_id(*args, &block) ⇒ Object
Developer Portal
103 104 105 |
# File 'lib/credentials_manager/appfile_config.rb', line 103 def team_id(*args, &block) setter(:team_id, *args, &block) end |
#team_name(*args, &block) ⇒ Object
107 108 109 |
# File 'lib/credentials_manager/appfile_config.rb', line 107 def team_name(*args, &block) setter(:team_name, *args, &block) end |