cocoapods-bb-PodAssistant 0.1.9.1 → 0.2.0

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: f6c32b006b3836cba11f001d3ebc24c707f3bd473a35156cfaf3bceae50f4528
4
- data.tar.gz: 447a74c6907306dfdacf90685572eeea587b97e0e20ad61c0ccebf7001f4ca69
3
+ metadata.gz: d20d9d58e270471cf2c4f2c67680ac357bfe3a9bc98bfff584365aa7c7880ccc
4
+ data.tar.gz: b9ae69a6fe68492eb9e60a9fd8f18bd128a983c05f2652f5bd4e256434965b2a
5
5
  SHA512:
6
- metadata.gz: b0f45f73957e38a0007348067cbcbc39d65a1a533ffe0ba5a349d82134909f3e51bdc72e062adfcecc7b184ddc3da11df2cc2dd2041740331f6216ebe53a8a27
7
- data.tar.gz: ea3629e578813651181a761037a0d4ec02a25b0003c6e24cca1574de0e1fd3b82a0e0ec0fc4f028b2e5fc91da44019c64e2eff3cecd80bab4cf44a1f7913a073
6
+ metadata.gz: fdb0cbecbf00a7e12b86a39f912516361edf310c261508a494b6126c9122ab79e737c6ee5c821b3ae2fd871bbbc2309c0aa664b0c8a94fa489588e13e0cea645
7
+ data.tar.gz: 6d2727972ff6356bca684ff3e7a9b6339d43e9e2fcf2952daada97c668712a9308cb37eb08e55bc38f7ad769aaeb7d4150241c12df3bc363c053839129ce58c9
@@ -13,12 +13,16 @@ class BabybusInstallEnv
13
13
  rootPath = getProjectRootPath
14
14
  bundleIdentifier = getProjectBundleIdentifier
15
15
  path = File.join(rootPath, "Configs", "#{bundleIdentifier}/BBPlistMacro.h")
16
+ puts "查找PlistMacro文件1:#{path}"
16
17
  if !File.file?(path)
17
18
  path = File.join(rootPath, "Configs/PlistMacro", "#{bundleIdentifier}/BBPlistMacro.h")
19
+ puts "查找PlistMacro文件2:#{path}"
18
20
  if !File.file?(path)
19
21
  path = File.join(rootPath, "Configs/PlistMacro", "#{bundleIdentifier}_BBPlistMacro.h")
22
+ puts "查找PlistMacro文件3:#{path}"
20
23
  if !File.file?(path)
21
24
  path = File.join(rootPath, "Configs/PlistMacro", "BBPlistMacro.h")
25
+ puts "查找PlistMacro文件4:#{path}"
22
26
  end
23
27
  end
24
28
  end
@@ -51,12 +55,16 @@ class BabybusInstallEnv
51
55
  rootPath = getProjectRootPath
52
56
  bundleIdentifier = getProjectBundleIdentifier
53
57
  path = File.join(rootPath, "Configs", "#{bundleIdentifier}/UnityFramework.framework")
58
+ puts "查找UnityFramework产物1:#{path}"
54
59
  if !File.file?(path)
55
60
  path = File.join(rootPath, "Configs/UnityFramework", "#{bundleIdentifier}/UnityFramework.framework")
61
+ puts "查找UnityFramework产物2:#{path}"
56
62
  if !File.directory?(path)
57
63
  path = File.join(rootPath, "Configs/UnityFramework", "#{bundleIdentifier}_UnityFramework.framework")
64
+ puts "查找UnityFramework产物3:#{path}"
58
65
  if !File.directory?(path)
59
66
  path = File.join(rootPath, "Configs/UnityFramework", "UnityFramework.framework")
67
+ puts "查找UnityFramework产物4:#{path}"
60
68
  end
61
69
  end
62
70
  end
@@ -78,7 +86,7 @@ class BabybusInstallEnv
78
86
  system "rm -rf #{replaceFilePath}; cp -af #{path} #{replaceFilePath}"
79
87
  puts "替换UnityFramework文件成功".yellow
80
88
  else
81
- puts "找不到UnityFramework配置文件,替换失败path:#{path}".red
89
+ puts "找不到UnityFramework产物文件,替换失败".red
82
90
  end
83
91
  end
84
92
  # 2D母包替换
@@ -24,12 +24,20 @@ def forceAddDebugTool
24
24
  forceAddDebugTool = BB::PodUtils.getValueFromInfoPlist("ForceAddDebugTool")
25
25
  return forceAddDebugTool === "true"
26
26
  end
27
- # 是否3d产品
27
+ # 是否3d产品(968开始切新版unity2022引擎)
28
28
  def isUnity3DApp
29
- isU3dValue = BB::PodUtils.getValueFromInfoPlist("Unity3D")
30
- return isU3dValue === "true"
29
+ if isUnityApp
30
+ # 1=>Cocos2D; 2=>Unity2D; 3=>普通 Unity3D; 4=>新版 Unity 3D; 5=>2D融合 打包机负责写入
31
+ value = BB::PodUtils.getValueFromInfoPlist("packer_engines_id")
32
+ return value === "4"
33
+ end
34
+ return false
35
+ end
36
+ # 是否unity产品,包含2d/3d
37
+ def isUnityApp
38
+ value = BB::PodUtils.getValueFromInfoPlist("Unity3D")
39
+ return value === "true"
31
40
  end
