Class: Fastlane::Apprepo::Uploader

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/apprepo/uploader.rb,
lib/fastlane/plugin/apprepo/helper/uploader.rb

Overview

Responsible for performing the SFTP operation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Uploader

rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 35

def initialize(options)
  self.options = options unless options.nil?
  self.host = options[:repo_url]
  self.port = options[:repo_port]
  self.user = options[:repo_user]
  self.password = options[:repo_password]
  self.rsa_keypath = options[:repo_key] # '../assets/circle.key'
  self.ipa_path = options[:ipa] # '../sampleapp.ipa'
  self.manifest_path = options[:manifest_path] # '../assets/example_manifest.json'
  self.appcode = options[:appcode]

  # Apprepo::Uploader.new.run!
  # FastlaneCore::PrintTable.print_values(config: nil , hide_keys: [:app],
  # mask_keys: ['app_review_information.demo_password'],
  # title: "deliver #{Apprepo::VERSION} Summary") # options
end

Instance Attribute Details

#appcodeObject

Returns the value of attribute appcode.



31
32
33
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 31

def appcode
  @appcode
end

#hostObject

These want to be an input parameters:



24
25
26
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 24

def host
  @host
end

#ipa_pathObject

Returns the value of attribute ipa_path.



29
30
31
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 29

def ipa_path
  @ipa_path
end

#manifest_pathObject

Returns the value of attribute manifest_path.



30
31
32
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 30

def manifest_path
  @manifest_path
end

#optionsObject

Returns the value of attribute options.



18
19
20
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 18

def options
  @options
end

#passwordObject

Returns the value of attribute password.



27
28
29
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 27

def password
  @password
end

#portObject

Returns the value of attribute port.



25
26
27
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 25

def port
  @port
end

#rsa_keypathObject

Returns the value of attribute rsa_keypath.



28
29
30
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 28

def rsa_keypath
  @rsa_keypath
end

#userObject

Returns the value of attribute user.



26
27
28
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 26

def user
  @user
end

Instance Method Details

#download_manifest_onlyObject

rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 97

def download_manifest_only
  FastlaneCore::UI.message('download_manifest_only...')
  rsa_key = load_rsa_key(rsa_keypath)
  success = true
  if !rsa_key.nil?
    FastlaneCore::UI.message('Logging in with RSA key for download...')
    Net::SSH.start(host, user, port: port,  key_data: rsa_key, keys_only: true) do |ssh|
      FastlaneCore::UI.message('Uploading UPA & Manifest...')
      success = ssh_sftp_download(ssh, manifest_path)
    end
  else
    FastlaneCore::UI.message('Logging in for download...')
    Net::SSH.start(host, user, port: port,  password: password) do |ssh|
      FastlaneCore::UI.message('Uploading UPA & Manifest...')
      success = ssh_sftp_download(ssh, manifest_path)
    end
  end
  success
end

#uploadObject

rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength



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
# File 'lib/fastlane/plugin/apprepo/uploader.rb', line 58

def upload
  # Login & Upload IPA with metadata using RSA key or username/password
  FastlaneCore::UI.message('upload...')

  if host.nil? || user.nil?
    FastlaneCore::UI.user_error('repo_url, repo_port, repo_user and repo_password or repo_key must be set on upload')
    return false
  end

  if rsa_keypath
    rsa_key = load_rsa_key(rsa_keypath)
    if rsa_key.nil?
      FastlaneCore::UI.user_error('Failed to load RSA key... ' + options[:rsa_keypath])
    end
  end

  success = false
  if !rsa_key.nil?
    FastlaneCore::UI.message('Logging in with RSA key...')
    Net::SSH.start(host, user, port: port, key_data: rsa_key, keys_only: true) do |ssh|
      FastlaneCore::UI.message('Uploading IPA & Manifest...')
      success = ssh_sftp_upload(ssh, ipa_path, manifest_path)
    end
  else
    FastlaneCore::UI.message('Logging in with username/password...')
    Net::SSH.start(host, user, port: port,  password: password) do |ssh|
      FastlaneCore::UI.message('Uploading IPA & Manifest...')
      success = ssh_sftp_upload(ssh, ipa_path, manifest_path)
    end
  end
  success
end