cocoapods-bb-PodAssistant 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b51e74ff613bc48453d0b937997988c53f5afb9d510ff03a9d749c574f5400e5
4
- data.tar.gz: 4473eeab305c9d52b40fe3964c2ab2e00daced64a6f67189b257b9ebf5f25a3e
3
+ metadata.gz: a4d73bccc2529481814cc586c3d0cb46b863c986741859ac8d399f1a8962ed1c
4
+ data.tar.gz: d96718876d58008ffa7e846cae38e68d46358fe3e88effd7477b669b514ede12
5
5
  SHA512:
6
- metadata.gz: 5f8dfd78e3ed158208d41d15ec6258c58e0679c39e4132ff6d93cba459984de7f6b2ecf200c8db80042176b8559616388de18d62266ae5d6b630867655937846
7
- data.tar.gz: c48dd116047320c6d2ab0ad045aa138682a00fa31752cedff4b48f02889cd65560d8cb71b8363792b1d93d2c5e3b88bf9a60fa7f14946d0d6ee67eab9b90cee0
6
+ metadata.gz: 979d7c8365b57c364e953ebe616d55be2c40c5547a72d42089db504123d9188bfe8920ede679ec412128e41cca44feaec052d32d1163c60b7434d022be2dfba4
7
+ data.tar.gz: c86d930fdd7cc595ea411b235ce98b18e8c105665b178a05938f9f4e942a20530bb83a5ac2dabb6a530022d0f82f2373adf6951d55984d2473b15d52d93e2a0f
@@ -114,7 +114,7 @@ module Pod
114
114
  ll_fetch_stale_git
115
115
  # 数据合并
116
116
  source_manager.merge_stable_data
117
- puts "[PodAssistant] `pod stable` complete!".green
117
+ puts "[PodAssistant] `pod stable` complete! Please execute the [pod install/ pod update] command".green
118
118
  else
119
119
  puts "[PodAssistant] `pod stable` 帮助文档请查看👇".yellow
120
120
  banner!
@@ -29,7 +29,12 @@ module BB
29
29
  # 产品线本地lock数据
30
30
  def fetch_local_stable_datas
31
31
  localSpec = BB::StableSpecs.new()
32
- return localSpec.readData(local_stable_yaml)
32
+ yml = local_stable_yaml
33
+ if !File.file?(yml)
34
+ puts "yml配置文件不存在,执行自动初始化项目yml配置文件".green
35
+ generate_localStable
36
+ end
37
+ return localSpec.readData(yml)
33
38
  end
34
39
 
35
40
  # 远端公共lock数据
@@ -231,51 +236,38 @@ module BB
231
236
  return lockfile
232
237
  end
233
238
 
239
+ # 生成项目stable配置文件
240
+ # 策略:根据podfile.lock dependencies依赖记录pod core标签/分支数据,不存储subspec数据
234
241
  def generate_localStable
235
242
  lockfile = podfile_lock
236
243
  local_specs = {}
237
- # step.1 获取分支指向信息
238
244
  dependencies = lockfile.dependencies
239
245
  dependencies.each do | dependency |
246
+ pod_name = dependency.name
247
+ if has_include_subspec(pod_name)
248
+ podCoreName = subspec_podname(pod_name)
249
+ else
250
+ podCoreName = pod_name
251
+ end
240
252
  if dependency.external_source.is_a? Hash
241
- name = dependency.name
253
+ # 指向分支
242
254
  external_source = dependency.external_source
243
- podCoreName = subspec_podname(name)
244
255
  # checkout_options = lockfile.checkout_options_for_pod_named(podCoreName)
245
256
  # if checkout_options.is_a? Hash
246
257
  # commit = checkout_options[:commit]
247
258
  # external_source[:commit] = commit
248
259
  # puts "name:#{podCoreName} checkout_options:#{checkout_options} commit:#{commit}"
249
260
  # end
250
- if podCoreName != name
251
- # local_specs.delete(podCoreName)
261
+ if !local_specs.has_key?(podCoreName)
252
262
  local_specs[podCoreName] = external_source
