cocoapods-bb-PodAssistant 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d20d9d58e270471cf2c4f2c67680ac357bfe3a9bc98bfff584365aa7c7880ccc
4
- data.tar.gz: b9ae69a6fe68492eb9e60a9fd8f18bd128a983c05f2652f5bd4e256434965b2a
3
+ metadata.gz: 97479d53d22f4894ba793463fbb3aa6cc0affdb87959c19640398527e63a1bdd
4
+ data.tar.gz: e9d2bbe17b2e17c47688c02d5a6cba2e44bef6f500ee8b70fa90e5d27332ee58
5
5
  SHA512:
6
- metadata.gz: fdb0cbecbf00a7e12b86a39f912516361edf310c261508a494b6126c9122ab79e737c6ee5c821b3ae2fd871bbbc2309c0aa664b0c8a94fa489588e13e0cea645
7
- data.tar.gz: 6d2727972ff6356bca684ff3e7a9b6339d43e9e2fcf2952daada97c668712a9308cb37eb08e55bc38f7ad769aaeb7d4150241c12df3bc363c053839129ce58c9
6
+ metadata.gz: ad79dceeb9b07d81250ff78dda40620203c4ad74b40e3596d6544beb4a6ffad7d6d2b61a2fad0aaacf66a317438662992e6580ec62f9fc0a49cceb2d677fb5db
7
+ data.tar.gz: e0a2bf40bd535d3ab06edba17a6b49a7b5e8dbff2df1b5563d59b8cb117b06d2f9f466a88d51e6a89972e2b1db93b0de3abf444b2ce33e1f1523305fa6f6c5a7
@@ -1,4 +1,5 @@
1
1
  require 'cocoapods-bb-PodAssistant/config/source_manager'
2
+ require 'cocoapods-bb-bin/native'
2
3
 
3
4
  module Pod
4
5
  class Command
@@ -1,4 +1,5 @@
1
1
  require 'cocoapods-bb-PodAssistant/config/source_manager'
2
+ require 'cocoapods-bb-bin/native'
2
3
 
3
4
  module Pod
4
5
  class Command
@@ -21,13 +22,14 @@ module Pod
21
22
 
22
23
  def self.options
23
24
  [
24
- ['--sync', '立即同步远端yml配置,更新组件信息'],
25
+ ['--force', '强制更新组件,突破stable版本限制'],
25
26
  ].concat(super)
26
27
  end
27
28
 
28
29
  def initialize(argv)
29
30
  @pods = argv.arguments!
30
31
  @sync = argv.flag?('sync', true)
32
+ @force = argv.flag?('force', true)
31
33
  super
32
34
  end
33
35
 
@@ -38,7 +40,7 @@ module Pod
38
40
  # verify_podfile_exists! # 系统提供api验证podfile是否ok
39
41
  if @sync
40
42
  puts "[PodAssistant] 需要同步组件信息#{@pods}".green
41
- source_manager.merge_stable_data(@pods)
43
+ source_manager.merge_stable_data(@pods, @force)
42
44
  end
43
45
  podStartTime = Time.new
44
46
  update_spec
@@ -121,9 +121,9 @@ module BB
121
121
  end
122
122
 
123
123
  # 合并stable数据,参数,支持传入更新某几个数据
124
- def merge_stable_data(update_pods=[])
124
+ def merge_stable_data(update_pods=[], is_force = false)
125
125
  #4、show origin_stable_lock diff with local_stable_lock
126
- new_stable_spec = compare_specs(fetch_local_stable_datas, fetch_origin_stable_datas, update_pods)
126
+ new_stable_spec = compare_specs(fetch_local_stable_datas, fetch_origin_stable_datas, update_pods, is_force)
127
127
 
128
128
  #5、rewirte local_stable_lock with origin_stable_lock
129
129
  update_localstable_datas(new_stable_spec)
@@ -191,7 +191,7 @@ module BB
191
191
  update_dependencies_and_remove_data(business_stable_yaml, business_stable_datas, dependencies_pods, remove_pods)
192
192
  end
193
193
  # compare specs 参数1:本地,参数2:远端,参数3:指定更新pod库
