apprepo 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/apprepo/version.rb +1 -1
  3. data/lib/test.rb +144 -49
  4. metadata +15 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81a7e5718e2671942e58361dc795a29e06d8a9f1
4
- data.tar.gz: 215a9a69fdad6db0af88b8c28925942f78232214
3
+ metadata.gz: 3667ef79193fbb1384523584c89cfd1f6f792f2c
4
+ data.tar.gz: 0472aecb30bb7fcaedad242bc2d016199fc6d5bd
5
5
  SHA512:
6
- metadata.gz: 9b71daddcecc92af2962c7ade8a340b44a1d304faea01025577b054f0577589439050a7a41e0e8078b7c6bba62ae65251e71555ed8c2ca6a197374998bc20acd
7
- data.tar.gz: 3cc18b0e4a8e16046839d36b893d6014115845ea37e2b7e044225a4b59844f117c234fef20e59b455aa54480cc28d0bc1fdbbcf05ba101f3a80178755c41ca2d
6
+ metadata.gz: ba9589874abbda0b3565e3c51982a397747319e9ae817be8bd5e5065ebbe5df9e12ed6be388b27a097ce100539a555980f0856ca39257e3d9246b2bdcdac5955
7
+ data.tar.gz: 28c1141ec0fe9b08a2f1b337d4b72ba5c512f22b699f498b898b81a6ef56075f1ca05439e13199556192555e90549d1e6ea89b8ab4fd0ff15cbb664e04926975
@@ -1,4 +1,4 @@
1
1
  module AppRepo
2
- VERSION = '0.0.4'.freeze
2
+ VERSION = '0.0.5'.freeze
3
3
  DESCRIPTION = 'Upload icon, metadata and your app to the T-Mobile Enterprise AppRepo and notify users on updaet using a single command'.freeze
4
4
  end
@@ -4,69 +4,164 @@ require 'rubygems'
4
4
  require 'net/ssh'
5
5
  require 'net/sftp'
6
6
 
7
- #
8
- # These want to be an input parameters:
9
- #
10
-
11
- host = 'repo.teacloud.net'
12
- user = 'circle'
13
- password = 'circle'
14
- keypath = '../assets/circle.key'
7
+ require 'fastlane'
8
+ require 'fastlane_core'
9
+
10
+ require_relative 'apprepo/options'
11
+
12
+ module AppRepo
13
+ class Test
14
+
15
+ attr_accessor :options
16
+
17
+ #
18
+ # These want to be an input parameters:
19
+ #
20
+
21
+ attr_accessor :host
22
+ attr_accessor :user
23
+ attr_accessor :password
24
+ attr_accessor :rsa_keypath
25
+ attr_accessor :ipa_path
26
+ attr_accessor :manifest_path
27
+ attr_accessor :appcode
28
+
29
+ def initialize
30
+ Fastlane::UI.message('[AppRepo:Test] Initializing...')
31
+ self.host = 'repo.teacloud.net'
32
+ self.user = 'circle'
33
+ self.password = 'circle'
34
+ self.rsa_keypath = '../assets/circle.key'
35
+ self.ipa_path = '../sampleapp.ipa'
36
+ self.manifest_path = '../assets/example_manifest.json'
37
+ self.appcode = 'APPREPO'
38
+ #self.options = options
39
+ #AppRepo::Test.new.run!
40
+ #FastlaneCore::PrintTable.print_values(config: nil , hide_keys: [:app], mask_keys: ['app_review_information.demo_password'], title: "deliver #{AppRepo::VERSION} Summary") # options
41
+ end
15
42
 
16
- File.open(File.dirname(__FILE__) + '/' + keypath, 'r') do |file|
17
- rsa_key = [file.read]
43
+ # upload an ipa and manifest file or directory to the remote host
44
+ def ssh_sftp_upload(ssh, local_ipa_path, manifest_path)
45
+ ssh.sftp.connect do |sftp|
18
46
 
19
- Net::SSH.start(host, user, password: 'circle') do |ssh|
20
- # TODO: Enable SSH when key will work on circle@repo.tecloud.net
21
- # Net::SSH.start( host, user, :key_data => rsa_key, :keys_only => true) do |ssh|
47
+ ipa_name = File.basename(local_ipa_path)
22
48
 
23
- ssh.sftp.connect do |sftp|
24
- # upload a file or directory to the remote host
25
- sftp.upload!('~/test.data', '/home/circle/repo/test.data')
49
+ if File.exist?(local_ipa_path)
50
+ Fastlane::UI.message("Local IPA found at "+local_ipa_path)
51
+ else
52
+ Fastlane::UI.message("IPA at given path does not exist!")
53
+ return
54
+ end
26
55
 
27
- result = ssh.exec!('ls')
56
+ # Check/create remote directories
28
57
 
29
- UI.message(result)
58
+ remote_path = get_remote_path() + self.appcode
59
+ Fastlane::UI.message("Checking APPCODE at: "+ remote_path )
30
60
 
31
- remote = '/home/' + user + '/repo/test.data'
32
- local = '/Users/sychram/test.data.from-remote'
61
+ remote_mkdir(sftp, remote_path)
33
62
 
34
- # download a file or directory from the remote host
35
- sftp.download!(remote, local)
63
+ # Check/delete remote (rename from metadata later) IPA
36
64
 
