Class: Fastlane::Actions::GetManagedPlayStorePublishingRightsAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



41
42
43
# File 'lib/fastlane/plugin/managed_google_play/actions/get_managed_play_store_publishing_rights.rb', line 41

def self.authors
  ["Jan Piotrowski"]
end

.available_optionsObject



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
# File 'lib/fastlane/plugin/managed_google_play/actions/get_managed_play_store_publishing_rights.rb', line 54

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      key: :json_key,
      env_name: "SUPPLY_JSON_KEY", # TODO
      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!("'#{value}' doesn't seem to be a JSON file") unless FastlaneCore::Helper.json_file?(File.expand_path(value))
        UI.user_error!("Could not find service account json file at path '#{File.expand_path(value)}'") unless File.exist?(File.expand_path(value))
      end
    ),
    FastlaneCore::ConfigItem.new(
      key: :json_key_data,
      env_name: "SUPPLY_JSON_KEY_DATA", # TODO
      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
    )

  ]
end

.descriptionObject



37
38
39
# File 'lib/fastlane/plugin/managed_google_play/actions/get_managed_play_store_publishing_rights.rb', line 37

def self.description
  "Obtain publishing rights for custom apps on Managed Google Play Store"
end

.detailsObject



49
50
51
52
# File 'lib/fastlane/plugin/managed_google_play/actions/get_managed_play_store_publishing_rights.rb', line 49

def self.details
  # Optional:
  "none yet"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/fastlane/plugin/managed_google_play/actions/get_managed_play_store_publishing_rights.rb', line 93

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

.return_valueObject



45
46
47
# File 'lib/fastlane/plugin/managed_google_play/actions/get_managed_play_store_publishing_rights.rb', line 45

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

.run(params) ⇒ Object



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
# File 'lib/fastlane/plugin/managed_google_play/actions/get_managed_play_store_publishing_rights.rb', line 7

def self.run(params)
  unless params[:json_key] || params[:json_key_data]
    UI.important("To not be asked about this value, you can specify it using 'json_key'")
    params[:json_key] = UI.input("The service account json file used to authenticate with Google: ")
  end

  FastlaneCore::PrintTable.print_values(
    config: params,
    mask_keys: [:json_key_data],
    title: "Summary for GetManagedPlayStorePublishingRights" # TODO
  )

  @keyfile = params[:json_key] # TODO: json_key_data as alternative

  # login
  credentials = JSON.parse(File.open(@keyfile, 'rb').read)
  # puts 'credentials: '+credentials.inspect
  # puts 'email: ' + credentials['client_email']

  callback_uri = 'https://janpio.github.io/fastlane-plugin-managed_google_play/callback.html'
  uri = "https://play.google.com/apps/publish/delegatePrivateApp?service_account=#{credentials['client_email']}&continueUrl=#{URI.escape(callback_uri)}"

  UI.message("To obtain publishing rights for custom apps on Managed Play Store, open the following URL and log in:")
  UI.message("")
  UI.important(uri)
  UI.message("([Cmd/Ctrl] + [Left click] lets you open this URL in many consoles/terminals/shells)")
  UI.message("")
  UI.message("After successful login you will be redirected to a page which outputs some information that is required for usage of the `create_app_on_managed_play_store` action.")
end