check_all_depencies 0.1.2 → 0.1.3
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 +4 -4
- data/bin/check_all_depencies +24 -3
- data/check_all_depencies.gemspec +1 -1
- data/lib/check_all_depencies.rb +192 -176
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da547ce39c056bf357f49387adb54dbe5f401d1350f806c9208bac7face114f5
|
4
|
+
data.tar.gz: f368c8d9d63e94e19d7b977740a1981e479a192085e2b0e046b594268fddcf78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a3cf68b04aa435e53b51a9c32916c76015e9468634cfa6f7b077e60fb591d301b1132bcbabfe48267587116531bba7fa62df586c60bef613072e0b40349bf2a
|
7
|
+
data.tar.gz: '051488443e4592cee5a5270b9453a8cc895750c2949b6f6ec028bfc59bb1d5032eff3a9ac831de669b2147defd4152d4736353ce3ea76fbf1bce66eb3901e1b3'
|
data/bin/check_all_depencies
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
#!/usr/bin/env ruby
|
2
3
|
# Analyzes the Podfile.lock content to extract pod dependencies
|
3
4
|
def analyze_podfile_lock(podfile_lock_content)
|
@@ -164,7 +165,7 @@ require 'json'
|
|
164
165
|
|
165
166
|
options = {}
|
166
167
|
OptionParser.new do |opts|
|
167
|
-
opts.banner = "Usage:
|
168
|
+
opts.banner = "Usage: check_all_depencies --lockPath LOCK_PATH --depWay DEP_WAY --configPath CONFIG_PATH"
|
168
169
|
|
169
170
|
opts.on("--lockPath LOCK_PATH", "Specify the Podfile.lock path") do |lockPath|
|
170
171
|
options[:lockPath] = lockPath
|
@@ -174,8 +175,28 @@ OptionParser.new do |opts|
|
|
174
175
|
options[:depWay] = depWay
|
175
176
|
end
|
176
177
|
|
177
|
-
#
|
178
|
-
|
178
|
+
# repo_configs examples
|
179
|
+
config_string = <<~CONFIG
|
180
|
+
repo_configs = {
|
181
|
+
'Lib1' => {
|
182
|
+
"branch" => "dev1",
|
183
|
+
"path" => "/Users/xxxxxxxxx/xxxxlib",
|
184
|
+
"git_url" => "xxxxxxxxxxxxxxxxxx"
|
185
|
+
},
|
186
|
+
'Lib2' => {
|
187
|
+
"branch" => "dev2",
|
188
|
+
"path" => "/Users/xxxxxxxxx/xxxxlib",
|
189
|
+
"git_url" => "xxxxxxxxxxxxxxxxxx"
|
190
|
+
},
|
191
|
+
'Lib3' => {
|
192
|
+
"branch" => "dev3",
|
193
|
+
"path" => "/Users/xxxxxxxxx/xxxxlib",
|
194
|
+
"git_url" => "xxxxxxxxxxxxxxxxxx"
|
195
|
+
}
|
196
|
+
}
|
197
|
+
CONFIG
|
198
|
+
|
199
|
+
opts.on("--configPath CONFIG_PATH", "Specify the path to repo_configs\n\n\n repo_configs examples:\n #{config_string}") do |configPath|
|
179
200
|
options[:configPath] = configPath
|
180
201
|
end
|
181
202
|
end.parse!
|
data/check_all_depencies.gemspec
CHANGED
data/lib/check_all_depencies.rb
CHANGED
@@ -1,212 +1,228 @@
|
|
1
|
-
require "check_all_depencies/version"
|
2
|
-
|
3
|
-
module CheckAllDepencies
|
4
|
-
class Error < StandardError; end
|
5
|
-
#!/usr/bin/env ruby
|
6
|
-
# Analyzes the Podfile.lock content to extract pod dependencies
|
7
|
-
def analyze_podfile_lock(podfile_lock_content)
|
8
|
-
unless podfile_lock_content.is_a?(String)
|
9
|
-
raise ArgumentError, 'podfile_lock_content must be a string.'
|
10
|
-
end
|
11
1
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
else
|
18
|
-
raise 'PODS section not found in the provided Podfile.lock content.'
|
19
|
-
end
|
2
|
+
#!/usr/bin/env ruby
|
3
|
+
# Analyzes the Podfile.lock content to extract pod dependencies
|
4
|
+
def analyze_podfile_lock(podfile_lock_content)
|
5
|
+
unless podfile_lock_content.is_a?(String)
|
6
|
+
raise ArgumentError, 'podfile_lock_content must be a string.'
|
20
7
|
end
|
21
8
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
analyze_podfile_lock(podfile_lock_content)
|
9
|
+
pods_section_match = podfile_lock_content.match(/^PODS:\n(.*?)(?=\n\n|\z)/m)
|
10
|
+
if pods_section_match
|
11
|
+
pods_section_content = pods_section_match[1]
|
12
|
+
pods_lines = pods_section_content.split("\n")
|
13
|
+
pods_lines.map(&:strip)
|
14
|
+
else
|
15
|
+
raise 'PODS section not found in the provided Podfile.lock content.'
|
30
16
|
end
|
17
|
+
end
|
31
18
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
19
|
+
# Reads the local Podfile.lock content
|
20
|
+
def read_local_podfile_lock(file_path)
|
21
|
+
unless File.exist?(file_path)
|
22
|
+
raise "File not found: #{file_path}"
|
23
|
+
end
|
24
|
+
|
25
|
+
podfile_lock_content = File.read(file_path)
|
26
|
+
analyze_podfile_lock(podfile_lock_content)
|
27
|
+
end
|
37
28
|
|
38
|
-
|
29
|
+
# Extracts unique specs from dependencies
|
30
|
+
def extract_unique_dependencies(pods)
|
31
|
+
unless pods.is_a?(Array)
|
32
|
+
raise ArgumentError, 'Input must be an array.'
|
33
|
+
end
|
39
34
|
|
40
|
-
|
41
|
-
repo_name = dependency.split('(').first.strip
|
42
|
-
cleaned_repo_name = repo_name.gsub(/- /, '')
|
43
|
-
unique << cleaned_repo_name unless unique.include?(cleaned_repo_name)
|
44
|
-
end
|
35
|
+
return [] if pods.empty?
|
45
36
|
|
46
|
-
|
37
|
+
unique_repositories = pods.each_with_object([]) do |dependency, unique|
|
38
|
+
repo_name = dependency.split('(').first.strip
|
39
|
+
cleaned_repo_name = repo_name.gsub(/- /, '')
|
40
|
+
unique << cleaned_repo_name unless unique.include?(cleaned_repo_name)
|
47
41
|
end
|
48
42
|
|
49
|
-
|
50
|
-
|
51
|
-
raise ArgumentError, 'Input must be an array' unless paths.is_a?(Array)
|
52
|
-
return [] if paths.empty?
|
53
|
-
raise ArgumentError, 'All elements in the array must be strings' unless paths.all? { |path| path.is_a?(String) }
|
54
|
-
|
55
|
-
shortest_paths = []
|
56
|
-
paths.each do |path|
|
57
|
-
is_shortest = true
|
58
|
-
paths.each do |other_path|
|
59
|
-
if path != other_path && other_path.start_with?(path)
|
60
|
-
is_shortest = false
|
61
|
-
break
|
62
|
-
end
|
63
|
-
end
|
64
|
-
shortest_paths << path if is_shortest
|
65
|
-
end
|
66
|
-
shortest_paths
|
67
|
-
end
|
43
|
+
unique_repositories
|
44
|
+
end
|
68
45
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
46
|
+
# Finds the shortest paths for dependencies
|
47
|
+
def find_shortest_paths(paths)
|
48
|
+
raise ArgumentError, 'Input must be an array' unless paths.is_a?(Array)
|
49
|
+
return [] if paths.empty?
|
50
|
+
raise ArgumentError, 'All elements in the array must be strings' unless paths.all? { |path| path.is_a?(String) }
|
51
|
+
|
52
|
+
shortest_paths = []
|
53
|
+
paths.each do |path|
|
54
|
+
is_shortest = true
|
55
|
+
paths.each do |other_path|
|
56
|
+
if path != other_path && other_path.start_with?(path)
|
57
|
+
is_shortest = false
|
58
|
+
break
|
78
59
|
end
|
79
|
-
|
60
|
+
end
|
61
|
+
shortest_paths << path if is_shortest
|
80
62
|
end
|
63
|
+
shortest_paths
|
64
|
+
end
|
81
65
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
podfile_entry << "\n"
|
66
|
+
# Builds all subspecs dependencies for a repo
|
67
|
+
def generate_repo_subspecs(repo,unique_repositories)
|
68
|
+
repo_subspecs = {}
|
69
|
+
unique_repositories.select { |dependency| dependency.start_with?(repo) }.each do |dependency|
|
70
|
+
if repo_subspecs.key?(repo)
|
71
|
+
repo_subspecs[repo] << dependency
|
72
|
+
else
|
73
|
+
repo_subspecs[repo] = [dependency]
|
74
|
+
end
|
92
75
|
end
|
93
|
-
|
94
|
-
|
76
|
+
return repo_subspecs
|
77
|
+
end
|
78
|
+
|
79
|
+
# Generates Podfile entry for path dependency
|
80
|
+
def generate_path_podfile_entry(lib,subspecs, base_path)
|
81
|
+
sub_specs = subspecs.map { |path| path.split('/', 2).last }.uniq
|
82
|
+
return "pod '#{lib}', :path => '#{base_path}'" if sub_specs.length <= 1
|
83
|
+
podfile_entry = "pod '#{lib}', :path => '#{base_path}', :subspecs => [\n"
|
84
|
+
sub_specs.each_with_index do |path, index|
|
85
|
+
subspec = path.gsub("#{lib}/", '')
|
86
|
+
podfile_entry << " '#{subspec}'"
|
87
|
+
podfile_entry << "," unless index == sub_specs.length - 1
|
88
|
+
podfile_entry << "\n"
|
95
89
|
end
|
90
|
+
podfile_entry << "]"
|
91
|
+
podfile_entry
|
92
|
+
end
|
96
93
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
end
|
108
|
-
podfile_entry << "]"
|
109
|
-
podfile_entry
|
94
|
+
# Generates Podfile entry for branch dependency
|
95
|
+
def generate_branch_podfile_entry(lib,subspecs, git_url, branch)
|
96
|
+
sub_specs = subspecs.map { |path| path.split('/', 2).last }.uniq
|
97
|
+
return "pod '#{lib}', :git => '#{git_url}', :branch => '#{branch}'" if sub_specs.length <= 1
|
98
|
+
podfile_entry = "pod '#{lib}', :git => '#{git_url}', :branch => '#{branch}', :subspecs => [\n"
|
99
|
+
sub_specs.each_with_index do |path, index|
|
100
|
+
subspec = path.gsub("#{lib}/", '')
|
101
|
+
podfile_entry << " '#{subspec}'"
|
102
|
+
podfile_entry << "," unless index == sub_specs.length - 1
|
103
|
+
podfile_entry << "\n"
|
110
104
|
end
|
105
|
+
podfile_entry << "]"
|
106
|
+
podfile_entry
|
107
|
+
end
|
111
108
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
end
|
135
|
-
puts podfile_entrys.join("\n")
|
136
|
-
podfile_entrys.join("\n")
|
109
|
+
# Generates all branch dependencies
|
110
|
+
def generate_map_branch_podfiles(lockPath, repo_configs)
|
111
|
+
raise ArgumentError, 'lockPath must be a string.' unless lockPath.is_a?(String)
|
112
|
+
raise ArgumentError, 'repo_configs must be a hash.' unless repo_configs.is_a?(Hash)
|
113
|
+
|
114
|
+
dependencies = read_local_podfile_lock(lockPath)
|
115
|
+
unique_dependencies = extract_unique_dependencies(dependencies)
|
116
|
+
# Throws an exception if unique_dependencies is empty
|
117
|
+
raise 'No unique dependencies found. Please check your Podfile.lock content and repo_configs.' if unique_dependencies.empty?
|
118
|
+
|
119
|
+
puts "====branch dependencies===="
|
120
|
+
podfile_entrys = []
|
121
|
+
repo_configs.each do |key, value|
|
122
|
+
next unless value.is_a?(Hash) && value.key?("git_url") && value.key?("branch")
|
123
|
+
|
124
|
+
git_url = value["git_url"]
|
125
|
+
branch = value["branch"]
|
126
|
+
repo_subspecs = generate_repo_subspecs(key, unique_dependencies)
|
127
|
+
repo_shortest_subspecs = find_shortest_paths(repo_subspecs[key])
|
128
|
+
# Generates Podfile entry
|
129
|
+
podfile_entry = generate_branch_podfile_entry(key, repo_shortest_subspecs, git_url, branch)
|
130
|
+
podfile_entrys << podfile_entry
|
137
131
|
end
|
132
|
+
puts podfile_entrys.join("\n")
|
133
|
+
podfile_entrys.join("\n")
|
134
|
+
end
|
138
135
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
136
|
+
# Generates all path dependencies
|
137
|
+
def generate_map_path_podfiles(lockPath, repo_configs)
|
138
|
+
raise ArgumentError, 'lockPath must be a string.' unless lockPath.is_a?(String)
|
139
|
+
raise ArgumentError, 'repo_configs must be a hash.' unless repo_configs.is_a?(Hash)
|
143
140
|
|
144
|
-
|
145
|
-
|
141
|
+
pods = read_local_podfile_lock(lockPath)
|
142
|
+
unique_dependencies = extract_unique_dependencies(pods)
|
146
143
|
|
147
|
-
|
148
|
-
|
144
|
+
# Throws an exception if unique_dependencies is empty
|
145
|
+
raise 'No unique dependencies found. Please check your Podfile.lock content and repo_configs.' if unique_dependencies.empty?
|
149
146
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
147
|
+
puts "====path dependencies===="
|
148
|
+
podfile_entrys = []
|
149
|
+
repo_configs.each do |key, value|
|
150
|
+
next unless value.is_a?(Hash) && value.key?("path")
|
154
151
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
end
|
162
|
-
puts podfile_entrys.join("\n")
|
163
|
-
podfile_entrys.join("\n")
|
152
|
+
path = value["path"]
|
153
|
+
repo_subspecs = generate_repo_subspecs(key, unique_dependencies)
|
154
|
+
repo_shortest_subspecs = find_shortest_paths(repo_subspecs[key])
|
155
|
+
# Generates Podfile entry
|
156
|
+
podfile_entry = generate_path_podfile_entry(key, repo_shortest_subspecs, path)
|
157
|
+
podfile_entrys << podfile_entry
|
164
158
|
end
|
159
|
+
puts podfile_entrys.join("\n")
|
160
|
+
podfile_entrys.join("\n")
|
161
|
+
end
|
165
162
|
|
166
|
-
|
167
|
-
|
163
|
+
require 'optparse'
|
164
|
+
require 'json'
|
168
165
|
|
169
|
-
|
170
|
-
|
171
|
-
|
166
|
+
options = {}
|
167
|
+
OptionParser.new do |opts|
|
168
|
+
opts.banner = "Usage: check_all_depencies --lockPath LOCK_PATH --depWay DEP_WAY --configPath CONFIG_PATH"
|
172
169
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
opts.on("--depWay DEP_WAY", "Specify the depWay parameter (path or branch)") do |depWay|
|
178
|
-
options[:depWay] = depWay
|
179
|
-
end
|
180
|
-
|
181
|
-
# New option to specify the path to repo_configs.txt
|
182
|
-
opts.on("--configPath CONFIG_PATH", "Specify the path to repo_configs") do |configPath|
|
183
|
-
options[:configPath] = configPath
|
184
|
-
end
|
185
|
-
end.parse!
|
170
|
+
opts.on("--lockPath LOCK_PATH", "Specify the Podfile.lock path") do |lockPath|
|
171
|
+
options[:lockPath] = lockPath
|
172
|
+
end
|
186
173
|
|
187
|
-
|
188
|
-
|
189
|
-
puts "Please provide lockPath, depWay, and configPath parameters.\n you can run:\n ruby MapHelper.rb --help "
|
190
|
-
exit
|
174
|
+
opts.on("--depWay DEP_WAY", "Specify the depWay parameter (path or branch)") do |depWay|
|
175
|
+
options[:depWay] = depWay
|
191
176
|
end
|
192
177
|
|
193
|
-
#
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
178
|
+
# repo_configs examples
|
179
|
+
config_string = <<~CONFIG
|
180
|
+
repo_configs = {
|
181
|
+
'Lib1' => {
|
182
|
+
"branch" => "dev1",
|
183
|
+
"path" => "/Users/xxxxxxxxx/xxxxlib",
|
184
|
+
"git_url" => "xxxxxxxxxxxxxxxxxx"
|
185
|
+
},
|
186
|
+
'Lib2' => {
|
187
|
+
"branch" => "dev2",
|
188
|
+
"path" => "/Users/xxxxxxxxx/xxxxlib",
|
189
|
+
"git_url" => "xxxxxxxxxxxxxxxxxx"
|
190
|
+
},
|
191
|
+
'Lib3' => {
|
192
|
+
"branch" => "dev3",
|
193
|
+
"path" => "/Users/xxxxxxxxx/xxxxlib",
|
194
|
+
"git_url" => "xxxxxxxxxxxxxxxxxx"
|
195
|
+
}
|
196
|
+
}
|
197
|
+
CONFIG
|
198
|
+
|
199
|
+
opts.on("--configPath CONFIG_PATH", "Specify the path to repo_configs\n\n\n repo_configs examples:\n #{config_string}") do |configPath|
|
200
|
+
options[:configPath] = configPath
|
200
201
|
end
|
202
|
+
end.parse!
|
201
203
|
|
202
|
-
|
204
|
+
# Check if all required arguments were provided
|
205
|
+
if options[:lockPath].nil? || options[:depWay].nil? || options[:configPath].nil?
|
206
|
+
puts "Please provide lockPath, depWay, and configPath parameters.\n you can run:\n ruby MapHelper.rb --help "
|
207
|
+
exit
|
208
|
+
end
|
203
209
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
210
|
+
# Function to read and parse the repo_configs.txt file
|
211
|
+
def read_repo_configs(config_path)
|
212
|
+
content = File.read(config_path)
|
213
|
+
eval(content) # Using eval to parse the Ruby hash from the file, be cautious with its use!
|
214
|
+
rescue
|
215
|
+
puts "Failed to read or parse the repo_configs from #{config_path}"
|
216
|
+
exit
|
217
|
+
end
|
218
|
+
|
219
|
+
repo_configs = read_repo_configs(options[:configPath])
|
220
|
+
|
221
|
+
# Calls before pod install complete
|
222
|
+
if options[:depWay] == "path"
|
223
|
+
generate_map_path_podfiles(options[:lockPath], repo_configs)
|
224
|
+
elsif options[:depWay] == "branch"
|
225
|
+
generate_map_branch_podfiles(options[:lockPath], repo_configs)
|
226
|
+
else
|
227
|
+
puts "Invalid argument. Please provide 'path' or 'branch'."
|
212
228
|
end
|