Class: PodBuilder::Command::Update

Inherits:
Object
  • Object
show all
Defined in:
lib/pod_builder/command/update.rb

Class Method Summary collapse

Class Method Details

.call(options) ⇒ Object



7
8
9
10
11
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
39
40
41
# File 'lib/pod_builder/command/update.rb', line 7

def self.call(options)          
  Configuration.check_inited
  PodBuilder::prepare_basepath

  info = PodBuilder::Info.generate_info()

  swift_version = PodBuilder::system_swift_version

  pods_to_update = []
  info.each do |pod_name, info|
    if info.dig(:restore_info, :version) != info.dig(:prebuilt_info, :version)
      pods_to_update.append(pod_name)
    end
    if (prebuilt_swift_version = info.dig(:prebuilt_info, :swift_version)) && prebuilt_swift_version != swift_version
      pods_to_update.append(pod_name)
    end
  end

  pods_to_update.map! { |x| x.split("/").first }.uniq!
  
  unless pods_to_update.count > 0
    puts "Frameworks in sync!\n".green
    return 0
  end
  if options.has_key?(:dry_run)
    puts "`#{pods_to_update.join("`, `")}` need to be rebuilt!\n".red
    return -2
  end

  ARGV.clear
  pods_to_update.each { |x| ARGV << x }

  options[:auto_resolve_dependencies] = true
  return PodBuilder::Command::Build.call(options)
end