Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env FASTLANE_PASSWORD and reindent close #7 #8

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
module Fastlane
module Actions
class FirebaseAddAndroidCertificateAction < Action

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

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

# Client input
type = params[:type].to_sym

bundle_id = params[:bundle_id]
name = params[:name]
appstore_id = params[:appstore_id]
sha256 = params[:sha256]

begin
client = api.add_android_certificate(project["projectNumber"], bundle_id, sha256)
rescue Firebase::Api::BadRequestError => e
if e.message != 'Requested entity already exists' then
raise
end
end

UI.success "Successfuly added android certificate of app #{bundle_id}"
end

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

def self.authors
["Tomas Kohout"]
end

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

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

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: :download_config,
env_name: "FIREBASE_DOWNLOAD_CONFIG",
description: "Should download config for created client",
optional: false,
is_string: false,
default_value: true),
FastlaneCore::ConfigItem.new(key: :type,
env_name: "FIREBASE_TYPE",
description: "Type of client (ios, android)",
verify_block: proc do |value|
types = [:ios, :android]
UI.user_error!("Type must be in #{types}") unless types.include?(value.to_sym)
end
),
FastlaneCore::ConfigItem.new(key: :bundle_id,
env_name: "FIREBASE_BUNDLE_ID",
description: "Bundle ID (package name)",
optional: false),
FastlaneCore::ConfigItem.new(key: :name,
env_name: "FIREBASE_BUNDLE_ID",
description: "Display name",
optional: true),
FastlaneCore::ConfigItem.new(key: :appstore_id,
env_name: "FIREBASE_APPSTORE_ID",
description: "AppStore 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),
FastlaneCore::ConfigItem.new(key: :sha256,
env_name: "FIREBASE_SHA_256",
description: "SHA256 for android",
optional: true)
]
end

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
end
end
end
104 changes: 104 additions & 0 deletions lib/fastlane/plugin/firebase/actions/firebase_add_apple_store_id.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
module Fastlane
module Actions
class FirebaseAddAppleStoreIdAction < Action

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

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

# Client input
type = params[:type].to_sym

bundle_id = params[:bundle_id]
name = params[:name]
appstore_id = params[:appstore_id]
store_id = params[:store_id]

client = api.add_apple_store_id(project["projectNumber"], bundle_id, store_id)

UI.success "Successfuly added apple store id of app #{bundle_id}"
end

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

def self.authors
["Tomas Kohout"]
end

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

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

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: :download_config,
env_name: "FIREBASE_DOWNLOAD_CONFIG",
description: "Should download config for created client",
optional: false,
is_string: false,
default_value: true),
FastlaneCore::ConfigItem.new(key: :type,
env_name: "FIREBASE_TYPE",
description: "Type of client (ios, android)",
verify_block: proc do |value|
types = [:ios, :android]
UI.user_error!("Type must be in #{types}") unless types.include?(value.to_sym)
end
),
FastlaneCore::ConfigItem.new(key: :bundle_id,
env_name: "FIREBASE_BUNDLE_ID",
description: "Bundle ID (package name)",
optional: false),
FastlaneCore::ConfigItem.new(key: :name,
env_name: "FIREBASE_BUNDLE_ID",
description: "Display name",
optional: true),
FastlaneCore::ConfigItem.new(key: :appstore_id,
env_name: "FIREBASE_APPSTORE_ID",
description: "AppStore 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),
FastlaneCore::ConfigItem.new(key: :store_id,
env_name: "APPLE_STORE_ID",
description: "App Apple ID",
optional: true)
]
end

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
end
end
end
105 changes: 105 additions & 0 deletions lib/fastlane/plugin/firebase/actions/firebase_add_team.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
module Fastlane
module Actions
class FirebaseAddTeamAction < Action

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

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

# Client input
type = params[:type].to_sym

bundle_id = params[:bundle_id]
name = params[:name]
appstore_id = params[:appstore_id]
team_id = params[:team_id]

# Add team
client = api.add_team(project["projectNumber"], bundle_id, team_id)

UI.success "Successfuly added team_id of app #{bundle_id}"
end

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

def self.authors
["Tomas Kohout"]
end

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

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

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: :download_config,
env_name: "FIREBASE_DOWNLOAD_CONFIG",
description: "Should download config for created client",
optional: false,
is_string: false,
default_value: true),
FastlaneCore::ConfigItem.new(key: :type,
env_name: "FIREBASE_TYPE",
description: "Type of client (ios, android)",
verify_block: proc do |value|
types = [:ios, :android]
UI.user_error!("Type must be in #{types}") unless types.include?(value.to_sym)
end
),
FastlaneCore::ConfigItem.new(key: :bundle_id,
env_name: "FIREBASE_BUNDLE_ID",
description: "Bundle ID (package name)",
optional: false),
FastlaneCore::ConfigItem.new(key: :name,
env_name: "FIREBASE_BUNDLE_ID",
description: "Display name",
optional: true),
FastlaneCore::ConfigItem.new(key: :appstore_id,
env_name: "FIREBASE_APPSTORE_ID",
description: "AppStore 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),
FastlaneCore::ConfigItem.new(key: :team_id,
env_name: "FIREBASE_TEAM_ID",
description: "ID of the Apple Team",
optional: true)
]
end

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
end
end
end
32 changes: 32 additions & 0 deletions lib/fastlane/plugin/firebase/lib/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,38 @@ def download_config_file(project_number, client_id)
UI.crash! e.page.body
end
end

def add_team(project_number, bundle_id, team_id)
parameters = {
"iosTeamId" => team_id
}

json = request_json("v1/projects/#{project_number}/clients/ios:#{bundle_id}:setTeamId", :post, parameters)
end

def add_android_certificate(project_number, bundle_id, sha256)
parameters = {
"requestHeader" => { "clientVersion" => "FIREBASE" },
"projectNumber" => project_number,
"clientId" => "android:#{bundle_id}",
"androidCertificate" => {
"androidSha256Hash" => sha256
}
}

json = request_json("v1/projects/#{project_number}/clients/android:#{bundle_id}:addAndroidCertificate", :post, parameters)
end

def add_apple_store_id(project_number, bundle_id, store_id)
parameters = {
"requestHeader" => { "clientVersion" => "FIREBASE" },
"projectNumber" => project_number,
"clientId" => "android:#{bundle_id}",
iosAppStoreId: store_id
}

json = request_json("v1/projects/#{project_number}/clients/ios:#{bundle_id}:setAppStoreId", :post, parameters)
end
end
end
end