cocoapods-bb-PodAssistant 0.2.1 → 0.2.2

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: 46f2909212dda4283465cfe1db2a4b2311ed002e97f5c64290129b75a3f96c85
4
- data.tar.gz: b11851246802d6000005ebbc23cbdf19687de70805896ccae2915963aa8aca49
3
+ metadata.gz: 97479d53d22f4894ba793463fbb3aa6cc0affdb87959c19640398527e63a1bdd
4
+ data.tar.gz: e9d2bbe17b2e17c47688c02d5a6cba2e44bef6f500ee8b70fa90e5d27332ee58
5
5
  SHA512:
6
- metadata.gz: aa134b6cc558192b7b864c4872592299dc70efd9a1c58786e53048fbd0e6a7967e8d167467353002b700808249c1d390fbcba938b73dc9215ac7b9d45e28d5e2
7
- data.tar.gz: 3bff44bfca25a276653939eb3575b6872221a8412a3d3b717c9f1acfb3f566a5a65758226c04f992aae1f1dcef60390e39015e4770237457d3aa7282b9d7b650
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
@@ -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
@@ -320,13 +321,137 @@ module BB
320
321
  return lockfile
321
322
  end
322
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
323
443
  # 生成项目stable配置文件
324
444
  # 策略:根据podfile.lock dependencies依赖记录pod core标签/分支数据,不存储subspec数据
325
- def generate_localStable
445
+ def generate_localStable(ignore_dependencies_pod_names=[])
326
446
  lockfile = podfile_lock
327
447
  local_specs = {}
448
+ internal_data = lockfile.internal_data
449
+ pods = internal_data['PODS']
328
450
  dependencies = lockfile.dependencies
329
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)
330
455
  # dependencies依赖数据
331
456
  dependencies.each do | dependency |
332
457
  pod_name = dependency.name
@@ -377,10 +502,17 @@ module BB
377
502
  end
378
503
  end
379
504
 
380
- # 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}"
381
513
  if local_specs.length > 0
382
514
  update_localstable_datas(local_specs)
383
- Pod::UI.puts "Generating yml配置文件=> #{local_stable_yaml} 更新成功".green
515
+ puts "Generating yml配置文件=> #{local_stable_yaml} 更新成功".green
384
516
  end
385
517
  end
386
518
  # pod库是否包含core subspec
@@ -1,3 +1,3 @@
1
1
  module CocoapodsBbPodassistant
2
- VERSION = "0.2.1"
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
@@ -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.1
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