class Fastlane::Actions::OneskyUploadAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/onesky/actions/onesky_upload_action.rb, line 30
def self.authors
  ['JMoravec', 'joshrlesch', 'danielkiedrowski']
end
available_options() click to toggle source
# File lib/fastlane/plugin/onesky/actions/onesky_upload_action.rb, line 34
def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :public_key,
                                 env_name: 'ONESKY_PUBLIC_KEY',
                                 description: 'Public key for OneSky',
                                 is_string: true,
                                 optional: false,
                                 verify_block: proc do |value|
                                   raise "No Public Key for OneSky given, pass using `public_key: 'token'`".red unless value and !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :secret_key,
                                 env_name: 'ONESKY_SECRET_KEY',
                                 description: 'Secret Key for OneSky',
                                 is_string: true,
                                 optional: false,
                                 verify_block: proc do |value|
                                   raise "No Secret Key for OneSky given, pass using `secret_key: 'token'`".red unless value and !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :project_id,
                                 env_name: 'ONESKY_PROJECT_ID',
                                 description: 'Project Id to upload file to',
                                 optional: false,
                                 verify_block: proc do |value|
                                   raise "No project id given, pass using `project_id: 'id'`".red unless value and !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :strings_file_path,
                                 env_name: 'ONESKY_STRINGS_FILE_PATH',
                                 description: 'Base file path for the strings file to upload',
                                 is_string: true,
                                 optional: false,
                                 verify_block: proc do |value|
                                   raise "Couldn't find file at path '#{value}'".red unless File.exist?(value)
                                 end),
    FastlaneCore::ConfigItem.new(key: :strings_file_format,
                                 env_name: 'ONESKY_STRINGS_FORMAT',
                                 description: 'Format of the strings file: see https://github.com/onesky/api-documentation-platform/blob/master/reference/format.md',
                                 is_string: true,
                                 optional: false,
                                 verify_block: proc do |value|
                                   raise 'No file format given'.red unless value and !value.empty?
                                 end),
    FastlaneCore::ConfigItem.new(key: :deprecate_missing,
                                 env_name: 'ONESKY_DEPRECATE_MISSING',
                                 description: 'Should missing phrases be marked as deprecated in OneSky?',
                                 is_string: false,
                                 optional: true,
                                 default_value: false)
  ]
end
description() click to toggle source
# File lib/fastlane/plugin/onesky/actions/onesky_upload_action.rb, line 26
def self.description
  'Upload a strings file to OneSky'
end
is_supported?(platform) click to toggle source
# File lib/fastlane/plugin/onesky/actions/onesky_upload_action.rb, line 84
def self.is_supported?(platform)
  true
end
run(params) click to toggle source
# File lib/fastlane/plugin/onesky/actions/onesky_upload_action.rb, line 4
def self.run(params)
  Actions.verify_gem!('onesky-ruby')
  require 'onesky'

  client = ::Onesky::Client.new(params[:public_key], params[:secret_key])

  project = client.project(params[:project_id])

  UI.success 'Starting the upload to OneSky'
  resp = project.upload_file(
    file: params[:strings_file_path],
    file_format: params[:strings_file_format],
    is_keeping_all_strings: !params[:deprecate_missing]
  )

  if resp.code == 201
    UI.success "#{File.basename params[:strings_file_path]} was successfully uploaded to project #{params[:project_id]} in OneSky"
  else
    UI.error "Error uploading file to OneSky, Status code is #{resp.code}"
  end
end