Class: Deliver::Setup
- Inherits:
-
Object
- Object
- Deliver::Setup
- Defined in:
- deliver/lib/deliver/setup.rb
Instance Attribute Summary collapse
-
#is_swift ⇒ Object
Returns the value of attribute is_swift.
Instance Method Summary collapse
- #deliverfile_path ⇒ Object
- #download_screenshots(path, options) ⇒ Object
-
#generate_deliver_file(deliver_path, options) ⇒ Object
This method takes care of creating a new ‘deliver’ folder, containing the app metadata and screenshots folders.
- #generate_metadata_files(app, version, path, options) ⇒ Object
- #generate_metadata_files_old(v, path) ⇒ Object
- #run(options, is_swift: false) ⇒ Object
- #setup_deliver(file_path, data, deliver_path, options) ⇒ Object
Instance Attribute Details
#is_swift ⇒ Object
Returns the value of attribute is_swift.
9 10 11 |
# File 'deliver/lib/deliver/setup.rb', line 9 def is_swift @is_swift end |
Instance Method Details
#deliverfile_path ⇒ Object
54 55 56 57 58 59 60 |
# File 'deliver/lib/deliver/setup.rb', line 54 def deliverfile_path if self.is_swift return "#{Deliver::ROOT}/lib/assets/DeliverfileDefault.swift" else return "#{Deliver::ROOT}/lib/assets/DeliverfileDefault" end end |
#download_screenshots(path, options) ⇒ Object
198 199 200 201 |
# File 'deliver/lib/deliver/setup.rb', line 198 def download_screenshots(path, ) FileUtils.mkdir_p(path) Deliver::DownloadScreenshots.run(, path) end |
#generate_deliver_file(deliver_path, options) ⇒ Object
This method takes care of creating a new ‘deliver’ folder, containing the app metadata and screenshots folders
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'deliver/lib/deliver/setup.rb', line 41 def generate_deliver_file(deliver_path, ) app = Deliver.cache[:app] platform = Spaceship::ConnectAPI::Platform.map([:platform]) v = app.get_latest_app_store_version(platform: platform) = [:metadata_path] || File.join(deliver_path, 'metadata') (app, v, , ) # Generate the final Deliverfile here return File.read(deliverfile_path) end |
#generate_metadata_files(app, version, path, options) ⇒ Object
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 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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'deliver/lib/deliver/setup.rb', line 62 def (app, version, path, ) # App info localizations if [:use_live_version] app_info = app.fetch_live_app_info UI.user_error!("The option `use_live_version` was set to `true`, however no live app was found on App Store Connect.") unless app_info else app_info = app.fetch_edit_app_info || app.fetch_live_app_info end app_info_localizations = app_info.get_app_info_localizations app_info_localizations.each do |localization| language = localization.locale UploadMetadata::LOCALISED_APP_VALUES.each do |file_key, attribute_name| content = localization.send(attribute_name.to_slug) || "" content += "\n" resulting_path = File.join(path, language, "#{file_key}.txt") FileUtils.mkdir_p(File.('..', resulting_path)) File.write(resulting_path, content) UI.("Writing to '#{resulting_path}'") end end # Version localizations version_localizations = version.get_app_store_version_localizations version_localizations.each do |localization| language = localization.locale UploadMetadata::LOCALISED_VERSION_VALUES.each do |file_key, attribute_name| content = localization.send(attribute_name) || "" content += "\n" resulting_path = File.join(path, language, "#{file_key}.txt") FileUtils.mkdir_p(File.('..', resulting_path)) File.write(resulting_path, content) UI.("Writing to '#{resulting_path}'") end end # App info (categories) UploadMetadata::NON_LOCALISED_APP_VALUES.each do |file_key, attribute_name| category = app_info.send(attribute_name) content = category ? category.id.to_s : "" content += "\n" resulting_path = File.join(path, "#{file_key}.txt") FileUtils.mkdir_p(File.('..', resulting_path)) File.write(resulting_path, content) UI.("Writing to '#{resulting_path}'") end # Version UploadMetadata::NON_LOCALISED_VERSION_VALUES.each do |file_key, attribute_name| content = version.send(attribute_name) || "" content += "\n" resulting_path = File.join(path, "#{file_key}.txt") FileUtils.mkdir_p(File.('..', resulting_path)) File.write(resulting_path, content) UI.("Writing to '#{resulting_path}'") end # Review information app_store_review_detail = begin version.fetch_app_store_review_detail rescue nil end # errors if doesn't exist UploadMetadata::REVIEW_INFORMATION_VALUES.each do |file_key, attribute_name| if app_store_review_detail content = app_store_review_detail.send(attribute_name) || "" else content = "" end content += "\n" base_dir = File.join(path, UploadMetadata::REVIEW_INFORMATION_DIR) resulting_path = File.join(base_dir, "#{file_key}.txt") FileUtils.mkdir_p(File.('..', resulting_path)) File.write(resulting_path, content) UI.("Writing to '#{resulting_path}'") end end |
#generate_metadata_files_old(v, path) ⇒ Object
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 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'deliver/lib/deliver/setup.rb', line 152 def (v, path) app_details = v.application.details # All the localised metadata (UploadMetadata::LOCALISED_VERSION_VALUES.keys + UploadMetadata::LOCALISED_APP_VALUES.keys).each do |key| v.description.languages.each do |language| if UploadMetadata::LOCALISED_VERSION_VALUES.keys.include?(key) content = v.send(key)[language].to_s else content = app_details.send(key)[language].to_s end content += "\n" resulting_path = File.join(path, language, "#{key}.txt") FileUtils.mkdir_p(File.('..', resulting_path)) File.write(resulting_path, content) UI.("Writing to '#{resulting_path}'") end end # All non-localised metadata (UploadMetadata::NON_LOCALISED_VERSION_VALUES.keys + UploadMetadata::NON_LOCALISED_APP_VALUES).each do |key| if UploadMetadata::NON_LOCALISED_VERSION_VALUES.keys.include?(key) content = v.send(key).to_s else content = app_details.send(key).to_s end content += "\n" resulting_path = File.join(path, "#{key}.txt") File.write(resulting_path, content) UI.("Writing to '#{resulting_path}'") end # Review information UploadMetadata::REVIEW_INFORMATION_VALUES_LEGACY.each do |key, option_name| content = v.send(key).to_s content += "\n" base_dir = File.join(path, UploadMetadata::REVIEW_INFORMATION_DIR) FileUtils.mkdir_p(base_dir) resulting_path = File.join(base_dir, "#{option_name}.txt") File.write(resulting_path, content) UI.("Writing to '#{resulting_path}'") end UI.success("Successfully created new configuration files.") end |
#run(options, is_swift: false) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'deliver/lib/deliver/setup.rb', line 11 def run(, is_swift: false) containing = Helper.fastlane_enabled_folder_path self.is_swift = is_swift if is_swift file_path = File.join(containing, 'Deliverfile.swift') else file_path = File.join(containing, 'Deliverfile') end data = generate_deliver_file(containing, ) setup_deliver(file_path, data, containing, ) end |
#setup_deliver(file_path, data, deliver_path, options) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'deliver/lib/deliver/setup.rb', line 24 def setup_deliver(file_path, data, deliver_path, ) File.write(file_path, data) screenshots_path = [:screenshots_path] || File.join(deliver_path, 'screenshots') unless [:skip_screenshots] download_screenshots(screenshots_path, ) # Add a README to the screenshots folder FileUtils.mkdir_p(screenshots_path) # just in case the fetching didn't work File.write(File.join(screenshots_path, 'README.txt'), File.read("#{Deliver::ROOT}/lib/assets/ScreenshotsHelp")) end UI.success("Successfully created new Deliverfile at path '#{file_path}'") end |