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: DeliverUIAutomationError, 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.
16
17
18
|
# File 'lib/deliver/deliver_process.rb', line 16
def app
@app
end
|
Returns All the updated/new information we got from the Deliverfile. is used to store the deploy information until the Deliverfile finished running.
20
21
22
|
# File 'lib/deliver/deliver_process.rb', line 20
def deploy_information
@deploy_information
end
|
Instance Method Details
#call_error_block(ex) ⇒ Object
225
226
227
228
229
230
231
232
233
|
# File 'lib/deliver/deliver_process.rb', line 225
def call_error_block(ex)
if @deploy_information[:blocks][:error]
@deploy_information[:blocks][:error].call(ex)
else
raise ex
end
end
|
#call_success_block ⇒ Object
221
222
223
|
# File 'lib/deliver/deliver_process.rb', line 221
def call_success_block
@deploy_information[:blocks][:success].call if @deploy_information[:blocks][:success]
end
|
#create_app ⇒ Object
92
93
94
95
|
# File 'lib/deliver/deliver_process.rb', line 92
def create_app
@app = Deliver::App.new(app_identifier: @app_identifier,
apple_id: @deploy_information[Deliverer::ValKey::APPLE_ID])
end
|
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/deliver/deliver_process.rb', line 68
def fetch_information_from_ipa_file
@app_version = @deploy_information[Deliverer::ValKey::APP_VERSION]
@app_identifier = @deploy_information[Deliverer::ValKey::APP_IDENTIFIER]
used_ipa_file = @deploy_information[:ipa] || @deploy_information[:beta_ipa]
if used_ipa_file
@ipa = Deliver::IpaUploader.new(Deliver::App.new, '/tmp/', used_ipa_file, is_beta_build?)
@app_identifier = verify_app_identifier(@app_identifier)
@app_version = verify_app_version(@app_version)
end
end
|
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/deliver/deliver_process.rb', line 105
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
|
# File 'lib/deliver/deliver_process.rb', line 27
def run
begin
run_unit_tests
fetch_information_from_ipa_file
Helper.log.info("Got all information needed to deploy a new update ('#{@app_version}') for app '#{@app_identifier}'")
verify_ipa_file
create_app
verify_app_on_itunesconnect
load_metadata_from_config_json_folder set_app_metadata
set_screenshots
verify_pdf_file
trigger_metadata_upload
trigger_ipa_upload
call_success_block
rescue Exception => ex
call_error_block(ex)
end
end
|
#run_unit_tests ⇒ Object
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/deliver/deliver_process.rb', line 57
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
# File 'lib/deliver/deliver_process.rb', line 149
def set_screenshots
screens_path = @deploy_information[Deliverer::ValKey::SCREENSHOTS_PATH]
if File.exists?('./Snapfile') and not screens_path
Helper.log.info("Found a Snapfile, using it to create new screenshots.".green)
begin
Snapshot::Runner.new.work
Helper.log.info("Looking for screenshots in './screenshots'.".yellow)
@app.metadata.set_all_screenshots_from_path('./screenshots')
rescue Exception => ex
raise DeliverUIAutomationError.new(ex)
end
elsif screens_path
if File.exists?('./Snapfile')
Helper.log.info("Found a Snapfile. Ignoring it. If you want 'deliver' to automatically take new screenshots for you, remove 'screenshots_path' from your 'Deliverfile'.".yellow)
end
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
211
212
213
214
215
216
217
218
219
|
# File 'lib/deliver/deliver_process.rb', line 211
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
|
206
207
208
209
|
# File 'lib/deliver/deliver_process.rb', line 206
def trigger_metadata_upload
result = @app.metadata.upload!
raise "Error uploading app metadata".red unless result == true
end
|
#verify_app_on_itunesconnect ⇒ Object
97
98
99
100
101
102
103
|
# File 'lib/deliver/deliver_process.rb', line 97
def verify_app_on_itunesconnect
if @ipa and not is_beta_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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
# File 'lib/deliver/deliver_process.rb', line 186
def verify_pdf_file
if @deploy_information[Deliverer::ValKey::SKIP_PDF] or is_beta_build?
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
|