32
-
33
41
  # 是否需要第三方支付sdk
34
42
  def isThirdPaySdk
35
43
  value = BB::PodUtils.getValueFromInfoPlist("Third_Purcharse")
@@ -83,9 +91,35 @@ def isPinyinAppp
83
91
  return bundleId === "com.sinyee.babybus.voicerecognition" || bundleId === "com.sinyee.babybus.read.ios" || bundleId === "com.sinyee.babybus.stroke"
84
92
  end
85
93
 
94
+ # 是否科学产品
95
+ def isCourseApp
96
+ bundleId = getProjectBundleIdentifier()
97
+ return bundleId === "com.ailiyong.world.course"
98
+ end
99
+
100
+ # 是否思维产品
101
+ def isMathApp
102
+ bundleId = getProjectBundleIdentifier()
103
+ return bundleId === "com.sinyee.babybus.mathIII"
104
+ end
105
+
106
+ # 是否abc产品
107
+ def isABCApp
108
+ bundleId = getProjectBundleIdentifier()
109
+ return bundleId === "com.sinyee.babybus.abc"
110
+ end
111
+
112
+ # 是否城市产品
113
+ def isCityApp
114
+ bundleId = getProjectBundleIdentifier()
115
+ return bundleId === "com.sinyee.babybus.city"
116
+ end
117
+
86
118
  # 是否矩阵产品
87
119
  def isMatrixApp
88
- if (isHanZiApp || isQMWApp || isPinyinAppp) then
120
+ bundleId = getProjectBundleIdentifier()
121
+ puts "###bundleId:#{bundleId}###".red
122
+ if (isHanZiApp || isQMWApp || isPinyinAppp || isCourseApp || isMathApp || isABCApp || isCityApp) then
89
123
  return false
90
124
  end
91
125
  return true
@@ -7,36 +7,45 @@ require 'cocoapods-bb-PodAssistant/babybus/business/babybus_install_environment'
7
7
  require 'cocoapods-bb-PodAssistant/helpers/pod_utils'
8
8
 
9
9
  class PodPostInstaller
10
- def initialize(lib, deployment_target="11.0", unity_deployment_target="11.0")
11
- @lib = lib
12
- @deployment_target = deployment_target
13
- @unity_deployment_target = unity_deployment_target
10
+ def initialize(lib, deployment_target=nil)
11
+ @lib = lib
12
+ if deployment_target.nil?
13
+ @deployment_target = isUnity3DApp ? "12.0" : "11.0" # Unity2022引擎最低支持iOS12.0、unity2d iOS11 、cocos iOS10、超A产品 iOS11 (968广告厂商升级最低支持iOS11)
14
+ else
15
+ @deployment_target = deployment_target
16
+ end
14
17
  end
15
18
  def run
16
19
  env = BabybusInstallEnv.new()
17
20
  is_xcode15 = BB::PodUtils.compare_xcode_15_version
18
21
  # 是否Untify项目
19
- isUnityProject = isUnity3DApp
20
-
22
+ isUnityProject = isUnityApp
21
23
  # Untify项目需要移除cocos项目res/src目录
22
24
  if (isUnityProject) then
23
25
  env.createCocosResource
24
26
  end
25
- ios_deployment_target = isUnityProject ? @unity_deployment_target : @deployment_target
26
- puts "当前工程最低支持iOS系统===>#{ios_deployment_target.to_s.send(:red)}".green
27
+ ios_deployment_target = @deployment_target
28
+ puts "pod组件配置工程最低支持iOS系统 ===> #{ios_deployment_target.to_s.send(:red)}".green
27
29
  @lib.aggregate_targets.first.user_project.save # 解决Xcode13 pod update操作出现failed to save pods.xcodeproj问题 by hm 21/11/8
28
30
  project = Xcodeproj::Project.open(BB::PodUtils.getXcodeprojPath)
29
31
  project.targets.each do |target|
30
32
  target.build_configurations.each do |config|
