cocoapods-diff 0.7.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/cocoapods-diff/command/diff.rb +78 -63
- data/lib/cocoapods-diff/version.rb +1 -1
- data/spec/command/diff_spec.rb +21 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b5d0be0fabd5ac9f98da7c16ad1551f0d88055650f5d26ae6184222f1b6540f
|
4
|
+
data.tar.gz: 56b824d32444602b34a788a703ca406915503e074413f13810a68f3436f3c589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac146c4f9ed43e4d8d958dd532c4db5c2d687a469571233d2d1b240ecb417521f08c31f4023dfb24dc83d702346cf0ee72d45134f2af74aa70d4cef0a5913113
|
7
|
+
data.tar.gz: d53e168a1bd4f683a2a4108e912993fb613c6e7c0a66be94d2f47c0e8c6e7a2c362c163b8cc18ad284c817e3e1b9ac2a470d70b206c4cf9dbbd0bb5ce5d75b74
|
data/Gemfile.lock
CHANGED
@@ -82,31 +82,19 @@ module Pod
|
|
82
82
|
older_spec = get_specification_for_version(@older_version)
|
83
83
|
newer_spec = get_specification_for_version(@newer_version)
|
84
84
|
|
85
|
-
# Warn the user if there's no subspecs to compare.
|
86
|
-
if older_spec.subspecs.empty? && newer_spec.subspecs.empty?
|
85
|
+
# Warn the user if there's no subspecs or dependencies to compare.
|
86
|
+
if older_spec.subspecs.empty? && older_spec.dependencies.empty? && newer_spec.subspecs.empty? && newer_spec.dependencies.empty?
|
87
87
|
return UI.warn "There's nothing to compare for #{@pod_name} #{@older_version} vs. #{@newer_version}"
|
88
88
|
end
|
89
89
|
|
90
|
-
# Remove the default subspecs value to compare all the subspecs if any
|
91
|
-
older_spec.default_subspecs = []
|
92
|
-
newer_spec.default_subspecs = []
|
93
|
-
|
94
90
|
# Get all the supported platforms without the OS version if no platforms are specified
|
95
91
|
@platforms = (newer_spec.available_platforms.map(&:name) | older_spec.available_platforms.map(&:name)) if @platforms.empty?
|
96
92
|
@platforms.map! { |platform| Pod::Platform.new(platform) }
|
97
93
|
|
98
|
-
#
|
99
|
-
@
|
100
|
-
@
|
101
|
-
|
102
|
-
@older_subspecs[platform.name] = older_spec.subspecs.select { |s| s.supported_on_platform?(platform) }
|
103
|
-
@newer_subspecs[platform.name] = newer_spec.subspecs.select { |s| s.supported_on_platform?(platform) }
|
104
|
-
end
|
105
|
-
|
106
|
-
# Get the dependencies specs of this spec
|
107
|
-
get_dependencies_specs(@older_version, @older_subspecs) if @include_dependencies
|
108
|
-
get_dependencies_specs(@newer_version, @newer_subspecs) if @include_dependencies
|
109
|
-
|
94
|
+
# Let cocoapods resolve the dependencies for a spec
|
95
|
+
@older_specs = resolve_dependencies_for_spec(older_spec)
|
96
|
+
@newer_specs = resolve_dependencies_for_spec(newer_spec)
|
97
|
+
|
110
98
|
# If no markdown or podfile options are passed, just print the diff on console
|
111
99
|
if @print_diff
|
112
100
|
return UI.title "Calculating diff" do
|
@@ -122,13 +110,13 @@ module Pod
|
|
122
110
|
|
123
111
|
if @newer_podfile_path
|
124
112
|
UI.title "Generating the Podfile for #{newer_spec.name} #{newer_spec.version} at #{@newer_podfile_path}" do
|
125
|
-
generate_podfile_file(
|
113
|
+
generate_podfile_file(newer_spec, @newer_specs, @newer_podfile_path)
|
126
114
|
end
|
127
115
|
end
|
128
116
|
|
129
117
|
if @older_podfile_path
|
130
118
|
UI.title "Generating the Podfile for #{older_spec.name} #{older_spec.version} at #{@older_podfile_path}" do
|
131
|
-
generate_podfile_file(
|
119
|
+
generate_podfile_file(older_spec, @older_specs, @older_podfile_path)
|
132
120
|
end
|
133
121
|
end
|
134
122
|
end
|
@@ -140,18 +128,66 @@ module Pod
|
|
140
128
|
query = @use_regex ? @pod_name : Regexp.escape(@pod_name)
|
141
129
|
set = config.sources_manager.search_by_name(query).first
|
142
130
|
spec_path = set.specification_paths_for_version(Pod::Version.new(version)).first
|
143
|
-
Pod::Specification.from_file(spec_path)
|
131
|
+
spec = Pod::Specification.from_file(spec_path)
|
132
|
+
|
133
|
+
# Remove the default subspecs value to compare all the subspecs if any
|
134
|
+
spec.default_subspecs = []
|
135
|
+
spec
|
144
136
|
end
|
145
137
|
|
146
|
-
#
|
147
|
-
def
|
148
|
-
|
149
|
-
|
138
|
+
# Resolve all the dependencies specs needed for this spec
|
139
|
+
def resolve_dependencies_for_spec(spec)
|
140
|
+
# Get all the subspecs of the spec
|
141
|
+
specs_by_platform = {}
|
142
|
+
@platforms.each do |platform|
|
143
|
+
specs_by_platform[platform.name] = spec.recursive_subspecs.select { |s| s.supported_on_platform?(platform) }
|
144
|
+
end
|
145
|
+
|
146
|
+
podfile = podfile(spec, specs_by_platform)
|
147
|
+
resolved_specs = Pod::Installer::Analyzer.new(config.sandbox, podfile).analyze.specs_by_target
|
150
148
|
|
151
149
|
@platforms.each do |platform|
|
152
|
-
key =
|
150
|
+
key = resolved_specs.keys.find { |key| key.name.end_with?(platform.name.to_s) }
|
153
151
|
next if key.nil?
|
154
|
-
|
152
|
+
|
153
|
+
if @include_dependencies
|
154
|
+
specs_by_platform[platform.name] = resolved_specs[key]
|
155
|
+
else
|
156
|
+
pod_names = [spec.name]
|
157
|
+
pod_names += spec.dependencies(platform).map(&:name)
|
158
|
+
pod_names += specs_by_platform[platform.name].map(&:name)
|
159
|
+
pod_names += specs_by_platform[platform.name].map { |spec| spec.dependencies(platform).map(&:name) }.flatten
|
160
|
+
pod_names = pod_names.uniq
|
161
|
+
|
162
|
+
specs_by_platform[platform.name] = resolved_specs[key].select { |spec| pod_names.include?(spec.name) }
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
specs_by_platform
|
167
|
+
end
|
168
|
+
|
169
|
+
def podfile(spec, specs_by_platform)
|
170
|
+
ps = @platforms
|
171
|
+
pod_name = spec.name
|
172
|
+
pod_version = spec.version.to_s
|
173
|
+
|
174
|
+
Pod::Podfile.new do
|
175
|
+
install! 'cocoapods', integrate_targets: false
|
176
|
+
use_frameworks!
|
177
|
+
|
178
|
+
ps.each do |p|
|
179
|
+
next if not spec.supported_on_platform?(p)
|
180
|
+
|
181
|
+
platform_version = [Pod::Version.new(spec.deployment_target(p.name) || "0")]
|
182
|
+
platform_version += specs_by_platform[p.name].map { |spec| Pod::Version.new(spec.deployment_target(p.name) || "0") }
|
183
|
+
platform_version = platform_version.max
|
184
|
+
|
185
|
+
target "#{pod_name}_#{p.name}" do
|
186
|
+
platform p.name, platform_version
|
187
|
+
pod pod_name, pod_version
|
188
|
+
specs_by_platform[p.name].each { |spec| pod spec.name, spec.version } if not specs_by_platform[p.name].empty?
|
189
|
+
end
|
190
|
+
end
|
155
191
|
end
|
156
192
|
end
|
157
193
|
|
@@ -163,17 +199,17 @@ module Pod
|
|
163
199
|
|
164
200
|
@platforms.each do |platform|
|
165
201
|
# Get a hash with the needed data: { name: => minimum supported version }
|
166
|
-
|
167
|
-
|
202
|
+
older_specs_data = @older_specs[platform.name].each_with_object({}) { |subspec, hash| hash[subspec.name.to_sym] = subspec.deployment_target(platform.name) || "Not defined" }
|
203
|
+
newer_specs_data = @newer_specs[platform.name].each_with_object({}) { |subspec, hash| hash[subspec.name.to_sym] = subspec.deployment_target(platform.name) || "Not defined" }
|
168
204
|
|
169
|
-
all_names = (
|
205
|
+
all_names = (newer_specs_data.keys | older_specs_data.keys)
|
170
206
|
name_header = "Name"
|
171
207
|
version_header = "Minimum Supported Version"
|
172
208
|
|
173
209
|
# Calculate the cell length to print a pretty table
|
174
210
|
name_cell_length = all_names.max_by(&:length).length
|
175
211
|
name_cell_length = [name_cell_length, name_header.length].max
|
176
|
-
version_cell_length = (
|
212
|
+
version_cell_length = (newer_specs_data.values | older_specs_data.values).max_by(&:length).length
|
177
213
|
version_cell_length = [version_cell_length, version_header.length].max
|
178
214
|
|
179
215
|
# Build the table
|
@@ -183,10 +219,10 @@ module Pod
|
|
183
219
|
|
184
220
|
# Table body
|
185
221
|
all_names.each do |name|
|
186
|
-
older_name =
|
187
|
-
older_version =
|
188
|
-
newer_name =
|
189
|
-
newer_version =
|
222
|
+
older_name = older_specs_data.keys.include?(name) ? name.to_s : ""
|
223
|
+
older_version = older_specs_data[name] || ""
|
224
|
+
newer_name = newer_specs_data.keys.include?(name) ? name.to_s : ""
|
225
|
+
newer_version = newer_specs_data[name] || ""
|
190
226
|
|
191
227
|
diff += "| #{older_name.ljust(name_cell_length)} | #{older_version.ljust(version_cell_length)} | #{newer_name.ljust(name_cell_length)} | #{newer_version.ljust(version_cell_length)} |\n"
|
192
228
|
end
|
@@ -202,19 +238,20 @@ module Pod
|
|
202
238
|
markdown_pathname.write(generate_diff_table)
|
203
239
|
end
|
204
240
|
|
205
|
-
def generate_podfile_file(
|
241
|
+
def generate_podfile_file(spec, specs_by_platform, path)
|
206
242
|
podfile = "install! 'cocoapods', integrate_targets: false\n"
|
207
243
|
podfile += "use_frameworks!\n"
|
208
244
|
|
209
245
|
@platforms.each do |platform|
|
210
|
-
next if
|
211
|
-
|
246
|
+
next if not spec.supported_on_platform?(platform)
|
247
|
+
|
248
|
+
platform_version = [Pod::Version.new(spec.deployment_target(platform.name) || "0")]
|
249
|
+
platform_version += specs_by_platform[platform.name].map { |spec| Pod::Version.new(spec.deployment_target(platform.name) || "0") }
|
250
|
+
platform_version = platform_version.max
|
212
251
|
|
213
252
|
podfile += "\ntarget '#{@pod_name}_#{platform.name}' do\n"
|
214
253
|
podfile += "\tplatform :#{platform.name}, '#{platform_version}'\n"
|
215
|
-
podfile += "\tpod '#{
|
216
|
-
|
217
|
-
subspecs[platform.name].each { |subspec| podfile += "\tpod '#{subspec.name}', '#{subspec.version}'\n" }
|
254
|
+
specs_by_platform[platform.name].each { |spec| podfile += "\tpod '#{spec.name}', '#{spec.version}'\n" } if not specs_by_platform[platform.name].empty?
|
218
255
|
podfile += "end\n"
|
219
256
|
end
|
220
257
|
|
@@ -222,28 +259,6 @@ module Pod
|
|
222
259
|
podfile_pathname.dirname.mkpath
|
223
260
|
podfile_pathname.write(podfile)
|
224
261
|
end
|
225
|
-
|
226
|
-
def podfile(version, subspecs)
|
227
|
-
ps = @platforms
|
228
|
-
pod_name = @pod_name
|
229
|
-
|
230
|
-
Pod::Podfile.new do
|
231
|
-
install! 'cocoapods', integrate_targets: false
|
232
|
-
use_frameworks!
|
233
|
-
|
234
|
-
ps.each do |p|
|
235
|
-
next if subspecs[p.name].empty?
|
236
|
-
platform_version = subspecs[p.name].map { |subspec| subspec.deployment_target(p.name) }.max
|
237
|
-
|
238
|
-
target "#{pod_name}_#{p.name}" do
|
239
|
-
platform p.name, platform_version
|
240
|
-
pod pod_name, version
|
241
|
-
subspecs[p.name].each { |subspec| pod subspec.name, subspec.version }
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
262
|
end
|
248
263
|
end
|
249
264
|
end
|
data/spec/command/diff_spec.rb
CHANGED
@@ -2,49 +2,53 @@ require File.expand_path("../../spec_helper", __FILE__)
|
|
2
2
|
require 'cocoapods-diff/version.rb'
|
3
3
|
|
4
4
|
module Pod
|
5
|
+
POD_NAME = "Firebase"
|
6
|
+
OLDER_VERSION = "6.0.0"
|
7
|
+
NEWER_VERSION = "10.0.0"
|
8
|
+
|
5
9
|
describe Command::Diff do
|
6
10
|
describe "CLAide" do
|
7
11
|
it "registers it self" do
|
8
|
-
Command.parse(%
|
12
|
+
Command.parse(%W{ diff }).should.be.instance_of Command::Diff
|
9
13
|
end
|
10
14
|
|
11
15
|
describe "Validate the command" do
|
12
16
|
it "is well-formed" do
|
13
|
-
lambda { Command.parse(%
|
17
|
+
lambda { Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} #{NEWER_VERSION} }).validate! }
|
14
18
|
.should.not.raise()
|
15
19
|
end
|
16
20
|
|
17
21
|
it "fails when a pod name is missing" do
|
18
|
-
lambda { Command.parse(%
|
22
|
+
lambda { Command.parse(%W{ diff }).validate! }
|
19
23
|
.should.raise(CLAide::Help)
|
20
24
|
.message.should.match(/A Pod name is required./)
|
21
25
|
end
|
22
26
|
|
23
27
|
it "fails when a version is missing" do
|
24
|
-
lambda { Command.parse(%
|
28
|
+
lambda { Command.parse(%W{ diff #{POD_NAME} }).validate! }
|
25
29
|
.should.raise(CLAide::Help)
|
26
30
|
.message.should.match(/An old Version is required./)
|
27
31
|
end
|
28
32
|
|
29
33
|
it "fails when a version to compare is missing" do
|
30
|
-
lambda { Command.parse(%
|
34
|
+
lambda { Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} }).validate! }
|
31
35
|
.should.raise(CLAide::Help)
|
32
36
|
.message.should.match(/A new Version is required./)
|
33
37
|
end
|
34
38
|
|
35
39
|
it "fails when versions are the same" do
|
36
|
-
lambda { Command.parse(%
|
40
|
+
lambda { Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} #{OLDER_VERSION} }).validate! }
|
37
41
|
.should.raise(CLAide::Help)
|
38
42
|
.message.should.match(/Versions should be different./)
|
39
43
|
end
|
40
44
|
|
41
45
|
it "fails when a non-existing version is passed" do
|
42
|
-
lambda { Command.parse(%
|
46
|
+
lambda { Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} 1.0.0-beta1 }).validate! }
|
43
47
|
.should.raise(DiffInformative)
|
44
48
|
end
|
45
49
|
|
46
50
|
it "fails when a more than one pod is found" do
|
47
|
-
lambda { Command.parse(%
|
51
|
+
lambda { Command.parse(%W{ diff Fire #{OLDER_VERSION} 9.0.0 }).validate! }
|
48
52
|
.should.raise(DiffInformative)
|
49
53
|
end
|
50
54
|
end
|
@@ -57,7 +61,7 @@ module Pod
|
|
57
61
|
end
|
58
62
|
|
59
63
|
it "returns the diff as string" do
|
60
|
-
diff = Command.parse(%
|
64
|
+
diff = Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} #{NEWER_VERSION} })
|
61
65
|
diff.validate!
|
62
66
|
result = diff.run
|
63
67
|
result.should.be.instance_of String
|
@@ -67,7 +71,7 @@ module Pod
|
|
67
71
|
it "generates the diff as markdown" do
|
68
72
|
require 'pathname'
|
69
73
|
markdown_pathname = Pathname.new("spec/test/Firebase.md")
|
70
|
-
diff = Command.parse(%W{ diff
|
74
|
+
diff = Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} #{NEWER_VERSION} --#{CocoapodsDiff::MARKDOWN_OPTION_NAME}=#{markdown_pathname} })
|
71
75
|
diff.validate!
|
72
76
|
diff.run
|
73
77
|
markdown_pathname.exist?.should.be.true?
|
@@ -77,7 +81,7 @@ module Pod
|
|
77
81
|
it "generates the newer Podfile" do
|
78
82
|
require 'pathname'
|
79
83
|
podfile_pathname = Pathname.new("spec/test/Podfile_newer")
|
80
|
-
diff = Command.parse(%W{ diff
|
84
|
+
diff = Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} #{NEWER_VERSION} --#{CocoapodsDiff::NEWER_PODFILE_OPTION_NAME}=#{podfile_pathname} })
|
81
85
|
diff.validate!
|
82
86
|
diff.run
|
83
87
|
podfile_pathname.exist?.should.be.true?
|
@@ -87,7 +91,7 @@ module Pod
|
|
87
91
|
it "generates the older Podfile" do
|
88
92
|
require 'pathname'
|
89
93
|
podfile_pathname = Pathname.new("spec/test/Podfile_older")
|
90
|
-
diff = Command.parse(%W{ diff
|
94
|
+
diff = Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} #{NEWER_VERSION} --#{CocoapodsDiff::OLDER_PODFILE_OPTION_NAME}=#{podfile_pathname} })
|
91
95
|
diff.validate!
|
92
96
|
diff.run
|
93
97
|
podfile_pathname.exist?.should.be.true?
|
@@ -98,7 +102,7 @@ module Pod
|
|
98
102
|
require 'pathname'
|
99
103
|
newer_podfile_pathname = Pathname.new("spec/test/Podfile_newer")
|
100
104
|
older_podfile_pathname = Pathname.new("spec/test/Podfile_older")
|
101
|
-
diff = Command.parse(%W{ diff
|
105
|
+
diff = Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} #{NEWER_VERSION} --#{CocoapodsDiff::NEWER_PODFILE_OPTION_NAME}=#{newer_podfile_pathname} --#{CocoapodsDiff::OLDER_PODFILE_OPTION_NAME}=#{older_podfile_pathname} })
|
102
106
|
diff.validate!
|
103
107
|
diff.run
|
104
108
|
newer_podfile_pathname.exist?.should.be.true?
|
@@ -112,7 +116,7 @@ module Pod
|
|
112
116
|
markdown_pathname = Pathname.new("spec/test/Firebase.md")
|
113
117
|
newer_podfile_pathname = Pathname.new("spec/test/Podfile_newer")
|
114
118
|
older_podfile_pathname = Pathname.new("spec/test/Podfile_older")
|
115
|
-
diff = Command.parse(%W{ diff
|
119
|
+
diff = Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} #{NEWER_VERSION} --#{CocoapodsDiff::MARKDOWN_OPTION_NAME}=#{markdown_pathname} --#{CocoapodsDiff::NEWER_PODFILE_OPTION_NAME}=#{newer_podfile_pathname} --#{CocoapodsDiff::OLDER_PODFILE_OPTION_NAME}=#{older_podfile_pathname} })
|
116
120
|
diff.validate!
|
117
121
|
diff.run
|
118
122
|
markdown_pathname.exist?.should.be.true?
|
@@ -126,7 +130,7 @@ module Pod
|
|
126
130
|
it "generates the diff with dependencies as markdown" do
|
127
131
|
require 'pathname'
|
128
132
|
markdown_pathname = Pathname.new("spec/test/Firebase_with_dependencies.md")
|
129
|
-
diff = Command.parse(%W{ diff
|
133
|
+
diff = Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} #{NEWER_VERSION} --#{CocoapodsDiff::INCLUDE_DEPENDENCIES_FLAG_NAME} --#{CocoapodsDiff::MARKDOWN_OPTION_NAME}=#{markdown_pathname} })
|
130
134
|
diff.validate!
|
131
135
|
diff.run
|
132
136
|
markdown_pathname.exist?.should.be.true?
|
@@ -136,7 +140,7 @@ module Pod
|
|
136
140
|
it "generates the newer Podfile with dependencies" do
|
137
141
|
require 'pathname'
|
138
142
|
podfile_pathname = Pathname.new("spec/test/Podfile_newer_with_dependencies")
|
139
|
-
diff = Command.parse(%W{ diff
|
143
|
+
diff = Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} #{NEWER_VERSION} --#{CocoapodsDiff::INCLUDE_DEPENDENCIES_FLAG_NAME} --#{CocoapodsDiff::NEWER_PODFILE_OPTION_NAME}=#{podfile_pathname} })
|
140
144
|
diff.validate!
|
141
145
|
diff.run
|
142
146
|
podfile_pathname.exist?.should.be.true?
|
@@ -146,7 +150,7 @@ module Pod
|
|
146
150
|
it "generates the older Podfile with dependencies" do
|
147
151
|
require 'pathname'
|
148
152
|
podfile_pathname = Pathname.new("spec/test/Podfile_older_with_dependencies")
|
149
|
-
diff = Command.parse(%W{ diff
|
153
|
+
diff = Command.parse(%W{ diff #{POD_NAME} #{OLDER_VERSION} #{NEWER_VERSION} --#{CocoapodsDiff::INCLUDE_DEPENDENCIES_FLAG_NAME} --#{CocoapodsDiff::OLDER_PODFILE_OPTION_NAME}=#{podfile_pathname} })
|
150
154
|
diff.validate!
|
151
155
|
diff.run
|
152
156
|
podfile_pathname.exist?.should.be.true?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Israel Soto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|