253
- if (!has_include_core_subspec(name)) # 过滤core数据
254
- local_specs[name] = external_source
255
- Pod::UI.puts "[分支] #{name} => (#{external_source})"
256
- end
257
- else
258
- local_specs[name] = external_source
259
- Pod::UI.puts "[分支] #{name} => (#{external_source})"
260
- end
261
- end
262
- end
263
- # step.2 获取pods标签信息,如果存在分支优先使用分支信息
264
- lockfile.pod_names.each do |pod_name|
265
- version = lockfile.version(pod_name)
266
- podCoreName = subspec_podname(pod_name)
267
- if local_specs.has_key?(podCoreName)
268
- if podCoreName != pod_name
269
- if (!has_include_core_subspec(pod_name)) # 过滤core数据
270
- # Pod::UI.puts "step.2 #{pod_name} => (#{local_specs[podCoreName]})"
271
- local_specs[pod_name] = local_specs[podCoreName]
272
- end
263
+ # puts "[分支] #{podCoreName} => (#{external_source})".yellow
273
264
  end
274
265
  else
275
- if (!has_include_core_subspec(pod_name)) # 过滤core数据
276
- ver = version.to_s
277
- local_specs[pod_name] = ver
278
- Pod::UI.puts "[标签] #{pod_name} => (#{ver})"
266
+ # 指向标签版本
267
+ version = lockfile.version(pod_name).to_s
268
+ if !version.empty? && !local_specs.has_key?(podCoreName)
269
+ local_specs[podCoreName] = version
270
+ # puts "[标签] #{podCoreName} => (#{version})".yellow
279
271
  end
280
272
  end
281
273
  end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsBbPodassistant
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -14,13 +14,23 @@ module BB
14
14
  @@member_configs = [
15
15
  ]
16
16
 
17
- def initialize(all_modules, member_modules, member_configs, ignore_local_stable = false)
17
+ # pod组件合并
18
+ # 参数说明
19
+ # all_modules 业务使用组件
20
+ # member_modules 项目成员模块,一般用于切本地开发使用
21
+ # member_configs 项目成员工程配置
22
+ # ignore_local_stable 是否忽略本地stable配置,true 适合pod子组件
23
+ # skip_stable_check 是否跳过stable检测,true 采用标准pod合并操作
24
+ def initialize(all_modules, member_modules = {}, member_configs = [], ignore_local_stable = false, skip_stable_check = false)
18
25
  @source_manager = BB::SourceManager.new()
19
26
  #加载远程稳定仓库 和本地podfile 指定的仓库进行合并
20
- @@all_modules = load_stable_specs_to_podfile(all_modules, ignore_local_stable)
27
+ if skip_stable_check == true
28
+ @@all_modules = all_modules
29
+ else
30
+ @@all_modules = load_stable_specs_to_podfile(all_modules, ignore_local_stable)
31
+ end
21
32
  @@member_modules = member_modules
22
33
  @@member_configs = member_configs
23
- # puts "member_modules:#{member_modules}"
24
34
  end
25
35
 
26
36
  def current_member
@@ -138,39 +148,69 @@ module BB
138
148
  }
139
149
  return podfile_hash
140
150
  end
151
+ # 合并组建数据
152
+ # 策略:本地stable作为基础数据,遍历podfile组件进行替换,变化以本地为主,标签以stable为主
141
153
  def merge_module_data(podfile_specs, local_stable_data)
142
154
  # puts "podfile_specs: #{podfile_specs}".green
143
155
  podfile_hash = convert_podfile_specs_data(podfile_specs)
144
156
  # puts "podfile_hash: #{podfile_hash}".red
145
157
  # puts "local_stable_data: #{local_stable_data}".red
146
158
  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