31
- if config.name.include? 'Debug' # 只有debug环境才进行替换操作,其它环境交由打包机处理
32
- puts "[#{target.name}/#{config.name}] 环境替换PlistMacro文件操作!!!开发者debug环境自行打开👇替换操作,禁止提交版本控制,谢谢🙏"
33
- env.copyPlistMacro # 开发自行打开不能提交到版本控制,避免test包出现配置不正确情况 by hm 22/5/17
34
- end
35
- # iOS17适配添加ld64
36
- if (is_xcode15 == true) then
37
- config.build_settings['OTHER_LDFLAGS'] = "$(inherited) -lxml2 -lz -ObjC -lstdc++ -ld64"
38
- else
39
- config.build_settings['OTHER_LDFLAGS'] = "$(inherited) -lxml2 -lz -ObjC -lstdc++"
33
+ if !target.name.include? '_test' # 过滤target test 工程
34
+ if config.name.include? 'Debug' # 只有debug环境才进行替换操作,其它环境交由打包机处理
35
+ puts "[#{target.name}/#{config.name}] 开发者debug环境环境替换[PlistMacro/cocos/unity]文件操作,其它环境交由打包机处理".red
36
+ env.copyPlistMacro # 开发自行打开不能提交到版本控制,避免test包出现配置不正确情况 by hm 22/5/17
37
+ if (isUnityProject) then
38
+ env.copyUnityFramework
39
+ else
40
+ env.copyCocosPackage
41
+ end
42
+ end
43
+ # iOS17适配添加ld64
44
+ if (is_xcode15 == true) then
45
+ config.build_settings['OTHER_LDFLAGS'] = "$(inherited) -lxml2 -lz -ObjC -lstdc++ -ld64"
46
+ else
47
+ config.build_settings['OTHER_LDFLAGS'] = "$(inherited) -lxml2 -lz -ObjC -lstdc++"
48
+ end
40
49
  end
41
50
  end
42
51
  end
@@ -54,51 +63,50 @@ class PodPostInstaller
54
63
  # project.targets.config
55
64
  @lib.pod_target_subprojects.flat_map { |p| p.targets }.each do |target|
56
65
  target.build_configurations.each do |config|
57
- # pod 1.13.0兼容故去除,避免
58
- # 适配xcode 15 动态库报错: Error 'DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead'
59
- # if (is_xcode15 == true) then
60
- # xcconfig_path = config.base_configuration_reference.real_path
61
- # xcconfig = File.read(xcconfig_path)
62
- # xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
63
- # File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
64
- # end
65
-
66
- config.build_settings['DEAD_CODE_STRIPPING'] = 'YES'
67
- config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = ios_deployment_target
68
- if (isUnityProject) then
69
- config.build_settings['ARCHS'] = 'arm64'
70
- else
71
- config.build_settings['ARCHS'] = '$(ARCHS_STANDARD)'
72
- end
73
- # fix xcode14手动签名问题 https://github.com/CocoaPods/CocoaPods/issues/11402
74
- # config.build_settings["DEVELOPMENT_TEAM"] = "#{teamid}"
75
- # Fix Xcode14 bundle need sign
76
- # https://github.com/CocoaPods/CocoaPods/issues/11402#issuecomment-1201464693
77
- if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
78
- config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
79
- end
80
- # 编译器优化
81
- config.build_settings['WARNING_CFLAGS'] = '-Wno-documentation -Wno-nullability-completeness -Wno-macro-redefined -Wno-property-attribute-mismatch -Wno-strict-prototypes -Wno-incompatible-pointer-types'
82
- config.build_settings['ASSETCATALOG_COMPILER_OPTIMIZATION'] = 'space'
83
- config.build_settings['ENABLE_BITCODE'] = 'NO'
84
- config.build_settings['DEAD_CODE_STRIPPING'] = 'YES'
85
- if config.name.include? 'Debug'
86
- config.build_settings['SWIFT_COMPILATION_MODE'] = 'Incremental'
87
- config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
88
- config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
89
- else
90
- config.build_settings['SWIFT_COMPILATION_MODE'] = 'wholemodule'
91
- config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Osize'
92
- config.build_settings['GCC_OPTIMIZATION_LEVEL'] = 'z'
93
- end
94
- # C++支持@import (工程中带mm类需要进行控制)
95
- if (target.name.include? 'matrix-wechat') || (target.name.include? 'Sentry')
96
- # 三方库不支持modulemap
97
- config.build_settings['OTHER_CPLUSPLUSFLAGS'] = "$(inherited) $(OTHER_CFLAGS)"
98
- else
99
- config.build_settings['OTHER_CPLUSPLUSFLAGS'] = "$(inherited) $(OTHER_CFLAGS) -fmodules -fcxx-modules"
100
- end
101
-
66
+ # pod 1.13.0兼容故去除,避免
67
+ # 适配xcode 15 动态库报错: Error 'DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead'
68
+ # if (is_xcode15 == true) then
69
+ # xcconfig_path = config.base_configuration_reference.real_path
70
+ # xcconfig = File.read(xcconfig_path)
71
+ # xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
72
+ # File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
73
+ # end
74
+
75
+ config.build_settings['DEAD_CODE_STRIPPING'] = 'YES'
76
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = ios_deployment_target
77
+ if (isUnityProject) then
78
+ config.build_settings['ARCHS'] = 'arm64'
79
+ else
80
+ config.build_settings['ARCHS'] = '$(ARCHS_STANDARD)'
81
+ end
82
+ # fix xcode14手动签名问题 https://github.com/CocoaPods/CocoaPods/issues/11402
83
+ # config.build_settings["DEVELOPMENT_TEAM"] = "#{teamid}"
84
+ # Fix Xcode14 bundle need sign
85
+ # https://github.com/CocoaPods/CocoaPods/issues/11402#issuecomment-1201464693
86
+ if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
87
+ config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
88
+ end
89
+ # 编译器优化
90
+ config.build_settings['WARNING_CFLAGS'] = '-Wno-documentation -Wno-nullability-completeness -Wno-macro-redefined -Wno-property-attribute-mismatch -Wno-strict-prototypes -Wno-incompatible-pointer-types'
91
+ config.build_settings['ASSETCATALOG_COMPILER_OPTIMIZATION'] = 'space'
92
+ config.build_settings['ENABLE_BITCODE'] = 'NO'
93
+ config.build_settings['DEAD_CODE_STRIPPING'] = 'YES'
94
+ if config.name.include? 'Debug'
95
+ config.build_settings['SWIFT_COMPILATION_MODE'] = 'Incremental'
96
+ config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
97
+ config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
98
+ else
99
+ config.build_settings['SWIFT_COMPILATION_MODE'] = 'wholemodule'
100
+ config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Osize'
101
+ config.build_settings['GCC_OPTIMIZATION_LEVEL'] = 'z'
102
+ end
103
+ # C++支持@import (工程中带mm类需要进行控制)
104
+ if (target.name.include? 'matrix-wechat') || (target.name.include? 'Sentry')
105
+ # 三方库不支持modulemap
106
+ config.build_settings['OTHER_CPLUSPLUSFLAGS'] = "$(inherited) $(OTHER_CFLAGS)"
107
+ else
108
+ config.build_settings['OTHER_CPLUSPLUSFLAGS'] = "$(inherited) $(OTHER_CFLAGS) -fmodules -fcxx-modules"
109
+ end
102
110
  end
