cocoapods-bb-PodAssistant 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/lib/cocoapods-bb-PodAssistant/babybus/business/babybus_install_environment.rb +129 -0
- data/lib/cocoapods-bb-PodAssistant/babybus/helpers/babybus_info_plist_helper.rb +92 -0
- data/lib/cocoapods-bb-PodAssistant/babybus/installer/post_install_hooks.rb +111 -0
- data/lib/cocoapods-bb-PodAssistant/command/PodAssistant.rb +44 -0
- data/lib/cocoapods-bb-PodAssistant/command/linkline/linkline.rb +68 -0
- data/lib/cocoapods-bb-PodAssistant/command/linkline/target-linkline.rb +9 -0
- data/lib/cocoapods-bb-PodAssistant/command/linkline/targetValidator-linkline.rb +25 -0
- data/lib/cocoapods-bb-PodAssistant/command/linkline/targetdefinition-linkline.rb +37 -0
- data/lib/cocoapods-bb-PodAssistant/command/stable/podfile-linkline.rb +9 -0
- data/lib/cocoapods-bb-PodAssistant/command/stable/stable.rb +168 -0
- data/lib/cocoapods-bb-PodAssistant/command.rb +9 -0
- data/lib/cocoapods-bb-PodAssistant/config/cache_path.rb +16 -0
- data/lib/cocoapods-bb-PodAssistant/config/source_manager.rb +389 -0
- data/lib/cocoapods-bb-PodAssistant/config/stable_source.rb +7 -0
- data/lib/cocoapods-bb-PodAssistant/config/stable_specs.rb +27 -0
- data/lib/cocoapods-bb-PodAssistant/gem_version.rb +3 -0
- data/lib/cocoapods-bb-PodAssistant/helpers/git_cmd_helper.rb +73 -0
- data/lib/cocoapods-bb-PodAssistant/helpers/pod_module_helper.rb +246 -0
- data/lib/cocoapods-bb-PodAssistant/helpers/pod_utils.rb +128 -0
- data/lib/cocoapods-bb-PodAssistant/helpers/stable_env_helper.rb +36 -0
- data/lib/cocoapods-bb-PodAssistant/helpers/stable_manager_helper.rb +85 -0
- data/lib/cocoapods-bb-PodAssistant/helpers/yaml_files_helper.rb +72 -0
- data/lib/cocoapods-bb-PodAssistant/helpers.rb +6 -0
- data/lib/cocoapods-bb-PodAssistant/podfile.rb +392 -0
- data/lib/cocoapods-bb-PodAssistant/source_provider_hook.rb +335 -0
- data/lib/cocoapods-bb-PodAssistant.rb +1 -0
- data/lib/cocoapods_plugin.rb +9 -0
- data/spec/command/PodAssistant_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +132 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
# cache stable
|
2
|
+
|
3
|
+
######################################## Git Command ########################################
|
4
|
+
def configGitPath(gitPath)
|
5
|
+
@gitPath = gitPath
|
6
|
+
end
|
7
|
+
|
8
|
+
def git_cmd(*args)
|
9
|
+
Dir.chdir(File.join(@gitPath)) {
|
10
|
+
return git! args
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def git_reset
|
15
|
+
git_cmd('reset','--hard') #fommate git command
|
16
|
+
end
|
17
|
+
|
18
|
+
def git_fetch
|
19
|
+
git_cmd('fetch') #fommate git command
|
20
|
+
end
|
21
|
+
|
22
|
+
def git_pull
|
23
|
+
# git_cmd('pull','--all') #fommate git command
|
24
|
+
end
|
25
|
+
def git_checkout_and_pull(stable_source, stable_branch = nil, stable_tag = nil)
|
26
|
+
# puts "spec source:#{stable_source} branch:#{stable_branch} tag:#{stable_tag}"
|
27
|
+
if stable_branch || stable_tag
|
28
|
+
if stable_branch
|
29
|
+
unless git_branch_exists?(stable_branch)
|
30
|
+
err_msg = "- Error: #{stable_source} did not exit branch #{stable_branch}"
|
31
|
+
Pod::UI.puts "#{err_msg}".send(:red)
|
32
|
+
exit -9006
|
33
|
+
end
|
34
|
+
git_cmd('checkout',stable_branch) #fommate git command
|
35
|
+
git_cmd('reset','--hard',"origin/#{stable_branch}") #fommate git command
|
36
|
+
end
|
37
|
+
if stable_tag
|
38
|
+
unless git_tag_exists?(stable_tag)
|
39
|
+
err_msg = "- Error: #{stable_source} did not exit tag #{stable_tag}"
|
40
|
+
Pod::UI.puts "#{err_msg}".send(:red)
|
41
|
+
exit -9007
|
42
|
+
end
|
43
|
+
|
44
|
+
git_cmd('checkout',stable_tag) #fommate git command
|
45
|
+
end
|
46
|
+
else
|
47
|
+
protechBranch = git_cmd('symbolic-ref','refs/remotes/origin/HEAD').split("/").last.strip || "main"
|
48
|
+
git_cmd('checkout',protechBranch)
|
49
|
+
git_cmd('reset','--hard',"origin/#{protechBranch}") #fommate git command
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def git_tag_exists?(tag)
|
54
|
+
if tag
|
55
|
+
git_cmd('tag').split("\n").include?(tag)
|
56
|
+
end
|
57
|
+
return true
|
58
|
+
end
|
59
|
+
|
60
|
+
def git_branch_exists?(branch)
|
61
|
+
if branch
|
62
|
+
branchs = git_cmd('branch','-a').split("\n")
|
63
|
+
branchs.include?(branch) || branchs.include?(' remotes/origin/' + branch) || branchs.include?('remotes/origin/' + branch)
|
64
|
+
end
|
65
|
+
return true
|
66
|
+
end
|
67
|
+
|
68
|
+
def git_clone(source, path)
|
69
|
+
puts "git clone source:#{source} path:#{path}"
|
70
|
+
UI.section("Cloning `#{source}` into `#{path}`.") do
|
71
|
+
Dir.chdir(path) { git! ['clone', source] } #origin git command
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
require 'cocoapods-bb-PodAssistant/config/source_manager'
|
2
|
+
|
3
|
+
module BB
|
4
|
+
class PodModule
|
5
|
+
# 全部项目配置 => { 全部项目配置 }
|
6
|
+
@@all_modules = [
|
7
|
+
]
|
8
|
+
|
9
|
+
# 个人项目配置 => { 门牌 => { 项目名称, 获取方式, 分支,目标, 版本,} } 匹配全部项目配置 个人配置替换全局配置
|
10
|
+
@@member_modules = {
|
11
|
+
}
|
12
|
+
|
13
|
+
# 成员配置 => { 门牌 => { 项目名称, 获取方式, 分支,目标, 版本,} } 匹配全部项目配置 个人配置替换全局配置
|
14
|
+
@@member_configs = [
|
15
|
+
]
|
16
|
+
|
17
|
+
def initialize(all_modules, member_modules, member_configs, ignore_local_stable = false)
|
18
|
+
@source_manager = BB::SourceManager.new()
|
19
|
+
#加载远程稳定仓库 和本地podfile 指定的仓库进行合并
|
20
|
+
@@all_modules = load_stable_specs_to_podfile(all_modules, ignore_local_stable)
|
21
|
+
@@member_modules = member_modules
|
22
|
+
@@member_configs = member_configs
|
23
|
+
# puts "member_modules:#{member_modules}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def current_member
|
27
|
+
if @@member_configs
|
28
|
+
@@member_configs.each do | c |
|
29
|
+
if c[:pathes]
|
30
|
+
c[:pathes].each do | p |
|
31
|
+
if File.exist?(p)
|
32
|
+
return c
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
return { :name => :podbox_member, :force_local => false, }
|
40
|
+
end
|
41
|
+
|
42
|
+
def current_member_modules
|
43
|
+
@current_member = self.current_member
|
44
|
+
@current_member_modules = []
|
45
|
+
if @@member_modules[current_member[:name]]
|
46
|
+
@@member_modules[current_member[:name]].each do | m |
|
47
|
+
if m[:inhibit_warnings] == nil
|
48
|
+
m[:inhibit_warnings] = true
|
49
|
+
end
|
50
|
+
@current_member_modules << m
|
51
|
+
end
|
52
|
+
end
|
53
|
+
return @current_member_modules
|
54
|
+
end
|
55
|
+
|
56
|
+
def current_all_modules
|
57
|
+
return @@all_modules
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
################################# linkline stable ����� #################################
|
62
|
+
# 格式化podfile 中的specs
|
63
|
+
#[
|
64
|
+
# { names: "BBGlobalMainModule", version: "1.1.1", method: REMOTE_TAG },
|
65
|
+
# { names: "xxxx", version: "1.1.2", method: REMOTE_TAG }
|
66
|
+
#]
|
67
|
+
def format_podfile_specs(pods)
|
68
|
+
pods.flat_map do |spec|
|
69
|
+
spec[:names].map do |name|
|
70
|
+
spec.dup.tap { |s| s[:names] = [name] }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# 合并stable和podfile 中的specs! ⚠️podfile 中的组件会覆盖stable 中的!
|
76
|
+
# 比如stable 中AFNetworking 指向标签1.1,而 podfile中AFNetworking 指向develop,那么最终AFNetworking 会指向develop
|
77
|
+
def load_stable_specs_to_podfile(podfile_specs, ignore_local_stable = false)
|
78
|
+
puts "[PodAssistant] start process pod module...".yellow
|
79
|
+
local_stable_data = @source_manager.fetch_local_stable_datas # 本地stable配置
|
80
|
+
if (local_stable_data.is_a? Hash) && !local_stable_data.empty?
|
81
|
+
return merge_module_data(podfile_specs, local_stable_data)
|
82
|
+
else
|
83
|
+
if !ignore_local_stable
|
84
|
+
puts "❌ 没有配置pod stable环境!!! 请先执行`pod stable --init`初始化,再执行pod in/up操作".red
|
85
|
+
exit
|
86
|
+
end
|
87
|
+
end
|
88
|
+
return format_podfile_specs(podfile_specs)
|
89
|
+
end
|
90
|
+
# 转化数据to hash
|
91
|
+
def convert_podfile_specs_data(podfile_specs)
|
92
|
+
podfile_hash = {}
|
93
|
+
podfile_specs.each { |pod|
|
94
|
+
# 对现有pod支持格式进行解析
|
95
|
+
names = pod[:names]
|
96
|
+
version = pod[:version]
|
97
|
+
method = pod[:method]
|
98
|
+
branch = pod[:branch]
|
99
|
+
git = pod[:git]
|
100
|
+
git_format = pod[:git_format]
|
101
|
+
commit = pod[:commit]
|
102
|
+
linkages = pod[:linkages]
|
103
|
+
linkage = pod[:linkage]
|
104
|
+
if (names.is_a? Array) && !names.empty?
|
105
|
+
data = {}
|
106
|
+
if version
|
107
|
+
data[:version] = version
|
108
|
+
end
|
109
|
+
if method
|
110
|
+
data[:method] = method
|
111
|
+
end
|
112
|
+
if branch
|
113
|
+
data[:branch] = branch
|
114
|
+
end
|
115
|
+
if git
|
116
|
+
data[:git] = git
|
117
|
+
end
|
118
|
+
if git_format
|
119
|
+
if git_format.include?("{git_name}")
|
120
|
+
data[:git_format] = git_format
|
121
|
+
else
|
122
|
+
data[:git] = git_format
|
123
|
+
end
|
124
|
+
end
|
125
|
+
if commit
|
126
|
+
data[:commit] = commit
|
127
|
+
end
|
128
|
+
if linkages
|
129
|
+
data[:linkages] = linkages
|
130
|
+
end
|
131
|
+
if linkage
|
132
|
+
data[:linkage] = linkage
|
133
|
+
end
|
134
|
+
names.each do |pod_name|
|
135
|
+
podfile_hash[pod_name] = data
|
136
|
+
end
|
137
|
+
end
|
138
|
+
}
|
139
|
+
return podfile_hash
|
140
|
+
end
|
141
|
+
def merge_module_data(podfile_specs, local_stable_data)
|
142
|
+
# puts "podfile_specs: #{podfile_specs}".green
|
143
|
+
podfile_hash = convert_podfile_specs_data(podfile_specs)
|
144
|
+
# puts "podfile_hash: #{podfile_hash}".red
|
145
|
+
# puts "local_stable_data: #{local_stable_data}".red
|
146
|
+
need_update_pod_data={}
|
147
|
+
podfile_hash.each do |podName,pod|
|
148
|
+
local_pod_data = local_stable_data[podName]
|
149
|
+
if pod != local_pod_data
|
150
|
+
branch = pod[:branch]
|
151
|
+
git_format = pod[:git_format]
|
152
|
+
version = pod[:version]
|
153
|
+
podCoreName = @source_manager.subspec_podname(podName)
|
154
|
+
# puts "podName:#{podName} pod:#{pod} branch:#{branch} git_format:#{git_format} version:#{version} local_pod_data:#{local_pod_data}".green
|
155
|
+
if (branch && !branch.empty?) || (git_format && !git_format.empty?)
|
156
|
+
# 项目配置指向分支数据,以本项目为主
|
157
|
+
puts "[PodAssistant] #{podName} 指向分支数据 => #{pod}"
|
158
|
+
need_update_pod_data[podCoreName] = pod
|
159
|
+
end
|
160
|
+
# succ = (version && !version.empty? && (local_pod_data.is_a? String) && (version != local_pod_data) && !version.include?(local_pod_data))
|
161
|
+
# puts "podName:#{podName} version:#{version} succ=#{succ}".red
|
162
|
+
if (version && !version.empty? && (local_pod_data.is_a? String) && (version != local_pod_data) && !version.include?(local_pod_data))
|
163
|
+
version = version.lstrip # 去除首字母空格
|
164
|
+
initial_str = version[0..0] # 第一个字母
|
165
|
+
# 项目配置固定版本,以本项目为主
|
166
|
+
is_fixed_version = initial_str.include?('=') ? true : false # 固定版本 pod 'A','= x.x.x'
|
167
|
+
is_lessthan_version = version.include?('<') ? true : false # 限制《最高》组件版本 pod 'A','< x.x.x' 或者 pod 'A','<= x.x.x'
|
168
|
+
is_greaterthan_version = version.include?('>') ? true : false # 限制《最低》组件版本 pod 'A','> x.x.x' 或者 pod 'A','>= x.x.x'
|
169
|
+
is_fuzzy_version = version.include?('~>') ? true : false # 固定版本 pod 'A','~> x.x.x'
|
170
|
+
is_fuzzy_versionV2 = (!is_fixed_version && !is_lessthan_version && !is_greaterthan_version && !is_fuzzy_version) ? true : false # 固定版本 pod 'A','x.x.x'
|
171
|
+
if (is_fixed_version == true) || (is_lessthan_version == true) || (is_fuzzy_version == true) || (is_fuzzy_versionV2 == true)
|
172
|
+
puts "[PodAssistant] ⚠️ 限制组件版本 '#{podName}', '#{version}' 以项目配置为主. (最新版本=> #{local_pod_data.send(:red)})"
|
173
|
+
need_update_pod_data[podCoreName] = version
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
if need_update_pod_data.count > 0
|
179
|
+
# puts "need_update_pod_data:#{need_update_pod_data}".green
|
180
|
+
# 规避指向分支/远端版本替换yml配置所有组件,避免pod指向指向多个源
|
181
|
+
need_update_pod_data.each do |podCoreName,pod|
|
182
|
+
local_stable_data.keys.each do |podName|
|
183
|
+
if (podName == podCoreName) || @source_manager.has_pod_subspec(podName, podCoreName)
|
184
|
+
local_stable_data[podName] = pod
|
185
|
+
puts "[PodAssistant] 合并组件 #{podName} #{pod} 以项目为主".yellow
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
puts "[PodAssistant] 重新保存本地stable数据".yellow
|
190
|
+
@source_manager.update_localstable_datas(local_stable_data)
|
191
|
+
else
|
192
|
+
puts "[PodAssistant] 本地stable数据无变化<===完成".yellow
|
193
|
+
end
|
194
|
+
# puts "local_stable_data: #{local_stable_data}".red
|
195
|
+
stable_specs = []
|
196
|
+
local_stable_data.each do |name,pod|
|
197
|
+
if pod.is_a? Hash
|
198
|
+
branch = pod[:branch]
|
199
|
+
git = pod[:git]
|
200
|
+
version = pod[:version]
|
201
|
+
method = pod[:method]
|
202
|
+
git_format = pod[:git_format]
|
203
|
+
commit = pod[:commit]
|
204
|
+
linkages = pod[:linkages]
|
205
|
+
linkage = pod[:linkage]
|
206
|
+
data = { names: [name] }
|
207
|
+
if version
|
208
|
+
data[:version] = version
|
209
|
+
end
|
210
|
+
if method
|
211
|
+
data[:method] = method
|
212
|
+
end
|
213
|
+
if branch
|
214
|
+
data[:branch] = branch
|
215
|
+
end
|
216
|
+
if git
|
217
|
+
data[:git] = git
|
218
|
+
end
|
219
|
+
if git_format
|
220
|
+
data[:git_format] = git_format
|
221
|
+
end
|
222
|
+
if commit
|
223
|
+
data[:commit] = commit
|
224
|
+
end
|
225
|
+
if linkages
|
226
|
+
data[:linkages] = linkages
|
227
|
+
end
|
228
|
+
if linkage
|
229
|
+
data[:linkage] = linkage
|
230
|
+
end
|
231
|
+
if !data.empty?
|
232
|
+
# puts "name:#{name} stable_specs: #{data}".green
|
233
|
+
stable_specs.push(data)
|
234
|
+
end
|
235
|
+
elsif pod.is_a? String
|
236
|
+
stable_specs.push({ names: [name], version: pod, method: REMOTE_TAG })
|
237
|
+
else
|
238
|
+
puts "unknow type data:#{pod}".red
|
239
|
+
end
|
240
|
+
end
|
241
|
+
return stable_specs
|
242
|
+
end
|
243
|
+
################################# linkline stable ����� #################################
|
244
|
+
|
245
|
+
end
|
246
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# Author = Min Hu
|
3
|
+
|
4
|
+
require 'xcodeproj'
|
5
|
+
require 'cocoapods'
|
6
|
+
|
7
|
+
module BB
|
8
|
+
class PodUtils
|
9
|
+
# 获取工程根目录路径
|
10
|
+
def self.getProjectRootPath
|
11
|
+
path = File.expand_path("..", getProjectPath)
|
12
|
+
# puts "Project Root Path:#{path}".red
|
13
|
+
raise Informative, "#{path} File no exist, please check" unless File.exist?(path)
|
14
|
+
return path
|
15
|
+
end
|
16
|
+
# 获取工程路径
|
17
|
+
def self.getProjectPath
|
18
|
+
path = Dir.pwd
|
19
|
+
# puts "Project Path:#{path}".yellow
|
20
|
+
raise Informative, "#{path} File no exist, please check" unless File.exist?(path)
|
21
|
+
return path
|
22
|
+
end
|
23
|
+
# xcode目录
|
24
|
+
def self.getXcodeprojPath
|
25
|
+
name = Dir.glob("*.xcodeproj")[0]
|
26
|
+
path = File.join(getProjectPath, name)
|
27
|
+
# puts "xcodeproj:#{path}"
|
28
|
+
raise Informative, "#{path} File no exist, please check" unless File.exist?(path)
|
29
|
+
return path
|
30
|
+
end
|
31
|
+
# 获取包名
|
32
|
+
def self.getProjectBundleIdentifier
|
33
|
+
projectBundleIdentifierKey = "PRODUCT_BUNDLE_IDENTIFIER"
|
34
|
+
value = getValueFromInfoPlist(projectBundleIdentifierKey)
|
35
|
+
if #{value} == #{projectBundleIdentifierKey}
|
36
|
+
project = Xcodeproj::Project.open(getXcodeprojPath)
|
37
|
+
project.targets.each do |target|
|
38
|
+
target.build_configurations.each do |config|
|
39
|
+
value = config.build_settings['PRODUCT_BUNDLE_IDENTIFIER']
|
40
|
+
if value && !value.empty?
|
41
|
+
break
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
if value && !value.empty?
|
46
|
+
break
|
47
|
+
end
|
48
|
+
end
|
49
|
+
puts "xcodeproj BundleIdentifier:#{value}"
|
50
|
+
return value
|
51
|
+
else
|
52
|
+
puts "info BundleIdentifier:#{value}"
|
53
|
+
return value
|
54
|
+
end
|
55
|
+
end
|
56
|
+
# 证书团队id
|
57
|
+
def self.getProjectDevelopmentTeam
|
58
|
+
value = ""
|
59
|
+
project = Xcodeproj::Project.open(getXcodeprojPath)
|
60
|
+
project.targets.each do |target|
|
61
|
+
target.build_configurations.each do |config|
|
62
|
+
value = config.build_settings['DEVELOPMENT_TEAM']
|
63
|
+
|
64
|
+
if value && !value.empty?
|
65
|
+
# 做你的处理
|
66
|
+
break
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
puts "xcodeproj DevelopmentTeam:#{value}"
|
71
|
+
return value
|
72
|
+
end
|
73
|
+
# 获取info配置文件路径
|
74
|
+
def self.getInfoPlistPath
|
75
|
+
path = File.join(getProjectPath, "bbframework/Resources/Info.plist")
|
76
|
+
# puts "InfoPlist:#{path}"
|
77
|
+
raise Informative, "#{path} File no exist, please check" unless File.exist?(path)
|
78
|
+
return path
|
79
|
+
end
|
80
|
+
# 获取info配置key对应的值
|
81
|
+
def self.getValueFromInfoPlist(key)
|
82
|
+
plistPath = getInfoPlistPath
|
83
|
+
value = `/usr/libexec/PlistBuddy -c "Print #{key}" #{plistPath}`
|
84
|
+
value = value.rstrip()
|
85
|
+
puts "#{key} => #{value}"
|
86
|
+
return value
|
87
|
+
end
|
88
|
+
# 获取Xcode版本
|
89
|
+
def self.xcode_version
|
90
|
+
xcode_version_output = `xcode-select -p`
|
91
|
+
return nil if xcode_version_output.empty?
|
92
|
+
|
93
|
+
xcode_path = xcode_version_output.chomp
|
94
|
+
version_output = `xcodebuild -version`
|
95
|
+
|
96
|
+
# Extract the Xcode version number
|
97
|
+
version_match = version_output.match(/Xcode (\d+(\.\d+)+)/)
|
98
|
+
return nil if version_match.nil?
|
99
|
+
|
100
|
+
xcode_version = version_match[1]
|
101
|
+
return xcode_version
|
102
|
+
end
|
103
|
+
# xcode14以上,14以后不再支持armv7(32位设备)
|
104
|
+
def self.compare_xcode_14_version
|
105
|
+
current_version = xcode_version
|
106
|
+
if current_version.nil?
|
107
|
+
puts "未找到安装的Xcode版本。".red
|
108
|
+
else
|
109
|
+
puts "当前Xcode版本:#{current_version}"
|
110
|
+
num_ver = current_version.to_i
|
111
|
+
return num_ver >= 14
|
112
|
+
end
|
113
|
+
return false
|
114
|
+
end
|
115
|
+
# xcode15以上
|
116
|
+
def self.compare_xcode_15_version
|
117
|
+
current_version = xcode_version
|
118
|
+
if current_version.nil?
|
119
|
+
puts "未找到安装的Xcode版本。".red
|
120
|
+
else
|
121
|
+
puts "当前Xcode版本:#{current_version}"
|
122
|
+
num_ver = current_version.to_i
|
123
|
+
return num_ver >= 15
|
124
|
+
end
|
125
|
+
return false
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'cocoapods-bb-PodAssistant/helpers/git_cmd_helper'
|
2
|
+
require 'cocoapods-bb-PodAssistant/config/stable_source'
|
3
|
+
|
4
|
+
module BB
|
5
|
+
class StableEnv
|
6
|
+
def initialize(stable_source = nil, stable_branch = nil, stable_tag = nil)
|
7
|
+
if stable_source.nil?
|
8
|
+
stable_source = StableSource.stable_default_source
|
9
|
+
end
|
10
|
+
@stable_source = stable_source
|
11
|
+
@stable_branch = stable_branch
|
12
|
+
@stable_tag = stable_tag
|
13
|
+
|
14
|
+
@cache = BB::Cache.new()
|
15
|
+
configGitPath(@cache.cachePath)
|
16
|
+
end
|
17
|
+
|
18
|
+
# stable 环境,执行pod stable
|
19
|
+
def loadStaleEnv
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
# 开发环境,执行pod install/update
|
24
|
+
def loadDeveloperEnv
|
25
|
+
cachePath = @cache.cachePath
|
26
|
+
puts "hook [pod install/update] sync stable git=>#{cachePath}"
|
27
|
+
if Dir.exist?(File.join(cachePath))
|
28
|
+
`cd #{cachePath}; git switch main; git pull --all`
|
29
|
+
else
|
30
|
+
clonePath = File.dirname(cachePath)
|
31
|
+
FileUtils.mkdir_p clonePath
|
32
|
+
`git clone #{@stable_source} #{cachePath}`
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'cocoapods-bb-PodAssistant/config/stable_specs'
|
2
|
+
require 'cocoapods-bb-PodAssistant/helpers'
|
3
|
+
|
4
|
+
module BB
|
5
|
+
class StableManager
|
6
|
+
def initialize()
|
7
|
+
end
|
8
|
+
|
9
|
+
# podfile 更新配置文件使用(通用)
|
10
|
+
def update_common_stable_lock(pod_targets)
|
11
|
+
update_stable_lock(public_stable_yaml, pod_targets)
|
12
|
+
end
|
13
|
+
# podfile 更新配置文件使用(业务线)
|
14
|
+
def update_business_stable_lock(businessSpecName, pod_targets)
|
15
|
+
update_stable_lock(business_stable_yaml(businessSpecName), pod_targets)
|
16
|
+
end
|
17
|
+
# podfile 更新配置文件使用(项目)
|
18
|
+
def update_product_stable_lock(pod_targets)
|
19
|
+
update_local_stable_lock(local_stable_yaml, pod_targets)
|
20
|
+
end
|
21
|
+
|
22
|
+
# 仓库缓存目录
|
23
|
+
def cachePath
|
24
|
+
if @cache.nil?
|
25
|
+
@cache = BB::Cache.new()
|
26
|
+
end
|
27
|
+
return @cache.cachePath
|
28
|
+
end
|
29
|
+
|
30
|
+
# 公共源路径(远端)
|
31
|
+
def public_stable_yaml
|
32
|
+
return File.join(cachePath, "stable_specs.yml") #名称固定
|
33
|
+
end
|
34
|
+
|
35
|
+
# 业务源路径(远端)
|
36
|
+
def business_stable_yaml(businessSpecName)
|
37
|
+
if businessSpecName
|
38
|
+
return File.join(cachePath, "#{businessSpecName}.yml") #名称由各自业务线约定
|
39
|
+
end
|
40
|
+
return nil
|
41
|
+
end
|
42
|
+
|
43
|
+
# 本地源路径
|
44
|
+
def local_stable_yaml
|
45
|
+
return File.join(Pathname.pwd, "stable_specs_lock.yml") #名称固定
|
46
|
+
end
|
47
|
+
|
48
|
+
private def update_stable_lock(yml_path, pod_targets)
|
49
|
+
# step.1 更新yaml配置文件
|
50
|
+
stableSpec = BB::StableSpecs.new()
|
51
|
+
stableSpec.update_stable_lock(yml_path, pod_targets)
|
52
|
+
# step.2 提交修改后代码
|
53
|
+
yml_name = File.basename(yml_path)
|
54
|
+
`cd #{cachePath}; git pull --all; git add #{yml_name}; git commit -m "[update] 更新stable配置文件#{yml_name}"; git push; git pull --all;`
|
55
|
+
end
|
56
|
+
private def update_local_stable_lock(yml_path, pod_targets)
|
57
|
+
# step.1 更新yaml配置文件
|
58
|
+
stableSpec = BB::StableSpecs.new()
|
59
|
+
stableSpec.update_local_stable_lock(yml_path, pod_targets)
|
60
|
+
end
|
61
|
+
|
62
|
+
# 更新通用lock
|
63
|
+
def self.updateCommonStableLock(pod_targets)
|
64
|
+
stableMgr = StableManager.new()
|
65
|
+
stableMgr.update_common_stable_lock(pod_targets)
|
66
|
+
end
|
67
|
+
# podfile 更新配置文件使用(业务线)
|
68
|
+
def self.updateBusinessStableLock(businessSpecName, pod_targets)
|
69
|
+
stableMgr = StableManager.new()
|
70
|
+
stableMgr.update_stable_lock(businessSpecName, pod_targets)
|
71
|
+
end
|
72
|
+
# 更新产品lock
|
73
|
+
def self.updateProductStableLock(pod_targets)
|
74
|
+
stableMgr = StableManager.new()
|
75
|
+
stableMgr.update_product_stable_lock(pod_targets)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# class << self
|
80
|
+
# def updateCommonStableLock(pod_targets)
|
81
|
+
# stableMgr = StableManager.new()
|
82
|
+
# stableMgr.update_common_stable_lock(pod_targets)
|
83
|
+
# end
|
84
|
+
# end
|
85
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
YAML_CONFIG_LIST_KEY = "list"
|
4
|
+
YAML_CONFIG_REMOVE_KEY = "remove"
|
5
|
+
YAML_CONFIG_DEPENDENCIES_KEY = "dependencies"
|
6
|
+
|
7
|
+
|
8
|
+
# 数据源格式 json:{list:{name:ver},remove:[name],dependencies:{name:[name]}}
|
9
|
+
# list 受版本控制数据
|
10
|
+
# remove 移除数据
|
11
|
+
# dependencies 依赖数据
|
12
|
+
module BB
|
13
|
+
class YamlFilesHelper
|
14
|
+
def self.save_stable_podlock(yml_path, pod_targets)
|
15
|
+
yamlData = read_stable_lock_yaml(yml_path)
|
16
|
+
# test data
|
17
|
+
# yamlData[YAML_CONFIG_REMOVE_KEY] = ["AFNetworking"]
|
18
|
+
# yamlData[YAML_CONFIG_DEPENDENCIES_KEY] = {"BBNativeContainer":["BBSchemeDispatcher","BBComponentServicesKit"]}
|
19
|
+
if yamlData.is_a? Hash
|
20
|
+
listdata = yamlData[YAML_CONFIG_LIST_KEY]
|
21
|
+
removedata = yamlData[YAML_CONFIG_REMOVE_KEY]
|
22
|
+
dependenciesdata = yamlData[YAML_CONFIG_DEPENDENCIES_KEY]
|
23
|
+
else
|
24
|
+
yamlData = {}
|
25
|
+
end
|
26
|
+
if listdata.nil?
|
27
|
+
listdata = {}
|
28
|
+
end
|
29
|
+
# 公共配置写入规则
|
30
|
+
if removedata.nil?
|
31
|
+
removedata = []
|
32
|
+
end
|
33
|
+
if dependenciesdata.nil?
|
34
|
+
dependenciesdata = {}
|
35
|
+
end
|
36
|
+
pod_targets.map { |pod_target|
|
37
|
+
name = pod_target.pod_name
|
38
|
+
listdata[name] = pod_target.root_spec.version.version
|
39
|
+
# 策略:列表存在数据需要删除移除数据
|
40
|
+
removedata.delete(name)
|
41
|
+
}
|
42
|
+
yamlData[YAML_CONFIG_LIST_KEY] = listdata
|
43
|
+
yamlData[YAML_CONFIG_REMOVE_KEY] = removedata
|
44
|
+
yamlData[YAML_CONFIG_DEPENDENCIES_KEY] = dependenciesdata
|
45
|
+
save_stable_lock_yaml(yml_path, yamlData)
|
46
|
+
end
|
47
|
+
def self.save_local_stable_podlock(yml_path, pod_targets)
|
48
|
+
yamlData = read_stable_lock_yaml(yml_path)
|
49
|
+
if yamlData.is_a? Hash
|
50
|
+
pod_targets.map { |pod_target|
|
51
|
+
name = pod_target.pod_name
|
52
|
+
yamlData[name] = pod_target.root_spec.version.version
|
53
|
+
}
|
54
|
+
save_stable_lock_yaml(yml_path, yamlData)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.save_stable_lock_yaml(yml_path, pod_jsondata)
|
59
|
+
File.open(yml_path,"w") { |f| YAML.dump(pod_jsondata, f) }
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.read_stable_lock_yaml(yml_path)
|
63
|
+
if File.file?(yml_path)
|
64
|
+
# puts "read yaml path:#{yml_path}"
|
65
|
+
json = YAML.load_file(yml_path)
|
66
|
+
# puts "read json:#{json}"
|
67
|
+
return json
|
68
|
+
end
|
69
|
+
return {}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
require 'cocoapods-bb-PodAssistant/helpers/pod_module_helper'
|
2
|
+
require 'cocoapods-bb-PodAssistant/helpers/yaml_files_helper'
|
3
|
+
require 'cocoapods-bb-PodAssistant/helpers/git_cmd_helper'
|
4
|
+
require 'cocoapods-bb-PodAssistant/helpers/stable_env_helper'
|
5
|
+
require 'cocoapods-bb-PodAssistant/helpers/stable_manager_helper'
|
6
|
+
require 'cocoapods-bb-PodAssistant/helpers/pod_utils'
|