check_all_depencies 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7e6ab7f15ab9534d7f505c830ceac19b3092693d5464fbd5099c05ed6f340dc
4
- data.tar.gz: 17145b5d7602dd1da0be1a189bbe9431fe5f4675c5b19dd3c2c43ce931ba5b4a
3
+ metadata.gz: da547ce39c056bf357f49387adb54dbe5f401d1350f806c9208bac7face114f5
4
+ data.tar.gz: f368c8d9d63e94e19d7b977740a1981e479a192085e2b0e046b594268fddcf78
5
5
  SHA512:
6
- metadata.gz: 4f08605aa6232fe408c1caf7b3c353499d7558c521b57e45f2f46dc4488ffcf9c87bb9aebe1773c433c4035038501466b2b5da709237869295f1edd1367723a8
7
- data.tar.gz: e6d9bc22f9b64029730b92b99a61347086ba2fb390a2aa54fd4f92d08460b23c18de24f644983fa0274b9069c5d3576eb6c9f463de684c3f61bee1c2dcffecf3
6
+ metadata.gz: 4a3cf68b04aa435e53b51a9c32916c76015e9468634cfa6f7b077e60fb591d301b1132bcbabfe48267587116531bba7fa62df586c60bef613072e0b40349bf2a
7
+ data.tar.gz: '051488443e4592cee5a5270b9453a8cc895750c2949b6f6ec028bfc59bb1d5032eff3a9ac831de669b2147defd4152d4736353ce3ea76fbf1bce66eb3901e1b3'
@@ -0,0 +1,228 @@
1
+
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.'
7
+ end
8
+
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.'
16
+ end
17
+ end
18
+
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
28
+
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
34
+
35
+ return [] if pods.empty?
36
+
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)
41
+ end
42
+
43
+ unique_repositories
44
+ end
45
+
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
59
+ end
60
+ end
61
+ shortest_paths << path if is_shortest
62
+ end
63
+ shortest_paths
64
+ end
65
+
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
75
+ end
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"
89
+ end
90
+ podfile_entry << "]"
91
+ podfile_entry
92
+ end
93
+
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"
104
+ end
105
+ podfile_entry << "]"
106
+ podfile_entry
107
+ end
108
+
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
131
+ end
132
+ puts podfile_entrys.join("\n")
133
+ podfile_entrys.join("\n")
134
+ end
135
+
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)
140
+
141
+ pods = read_local_podfile_lock(lockPath)
142
+ unique_dependencies = extract_unique_dependencies(pods)
143
+
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?
146
+
147
+ puts "====path dependencies===="
148
+ podfile_entrys = []
149
+ repo_configs.each do |key, value|
150
+ next unless value.is_a?(Hash) && value.key?("path")
151
+
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
158
+ end
159
+ puts podfile_entrys.join("\n")
160
+ podfile_entrys.join("\n")
161
+ end
162
+
163
+ require 'optparse'
164
+ require 'json'
165
+
166
+ options = {}
167
+ OptionParser.new do |opts|
168
+ opts.banner = "Usage: check_all_depencies --lockPath LOCK_PATH --depWay DEP_WAY --configPath CONFIG_PATH"
169
+
170
+ opts.on("--lockPath LOCK_PATH", "Specify the Podfile.lock path") do |lockPath|
171
+ options[:lockPath] = lockPath
172
+ end
173
+
174
+ opts.on("--depWay DEP_WAY", "Specify the depWay parameter (path or branch)") do |depWay|
175
+ options[:depWay] = depWay
176
+ end
177
+
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
201
+ end
202
+ end.parse!
203
+
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
209
+
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'."
228
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "check_all_depencies"
3
- spec.version = "0.1.1"
3
+ spec.version = "0.1.3"
4
4
  spec.authors = ["ITxiansheng"]
5
5
  spec.email = ["itxiansheng@gmail.com"]
6
6
 
@@ -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
- pods_section_match = podfile_lock_content.match(/^PODS:\n(.*?)(?=\n\n|\z)/m)
13
- if pods_section_match
14
- pods_section_content = pods_section_match[1]
15
- pods_lines = pods_section_content.split("\n")
16
- pods_lines.map(&:strip)
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
- # Reads the local Podfile.lock content
23
- def read_local_podfile_lock(file_path)
24
- unless File.exist?(file_path)
25
- raise "File not found: #{file_path}"
26
- end
27
-
28
- podfile_lock_content = File.read(file_path)
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
- # Extracts unique specs from dependencies
33
- def extract_unique_dependencies(pods)
34
- unless pods.is_a?(Array)
35
- raise ArgumentError, 'Input must be an array.'
36
- end
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
- return [] if pods.empty?
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
- unique_repositories = pods.each_with_object([]) do |dependency, unique|
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
- unique_repositories
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
- # Finds the shortest paths for dependencies
50
- def find_shortest_paths(paths)
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
- # Builds all subspecs dependencies for a repo
70
- def generate_repo_subspecs(repo,unique_repositories)
71
- repo_subspecs = {}
72
- unique_repositories.select { |dependency| dependency.start_with?(repo) }.each do |dependency|
73
- if repo_subspecs.key?(repo)
74
- repo_subspecs[repo] << dependency
75
- else
76
- repo_subspecs[repo] = [dependency]
77
- end
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
- return repo_subspecs
60
+ end
61
+ shortest_paths << path if is_shortest
80
62
  end
63
+ shortest_paths
64
+ end
81
65
 
