Class: Fastlane::Actions::ValidateUniversalLinksAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



58
59
60
61
62
63
# File 'lib/fastlane/plugin/branch/actions/validate_universal_links_action.rb', line 58

def self.authors
  [
    "Branch <[email protected]>",
    "Jimmy Dee <[email protected]>"
  ]
end

.available_optionsObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/fastlane/plugin/branch/actions/validate_universal_links_action.rb', line 88

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :xcodeproj,
                            env_name: "BRANCH_XCODEPROJ",
                         description: "Path to an Xcode project to validate",
                            optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :target,
                            env_name: "BRANCH_TARGET",
                         description: "Name of the target in the Xcode project to validate",
                            optional: true,
                                type: String),
    FastlaneCore::ConfigItem.new(key: :domains,
                            env_name: "BRANCH_DOMAINS",
                         description: "Branch (and/or non-Branch) Universal Link/App Link domains expected to be present in project (comma-separated list or array)",
                            optional: true,
                           is_string: false)
  ]
end

.categoryObject



116
117
118
# File 'lib/fastlane/plugin/branch/actions/validate_universal_links_action.rb', line 116

def self.category
  :project
end

.descriptionObject



54
55
56
# File 'lib/fastlane/plugin/branch/actions/validate_universal_links_action.rb', line 54

def self.description
  "Validates Universal Link configuration for an Xcode project."
end

.detailsObject



65
66
67
68
69
# File 'lib/fastlane/plugin/branch/actions/validate_universal_links_action.rb', line 65

def self.details
  "This action validates all the Universal Link domains found in an Xcode project's entitlements " \
  "file by ensuring that the development team and bundle identifier combination is found in the " \
  "domain's apple-app-site-association file."
end

.example_codeObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/fastlane/plugin/branch/actions/validate_universal_links_action.rb', line 71

def self.example_code
  [
    "      validate_universal_links\n    EOF,\n    <<-EOF\n      validate_universal_links(xcodeproj: \"MyProject.xcodeproj\")\n    EOF,\n    <<-EOF\n      validate_universal_links(xcodeproj: \"MyProject.xcodeproj\", target: \"MyProject\")\n    EOF,\n    <<-EOF\n      validate_universal_links(domains: %w{example.com www.example.com})\n    EOF\n  ]\nend\n"

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/fastlane/plugin/branch/actions/validate_universal_links_action.rb', line 112

def self.is_supported?(platform)
  platform == :ios
end

.return_valueObject



108
109
110
# File 'lib/fastlane/plugin/branch/actions/validate_universal_links_action.rb', line 108

def self.return_value
  "Returns true for a valid configuration, false otherwise."
end

.run(params) ⇒ Object



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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fastlane/plugin/branch/actions/validate_universal_links_action.rb', line 6

def self.run(params)
  helper = Fastlane::Helper::BranchHelper

  xcodeproj_path = helper.xcodeproj_path_from_params params
  # Error reporting is done in the helper.
  return false if xcodeproj_path.nil?

  # raises
  xcodeproj = Xcodeproj::Project.open xcodeproj_path

  target = params[:target] # may be nil
  domains = params[:domains] # may be nil

  valid = true

  unless domains.nil?
    domains_valid = helper.validate_project_domains(
      helper.custom_domains_from_params(params),
      xcodeproj,
      target
    )

    if domains_valid
      UI.message "Project domains match :domains parameter: ✅"
    else
      UI.error "Project domains do not match specified :domains"
      helper.errors.each { |error| UI.error " #{error}" }
    end

    valid &&= domains_valid
  end

  configuration_valid = helper.validate_team_and_bundle_ids_from_aasa_files xcodeproj, target
  unless configuration_valid
    UI.error "Universal Link configuration failed validation."
    helper.errors.each { |error| UI.error " #{error}" }
  end

  valid &&= configuration_valid

  UI.message "Universal Link configuration passed validation. ✅" if valid

  valid
rescue => e
  UI.user_error! "Error in ValidateUniversalLinksAction: #{e.message}\n#{e.backtrace}"
  false
end