cocoapods-byte-panglem 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +22 -0
- data/README.md +11 -0
- data/Rakefile +13 -0
- data/cocoapods-byte-panglem.gemspec +25 -0
- data/lib/cocoapods-byte-panglem/analyzer.rb +212 -0
- data/lib/cocoapods-byte-panglem/command.rb +4 -0
- data/lib/cocoapods-byte-panglem/config.rb +174 -0
- data/lib/cocoapods-byte-panglem/gem_version.rb +11 -0
- data/lib/cocoapods-byte-panglem/net.rb +68 -0
- data/lib/cocoapods-byte-panglem/panglem.rb +203 -0
- data/lib/cocoapods-byte-panglem/plugin.rb +2 -0
- data/lib/cocoapods-byte-panglem/recorder.rb +464 -0
- data/lib/cocoapods-byte-panglem/tool.rb +62 -0
- data/lib/cocoapods-byte-panglem.rb +4 -0
- data/lib/cocoapods_plugin.rb +4 -0
- data/spec/command/panglem_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +125 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
##Copyright 2023 ByteDance Ltd. and/or its affiliates
|
2
|
+
##SPDX-License-Identifier: MIT
|
3
|
+
|
4
|
+
require 'cocoapods'
|
5
|
+
require 'singleton'
|
6
|
+
require 'cocoapods-byte-panglem/gem_version'
|
7
|
+
require 'digest'
|
8
|
+
require "thread"
|
9
|
+
|
10
|
+
require_relative 'net'
|
11
|
+
require_relative 'config'
|
12
|
+
require_relative 'tool'
|
13
|
+
require_relative 'analyzer'
|
14
|
+
require_relative 'recorder'
|
15
|
+
require_relative 'plugin'
|
16
|
+
|
17
|
+
module PMPlugin
|
18
|
+
def PMPlugin.action()
|
19
|
+
recoder= PM::Recorder.instance
|
20
|
+
if recoder.is_load_plugin
|
21
|
+
yield(recoder) if block_given?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def PMPlugin.update()
|
26
|
+
# puts "[cocoapods-byte-panglem][debug]checking for updates..."
|
27
|
+
command = 'gem install cocoapods-byte-panglem'
|
28
|
+
stdout, stderr, status = Open3.capture3(command)
|
29
|
+
|
30
|
+
if status.success?
|
31
|
+
# puts "[cocoapods-byte-panglem][debug] update sucess"
|
32
|
+
else
|
33
|
+
# puts "[cocoapods-byte-panglem][debug] update fail message:#{stderr}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
class Xcodeproj::Project::Object::XCBuildConfiguration
|
40
|
+
## 重写属性
|
41
|
+
attr_accessor :simple_attributes_hash
|
42
|
+
end
|
43
|
+
|
44
|
+
class Pod::Resolver
|
45
|
+
|
46
|
+
alias_method :original_search_for, :search_for
|
47
|
+
def search_for(dependency)
|
48
|
+
possibilities = original_search_for(dependency) ##返回不可变数组
|
49
|
+
PMPlugin.action do |recoder|
|
50
|
+
PM::SpecificationInfo.update Pod::Specification.root_name(dependency.name) , possibilities
|
51
|
+
end
|
52
|
+
possibilities
|
53
|
+
end
|
54
|
+
|
55
|
+
alias_method :original_specifications_for_dependency, :specifications_for_dependency
|
56
|
+
def specifications_for_dependency(dependency, additional_requirements = [])
|
57
|
+
PMPlugin.action do |recoder|
|
58
|
+
if PM::MapRelations.should_remove_requirements?(Pod::Specification.root_name(dependency.name))
|
59
|
+
additional_requirements = []
|
60
|
+
dependency = Pod::Dependency.new(dependency.name)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
original_specifications_for_dependency(dependency, additional_requirements)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class Pod::Installer::Analyzer
|
68
|
+
|
69
|
+
alias_method :original_resolve_dependencies, :resolve_dependencies
|
70
|
+
def resolve_dependencies(locked_dependencies)
|
71
|
+
resolver_specs_by_target = original_resolve_dependencies(locked_dependencies)
|
72
|
+
PMPlugin.action do |recoder|
|
73
|
+
resolver_specs_by_target.each do |target, specs|
|
74
|
+
|
75
|
+
if specs.length > 0
|
76
|
+
## SDK 场景下 不需要
|
77
|
+
# Pod::UserInterface.section 'cocoapods-byte-panglem remove invalid dependencie from loaded dependencies ' do
|
78
|
+
# PM::Analyzer.delete_invalid_adapters target, specs
|
79
|
+
# end if PM::Recorder.instance.get_global_note.auto_load
|
80
|
+
|
81
|
+
|
82
|
+
if PM::Recorder.instance.is_release
|
83
|
+
Pod::UserInterface.section "[cocoapods-byte-panglem][info] start trying to update the sdk version (when is_release is yes) " do
|
84
|
+
PM::Analyzer.resolve_release_target target, specs
|
85
|
+
end
|
86
|
+
else
|
87
|
+
Pod::UserInterface.section '[cocoapods-byte-panglem][info] start trying to update the sdk version ' do
|
88
|
+
is_update_finish = PM::Analyzer.resolve_last target, specs
|
89
|
+
if is_update_finish
|
90
|
+
Pod::UserInterface.section '[cocoapods-byte-panglem][info] write Podfile.pangle.lock' do
|
91
|
+
write_lock_file recoder
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
resolver_specs_by_target
|
100
|
+
end
|
101
|
+
|
102
|
+
def write_lock_file(recoder)
|
103
|
+
PM::Lockfile.new(recoder.to_hash).write_to_disk(File.expand_path("#{Pod::Config.instance.installation_root}/Podfile.pangle"))
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
module Pod
|
108
|
+
|
109
|
+
class Podfile
|
110
|
+
|
111
|
+
module DSL
|
112
|
+
def use_pangm_sdk_update!(option = true)
|
113
|
+
current_target_definition.use_pangm_sdk_update!(option)
|
114
|
+
end
|
115
|
+
|
116
|
+
def pangm_release_target!(option = true)
|
117
|
+
current_target_definition.pangm_release_target!(option)
|
118
|
+
end
|
119
|
+
|
120
|
+
alias_method :original_plugin, :plugin
|
121
|
+
def plugin(name, options = {})
|
122
|
+
if name == 'cocoapods-byte-panglem'
|
123
|
+
PM::Recorder.instance.set_plugin_load true
|
124
|
+
case options
|
125
|
+
when Hash
|
126
|
+
PM::Recorder.instance.set_is_debug options[:is_debug]
|
127
|
+
end
|
128
|
+
|
129
|
+
PMPlugin.update
|
130
|
+
end
|
131
|
+
original_plugin(name, options)
|
132
|
+
end
|
133
|
+
|
134
|
+
# alias_method :original_target, :target
|
135
|
+
# def target(name, options = nil)
|
136
|
+
# relust = original_target(name, options)
|
137
|
+
|
138
|
+
# result
|
139
|
+
# end
|
140
|
+
|
141
|
+
alias_method :original_pod, :pod
|
142
|
+
def pod(name = nil, *requirements)
|
143
|
+
## SDK 场景不需要
|
144
|
+
# PMPlugin.action do |recoder|
|
145
|
+
# unless current_target_definition.have_add_dependencys
|
146
|
+
# current_target_definition.have_add_dependencys = true
|
147
|
+
# ask_name = PM::MapRelations.get_sdk
|
148
|
+
# current_target_definition.store_pod(PM::MapRelations.get_sdk, [])
|
149
|
+
# end if recoder.get_global_note.auto_load
|
150
|
+
# end
|
151
|
+
original_pod(name, *requirements)
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
class TargetDefinition
|
158
|
+
|
159
|
+
## 媒体线上版本target的标识
|
160
|
+
attr_reader :pangm_release_target
|
161
|
+
|
162
|
+
## 是否已自动加载了库
|
163
|
+
attr_accessor :have_add_dependencys
|
164
|
+
|
165
|
+
## rarget维度的配置信息
|
166
|
+
attr_reader :pm_build_config
|
167
|
+
|
168
|
+
def use_pangm_sdk_update!(option)
|
169
|
+
@global_pm_build_config = PM::Recorder.instance.find_global_note option
|
170
|
+
end
|
171
|
+
|
172
|
+
## SDK 暂不需要
|
173
|
+
def pangm_release_target!(option = true)
|
174
|
+
|
175
|
+
raise ArgumentError, "cocoapods-byte-panglem The `pangm_release_target!` configuration item needs to be set in a specific target, do not set it globally" if @label == "Pods"
|
176
|
+
name = String.new("T-") << label
|
177
|
+
case option
|
178
|
+
when true
|
179
|
+
@pm_build_config = PM::Recorder.instance.get_target name
|
180
|
+
@pm_build_config.is_release_target = option
|
181
|
+
@pm_build_config.referenced_target = name
|
182
|
+
when Hash
|
183
|
+
@pm_build_config = PM::Recorder.instance.get_target name
|
184
|
+
@pm_build_config.is_release_target = true
|
185
|
+
@pm_build_config.referenced_target = String.new("T-") << option[:referenced]
|
186
|
+
else
|
187
|
+
raise ArgumentError, "CSJM error: `#{option.inspect}`, should be a true or a target name"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
original_parse_inhibit_warnings = instance_method(:parse_inhibit_warnings)
|
192
|
+
define_method(:parse_inhibit_warnings) do |name, requirements|
|
193
|
+
PMPlugin.action do |recoder|
|
194
|
+
## 这里去掉adapter 大部分逻辑部分
|
195
|
+
@pm_build_config = recoder.get_target String.new("T-") << label
|
196
|
+
end
|
197
|
+
original_parse_inhibit_warnings.bind(self).call(name, requirements)
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
@@ -0,0 +1,464 @@
|
|
1
|
+
##Copyright 2023 ByteDance Ltd. and/or its affiliates
|
2
|
+
##SPDX-License-Identifier: MIT
|
3
|
+
|
4
|
+
require 'cocoapods'
|
5
|
+
require_relative 'net'
|
6
|
+
require_relative 'config'
|
7
|
+
require_relative 'tool'
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
module Pod
|
12
|
+
class Specification
|
13
|
+
|
14
|
+
def get_default_subspec_name
|
15
|
+
@attributes_hash["default_subspecs"].first
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_subspecs
|
19
|
+
# default_name = @attributes_hash["default_subspecs"].first
|
20
|
+
subspecs = []
|
21
|
+
name_list_a = []
|
22
|
+
rely_spec_version = ""
|
23
|
+
@subspecs.map do |spec|
|
24
|
+
puts "s:#{spec.class}"
|
25
|
+
get_dependencies spec.name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_dependencies(spec_name)
|
30
|
+
depens = spec.dependencies
|
31
|
+
# name_list = []
|
32
|
+
# depens.map do |den|
|
33
|
+
# if den.name.length > 0
|
34
|
+
# name_list | get_dependencies den.name
|
35
|
+
# name_list << den.name
|
36
|
+
# end
|
37
|
+
# end if depens.length > 0
|
38
|
+
# name_list
|
39
|
+
end
|
40
|
+
|
41
|
+
# def get_specfication(spec_name)
|
42
|
+
# end
|
43
|
+
|
44
|
+
def get_rely_version
|
45
|
+
hash = @attributes_hash
|
46
|
+
|
47
|
+
subs = @subspecs
|
48
|
+
subs
|
49
|
+
dep_accurate_sperc = @subspecs.select do |spec|
|
50
|
+
spec.name == "Ads-Global/Dep_Accurate"
|
51
|
+
end.first
|
52
|
+
dep_accurate_sperc.dependencies.first.get_requirment
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class Dependency
|
57
|
+
def get_requirment
|
58
|
+
@requirement.requirements.first.last.version
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
module PM
|
64
|
+
|
65
|
+
# 记录Pangle SDK版本信息
|
66
|
+
#
|
67
|
+
class Info
|
68
|
+
attr_accessor :name
|
69
|
+
attr_accessor :version
|
70
|
+
def initialize(name, version)
|
71
|
+
@name = name
|
72
|
+
@version = version
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_hash
|
76
|
+
hash = {}
|
77
|
+
hash["NAME"] = @name
|
78
|
+
hash["VERSION"] = @version
|
79
|
+
hash
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.from_hash(hash)
|
83
|
+
Info.new(hash["NAME"],hash["VERSION"])
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# SDK 信息
|
88
|
+
class SDKInfo < Info
|
89
|
+
end
|
90
|
+
|
91
|
+
# Mediation信息
|
92
|
+
class MInfo < Info
|
93
|
+
end
|
94
|
+
|
95
|
+
# 配置信息
|
96
|
+
#
|
97
|
+
class Note
|
98
|
+
attr_accessor :auto_load
|
99
|
+
attr_accessor :auto_update
|
100
|
+
attr_accessor :load_detect
|
101
|
+
def get_update(update_value)
|
102
|
+
value = ''
|
103
|
+
case update_value
|
104
|
+
when true
|
105
|
+
value = PM::BuildConfig.update_value_last_version
|
106
|
+
when false
|
107
|
+
value = PM::BuildConfig.update_value_non
|
108
|
+
when String
|
109
|
+
value = update_value
|
110
|
+
else
|
111
|
+
raise ArgumentError, "CSJM error: `#{update_value.inspect}`, should be a boolean or string."
|
112
|
+
end
|
113
|
+
value
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
class GlobalNote < Note
|
118
|
+
attr_accessor :auto_load_whitelist
|
119
|
+
attr_accessor :use_service_local
|
120
|
+
attr_reader :is_release
|
121
|
+
def initialize(auto_load = true , auto_update = PM::BuildConfig.update_value_last_version, load_detect = true, auto_load_whitelist = {},is_release = false)
|
122
|
+
@auto_load = auto_load
|
123
|
+
@auto_update = get_update auto_update
|
124
|
+
@load_detect = load_detect
|
125
|
+
@auto_load_whitelist = auto_load_whitelist
|
126
|
+
@is_release = is_release
|
127
|
+
end
|
128
|
+
|
129
|
+
def to_hash
|
130
|
+
hash = {}
|
131
|
+
hash["AUTO_LOAD"] = @auto_load
|
132
|
+
hash["AUTO_UPDATE"] = @auto_update
|
133
|
+
hash["LOAD_DETECT"] = @load_detect
|
134
|
+
hash["AUTO_LOAD_WHITELIST"] = @auto_load_whitelist
|
135
|
+
hash
|
136
|
+
end
|
137
|
+
|
138
|
+
def self.from_hash(hash)
|
139
|
+
global_note = GlobalNote.new()
|
140
|
+
global_note.auto_load = hash["AUTO_LOAD"] if hash.has_key?("AUTO_LOAD")
|
141
|
+
global_note.auto_update = hash["AUTO_UPDATE"] if hash.has_key?("AUTO_UPDATE")
|
142
|
+
global_note.load_detect = hash["LOAD_DETECT"] if hash.has_key?("LOAD_DETECT")
|
143
|
+
global_note.auto_load_whitelist = hash["AUTO_LOAD_WHITELIST"] if hash.has_key?("AUTO_LOAD_WHITELIST")
|
144
|
+
global_note
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
class AdnNote < Note
|
149
|
+
|
150
|
+
attr_accessor :adn_name
|
151
|
+
attr_accessor :adn_version
|
152
|
+
attr_accessor :adapter_name
|
153
|
+
attr_accessor :adapter_original_version ##加载的版本号
|
154
|
+
attr_accessor :adapter_expected_version ##期望加载的版本号
|
155
|
+
|
156
|
+
def initialize(adn_name, auto_load = false , auto_update = PM::BuildConfig.update_value_non, load_detect = false)
|
157
|
+
@adn_name = adn_name
|
158
|
+
@adapter_name = PM::MapRelations.get_adapter adn_name
|
159
|
+
@auto_load = auto_load
|
160
|
+
@auto_update = get_update auto_update
|
161
|
+
@load_detect = load_detect
|
162
|
+
end
|
163
|
+
|
164
|
+
def to_hash
|
165
|
+
hash = {}
|
166
|
+
hash["ADN_NAME"] = @adn_name
|
167
|
+
hash["ADN_VERSION"] = @adn_version
|
168
|
+
hash["ADAPTER_NAME"] = @adapter_name
|
169
|
+
hash["ADAPTER_ORIGINAL_VERSION"] = @adapter_original_version
|
170
|
+
hash["ADAPTER_EXPECTED_VERSION"] = @adapter_expected_version
|
171
|
+
hash["AUTO_LOAD"] = @auto_load
|
172
|
+
hash["AUTO_UPDATE"] = @auto_update
|
173
|
+
hash["LOAD_DETECT"] = @load_detect
|
174
|
+
hash
|
175
|
+
end
|
176
|
+
|
177
|
+
def self.from_hash(hash)
|
178
|
+
note = AdnNote.new(hash["ADN_NAME"],hash["AUTO_LOAD"],hash["AUTO_UPDATE"],hash["LOAD_DETECT"])
|
179
|
+
note.adn_name = hash["ADN_NAME"]
|
180
|
+
note.adn_version = hash["ADN_VERSION"]
|
181
|
+
note.adapter_name = hash["ADAPTER_NAME"]
|
182
|
+
note.adapter_original_version = hash["ADAPTER_ORIGINAL_VERSION"]
|
183
|
+
note.adapter_expected_version = hash["ADAPTER_EXPECTED_VERSION"]
|
184
|
+
note
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
class UpdateResut
|
189
|
+
attr_accessor :is_sdk_update
|
190
|
+
attr_accessor :is_rely_update
|
191
|
+
attr_accessor :sdk_list
|
192
|
+
attr_accessor :rely_list
|
193
|
+
attr_accessor :sdk_name
|
194
|
+
attr_accessor :rely_name
|
195
|
+
attr_accessor :sdk_original_version
|
196
|
+
attr_accessor :rely_original_version
|
197
|
+
attr_accessor :sdk_target_version
|
198
|
+
attr_accessor :rely_target_version
|
199
|
+
|
200
|
+
def initialize()
|
201
|
+
@is_sdk_update = false
|
202
|
+
@is_rely_update = false
|
203
|
+
@sdk_list = []
|
204
|
+
@rely_list = []
|
205
|
+
end
|
206
|
+
|
207
|
+
def self.from_hash(hash)
|
208
|
+
re = UpdateResut.new()
|
209
|
+
re.sdk_name = "Ads-Global"
|
210
|
+
re.rely_name = "BURelyFoundation_Global"
|
211
|
+
re.sdk_original_version = hash["SDK_ORIGINAL_VERSION"]
|
212
|
+
re.sdk_target_version = hash["SDK_TARGET_VERSION"]
|
213
|
+
re.rely_original_version = hash['RELY_ORIGINAL_VERSION']
|
214
|
+
re.rely_target_version = hash['RELY_TARGET_VERSION']
|
215
|
+
re.is_sdk_update = re.sdk_original_version != re.sdk_target_version
|
216
|
+
re.is_rely_update = re.rely_original_version != re.rely_target_version
|
217
|
+
info_r = PM::SpecificationInfo.get_info
|
218
|
+
re.sdk_list = info_r[re.sdk_name].select do |spec|
|
219
|
+
Pod::Specification.root_name(spec.name) == re.sdk_name && spec.version.version == re.sdk_target_version
|
220
|
+
end
|
221
|
+
re.rely_list = info_r[ re.rely_name].select do |spec|
|
222
|
+
Pod::Specification.root_name(spec.name) == re.rely_name && spec.version.version == re.rely_target_version
|
223
|
+
end
|
224
|
+
re
|
225
|
+
end
|
226
|
+
|
227
|
+
end
|
228
|
+
# 配置信息 (cocoapods target维度下)
|
229
|
+
#
|
230
|
+
class Target
|
231
|
+
|
232
|
+
attr_accessor :is_release_target
|
233
|
+
attr_accessor :referenced_target
|
234
|
+
attr_reader :label
|
235
|
+
attr_accessor :PM_info
|
236
|
+
attr_accessor :nots_info
|
237
|
+
|
238
|
+
def initialize(label)
|
239
|
+
@label = label.clone
|
240
|
+
@is_release_target = false
|
241
|
+
end
|
242
|
+
|
243
|
+
def find_note(adn_name)
|
244
|
+
@nots_info ||= {}
|
245
|
+
global_note = PM::Recorder.instance.global_note
|
246
|
+
note = (@nots_info.has_key?(adn_name) && @nots_info[adn_name]) || AdnNote.new(adn_name, global_note.auto_load, global_note.auto_update, global_note.load_detect)
|
247
|
+
@nots_info[adn_name] = note unless @nots_info.has_key?(adn_name)
|
248
|
+
note
|
249
|
+
end
|
250
|
+
|
251
|
+
def has_adn?(adn_name)
|
252
|
+
PM::MapRelations.is_adn?(adn_name) && @nots_info.has_key?(adn_name)
|
253
|
+
end
|
254
|
+
|
255
|
+
def is_adn_update_or_detect?(adn_name)
|
256
|
+
result = is_adn_update?(adn_name) || is_adn_detect?(adn_name)
|
257
|
+
result
|
258
|
+
end
|
259
|
+
|
260
|
+
def is_adn_update?(adn_name)
|
261
|
+
result = has_adn?(adn_name) && @nots_info[adn_name].auto_update != PM::BuildConfig.update_value_non
|
262
|
+
result
|
263
|
+
end
|
264
|
+
|
265
|
+
def is_adn_detect?(adn_name)
|
266
|
+
has_adn?(adn_name) && @nots_info[adn_name].load_detect
|
267
|
+
end
|
268
|
+
|
269
|
+
def to_hash
|
270
|
+
hash = {}
|
271
|
+
hash["LABEL"] = @label
|
272
|
+
hash["IS_RELEASE_TARGET"] = @is_release_target
|
273
|
+
hash["PM_INFO"] = @pm_info.to_hash
|
274
|
+
hash["NOTS_INFO"] = {}
|
275
|
+
@nots_info.each {|key, value|
|
276
|
+
hash["NOTS_INFO"][key] = value.to_hash
|
277
|
+
}
|
278
|
+
hash
|
279
|
+
end
|
280
|
+
|
281
|
+
def self.from_hash(hash)
|
282
|
+
target = Target.new(hash["LABEL"])
|
283
|
+
target.is_release_target = true
|
284
|
+
target.PM_info = PMInfo.from_hash hash["PM_INFO"] if hash.has_key?("PM_INFO")
|
285
|
+
target.nots_info ||= {}
|
286
|
+
hash["NOTS_INFO"].each do |name, note_info|
|
287
|
+
target.nots_info[name] = AdnNote.from_hash note_info
|
288
|
+
end
|
289
|
+
target
|
290
|
+
end
|
291
|
+
|
292
|
+
end
|
293
|
+
|
294
|
+
# 记录方
|
295
|
+
#
|
296
|
+
class Recorder
|
297
|
+
|
298
|
+
include Singleton
|
299
|
+
attr_accessor :global_note
|
300
|
+
attr_accessor :target_info
|
301
|
+
attr_accessor :sdk_original_version
|
302
|
+
attr_accessor :rely_original_version
|
303
|
+
attr_accessor :sdk_target_version
|
304
|
+
attr_accessor :rely_target_version
|
305
|
+
attr_accessor :adapter_list
|
306
|
+
attr_reader :is_load_plugin
|
307
|
+
attr_reader :plugin_version
|
308
|
+
attr_reader :lockfile_data
|
309
|
+
attr_reader :is_debug
|
310
|
+
|
311
|
+
|
312
|
+
def initialize()
|
313
|
+
@adapter_list = []
|
314
|
+
@is_debug = false
|
315
|
+
end
|
316
|
+
|
317
|
+
def set_plugin_load(is_load)
|
318
|
+
@is_load_plugin = is_load
|
319
|
+
@plugin_version = CocoapodsBytePanglem::Version.version
|
320
|
+
end
|
321
|
+
|
322
|
+
def set_is_debug(is_debug)
|
323
|
+
@is_debug = is_debug
|
324
|
+
end
|
325
|
+
|
326
|
+
def add_global_note(note)
|
327
|
+
@global_note = note
|
328
|
+
end
|
329
|
+
|
330
|
+
def find_global_note(option, is_force_update = false)
|
331
|
+
|
332
|
+
return @global_note if !is_force_update && @global_note != nil
|
333
|
+
@global_note = GlobalNote.new(false, PM::BuildConfig.update_value_non, false)
|
334
|
+
load_key = PM::BuildConfig.get_load_key
|
335
|
+
update_key = PM::BuildConfig.get_update_key
|
336
|
+
load_detect_key = PM::BuildConfig.get_load_detect_key
|
337
|
+
auto_load_whitelist_key = PM::BuildConfig.get_load_whitelist_key
|
338
|
+
is_release_key = PM::BuildConfig.get_is_release_key
|
339
|
+
use_service_local_key = PM::BuildConfig.get_use_service_local_key
|
340
|
+
|
341
|
+
case option
|
342
|
+
when true, false
|
343
|
+
@global_note = PM::GlobalNote.new(option,option,option,{})
|
344
|
+
when Hash
|
345
|
+
load_value = option.has_key?(load_key) ? option[load_key] : true
|
346
|
+
update_value = option.has_key?(update_key) ? option[update_key] : true
|
347
|
+
detect_value = option.has_key?(load_detect_key) ? option[load_detect_key] : true
|
348
|
+
auto_load_whitelist = option.has_key?(auto_load_whitelist_key)?option[auto_load_whitelist_key] : {}
|
349
|
+
is_release = option.has_key?(is_release_key)?option[is_release_key] : false
|
350
|
+
@global_note = PM::GlobalNote.new(load_value, update_value,detect_value,auto_load_whitelist, is_release)
|
351
|
+
@global_note.use_service_local = option.has_key?(use_service_local_key)?option[use_service_local_key] : false
|
352
|
+
else
|
353
|
+
raise ArgumentError, "[cocoapods-byte-panglem][error] `#{option.inspect}`, should be a boolean or hash."
|
354
|
+
end
|
355
|
+
@global_note
|
356
|
+
end
|
357
|
+
|
358
|
+
def get_global_note
|
359
|
+
@global_note
|
360
|
+
end
|
361
|
+
|
362
|
+
def get_target(label)
|
363
|
+
@target_info ||= {}
|
364
|
+
@target_info[label] ||= Target.new(label)
|
365
|
+
end
|
366
|
+
|
367
|
+
def is_release()
|
368
|
+
@global_note.is_release
|
369
|
+
end
|
370
|
+
|
371
|
+
def use_service_local()
|
372
|
+
@global_note.use_service_local
|
373
|
+
end
|
374
|
+
|
375
|
+
def to_hash
|
376
|
+
hash = {}
|
377
|
+
hash["IS_LOAD_PLUGIN"] = @is_load_plugin
|
378
|
+
hash["PLUGIN_VERSION"] = @plugin_version
|
379
|
+
hash["SDK_ORIGINAL_VERSION"] = @sdk_original_version
|
380
|
+
hash["RELY_ORIGINAL_VERSION"] = @rely_original_version
|
381
|
+
hash["SDK_TARGET_VERSION"] = @sdk_target_version
|
382
|
+
hash["RELY_TARGET_VERSION"] = @rely_target_version
|
383
|
+
hash["ADAPTER_LIST"] = @adapter_list
|
384
|
+
checksum = Digest::SHA1.hexdigest(hash.inspect)
|
385
|
+
checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode)
|
386
|
+
hash["RECODER_CHECKSUM"] = checksum
|
387
|
+
hash
|
388
|
+
end
|
389
|
+
end
|
390
|
+
|
391
|
+
# 对应cocoapods 的Specification
|
392
|
+
#
|
393
|
+
class SpecificationInfo
|
394
|
+
@@possibilities = {}
|
395
|
+
def self.update(name = '', possibilities)
|
396
|
+
if name.length > 0
|
397
|
+
@@possibilities[name] ||= []
|
398
|
+
@@possibilities[name] = @@possibilities[name] | possibilities
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
def self.get_info()
|
403
|
+
@@possibilities
|
404
|
+
end
|
405
|
+
|
406
|
+
def self.get_a_specfication(name, version)
|
407
|
+
result = @@possibilities[name].find { |specification|
|
408
|
+
specification.version.version == version
|
409
|
+
}
|
410
|
+
result
|
411
|
+
end
|
412
|
+
|
413
|
+
def self.get_specfication(response_data ={}, original_sdk_spec)
|
414
|
+
|
415
|
+
## 这里需要获取到所有需要获取SDK期望版本下 所有subspec的specfication集合.
|
416
|
+
## 1. 获取到期望sdk的版本号 和 基础库的版本号
|
417
|
+
## 2. 计算出所有需要的subspec的名称
|
418
|
+
## 3. 计算出升级时需要替换的所有的specfication
|
419
|
+
info_r = get_info
|
420
|
+
target_sdk_version = response_data["data"]["pangle_sdk_version"]
|
421
|
+
if target_sdk_version == nil || target_sdk_version.length == 0
|
422
|
+
## 兜底, 赋值为当前版本
|
423
|
+
target_sdk_version = original_sdk_spec.spec.version.version
|
424
|
+
end
|
425
|
+
sdk_name = "Ads-Global"
|
426
|
+
rely_name = "BURelyFoundation_Global"
|
427
|
+
result = UpdateResut.new()
|
428
|
+
result.sdk_name = sdk_name
|
429
|
+
result.rely_name = rely_name
|
430
|
+
target_sdk_root_spec = nil
|
431
|
+
target_sdk_spec_list = info_r[sdk_name].select do |spec|
|
432
|
+
target_sdk_root_spec = spec if spec.name == sdk_name && spec.version.version == target_sdk_version
|
433
|
+
Pod::Specification.root_name(spec.name) == sdk_name && spec.version.version == target_sdk_version
|
434
|
+
end
|
435
|
+
if target_sdk_root_spec == nil
|
436
|
+
raise "[cocoapods-byte-panglem][error] pangle sdk version:#{target_sdk_version} not found, please try use `pod install --repo-update`"
|
437
|
+
end
|
438
|
+
if target_sdk_root_spec.version.version != original_sdk_spec.spec.version.version
|
439
|
+
|
440
|
+
result.is_sdk_update = true
|
441
|
+
result.sdk_list = target_sdk_spec_list
|
442
|
+
result.sdk_original_version = original_sdk_spec.spec.version.version
|
443
|
+
result.sdk_target_version = target_sdk_root_spec.version.version
|
444
|
+
PM::Recorder.instance.sdk_original_version = result.sdk_original_version
|
445
|
+
PM::Recorder.instance.sdk_target_version = result.sdk_target_version
|
446
|
+
target_rely_version = target_sdk_root_spec.get_rely_version
|
447
|
+
original_rely_version = original_sdk_spec.spec.get_rely_version
|
448
|
+
# target_rely_version = "0.2.0.0"
|
449
|
+
if target_rely_version != original_rely_version
|
450
|
+
target_rely_spec_list = info_r[rely_name].select do |spec|
|
451
|
+
Pod::Specification.root_name(spec.name) == rely_name && spec.version.version == target_rely_version
|
452
|
+
end
|
453
|
+
result.is_rely_update = true
|
454
|
+
result.rely_list = target_rely_spec_list
|
455
|
+
result.rely_original_version = original_rely_version
|
456
|
+
result.rely_target_version = target_rely_version
|
457
|
+
PM::Recorder.instance.rely_original_version = result.rely_original_version
|
458
|
+
PM::Recorder.instance.rely_target_version = result.rely_target_version
|
459
|
+
end
|
460
|
+
end
|
461
|
+
result
|
462
|
+
end
|
463
|
+
end
|
464
|
+
end
|