Class: Deliver::DeliverProcess
- Inherits:
-
Object
- Object
- Deliver::DeliverProcess
show all
- Defined in:
- lib/deliver/deliver_process.rb
Overview
This class takes care of verifying all inputs and triggering the upload process
Defined Under Namespace
Classes: DeliverUnitTestsError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(deploy_information = nil) ⇒ DeliverProcess
Returns a new instance of DeliverProcess.
22
23
24
25
|
# File 'lib/deliver/deliver_process.rb', line 22
def initialize(deploy_information = nil)
@deploy_information = deploy_information || {}
@deploy_information[:blocks] ||= {}
end
|
Instance Attribute Details
Returns The App that is currently being edited.
10
11
12
|
# File 'lib/deliver/deliver_process.rb', line 10
def app
@app
end
|
#app_identifier ⇒ String
Returns : The app identifier of the currently used app (e.g. com.krausefx.app).
20
21
22
|
# File 'lib/deliver/deliver_process.rb', line 20
def app_identifier
@app_identifier
end
|
Returns All the updated/new information we got from the Deliverfile. is used to store the deploy information until the Deliverfile finished running.
17
18
19
|
# File 'lib/deliver/deliver_process.rb', line 17
def deploy_information
@deploy_information
end
|
Returns The IPA uploader that is currently being used.
13
14
15
|
# File 'lib/deliver/deliver_process.rb', line 13
def ipa
@ipa
end
|
Instance Method Details
#call_error_block(ex) ⇒ Object
275
276
277
278
279
280
281
282
283
|
# File 'lib/deliver/deliver_process.rb', line 275
def call_error_block(ex)
if @deploy_information[:blocks][:error]
@deploy_information[:blocks][:error].call(hash_for_callback(ex))
end
raise ex
end
|
#call_success_block ⇒ Object
269
270
271
272
273
|
# File 'lib/deliver/deliver_process.rb', line 269
def call_success_block
if @deploy_information[:blocks][:success]
@deploy_information[:blocks][:success].call(hash_for_callback)
end
end
|
#create_app ⇒ Object
129
130
131
132
|
# File 'lib/deliver/deliver_process.rb', line 129
def create_app
@app = Deliver::App.new(app_identifier: @app_identifier,
apple_id: @deploy_information[Deliverer::ValKey::APPLE_ID])
end
|
#fetch_app_identifier_from_app_file ⇒ Object
119
120
121
|
# File 'lib/deliver/deliver_process.rb', line 119
def fetch_app_identifier_from_app_file
@app_identifier = (CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier) rescue nil)
end
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/deliver/deliver_process.rb', line 77
def fetch_information_from_ipa_file
@app_version = @deploy_information[Deliverer::ValKey::APP_VERSION]
@app_identifier = @deploy_information[Deliverer::ValKey::APP_IDENTIFIER]
if is_release_build?
used_ipa_file = @deploy_information[:ipa]
elsif is_beta_build?
used_ipa_file = @deploy_information[:beta_ipa]
end
if used_ipa_file.kind_of?Proc
used_ipa_file = used_ipa_file.call
Deliverfile::Deliverfile::DSL.validate_ipa!(used_ipa_file)
end
if (used_ipa_file || '').length == 0 and is_beta_build?
raise "Could not find an ipa file for 'beta' mode. Provide one using `beta_ipa do ... end` in your Deliverfile.".red
end
ENV["DELIVER_IPA_PATH"] = used_ipa_file
if used_ipa_file
upload_strategy = Deliver::IPA_UPLOAD_STRATEGY_APP_STORE
if is_beta_build?
upload_strategy = Deliver::IPA_UPLOAD_STRATEGY_BETA_BUILD
end
if skip_deployment?
upload_strategy = Deliver::IPA_UPLOAD_STRATEGY_JUST_UPLOAD
end
@ipa = Deliver::IpaUploader.new(Deliver::App.new, '/tmp/', used_ipa_file, upload_strategy)
@app_identifier = verify_app_identifier(@app_identifier)
@app_version = verify_app_version(@app_version)
end
end
|
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
# File 'lib/deliver/deliver_process.rb', line 142
def load_metadata_from_config_json_folder
return unless @deploy_information[Deliverer::ValKey::CONFIG_JSON_FOLDER]
matching = {
'title' => Deliverer::ValKey::TITLE,
'description' => Deliverer::ValKey::DESCRIPTION,
'version_whats_new' => Deliverer::ValKey::CHANGELOG,
'keywords' => Deliverer::ValKey::KEYWORDS,
'privacy_url' => Deliverer::ValKey::PRIVACY_URL,
'software_url' => Deliverer::ValKey::MARKETING_URL,
'support_url' => Deliverer::ValKey::SUPPORT_URL
}
file_path = @deploy_information[:config_json_folder]
unless file_path.split("/").last.include?"metadata.json"
file_path += "/metadata.json"
end
raise "Could not find metadatafile at path '#{file_path}'".red unless File.exists?file_path
content = JSON.parse(File.read(file_path))
content.each do |language, current|
matching.each do |key, value|
if current[key]
@deploy_information[value] ||= {}
@deploy_information[value][language] ||= current[key]
end
end
end
end
|
#run ⇒ Object
27
28
29
30
31
32
33
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
|
# File 'lib/deliver/deliver_process.rb', line 27
def run
begin
run_unit_tests
fetch_information_from_ipa_file
verify_ipa_file
Helper.log.info("Got all information needed to deploy a new update ('#{@app_version}') for app '#{@app_identifier}'")
create_app
verify_app_on_itunesconnect
unless is_beta_build?
load_metadata_from_config_json_folder set_app_metadata
set_screenshots
verify_pdf_file
additional_itc_information
trigger_metadata_upload
end
trigger_ipa_upload
call_success_block
rescue => ex
call_error_block(ex)
end
end
|
#run_unit_tests ⇒ Object
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/deliver/deliver_process.rb', line 66
def run_unit_tests
if @deploy_information[:blocks][:unit_tests]
result = @deploy_information[:blocks][:unit_tests].call
if result
Helper.log.debug("Unit tests successful".green)
else
raise DeliverUnitTestsError.new("Unit tests failed. Got result: '#{result}'. Need 'true' or 1 to succeed.".red)
end
end
end
|
#set_screenshots ⇒ Object
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
# File 'lib/deliver/deliver_process.rb', line 189
def set_screenshots
screens_path = @deploy_information[Deliverer::ValKey::SCREENSHOTS_PATH]
if (ENV["DELIVER_SCREENSHOTS_PATH"] || '').length > 0
Helper.log.warn "Overwriting screenshots path from config (#{screens_path}) with (#{ENV["DELIVER_SCREENSHOTS_PATH"]})".yellow
screens_path = ENV["DELIVER_SCREENSHOTS_PATH"]
end
if screens_path
if not @app.metadata.set_all_screenshots_from_path(screens_path)
if screens_path.kind_of?String
if @deploy_information[Deliverer::ValKey::DEFAULT_LANGUAGE]
screens_path = { @deploy_information[Deliverer::ValKey::DEFAULT_LANGUAGE] => screens_path } @deploy_information[Deliverer::ValKey::SCREENSHOTS_PATH] = screens_path
else
Helper.log.error "You must have folders for the screenshots (#{screens_path}) for each language (e.g. en-US, de-DE)."
screens_path = nil
end
end
@app.metadata.set_screenshots_for_each_language(screens_path) if screens_path
end
end
end
|
#trigger_ipa_upload ⇒ Object
259
260
261
262
263
264
265
266
267
|
# File 'lib/deliver/deliver_process.rb', line 259
def trigger_ipa_upload
if @ipa
@ipa.app = @app result = @ipa.upload! raise "Error uploading ipa file".red unless result == true
else
Helper.log.warn "No IPA file given. Only the metadata was uploaded. If you want to deploy a full update, provide an ipa file."
end
end
|
235
236
237
238
|
# File 'lib/deliver/deliver_process.rb', line 235
def trigger_metadata_upload
result = @app.metadata.upload!
raise "Error uploading app metadata".red unless result == true
end
|
#verify_app_on_itunesconnect ⇒ Object
134
135
136
137
138
139
140
|
# File 'lib/deliver/deliver_process.rb', line 134
def verify_app_on_itunesconnect
if @ipa and is_release_build?
@app.create_new_version!(@app_version) unless Helper.is_test?
@app.metadata.verify_version(@app_version)
end
end
|
#verify_ipa_file ⇒ Object
#verify_pdf_file ⇒ Object
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
# File 'lib/deliver/deliver_process.rb', line 215
def verify_pdf_file
if @deploy_information[Deliverer::ValKey::SKIP_PDF]
Helper.log.debug "PDF verify was skipped"
else
pdf_path = PdfGenerator.new.render(self)
unless Helper.is_test?
puts "----------------------------------------------------------------------------"
puts "Verifying the upload via the PDF file can be disabled by either adding"
puts "'skip_pdf true' to your Deliverfile or using the flag --force."
puts "----------------------------------------------------------------------------"
system("open '#{pdf_path}'")
okay = agree("Does the PDF on path '#{pdf_path}' look okay for you? (blue = updated) (y/n)", true)
raise "Did not upload the metadata, because the PDF file was rejected by the user".yellow unless okay
end
end
end
|