Class: Deliver::DeliverfileCreator
- Inherits:
-
Object
- Object
- Deliver::DeliverfileCreator
- Defined in:
- lib/deliver/deliverfile/deliverfile_creator.rb
Overview
Helps new user quickly adopt Deliver
Class Method Summary collapse
-
.create(deliver_path, project_name = nil) ⇒ Object
This method will ask the user what he wants to do.
-
.create_based_on_identifier(deliver_path, identifier, project_name) ⇒ Object
This will download all the app metadata and store its data into JSON files.
-
.create_example_deliver_file(path, project_name) ⇒ Object
This method is used, when the user does not want to automatically create the Deliverfile.
Class Method Details
.create(deliver_path, project_name = nil) ⇒ Object
This method will ask the user what he wants to do
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/deliver/deliverfile/deliverfile_creator.rb', line 12 def self.create(deliver_path, project_name = nil) deliver_file_path = File.join(deliver_path, Deliver::Deliverfile::Deliverfile::FILE_NAME) raise "Deliverfile already exists at path '#{deliver_file_path}'. Run 'deliver' to use Deliver.".red if File.exists?(deliver_file_path) project_name ||= Dir.pwd.split("/").last if agree("Do you want Deliver to automatically create the Deliverfile for you based " + "on your current app? The app has to be in the App Store to use this feature. (y/n)", true) puts "\n\nFirst, you need to login with your iTunesConnect credentials. ".yellow + "\nThis is necessary to fetch the latest metadata from your app and use it to create a Deliverfile for you." + "\nIf you have previously entered your credentials already, you will not be asked again." if CredentialsManager::PasswordManager.shared_manager.username and CredentialsManager::PasswordManager.shared_manager.password identifier = ((CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier) rescue '') || '') while identifier.length < 3 identifier = ask("\nApp Identifier of your app (e.g. at.felixkrause.app_name): ") end self.create_based_on_identifier(deliver_path, identifier, project_name) else self.create_example_deliver_file(deliver_file_path, project_name) end else self.create_example_deliver_file(deliver_file_path, project_name) end end |
.create_based_on_identifier(deliver_path, identifier, project_name) ⇒ Object
This will download all the app metadata and store its data into JSON files
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/deliver/deliverfile/deliverfile_creator.rb', line 56 def self.create_based_on_identifier(deliver_path, identifier, project_name) app = Deliver::App.new(app_identifier: identifier) app.("/tmp") # we don't want to pollute the current folder app. # this will download the latest app metadata file_path = File.join(deliver_path, Deliver::Deliverfile::Deliverfile::FILE_NAME) json = generate_deliver_file(app, deliver_path, project_name) File.write(file_path, json) FileUtils.mkdir_p File.join(deliver_path, 'screenshots') begin Helper.log.info "Downloading all previously used app screenshots.".green ItunesConnect.new.download_existing_screenshots(app, deliver_path) rescue Exception => ex Helper.log.error ex Helper.log.error "Couldn't download already existing screenshots from iTunesConnect. You have to add them manually!".red end # Add a README to the screenshots folder FileUtils.mkdir_p File.join(deliver_path, 'screenshots') # just in case the fetching didn't work File.write(File.join(deliver_path, 'screenshots', 'README.txt'), File.read("#{Helper.gem_path('deliver')}/lib/assets/ScreenshotsHelp")) Helper.log.info "Successfully created new Deliverfile at '#{file_path}'".green end |
.create_example_deliver_file(path, project_name) ⇒ Object
This method is used, when the user does not want to automatically create the Deliverfile
43 44 45 46 47 48 49 50 |
# File 'lib/deliver/deliverfile/deliverfile_creator.rb', line 43 def self.create_example_deliver_file(path, project_name) gem_path = Helper.gem_path('deliver') example = File.read("#{gem_path}/lib/assets/DeliverfileExample") example.gsub!("[[APP_NAME]]", project_name) File.write(path, example) puts "Successfully created new Deliverfile at '#{path}'".green end |