Class: Fastlane::Actions::ValidatePlayStoreJsonKeyAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/validate_play_store_json_key.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



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

def self.authors
  ["janpio"]
end

.available_optionsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'fastlane/lib/fastlane/actions/validate_play_store_json_key.rb', line 43

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :json_key,
      env_name: "SUPPLY_JSON_KEY",
      short_option: "-j",
      conflicting_options: [:json_key_data],
      optional: true, # this shouldn't be optional but is until I find out how json_key OR json_key_data can be required
      description: "The path to a file containing service account JSON, used to authenticate with Google",
      code_gen_sensitive: true,
      default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_file),
      default_value_dynamic: true,
      verify_block: proc do |value|
        UI.user_error!("Could not find service account json file at path '#{File.expand_path(value)}'") unless File.exist?(File.expand_path(value))
        UI.user_error!("'#{value}' doesn't seem to be a JSON file") unless FastlaneCore::Helper.json_file?(File.expand_path(value))
      end
    ),
    FastlaneCore::ConfigItem.new(
      key: :json_key_data,
      env_name: "SUPPLY_JSON_KEY_DATA",
      short_option: "-c",
      conflicting_options: [:json_key],
      optional: true,
      description: "The raw service account JSON data used to authenticate with Google",
      code_gen_sensitive: true,
      default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_data_raw),
      default_value_dynamic: true,
      verify_block: proc do |value|
        begin
          JSON.parse(value)
        rescue JSON::ParserError
          UI.user_error!("Could not parse service account json: JSON::ParseError")
        end
      end
    ),
    # stuff
    FastlaneCore::ConfigItem.new(key: :root_url,
      env_name: "SUPPLY_ROOT_URL",
      description: "Root URL for the Google Play API. The provided URL will be used for API calls in place of https://www.googleapis.com/",
      optional: true,
      verify_block: proc do |value|
        UI.user_error!("Could not parse URL '#{value}'") unless value =~ URI.regexp
      end),
    FastlaneCore::ConfigItem.new(key: :timeout,
      env_name: "SUPPLY_TIMEOUT",
      optional: true,
      description: "Timeout for read, open, and send (in seconds)",
      type: Integer,
      default_value: 300)
  ]
end

.categoryObject



99
100
101
# File 'fastlane/lib/fastlane/actions/validate_play_store_json_key.rb', line 99

def self.category
  :misc
end

.descriptionObject



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

def self.description
  "Validate that the Google Play Store `json_key` works"
end

.detailsObject



31
32
33
# File 'fastlane/lib/fastlane/actions/validate_play_store_json_key.rb', line 31

def self.details
  "Use this action to test and validate your private key json key file used to connect and authenticate with the Google Play API"
end

.example_codeObject



35
36
37
38
39
40
41
# File 'fastlane/lib/fastlane/actions/validate_play_store_json_key.rb', line 35

def self.example_code
  [
    "validate_play_store_json_key(
      json_key: 'path/to/you/json/key/file'
    )"
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



95
96
97
# File 'fastlane/lib/fastlane/actions/validate_play_store_json_key.rb', line 95

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

.run(params) ⇒ Object



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

def self.run(params)
  FastlaneCore::PrintTable.print_values(
    config: params,
    mask_keys: [:json_key_data],
    title: "Summary for validate_play_store_json_key"
  )

  begin
    client = Supply::Client.make_from_config(params: params)
    FastlaneCore::UI.success("Successfully established connection to Google Play Store.")
    FastlaneCore::UI.verbose("client: " + client.inspect)
  rescue => e
    UI.error("Could not establish a connection to Google Play Store with this json key file.")
    UI.error("#{e.message}\n#{e.backtrace.join("\n")}") if FastlaneCore::Globals.verbose?
  end
end