Class: Fastlane::Actions::GetCiAppValueAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



116
117
118
119
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 116

def self.authors
  # So no one will ever forget your contribution to fastlane :) You are awesome btw!
  ["Your GitHub/Twitter Name"]
end

.available_optionsObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 79

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :xcodeproj,
                                 env_name: "FL_GET_CI_APP_VALUE_PROJECT",
                                 description: "Optional, you must specify the path to your main Xcode project if it is not in the project root directory or if you have multiple *.xcodeproj's in the root directory",
                                 optional: true,
                                 verify_block: proc do |value|
                                  UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with? ".xcworkspace"
                                  UI.user_error!("Could not find Xcode project at path '#{File.expand_path(value)}'") if !File.exist?(value) and !Helper.is_test?
                                end),
    FastlaneCore::ConfigItem.new(key: :target,
                                env_name: "FL_GET_CI_APP_VALUE_TARGET",
                                conflicting_options: [:scheme],
                                description: "Specify a specific target if you have multiple per project, optional"),
    FastlaneCore::ConfigItem.new(key: :app_id,
                                 env_name: "FL_GET_CI_APP_VALUE_APP_ID",
                                 description: "You must specify the path to your main Xcode project if it is not in the project root directory or if you have multiple *.xcodeproj's in the root directory",
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :ci_key,
                                 env_name: "FL_GET_CI_APP_VALUE_CI_KEY",
                                 description: "You must specify the path to your main Xcode project if it is not in the project root directory or if you have multiple *.xcodeproj's in the root directory",
                                 optional: false)
  ]
end

.descriptionObject



69
70
71
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 69

def self.description
  "A short description with <= 80 characters of what this action does"
end

.detailsObject



73
74
75
76
77
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 73

def self.details
  # Optional:
  # this is your chance to provide a more detailed description of this action
  "You can use this action to do cool things..."
end

.find_info(params, is_absolute = false) ⇒ Object



38
39
40
41
42
43
44
45
46
47
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 38

def self.find_info(params, is_absolute=false)
  project = find_project(params)
  target = find_target(params)
  buildConfiguration = target.build_settings("Release")
  filePath = buildConfiguration["INFOPLIST_FILE"]
  if is_absolute then
    filePath = File.join(Pathname.new(project.path).parent.to_path, filePath)
  end
  filePath
end

.find_project(params) ⇒ Object



17
18
19
20
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 17

def self.find_project(params)
  project = Xcodeproj::Project.open(params[:xcodeproj])
  project
end

.find_target(params) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 22

def self.find_target(params)
  project = find_project(params)
  if params[:target]
    target = project.targets.detect { |t| t.name == params[:target] }
    target
  else
    # firstly we are trying to find modern application target
    target = project.targets.detect do |t|
      t.kind_of?(Xcodeproj::Project::Object::PBXNativeTarget) &&
        t.product_type == 'com.apple.product-type.application'
    end
    target = project.targets[0] if target.nil?
    target
  end
end

.get_ci_app(params) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 56

def self.get_ci_app(params)
  ciApps = get_ci_apps(params)
  ciApps.each do |app|
    if app["APP_ID"] == params[:app_id] then
      return app
    end
  end
end

.get_ci_apps(params) ⇒ Object



49
50
51
52
53
54
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 49

def self.get_ci_apps(params)
  infoPlistPath = find_info(params)
  info = Xcodeproj::Plist.read_from_path(infoPlistPath)
  ciAPPs = info["CI_APPS"]
  ciAPPs
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 121

def self.is_supported?(platform)
  # you can do things like
  # 
  #  true
  # 
  #  platform == :ios
  # 
  #  [:ios, :mac].include?(platform)
  # 

  platform == :ios
end

.outputObject



104
105
106
107
108
109
110
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 104

def self.output
  # Define the shared values you are going to provide
  # Example
  [
    ['GET_CI_APP_VALUE_CUSTOM_VALUE', 'A description of what this value contains']
  ]
end

.return_valueObject



112
113
114
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 112

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

.run(params) ⇒ Object



11
12
13
14
15
# File 'lib/fastlane/plugin/ci_apps/actions/get_ci_app_value.rb', line 11

def self.run(params)
  ciApp = get_ci_app(params)
  ci_value = ciApp[params[:ci_key]]
  ci_value
end