cocoapods-anker-ar 1.2.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a12a0c8334bae3fa0d0b53a6a5cf0480ca0d0fa2fec3d3b9a0eb324b67534a05
4
- data.tar.gz: d8bff5397f7262b366e5ad61b22424defe4d4a74dd36860c3df1014ec7ba8919
3
+ metadata.gz: 2f7f7de7a7a171b60747089ca8c51d423b9a26bd2d7d50b418683d9e5582928e
4
+ data.tar.gz: 561d0f5dd9099c3f254dace5c021ce0607ffdb056cff867d84a9f45124492509
5
5
  SHA512:
6
- metadata.gz: de8a4b20398dff205da4f52e982b5edbc5e5fdd428e3e51c0c1e2b9f18d1e732f6aa8c4633a0e52b82c7e07cee39763f7a0bbd985ae07b9900bb3eb399f8b0f6
7
- data.tar.gz: 2a18ff5a74d03cb4c790e70961b581bb82623ffa0cbc56157afae15bb80f7c41814766862a03572d0926cb4d40d02b7abf20dd433a6c0c3b65a8966d8e407eaa
6
+ metadata.gz: 4c04469d6b95601cf7122eda64453de636571cb12517559985eeecd4331573db13576359b29abddadf3fb9b2cc1cb4aaa3110d0f7791767af0106af2c46fb7e2
7
+ data.tar.gz: 7304d9ccd6684d48bc1fd38d44a10b6fe7c646573f63e9f217395fa0817f4f7e436fc5ea4601645954e92a8433a89b84042fc556401c0289d6a6bb733ea57879
@@ -1,3 +1,3 @@
1
1
  module CocoapodsAnkerAr
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.2"
3
3
  end
@@ -5,75 +5,171 @@ require 'coding_ar_util'
5
5
  module Pod
6
6
  module Downloader
7
7
  class Http
8
+ # The upstream implementation of `should_flatten?`, captured lazily.
9
+ #
10
+ # It is used as an escape hatch when another plugin (e.g. cocoapods-art)
11
+ # has captured our definition with `alias_method` and calls back into us:
12
+ # continuing down the `super` chain in that situation loops forever.
13
+ #
14
+ # @return [UnboundMethod, nil]
15
+ #
16
+ def self.base_should_flatten?
17
+ @base_should_flatten ||=
18
+ begin
19
+ require 'cocoapods-downloader/http'
20
+ Pod::Downloader::RemoteFile.instance_method(:should_flatten?)
21
+ rescue NameError, LoadError
22
+ nil
23
+ end
24
+ end
25
+
26
+ # Union with the upstream option list instead of replacing it.
27
+ #
28
+ # Other plugins (cocoapods-art adds `:headers`) and newer CocoaPods
29
+ # releases contribute options here. Replacing the list would make
30
+ # `Base#initialize` reject their options as unrecognized.
31
+ #
8
32
  def self.options
9
- [:type, :flatten, :sha1, :sha256, :indexDownload]
33
+ upstream = defined?(super) ? (super || []) : []
34
+ (upstream | [:type, :flatten, :sha1, :sha256, :indexDownload]).freeze
10
35
  end
11
36
 
12
- alias_method :orig_download_file, :download_file
13
- alias_method :orig_should_flatten?, :should_flatten?
37
+ # Use prepend instead of alias_method to safely monkey-patch without
38
+ # infinite recursion when the plugin is loaded more than once.
39
+ module AnkerArExtensions
40
+ CODING_AR_HOST = 'codingcorp-cocoapods.pkg.coding.anker-in.com'.freeze
14
41
 
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)
42
+ def download_file(full_filename)
43
+ if url.to_s.include?(CODING_AR_HOST)
44
+ CodingArUtil.download(url, full_filename)
45
+ else
46
+ super
47
+ end
48
+ end
49
+
50
+ def should_flatten?
51
+ if options.key?(:indexDownload) && options[:indexDownload] == true
52
+ true
53
+ elsif url.to_s.include?(CODING_AR_HOST)
54
+ # For CODING-AR packages, preserve directory structure to maintain .xcframework layout
55
+ # Use indexDownload: true in podspec if flattening is needed
56
+ puts "🔧 [CocoaPods-Anker-AR] Preserving directory structure for CODING-AR package"
57
+ false
58
+ elsif @__anker_resolving_should_flatten
59
+ # Re-entered through a plugin that aliased this method
60
+ # (cocoapods-art does `alias_method :orig_should_flatten?, ...`).
61
+ # Delegating again would bounce between the two definitions
62
+ # forever, so fall back to the downloader's own implementation.
63
+ base = self.class.base_should_flatten?
64
+ return base ? base.bind(self).call : false
65
+ else
66
+ begin
67
+ @__anker_resolving_should_flatten = true
68
+ super
69
+ ensure
70
+ @__anker_resolving_should_flatten = false
71
+ end
72
+ end
21
73
  end
22
74
  end