159
+ stable_hash = local_stable_data
160
+ podfile_hash.each do |podName,podfile_pod|
161
+ podCoreName = @source_manager.subspec_podname(podName)
162
+ if (podName == podCoreName) || @source_manager.has_pod_subspec(podName, podCoreName)
163
+ pod = stable_hash[podCoreName]
164
+ if pod.nil? # stbale没有受版本控制
165
+ need_update_pod_data[podName] = podfile_pod
166
+ else
167
+ # puts "[stable]podCoreName:#{podCoreName}(#{pod}) VS [podfile] podName:#{podName}(#{podfile_pod})".yellow
168
+ if podName == "BBWriteReview/World"
169
+ puts "[stable]podCoreName:#{podCoreName}(#{pod}) VS [podfile] podName:#{podName}(#{podfile_pod})".yellow
170
+ end
171
+ if pod == podfile_pod
172
+ if podName != podCoreName
173
+ need_update_pod_data[podName] = podfile_pod
174
+ end
175
+ else
176
+ branch = podfile_pod[:branch]
177
+ git = podfile_pod[:git]
178
+ if git.nil?
179
+ git = podfile_pod[:git_format]
180
+ end
181
+ version = podfile_pod[:version]
182
+ if (branch && !branch.empty?) || (git && !git.empty?)
183
+ # 项目配置指向分支数据,以本项目为主
184
+ puts "[PodAssistant] #{podName} 指向分支数据 => #{podfile_pod}"
185
+ stable_hash[podCoreName] = podfile_pod
186
+ if podName != podCoreName
187
+ need_update_pod_data[podName] = podfile_pod
188
+ end
189
+ elsif (version && !version.empty? && (pod.is_a? String) && (version != pod))
190
+ version = version.lstrip # 去除首字母空格
191
+ initial_str = version[0..0] # 第一个字母
192
+ # 项目配置固定版本,以本项目为主
193
+ is_fixed_version = initial_str.include?('=') ? true : false # 固定版本 pod 'A','= x.x.x'
194
+ is_lessthan_version = version.include?('<') ? true : false # 限制《最高》组件版本 pod 'A','< x.x.x' 或者 pod 'A','<= x.x.x'
195
+ is_greaterthan_version = version.include?('>') ? true : false # 限制《最低》组件版本 pod 'A','> x.x.x' 或者 pod 'A','>= x.x.x'
196
+ is_fuzzy_version = version.include?('~>') ? true : false # 固定版本 pod 'A','~> x.x.x'
197
+ is_fuzzy_versionV2 = (!is_fixed_version && !is_lessthan_version && !is_greaterthan_version && !is_fuzzy_version) ? true : false # 固定版本 pod 'A','x.x.x'
198
+ if (is_fixed_version == true) || (is_lessthan_version == true) || (is_fuzzy_versionV2 == true)
199
+ puts "[PodAssistant] ⚠️ 限制组件版本 '#{podName}', '#{version}' 以项目配置为主. (最新版本=> #{pod.send(:red)})"
200
+ stable_hash[podCoreName] = version
201
+ if podName != podCoreName
202
+ need_update_pod_data[podName] = version
203
+ end
204
+ elsif (is_greaterthan_version == true) || (is_fuzzy_version == true)
205
+ # puts "[PodAssistant] '#{podName}', '#{pod.send(:red)}' 以stable配置为主."
206
+ need_update_pod_data[podName] = pod
207
+ end
208
+ else
209
+ if podName != podCoreName
210
+ # puts "[PodAssistant] '#{podName}', '#{pod.send(:red)}' 以stable配置为主."
211
+ need_update_pod_data[podName] = pod
212
+ end
213
+ end
174
214
  end
175
215
  end
176
216
  end
@@ -178,22 +218,16 @@ module BB
178
218
  if need_update_pod_data.count > 0
179
219
  # puts "need_update_pod_data:#{need_update_pod_data}".green
180
220
  # 规避指向分支/远端版本替换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
221
+ need_update_pod_data.each do |podName,pod|
222
+ stable_hash[podName] = pod
223
+ puts "[PodAssistant] merge pod #{podName} #{pod}"
188
224
  end
189
- puts "[PodAssistant] 重新保存本地stable数据".yellow
190
- @source_manager.update_localstable_datas(local_stable_data)
191
225
  else