103
111
  # 修复警告 Run script build phase '[CP] Copy Pods Resources' will be run during every build because it does not specify any outputs
104
112
  fix_phases = target.shell_script_build_phases.find { |x| x.name == '[CP] Copy XCFrameworks' || 'Create Symlinks to Header Folders' }
@@ -0,0 +1,93 @@
1
+ require 'cocoapods-bb-PodAssistant/config/source_manager'
2
+
3
+ module Pod
4
+ class Command
5
+ class Stable < Command
6
+ class Push < Stable
7
+ self.summary = '[更新stable组件稳定版本] Update outdated project dependencies and create new ' \
8
+ 'Podfile.lock'
9
+
10
+ self.description = <<-DESC
11
+ 常用命令如下:\n
12
+ 更新所有公共组件: `pod stable push`\n
13
+ 更新指定公共组件: `pod stable push 组件名称`\n
14
+ 更新指定公共组件/移除组件: `pod stable push 组件名称 --remove=组件名称` #多个移除名称带`,`\n
15
+ 更新指定公共组件/带依赖关系: `pod stable push 组件名称 --dependencies=组件名称` #多个依赖名称带`,`\n
16
+ 更新指定公共组件/带依赖关系/移除组件: `pod stable push 组件名称 --dependencies=组件名称 --remove=组件名称` #多个依赖名称带`,`\n
17
+ 参数说明:--dependencies 依赖组件 --remove 需要移除组件 --update-matrix 更新矩阵产品公共业务线
18
+ DESC
19
+
20
+ self.arguments = [
21
+ CLAide::Argument.new('POD_NAMES', false, true),
22
+ ]
23
+
24
+ def self.options
25
+ [
26
+ ['--dependencies', '依赖组件名称,多个使用`,`隔开'],
27
+ ['--remove', '移除公共组件名称,多个使用`,`隔开'],
28
+ ['--update-matrix', '更新矩阵产品公共业务线'],
29
+ ].concat(super)
30
+ end
31
+
32
+ def initialize(argv)
33
+ @pods = argv.arguments!
34
+ @dependencies = argv.option('dependencies', nil)&.split(',')
35
+ @remove = argv.option('remove', nil)&.split(',')
36
+ @is_matrix = argv.flag?('update-matrix', false)
37
+ super
38
+ end
39
+
40
+ def run
41
+ puts "[PodAssistant] 开始执行 $ pod stable push".yellow
42
+ source_manager = BB::SourceManager.new(false)
43
+ cachePath = source_manager.cache_path
44
+ puts "stable cache git=>#{cachePath}"
45
+ Dir.chdir(File.join(cachePath)) {
46
+ # puts "pwd:#{`pwd`}".green
47
+ path = @is_matrix ? matrix_stable_path : common_stable_path
48
+ Dir.chdir(File.join(path)) {
49
+ if @pods.any?
50
+ if (@pods.length > 1) && (@dependencies)
51
+ puts "❌ 无效指令,不能处理多个组件#{@pods}依赖,更新组件仅支持单组件".red
52
+ puts "举例:pod stable push <单组件> --dependencies=<多组件>".green
53
+ puts "详见 pod stable push --help".green
54
+ system "pod stable push --help"
55
+ exit
56
+ elsif (@pods.length == 1) && (@dependencies || @remove)
57
+ pod_name=@pods.first
58
+ dependencies_hash = {}
59
+ if @dependencies
60
+ dependencies_hash[pod_name] = @dependencies
61
+ end
62
+ if @is_matrix
63
+ source_manager.update_business_dependencies_and_remove_data(dependencies_hash, @remove)
64
+ else
65
+ source_manager.update_common_dependencies_and_remove_data(dependencies_hash, @remove)
66
+ end
67
+ end
68
+ pods_str = @pods.join(" ")
69
+ system "pod stable update #{pods_str}"
70
+ else
71
+ if (@dependencies) || (@remove)
72
+ puts "❌ 无效指令,没有制定组件名称 详见 pod stable push --help".red
73
+ system "pod stable push --help"
74
+ exit
75
+ end
76
+ system "pod stable update"
77
+ end
78
+ }
79
+ }
80
+ end
81
+
82
+ # 公共stable目录
83
+ private def common_stable_path
84
+ return File.join(Dir.pwd, 'Common_Stable')
85
+ end
86
+ # 全线矩阵产品公共stable目录
87
+ private def matrix_stable_path
88
+ return File.join(Dir.pwd, 'Matrix_Common_Stable')
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -8,7 +8,7 @@ module Pod
8
8
  class Stable < Command
