Class: Fastlane::Actions::UpdateUrbanAirshipConfigurationAction

Inherits:
Fastlane::Action
  • Object
show all
Defined in:
fastlane/lib/fastlane/actions/update_urban_airship_configuration.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, author, deprecated_notes, 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

.authorsObject



67
68
69
# File 'fastlane/lib/fastlane/actions/update_urban_airship_configuration.rb', line 67

def self.authors
  ["kcharwood"]
end

.available_optionsObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'fastlane/lib/fastlane/actions/update_urban_airship_configuration.rb', line 31

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :plist_path,
                                 env_name: "URBAN_AIRSHIP_PLIST_PATH",
                                 description: "Path to Urban Airship configuration Plist",
                                 verify_block: proc do |value|
                                   UI.user_errror!("Could not find Urban Airship plist file") unless File.exist?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :development_app_key,
                                 optional: true,
                                 env_name: "URBAN_AIRSHIP_DEVELOPMENT_APP_KEY",
                                 sensitive: true,
                                 description: "The development app key"),
    FastlaneCore::ConfigItem.new(key: :development_app_secret,
                                 optional: true,
                                 env_name: "URBAN_AIRSHIP_DEVELOPMENT_APP_SECRET",
                                 sensitive: true,
                                 description: "The development app secret"),
    FastlaneCore::ConfigItem.new(key: :production_app_key,
                                 optional: true,
                                 env_name: "URBAN_AIRSHIP_PRODUCTION_APP_KEY",
                                 sensitive: true,
                                 description: "The production app key"),
    FastlaneCore::ConfigItem.new(key: :production_app_secret,
                                 optional: true,
                                 env_name: "URBAN_AIRSHIP_PRODUCTION_APP_SECRET",
                                 sensitive: true,
                                 description: "The production app secret"),
    FastlaneCore::ConfigItem.new(key: :detect_provisioning_mode,
                                 env_name: "URBAN_AIRSHIP_DETECT_PROVISIONING_MODE",
                                 type: Boolean,
                                 optional: true,
                                 description: "Automatically detect provisioning mode")
  ]
end

.categoryObject



85
86
87
# File 'fastlane/lib/fastlane/actions/update_urban_airship_configuration.rb', line 85

def self.category
  :push
end

.descriptionObject



23
24
25
# File 'fastlane/lib/fastlane/actions/update_urban_airship_configuration.rb', line 23

def self.description
  "Set [Urban Airship](https://www.urbanairship.com/) plist configuration values"
end

.detailsObject



27
28
29
# File 'fastlane/lib/fastlane/actions/update_urban_airship_configuration.rb', line 27

def self.details
  "This action updates the `AirshipConfig.plist` needed to configure the Urban Airship SDK at runtime, allowing keys and secrets to easily be set for the Enterprise and Production versions of the application."
end

.example_codeObject



75
76
77
78
79
80
81
82
83
# File 'fastlane/lib/fastlane/actions/update_urban_airship_configuration.rb', line 75

def self.example_code
  [
    'update_urban_airship_configuration(
      plist_path: "AirshipConfig.plist",
      production_app_key: "PRODKEY",
      production_app_secret: "PRODSECRET"
    )'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



71
72
73
# File 'fastlane/lib/fastlane/actions/update_urban_airship_configuration.rb', line 71

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

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'fastlane/lib/fastlane/actions/update_urban_airship_configuration.rb', line 4

def self.run(params)
  require "plist"

  begin
    path = File.expand_path(params[:plist_path])
    plist = Plist.parse_xml(path)
    plist['developmentAppKey'] = params[:development_app_key] unless params[:development_app_key].nil?
    plist['developmentAppSecret'] = params[:development_app_secret] unless params[:development_app_secret].nil?
    plist['productionAppKey'] = params[:production_app_key] unless params[:production_app_key].nil?
    plist['productionAppSecret'] = params[:production_app_secret] unless params[:production_app_secret].nil?
    plist['detectProvisioningMode'] = params[:detect_provisioning_mode] unless params[:detect_provisioning_mode].nil?
    new_plist = plist.to_plist
    File.write(path, new_plist)
  rescue => ex
    UI.error(ex)
    UI.error("Unable to update Urban Airship configuration for plist file at '#{path}'")
  end
end