192
226
  puts "[PodAssistant] 本地stable数据无变化<===完成".yellow
193
227
  end
194
- # puts "local_stable_data: #{local_stable_data}".red
228
+ # puts "[PodAssistant] stable_hash:#{stable_hash}".red
195
229
  stable_specs = []
196
- local_stable_data.each do |name,pod|
230
+ stable_hash.each do |name,pod|
197
231
  if pod.is_a? Hash
198
232
  branch = pod[:branch]
199
233
  git = pod[:git]
@@ -235,7 +269,7 @@ module BB
235
269
  elsif pod.is_a? String
236
270
  stable_specs.push({ names: [name], version: pod, method: REMOTE_TAG })
237
271
  else
238
- puts "unknow type data:#{pod}".red
272
+ puts "unknow type [#{name}] data:#{pod}".red
239
273
  end
240
274
  end
241
275
  return stable_specs
@@ -47,13 +47,25 @@ module Pod
47
47
  class Podfile
48
48
  # @!group DSL support
49
49
  include Pod::Podfile::DSL
50
-
51
- # pod组件合并操作
52
- def pod_module_run(pod_modules, member_modules = {}, member_configs = [], ignore_local_stable = false)
50
+ # pod组件合并操作(项目)
51
+ def project_pod_module_run(pod_modules, member_modules = {}, member_configs = [], skip_stable_check = false)
52
+ # Pod::UI.puts "Pod Module:#{pod_modules}"
53
+ time1 = Time.new
54
+ puts "[PodAssistant]项目pod组件组装开始操作时间:#{time1}".green
55
+ source = BB::PodModule.new(pod_modules, member_modules, member_configs, false, skip_stable_check)
56
+ pod_box_module_run(source)
57
+ time2 = Time.new
58
+ puts "[PodAssistant]项目pod组件组装结束时间:#{time2}".green
59
+ # 获取时间差
60
+ time = time2 - time1
61
+ puts "项目pod组件组装操作耗时:#{time.to_s.send(:red)}秒".green
62
+ end
63
+ # pod组件合并操作(单组件)
64
+ def pod_module_run(pod_modules, member_modules = {}, member_configs = [])
53
65
  # Pod::UI.puts "Pod Module:#{pod_modules}"
54
66
  time1 = Time.new
55
67
  puts "[PodAssistant]pod组件组装开始操作时间:#{time1}".green
56
- source = BB::PodModule.new(pod_modules, member_modules, member_configs, ignore_local_stable)
68
+ source = BB::PodModule.new(pod_modules, member_modules, member_configs, true, true)
57
69
  pod_box_module_run(source)
58
70
  time2 = Time.new
59
71
  puts "[PodAssistant]pod组件组装结束时间:#{time2}".green
@@ -1,6 +1,7 @@
1
1
  require 'cocoapods-bb-PodAssistant/command'
2
2
  require 'csv'
3
3
  require 'xcodeproj'
4
+ require 'cocoapods-bb-PodAssistant/config/source_manager'
4
5
 
5
6
  class Dir
6
7
  def self.size(dir)
@@ -67,6 +68,9 @@ module BB
67
68
  end
68
69
  Pod::HooksManager.register("cocoapods-bb-PodAssistant", :post_install) do |installer|
69
70
  begin
71
+ source_manager = BB::SourceManager.new(@businessSpec)
72
+ # 生成本地yml配置
73
+ source_manager.generate_localStable
70
74
  $podEndTime = Time.new
71
75
  puts "[PodAssistant] plugin hook post_install".yellow
72
76
  puts "[PodAssistant] pod库下载耗时 GitCloneAllSize: #{$gitAllSize} M GitCloneAllTime: #{$cloneAllTime} S CDNDownloadAllSize: #{$pluginCurrentZipAllSize} M CDNAllTime: #{$downloadAllTime} S CDNDownloadAllTime: #{$cdnDownloadAllTime} S CDNUnzipAllTime: #{$cdnUnZipAllTime} S"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-bb-PodAssistant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - humin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-12 00:00:00.000000000 Z
11
+ date: 2023-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods-core