Class: Fastlane::Actions::OneskyUploadAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



30
31
32
# File 'lib/fastlane/plugin/onesky/actions/onesky_upload_action.rb', line 30

def self.authors
  ['JMoravec', 'joshrlesch', 'danielkiedrowski']
end

.available_optionsObject



34
35
36
37
38
39
40
41
42
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
# 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

.descriptionObject



26
27
28
# 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) ⇒ Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/fastlane/plugin/onesky/actions/onesky_upload_action.rb', line 84

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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