cocoapods-byte-csjm 0.0.13 → 0.0.17
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/lib/cocoapods-byte-csjm/config.rb +126 -51
- data/lib/cocoapods-byte-csjm/gem_version.rb +1 -1
- data/lib/cocoapods-byte-csjm/gm.rb +243 -145
- data/lib/cocoapods-byte-csjm/net.rb +28 -0
- metadata +3 -6
- data/cocoapods-byte-csjm-0.0.4.gem +0 -0
- data/cocoapods-byte-csjm-0.0.5.gem +0 -0
- data/cocoapods-byte-csjm-0.0.6.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cabfe6c655cbf23d67e618a57d5a78a6e78f50bffb9e424b86190706dd0239d
|
4
|
+
data.tar.gz: 531fd69060498b48d2cd818bc3d6992413fcae10b42e784dedb44f6842bf4851
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96d85b34ea5758310823ce73fd1212549327b420b8b845bfbbf012038cf1d2c4599f6a9788f7ad40ee36d29cf49e6f4150ce370ac22aab02bfdf2b05073248b2
|
7
|
+
data.tar.gz: 6c9d34ecf30f2fae6384e7aba1ff0de0f231e6f623192008567812dfd123cf2156d5ec27f9bbc99fbd12abf54acd6ccfb2d99bb7bb3b5d7b5c9502cbde837029
|
@@ -1,4 +1,11 @@
|
|
1
|
+
require_relative 'net'
|
2
|
+
|
1
3
|
module GM
|
4
|
+
module Beta
|
5
|
+
CSJ_RELEASE = 1
|
6
|
+
GM_RELEASE = 2
|
7
|
+
CSJ_BETA = 3
|
8
|
+
end
|
2
9
|
|
3
10
|
class BuildConfig
|
4
11
|
|
@@ -19,7 +26,7 @@ module GM
|
|
19
26
|
end
|
20
27
|
|
21
28
|
def self.update_value_last_version
|
22
|
-
return "last"
|
29
|
+
return "last" ## 最新版本
|
23
30
|
end
|
24
31
|
|
25
32
|
def self.update_value_last_stable_version
|
@@ -27,100 +34,168 @@ module GM
|
|
27
34
|
end
|
28
35
|
|
29
36
|
def self.update_value_non
|
30
|
-
return "not_update"
|
37
|
+
return "not_update" ## 不自动更新
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.mediation_names
|
41
|
+
return %w[Ads-CN/CSJMediation Ads-CN-Beta/CSJMediation Ads-Fusion-CN-Beta/CSJMediation]
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.mediation_name_csj
|
45
|
+
return 'Ads-CN/CSJMediation'
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.mediation_name_beta
|
49
|
+
return 'Ads-CN-Beta/CSJMediation'
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.mediation_name_gm
|
53
|
+
return 'Ads-Fusion-CN-Beta/CSJMediation'
|
31
54
|
end
|
32
55
|
|
33
|
-
def self.
|
34
|
-
return
|
56
|
+
def self.mediation_version_type(name)
|
57
|
+
return Beta::CSJ_BETA if name.start_with?('Ads-CN-Beta/')
|
58
|
+
return Beta::CSJ_RELEASE if name.start_with?('Ads-CN/')
|
59
|
+
return Beta::GM_RELEASE if name.start_with?('Ads-Fusion-CN-Beta/')
|
60
|
+
0
|
35
61
|
end
|
36
62
|
|
37
63
|
def self.get_all_config
|
38
|
-
[BuildConfig.get_update_key,BuildConfig.get_load_key,BuildConfig.get_load_detect_key]
|
64
|
+
[BuildConfig.get_update_key, BuildConfig.get_load_key, BuildConfig.get_load_detect_key]
|
39
65
|
end
|
40
66
|
end
|
41
67
|
|
42
68
|
class Adn_Adapter
|
43
|
-
|
69
|
+
ADN_ADAPTER = Hash[
|
44
70
|
# 'Ads-CN' => 'ABUAdCsjAdapter',
|
45
|
-
'UnityAds' => '
|
46
|
-
'Google-Mobile-Ads-SDK'=> '
|
47
|
-
'BaiduMobAdSDK'=> '
|
48
|
-
'GDTMobSDK'=> '
|
49
|
-
'SigmobAd-iOS'=> '
|
50
|
-
'KSAdSDK'=> '
|
51
|
-
'KlevinAdSDK'=> '
|
52
|
-
'MintegralAdSDK'=> '
|
71
|
+
'UnityAds' => 'UnityAdapter',
|
72
|
+
'Google-Mobile-Ads-SDK' => 'AdmobAdapter',
|
73
|
+
'BaiduMobAdSDK' => 'BaiduAdapter',
|
74
|
+
'GDTMobSDK' => 'GdtAdapter',
|
75
|
+
'SigmobAd-iOS' => 'SigmobAdapter',
|
76
|
+
'KSAdSDK' => 'KsAdapter',
|
77
|
+
'KlevinAdSDK' => 'KlevinAdapter',
|
78
|
+
'MintegralAdSDK' => 'MintegralAdapter',
|
53
79
|
].freeze
|
54
80
|
|
55
|
-
|
56
|
-
'unity' => '
|
57
|
-
'admob'=> '
|
58
|
-
'baidu'=> '
|
59
|
-
'gdt'=> '
|
60
|
-
'sigmob'=> '
|
61
|
-
'ks'=> '
|
62
|
-
'klevin'=> '
|
63
|
-
'mtg'=> '
|
81
|
+
SERVER_MAP_ADAPTER = Hash[
|
82
|
+
'unity' => 'UnityAdapter',
|
83
|
+
'admob' => 'AdmobAdapter',
|
84
|
+
'baidu' => 'BaiduAdapter',
|
85
|
+
'gdt' => 'GdtAdapter',
|
86
|
+
'sigmob' => 'SigmobAdapter',
|
87
|
+
'ks' => 'KsAdapter',
|
88
|
+
'klevin' => 'KlevinAdapter',
|
89
|
+
'mtg' => 'MintegralAdapter',
|
64
90
|
].freeze
|
65
91
|
|
66
|
-
|
92
|
+
SERVER_MAP_ADN = Hash[
|
67
93
|
'UnityAds' => 'unity',
|
68
|
-
'Google-Mobile-Ads-SDK'=> 'admob',
|
69
|
-
'BaiduMobAdSDK'=> 'baidu',
|
70
|
-
'GDTMobSDK'=> 'gdt',
|
71
|
-
'SigmobAd-iOS'=> 'sigmob',
|
72
|
-
'KSAdSDK'=> 'ks',
|
73
|
-
'KlevinAdSDK'=> 'klevin',
|
74
|
-
'MintegralAdSDK'=> 'mtg',
|
94
|
+
'Google-Mobile-Ads-SDK' => 'admob',
|
95
|
+
'BaiduMobAdSDK' => 'baidu',
|
96
|
+
'GDTMobSDK' => 'gdt',
|
97
|
+
'SigmobAd-iOS' => 'sigmob',
|
98
|
+
'KSAdSDK' => 'ks',
|
99
|
+
'KlevinAdSDK' => 'klevin',
|
100
|
+
'MintegralAdSDK' => 'mtg',
|
75
101
|
].freeze
|
76
102
|
|
103
|
+
# 获取ADN缩写名称
|
77
104
|
def self.get_adn_abbreviation(name)
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
|
105
|
+
SERVER_MAP_ADN[name]
|
106
|
+
end
|
107
|
+
|
108
|
+
# 已知ADN缩写名称,获取adapter名称
|
109
|
+
def self.get_adapter_from_adn_abbreviation(name, beta_type)
|
110
|
+
_adapter_name = SERVER_MAP_ADAPTER[name]
|
111
|
+
adapter_name = nil
|
112
|
+
if beta_type == Beta::CSJ_BETA
|
113
|
+
adapter_name = 'GM' + _adapter_name + '-Beta'
|
114
|
+
elsif beta_type == Beta::CSJ_RELEASE
|
115
|
+
adapter_name = 'GM' + _adapter_name
|
116
|
+
elsif beta_type == Beta::GM_RELEASE
|
117
|
+
adapter_name = 'CSJM' + _adapter_name
|
118
|
+
end
|
119
|
+
adapter_name
|
83
120
|
end
|
84
121
|
|
122
|
+
# 判断是否是ADN名称
|
85
123
|
def self.is_adn?(name)
|
86
|
-
|
124
|
+
ADN_ADAPTER.has_key?(name)
|
87
125
|
end
|
88
126
|
|
127
|
+
# 判断是否是adapter名称
|
89
128
|
def self.is_adapter?(name)
|
90
|
-
|
129
|
+
if name.end_with?('-Beta')
|
130
|
+
len = name.length
|
131
|
+
name = name[0..len - 6]
|
132
|
+
end
|
133
|
+
if name.start_with?('GM')
|
134
|
+
len = name.length
|
135
|
+
name = name[2..len - 1]
|
136
|
+
elsif name.start_with?('CSJM')
|
137
|
+
len = name.length
|
138
|
+
name = name[2..len - 1]
|
139
|
+
end
|
140
|
+
ADN_ADAPTER.has_value?(name)
|
91
141
|
end
|
92
142
|
|
93
|
-
|
94
|
-
|
143
|
+
# 获取adapter的名称
|
144
|
+
def self.get_adapter(name, beta_type)
|
95
145
|
if is_adn?(name)
|
96
|
-
|
146
|
+
_adapter_name = ADN_ADAPTER[name]
|
147
|
+
adapter_name = nil
|
148
|
+
if beta_type == Beta::CSJ_BETA
|
149
|
+
adapter_name = 'GM' + _adapter_name + '-Beta'
|
150
|
+
elsif beta_type == Beta::CSJ_RELEASE
|
151
|
+
adapter_name = 'GM' + _adapter_name
|
152
|
+
elsif beta_type == Beta::GM_RELEASE
|
153
|
+
adapter_name = 'CSJM' + _adapter_name
|
154
|
+
end
|
155
|
+
return adapter_name
|
97
156
|
end
|
98
|
-
|
157
|
+
nil
|
99
158
|
end
|
100
159
|
|
160
|
+
# 获取ADN的名称
|
101
161
|
def self.get_adn(name)
|
102
162
|
adn_name = ''
|
103
163
|
if is_adapter?(name)
|
104
164
|
## .index 在调试时候会报错
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
165
|
+
ADN_ADAPTER.select { |key, value|
|
166
|
+
if name.include?(value)
|
167
|
+
adn_name = key
|
168
|
+
break
|
169
|
+
end
|
170
|
+
true
|
111
171
|
}
|
112
172
|
end
|
113
173
|
adn_name
|
114
174
|
end
|
115
175
|
|
176
|
+
# 获取所有的adapter的名称
|
116
177
|
def self.get_all_adapter
|
117
|
-
|
178
|
+
adapter_base_names = ADN_ADAPTER.values
|
179
|
+
gm_adapters = adapter_base_names.map { |adapter_name|
|
180
|
+
'CSJM' + adapter_name
|
181
|
+
}
|
182
|
+
beta_adapters = adapter_base_names.map { |adapter_name|
|
183
|
+
'GM' + adapter_name + '-Beta'
|
184
|
+
}
|
185
|
+
did_release = Network.csj_did_release
|
186
|
+
csj_adapters = []
|
187
|
+
if did_release
|
188
|
+
csj_adapters = adapter_base_names.map { |adapter_name|
|
189
|
+
'GM' + adapter_name
|
190
|
+
}
|
191
|
+
end
|
192
|
+
csj_adapters + beta_adapters + gm_adapters
|
118
193
|
end
|
119
194
|
|
195
|
+
# 获取所有的ADN的名称
|
120
196
|
def self.get_all_adn
|
121
|
-
|
197
|
+
ADN_ADAPTER.keys
|
122
198
|
end
|
123
199
|
end
|
124
200
|
|
125
|
-
|
126
201
|
end
|
@@ -12,28 +12,25 @@ require 'cocoapods/command/update'
|
|
12
12
|
require 'time'
|
13
13
|
require 'open3'
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
15
|
module CSJMPlugin
|
20
|
-
def CSJMPlugin.action
|
21
|
-
recoder= GM::Recorder.instance
|
16
|
+
def CSJMPlugin.action
|
17
|
+
recoder = GM::Recorder.instance
|
22
18
|
if recoder.is_load_plugin
|
23
19
|
yield(recoder) if block_given?
|
24
20
|
end
|
25
21
|
end
|
26
22
|
|
27
23
|
def CSJMPlugin.update
|
24
|
+
current_version = CocoapodsByteCsjm::Version.version
|
25
|
+
puts "Current version is #{current_version}"
|
28
26
|
puts "Checking for updates..."
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
puts "cocoapods-byte-csjm
|
35
|
-
|
36
|
-
puts "cocoapods-byte-csjm update fail message:#{stderr}"
|
27
|
+
latest_version = GM::Network.latest_version
|
28
|
+
if latest_version != current_version
|
29
|
+
puts "—————————————————————————————————————————————————————————————".red
|
30
|
+
puts "| 检测到 cocoapods-byte-csjm 存在新版本 (#{latest_version} > #{current_version})".red
|
31
|
+
puts "| 请执行 `sudo gem install cocoapods-byte-csjm` 更新".red
|
32
|
+
puts "| 使用bundle用户请在Gemfile中修改 `gem 'cocoapods-byte-csjm', '~> #{latest_version}'`".red
|
33
|
+
puts "—————————————————————————————————————————————————————————————".red
|
37
34
|
end
|
38
35
|
end
|
39
36
|
end
|
@@ -45,8 +42,9 @@ module GM
|
|
45
42
|
def initialize(hash)
|
46
43
|
@internal_data = hash
|
47
44
|
end
|
45
|
+
|
48
46
|
# 读取lock文件
|
49
|
-
# @
|
47
|
+
# @return lock的json内容
|
50
48
|
# @param 文件路径
|
51
49
|
def self.read_from_path(path)
|
52
50
|
if File.exist?(path)
|
@@ -54,15 +52,17 @@ module GM
|
|
54
52
|
end
|
55
53
|
return false, nil
|
56
54
|
end
|
55
|
+
|
57
56
|
# 写入lock文件
|
58
57
|
def write_to_disk(path)
|
59
58
|
begin
|
60
59
|
is_exist, existing = LockfileCSJM.read_from_path(path)
|
61
60
|
return if existing == @internal_data
|
62
61
|
rescue Exception
|
62
|
+
puts 'Read csjm lock file failed'
|
63
63
|
end
|
64
64
|
File.open(path, 'w+') do |f|
|
65
|
-
YAML.dump(@internal_data,f)
|
65
|
+
YAML.dump(@internal_data, f)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -72,27 +72,31 @@ module GM
|
|
72
72
|
class GmInfo
|
73
73
|
attr_accessor :name
|
74
74
|
attr_accessor :version
|
75
|
+
|
75
76
|
def initialize(name, version)
|
76
77
|
@name = name
|
77
78
|
@version = version
|
78
79
|
end
|
80
|
+
|
79
81
|
def to_hash
|
80
82
|
hash = {}
|
81
83
|
hash["NAME"] = @name
|
82
84
|
hash["VERSION"] = @version
|
83
85
|
hash
|
84
86
|
end
|
87
|
+
|
85
88
|
def self.from_hash(hash)
|
86
|
-
GmInfo.new(hash["NAME"],hash["VERSION"])
|
89
|
+
GmInfo.new(hash["NAME"], hash["VERSION"])
|
87
90
|
end
|
88
91
|
end
|
89
92
|
|
90
93
|
# 媒体配置记录
|
91
94
|
#
|
92
|
-
class
|
95
|
+
class Note
|
93
96
|
attr_accessor :auto_load
|
94
97
|
attr_accessor :auto_update
|
95
98
|
attr_accessor :load_detect
|
99
|
+
|
96
100
|
def get_update(update_value)
|
97
101
|
value = ''
|
98
102
|
case update_value
|
@@ -111,7 +115,8 @@ module GM
|
|
111
115
|
|
112
116
|
class GlobalNote < Note
|
113
117
|
attr_accessor :auto_load_whitelist
|
114
|
-
|
118
|
+
|
119
|
+
def initialize(auto_load = true, auto_update = GM::BuildConfig.update_value_last_version, load_detect = true, auto_load_whitelist = [])
|
115
120
|
@auto_load = auto_load
|
116
121
|
@auto_update = get_update auto_update
|
117
122
|
@load_detect = load_detect
|
@@ -136,7 +141,7 @@ module GM
|
|
136
141
|
end
|
137
142
|
|
138
143
|
def self.from_hash(hash)
|
139
|
-
global_note =
|
144
|
+
global_note = GlobalNote.new
|
140
145
|
global_note.auto_load = hash["AUTO_LOAD"] if hash.has_key?("AUTO_LOAD")
|
141
146
|
global_note.auto_update = hash["AUTO_UPDATE"] if hash.has_key?("AUTO_UPDATE")
|
142
147
|
global_note.load_detect = hash["LOAD_DETECT"] if hash.has_key?("LOAD_DETECT")
|
@@ -153,9 +158,9 @@ module GM
|
|
153
158
|
attr_accessor :adapter_original_version ##加载的版本号
|
154
159
|
attr_accessor :adapter_expected_version ##期望加载的版本号
|
155
160
|
|
156
|
-
def initialize(adn_name, auto_load = false
|
161
|
+
def initialize(adn_name, auto_load = false, auto_update = GM::BuildConfig.update_value_non, load_detect = false)
|
157
162
|
@adn_name = adn_name
|
158
|
-
@adapter_name = GM::Adn_Adapter.get_adapter adn_name
|
163
|
+
@adapter_name = GM::Adn_Adapter.get_adapter adn_name, Beta::CSJ_RELEASE
|
159
164
|
@auto_load = auto_load
|
160
165
|
@auto_update = get_update auto_update
|
161
166
|
@load_detect = load_detect
|
@@ -177,7 +182,7 @@ module GM
|
|
177
182
|
end
|
178
183
|
|
179
184
|
def self.from_hash(hash)
|
180
|
-
note =
|
185
|
+
note = AdnNote.new(hash["ADN_NAME"], hash["AUTO_LOAD"], hash["AUTO_UPDATE"], hash["LOAD_DETECT"])
|
181
186
|
note.adn_name = hash["ADN_NAME"]
|
182
187
|
note.adn_version = hash["ADN_VERSION"]
|
183
188
|
note.adapter_name = hash["ADAPTER_NAME"]
|
@@ -194,9 +199,9 @@ module GM
|
|
194
199
|
|
195
200
|
attr_accessor :is_release_target
|
196
201
|
attr_accessor :referenced_target
|
197
|
-
attr_reader
|
202
|
+
attr_reader :label
|
198
203
|
attr_accessor :gm_info
|
199
|
-
attr_accessor :
|
204
|
+
attr_accessor :notes_info
|
200
205
|
|
201
206
|
def initialize(label)
|
202
207
|
@label = label.clone
|
@@ -204,29 +209,27 @@ module GM
|
|
204
209
|
end
|
205
210
|
|
206
211
|
def find_note(adn_name)
|
207
|
-
@
|
212
|
+
@notes_info ||= {}
|
208
213
|
global_note = GM::Recorder.instance.global_note
|
209
|
-
note = (@
|
210
|
-
@
|
214
|
+
note = (@notes_info.has_key?(adn_name) && @notes_info[adn_name]) || AdnNote.new(adn_name, global_note.auto_load, global_note.auto_update, global_note.load_detect)
|
215
|
+
@notes_info[adn_name] = note unless @notes_info.has_key?(adn_name)
|
211
216
|
note
|
212
217
|
end
|
213
218
|
|
214
219
|
def has_adn?(adn_name)
|
215
|
-
GM::Adn_Adapter.is_adn?(adn_name) && @
|
220
|
+
GM::Adn_Adapter.is_adn?(adn_name) && @notes_info.has_key?(adn_name)
|
216
221
|
end
|
217
222
|
|
218
223
|
def is_adn_update_or_detect?(adn_name)
|
219
|
-
|
220
|
-
result
|
224
|
+
is_adn_update?(adn_name) || is_adn_detect?(adn_name)
|
221
225
|
end
|
222
226
|
|
223
227
|
def is_adn_update?(adn_name)
|
224
|
-
|
225
|
-
result
|
228
|
+
has_adn?(adn_name) && @notes_info[adn_name].auto_update != GM::BuildConfig.update_value_non && GM::Recorder.instance.global_note.has_set_load?(adn_name)
|
226
229
|
end
|
227
230
|
|
228
231
|
def is_adn_detect?(adn_name)
|
229
|
-
has_adn?(adn_name) && @
|
232
|
+
has_adn?(adn_name) && @notes_info[adn_name].load_detect
|
230
233
|
end
|
231
234
|
|
232
235
|
def to_hash
|
@@ -234,10 +237,10 @@ module GM
|
|
234
237
|
hash["LABEL"] = @label
|
235
238
|
hash["IS_RELEASE_TARGET"] = @is_release_target
|
236
239
|
hash["GM_INFO"] = @gm_info.to_hash
|
237
|
-
hash["
|
238
|
-
@
|
239
|
-
hash["
|
240
|
-
}
|
240
|
+
hash["NOTES_INFO"] = {}
|
241
|
+
@notes_info.each { |key, value|
|
242
|
+
hash["NOTES_INFO"][key] = value.to_hash
|
243
|
+
} if @notes_info != nil
|
241
244
|
hash
|
242
245
|
end
|
243
246
|
|
@@ -245,9 +248,9 @@ module GM
|
|
245
248
|
target = Target.new(hash["LABEL"])
|
246
249
|
target.is_release_target = true
|
247
250
|
target.gm_info = GmInfo.from_hash hash["GM_INFO"] if hash.has_key?("GM_INFO")
|
248
|
-
target.
|
249
|
-
hash["
|
250
|
-
target.
|
251
|
+
target.notes_info ||= {}
|
252
|
+
hash["NOTES_INFO"].each do |name, note_info|
|
253
|
+
target.notes_info[name] = AdnNote.from_hash note_info
|
251
254
|
end
|
252
255
|
target
|
253
256
|
end
|
@@ -264,6 +267,7 @@ module GM
|
|
264
267
|
attr_reader :is_load_plugin
|
265
268
|
attr_reader :plugin_version
|
266
269
|
attr_reader :lockfile_data
|
270
|
+
|
267
271
|
def set_plugin_load(is_load)
|
268
272
|
@is_load_plugin = is_load
|
269
273
|
@plugin_version = CocoapodsByteCsjm::Version.version
|
@@ -274,22 +278,21 @@ module GM
|
|
274
278
|
end
|
275
279
|
|
276
280
|
def find_global_note(option, is_force_update = false)
|
277
|
-
|
278
281
|
return @global_note if !is_force_update && @global_note != nil
|
279
282
|
@global_note = GlobalNote.new(false, GM::BuildConfig.update_value_non, false)
|
280
|
-
load_key
|
281
|
-
update_key
|
283
|
+
load_key = GM::BuildConfig.get_load_key
|
284
|
+
update_key = GM::BuildConfig.get_update_key
|
282
285
|
load_detect_key = GM::BuildConfig.get_load_detect_key
|
283
286
|
auto_load_whitelist_key = GM::BuildConfig.get_load_whitelist_key
|
284
287
|
case option
|
285
288
|
when true, false
|
286
|
-
@global_note =
|
289
|
+
@global_note = GM::GlobalNote.new(option, option, option, {})
|
287
290
|
when Hash
|
288
291
|
load_value = option.has_key?(load_key) ? option[load_key] : true
|
289
292
|
update_value = option.has_key?(update_key) ? option[update_key] : true
|
290
293
|
detect_value = option.has_key?(load_detect_key) ? option[load_detect_key] : true
|
291
|
-
auto_load_whitelist = option.has_key?(auto_load_whitelist_key)?option[auto_load_whitelist_key] : {}
|
292
|
-
@global_note =
|
294
|
+
auto_load_whitelist = option.has_key?(auto_load_whitelist_key) ? option[auto_load_whitelist_key] : {}
|
295
|
+
@global_note = GM::GlobalNote.new(load_value, update_value, detect_value, auto_load_whitelist)
|
293
296
|
else
|
294
297
|
raise ArgumentError, "CSJM error: `#{option.inspect}`, should be a boolean or hash."
|
295
298
|
end
|
@@ -311,7 +314,7 @@ module GM
|
|
311
314
|
hash["PLUGIN_VERSION"] = @plugin_version
|
312
315
|
hash["GLOBAL_NOTE"] = @global_note.to_hash
|
313
316
|
hash["TARGET_INFO"] = {}
|
314
|
-
@target_info.each {|item, value|
|
317
|
+
@target_info.each { |item, value|
|
315
318
|
hash["TARGET_INFO"][item] = value.to_hash
|
316
319
|
}
|
317
320
|
checksum = Digest::SHA1.hexdigest(hash.inspect)
|
@@ -325,48 +328,49 @@ module GM
|
|
325
328
|
#
|
326
329
|
class SpecificationInfo
|
327
330
|
@@possibilities = {}
|
331
|
+
|
328
332
|
def self.update(name = '', possibilities)
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
+
if name.length > 0
|
334
|
+
@@possibilities[name] ||= []
|
335
|
+
@@possibilities[name] = @@possibilities[name] | possibilities
|
336
|
+
end
|
333
337
|
end
|
334
338
|
|
335
|
-
def self.get_info
|
336
|
-
|
339
|
+
def self.get_info
|
340
|
+
@@possibilities
|
337
341
|
end
|
338
342
|
|
339
343
|
def self.get_a_specfication(name, version)
|
340
|
-
result =
|
344
|
+
result = @@possibilities[name].find { |specification|
|
341
345
|
specification.version.version == version
|
342
346
|
}
|
343
347
|
result
|
344
348
|
end
|
345
349
|
|
346
|
-
def self.get_specfication(info_list = [])
|
350
|
+
def self.get_specfication(info_list = [], beta_type)
|
347
351
|
|
348
352
|
##请注意, 这里可能获取不到对应的Specfication 实例, 此时需要报错并提示媒体使用pod update
|
349
|
-
result =
|
353
|
+
result = info_list.map { |info|
|
350
354
|
info['is_find'] = false
|
351
|
-
adapter_name = GM::Adn_Adapter.get_adapter_from_adn_abbreviation
|
355
|
+
adapter_name = GM::Adn_Adapter.get_adapter_from_adn_abbreviation(info["adn_name"], beta_type)
|
352
356
|
@@possibilities[adapter_name].find { |specification|
|
353
357
|
info['is_find'] = true if specification.version.version == info["adn_adapter_version"]
|
354
358
|
specification.version.version == info["adn_adapter_version"]
|
355
359
|
}
|
356
360
|
}.flatten
|
357
|
-
unfind_list = info_list.select{ |info|
|
361
|
+
unfind_list = info_list.select { |info|
|
358
362
|
info['is_find'] == false
|
359
363
|
}
|
360
364
|
if unfind_list.size > 0
|
361
|
-
|
365
|
+
# infos = get_info
|
362
366
|
str = "adapters("
|
363
|
-
unfind_list.each {|item|
|
364
|
-
str << GM::Adn_Adapter.get_adapter_from_adn_abbreviation(
|
367
|
+
unfind_list.each { |item|
|
368
|
+
str << GM::Adn_Adapter.get_adapter_from_adn_abbreviation(item["adn_name"], beta_type) + "->" + item["adn_adapter_version"] + " "
|
365
369
|
}
|
366
370
|
str << ")"
|
367
371
|
raise "CSJM error: #{str} 版本未找到,请执行 `pod update --verbose`"
|
368
372
|
end
|
369
|
-
|
373
|
+
result
|
370
374
|
end
|
371
375
|
end
|
372
376
|
|
@@ -382,41 +386,41 @@ module GM
|
|
382
386
|
checksum = hash.delete("RECODER_CHECKSUM")
|
383
387
|
verified_checksum = Digest::SHA1.hexdigest(hash.inspect).encode('UTF-8') if checksum.respond_to?(:encode)
|
384
388
|
if verified_checksum != checksum
|
385
|
-
raise
|
389
|
+
raise "CSJM error: Podfile.csjm.lock 文件校验失败, 请检查该文件是否被改动, 尝试删掉该文件并执行 'pod install', 若你确认没有被修改,请联系技术支持"
|
386
390
|
end
|
387
391
|
## 校验对应的target是否存在
|
388
|
-
|
389
|
-
raise
|
392
|
+
unless hash["TARGET_INFO"].has_key?(target.gm_build_config.referenced_target)
|
393
|
+
raise "CSJM error:#{target.gm_build_config.label} 设置了'is_release_target=true' 但是在 Podfile.csjm.lock文件中没有找到target的信息"
|
390
394
|
end
|
391
395
|
|
392
396
|
## 校验gm版本是否符合
|
393
|
-
gm_spec =
|
394
|
-
GM::BuildConfig.mediation_name==spec.spec.name
|
397
|
+
gm_spec = specs.find do |spec|
|
398
|
+
GM::BuildConfig.mediation_name == spec.spec.name
|
395
399
|
end
|
396
400
|
if gm_spec.nil?
|
397
|
-
raise
|
401
|
+
raise "CSJM error:#{GM::BuildConfig.mediation_name} not found in #{target.label}"
|
398
402
|
end
|
399
|
-
referenced_target =
|
403
|
+
referenced_target = GM::Target.from_hash hash["TARGET_INFO"][target.gm_build_config.referenced_target]
|
400
404
|
if gm_spec.spec.version.version != referenced_target.gm_info.version
|
401
|
-
raise
|
405
|
+
raise "CSJM error:#{GM::BuildConfig.mediation_name} version has change(#{referenced_target.gm_info.version}->#{gm_spec.spec.version.version}),please check"
|
402
406
|
end
|
403
407
|
## 替换各adapter的版本
|
404
|
-
referenced_target.
|
408
|
+
referenced_target.notes_info.each do |adn_name, note|
|
405
409
|
|
406
|
-
original_adapter_sp = specs.find{|spec|
|
410
|
+
original_adapter_sp = specs.find { |spec|
|
407
411
|
spec.spec.name == note.adapter_name
|
408
412
|
}
|
409
413
|
if original_adapter_sp.nil?
|
410
|
-
raise
|
414
|
+
raise "CSJM error:#{note.adapter_name} not found"
|
411
415
|
end
|
412
416
|
##校验adn是否更换了版本
|
413
417
|
original_adn_sp = specs.find do |spec|
|
414
418
|
spec.spec.name == note.adn_name
|
415
419
|
end
|
416
420
|
if original_adn_sp.spec.version.version != note.adn_version
|
417
|
-
raise
|
421
|
+
raise "CSJM error:#{note.adn_name} version has change(#{note.adn_version}->#{original_adapter_sp.spec.version.version}),please check"
|
418
422
|
end
|
419
|
-
if
|
423
|
+
if note.adapter_expected_version.length > 0 && original_adapter_sp.spec.version.version != note.adapter_expected_version
|
420
424
|
title_options = { :verbose_prefix => '-> '.green }
|
421
425
|
Pod::UserInterface.titled_section("#{note.adn_name} will change adapter version , the current adapter(#{note.adapter_name}) version will change from #{original_adapter_sp.spec.version.version} to #{note.adapter_expected_version}", title_options)
|
422
426
|
replace_sp = GM::SpecificationInfo.get_a_specfication note.adapter_name, note.adapter_expected_version
|
@@ -426,21 +430,24 @@ module GM
|
|
426
430
|
end
|
427
431
|
end
|
428
432
|
end
|
429
|
-
specs.sort_by!{|spec| spec.spec.name}
|
433
|
+
specs.sort_by! { |spec| spec.spec.name }
|
430
434
|
else
|
431
|
-
raise
|
435
|
+
raise "CSJM error: #{File.expand_path("#{Pod::Config.instance.installation_root}/Podfile.csjm.lock")} not found, please check"
|
432
436
|
end
|
433
437
|
end
|
434
438
|
|
435
439
|
def self.resolve_last(target, specs)
|
436
|
-
|
440
|
+
beta_type = target.did_pod_csjm_beta specs
|
437
441
|
gm_spec = nil
|
442
|
+
mediation_names = GM::BuildConfig.mediation_names
|
438
443
|
adn_specs = specs.select do |spec|
|
439
444
|
name = spec.spec.name
|
440
|
-
if name
|
441
|
-
|
442
|
-
|
443
|
-
|
445
|
+
if mediation_names.include?(name)
|
446
|
+
version_type = GM::BuildConfig.mediation_version_type(name)
|
447
|
+
if version_type == beta_type
|
448
|
+
gm_spec = spec
|
449
|
+
target.gm_build_config.gm_info = GM::GmInfo.new(spec.spec.name, spec.spec.version.version)
|
450
|
+
end
|
444
451
|
end
|
445
452
|
if GM::Adn_Adapter.is_adapter?(name)
|
446
453
|
adn_note = target.gm_build_config.find_note GM::Adn_Adapter.get_adn name
|
@@ -452,20 +459,20 @@ module GM
|
|
452
459
|
end
|
453
460
|
target.gm_build_config.is_adn_update?(name) ## 这里去掉不更新但版本校验功能
|
454
461
|
end
|
455
|
-
|
456
|
-
|
462
|
+
GM::VersionAnalyzer.delete_invalid_sdks_for_beta target, specs, beta_type
|
463
|
+
raise "CSJM error: #{GM::BuildConfig.mediation_name} not found, please check" if gm_spec == nil
|
464
|
+
adn_info_list = adn_specs.map { |adn_spec|
|
457
465
|
adn_note = target.gm_build_config.find_note adn_spec.spec.name
|
458
466
|
adn_note.adn_version = adn_spec.spec.version.version
|
459
|
-
{"adn_name" => GM::Adn_Adapter.get_adn_abbreviation(adn_spec.spec.name),"adn_version" => adn_spec.spec.version.version}
|
467
|
+
{ "adn_name" => GM::Adn_Adapter.get_adn_abbreviation(adn_spec.spec.name), "adn_version" => adn_spec.spec.version.version }
|
460
468
|
# {"adn_name" => "ks","adn_version" => adn_spec.spec.version.version}
|
461
469
|
# {"adn_name" => adn_spec.spec.name,"adn_version" => adn_spec.spec.version.version, "auto_update" => adn_note.auto_update, "load_detect" => adn_note.load_detect, "adapter_name" => adn_note.adapter_name, "adapter_version" => adn_note.adapter_original_version}
|
462
470
|
} if gm_spec
|
463
471
|
## 网络请求
|
464
472
|
response_data = request_adapter gm_spec.spec.version.version, adn_info_list
|
465
|
-
result =
|
466
|
-
result.each{|item|
|
467
|
-
|
468
|
-
original_sp = specs.find{|spec|
|
473
|
+
result = GM::SpecificationInfo.get_specfication(response_data, beta_type)
|
474
|
+
result.each { |item|
|
475
|
+
original_sp = specs.find { |spec|
|
469
476
|
spec.spec.name == item.name
|
470
477
|
}
|
471
478
|
adn_name = GM::Adn_Adapter.get_adn item.name
|
@@ -476,47 +483,95 @@ module GM
|
|
476
483
|
Pod::UserInterface.titled_section("#{adn_name} has set version update or check, the current adapter(#{item.name}) version(#{item.version.version}) is as expected", title_options)
|
477
484
|
else
|
478
485
|
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
486
|
+
if original_sp && original_sp.spec.version.version != item.version.version ## 更新到最新版本 或 最新稳定版本
|
487
|
+
if target.gm_build_config.is_adn_update?(adn_name)
|
488
|
+
# puts '开始更新版本'
|
489
|
+
title_options = { :verbose_prefix => '-> '.green }
|
490
|
+
Pod::UserInterface.titled_section("#{adn_name} will change adapter version , the current adapter(#{item.name}) version will change from #{original_sp.spec.version.version} to #{item.version.version}", title_options)
|
491
|
+
specs << Pod::Resolver::ResolverSpecification.new(item, original_sp.used_by_non_library_targets_only, item.spec_source)
|
492
|
+
specs.delete original_sp
|
493
|
+
elsif target.gm_build_config.is_adn_detect?(adn_name) ##媒体关闭了自动更新,只选择检查版本是否适配
|
494
|
+
## 版本校验功能暂时去掉 , 一期不上,后续具体看情况
|
495
|
+
# puts '开始校验版本'
|
496
|
+
# if item.version.version != original_sp.spec.version.version
|
497
|
+
# raise "CSJM error:#{adn_name} has set the version check of the adapter(#{item.name}), current version does not match. please change your version. The current version is #{original_sp.spec.version.version} but the expected version is #{item.version.version}"
|
498
|
+
# end
|
499
|
+
else
|
500
|
+
# puts '什么也不做'
|
501
|
+
end
|
494
502
|
end
|
495
503
|
end
|
496
|
-
end
|
497
504
|
}
|
498
|
-
specs.sort_by!{|spec| spec.spec.name}
|
505
|
+
specs.sort_by! { |spec| spec.spec.name }
|
499
506
|
end
|
500
507
|
|
501
508
|
def self.delete_invalid_adapters(target, specs)
|
502
|
-
un_den_adn_list= GM::Adn_Adapter.get_all_adn - specs.map(&:spec).map(&:name).map do |item|
|
509
|
+
un_den_adn_list = GM::Adn_Adapter.get_all_adn - specs.map(&:spec).map(&:name).map do |item|
|
503
510
|
GM::Adn_Adapter.is_adn?(item) ? Pod::Specification.root_name(item) : nil
|
504
511
|
end.compact.uniq
|
505
|
-
|
506
|
-
|
507
|
-
|
512
|
+
un_den_adapter_list_csj = un_den_adn_list.map { |item|
|
513
|
+
GM::Adn_Adapter.get_adapter(item, GM::Beta::CSJ_RELEASE)
|
514
|
+
}
|
515
|
+
un_den_adapter_list_beta = un_den_adn_list.map { |item|
|
516
|
+
GM::Adn_Adapter.get_adapter(item, GM::Beta::CSJ_BETA)
|
508
517
|
}
|
518
|
+
un_den_adapter_list_gm = un_den_adn_list.map { |item|
|
519
|
+
GM::Adn_Adapter.get_adapter(item, GM::Beta::GM_RELEASE)
|
520
|
+
}
|
521
|
+
un_den_adapter_list = un_den_adapter_list_csj + un_den_adapter_list_beta + un_den_adapter_list_gm
|
509
522
|
specs.delete_if { |spec|
|
510
|
-
hh = !GM::Recorder.instance.global_note.auto_load_whitelist.include?(Pod::Specification.root_name(spec.spec.name))
|
511
|
-
result =
|
523
|
+
# hh = !GM::Recorder.instance.global_note.auto_load_whitelist.include?(Pod::Specification.root_name(spec.spec.name))
|
524
|
+
result = un_den_adapter_list.include?(Pod::Specification.root_name(spec.spec.name)) && !GM::Recorder.instance.global_note.auto_load_whitelist.include?(Pod::Specification.root_name(spec.spec.name))
|
512
525
|
if result
|
513
|
-
title_options = { :verbose_prefix => '-> '.red}
|
526
|
+
title_options = { :verbose_prefix => '-> '.red }
|
514
527
|
Pod::UserInterface.titled_section("remove #{spec.spec.name}", title_options)
|
515
528
|
end
|
516
529
|
result
|
517
530
|
}
|
518
531
|
end
|
519
532
|
|
533
|
+
def self.delete_invalid_sdks_for_beta(target, specs, beta_type)
|
534
|
+
mediation_name_gm = GM::BuildConfig.mediation_name_gm
|
535
|
+
mediation_name_csj = GM::BuildConfig.mediation_name_csj
|
536
|
+
mediation_name_beta = GM::BuildConfig.mediation_name_beta
|
537
|
+
if beta_type == GM::Beta::CSJ_BETA
|
538
|
+
remove_csjm_names = [mediation_name_gm, mediation_name_csj]
|
539
|
+
elsif beta_type == GM::Beta::CSJ_RELEASE
|
540
|
+
remove_csjm_names = [mediation_name_gm, mediation_name_beta]
|
541
|
+
elsif beta_type == GM::Beta::GM_RELEASE
|
542
|
+
remove_csjm_names = [mediation_name_csj, mediation_name_beta]
|
543
|
+
end
|
544
|
+
remove_names = []
|
545
|
+
remove_csjm_names.each do |name|
|
546
|
+
parent_name = name.split('/')[0]
|
547
|
+
remove_names.append(parent_name)
|
548
|
+
end
|
549
|
+
|
550
|
+
specs.delete_if { |spec|
|
551
|
+
name = spec.spec.name
|
552
|
+
need_remove = false
|
553
|
+
remove_names.each { |r_n|
|
554
|
+
need_remove = true if name == r_n || name == r_n + '/BUAdSDK' || name == r_n + '/CSJMediation'
|
555
|
+
}
|
556
|
+
if need_remove
|
557
|
+
title_options = { :verbose_prefix => '-> '.red }
|
558
|
+
Pod::UserInterface.titled_section("remove #{name}", title_options)
|
559
|
+
true
|
560
|
+
else
|
561
|
+
# 匹配头部,固定CSJM|GM
|
562
|
+
start_right = beta_type != GM::Beta::GM_RELEASE ? name.start_with?('CSJM') : name.start_with?('GM')
|
563
|
+
# 匹配尾部,beta版本以Adapter结尾,正式版本以Beta结尾
|
564
|
+
end_right = (beta_type != GM::Beta::CSJ_BETA && name.end_with?('Adapter-Beta')) || (beta_type == GM::Beta::CSJ_BETA && name.end_with?('Adapter'))
|
565
|
+
result = start_right && end_right
|
566
|
+
if result
|
567
|
+
title_options = { :verbose_prefix => '-> '.red }
|
568
|
+
Pod::UserInterface.titled_section("remove #{name}", title_options)
|
569
|
+
end
|
570
|
+
result
|
571
|
+
end
|
572
|
+
}
|
573
|
+
end
|
574
|
+
|
520
575
|
def self.get_package_name
|
521
576
|
|
522
577
|
project_path = Pod::Config.instance.project_root
|
@@ -539,9 +594,8 @@ module GM
|
|
539
594
|
end
|
540
595
|
|
541
596
|
def self.request_adapter(m_version, adn_list)
|
542
|
-
|
543
597
|
package_name = ['com.bytedance.gromore-inhouse'] ##get_package_name
|
544
|
-
body =
|
598
|
+
body = Hash["package_name" => package_name, "mediation_version" => m_version, "os_type" => "ios", "list" => adn_list]
|
545
599
|
Pod::UserInterface.section '[DEBUG]CSJM plugin Network request data' do
|
546
600
|
puts "请求信息:#{body}"
|
547
601
|
end
|
@@ -549,7 +603,7 @@ module GM
|
|
549
603
|
data = GM::Network.request_adapter(body)
|
550
604
|
config_time_end = (Time.now.to_f * 1000).to_i
|
551
605
|
## 埋点信息
|
552
|
-
push_track config_time_start ,
|
606
|
+
push_track config_time_start, config_time_end, data, m_version
|
553
607
|
|
554
608
|
if data["code"] == "PG0000"
|
555
609
|
## 请求adn数目和返回adapter 个数不一致时进行报错处理
|
@@ -560,7 +614,7 @@ module GM
|
|
560
614
|
{ "adn_name" => hash["adn_name"], "adn_version" => hash["adn_version"] }
|
561
615
|
end
|
562
616
|
end.compact
|
563
|
-
raise "CSJM error:未查找到与#{JSON.generate(unfind_adn_list)}匹配的
|
617
|
+
raise "CSJM error:未查找到与#{JSON.generate(unfind_adn_list)}匹配的Adapter,请更新SDK至合适版本,如有疑问请联系技术支持。"
|
564
618
|
end
|
565
619
|
return data["data"]
|
566
620
|
else
|
@@ -568,7 +622,7 @@ module GM
|
|
568
622
|
case data["code"]
|
569
623
|
when "PG0201"
|
570
624
|
raise "CSJM error: #{data["message"]}(应用ID:#{package_name}),请使用在平台注册的应用ID,如有疑问请联系技术支持。"
|
571
|
-
when "21018"
|
625
|
+
when "21018", "PG21018"
|
572
626
|
raise "CSJM error: #{data["message"]}(应用ID:#{package_name}),如有疑问请联系技术支持。"
|
573
627
|
else
|
574
628
|
raise "CSJM error: #{data["message"]}(应用ID:#{package_name}),如有疑问请联系技术支持。"
|
@@ -579,10 +633,10 @@ module GM
|
|
579
633
|
def self.push_track(config_start_time, config_end_time, response_data, m_version)
|
580
634
|
config_duration = config_end_time - config_start_time
|
581
635
|
package_name = get_package_name
|
582
|
-
event_extra =
|
636
|
+
event_extra = Hash["package_ids" => package_name, "mediation_version" => m_version, "os" => "ios", "config_time_start" => config_start_time, "config_time_end" => config_end_time, "config_duration" => config_duration, "response" => response_data, "plugin_version" => CocoapodsByteCsjm::Version.version]
|
583
637
|
event_extra = event_extra.to_json
|
584
|
-
stats_list = Array.new << Hash["conn_type" => 1, "event_id" => "3C0BA297-0C19-4F68-949A-3196B6F0B895", "timestamp" =>(Time.now.to_f * 1000).to_i
|
585
|
-
body = Hash["ts" =>Time.now.to_i, "stats_list" => stats_list]
|
638
|
+
stats_list = Array.new << Hash["conn_type" => 1, "event_id" => "3C0BA297-0C19-4F68-949A-3196B6F0B895", "timestamp" => (Time.now.to_f * 1000).to_i, "type" => "auto_tools", "event_extra" => event_extra]
|
639
|
+
body = Hash["ts" => Time.now.to_i, "stats_list" => stats_list]
|
586
640
|
# Pod::UserInterface.section '[DEBUG]CSJM plugin Network request data' do
|
587
641
|
# puts "埋点信息:#{body}"
|
588
642
|
# end
|
@@ -615,15 +669,17 @@ end
|
|
615
669
|
class Pod::Resolver
|
616
670
|
|
617
671
|
alias_method :original_search_for, :search_for
|
672
|
+
|
618
673
|
def search_for(dependency)
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
674
|
+
possibilities = original_search_for(dependency) ##返回不可变数组
|
675
|
+
CSJMPlugin.action do |recoder|
|
676
|
+
GM::SpecificationInfo.update dependency.name, possibilities
|
677
|
+
end
|
678
|
+
possibilities
|
624
679
|
end
|
625
680
|
|
626
681
|
alias_method :original_specifications_for_dependency, :specifications_for_dependency
|
682
|
+
|
627
683
|
def specifications_for_dependency(dependency, additional_requirements = [])
|
628
684
|
CSJMPlugin.action do |recoder|
|
629
685
|
if additional_requirements.length > 0 && GM::Adn_Adapter.is_adapter?(dependency.name)
|
@@ -638,16 +694,17 @@ end
|
|
638
694
|
class Pod::Installer::Analyzer
|
639
695
|
|
640
696
|
alias_method :original_resolve_dependencies, :resolve_dependencies
|
697
|
+
|
641
698
|
def resolve_dependencies(locked_dependencies)
|
642
699
|
resolver_specs_by_target = original_resolve_dependencies(locked_dependencies)
|
643
700
|
CSJMPlugin.action do |recoder|
|
644
701
|
resolver_specs_by_target.each do |target, specs|
|
645
702
|
if specs.length > 0
|
646
|
-
Pod::UserInterface.section 'CSJM plugin remove invalid adapter
|
703
|
+
Pod::UserInterface.section 'CSJM plugin remove invalid adapter dependency from loaded dependencies ' do
|
647
704
|
GM::VersionAnalyzer.delete_invalid_adapters target, specs
|
648
705
|
end if GM::Recorder.instance.get_global_note.auto_load
|
649
706
|
|
650
|
-
if target.gm_build_config
|
707
|
+
if target.gm_build_config&.is_release_target
|
651
708
|
Pod::UserInterface.section "CSJM plugin is detected that #{target.label} target is set to `gm_release_target!`, start configuration" do
|
652
709
|
GM::VersionAnalyzer.resolve_release_target target, specs
|
653
710
|
end
|
@@ -684,28 +741,30 @@ module Pod
|
|
684
741
|
end
|
685
742
|
|
686
743
|
alias_method :original_pod, :pod
|
744
|
+
|
687
745
|
def pod(name = nil, *requirements)
|
746
|
+
# 执行注入
|
688
747
|
CSJMPlugin.action do |recoder|
|
689
748
|
if recoder.get_global_note.auto_load
|
690
|
-
unless current_target_definition.
|
691
|
-
current_target_definition.
|
749
|
+
unless current_target_definition.is_add_adapter_dependencies
|
750
|
+
current_target_definition.is_add_adapter_dependencies = true
|
692
751
|
Pod::UserInterface.section 'CSJM plugin start auto load dependencies ' do
|
693
|
-
GM::Adn_Adapter.get_all_adapter.each {|item|
|
694
|
-
if
|
752
|
+
GM::Adn_Adapter.get_all_adapter.each { |item|
|
753
|
+
if GM::Recorder.instance.global_note.auto_load_whitelist.include?(GM::Adn_Adapter.get_adn item) || GM::Recorder.instance.global_note.auto_load_whitelist.size == 0
|
695
754
|
title_options = { :verbose_prefix => '-> '.green }
|
696
|
-
Pod::UserInterface.titled_section("add #{item}", title_options)
|
697
|
-
current_target_definition.store_pod(item,[String.new(">=0")]
|
755
|
+
Pod::UserInterface.titled_section("add #{item}", title_options) # unless item.end_with?('-Beta')
|
756
|
+
current_target_definition.store_pod(item, [String.new(">=0")])
|
698
757
|
end
|
699
758
|
}
|
700
759
|
end
|
701
760
|
end
|
702
761
|
end
|
703
|
-
|
704
762
|
end
|
705
763
|
original_pod(name, *requirements)
|
706
764
|
end
|
707
765
|
|
708
766
|
alias_method :original_plugin, :plugin
|
767
|
+
|
709
768
|
def plugin(name, options = {})
|
710
769
|
if name == 'cocoapods-byte-csjm'
|
711
770
|
GM::Recorder.instance.set_plugin_load true
|
@@ -717,12 +776,49 @@ module Pod
|
|
717
776
|
end
|
718
777
|
|
719
778
|
class TargetDefinition
|
720
|
-
|
721
779
|
attr_reader :gm_release_target
|
722
|
-
attr_accessor :
|
780
|
+
attr_accessor :is_add_adapter_dependencies
|
723
781
|
attr_reader :global_gm_build_config
|
724
782
|
attr_reader :gm_build_config
|
783
|
+
# attr_reader :internal_hash
|
784
|
+
|
785
|
+
def did_pod_csjm_beta(specs)
|
786
|
+
# 检测是否pod依赖
|
787
|
+
beta_type = _did_pod_csjm_beta
|
788
|
+
if beta_type == nil
|
789
|
+
# 以上仅判断是否使用pod依赖进来的,对于媒体封装的组件依赖SDK的情况无效,所以需要继续判断
|
790
|
+
# 遍历每一个spec,判断非adapter,并且依赖mediation的
|
791
|
+
mediation_beta_name = GM::BuildConfig.mediation_name_beta
|
792
|
+
mediation_gm_name = GM::BuildConfig.mediation_name_gm
|
793
|
+
mediation_csj_name = GM::BuildConfig.mediation_name_csj
|
794
|
+
specs.map(&:spec).map { |item|
|
795
|
+
name = item.name
|
796
|
+
unless name.start_with?('CSJM') || name.start_with?('GM')
|
797
|
+
attributes = item.attributes_hash
|
798
|
+
dependencies = attributes['dependencies']
|
799
|
+
if dependencies && dependencies.keys.include?(mediation_beta_name)
|
800
|
+
beta_type = GM::Beta::CSJ_BETA
|
801
|
+
elsif dependencies && dependencies.keys.include?(mediation_gm_name)
|
802
|
+
beta_type = GM::Beta::GM_RELEASE
|
803
|
+
elsif dependencies && dependencies.keys.include?(mediation_csj_name)
|
804
|
+
beta_type = GM::Beta::CSJ_RELEASE
|
805
|
+
end
|
806
|
+
end
|
807
|
+
}
|
808
|
+
end
|
809
|
+
beta_type
|
810
|
+
end
|
725
811
|
|
812
|
+
def _did_pod_csjm_beta
|
813
|
+
list = @internal_hash['dependencies']
|
814
|
+
list.each do |item|
|
815
|
+
item.keys.each do |name|
|
816
|
+
version_type = GM::BuildConfig.mediation_version_type name
|
817
|
+
return version_type if version_type != 0
|
818
|
+
end
|
819
|
+
end
|
820
|
+
nil
|
821
|
+
end
|
726
822
|
|
727
823
|
def gm_release_target!(option = true)
|
728
824
|
|
@@ -730,11 +826,11 @@ module Pod
|
|
730
826
|
case option
|
731
827
|
when true
|
732
828
|
name = String.new("T-") << label
|
733
|
-
@gm_build_config =
|
829
|
+
@gm_build_config = GM::Recorder.instance.get_target name
|
734
830
|
@gm_build_config.is_release_target = option
|
735
831
|
@gm_build_config.referenced_target = name
|
736
832
|
when Hash
|
737
|
-
@gm_build_config =
|
833
|
+
@gm_build_config = GM::Recorder.instance.get_target String.new("T-") << label
|
738
834
|
@gm_build_config.is_release_target = true
|
739
835
|
@gm_build_config.referenced_target = String.new("T-") << option[:referenced]
|
740
836
|
else
|
@@ -747,19 +843,20 @@ module Pod
|
|
747
843
|
end
|
748
844
|
|
749
845
|
alias_method :original_parse_inhibit_warnings, :parse_inhibit_warnings
|
846
|
+
|
750
847
|
def parse_inhibit_warnings(name, requirements)
|
751
848
|
|
752
849
|
CSJMPlugin.action do |recoder|
|
753
850
|
options = requirements.last || {}
|
754
851
|
name = Specification.root_name(name)
|
755
|
-
@gm_build_config =
|
852
|
+
@gm_build_config = recoder.get_target String.new("T-") << label
|
756
853
|
if GM::Adn_Adapter.is_adn?(name)
|
757
|
-
load_key
|
758
|
-
update_key
|
854
|
+
load_key = GM::BuildConfig.get_load_key
|
855
|
+
update_key = GM::BuildConfig.get_update_key
|
759
856
|
load_detect_key = GM::BuildConfig.get_load_detect_key
|
760
857
|
|
761
858
|
gm_note = @gm_build_config.find_note name
|
762
|
-
GM::BuildConfig.get_all_config.each{|item|
|
859
|
+
GM::BuildConfig.get_all_config.each { |item|
|
763
860
|
if options.is_a?(Hash) && options[item] != nil
|
764
861
|
# gm_note.auto_load = options[item] if item == load_key ## adn维度 auto_load 失效
|
765
862
|
gm_note.load_detect = options[item] if item == load_detect_key
|
@@ -774,6 +871,7 @@ module Pod
|
|
774
871
|
end
|
775
872
|
|
776
873
|
private
|
874
|
+
|
777
875
|
def adapter_update_config(update_value)
|
778
876
|
value = ''
|
779
877
|
is_update = false
|
@@ -785,7 +883,7 @@ module Pod
|
|
785
883
|
value = GM::BuildConfig.update_value_non
|
786
884
|
when String
|
787
885
|
value = update_value
|
788
|
-
is_update
|
886
|
+
is_update = true if update_value == GM::BuildConfig.update_value_last_version || update_value == GM::BuildConfig.update_value_non
|
789
887
|
else
|
790
888
|
raise ArgumentError, "CSJM error: `#{update_value.inspect}`, 应该设置为布尔值"
|
791
889
|
end
|
@@ -35,5 +35,33 @@ module GM
|
|
35
35
|
def Network.push_track(body)
|
36
36
|
data = post("https://gromore.pangolin-sdk-toutiao.com/api/ad/union/mediation/stats/",body)
|
37
37
|
end
|
38
|
+
|
39
|
+
def Network.latest_version
|
40
|
+
url = URI.parse('https://sf3-fe-tos.pglstatp-toutiao.com/obj/csj-sdk-static/cocoapods-byte-csjm/latest_version.txt')
|
41
|
+
http = Net::HTTP.new(url.host, url.port)
|
42
|
+
http.use_ssl = true
|
43
|
+
request = Net::HTTP::Get.new(url)
|
44
|
+
response = http.request(request)
|
45
|
+
if response.code == '200'
|
46
|
+
result = response.body
|
47
|
+
return result
|
48
|
+
else
|
49
|
+
return nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def Network.csj_did_release
|
54
|
+
url = URI.parse('https://cdn.cocoapods.org/all_pods_versions_a_9_a.txt') # GMGdtAdapter所在的地址
|
55
|
+
http = Net::HTTP.new(url.host, url.port)
|
56
|
+
http.use_ssl = true
|
57
|
+
request = Net::HTTP::Get.new(url)
|
58
|
+
response = http.request(request)
|
59
|
+
if response.code == '200'
|
60
|
+
result = response.body
|
61
|
+
return result.include?('GMGdtAdapter')
|
62
|
+
# return result.include?('AtomicSDK')
|
63
|
+
end
|
64
|
+
false
|
65
|
+
end
|
38
66
|
end
|
39
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-byte-csjm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- zhangtianhao.1230@bytedance.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -69,9 +69,6 @@ files:
|
|
69
69
|
- LICENSE.txt
|
70
70
|
- README.md
|
71
71
|
- Rakefile
|
72
|
-
- cocoapods-byte-csjm-0.0.4.gem
|
73
|
-
- cocoapods-byte-csjm-0.0.5.gem
|
74
|
-
- cocoapods-byte-csjm-0.0.6.gem
|
75
72
|
- cocoapods-byte-csjm.gemspec
|
76
73
|
- lib/cocoapods-byte-csjm.rb
|
77
74
|
- lib/cocoapods-byte-csjm/config.rb
|
@@ -101,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
98
|
- !ruby/object:Gem::Version
|
102
99
|
version: '0'
|
103
100
|
requirements: []
|
104
|
-
rubygems_version: 3.
|
101
|
+
rubygems_version: 3.5.4
|
105
102
|
signing_key:
|
106
103
|
specification_version: 4
|
107
104
|
summary: a plugin for csjm
|
Binary file
|
Binary file
|
Binary file
|