9
9
  class Sync < Stable
10
10
 
11
- self.summary = '[同步远端yml配置] sync a Stable yml config file'
11
+ self.summary = '[同步远端yml配置,更新所有公共组件标签库版本] sync a Stable yml config file'
12
12
 
13
13
  self.description = <<-DESC
14
14
  同步远端stable yml配置文件,并对本地文件进行合并操作
@@ -4,7 +4,7 @@ module Pod
4
4
  class Command
5
5
  class Stable < Command
6
6
  class Update < Stable
7
- self.summary = '[命令同执行`pod update操作`] Update outdated project dependencies and create new ' \
7
+ self.summary = '[命令同执行`pod update操作`,同步更新stable组件标签版本到最新] Update outdated project dependencies and create new ' \
8
8
  'Podfile.lock'
9
9
 
10
10
  self.description = <<-DESC
@@ -27,7 +27,7 @@ module Pod
27
27
 
28
28
  def initialize(argv)
29
29
  @pods = argv.arguments!
30
- @sync = argv.flag?('sync')
30
+ @sync = argv.flag?('sync', true)
31
31
  super
32
32
  end
33
33
 
@@ -41,6 +41,7 @@ module Pod
41
41
  source_manager.merge_stable_data(@pods)
42
42
  end
43
43
  podStartTime = Time.new
44
+ update_spec
44
45
  if @pods.any?
45
46
  pods_str = @pods.join(" ")
46
47
  system "pod update #{pods_str}"
@@ -55,6 +56,11 @@ module Pod
55
56
  source_manager.update_local_stable_from_podmodules(@pods)
56
57
  puts "[PodAssistant] `pod stable update` complete!".green
57
58
  end
59
+ def update_spec
60
+ system "pod repo update babybus-babybus-ios-specs-babybus-specs"
61
+ system "pod repo update babybus-babybus-ios-specs-sourcev2-specs"
62
+ system "pod repo update babybus-babybus-ios-specs-dylib-specs"
63
+ end
58
64
  end
59
65
  end
60
66
  end
@@ -6,6 +6,7 @@ require 'cocoapods-bb-PodAssistant/command/stable/init'
6
6
  require 'cocoapods-bb-PodAssistant/command/stable/install'
7
7
  require 'cocoapods-bb-PodAssistant/command/stable/update'
8
8
  require 'cocoapods-bb-PodAssistant/command/stable/sync'
9
+ require 'cocoapods-bb-PodAssistant/command/stable/push'
9
10
 
10
11
  module Pod
11
12
 
@@ -29,21 +30,16 @@ module Pod
29
30
  拉取稳定lock配置插件。利用版本比对进行更新配置实现对组件版本控制管理。
30
31
  DESC
31
32
 
32
- self.default_subcommand = 'init'
33
+ # self.default_subcommand = 'init'
33
34
 
34
35
  #-----------------------------------------------------------------------#
35
36
 
36
37
  extend Executable
37
38
  executable :git
38
39
 
39
- def validate!
40
+ def initialize(argv)
40
41
  super
41
- banner! if @help
42
- end
43
-
44
- def run
45
- puts "[PodAssistant] `pod stable` 帮助文档请查看�".yellow
46
- # banner!
42
+ puts "cocoapods-bb-PodAssistant (#{CocoapodsBbPodassistant::VERSION})"
47
43
  end
48
44
 
49
45
  end
@@ -3,12 +3,12 @@ require 'cocoapods-bb-PodAssistant/helpers/pod_utils'
3
3
 
4
4
  module BB
5
5
  class Cache
6
- def initialize(stable_source = nil)
6
+ def initialize(stable_source = nil, verify_stable_env=true)
7
7
  if stable_source.nil?
8
8
  stable_source = StableSource.stable_default_source
9
9
  end
10
10
  @stable_source = stable_source
11
- if File.exist?(File.join(Pathname.pwd, "Podfile"))
11
+ if verify_stable_env && File.exist?(File.join(Pathname.pwd, "Podfile"))
12
12
  @bundleId = BB::PodUtils.getProjectBundleIdentifier
13
13
  end