82
- # Generates Podfile entry for path dependency
83
- def generate_path_podfile_entry(lib,subspecs, base_path)
84
- sub_specs = subspecs.map { |path| path.split('/', 2).last }.uniq
85
- return "pod '#{lib}', :path => '#{base_path}'" if sub_specs.length <= 1
86
- podfile_entry = "pod '#{lib}', :path => '#{base_path}', :subspecs => [\n"
87
- sub_specs.each_with_index do |path, index|
88
- subspec = path.gsub("#{lib}/", '')
89
- podfile_entry << " '#{subspec}'"
90
- podfile_entry << "," unless index == sub_specs.length - 1
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
- podfile_entry << "]"
94
- podfile_entry
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
- # Generates Podfile entry for branch dependency
98
- def generate_branch_podfile_entry(lib,subspecs, git_url, branch)
99
- sub_specs = subspecs.map { |path| path.split('/', 2).last }.uniq
100
- return "pod '#{lib}', :git => '#{git_url}', :branch => '#{branch}'" if sub_specs.length <= 1
101
- podfile_entry = "pod '#{lib}', :git => '#{git_url}', :branch => '#{branch}', :subspecs => [\n"
102
- sub_specs.each_with_index do |path, index|
103
- subspec = path.gsub("#{lib}/", '')
104
- podfile_entry << " '#{subspec}'"
105
- podfile_entry << "," unless index == sub_specs.length - 1
106
- podfile_entry << "\n"
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
- # Generates all branch dependencies
113
- def generate_map_branch_podfiles(lockPath, repo_configs)
114
- raise ArgumentError, 'lockPath must be a string.' unless lockPath.is_a?(String)
115
- raise ArgumentError, 'repo_configs must be a hash.' unless repo_configs.is_a?(Hash)
116
-
117
- dependencies = read_local_podfile_lock(lockPath)
118
- unique_dependencies = extract_unique_dependencies(dependencies)
119
- # Throws an exception if unique_dependencies is empty
120
- raise 'No unique dependencies found. Please check your Podfile.lock content and repo_configs.' if unique_dependencies.empty?
121
-
122
- puts "====branch dependencies===="
123
- podfile_entrys = []
124
- repo_configs.each do |key, value|
125
- next unless value.is_a?(Hash) && value.key?("git_url") && value.key?("branch")
126
-
127
- git_url = value["git_url"]
128
- branch = value["branch"]
129
- repo_subspecs = generate_repo_subspecs(key, unique_dependencies)
130
- repo_shortest_subspecs = find_shortest_paths(repo_subspecs[key])
131
- # Generates Podfile entry
132
- podfile_entry = generate_branch_podfile_entry(key, repo_shortest_subspecs, git_url, branch)
133
- podfile_entrys << podfile_entry
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
- # Generates all path dependencies
140
- def generate_map_path_podfiles(lockPath, repo_configs)
141
- raise ArgumentError, 'lockPath must be a string.' unless lockPath.is_a?(String)
142
- raise ArgumentError, 'repo_configs must be a hash.' unless repo_configs.is_a?(Hash)
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
- pods = read_local_podfile_lock(lockPath)
145
- unique_dependencies = extract_unique_dependencies(pods)
141
+ pods = read_local_podfile_lock(lockPath)
142
+ unique_dependencies = extract_unique_dependencies(pods)
146
143
 
147
- # Throws an exception if unique_dependencies is empty
148
- raise 'No unique dependencies found. Please check your Podfile.lock content and repo_configs.' if unique_dependencies.empty?
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
- puts "====path dependencies===="
151
- podfile_entrys = []
152
- repo_configs.each do |key, value|
153
- next unless value.is_a?(Hash) && value.key?("path")
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
- path = value["path"]
156
- repo_subspecs = generate_repo_subspecs(key, unique_dependencies)
157
- repo_shortest_subspecs = find_shortest_paths(repo_subspecs[key])
158
- # Generates Podfile entry
159
- podfile_entry = generate_path_podfile_entry(key, repo_shortest_subspecs, path)
160
- podfile_entrys << podfile_entry
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
- require 'optparse'
167
- require 'json'
163
+ require 'optparse'
164
+ require 'json'
168
165
 
169
- options = {}
170
- OptionParser.new do |opts|
171
- opts.banner = "Usage: ruby MapHelper.rb --lockPath LOCK_PATH --depWay DEP_WAY --configPath CONFIG_PATH"
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
- opts.on("--lockPath LOCK_PATH", "Specify the Podfile.lock path") do |lockPath|
174
- options[:lockPath] = lockPath
175
- end
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
- # Check if all required arguments were provided
188
- if options[:lockPath].nil? || options[:depWay].nil? || options[:configPath].nil?
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
- # Function to read and parse the repo_configs.txt file
194
- def read_repo_configs(config_path)
195
- content = File.read(config_path)
196
- eval(content) # Using eval to parse the Ruby hash from the file, be cautious with its use!
197
- rescue
198
- puts "Failed to read or parse the repo_configs from #{config_path}"
199
- exit
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
- repo_configs = read_repo_configs(options[:configPath])
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
- # Calls before pod install complete
205
- if options[:depWay] == "path"
206
- generate_map_path_podfiles(options[:lockPath], repo_configs)
207
- elsif options[:depWay] == "branch"
208
- generate_map_branch_podfiles(options[:lockPath], repo_configs)
209
- else
210
- puts "Invalid argument. Please provide 'path' or 'branch'."
211
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check_all_depencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITxiansheng
@@ -42,6 +42,7 @@ 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