194
- def compare_specs(local_specs, common_specs, update_pods=[])
194
+ def compare_specs(local_specs, common_specs, update_pods=[], is_force = false)
195
195
  added_projects = []
196
196
  updated_projects = []
197
197
  rollbacked_projects = []
@@ -218,10 +218,11 @@ module BB
218
218
  if (update_pods.length == 0) || (update_pods.include?(podCoreName))
219
219
  if versionGreat(version, local_version)
220
220
  updated_projects << "【#{name}】 (#{local_version}) -> (#{version.to_s.send(:yellow)})"
221
+ need_update_pod_lists[podCoreName] = version
221
222
  else
223
+ # 本地指向分支,以本地为主
222
224
  rollbacked_projects << "【#{name}】 (#{version.to_s.send(:red)}) <- (#{local_version})"
223
225
  end
224
- need_update_pod_lists[podCoreName] = version
225
226
  end
226
227
  end
227
228
  end
@@ -271,6 +272,17 @@ module BB
271
272
  new_specs.delete(name)
272
273
  end
273
274
  showMergeLog(added_projects, updated_projects, rollbacked_projects, deleted_projects)
275
+ # step.4 强制更新组件
276
+ if is_force == true
277
+ puts "强制升级组件#{update_pods}".red
278
+ update_pods.each do |pod_name|
279
+ pod = new_specs[pod_name]
280
+ if (pod.is_a? String) && !pod.include?('>=')
281
+ puts "强制升级name:#{pod_name} (>= #{pod})".red
282
+ new_specs[pod_name] = ">= #{pod}"
283
+ end
284
+ end
285
+ end
274
286
  # puts "new_specs:#{new_specs}".send(:red)
275
287
  return new_specs
276
288
  end
@@ -309,13 +321,137 @@ module BB
309
321
  return lockfile
310
322
  end
311
323
 
