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