Class: Pod::Command::Outdated
- Inherits:
-
Pod::Command
show all
- Includes:
- ProjectDirectory, RepoUpdate
- Defined in:
- lib/cocoapods/command/outdated.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#ensure_master_spec_repo_exists!, ensure_not_root_or_allowed!, git_version, #installer_for_config, report_error, run, #verify_lockfile_exists!, verify_minimum_git_version!, #verify_podfile_exists!, verify_xcode_license_approved!
#config
Constructor Details
#initialize(argv) ⇒ Outdated
Returns a new instance of Outdated.
20
21
22
23
|
# File 'lib/cocoapods/command/outdated.rb', line 20
def initialize(argv)
@ignore_prerelease = argv.flag?('ignore-prerelease')
super
end
|
Class Method Details
.options ⇒ Object
14
15
16
17
18
|
# File 'lib/cocoapods/command/outdated.rb', line 14
def self.options
[
['--ignore-prerelease', "Don't consider prerelease versions to be updates"],
].concat(super)
end
|
Instance Method Details
#analyzer ⇒ Object
69
70
71
72
73
74
|
# File 'lib/cocoapods/command/outdated.rb', line 69
def analyzer
@analyzer ||= begin
verify_podfile_exists!
Installer::Analyzer.new(config.sandbox, config.podfile, config.lockfile)
end
end
|
#deprecated_pods ⇒ Object
106
107
108
109
110
111
112
|
# File 'lib/cocoapods/command/outdated.rb', line 106
def deprecated_pods
@deprecated_pods ||= begin
spec_sets.map(&:specification).select do |spec|
spec.deprecated || spec.deprecated_in_favor_of
end.compact.uniq
end
end
|
#ensure_external_podspecs_present! ⇒ Object
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/cocoapods/command/outdated.rb', line 139
def ensure_external_podspecs_present!
return unless config.podfile
config.podfile.dependencies.each do |dep|
next if dep.external_source.nil?
unless config.sandbox.specification(dep.root_name)
raise Informative, 'You must run `pod install` first to ensure that the ' \
"podspec for `#{dep.root_name}` has been fetched."
end
end
end
|
#installed_pods ⇒ Object
124
125
126
127
128
129
130
|
# File 'lib/cocoapods/command/outdated.rb', line 124
def installed_pods
@installed_pods ||= begin
verify_podfile_exists!
lockfile.pod_names
end
end
|
#lockfile ⇒ Object
132
133
134
135
136
137
|
# File 'lib/cocoapods/command/outdated.rb', line 132
def lockfile
@lockfile ||= begin
verify_lockfile_exists!
config.lockfile
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/cocoapods/command/outdated.rb', line 27
def run
if updates.empty?
UI.puts 'No pod updates are available.'.yellow
else
UI.section 'The color indicates what happens when you run `pod update`' do
UI.puts "#{'<green>'.green}\t - Will be updated to the newest version"
UI.puts "#{'<blue>'.blue}\t - Will be updated, but not to the newest version because of specified version in Podfile"
UI.puts "#{'<red>'.red}\t - Will not be updated because of specified version in Podfile"
UI.puts ''
end if ansi_output?
UI.section 'The following pod updates are available:' do
updates.each do |(name, from_version, matching_version, to_version)|
color = :blue
if matching_version == to_version
color = :green
elsif from_version == matching_version
color = :red
end
UI.puts "- #{name} #{from_version.to_s.send(color)} -> #{matching_version.to_s.send(color)} " \
"(latest version #{to_version.to_s})" end
end
end
if deprecated_pods.any?
UI.section 'The following pods are deprecated:' do
deprecated_pods.each do |spec|
if spec.deprecated_in_favor_of
UI.puts "- #{spec.name}" \
" (in favor of #{spec.deprecated_in_favor_of})"
else
UI.puts "- #{spec.name}"
end
end
end
end
end
|
#spec_sets ⇒ Object
114
115
116
117
118
119
120
121
122
|
# File 'lib/cocoapods/command/outdated.rb', line 114
def spec_sets
@spec_sets ||= begin
analyzer.send(:update_repositories) if repo_update?(:default => true)
aggregate = Source::Aggregate.new(analyzer.sources)
installed_pods.map do |pod_name|
aggregate.search(Dependency.new(pod_name))
end.compact.uniq
end
end
|
#unlocked_pods ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/cocoapods/command/outdated.rb', line 94
def unlocked_pods
@unlocked_pods ||= begin
pods = []
UI.titled_section('Analyzing dependencies') do
pods = Installer::Analyzer.new(config.sandbox, config.podfile).
analyze(:outdated).
specs_by_target.values.flatten.uniq
end
pods
end
end
|
#updates ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/cocoapods/command/outdated.rb', line 76
def updates
@updates ||= begin
ensure_external_podspecs_present!
spec_sets.map do |set|
spec = set.specification
source_version = set.versions.find { |version| !@ignore_prerelease || !version.prerelease? }
pod_name = spec.root.name
lockfile_version = lockfile.version(pod_name)
if source_version > lockfile_version
matching_spec = unlocked_pods.find { |s| s.name == pod_name }
matching_version =
matching_spec ? matching_spec.version : '(unused)'
[pod_name, lockfile_version, matching_version, source_version]
end
end.compact.uniq
end
end
|