Class: Fastlane::Actions::FirebaseDownloadConfigAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



31
32
33
# File 'lib/fastlane/plugin/firebase/actions/firebase_download_config_action.rb', line 31

def self.authors
  ["Tomas Kohout"]
end

.available_optionsObject



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

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :username,
                            env_name: "FIREBASE_USERNAME",
                         description: "Username for your google account",
                            optional: false),
    FastlaneCore::ConfigItem.new(key: :project_number,
                            env_name: "FIREBASE_PROJECT_NUMBER",
                         description: "Project number",
                            optional: true),
    FastlaneCore::ConfigItem.new(key: :client_id,
                            env_name: "FIREBASE_CLIENT_ID",
                         description: "Project client id",
                            optional: true),
    FastlaneCore::ConfigItem.new(key: :output_path,
                            env_name: "FIREBASE_OUTPUT_PATH",
                         description: "Path for the downloaded config",
                            optional: false,
                            default_value: "./"),
    FastlaneCore::ConfigItem.new(key: :output_name,
                            env_name: "FIREBASE_OUTPUT_NAME",
                         description: "Name of the downloaded file",
                            optional: true)
  ]
end

.descriptionObject



27
28
29
# File 'lib/fastlane/plugin/firebase/actions/firebase_download_config_action.rb', line 27

def self.description
  "An unofficial tool to access Firebase"
end

.detailsObject



39
40
41
42
# File 'lib/fastlane/plugin/firebase/actions/firebase_download_config_action.rb', line 39

def self.details
  # Optional:
  "Firebase helps you list your projects, create applications, download configuration files and more..."
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
73
74
75
76
# File 'lib/fastlane/plugin/firebase/actions/firebase_download_config_action.rb', line 70

def self.is_supported?(platform)
  # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
  # See: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md
  #
  # [:ios, :mac, :android].include?(platform)
  true
end

.return_valueObject



35
36
37
# File 'lib/fastlane/plugin/firebase/actions/firebase_download_config_action.rb', line 35

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

.run(params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fastlane/plugin/firebase/actions/firebase_download_config_action.rb', line 5

def self.run(params)
  manager = Firebase::Manager.new
  
  # Login
  api = manager.(params[:username])

  #Select project
  project = manager.select_project(params[:project_number])
  project_number = project["projectNumber"]

  #Select client
  client = manager.select_client(project, params[:client_id])
  client_id = client["clientId"]

  #Download
  config = api.download_config_file(project_number, client_id)
  path = File.join(params[:output_path], params[:output_name] || config.filename)
  config.save!(path)

  UI.success "Successfuly saved config at #{path}"
end