cocoapods-diff 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e20036a25e82e63e799afb07964c14862cd2eb431fb136d2c040acf196fc1753
4
+ data.tar.gz: afa96a35cb251272bcc29059b557a842479c165ba6ff82529fea261c42f6c1c3
5
+ SHA512:
6
+ metadata.gz: a8ea4f66e7bb77a9d3f8a3fa6fc98b30d9f2939967263315d9342939fc8353c5c697d949dc95031ee173c2be832a354264dfcef614902b62e4717dcf6370ac51
7
+ data.tar.gz: 2d127059340ba81f0d955e6663bdde22f50ae1ac0c2bb36554abcce58e2c06c39e1922f4c714da7036e6f8e905c26a5bc38a7900dbb4ed7d1587960d72ae103e
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ spec/test
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cocoapods-diff.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'cocoapods'
8
+
9
+ gem 'mocha'
10
+ gem 'bacon'
11
+ gem 'mocha-on-bacon'
12
+ gem 'prettybacon'
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,116 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-diff (0.7.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ CFPropertyList (3.0.5)
10
+ rexml
11
+ activesupport (6.1.7)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ zeitwerk (~> 2.3)
17
+ addressable (2.8.1)
18
+ public_suffix (>= 2.0.2, < 6.0)
19
+ algoliasearch (1.27.5)
20
+ httpclient (~> 2.8, >= 2.8.3)
21
+ json (>= 1.5.1)
22
+ atomos (0.1.3)
23
+ bacon (1.2.0)
24
+ claide (1.1.0)
25
+ cocoapods (1.11.3)
26
+ addressable (~> 2.8)
27
+ claide (>= 1.0.2, < 2.0)
28
+ cocoapods-core (= 1.11.3)
29
+ cocoapods-deintegrate (>= 1.0.3, < 2.0)
30
+ cocoapods-downloader (>= 1.4.0, < 2.0)
31
+ cocoapods-plugins (>= 1.0.0, < 2.0)
32
+ cocoapods-search (>= 1.0.0, < 2.0)
33
+ cocoapods-trunk (>= 1.4.0, < 2.0)
34
+ cocoapods-try (>= 1.1.0, < 2.0)
35
+ colored2 (~> 3.1)
36
+ escape (~> 0.0.4)
37
+ fourflusher (>= 2.3.0, < 3.0)
38
+ gh_inspector (~> 1.0)
39
+ molinillo (~> 0.8.0)
40
+ nap (~> 1.0)
41
+ ruby-macho (>= 1.0, < 3.0)
42
+ xcodeproj (>= 1.21.0, < 2.0)
43
+ cocoapods-core (1.11.3)
44
+ activesupport (>= 5.0, < 7)
45
+ addressable (~> 2.8)
46
+ algoliasearch (~> 1.0)
47
+ concurrent-ruby (~> 1.1)
48
+ fuzzy_match (~> 2.0.4)
49
+ nap (~> 1.0)
50
+ netrc (~> 0.11)
51
+ public_suffix (~> 4.0)
52
+ typhoeus (~> 1.0)
53
+ cocoapods-deintegrate (1.0.5)
54
+ cocoapods-downloader (1.6.3)
55
+ cocoapods-plugins (1.0.0)
56
+ nap
57
+ cocoapods-search (1.0.1)
58
+ cocoapods-trunk (1.6.0)
59
+ nap (>= 0.8, < 2.0)
60
+ netrc (~> 0.11)
61
+ cocoapods-try (1.2.0)
62
+ colored2 (3.1.2)
63
+ concurrent-ruby (1.1.10)
64
+ escape (0.0.4)
65
+ ethon (0.15.0)
66
+ ffi (>= 1.15.0)
67
+ ffi (1.15.5)
68
+ fourflusher (2.3.1)
69
+ fuzzy_match (2.0.4)
70
+ gh_inspector (1.1.3)
71
+ httpclient (2.8.3)
72
+ i18n (1.12.0)
73
+ concurrent-ruby (~> 1.0)
74
+ json (2.6.2)
75
+ minitest (5.16.3)
76
+ mocha (1.16.0)
77
+ mocha-on-bacon (0.2.3)
78
+ mocha (>= 0.13.0)
79
+ molinillo (0.8.0)
80
+ nanaimo (0.3.0)
81
+ nap (1.1.0)
82
+ netrc (0.11.0)
83
+ prettybacon (0.0.2)
84
+ bacon (~> 1.2)
85
+ public_suffix (4.0.7)
86
+ rake (13.0.6)
87
+ rexml (3.2.5)
88
+ ruby-macho (2.5.1)
89
+ typhoeus (1.4.0)
90
+ ethon (>= 0.9.0)
91
+ tzinfo (2.0.5)
92
+ concurrent-ruby (~> 1.0)
93
+ xcodeproj (1.22.0)
94
+ CFPropertyList (>= 2.3.3, < 4.0)
95
+ atomos (~> 0.1.3)
96
+ claide (>= 1.0.2, < 2.0)
97
+ colored2 (~> 3.1)
98
+ nanaimo (~> 0.3.0)
99
+ rexml (~> 3.2.4)
100
+ zeitwerk (2.6.1)
101
+
102
+ PLATFORMS
103
+ ruby
104
+
105
+ DEPENDENCIES
106
+ bacon
107
+ bundler (~> 1.3)
108
+ cocoapods
109
+ cocoapods-diff!
110
+ mocha
111
+ mocha-on-bacon
112
+ prettybacon
113
+ rake
114
+
115
+ BUNDLED WITH
116
+ 1.17.2
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2022 Israel Soto <israel.spgh@gmail.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # cocoapods-diff
2
+
3
+ A Cocoapods plugin that shows the diff between two versions of a pod.
4
+
5
+ It can generate a markdown showing the diff or create the Podfile for the specified versions including all the subspecs and its dependencies.
6
+
7
+ ## Installation
8
+
9
+ $ gem install cocoapods-diff
10
+
11
+ ## Usage
12
+
13
+ $ pod diff POD_NAME OLDER_VERSION NEWER_VERSION
14
+
15
+ You can pass some flags and options to generate the diff as a markdown or a Podfile:
16
+
17
+ | Option name | Description |
18
+ |---|---|
19
+ | `--regex` | Interpret the `POD_NAME` as a regular expression |
20
+ | `--include-dependencies` | Include dependencies in diff. |
21
+ | `--platforms` | Platforms to be compared. If not set, all platforms will be compared. Example: `--platforms=ios,tvos` |
22
+ | `--markdown` | Output a markdown file with diffs. Example: `--markdown=path/to/save/markdown_name.md` |
23
+ | `--older-podfile` | Output a Podfile with the newer's versions. Example: `--older-podfile=path/to/save/Podfile_name` |
24
+ | `--newer-podfile` | Output a Podfile with the older's versions. Example: `--newer-podfile=path/to/save/Podfile_name` |
25
+
26
+ If no Markdown or Podfile options are passed, the output will be printed on console.
27
+
28
+ ## Example
29
+
30
+ Running the following command:
31
+
32
+ $ pod diff Firebase 6.0.0 10.0.0 --platforms=ios,tvos
33
+
34
+ will generate the following output:
35
+
36
+ # Firebase
37
+
38
+ ## ios 6.0.0 vs. 10.0.0
39
+
40
+ | Name | Minimum Supported Version | Name | Minimum Supported Version |
41
+ |-------------------------------------:|:--------------------------|-------------------------------------:|:--------------------------|
42
+ | Firebase/Core | 8.0 | Firebase/Core | 10.0 |
43
+ | Firebase/CoreOnly | 8.0 | Firebase/CoreOnly | 10.0 |
44
+ | Firebase/Analytics | 8.0 | Firebase/Analytics | 10.0 |
45
+ | | | Firebase/AnalyticsWithAdIdSupport | 10.0 |
46
+ | | | Firebase/AnalyticsWithoutAdIdSupport | 10.0 |
47
+ | Firebase/ABTesting | 8.0 | Firebase/ABTesting | 11.0 |
48
+ | | | Firebase/AppDistribution | 11.0 |
49
+ | | | Firebase/AppCheck | 11.0 |
50
+ | Firebase/Auth | 8.0 | Firebase/Auth | 11.0 |
51
+ | | | Firebase/Crashlytics | 11.0 |
52
+ | Firebase/Database | 8.0 | Firebase/Database | 11.0 |
53
+ | Firebase/DynamicLinks | 8.0 | Firebase/DynamicLinks | 11.0 |
54
+ | Firebase/Firestore | 8.0 | Firebase/Firestore | 11.0 |
55
+ | Firebase/Functions | 8.0 | Firebase/Functions | 11.0 |
56
+ | Firebase/InAppMessaging | 8.0 | Firebase/InAppMessaging | 11.0 |
57
+ | | | Firebase/Installations | 10.0 |
58
+ | Firebase/Messaging | 8.0 | Firebase/Messaging | 11.0 |
59
+ | | | Firebase/MLModelDownloader | 11.0 |
60
+ | Firebase/Performance | 8.0 | Firebase/Performance | 11.0 |
61
+ | Firebase/RemoteConfig | 8.0 | Firebase/RemoteConfig | 11.0 |
62
+ | Firebase/Storage | 8.0 | Firebase/Storage | 11.0 |
63
+ | Firebase/MLCommon | 9.0 | | |
64
+ | Firebase/MLModelInterpreter | 9.0 | | |
65
+ | Firebase/MLNLLanguageID | 9.0 | | |
66
+ | Firebase/MLNLSmartReply | 9.0 | | |
67
+ | Firebase/MLNLTranslate | 9.0 | | |
68
+ | Firebase/MLNaturalLanguage | 9.0 | | |
69
+ | Firebase/MLVision | 9.0 | | |
70
+ | Firebase/MLVisionAutoML | 9.0 | | |
71
+ | Firebase/MLVisionBarcodeModel | 9.0 | | |
72
+ | Firebase/MLVisionFaceModel | 9.0 | | |
73
+ | Firebase/MLVisionLabelModel | 9.0 | | |
74
+ | Firebase/MLVisionObjectDetection | 9.0 | | |
75
+ | Firebase/MLVisionTextModel | 9.0 | | |
76
+ | Firebase/InAppMessagingDisplay | 8.0 | | |
77
+ | Firebase/AdMob | 8.0 | | |
78
+
79
+
80
+ ## tvos 6.0.0 vs. 10.0.0
81
+
82
+ | Name | Minimum Supported Version | Name | Minimum Supported Version |
83
+ |-------------------------------------:|:--------------------------|-------------------------------------:|:--------------------------|
84
+ | | | Firebase/Core | 12.0 |
85
+ | | | Firebase/CoreOnly | 12.0 |
86
+ | | | Firebase/Analytics | 12.0 |
87
+ | | | Firebase/AnalyticsWithAdIdSupport | 12.0 |
88
+ | | | Firebase/AnalyticsWithoutAdIdSupport | 12.0 |
89
+ | | | Firebase/ABTesting | 12.0 |
90
+ | | | Firebase/AppCheck | 12.0 |
91
+ | | | Firebase/Auth | 12.0 |
92
+ | | | Firebase/Crashlytics | 12.0 |
93
+ | | | Firebase/Database | 12.0 |
94
+ | | | Firebase/Firestore | 12.0 |
95
+ | | | Firebase/Functions | 12.0 |
96
+ | | | Firebase/InAppMessaging | 12.0 |
97
+ | | | Firebase/Installations | 12.0 |
98
+ | | | Firebase/Messaging | 12.0 |
99
+ | | | Firebase/MLModelDownloader | 12.0 |
100
+ | | | Firebase/Performance | 12.0 |
101
+ | | | Firebase/RemoteConfig | 12.0 |
102
+ | | | Firebase/Storage | 12.0 |
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ def specs(dir)
4
+ FileList["spec/#{dir}/*_spec.rb"].shuffle.join(' ')
5
+ end
6
+
7
+ desc 'Runs all the specs'
8
+ task :specs do
9
+ sh "bundle exec bacon #{specs('**')}"
10
+ end
11
+
12
+ task :default => :specs
13
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cocoapods-diff/version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cocoapods-diff'
8
+ spec.version = CocoapodsDiff::VERSION
9
+ spec.authors = ['Israel Soto']
10
+ spec.email = ['israel.spgh@gmail.com']
11
+ spec.description = CocoapodsDiff::SUMMARY
12
+ spec.summary = CocoapodsDiff::DESCRIPTION
13
+ spec.homepage = 'https://github.com/SotoiGhost/cocoapods-diff'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,249 @@
1
+ require 'cocoapods-diff/version'
2
+ require 'cocoapods-diff/diffinformative'
3
+
4
+ module Pod
5
+ class Command
6
+ class Diff < Command
7
+ require 'pathname'
8
+
9
+ self.summary = CocoapodsDiff::SUMMARY
10
+ self.description = CocoapodsDiff::DESCRIPTION
11
+
12
+ self.arguments = [
13
+ CLAide::Argument.new(CocoapodsDiff::POD_NAME_ARGUMENT_NAME, true, false),
14
+ CLAide::Argument.new(CocoapodsDiff::OLDER_VERSION_ARGUMENT_NAME, true, false),
15
+ CLAide::Argument.new(CocoapodsDiff::NEWER_VERSION_ARGUMENT_NAME, true, false),
16
+ ]
17
+
18
+ def self.options
19
+ [
20
+ ["--#{CocoapodsDiff::REGEX_FLAG_NAME}", "Interpret the `POD_NAME` as a regular expression"],
21
+ ["--#{CocoapodsDiff::INCLUDE_DEPENDENCIES_FLAG_NAME}", "Include dependencies in diff."],
22
+ ["--#{CocoapodsDiff::PLATFORMS_OPTION_NAME}", "Platforms to be compared. If not set, all platforms will be compared. Example: --#{CocoapodsDiff::PLATFORMS_OPTION_NAME}=ios,tvos"],
23
+ ["--#{CocoapodsDiff::MARKDOWN_OPTION_NAME}", "Output a markdown file with diffs. Example: --#{CocoapodsDiff::MARKDOWN_OPTION_NAME}=path/to/save/markdown_name.md"],
24
+ ["--#{CocoapodsDiff::NEWER_PODFILE_OPTION_NAME}", "Output a Podfile with the newer's versions. Example: --#{CocoapodsDiff::NEWER_PODFILE_OPTION_NAME}=path/to/save/Podfile_name"],
25
+ ["--#{CocoapodsDiff::OLDER_PODFILE_OPTION_NAME}", "Output a Podfile with the older's versions. Example: --#{CocoapodsDiff::NEWER_PODFILE_OPTION_NAME}=path/to/save/Podfile_name"]
26
+ ].concat(super)
27
+ end
28
+
29
+ def initialize(argv)
30
+ # Let's get all the command line arguments.
31
+ @pod_name = argv.shift_argument
32
+ @older_version = argv.shift_argument
33
+ @newer_version = argv.shift_argument
34
+ @use_regex = argv.flag?(CocoapodsDiff::REGEX_FLAG_NAME)
35
+ @include_dependencies = argv.flag?(CocoapodsDiff::INCLUDE_DEPENDENCIES_FLAG_NAME)
36
+ @platforms = argv.option(CocoapodsDiff::PLATFORMS_OPTION_NAME, "").split(",")
37
+ @markdown_path = argv.option(CocoapodsDiff::MARKDOWN_OPTION_NAME)
38
+ @newer_podfile_path = argv.option(CocoapodsDiff::NEWER_PODFILE_OPTION_NAME)
39
+ @older_podfile_path = argv.option(CocoapodsDiff::OLDER_PODFILE_OPTION_NAME)
40
+ @print_diff = @markdown_path.nil? && @newer_podfile_path.nil? && @older_podfile_path.nil?
41
+ super
42
+ end
43
+
44
+ def validate!
45
+ super
46
+
47
+ # Valdiate the required arguments.
48
+ help! "A Pod name is required." unless @pod_name
49
+ help! "An old Version is required." unless @older_version
50
+ help! "A new Version is required." unless @newer_version
51
+ help! "Versions should be different." if @older_version === @newer_version
52
+
53
+ # Reverse versions if the newer version is smaller than the older one.
54
+ @older_version, @newer_version = @newer_version, @older_version if Pod::Version.new(@newer_version) < Pod::Version.new(@older_version)
55
+
56
+ # Validate that the Podspecs with the specified versions exist by using the `pod spec which` command.
57
+ # Arguments needed for the command.
58
+ args = [@pod_name]
59
+ args += ["--#{CocoapodsDiff::REGEX_FLAG_NAME}"] if @use_regex
60
+
61
+ # Podspec with the older version validation
62
+ begin
63
+ older_which_spec = Pod::Command::Spec::Which.new CLAide::ARGV.new(args + ["--version=#{@older_version}"])
64
+ older_which_spec.run
65
+ rescue Pod::Informative => e
66
+ raise DiffInformative, "There was a problem trying to locate the pod #{@pod_name} (#{@older_version})\n" +
67
+ "Original error message: #{e.message}"
68
+ end
69
+
70
+ # Podspec with the newer version validation
71
+ begin
72
+ newer_which_spec = Pod::Command::Spec::Which.new CLAide::ARGV.new(args + ["--version=#{@newer_version}"])
73
+ newer_which_spec.run
74
+ rescue Pod::Informative => e
75
+ raise DiffInformative, "There was a problem trying to locate the pod #{@pod_name} (#{@newer_version})\n" +
76
+ "Original error message: #{e.message}"
77
+ end
78
+ end
79
+
80
+ def run
81
+ # As we already validate the arguments provided, it's safe to get the podspecs.
82
+ older_spec = get_specification_for_version(@older_version)
83
+ newer_spec = get_specification_for_version(@newer_version)
84
+
85
+ # Warn the user if there's no subspecs to compare.
86
+ if older_spec.subspecs.empty? && newer_spec.subspecs.empty?
87
+ return UI.warn "There's nothing to compare for #{@pod_name} #{@older_version} vs. #{@newer_version}"
88
+ end
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
+ # Get all the supported platforms without the OS version if no platforms are specified
95
+ @platforms = (newer_spec.available_platforms.map(&:name) | older_spec.available_platforms.map(&:name)) if @platforms.empty?
96
+ @platforms.map! { |platform| Pod::Platform.new(platform) }
97
+
98
+ # Split the subspecs per platform now as we can use them multiple times
99
+ @older_subspecs = {}
100
+ @newer_subspecs = {}
101
+ @platforms.each do |platform|
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
+
110
+ # If no markdown or podfile options are passed, just print the diff on console
111
+ if @print_diff
112
+ return UI.title "Calculating diff" do
113
+ UI.puts generate_diff_table
114
+ end
115
+ end
116
+
117
+ if @markdown_path
118
+ UI.title "Generating the Markdown file at #{@markdown_path}" do
119
+ generate_markdown_file
120
+ end
121
+ end
122
+
123
+ if @newer_podfile_path
124
+ UI.title "Generating the Podfile for #{newer_spec.name} #{newer_spec.version} at #{@newer_podfile_path}" do
125
+ generate_podfile_file(@newer_podfile_path, newer_spec.version, @newer_subspecs)
126
+ end
127
+ end
128
+
129
+ if @older_podfile_path
130
+ UI.title "Generating the Podfile for #{older_spec.name} #{older_spec.version} at #{@older_podfile_path}" do
131
+ generate_podfile_file(@older_podfile_path, older_spec.version, @older_subspecs)
132
+ end
133
+ end
134
+ end
135
+
136
+ private
137
+
138
+ # Gets the podspec for an specific version
139
+ def get_specification_for_version(version)
140
+ query = @use_regex ? @pod_name : Regexp.escape(@pod_name)
141
+ set = config.sources_manager.search_by_name(query).first
142
+ spec_path = set.specification_paths_for_version(Pod::Version.new(version)).first
143
+ Pod::Specification.from_file(spec_path)
144
+ end
145
+
146
+ # Get the dependencies specs of this spec
147
+ def get_dependencies_specs(version, subspecs)
148
+ podfile = podfile(version, subspecs)
149
+ specs = Pod::Installer::Analyzer.new(config.sandbox, podfile).analyze.specs_by_target
150
+
151
+ @platforms.each do |platform|
152
+ key = specs.keys.find { |key| key.name.end_with?(platform.name.to_s) }
153
+ next if key.nil?
154
+ subspecs[platform.name] = specs[key]
155
+ end
156
+ end
157
+
158
+ # Generates the diff table between versions to be printed
159
+ def generate_diff_table
160
+ # TODO: Diff every property between podspecs (:attributes_hash)
161
+
162
+ diff = "# #{@pod_name}\n"
163
+
164
+ @platforms.each do |platform|
165
+ # Get a hash with the needed data: { name: => minimum supported version }
166
+ older_subspecs_data = @older_subspecs[platform.name].each_with_object({}) { |subspec, hash| hash[subspec.name.to_sym] = subspec.deployment_target(platform.name) || "Not defined" }
167
+ newer_subspecs_data = @newer_subspecs[platform.name].each_with_object({}) { |subspec, hash| hash[subspec.name.to_sym] = subspec.deployment_target(platform.name) || "Not defined" }
168
+
169
+ all_names = (newer_subspecs_data.keys | older_subspecs_data.keys)
170
+ name_header = "Name"
171
+ version_header = "Minimum Supported Version"
172
+
173
+ # Calculate the cell length to print a pretty table
174
+ name_cell_length = all_names.max_by(&:length).length
175
+ name_cell_length = [name_cell_length, name_header.length].max
176
+ version_cell_length = (newer_subspecs_data.values | older_subspecs_data.values).max_by(&:length).length
177
+ version_cell_length = [version_cell_length, version_header.length].max
178
+
179
+ # Build the table
180
+ diff += "\n## #{platform.name} #{@older_version} vs. #{@newer_version}\n\n" # Table title
181
+ diff += "| #{name_header.ljust(name_cell_length)} | #{version_header.ljust(version_cell_length)} | #{name_header.ljust(name_cell_length)} | #{version_header.ljust(version_cell_length)} |\n" # Headers
182
+ diff += "|-#{"".ljust(name_cell_length, "-")}:|:#{"".ljust(version_cell_length, "-")}-|-#{"".ljust(name_cell_length, "-")}:|:#{"".ljust(version_cell_length, "-")}-|\n" # Columns aligment
183
+
184
+ # Table body
185
+ all_names.each do |name|
186
+ older_name = older_subspecs_data.keys.include?(name) ? name.to_s : ""
187
+ older_version = older_subspecs_data[name] || ""
188
+ newer_name = newer_subspecs_data.keys.include?(name) ? name.to_s : ""
189
+ newer_version = newer_subspecs_data[name] || ""
190
+
191
+ 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
+ end
193
+
194
+ diff += "\n"
195
+ end
196
+ diff
197
+ end
198
+
199
+ def generate_markdown_file
200
+ markdown_pathname = Pathname.new(@markdown_path)
201
+ markdown_pathname.dirname.mkpath
202
+ markdown_pathname.write(generate_diff_table)
203
+ end
204
+
205
+ def generate_podfile_file(path, version, subspecs)
206
+ podfile = "install! 'cocoapods', integrate_targets: false\n"
207
+ podfile += "use_frameworks!\n"
208
+
209
+ @platforms.each do |platform|
210
+ next if subspecs[platform.name].empty?
211
+ platform_version = subspecs[platform.name].map { |subspec| Pod::Version.new(subspec.deployment_target(platform.name) || "0") }.max
212
+
213
+ podfile += "\ntarget '#{@pod_name}_#{platform.name}' do\n"
214
+ podfile += "\tplatform :#{platform.name}, '#{platform_version}'\n"
215
+ podfile += "\tpod '#{@pod_name}', '#{version}'\n"
216
+
217
+ subspecs[platform.name].each { |subspec| podfile += "\tpod '#{subspec.name}', '#{subspec.version}'\n" }
218
+ podfile += "end\n"
219
+ end
220
+
221
+ podfile_pathname = Pathname.new(path)
222
+ podfile_pathname.dirname.mkpath
223
+ podfile_pathname.write(podfile)
224
+ 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
+ end
248
+ end
249
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-diff/command/diff'
@@ -0,0 +1,2 @@
1
+ class DiffInformative < Pod::Informative
2
+ end
@@ -0,0 +1,24 @@
1
+ module CocoapodsDiff
2
+ NAME = "cocoapods-diff"
3
+ VERSION = "0.7.0"
4
+ SUMMARY = "Shows the diff between two versions of a pod."
5
+ DESCRIPTION = <<-DESC
6
+ A Cocoapods plugin that shows the diff between two versions of a pod.
7
+ It can generate a markdown showing the diff or create the Podfile for the specified versions including all the subspecs and its dependencies.
8
+ DESC
9
+
10
+ # CLAide Arguments
11
+ POD_NAME_ARGUMENT_NAME = "POD_NAME"
12
+ OLDER_VERSION_ARGUMENT_NAME = "OLDER_VERSION"
13
+ NEWER_VERSION_ARGUMENT_NAME = "NEWER_VERSION"
14
+
15
+ # CLAide Flags
16
+ REGEX_FLAG_NAME = "regex"
17
+ INCLUDE_DEPENDENCIES_FLAG_NAME = "include-dependencies"
18
+
19
+ # CLAide Options
20
+ PLATFORMS_OPTION_NAME = "platforms"
21
+ MARKDOWN_OPTION_NAME = "markdown"
22
+ OLDER_PODFILE_OPTION_NAME = "older-podfile"
23
+ NEWER_PODFILE_OPTION_NAME = "newer-podfile"
24
+ end
@@ -0,0 +1 @@
1
+ require 'cocoapods-diff/version'
@@ -0,0 +1 @@
1
+ require 'cocoapods-diff/command'
@@ -0,0 +1,158 @@
1
+ require File.expand_path("../../spec_helper", __FILE__)
2
+ require 'cocoapods-diff/version.rb'
3
+
4
+ module Pod
5
+ describe Command::Diff do
6
+ describe "CLAide" do
7
+ it "registers it self" do
8
+ Command.parse(%w{ diff }).should.be.instance_of Command::Diff
9
+ end
10
+
11
+ describe "Validate the command" do
12
+ it "is well-formed" do
13
+ lambda { Command.parse(%w{ diff Firebase 9.0.0 10.0.0 }).validate! }
14
+ .should.not.raise()
15
+ end
16
+
17
+ it "fails when a pod name is missing" do
18
+ lambda { Command.parse(%w{ diff }).validate! }
19
+ .should.raise(CLAide::Help)
20
+ .message.should.match(/A Pod name is required./)
21
+ end
22
+
23
+ it "fails when a version is missing" do
24
+ lambda { Command.parse(%w{ diff Firebase }).validate! }
25
+ .should.raise(CLAide::Help)
26
+ .message.should.match(/An old Version is required./)
27
+ end
28
+
29
+ it "fails when a version to compare is missing" do
30
+ lambda { Command.parse(%w{ diff Firebase 10.0.0 }).validate! }
31
+ .should.raise(CLAide::Help)
32
+ .message.should.match(/A new Version is required./)
33
+ end
34
+
35
+ it "fails when versions are the same" do
36
+ lambda { Command.parse(%w{ diff Firebase 10.0.0 10.0.0 }).validate! }
37
+ .should.raise(CLAide::Help)
38
+ .message.should.match(/Versions should be different./)
39
+ end
40
+
41
+ it "fails when a non-existing version is passed" do
42
+ lambda { Command.parse(%w{ diff Firebase 10.0.0 1.0.0-beta1 }).validate! }
43
+ .should.raise(DiffInformative)
44
+ end
45
+
46
+ it "fails when a more than one pod is found" do
47
+ lambda { Command.parse(%w{ diff Fire 10.0.0 9.0.0 }).validate! }
48
+ .should.raise(DiffInformative)
49
+ end
50
+ end
51
+
52
+ describe "Test the command" do
53
+ it "returns a warning if there's nothing to compare" do
54
+ diff = Command.parse(%W{ diff GooglePlaces 6.0.0 7.0.0 })
55
+ diff.validate!
56
+ diff.run.should.match(/There's nothing to compare/)
57
+ end
58
+
59
+ it "returns the diff as string" do
60
+ diff = Command.parse(%w{ diff Firebase 6.0.0 10.0.0 })
61
+ diff.validate!
62
+ result = diff.run
63
+ result.should.be.instance_of String
64
+ result.should.not.be.empty?
65
+ end
66
+
67
+ it "generates the diff as markdown" do
68
+ require 'pathname'
69
+ markdown_pathname = Pathname.new("spec/test/Firebase.md")
70
+ diff = Command.parse(%W{ diff Firebase 6.0.0 10.0.0 --#{CocoapodsDiff::MARKDOWN_OPTION_NAME}=#{markdown_pathname} })
71
+ diff.validate!
72
+ diff.run
73
+ markdown_pathname.exist?.should.be.true?
74
+ markdown_pathname.empty?.should.be.false?
75
+ end
76
+
77
+ it "generates the newer Podfile" do
78
+ require 'pathname'
79
+ podfile_pathname = Pathname.new("spec/test/Podfile_newer")
80
+ diff = Command.parse(%W{ diff Firebase 6.0.0 10.0.0 --#{CocoapodsDiff::NEWER_PODFILE_OPTION_NAME}=#{podfile_pathname} })
81
+ diff.validate!
82
+ diff.run
83
+ podfile_pathname.exist?.should.be.true?
84
+ podfile_pathname.empty?.should.be.false?
85
+ end
86
+
87
+ it "generates the older Podfile" do
88
+ require 'pathname'
89
+ podfile_pathname = Pathname.new("spec/test/Podfile_older")
90
+ diff = Command.parse(%W{ diff Firebase 6.0.0 10.0.0 --#{CocoapodsDiff::OLDER_PODFILE_OPTION_NAME}=#{podfile_pathname} })
91
+ diff.validate!
92
+ diff.run
93
+ podfile_pathname.exist?.should.be.true?
94
+ podfile_pathname.empty?.should.be.false?
95
+ end
96
+
97
+ it "generates both Podfiles" do
98
+ require 'pathname'
99
+ newer_podfile_pathname = Pathname.new("spec/test/Podfile_newer")
100
+ older_podfile_pathname = Pathname.new("spec/test/Podfile_older")
101
+ diff = Command.parse(%W{ diff Firebase 6.0.0 10.0.0 --#{CocoapodsDiff::NEWER_PODFILE_OPTION_NAME}=#{newer_podfile_pathname} --#{CocoapodsDiff::OLDER_PODFILE_OPTION_NAME}=#{older_podfile_pathname} })
102
+ diff.validate!
103
+ diff.run
104
+ newer_podfile_pathname.exist?.should.be.true?
105
+ newer_podfile_pathname.empty?.should.be.false?
106
+ older_podfile_pathname.exist?.should.be.true?
107
+ older_podfile_pathname.empty?.should.be.false?
108
+ end
109
+
110
+ it "generates Markdown and Podfiles" do
111
+ require 'pathname'
112
+ markdown_pathname = Pathname.new("spec/test/Firebase.md")
113
+ newer_podfile_pathname = Pathname.new("spec/test/Podfile_newer")
114
+ older_podfile_pathname = Pathname.new("spec/test/Podfile_older")
115
+ diff = Command.parse(%W{ diff Firebase 6.0.0 10.0.0 --#{CocoapodsDiff::MARKDOWN_OPTION_NAME}=#{markdown_pathname} --#{CocoapodsDiff::NEWER_PODFILE_OPTION_NAME}=#{newer_podfile_pathname} --#{CocoapodsDiff::OLDER_PODFILE_OPTION_NAME}=#{older_podfile_pathname} })
116
+ diff.validate!
117
+ diff.run
118
+ markdown_pathname.exist?.should.be.true?
119
+ markdown_pathname.empty?.should.be.false?
120
+ newer_podfile_pathname.exist?.should.be.true?
121
+ newer_podfile_pathname.empty?.should.be.false?
122
+ older_podfile_pathname.exist?.should.be.true?
123
+ older_podfile_pathname.empty?.should.be.false?
124
+ end
125
+
126
+ it "generates the diff with dependencies as markdown" do
127
+ require 'pathname'
128
+ markdown_pathname = Pathname.new("spec/test/Firebase_with_dependencies.md")
129
+ diff = Command.parse(%W{ diff Firebase 10.0.0 6.0.0 --#{CocoapodsDiff::INCLUDE_DEPENDENCIES_FLAG_NAME} --#{CocoapodsDiff::MARKDOWN_OPTION_NAME}=#{markdown_pathname} })
130
+ diff.validate!
131
+ diff.run
132
+ markdown_pathname.exist?.should.be.true?
133
+ markdown_pathname.empty?.should.be.false?
134
+ end
135
+
136
+ it "generates the newer Podfile with dependencies" do
137
+ require 'pathname'
138
+ podfile_pathname = Pathname.new("spec/test/Podfile_newer_with_dependencies")
139
+ diff = Command.parse(%W{ diff Firebase 6.0.0 10.0.0 --#{CocoapodsDiff::INCLUDE_DEPENDENCIES_FLAG_NAME} --#{CocoapodsDiff::NEWER_PODFILE_OPTION_NAME}=#{podfile_pathname} })
140
+ diff.validate!
141
+ diff.run
142
+ podfile_pathname.exist?.should.be.true?
143
+ podfile_pathname.empty?.should.be.false?
144
+ end
145
+
146
+ it "generates the older Podfile with dependencies" do
147
+ require 'pathname'
148
+ podfile_pathname = Pathname.new("spec/test/Podfile_older_with_dependencies")
149
+ diff = Command.parse(%W{ diff Firebase 6.0.0 10.0.0 --#{CocoapodsDiff::INCLUDE_DEPENDENCIES_FLAG_NAME} --#{CocoapodsDiff::OLDER_PODFILE_OPTION_NAME}=#{podfile_pathname} })
150
+ diff.validate!
151
+ diff.run
152
+ podfile_pathname.exist?.should.be.true?
153
+ podfile_pathname.empty?.should.be.false?
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,50 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $:.unshift((ROOT + 'lib').to_s)
4
+ $:.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'bacon'
8
+ require 'mocha-on-bacon'
9
+ require 'pretty_bacon'
10
+ require 'pathname'
11
+ require 'cocoapods'
12
+
13
+ Mocha::Configuration.prevent(:stubbing_non_existent_method)
14
+
15
+ require 'cocoapods_plugin'
16
+
17
+ #-----------------------------------------------------------------------------#
18
+
19
+ module Pod
20
+
21
+ # Disable the wrapping so the output is deterministic in the tests.
22
+ #
23
+ UI.disable_wrap = true
24
+
25
+ # Redirects the messages to an internal store.
26
+ #
27
+ module UI
28
+ @output = ''
29
+ @warnings = ''
30
+
31
+ class << self
32
+ attr_accessor :output
33
+ attr_accessor :warnings
34
+
35
+ def puts(message = '')
36
+ @output << "#{message}\n"
37
+ end
38
+
39
+ def warn(message = '', actions = [])
40
+ @warnings << "#{message}\n"
41
+ end
42
+
43
+ def print(message)
44
+ @output << message
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ #-----------------------------------------------------------------------------#
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cocoapods-diff
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.0
5
+ platform: ruby
6
+ authors:
7
+ - Israel Soto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-12-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Shows the diff between two versions of a pod.
42
+ email:
43
+ - israel.spgh@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - cocoapods-diff.gemspec
55
+ - lib/cocoapods-diff.rb
56
+ - lib/cocoapods-diff/command.rb
57
+ - lib/cocoapods-diff/command/diff.rb
58
+ - lib/cocoapods-diff/diffinformative.rb
59
+ - lib/cocoapods-diff/version.rb
60
+ - lib/cocoapods_plugin.rb
61
+ - spec/command/diff_spec.rb
62
+ - spec/spec_helper.rb
63
+ homepage: https://github.com/SotoiGhost/cocoapods-diff
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.0.3.1
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: A Cocoapods plugin that shows the diff between two versions of a pod. It
86
+ can generate a markdown showing the diff or create the Podfile for the specified
87
+ versions including all the subspecs and its dependencies.
88
+ test_files:
89
+ - spec/command/diff_spec.rb
90
+ - spec/spec_helper.rb