cocoapods-anker-ar 1.1.0 → 1.2.1

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: 16401c71eaa53378e7477371a859c8fa24d15f9f19afb4f16aa346064f7cb625
4
- data.tar.gz: 9b6394c29855c198f343a67f884bbfe9e004c89655b4faf77313aac812d9064a
3
+ metadata.gz: 53d87b175c6ad2c28fd275fca7d098217545acc5132fcccf89084e5725c1b0fa
4
+ data.tar.gz: 1ec89fbaadae87a458ce6390f7f7b47a9fc4117b5d7142eb9661ce78233a0523
5
5
  SHA512:
6
- metadata.gz: 78d8352d2476d37be3219373f0b1f0b9e5749537958054e7f74534d3fc5d2adfc1cf6a2cad704a75b541886516f90a16870b85e0c26ca524a89d0ca7b4b07ef0
7
- data.tar.gz: 72c3f836e17875feda638a7f925c27be388de5f51502e87f298a3c4b386d0966f995e9e02188af999ab3add9a07b37a0f6bd609dddb99bf9b687edb4c3b5b64a
6
+ metadata.gz: '0951275ac2c303879914b1f3e09bffaaf4d1bcddaf6e1dae3e3e85fa35d2fe55befa9cca7dfcfbce9eba578fee064f6f3e34e83d28fefd42ef03c4673f9eae20'
7
+ data.tar.gz: 0e9df006388d9261d60647d7ee1b3b32bb38ccada256d1e167eff558efe9a339515f2c2abb273b4331f5f56e81b6ec2e67ea3dd2cfa37ee42301d4660fa7b620
@@ -1,3 +1,3 @@
1
1
  module CocoapodsAnkerAr
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -9,30 +9,32 @@ module Pod
9
9
  [:type, :flatten, :sha1, :sha256, :indexDownload]
10
10
  end
11
11
 
12
- alias_method :orig_download_file, :download_file
13
- alias_method :orig_should_flatten?, :should_flatten?
14
-
15
- def download_file(full_filename)
16
- # Check if this is a CODING-AR URL
17
- if url.to_s.include?('codingcorp-cocoapods.pkg.coding.anker-in.com')
18
- CodingArUtil.download(url, full_filename)
19
- else
20
- orig_download_file(full_filename)
12
+ # Use prepend instead of alias_method to safely monkey-patch without
13
+ # infinite recursion when the plugin is loaded more than once.
14
+ module AnkerArExtensions
15
+ def download_file(full_filename)
16
+ if url.to_s.include?('codingcorp-cocoapods.pkg.coding.anker-in.com')
17
+ CodingArUtil.download(url, full_filename)
18
+ else
19
+ super
20
+ end
21
21
  end
22
- end
23
22
 
24
- def should_flatten?
25
- if options.key?(:indexDownload) && options[:indexDownload] == true
26
- true
27
- elsif url.to_s.include?('codingcorp-cocoapods.pkg.coding.anker-in.com')
28
- # For CODING-AR packages, preserve directory structure to maintain .xcframework layout
29
- # Use indexDownload: true in podspec if flattening is needed
30
- puts "🔧 [CocoaPods-Anker-AR] Preserving directory structure for CODING-AR package"
31
- false
32
- else
33
- orig_should_flatten?
23
+ def should_flatten?
24
+ if options.key?(:indexDownload) && options[:indexDownload] == true
25
+ true
26
+ elsif url.to_s.include?('codingcorp-cocoapods.pkg.coding.anker-in.com')
27
+ # For CODING-AR packages, preserve directory structure to maintain .xcframework layout
28
+ # Use indexDownload: true in podspec if flattening is needed
29
+ puts "🔧 [CocoaPods-Anker-AR] Preserving directory structure for CODING-AR package"
30
+ false
31
+ else
32
+ super
33
+ end
34
34
  end
35
35
  end
36
+
37
+ prepend AnkerArExtensions
36
38
  end
37
39
  end
38
40
  end
@@ -40,40 +42,43 @@ end
40
42
  module Pod
41
43
  class Source
42
44
  class Manager
43
- alias_method :orig_source_from_path, :source_from_path
44
- alias_method :orig_create_source_with_url, :create_source_with_url
45
+ # Use prepend instead of alias_method to safely monkey-patch without
46
+ # infinite recursion when the plugin is loaded more than once.
47
+ module AnkerArExtensions
48
+ def source_from_path(path)
49
+ @sources_by_path ||= Hash.new do |hash, key|
50
+ hash[key] = case
51
+ when key.basename.to_s == Pod::TrunkSource::TRUNK_REPO_NAME
52
+ TrunkSource.new(key)
53
+ when (key + '.url').exist?
54
+ CDNSource.new(key)
55
+ when (key + '.coding_ar_url').exist?
56
+ CodingArSource.new(key)
57
+ else
58
+ Source.new(key)
59
+ end
60
+ end
45
61
 