23
75
 
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
76
+ prepend AnkerArExtensions
77
+ end
78
+ end
79
+ end
80
+
81
+ # ---------------------------------------------------------------------------
82
+ # CDN 源传输层兼容开关
83
+ # ---------------------------------------------------------------------------
84
+ #
85
+ # cocoapods-core 的 `Pod::CDNSource` 在构造请求时硬编码了
86
+ # `:http_version => :httpv2_0`(见 cocoapods-core/lib/cocoapods-core/cdn_source.rb
87
+ # 的 `download_typhoeus_impl_async`)。当链路(VPN / MTU / 中间设备 / 服务端
88
+ # h2 实现)对 HTTP/2 支持不完整时,libcurl 会抛出
89
+ #
90
+ # CDN: <repo> URL couldn't be downloaded: <url> Response: Error in the HTTP2 framing layer
91
+ #
92
+ # 该异常在 CDN 源里是 `raise Informative`,属于致命错误,`pod install` 会中断,
93
+ # 且无法通过 Podfile 或 CocoaPods 配置项规避(上游没有暴露协议开关)。
94
+ #
95
+ # 这里提供两个环境变量作为逃生舱:
96
+ #
97
+ # COCOAPODS_CDN_HTTP_1_1=1 强制 CDN 请求走 HTTP/1.1(推荐用于排查上述报错)
98
+ # COCOAPODS_CDN_MAX_CONCURRENCY 交给上游 cocoapods-core 自己读取,无需在此处理
99
+ #
100
+ # 默认不改变任何行为:不设环境变量时协议仍是上游的 :httpv2_0,
101
+ # 避免给其它使用方带来性能回归。
102
+ #
103
+ module Pod
104
+ class CDNSource
105
+ module AnkerArHttpVersion
106
+ # @return [Symbol, nil] 需要强制使用的 libcurl 协议,nil 表示保持上游默认。
107
+ def self.forced_http_version
108
+ case ENV['COCOAPODS_CDN_HTTP_1_1'].to_s.strip.downcase
109
+ when '1', 'true', 'yes', 'on', '1.1', 'http1', 'http/1.1'
110
+ :httpv1_1
32
111
  else
33
- orig_should_flatten?
112
+ nil
34
113
  end
35
114
  end
115
+
116
+ def queue_request(request)
117
+ forced = AnkerArHttpVersion.forced_http_version
118
+ if forced
119
+ # 请求入队前覆写协议;Typhoeus 允许在 run 之前修改 options。
120
+ begin
121
+ request.options[:http_version] = forced
122
+ rescue StandardError
123
+ # options 结构在未来的 CocoaPods 里可能变化,失败时退回上游行为
124
+ end
125
+ end
126
+ super
127
+ end
36
128
  end
129
+
130
+ prepend AnkerArHttpVersion unless ancestors.include?(AnkerArHttpVersion)
37
131
  end
38
132
  end
39
133
 
40
134
  module Pod
41
135
  class Source
42
136
  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
-
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
137
+ # Use prepend instead of alias_method to safely monkey-patch without
138
+ # infinite recursion when the plugin is loaded more than once.
139
+ module AnkerArExtensions
140
+ def source_from_path(path)
141
+ # Only intercept repos that carry our marker file. Everything else
142
+ # is delegated to the rest of the chain so that other plugins
143
+ # patching `source_from_path` (e.g. cocoapods-art) keep working.
144
+ #
145
+ # Our own cache is deliberately kept in a dedicated ivar:
146
+ # cocoapods-art builds its own Hash under `@sources_by_path`, and
147
+ # sharing that one would make the two plugins recurse into each other.
148
+ if (path + '.coding_ar_url').exist?
149
+ @__anker_sources_by_path ||= {}
150
+ @__anker_sources_by_path[path] ||= CodingArSource.new(path)
151
+ else
152
+ super
153
+ end
58
154
  end
59
155
 
60
- @sources_by_path[path]
61
- end
156
+ def create_source_with_url(url)
157
+ require 'coding_ar_util'
62
158
 
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
159
+ name = name_for_url(url)
160
+ if CodingArUtil.coding_ar_service?(url)
161
+ Command::Repo::AddCodingAr.parse([name, url]).run
162
+ else
163
+ super
164
+ end
72
165
 
73
- source = source_with_url(url)
74
- raise "Unable to create a source with URL #{url}" unless source
75
- source
166
+ source = source_with_url(url)
167
+ raise "Unable to create a source with URL #{url}" unless source
168
+ source
169
+ end
76
170
  end
171
+
172
+ prepend AnkerArExtensions
77
173
  end
78
174
  end
79
175
  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.2.0
4
+ version: 1.2.2
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: 2026-03-31 00:00:00.000000000 Z
11
+ date: 2026-11-04 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.0.3.1
73
- signing_key:
72
+ rubygems_version: 3.5.22
73
+ signing_key:
74
74
  specification_version: 4
75
75
  summary: CODING-AR-backed repo support for Cocoapods
76
76
  test_files: []