lib/pod_builder/command/build.rb in pod-builder-0.2.2 vs lib/pod_builder/command/build.rb in pod-builder-0.2.3

- old
+ new

@@ -35,10 +35,14 @@ puts "\n\n🎉 done!\n".green return true end + Podfile.restore_podfile_clean(all_buildable_items) + + restore_file_error = Podfile.restore_file_sanity_check + check_splitted_subspecs_are_static(all_buildable_items, options) check_pods_exists(argument_pods, buildable_items) pods_to_build = buildable_items.select { |x| argument_pods.include?(x.root_name) } pods_to_build += other_subspecs(pods_to_build, buildable_items) @@ -80,11 +84,11 @@ # remove lockfile which gets unexplicably created FileUtils.rm_f(PodBuilder::basepath("Podfile.lock")) end - write_license_files(licenses, all_buildable_items) + Licenses::write(licenses, all_buildable_items) GenerateLFS::call(nil) Podspec::generate(analyzer) builded_pods = podfiles_items.flatten @@ -96,10 +100,14 @@ Podfile::deintegrate_install sanity_checks(options) + if (restore_file_error = restore_file_error) && Configuration.restore_enabled + puts "\n\n⚠️ Podfile.restore was found invalid and was overwritten. Error:\n #{restore_file_error}".red + end + puts "\n\n🎉 done!\n".green return true end private @@ -114,65 +122,9 @@ return data["PreferenceSpecifiers"] end return [] - end - - def self.write_license_files(licenses, all_buildable_items) - puts "Writing licenses".yellow - license_file_path = PodBuilder::project_path(Configuration.license_filename) + ".plist" - - current_licenses = [] - if File.exist?(license_file_path) - plist = CFPropertyList::List.new(:file => license_file_path) - dict = CFPropertyList.native_types(plist.value) - current_licenses = dict["PreferenceSpecifiers"] - current_licenses.shift - current_licenses.pop - end - - licenses_header = licenses.shift - raise "Unexpected license found in header" if licenses_header.has_key?("License") - license_footer = licenses.pop - raise "Unexpected license found in footer" if license_footer.has_key?("License") - - lincenses_titles = licenses.map { |x| x["Title"] } - current_licenses.select! { |x| !lincenses_titles.include?(x["Title"]) } - - licenses += current_licenses # merge with existing license - licenses.uniq! { |x| x["Title"] } - licenses.sort_by! { |x| x["Title"] } - licenses.select! { |x| !Configuration.skip_licenses.include?(x["Title"]) } - licenses.select! { |x| all_buildable_items.map(&:root_name).include?(x["Title"]) } # Remove items that are no longer included - - license_dict = {} - license_dict["PreferenceSpecifiers"] = [licenses_header, licenses, license_footer].flatten - license_dict["StringsTable"] = "Acknowledgements" - license_dict["Title"] = license_dict["StringsTable"] - - plist = CFPropertyList::List.new - plist.value = CFPropertyList.guess(license_dict) - plist.save(license_file_path, CFPropertyList::List::FORMAT_BINARY) - - write_markdown_licenses(license_file_path) - end - - def self.write_markdown_licenses(plist_path) - plist = CFPropertyList::List.new(:file => plist_path) - dict = CFPropertyList.native_types(plist.value) - licenses = dict["PreferenceSpecifiers"] - header = licenses.shift - - markdown = [] - markdown += ["# #{header["Title"]}", header["FooterText"], ""] - markdown += licenses.map { |x| ["## #{x["Title"]}", x["FooterText"], ""] } - - markdown.flatten! - - markdown_path = plist_path.chomp(File.extname(plist_path)) + ".md" - - File.write(markdown_path, markdown.join("\n")) end def self.add_dependencies(pods, buildable_items) pods.dup.each do |pod| build_configuration = pods.first.build_configuration