46
- def source_from_path(path)
47
- @sources_by_path ||= Hash.new do |hash, key|
48
- hash[key] = case
49
- when key.basename.to_s == Pod::TrunkSource::TRUNK_REPO_NAME
50
- TrunkSource.new(key)
51
- when (key + '.url').exist?
52
- CDNSource.new(key)
53
- when (key + '.coding_ar_url').exist?
54
- CodingArSource.new(key)
55
- else
56
- Source.new(key)
57
- end
62
+ @sources_by_path[path]
58
63
  end
59
64
 
60
- @sources_by_path[path]
61
- end
65
+ def create_source_with_url(url)
66
+ require 'coding_ar_util'
62
67
 
63
- def create_source_with_url(url)
64
- require 'coding_ar_util'
65
-
66
- name = name_for_url(url)
67
- if CodingArUtil.coding_ar_service?(url)
68
- Command::Repo::AddCodingAr.parse([name, url]).run
69
- else
70
- orig_create_source_with_url(url)
71
- end
68
+ name = name_for_url(url)
69
+ if CodingArUtil.coding_ar_service?(url)
70
+ Command::Repo::AddCodingAr.parse([name, url]).run
71
+ else
72
+ super
73
+ end
72
74
 
73
- source = source_with_url(url)
74
- raise "Unable to create a source with URL #{url}" unless source
75
- source
75
+ source = source_with_url(url)
76
+ raise "Unable to create a source with URL #{url}" unless source
77
+ source
78
+ end
76
79
  end
80
+
81
+ prepend AnkerArExtensions
77
82
  end
78
83
  end
79
84
  end
@@ -110,8 +110,9 @@ module Pod
110
110
  pod_root = File.dirname Pathname(@podspec).realpath
111
111
  path_list = Pod::Sandbox::PathList.new(pod_root)
112
112
 
113
- file_accessors ||= spec.available_platforms.flat_map do |platform|
114
- Pod::Sandbox::FileAccessor.new(path_list, spec.consumer(platform))
113
+ all_specs = [spec] + spec.recursive_subspecs
114
+ file_accessors ||= spec.available_platforms.flat_map do |platform|
115
+ all_specs.map { |s| Pod::Sandbox::FileAccessor.new(path_list, s.consumer(platform)) }
115
116
  end
116
117
 
117
118
  pod_files = Pod::Sandbox::FileAccessor.all_files(file_accessors).map do |path|
@@ -92,45 +92,109 @@ module Pod
92
92
  def update(_show_output)
93
93
  require 'json'
94
94
  require 'coding_ar_util'
95
+ require 'typhoeus'
96
+ require 'etc'
95
97
 
96
98
  changed_spec_paths = []
97
99
  UI.puts "Updating CODING-AR-backed repo #{name}".yellow if _show_output
98
- Pathname.glob(repo.join('**/*/*.json')).map do |f|
100
+
101
+ files = Pathname.glob(repo.join('**/*/*.json'))
102
+ spec_requests = []
103
+
104
+ files.each do |f|
99
105
  begin
100
106
  origin_content = File.read(f)
101
- spec = JSON.parse origin_content
107
+ spec = JSON.parse(origin_content)
102
108
  spec_url = "#{url}/Specs/#{spec['name']}/#{spec['version']}/#{spec['name']}.podspec.json"
103
- UI.puts "- Fetch #{spec_url}" if _show_output
104
- FileUtils.mkdir_p File.dirname(f)
105
- CodingArUtil.download(spec_url, f)
106
- latest_content = File.read(f)
107
- FileUtils.rm_rf(File.dirname(f)) if latest_content.to_s.start_with?('Pod not found')
108
- JSON.parse latest_content
109
- changed_spec_paths.push(f) if origin_content != latest_content
110
- rescue RuntimeError => e
111
- if e.message.include?('Spec not found')
112
- UI.puts "- Skipping #{spec['name']} #{spec['version']}: Spec not found".yellow if _show_output
113
- next
114
- elsif e.message.include?('URL using bad/illegal format') || e.message.include?('missing URL')
115
- UI.puts "- Skipping #{spec['name']} #{spec['version']}: Invalid URL format".yellow if _show_output
116
- next
117
- else
118
- UI.puts "- Skipping #{spec['name']} #{spec['version']}: #{e.message}".yellow if _show_output
119
- next
120
- end
109
+ spec_requests << {
110
+ file: f,
111
+ url: spec_url,
112
+ origin_content: origin_content,
113
+ spec_name: spec['name'],
114
+ spec_version: spec['version']
115
+ }
121
116
  rescue JSON::ParserError => e