324
+ def name_and_version_from_string(string_representation)
325
+ match_data = string_representation.match(/\A((?:\s?[^\s(])+)(?: \((.+)\))?\Z/)
326
+ unless match_data
327
+ raise Informative, 'Invalid string representation for a ' \
328
+ "specification: `#{string_representation}`. " \
329
+ 'The string representation should include the name and ' \
330
+ 'optionally the version of the Pod.'
331
+ end
332
+ name = match_data[1]
333
+ vers = Pod::Version.new(match_data[2])
334
+ [name, vers]
335
+ end
336
+ def name_from_string(string_representation)
337
+ match_data = string_representation.match(/\A((?:\s?[^\s(])+)(?: \((.+)\))?\Z/)
338
+ unless match_data
339
+ raise Informative, 'Invalid string representation for a ' \
340
+ "specification: `#{string_representation}`. " \
341
+ 'The string representation should include the name and ' \
342
+ 'optionally the version of the Pod.'
343
+ end
344
+ name = match_data[1]
345
+ return name
346
+ end
347
+ def podfile_lock_pods
348
+ lockfile = podfile_lock
349
+ internal_data = lockfile.internal_data
350
+ pods = internal_data['PODS']
351
+ list={}
352
+ pods.each do |pod|
353
+ if pod.is_a?(Hash) # 存在依赖关系
354
+ pod_name = pod.keys.first
355
+ name, version = name_and_version_from_string(pod_name)
356
+ data = pod[pod_name]
357
+ data.each do | pod |
358
+ dependencies_pod_name = name_from_string(pod)
359
+ data = list[name]
360
+ if data.nil?
361
+ sub_data=[]
362
+ sub_data.push(dependencies_pod_name)
363
+ list[name]=sub_data
364
+ else
365
+ data.push(dependencies_pod_name)
366
+ list[name]=data
367
+ end
368
+ end
369
+ end
370
+ end
371
+ return list
372
+ end
373
+ def whitelist_podnames
374
+ return ['BBPostion', 'FMDB', 'Masonry', 'lottie-ios', 'SDWebImage', 'SSZipArchive', 'YYModel']
375
+ end
376
+ # 矩阵产品需要过滤组件
377
+ def matrix_filter_pod_names(pods, ignore_dependencies_pod_names=[])
378
+ ignore_dependencies_pod_names=['BBSAdvert'] unless ignore_dependencies_pod_names.nil? # 如果业务方配置,以业务方为主,默认处理广告业务
379
+ find_ok_dependencies_pod_names=[]
380
+ filter_pod_names=[]
381
+ whitelist_pods={}
382
+ whitelist = whitelist_podnames
383
+ # 查找需要进行过滤数据,解决多场景下组件动态更新,以广告为例
384
+ if ignore_dependencies_pod_names.length > 0
385
+ puts "业务方配置需要过滤数据:#{ignore_dependencies_pod_names} cls:#{ignore_dependencies_pod_names.class}".yellow
386
+ pods.each do |pod|
387
+ if pod.is_a?(Hash) # 存在依赖关系
388
+ pod_name = pod.keys.first
389
+ name, version = name_and_version_from_string(pod_name)
390
+ podCoreName = subspec_podname(name)
391
+ if ignore_dependencies_pod_names.include?(podCoreName) || find_ok_dependencies_pod_names.include?(name)
392
+ if !find_ok_dependencies_pod_names.include?(name)
393
+ find_ok_dependencies_pod_names.push(name)
394
+ end
395
+ sub_pods=[]
396
+ data = pod[pod_name]
397
+ data.each do | pod |
398
+ dependencies_pod_name = name_from_string(pod)
399
+ if dependencies_pod_name.include?(name) #subspecs
400
+ if !find_ok_dependencies_pod_names.include?(dependencies_pod_name)
401
+ find_ok_dependencies_pod_names.push(dependencies_pod_name)
402
+ end
403
+ end
404
+ if !sub_pods.include?(dependencies_pod_name)
405
+ sub_pods.push(dependencies_pod_name)
406
+ end
407
+ tmp_whitelist_pod_names = whitelist_pods[podCoreName]
408
+ if (podCoreName != name) && !tmp_whitelist_pod_names.include?(dependencies_pod_name)
409
+ dependencies_core_pod_name = subspec_podname(dependencies_pod_name)
410
+ if (podCoreName != dependencies_core_pod_name) && !whitelist.include?(dependencies_core_pod_name) && !filter_pod_names.include?(dependencies_core_pod_name)
411
+ filter_pod_names.push(dependencies_core_pod_name)
412
+ end
413
+ end
414
+ end
415
+ if podCoreName == name
416
+ whitelist_pods[podCoreName]=sub_pods
417
+ end
418
+ end
419
+ end
420
+ end
421
+ puts "过滤组件数据依赖:#{find_ok_dependencies_pod_names} cls:#{find_ok_dependencies_pod_names.class}"
422
+ # puts "==whitelist_pods:#{whitelist_pods} cls:#{whitelist_pods.class}".red
423
+ puts "需要过滤一级黑名单数据:#{filter_pod_names} cls:#{filter_pod_names.class}".yellow
424
+ if filter_pod_names.length > 0
425
+ pods_list = podfile_lock_pods
426
+ pods_list.keys.each do | pod_name |
427
+ podCoreName = subspec_podname(pod_name)
428
+ if filter_pod_names.include?(podCoreName)
429
+ data = pods_list[pod_name]
430
+ data.each do | sub_pod_name |
431
+ sub_podCoreName = subspec_podname(sub_pod_name)
432
+ if !sub_podCoreName.include?('BB') && !whitelist.include?(sub_podCoreName) && !filter_pod_names.include?(sub_podCoreName)
433
+ filter_pod_names.push(sub_podCoreName)
434
+ end
435
+ end
436
+ end
437
+ end
438
+ puts "需要过滤all黑名单数据:#{filter_pod_names} cls:#{filter_pod_names.class}".yellow
439
+ end
440
+ end
441
+ return filter_pod_names
442
+ end
312
443
  # 生成项目stable配置文件
313
444
  # 策略:根据podfile.lock dependencies依赖记录pod core标签/分支数据,不存储subspec数据
314
- def generate_localStable
445
+ def generate_localStable(ignore_dependencies_pod_names=[])
315
446
  lockfile = podfile_lock
316
447
  local_specs = {}
448
+ internal_data = lockfile.internal_data
449
+ pods = internal_data['PODS']
317
450
  dependencies = lockfile.dependencies
318
451
  pod_names = lockfile.pod_names
452
+ # puts "dependencies:#{dependencies}".red
453
+ # puts "pod_names:#{pod_names}".green
454
+ filter_pod_names = matrix_filter_pod_names(pods, ignore_dependencies_pod_names)
319
455
  # dependencies依赖数据
320
456
  dependencies.each do | dependency |
321
457
  pod_name = dependency.name
@@ -366,10 +502,17 @@ module BB
366
502
  end
367
503
  end
368
504
 
369
- # Pod::UI.puts "yml配置数据:#{local_specs}"
505
+ # 删除过滤数据
506
+ filter_pod_names.each do | pod_name |
507
+ if local_specs.include?(pod_name)
508
+ # puts "删除过滤数据pod_name:#{pod_name} #{local_specs[pod_name]}"
509
+ local_specs.delete(pod_name)
510
+ end
511
+ end
512
+ # puts "yml配置数据:#{local_specs}"
370
513
  if local_specs.length > 0
371
514
  update_localstable_datas(local_specs)
372
- Pod::UI.puts "Generating yml配置文件=> #{local_stable_yaml} 更新成功".green
515
+ puts "Generating yml配置文件=> #{local_stable_yaml} 更新成功".green
373
516
  end
374
517
  end
375
518
  # pod库是否包含core subspec
@@ -1,3 +1,3 @@
1
1
  module CocoapodsBbPodassistant
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -25,13 +25,29 @@ module BB
25
25
  @source_manager = BB::SourceManager.new()
26
26
  #加载远程稳定仓库 和本地podfile 指定的仓库进行合并
27
27
  if skip_stable_check == true
28
- @@all_modules = all_modules
28
+ # 过滤带:remove数据
29
+ @@all_modules = filter_origin_pod_modules(all_modules)
29
30
  else
30
31
  @@all_modules = load_stable_specs_to_podfile(all_modules, ignore_local_stable)
31
32
  end
32
33
  @@member_modules = member_modules
33
34
  @@member_configs = member_configs
34
35
  end
36
+ private def filter_origin_pod_modules(all_modules)
37
+ result_modules = []
38
+ all_modules.each do |pod|
39
+ if pod.is_a?(Hash)
40
+ remove = pod[:remove]
41
+ if remove
42
+ pod_name = pod.first
43
+ puts "###业务方配置需要移除插件####names:[#{pod_name}] pod:#{pod}".red
44
+ else
45
+ result_modules.push(pod)
46
+ end
47
+ end
48
+ end
49
+ return result_modules
50
+ end
35
51
 
36
52
  def current_member
37
53
  if @@member_configs
@@ -272,7 +288,7 @@ module BB
272
288
  end
273
289
  end
274
290
  stable_hash[podName] = pod
275
- puts "[PodAssistant] merge pod #{podName} #{pod}"
291
+ # puts "[PodAssistant] merge pod #{podName} #{pod}"
276
292
  end
277
293
  else
278
294
  puts "[PodAssistant] 本地stable数据无变化<===完成".yellow
@@ -315,15 +331,17 @@ module BB
315
331
  data[:linkage] = linkage
316
332
  end
317
333
  if !data.empty?
318
- # puts "name:#{name} stable_specs: #{data}".green
334
+ # puts "===git===分支==> #{data}".green
319
335
  stable_specs.push(data)
320
336
  end
321
337
  elsif pod.is_a? String
338
+ # puts "===git===标签==> { names: [\"#{name}\"], version: #{pod}, method: REMOTE_TAG }".green
322
339
  stable_specs.push({ names: [name], version: pod, method: REMOTE_TAG })
323
340
  else
324
341
  puts "unknow type [#{name}] data:#{pod}".red
325
342
  end
326
343
  end
344
+ # puts "[PodAssistant] stable_specs:#{stable_specs}".green
327
345
  return stable_specs
328
346
  end
329
347
  ################################# linkline stable ����� #################################
@@ -0,0 +1,48 @@
1
+ require 'active_support/core_ext/string/inflections'
2
+ require 'fileutils'
3
+ require 'cocoapods/podfile'
4
+ require 'cocoapods-bb-bin/native'
5
+
6
+ module Pod
7
+ class Installer
8
+ autoload :Analyzer, 'cocoapods/installer/analyzer'
9
+ autoload :InstallationOptions, 'cocoapods/installer/installation_options'
10
+ autoload :PostInstallHooksContext, 'cocoapods/installer/post_install_hooks_context'
11
+ autoload :PreInstallHooksContext, 'cocoapods/installer/pre_install_hooks_context'
12
+ autoload :BaseInstallHooksContext, 'cocoapods/installer/base_install_hooks_context'
13
+ autoload :PostIntegrateHooksContext, 'cocoapods/installer/post_integrate_hooks_context'
14
+ autoload :PreIntegrateHooksContext, 'cocoapods/installer/pre_integrate_hooks_context'
15
+ autoload :SourceProviderHooksContext, 'cocoapods/installer/source_provider_hooks_context'
16
+ autoload :PodfileValidator, 'cocoapods/installer/podfile_validator'
17
+ autoload :PodSourceDownloader, 'cocoapods/installer/pod_source_downloader'
18
+ autoload :PodSourceInstaller, 'cocoapods/installer/pod_source_installer'
19
+ autoload :PodSourcePreparer, 'cocoapods/installer/pod_source_preparer'
20
+ autoload :UserProjectIntegrator, 'cocoapods/installer/user_project_integrator'
21
+ autoload :Xcode, 'cocoapods/installer/xcode'
22
+ autoload :SandboxHeaderPathsInstaller, 'cocoapods/installer/sandbox_header_paths_installer'
23
+ autoload :SandboxDirCleaner, 'cocoapods/installer/sandbox_dir_cleaner'
24
+ autoload :ProjectCache, 'cocoapods/installer/project_cache/project_cache'
25
+ autoload :TargetUUIDGenerator, 'cocoapods/installer/target_uuid_generator'
26
+
27
+ include Config::Mixin
28
+
29
+ # alias_method :origin_resolve_dependencies, :resolve_dependencies
30
+ # def resolve_dependencies
31
+ # puts "[PodAssistant] 开始执行 Installer resolve_dependencies".red
32
+ # puts "[PodAssistant] 开始执行 Installer resolve_dependencies [#{$*}] [#{$*.first}]".green
33
+ # analyzer = origin_resolve_dependencies
34
+ # puts "analyzer:#{analyzer}".green
35
+ # if ($*.first == "update" || $*.first == "install")
36
+ # puts 'Analyzing dependencies virtual'.red
37
+ # # UI.section 'Analyzing dependencies virtual' do
38
+ # $virtual_dependencies_names = @analysis_result.specifications.map(&:name)
39
+ # $virtual_dependencies_flag = true
40
+ # analyzer = origin_resolve_dependencies
41
+ # # end
42
+ # end
43
+ # puts "analyzer:#{analyzer}".red
44
+ # analyzer
45
+ # end
46
+
47
+ end
48
+ end
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.2.0
4
+ version: 0.2.2
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-19 00:00:00.000000000 Z
11
+ date: 2023-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods-core
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.10.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: cocoapods-bb-bin
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.7.7
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.7.7
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -103,6 +117,7 @@ files:
103
117
  - lib/cocoapods-bb-PodAssistant/helpers/stable_env_helper.rb
104
118
  - lib/cocoapods-bb-PodAssistant/helpers/stable_manager_helper.rb
105
119
  - lib/cocoapods-bb-PodAssistant/helpers/yaml_files_helper.rb
120
+ - lib/cocoapods-bb-PodAssistant/native/installer.rb
106
121
  - lib/cocoapods-bb-PodAssistant/podfile.rb
107
122
  - lib/cocoapods-bb-PodAssistant/source_provider_hook.rb
108
123
  - lib/cocoapods_plugin.rb