14
14
  if @bundleId.nil?
@@ -7,13 +7,16 @@ require 'cocoapods-bb-PodAssistant/helpers/stable_env_helper'
7
7
  # 数据源管理
8
8
  module BB
9
9
  class SourceManager
10
- def initialize()
11
- env = BB::StableEnv.new()
12
- # puts "SourceManager env:#{env}".red
13
- @businessSpecName = env.business_stable
14
- @stableMgr = BB::StableManager.new(env)
10
+ def initialize(verify_stable_env=true)
11
+ @env = BB::StableEnv.new(verify_stable_env)
12
+ @businessSpecName = @env.business_stable
13
+ @stableMgr = BB::StableManager.new(@env, verify_stable_env)
15
14
  end
16
15
 
16
+ def cache_path
17
+ return @env.cache_path
18
+ end
19
+
17
20
  # 公共源路径(远端)
18
21
  def public_stable_yaml
19
22
  return @stableMgr.public_stable_yaml
@@ -29,6 +32,18 @@ module BB
29
32
  return @stableMgr.local_stable_yaml
30
33
  end
31
34
 
35
+ def get_stable_datas(yml)
36
+ spec = BB::StableSpecs.new()
37
+ return spec.readData(yml)
38
+ end
39
+ # 通用-公共lock数据
40
+ def common_stable_datas
41
+ return get_stable_datas(public_stable_yaml)
42
+ end
43
+ # 业务线-公共lock数据
44
+ def business_stable_datas
45
+ return get_stable_datas(business_stable_yaml)
46
+ end
32
47
  # 产品线本地lock数据
33
48
  def fetch_local_stable_datas
34
49
  localSpec = BB::StableSpecs.new()
@@ -37,7 +52,7 @@ module BB
37
52
  puts "yml配置文件不存在,执行自动初始化项目yml配置文件".green
38
53
  generate_localStable
39
54
  end
40
- return localSpec.readData(yml)
55
+ return get_stable_datas(yml)
41
56
  end
42
57
 
43
58
  # 远端公共lock数据
@@ -90,8 +105,19 @@ module BB
90
105
 
91
106
  # 更新本地lock数据
92
107
  def update_localstable_datas(stable_lock)
93
- localSpec = BB::StableSpecs.new()
94
- localSpec.writeData(local_stable_yaml, stable_lock)
108
+ update_stable_lock(local_stable_yaml, stable_lock)
109
+ end
110
+ # podfile 更新配置文件使用(通用)
111
+ def update_common_stable_lock(stable_lock)
112
+ update_stable_lock(public_stable_yaml, stable_lock)
113
+ end
114
+ # podfile 更新配置文件使用(业务线)
115
+ def update_business_stable_lock(stable_lock)
116
+ update_stable_lock(business_stable_yaml, stable_lock)
117
+ end
118
+ def update_stable_lock(stable_yaml, stable_lock)
119
+ stableSpec = BB::StableSpecs.new()
120
+ stableSpec.writeData(stable_yaml, stable_lock)
95
121
  end
96
122
 
97
123
  # 合并stable数据,参数,支持传入更新某几个数据
@@ -122,7 +148,48 @@ module BB
122
148
  end
123
149
  return result
124
150
  end
125
-
151
+ # 更新依赖/移除数据
152
+ def update_dependencies_and_remove_data(stable_yaml, stable_specs, dependencies_pods, remove_pods)
153
+ if dependencies_pods || remove_pods
154
+ listdata = stable_specs[YAML_CONFIG_LIST_KEY]
155
+ removedata = stable_specs[YAML_CONFIG_REMOVE_KEY]
156
+ dependenciesdata = stable_specs[YAML_CONFIG_DEPENDENCIES_KEY]
157
+ if remove_pods
158
+ remove_pods.each do |name|
159
+ name = name.to_s
160
+ if listdata[name].nil?
161
+ puts "❌ 移除未知公共组件【#{name}】,请确认名称是否正确!!! 传入参数list:#{remove_pods}".red
162
+ exit
163
+ end
164
+ if !removedata.include?(name)
165
+ removedata.push(name)
166
+ end
167
+ end
168
+ end
169
+ if dependencies_pods
170
+ dependencies_pods.each do |name, array|
171
+ if array.length > 0
172
+ array.each do |pod_name|
173
+ if listdata[pod_name].nil?
174
+ puts "❌ 依赖未知公共组件【#{name}】,请确认名称是否正确!!! 传入参数list:#{array}".red
175
+ exit
176
+ end
177
+ end
178
+ dependenciesdata[name] = array
179
+ end
180
+ end
181
+ end
182
+ stable_specs[YAML_CONFIG_REMOVE_KEY] = removedata
183
+ stable_specs[YAML_CONFIG_DEPENDENCIES_KEY] = dependenciesdata
184
+ update_stable_lock(stable_yaml, stable_specs)
185
+ end
186
+ end
187
+ def update_common_dependencies_and_remove_data(dependencies_pods, remove_pods)
188
+ update_dependencies_and_remove_data(public_stable_yaml, common_stable_datas, dependencies_pods, remove_pods)
189
+ end
190
+ def update_business_dependencies_and_remove_data(dependencies_pods, remove_pods)
191
+ update_dependencies_and_remove_data(business_stable_yaml, business_stable_datas, dependencies_pods, remove_pods)
192
+ end
126
193
  # compare specs 参数1:本地,参数2:远端,参数3:指定更新pod库
127
194
  def compare_specs(local_specs, common_specs, update_pods=[])
128
195
  added_projects = []
@@ -1,3 +1,3 @@
1
1
  module CocoapodsBbPodassistant
2
- VERSION = "0.1.9.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -111,6 +111,7 @@ module BB
111
111
  commit = pod[:commit]
112
112
  linkages = pod[:linkages]
113
113
  linkage = pod[:linkage]
114
+ remove = pod[:remove]
114
115
  if (names.is_a? Array) && !names.empty?
115
116
  data = {}
116
117
  if version
@@ -141,6 +142,10 @@ module BB
141
142
  if linkage
142
143
  data[:linkage] = linkage
143
144
  end
145
+ if remove
146
+ data[:remove] = remove
147
+ puts "###业务方配置需要移除插件####names:[#{names}] pod:#{pod}".red
148
+ end
144
149
  names.each do |pod_name|
145
150
  podfile_hash[pod_name] = data
146
151
  end
@@ -159,7 +164,7 @@ module BB
159
164
  stable_hash = local_stable_data
160
165
  podfile_hash.each do |podName,podfile_pod|
161
166
  if podfile_pod.count == 0
162
- puts "❌ podfile组件配置异常,请确认:method => REMOTE_VERSION是否配置\n组件信息如下:\n#{podName} => #{podfile_pod}".red
167
+ puts "❌ podfile组件[#{podName}]配置异常,请确认:method => REMOTE_VERSION是否配置\n组件信息如下:\n#{podName} => #{podfile_pod}".red
163
168
  exit
164
169
  end
165
170
  podCoreName = @source_manager.subspec_podname(podName)
@@ -168,10 +173,6 @@ module BB
168
173
  if pod.nil? # stbale没有受版本控制
169
174
  need_update_pod_data[podName] = podfile_pod
170
175
  else
171
- # if podCoreName == 'BBGameModule'
172
- # succ = (pod == podfile_pod) ? true : false
173
- # puts "[stable]podCoreName:#{podCoreName}(#{pod}) VS [podfile] podName:#{podName}(#{podfile_pod}) succ:#{succ}".green
174
- # end
175
176
  if pod == podfile_pod
176
177
  if podName != podCoreName
177
178
  need_update_pod_data[podName] = podfile_pod
@@ -183,6 +184,12 @@ module BB
183
184
  git = podfile_pod[:git_format]
184
185
  end
185
186
  version = podfile_pod[:version]
187
+ remove = podfile_pod[:remove]
188
+ if remove
189
+ puts "[PodAssistant] 过滤组件数据 #{podName} #{podfile_pod}".red
190
+ stable_hash.delete(podCoreName)
191
+ next
192
+ end
186
193
  if (branch && !branch.empty?) || (git && !git.empty?)
187
194
  # 项目配置指向分支数据,以本项目为主
188
195
  puts "[PodAssistant] #{podName} 指向分支数据 => #{podfile_pod}"
@@ -256,6 +263,14 @@ module BB
256
263
  # puts "need_update_pod_data:#{need_update_pod_data}".green
257
264
  # 规避指向分支/远端版本替换yml配置所有组件,避免pod指向指向多个源
258
265
  need_update_pod_data.each do |podName,pod|
266
+ if pod.is_a? Hash
267
+ remove = pod[:remove]
268
+ if remove
269
+ puts "[PodAssistant] 过滤组件数据 #{podName} #{pod} remove:#{remove}".red
270
+ stable_hash.delete(podName)
271
+ next
272
+ end
273
+ end
259
274
  stable_hash[podName] = pod
260
275
  puts "[PodAssistant] merge pod #{podName} #{pod}"
261
276
  end
@@ -2,16 +2,17 @@ require 'cocoapods-bb-PodAssistant/config/stable_source'
2
2
 
3
3
  module BB
4
4
  class StableEnv
5
- def initialize()
6
- @cache = BB::Cache.new()
5
+ def initialize(verify_stable_env=true)
6
+ @cache = BB::Cache.new(nil, verify_stable_env)
7
7
  configGitPath(@cache.cachePath)
8
- # 自动加载stable环境
9
- loadStaleEnv
10
- if verify_stable_env_exists == false
11
- puts "[PodAssistant] ❌工程没有配置stable环境".red
12
- else
13
- fetch_stale_git # 自动拉取远端git仓库数据
8
+ if verify_stable_env
9
+ # 自动加载stable环境
10
+ loadStaleEnv
11
+ if verify_stable_env_exists == false
12
+ puts "[PodAssistant] ❌工程没有配置stable环境".red
13
+ end
14
14
  end
15
+ fetch_stale_git # 自动拉取远端git仓库数据
15
16
  end
16
17
 
