module PodsOrz
Constants
- VERSION
Public Class Methods
binary_command()
click to toggle source
# File lib/podsorz/command/binary.rb, line 7 def self.binary_command desc "Binary command, static library related command" command :binary do |binary| binary.desc "package pods(which in PodsOrzConfig) into static libraries" binary.command :package do |package| package.action do |global_options,options,args| dir_path = global_options[:path] prepare_work(dir_path) git_manager = PodsOrz::PodsGitManager.new(dir_path) result_hash = filter_binary_pods_list(dir_path,git_manager, :package) package_list = result_hash[:package] binary_manager = PodsOrz::BinaryManager.new(dir_path) binary_manager.package(package_list) end end binary.desc "show whether remote exist static libraries on current version" binary.command :show do |show| show.action do |global_options,options,args| dir_path = global_options[:path] prepare_work(dir_path) git_manager = PodsOrz::PodsGitManager.new(dir_path) filter_binary_pods_list(dir_path,git_manager, :show) end end binary.desc "publish binary repo" binary.command :publish do |publish| publish.action do |global_options,options,args| dir_path = global_options[:path] prepare_work(dir_path) git_manager = PodsOrz::PodsGitManager.new(dir_path) result_hash = filter_binary_pods_list(dir_path,git_manager, :package) package_list = result_hash[:package] binary_manager = PodsOrz::BinaryManager.new(dir_path) binary_manager.publish(package_list) end end binary.default_command :show end end
check_command()
click to toggle source
# File lib/podsorz/command/check.rb, line 8 def self.check_command desc "Check Pods not merge" command :check do |check| check.action do |global_options, options, args| dir_path = global_options[:path] is_directory = File.directory?(dir_path) unless is_directory Logger.error("Check failure, it is not a directory path: #{dir_path}") exit() end @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(dir_path) kx_pods_path = File.expand_path("../#{@orzconfig_parse.file_devpods_name}", dir_path) # puts "kx_pods_path #{kx_pods_path}" checkManger = PodsOrz::PodsCheckMerge.new() checkManger.branchList(kx_pods_path) end end end
commit_command()
click to toggle source
# File lib/podsorz/command/commit.rb, line 5 def self.commit_command desc "Execute git commit command" command :commit do |commit| commit.switch :push, :negatable => false, :desc => "Push Local branch & commits into remote" commit.switch :notify, :negatable => false, :desc => "1.Merge personal branch & commit into parent(base on) branch 2.Update Podfile_orz.rb" commit.example "podsorz commit", desc:"Just local branch commit" commit.example "podsorz commit --push", desc:"Push Local branch & commits into remote" commit.example "podsorz commit --push --notify", desc:"1.Push Local branch & commits into remote 2.Update Podfile_orz.rb 3.If personal branch, merge into parent branch" commit.example "podsorz commit --notify ❌", desc:"Not support,illegality command" commit.action do |global_options, options, args| is_push = options[:push] is_notify = options[:notify] if is_push == false && is_notify == true help_now!("illegality 'notify' options") end dir_path = global_options[:path] detector = PodsOrz::PodsDetector.new(dir_path) detector.start_detector() git_manager = PodsOrz::PodsGitManager.new(dir_path) is_same = git_manager.ensure_pods_branch() exit() unless is_same git_manager.pod_commit(is_push, is_notify) end end end
filter_binary_pods_list(dir_path,git_manager, cmd_type)
click to toggle source
# File lib/podsorz/command/binary.rb, line 67 def self.filter_binary_pods_list(dir_path,git_manager, cmd_type) result_hash = { :binary => [], :package => [] } #1.获取静态库加载配置表 is_all_binary = git_manager.orzconfig_parse.is_all_binary origin_binary_list = [] unless cmd_type == :show if is_all_binary totoal_model_list = git_manager.podfile_io.filter_binary_pod_models() totoal_model_list.each do |model| origin_binary_list << model.name.to_s end else origin_binary_list = git_manager.orzconfig_parse.static_lib_list if cmd_type == :binary origin_binary_list = git_manager.orzconfig_parse.will_package_list if cmd_type == :package end else totoal_model_list = git_manager.podfile_io.total_pod_models totoal_model_list.each do |model| origin_binary_list << model.name.to_s end end return result_hash if origin_binary_list.empty? empty_binary_list = [] exist_binary_list = [] has_binary_list = [] can_package_list = [] #2.查询Podfile_orz是否为已发版本状态 binary_repo = PodsOrz::BinaryRepo.new(dir_path) binary_repo.check_binary_repo_exist() origin_binary_list.each do |pod| pod_version = git_manager.podfile_io.get_podfile_pod_version(pod) if pod_version.empty? branch = git_manager.podfile_io.get_podfile_pod_branch(pod) unless branch.empty? empty_binary_list << "#{pod} no source-code version, :branch => #{branch}" else empty_binary_list << "#{pod} no source-code version, :branch => 'master'" end next end has_remote = binary_repo.check_binary_pod_exist(pod, pod_version) unless has_remote empty_binary_list << "#{pod} no binary version:(#{pod_version})" else exist_binary_list << "#{pod}:(#{pod_version})" has_binary_list << pod end if !pod_version.empty? && !has_remote can_package_list << pod end end Logger.highlight("[cmd:#{cmd_type}] Exist static library pods :") exist_binary_list.each do |item| puts item.colorize(:green) end Logger.separator Logger.warning("[cmd:#{cmd_type}] Not exist static library pods:") empty_binary_list.each do |item| puts item.colorize(:yellow) end result_hash[:binary] = has_binary_list result_hash[:package] = can_package_list result_hash end
install_command()
click to toggle source
# File lib/podsorz/command/install.rb, line 6 def self.install_command desc "Pod Install command, do the same with 'pod install'.Repo will update to latest, pod in 'FIX_POD_LIST' NOT update to latest!" command :install do |install| install.example "podsorz install", :desc => "Install pods, 'FIX_POD_LIST' are 'NOT' updated to latest, they are using your local 'git' code" install.action do |global_options, options, args| dir_path = global_options[:path] detector = PodsOrz::PodsDetector.new(dir_path) detector.start_detector() git_manager = PodsOrz::PodsGitManager.new(dir_path) is_same = git_manager.ensure_pods_branch() exit() unless is_same #获取binary 列表 list_hash = PodsOrz.filter_binary_pods_list(dir_path,git_manager, :binary) git_manager.install_pod(dir_path, list_hash[:binary]) end end end
prepare_work(dir_path)
click to toggle source
# File lib/podsorz/command/binary.rb, line 61 def self.prepare_work(dir_path) pods_repo = PodsOrz::PodsRepo.new(dir_path) pods_repo.check_repo_exist() end
publish_command()
click to toggle source
# File lib/podsorz/command/publish.rb, line 6 def self.publish_command() desc "Publish pods release version.Make sure everything works pass through Tester, work branch MUST be 'release'" long_desc %{ what will 'podsorz publish' cmd do:\n 1.判断 release 是否存在新的 commit 内容 \n 2.若存在新的 commit,podspec 文件修改内容 versoin +1\n 3.将 release 分支代码 Merge into master / develop \n 4.为release branch 最新代码打上 New Tag\n 5.Repo 添加kuxiu_specs 并且 更新到最新 \n 6.比较 local version, git tag, remote version 三者关系\n 7.发布新的组件版本\n 8.更改远端 Podfile_orz.rb, 同步对应 pod 到最新的 version\n } command :publish do |publish| publish.switch :swift, :negatable => false, :desc => "Publish Swift Pod" publish.example "podsorz publish --swift", desc:"Single Publish Action,Publish Only One ’Swift‘ Pod" publish.action do |global_options, options, args| dir_path = global_options[:path] detector = PodsOrz::PodsDetector.new(dir_path) detector.start_detector() git_manager = PodsOrz::PodsGitManager.new(dir_path) is_same = git_manager.ensure_pods_branch() exit() unless is_same branch_name = git_manager.fetch_pods_branch_name() unless branch_name.include? "release" Logger.error("Publish command need 'release' branch, current branch:'#{branch_name}', you should 'podsorz switch release' first") exit() end is_swift = options[:swift] git_manager.start_repo_publish(is_swift) end end end
setup_command()
click to toggle source
# File lib/podsorz/command/setup.rb, line 5 def self.setup_command desc "Setup PodsOrz environment, init PodFile, PodsOrzConfig.rb, check Podfile_orz.rb exist" command :setup do |setup| setup.action do |global_options, options, args| dir_path = global_options[:path] is_directory = File.directory?(dir_path) unless is_directory Logger.error("Setup failure, it is not a directory path: #{dir_path}") exit() end detector = PodsOrz::OrzEnvDetector.new() detector.detect_podfile(dir_path) detector.detect_PodsOrzConfig(dir_path) podfile_orz_result = detector.detect_podfile_orz(dir_path) end end end
sort_command()
click to toggle source
# File lib/podsorz/command/sort.rb, line 5 def self.sort_command desc "Prioritize the pods to be released and check for loops. Output the number of dependency" command :sort do |sort| sort.action do |global_options, options, args| dir_path = global_options[:path] is_directory = File.directory?(dir_path) unless is_directory Logger.error("Check failure, it is not a directory path: #{dir_path}") exit() end @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(dir_path) kx_pods_path = File.expand_path("../#{@orzconfig_parse.file_devpods_name}", dir_path) pods_list = @orzconfig_parse.fix_pod_list if pods_list.empty? Logger.warning("fix_pods is empty nothing to do") else pods_sort = PodsOrz::PodsSort.new() pods_list = pods_sort.sort(pods_list,kx_pods_path) end end end end
switch_command()
click to toggle source
# File lib/podsorz/command/switch.rb, line 5 def self.switch_command desc "Switch branch which is in fix_pods_list.Argument match 'develop', 'feature', 'release', 'bugfix'" arg_name '\'branch_name\'' command :switch do |switch| switch.example "podsorz switch develop", desc:"siwtch into 'develop' branch." switch.action do |global_options, options, args| help_now!('branch_name is required') if args.empty? input_branch = args.shift.to_s.strip.chomp available = ["develop", "feature", "release", "bugfix"] result = "" available.each do |branch| cmp_result = branch.casecmp(input_branch) if cmp_result == 0 result = branch break end end help_now!("branch is unknow,current support:'develop', 'feature', 'release', 'bugfix'") if result.empty? dir_path = global_options[:path] detector = PodsOrz::PodsDetector.new(dir_path) detector.start_detector() git_manager = PodsOrz::PodsGitManager.new(dir_path) case result when "develop" git_manager.switch_develop_state() when "feature" git_manager.switch_feature_state() when "release" git_manager.switch_release_state() when "bugfix" git_manager.switch_bugfix_state() end end end end
sync_command()
click to toggle source
# File lib/podsorz/command/sync.rb, line 5 def self.sync_command desc "Sync current_branch latest code from origin/current_branch or --rebase=‘other_branch’ " command :sync do |sync| sync.flag [:r, :rebase], :desc => "set rebase command on 'other_branch' " sync.example "podsorz sync", desc:"current_branch 'git pull --rebase' " sync.example "podsorz sync -r release", desc:"1.current_branch 'git pull --rebase', 2.sync commit from release" sync.example "podsorz sync --rebase=feature/xq_2.0.0", desc:"1.current_branch 'git pull --rebase', 2.sync commit from feature/xq_2.0.0" sync.action do |global_options, options, args| other_branch = options[:rebase] other_branch = other_branch.to_s.strip.chomp dir_path = global_options[:path] detector = PodsOrz::PodsDetector.new(dir_path) detector.start_detector() git_manager = PodsOrz::PodsGitManager.new(dir_path) is_same = git_manager.ensure_pods_branch() exit() unless is_same git_manager.cmd_sync_pod(other_branch) end end end