Module: PodsOrz

Defined in:
lib/podsorz.rb,
lib/podsorz/version.rb,
lib/podsorz/command/sort.rb,
lib/podsorz/command/sync.rb,
lib/podsorz/command/check.rb,
lib/podsorz/command/setup.rb,
lib/podsorz/command/binary.rb,
lib/podsorz/command/commit.rb,
lib/podsorz/command/switch.rb,
lib/podsorz/command/install.rb,
lib/podsorz/command/publish.rb,
lib/podsorz/util/git_operator.rb,
lib/podsorz/util/process_operator.rb,
lib/podsorz/core/PodsOrz/pods_repo.rb,
lib/podsorz/core/PodsOrz/pods_sort.rb,
lib/podsorz/core/Binary/binary_repo.rb,
lib/podsorz/core/PodFile/podfile_io.rb,
lib/podsorz/core/Specs/podspec_model.rb,
lib/podsorz/core/Binary/binary_server.rb,
lib/podsorz/core/PodsOrz/pods_version.rb,
lib/podsorz/core/Binary/binary_builder.rb,
lib/podsorz/core/Binary/binary_manager.rb,
lib/podsorz/core/PodFile/podfile_model.rb,
lib/podsorz/core/PodsOrz/pods_detector.rb,
lib/podsorz/core/Config/orz_env_detector.rb,
lib/podsorz/core/PodsOrz/pods_check_merge.rb,
lib/podsorz/core/PodsOrz/pods_git_manager.rb,
lib/podsorz/core/PodsOrz/pods_git_operator.rb,
lib/podsorz/core/Config/pod_orzconfig_parse.rb

Defined Under Namespace

Classes: BinaryBuilder, BinaryManager, BinaryRepo, BinaryServer, GitOperator, OrzEnvDetector, PodOrzconfigParse, PodfileIO, PodfileModel, PodsCheckMerge, PodsDetector, PodsGitManager, PodsGitOperator, PodsRepo, PodsSort, PodsVersion, PodspecModel, ProcessOperator

Constant Summary collapse

VERSION =
"0.0.15"

Class Method Summary collapse

Class Method Details

.binary_commandObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 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_commandObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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_commandObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# 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) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# 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_commandObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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) ⇒ Object



61
62
63
64
# 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_commandObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 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_commandObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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_commandObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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_commandObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 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_commandObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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