17
18
  # stable 环境,执行pod stable
@@ -40,27 +41,28 @@ module BB
40
41
  # 拉取stable仓库代码 hook开发环境,执行pod install/update
41
42
  def system_clone_stable_git
42
43
  cachePath = @cache.cachePath
43
- puts "hook [pod install/update] fetch stable git=>#{cachePath}"
44
+ puts "fetch stable git=>#{cachePath}"
44
45
  if !Dir.exist?(File.join(cachePath))
46
+ puts "git clone=>#{stable_source}"
45
47
  clonePath = File.dirname(cachePath)
46
48
  FileUtils.mkdir_p clonePath
47
- system "git clone #{@stable_source} #{cachePath}"
49
+ system "git clone #{stable_source} #{cachePath}"
48
50
  end
49
51
  if verify_branch_exists
50
52
  if stable_tag || stable_branch
51
53
  if stable_branch
52
- system "cd #{cachePath}; git checkout #{stable_branch}; git reset --hard origin/#{stable_branch}; git pull --all"
54
+ system "cd #{cachePath}; git pull --all; git checkout #{stable_branch}; git reset --hard origin/#{stable_branch}"
53
55
  end
54
56
  if stable_tag
55
- system "cd #{cachePath}; git checkout #{stable_tag};"
57
+ system "cd #{cachePath}; git pull --all; git checkout #{stable_tag};"
56
58
  end
57
59
  else
58
60
  result =`git symbolic-ref refs/remotes/origin/HEAD`
59
61
  protechBranch = result.split("/").last.strip || default_branch
60
- system "cd #{cachePath}; git checkout #{protechBranch}; git reset --hard origin/#{protechBranch}; git pull --all"
62
+ system "cd #{cachePath}; git pull --all; git checkout #{protechBranch}; git reset --hard origin/#{protechBranch}"
61
63
  end
62
64
  else
63
- puts "❌ stable配置无效分支信息source:#{@stable_source} branch:#{stable_branch}".red
65
+ puts "❌ stable配置无效分支信息source:#{stable_source} branch:#{stable_branch}".red
64
66
  exit
65
67
  end
66
68
  end
@@ -81,6 +83,9 @@ module BB
81
83
  end
82
84
 
83
85
  def stable_source
86
+ if @stable_source.nil?
87
+ @stable_source = StableSource.stable_default_source
88
+ end
84
89
  return @stable_source
85
90
  end
86
91
  def default_branch
@@ -129,5 +134,8 @@ module BB
129
134
  end
130
135
  return false
131
136
  end
137
+ def cache_path
138
+ return @cache.cachePath
139
+ end
132
140
  end
133
141
  end
@@ -4,8 +4,9 @@ require 'cocoapods-bb-PodAssistant/helpers/stable_env_helper'
4
4
 
5
5
  module BB
6
6
  class StableManager
7
- def initialize(env = nil)
7
+ def initialize(env = nil, verify_stable_env=true)
8
8
  @env = env
9
+ @verify_stable_env = verify_stable_env
9
10
  end
10
11
 
11
12
  # podfile 更新配置文件使用(通用)
@@ -32,7 +33,7 @@ module BB
32
33
  # 仓库缓存目录
33
34
  def cachePath
34
35
  if @cache.nil?
35
- @cache = BB::Cache.new()
36
+ @cache = BB::Cache.new(nil, @verify_stable_env)
36
37
  end
37
38
  return @cache.cachePath
38
39
  end
@@ -61,7 +62,8 @@ module BB
61
62
  stableSpec.update_stable_lock(yml_path, pod_targets)
62
63
  # step.2 提交修改后代码
63
64
  yml_name = File.basename(yml_path)
64
- `cd #{cachePath}; git pull --all; git add #{yml_name}; git commit -m "[update] 更新stable配置文件#{yml_name}"; git push; git pull --all;`
65
+ # `cd #{cachePath}; git pull --all; git add #{yml_name}; git commit -m "[update] 更新stable配置文件#{yml_name}"; git push; git pull --all;`
66
+ `cd #{cachePath}; git pull --all; git add * ; git commit -m "[update] 更新stable配置文件#{yml_name}"; git push; git pull --all;`
65
67
  end
66
68
  private def update_local_stable_lock(yml_path, pod_targets)
67
69
  # step.1 更新yaml配置文件
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.9.1
4
+ version: 0.2.0
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-17 00:00:00.000000000 Z
11
+ date: 2023-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods-core
@@ -88,6 +88,7 @@ files:
88
88
  - lib/cocoapods-bb-PodAssistant/command/stable.rb
89
89
  - lib/cocoapods-bb-PodAssistant/command/stable/init.rb
90
90
  - lib/cocoapods-bb-PodAssistant/command/stable/install.rb
91
+ - lib/cocoapods-bb-PodAssistant/command/stable/push.rb
91
92
  - lib/cocoapods-bb-PodAssistant/command/stable/sync.rb
92
93
  - lib/cocoapods-bb-PodAssistant/command/stable/update.rb
93
94
  - lib/cocoapods-bb-PodAssistant/config/cache_path.rb