122
117
  UI.puts "- Skipping #{f}: Invalid JSON format".yellow if _show_output
123
- next
124
118
  rescue => e
125
119
  UI.puts "- Skipping #{f}: #{e.message}".yellow if _show_output
126
- next
127
120
  end
128
121
  end
129
- UI.puts "Successfully update CODING-AR-backed repo #{name}".green if _show_output
130
122
 
123
+ return [] if spec_requests.empty?
124
+
125
+ max_concurrency = [[Etc.nprocessors * 2, 4].max, 20].min
126
+ UI.puts "Fetching #{spec_requests.size} specs with #{max_concurrency} concurrent connections...".yellow if _show_output
127
+
128
+ start_time = Time.now
129
+ hydra = Typhoeus::Hydra.new(max_concurrency: max_concurrency)
130
+
131
+ spec_requests.each do |req|
132
+ request = Typhoeus::Request.new(
133
+ req[:url],
134
+ method: :get,
135
+ netrc: :optional,
136
+ netrc_file: ENV[CodingArUtil::CODING_AR_NETRC_PATH_ENV] || Netrc.default_path,
137
+ followlocation: true,
138
+ headers: { 'User-Agent' => CodingArUtil::USER_AGENT }
139
+ )
140
+
141
+ request.on_complete do |response|
142
+ handle_spec_response(response, req, changed_spec_paths, _show_output)
143
+ end
144
+
145
+ hydra.queue(request)
146
+ end
147
+
148
+ hydra.run
149
+ elapsed = Time.now - start_time
150
+
151
+ UI.puts "Fetched #{spec_requests.size} specs in #{elapsed.round(2)}s (#{(spec_requests.size / elapsed).round(1)} specs/sec)".green if _show_output
152
+ UI.puts "Successfully update CODING-AR-backed repo #{name}".green if _show_output
131
153
  []
132
154
  end
133
155
 
156
+ def handle_spec_response(response, req, changed_spec_paths, show_output)
157
+ file = req[:file]
158
+ spec_name = req[:spec_name]
159
+ spec_version = req[:spec_version]
160
+ origin_content = req[:origin_content]
161
+
162
+ UI.puts "- Fetch #{req[:url]}" if show_output
163
+
164
+ if response.code == 0
165
+ UI.puts "- Skipping #{spec_name} #{spec_version}: #{response.return_message}".yellow if show_output
166
+ return
167
+ elsif response.code != 200
168
+ error_msg = response.body.to_s
169
+ if error_msg.include?('Spec not found') || error_msg.include?('not found')
170
+ UI.puts "- Skipping #{spec_name} #{spec_version}: Spec not found".yellow if show_output
171
+ elsif error_msg.include?('URL using bad/illegal format') || error_msg.include?('missing URL')
172
+ UI.puts "- Skipping #{spec_name} #{spec_version}: Invalid URL format".yellow if show_output
173
+ else
174
+ UI.puts "- Skipping #{spec_name} #{spec_version}: HTTP #{response.code}".yellow if show_output
175
+ end
176
+ return
177
+ end
178
+
179
+ begin
180
+ latest_content = response.body
181
+ if latest_content.to_s.start_with?('Pod not found')
182
+ FileUtils.rm_rf(File.dirname(file))
183
+ return
184
+ end
185
+
186
+ JSON.parse(latest_content)
187
+ FileUtils.mkdir_p(File.dirname(file))
188
+ File.open(file, 'wb') { |f| f << latest_content }
189
+
190
+ changed_spec_paths.push(file) if origin_content != latest_content
191
+ rescue JSON::ParserError => e
192
+ UI.puts "- Skipping #{spec_name} #{spec_version}: Invalid JSON in response".yellow if show_output
193
+ rescue => e
194
+ UI.puts "- Skipping #{spec_name} #{spec_version}: #{e.message}".yellow if show_output
195
+ end
196
+ end
197
+
134
198
  def updateable?
135
199
  true
136
200
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-anker-ar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dark Liu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-12 00:00:00.000000000 Z
11
+ date: 2026-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler