require 'cocoapods-bb-PodAssistant/config/stable_specs' require 'cocoapods-bb-PodAssistant/helpers' require 'cocoapods-bb-PodAssistant/helpers/stable_env_helper' module BB class StableManager def initialize(env = nil) @env = env end # podfile 更新配置文件使用(通用) def update_common_stable_lock(pod_targets) update_stable_lock(public_stable_yaml, pod_targets) end # podfile 更新配置文件使用(业务线) def update_business_stable_lock(pod_targets) if @env.nil? @env = BB::StableEnv.new() end businessSpecName = @env.business_stable if !businessSpecName.nil? update_stable_lock(business_stable_yaml(businessSpecName), pod_targets) else puts "没有配置业务线公共源,请确认!!!".yellow end end # podfile 更新配置文件使用(项目) def update_product_stable_lock(pod_targets) update_local_stable_lock(local_stable_yaml, pod_targets) end # 仓库缓存目录 def cachePath if @cache.nil? @cache = BB::Cache.new() end return @cache.cachePath end # 公共源路径(远端) def public_stable_yaml return File.join(cachePath, "stable_specs.yml") #名称固定 end # 业务源路径(远端) def business_stable_yaml(businessSpecName) if businessSpecName return File.join(cachePath, "#{businessSpecName}.yml") #名称由各自业务线约定 end return nil end # 本地源路径 def local_stable_yaml return File.join(Pathname.pwd, "stable_specs_lock.yml") #名称固定 end private def update_stable_lock(yml_path, pod_targets) # step.1 更新yaml配置文件 stableSpec = BB::StableSpecs.new() stableSpec.update_stable_lock(yml_path, pod_targets) # step.2 提交修改后代码 yml_name = File.basename(yml_path) `cd #{cachePath}; git pull --all; git add #{yml_name}; git commit -m "[update] 更新stable配置文件#{yml_name}"; git push; git pull --all;` end private def update_local_stable_lock(yml_path, pod_targets) # step.1 更新yaml配置文件 stableSpec = BB::StableSpecs.new() stableSpec.update_local_stable_lock(yml_path, pod_targets) end # 更新通用lock def self.updateCommonStableLock(pod_targets) stableMgr = StableManager.new() stableMgr.update_common_stable_lock(pod_targets) end # podfile 更新配置文件使用(业务线) def self.updateBusinessStableLock(pod_targets) stableMgr = StableManager.new() stableMgr.update_business_stable_lock(pod_targets) end # 更新产品lock def self.updateProductStableLock(pod_targets) stableMgr = StableManager.new() stableMgr.update_product_stable_lock(pod_targets) end # pod助手ruby文件路径 def self.pod_assistant_path() stableMgr = StableManager.new() return File.join(stableMgr.cachePath, "PodAssistant/PodAssistant.rb") #名称固定 end # pod助手机器人ruby文件路径 def self.pod_assistant_robot_path() stableMgr = StableManager.new() return File.join(stableMgr.cachePath, "PodAssistant/robot.rb") #名称固定 end end end