cocoapods-anker-ar 1.0.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1eff05882bede930b0162dd2e297180cb07480a2de63816dc982036d7026e7aa
4
- data.tar.gz: bb02a35f71c88ff4bd1db0069e0b4a99f9a2015672301453da72903c2edfcd0c
3
+ metadata.gz: a12a0c8334bae3fa0d0b53a6a5cf0480ca0d0fa2fec3d3b9a0eb324b67534a05
4
+ data.tar.gz: d8bff5397f7262b366e5ad61b22424defe4d4a74dd36860c3df1014ec7ba8919
5
5
  SHA512:
6
- metadata.gz: aa478181f273b4f8bd69eff7a5db5eb0ffa81019b528cf5068c07459df1fa74ba6a602bf290c97914dc3eefd853cb59c43dc83b853f8daa5a257afde7a0a8a20
7
- data.tar.gz: 3392065f1ab0711dbad3a1721f103dbee3bd33f91d6386d3af72604688245afee6052c45fe1d619ad5a0f3c075916c4cc88e519d530c9572f1818f12b50512ff
6
+ metadata.gz: de8a4b20398dff205da4f52e982b5edbc5e5fdd428e3e51c0c1e2b9f18d1e732f6aa8c4633a0e52b82c7e07cee39763f7a0bbd985ae07b9900bb3eb399f8b0f6
7
+ data.tar.gz: 2a18ff5a74d03cb4c790e70961b581bb82623ffa0cbc56157afae15bb80f7c41814766862a03572d0926cb4d40d02b7abf20dd433a6c0c3b65a8966d8e407eaa
@@ -1,3 +1,3 @@
1
1
  module CocoapodsAnkerAr
2
- VERSION = "1.0.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -13,14 +13,24 @@ module Pod
13
13
  alias_method :orig_should_flatten?, :should_flatten?
14
14
 
15
15
  def download_file(full_filename)
16
- CodingArUtil.download(url, 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)
21
+ end
17
22
  end
18
23
 
19
24
  def should_flatten?
20
- if options.key?(:indexDownload)
25
+ if options.key?(:indexDownload) && options[:indexDownload] == true
21
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
22
32
  else
23
- super
33
+ orig_should_flatten?
24
34
  end
25
35
  end
26
36
  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|
@@ -182,6 +183,181 @@ module Pod
182
183
  }
183
184
  end
184
185
  end
186
+
187
+ class RepushCodingAr < Repo
188
+ extend Executable
189
+ executable :tar
190
+
191
+ self.summary = 'Repush a pod with new version to CODING-AR.'
192
+ self.description = <<-DESC
193
+ Download an existing pod from CODING-AR repo, update its version and repush it.
194
+ DESC
195
+
196
+ self.arguments = [
197
+ CLAide::Argument.new('REPO', true),
198
+ CLAide::Argument.new('PODSPEC_NAME', true),
199
+ CLAide::Argument.new('PODSPEC_VERSION', true),
200
+ CLAide::Argument.new('NEW_PODSPEC_VERSION', true)
201
+ ]
202
+
203
+ def initialize(argv)
204
+ @repo = argv.shift_argument
205
+ @podspec_name = argv.shift_argument
206
+ @podspec_version = argv.shift_argument
207
+ @new_podspec_version = argv.shift_argument
208
+ super
209
+ end
210
+
211
+ def validate!
212
+ super
213
+ unless @repo && @podspec_name && @podspec_version && @new_podspec_version
214
+ help! 'This command requires repo name, podspec name, current version and new version.'
215
+ end
216
+ end
217
+
218
+ def run
219
+ unless File.file? File.join(Config.instance.repos_dir, @repo, ".coding_ar_url")
220
+ raise Informative, "`#@repo` is not a CODING-AR repo.".red
221
+ end
222
+
223
+ # Check if target version already exists
224
+ if version_exists?(@new_podspec_version)
225
+ raise Informative, "Version #{@new_podspec_version} already exists for #{@podspec_name}".red
226
+ end
227
+
228
+ FileUtils.mkdir_p tmp_dir
229
+ begin
230
+ UI.section("Repushing pod `#{@podspec_name}` from #{@podspec_version} to #{@new_podspec_version} in CODING-AR repo `#@repo`") do
231
+ # Download original files
232
+ original_tar_gz_path = download_original_tar_gz
233
+ original_spec_path = download_original_spec
234
+
235
+ # Create new version files
236
+ new_tar_gz_path = create_new_tar_gz(original_tar_gz_path)
237
+ new_spec_path = create_new_spec(original_spec_path)
238
+
239
+ # Push to CODING-AR
240
+ post_pod_with_spec(new_tar_gz_path, new_spec_path)
241
+ end
242
+ UI.puts "Successfully repushed pod `#{@podspec_name} #{@new_podspec_version}` to CODING-AR repo `#@repo`".green
243
+ ensure
244
+ FileUtils.rm_rf tmp_dir
245
+ end
246
+ end
247
+
248
+ private
249
+
250
+ def version_exists?(version)
251
+ source = source_manager.source_with_name(@repo)
252
+ return false unless source
253
+
254
+ versions = source.versions(@podspec_name)
255
+ return false unless versions
256
+
257
+ versions.any? { |v| v.to_s == version }
258
+ rescue
259
+ false
260
+ end
261
+
262
+ def source_manager
263
+ Pod::Source::Manager.new(Config.instance.repos_dir)
264
+ end
265
+
266
+ def download_original_tar_gz
267
+ tar_gz_url = "#{coding_ar_repo_url}/Release/#{@podspec_name}/#{@podspec_version}/#{@podspec_name}-#{@podspec_version}.tar.gz"
268
+ tar_gz_path = File.join(tmp_dir, "#{@podspec_name}-#{@podspec_version}.tar.gz")
269
+
270
+ require 'coding_ar_util'
271
+ CodingArUtil.download(tar_gz_url, tar_gz_path)
272
+ tar_gz_path
273
+ end
274
+
275
+ def download_original_spec
276
+ spec_url = "#{coding_ar_repo_url}/Specs/#{@podspec_name}/#{@podspec_version}/#{@podspec_name}.podspec.json"
277
+ spec_path = File.join(tmp_dir, "#{@podspec_name}-#{@podspec_version}.podspec.json")
278
+
279
+ require 'coding_ar_util'
280
+ CodingArUtil.download(spec_url, spec_path)
281
+ spec_path
282
+ end
283
+
284
+ def create_new_tar_gz(original_tar_gz_path)
285
+ # Directly copy original tar.gz with new version name
286
+ new_tar_gz_path = File.join(tmp_dir, "#{@podspec_name}-#{@new_podspec_version}.tar.gz")
287
+ FileUtils.copy_file(original_tar_gz_path, new_tar_gz_path)
288
+ new_tar_gz_path
289
+ end
290
+
291
+ def create_new_spec(original_spec_path)
292
+ require 'json'
293
+
294
+ # Read and parse original spec
295
+ original_content = File.read(original_spec_path)
296
+ spec_hash = JSON.parse(original_content)
297
+
298
+ # Update version
299
+ spec_hash['version'] = @new_podspec_version
300
+
301
+ # Update source information
302
+ if spec_hash['source']
303
+ source = spec_hash['source']
304
+
305
+ # Update source tag if it contains version-specific information
306
+ if source['tag']
307
+ source['tag'] = @new_podspec_version
308
+ end
309
+
310
+ # Update source http URL if it contains version-specific information
311
+ if source['http']
312
+ # Replace old version with new version in http URL
313
+ source['http'] = source['http'].gsub(@podspec_version, @new_podspec_version)
314
+ end
315
+ end
316
+
317
+ # Write new spec file
318
+ new_spec_path = File.join(tmp_dir, "#{@podspec_name}.podspec.json")
319
+ File.open(new_spec_path, 'w') do |file|
320
+ file.write(JSON.pretty_generate(spec_hash))
321
+ end
322
+
323
+ new_spec_path
324
+ end
325
+
326
+ def post_pod_with_spec(pod_path, spec_path)
327
+ require 'json'
328
+
329
+ request_body = {
330
+ 'pod' => file_push_profile(pod_path),
331
+ 'spec' => file_push_profile(spec_path)
332
+ }
333
+ request_body_json_path = File.join(tmp_dir, "request_body.json")
334
+ request_body_json = File.new(request_body_json_path, "wb")
335
+ request_body_json.puts(request_body.to_json)
336
+ request_body_json.close
337
+
338
+ require 'coding_ar_util'
339
+ CodingArUtil.push_pod(coding_ar_repo_url, request_body_json_path)
340
+ end
341
+
342
+ def tmp_dir
343
+ File.join(Config.instance.repos_dir, @repo, '.tmp', @podspec_name, @new_podspec_version)
344
+ end
345
+
346
+ def coding_ar_repo_url
347
+ File.read File.join(Config.instance.repos_dir, @repo, ".coding_ar_url")
348
+ end
349
+
350
+ def file_push_profile(path)
351
+ require 'digest/sha1'
352
+
353
+ content = File.read(path)
354
+ {
355
+ 'size' => File.lstat(path).size,
356
+ 'base64_content' => Base64.strict_encode64(content),
357
+ 'sha1_digest' => Digest::SHA1.hexdigest(content)
358
+ }
359
+ end
360
+ end
185
361
  end
186
362
  end
187
363
  end
@@ -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.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dark Liu
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-03 00:00:00.000000000 Z
11
+ date: 2026-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,7 +54,7 @@ homepage: http://codingcorp.coding.anker-in.com/public/CODING_ANKER/cocoapods-an
54
54
  licenses:
55
55
  - MIT
56
56
  metadata: {}
57
- post_install_message:
57
+ post_install_message:
58
58
  rdoc_options: []
59
59
  require_paths:
60
60
  - lib
@@ -69,8 +69,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.5.22
73
- signing_key:
72
+ rubygems_version: 3.0.3.1
73
+ signing_key:
74
74
  specification_version: 4
75
75
  summary: CODING-AR-backed repo support for Cocoapods
76
76
  test_files: []