37
- # grab data off the remote host directly to a buffer
38
- data = sftp.download!(remote)
65
+ remote_ipa_path = get_remote_ipa_path(local_ipa_path)
66
+ Fastlane::UI.message("Checking remote IPA.")
67
+ begin
68
+ sftp.stat!(remote_ipa_path) do |response|
69
+ if response.ok?
70
+ Fastlane::UI.message("Removing existing IPA...")
71
+ sftp.remove!(remote_ipa_path)
72
+ end
73
+ end
74
+ rescue
75
+ Fastlane::UI.message("No previous IPA found.")
76
+ end
39
77
 
40
- # open and write to a pseudo-IO for a remote file
41
- sftp.file.open(remote, 'w') do |f|
42
- UI.message("opened file from sftp")
78
+ Fastlane::UI.message("Will upload IPA...")
79
+
80
+ path = File.dirname(__FILE__) + '/' + local_ipa_path
81
+ Fastlane::UI.message("Uploading IPA: " + path + " to path " + remote_ipa_path)
82
+ sftp.upload!(path, remote_ipa_path)
83
+
84
+ remote_manifest_path = remote_path + '/manifest.json'
85
+
86
+ Fastlane::UI.message("Checking remote Manifest.")
87
+ begin
88
+ sftp.stat!(remote_manifest_path) do |response|
89
+ if response.ok?
90
+ Fastlane::UI.message("Reading existing Manifest.")
91
+ sftp.file.open(remote_manifest_path, 'w') do |f|
92
+ UI.message("opened file from sftp")
93
+ end
94
+ end
95
+ end
96
+ rescue
97
+ Fastlane::UI.message("No previous Manifest found.")
98
+ end
99
+
100
+ Fastlane::UI.message("Uploading Manifest: " + manifest_path + " to path " + remote_manifest_path)
101
+ sftp.upload!(manifest_path, remote_manifest_path)
102
+
103
+ # list the entries in a directory for verification
104
+ sftp.dir.foreach(remote_path) do |entry|
105
+ Fastlane::UI.message(entry.longname)
106
+ end
43
107
  end
108
+ end
44
109
 
45
- # open and read from a pseudo-IO for a remote file
46
- sftp.file.open(remote, 'r') do |f|
47
- puts f.gets
48
- end
110
+ def remote_mkdir(sftp, remote_path)
111
+ begin
112
+ sftp.mkdir remote_path
113
+ rescue Net::SFTP::StatusException => e
114
+ if e.code == 11
115
+ Fastlane::UI.message('Remote directory' + remote_path + ' already exists. OK...')
116
+ else
117
+ raise
118
+ end
119
+ end
120
+ end
49
121
 
50
- directory = '/home/' + user + '/ruby-test'
51
-
52
- # safely make a directory
53
- begin
54
- sftp.mkdir directory
55
- rescue Net::SFTP::StatusException => e
56
- # verify if this returns 11. Your server may return
57
- # something different like 4.
58
- if e.code == 11
59
- puts 'directory already exists. Carry on...'
60
- sftp.rmdir!('/home/' + user + '/ruby-test')
61
- else
62
- raise
122
+ def load_rsa_key(rsa_keypath)
123
+ File.open(File.dirname(__FILE__) + '/' + rsa_keypath, 'r') do |file|
124
+ rsa_key = [file.read]
125
+ if rsa_key != nil
126
+ Fastlane::UI.message("Successfully loaded RSA key...")
63
127
  end
128
+ return rsa_key
64
129
  end
130
+ end
131
+
132
+ def get_remote_ipa_path(ipa_path)
133
+ path = get_remote_path() + self.appcode + '/' + File.basename(ipa_path)
134
+ Fastlane::UI.message("remote_ipa_path: " + path)
135
+ return path
136
+ end
137
+
138
+ def get_remote_path()
139
+ path = '/home/' + user + '/repo/apps/'
140
+ Fastlane::UI.message("get_remote_path: " + path)
141
+ return path
142
+ end
65
143
 
66
- # list the entries in a directory
67
- sftp.dir.foreach('.') do |entry|
68
- puts entry.longname
144
+ def run
145
+ # Login & Upload IPA with metadata using RSA key or username/password
146
+ rsa_key = nil # load_rsa_key(self.rsa_keypath)
147
+ if rsa_key != nil
148
+ Fastlane::UI.message("Logging in with RSA key " + self.rsa_keypath)
149
+ Net::SSH.start( self.host, self.user, :key_data => rsa_key, :keys_only => true) do |ssh|
150
+ Fastlane::UI.message("Logged in, uploading UPA & Manifest...")
151
+ ssh_sftp_upload(ssh, self.ipa_path, self.manifest_path)
152
+ end
153
+ else
154
+ # Login with
155
+ Fastlane::UI.message("Logging in with username " + self.user + " and password *****...")
156
+ Net::SSH.start(self.host, self.user, password: self.password) do |ssh|
157
+ Fastlane::UI.message("Logged in, uploading UPA & Manifest...")
158
+ ssh_sftp_upload(ssh, self.ipa_path, self.manifest_path)
159
+ end
69
160
  end
70
161
  end
71
- end
72
- end
162
+
163
+ # test
164
+ Test.new.run
165
+
166
+ end # class
167
+ end # module
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apprepo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
@@ -73,6 +73,20 @@ dependencies:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: json
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.8.1
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.8.1
76
90
  - !ruby/object:Gem::Dependency
77
91
  name: fastimage
78
92
  requirement: !ruby/object:Gem::Requirement