podsorz 0.0.2 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -13
- data/lib/podsorz.rb +12 -2
- data/lib/podsorz/command/binary.rb +150 -0
- data/lib/podsorz/command/commit.rb +2 -2
- data/lib/podsorz/command/install.rb +9 -3
- data/lib/podsorz/command/publish.rb +7 -3
- data/lib/podsorz/command/setup.rb +1 -1
- data/lib/podsorz/command/switch.rb +2 -2
- data/lib/podsorz/command/sync.rb +2 -2
- data/lib/podsorz/core/Binary/binary_builder.rb +312 -0
- data/lib/podsorz/core/Binary/binary_manager.rb +173 -0
- data/lib/podsorz/core/Binary/binary_repo.rb +178 -0
- data/lib/podsorz/core/Binary/binary_server.rb +21 -0
- data/lib/podsorz/core/Config/orz_config_templet.rb +31 -0
- data/lib/podsorz/core/{orz_env_detector.rb → Config/orz_env_detector.rb} +1 -1
- data/lib/podsorz/core/{pod_orzconfig_parse.rb → Config/pod_orzconfig_parse.rb} +15 -1
- data/lib/podsorz/core/{podfile_io.rb → PodFile/podfile_io.rb} +143 -4
- data/lib/podsorz/core/{podfile_model.rb → PodFile/podfile_model.rb} +26 -1
- data/lib/podsorz/core/{pods_detector.rb → PodsOrz/pods_detector.rb} +1 -1
- data/lib/podsorz/core/{pods_git_manager.rb → PodsOrz/pods_git_manager.rb} +22 -12
- data/lib/podsorz/core/{pods_git_operator.rb → PodsOrz/pods_git_operator.rb} +134 -37
- data/lib/podsorz/core/{pods_repo.rb → PodsOrz/pods_repo.rb} +44 -11
- data/lib/podsorz/core/{pods_version.rb → PodsOrz/pods_version.rb} +4 -1
- data/lib/podsorz/core/Specs/podspec_model.rb +45 -0
- data/lib/podsorz/util/git_operator.rb +47 -0
- data/lib/podsorz/version.rb +1 -1
- data/podsorz.gemspec +11 -1
- metadata +35 -15
- data/Note +0 -3
- data/lib/podsorz/core/orz_config_templet.rb +0 -13
@@ -0,0 +1,173 @@
|
|
1
|
+
require "podsorz/core/Config/pod_orzconfig_parse"
|
2
|
+
require "podsorz/core/Binary/binary_repo"
|
3
|
+
require "podsorz/core/Binary/binary_builder"
|
4
|
+
|
5
|
+
module PodsOrz
|
6
|
+
class BinaryManager
|
7
|
+
attr_accessor :main_path, :orzconfig_parse, :podfile_io, :binary_repo, :binary_builder
|
8
|
+
|
9
|
+
def initialize(main_path)
|
10
|
+
@main_path = main_path
|
11
|
+
@orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path)
|
12
|
+
@podfile_io = PodsOrz::PodfileIO.new(main_path)
|
13
|
+
|
14
|
+
@binary_repo = PodsOrz::BinaryRepo.new()
|
15
|
+
@binary_repo.check_binary_repo_exist()
|
16
|
+
|
17
|
+
@binary_builder = PodsOrz::BinaryBuilder.new(main_path, @podfile_io)
|
18
|
+
end
|
19
|
+
|
20
|
+
#Package Command
|
21
|
+
def package(package_list)
|
22
|
+
|
23
|
+
#1.检测打包Pod是否项目中正在使用
|
24
|
+
has_fault = check_podfile_exist_pods_list(package_list)
|
25
|
+
exit() if has_fault
|
26
|
+
|
27
|
+
#2 若源码Repo 未发布,则不进行二进制制作
|
28
|
+
has_pod_repo = package_check_remote_exist_pod_repo(package_list)
|
29
|
+
exit() unless has_pod_repo
|
30
|
+
|
31
|
+
#3.检测打包Pod是否已经存在当前版本version的二进制静态库
|
32
|
+
has_remote_binary = package_check_remote_exist_binary(package_list)
|
33
|
+
exit() if has_remote_binary
|
34
|
+
|
35
|
+
#4.开始进行源码打包工作
|
36
|
+
start_build(package_list)
|
37
|
+
end
|
38
|
+
|
39
|
+
def check_podfile_exist_pods_list(pods_list)
|
40
|
+
has_fault = false
|
41
|
+
|
42
|
+
if pods_list.empty?
|
43
|
+
Logger.error("check pods_list is empty")
|
44
|
+
has_fault = true
|
45
|
+
return has_fault
|
46
|
+
end
|
47
|
+
|
48
|
+
fault_pods_list = []
|
49
|
+
|
50
|
+
pods_list.each do |pod|
|
51
|
+
total_pod_models = @podfile_io.total_pod_models
|
52
|
+
|
53
|
+
find_result = false
|
54
|
+
total_pod_models.each do |model|
|
55
|
+
if model.name.include? pod
|
56
|
+
find_result = true
|
57
|
+
break
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
fault_pods_list << pod unless find_result
|
62
|
+
end
|
63
|
+
|
64
|
+
unless fault_pods_list.empty?
|
65
|
+
Logger.error("project do not exist pod: \n")
|
66
|
+
fault_pods_list.each do |pod|
|
67
|
+
puts("#{pod} \n")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
has_fault
|
72
|
+
end
|
73
|
+
|
74
|
+
def package_check_remote_exist_pod_repo(pods_list)
|
75
|
+
result = true
|
76
|
+
|
77
|
+
pods_list.each do |pod|
|
78
|
+
pod_version = @podfile_io.get_podfile_pod_version(pod)
|
79
|
+
|
80
|
+
if pod_version.empty?
|
81
|
+
Logger.error("#{pod} donot have 'source code' publish version, package action has been stop")
|
82
|
+
result = false
|
83
|
+
break
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
result
|
88
|
+
end
|
89
|
+
|
90
|
+
def package_check_remote_exist_binary(pods_list)
|
91
|
+
result = false
|
92
|
+
|
93
|
+
pods_list.each do |pod|
|
94
|
+
pod_version = @podfile_io.get_podfile_pod_version(pod)
|
95
|
+
|
96
|
+
unless pod_version.nil?
|
97
|
+
has_remote = @binary_repo.check_binary_pod_exist(pod, pod_version)
|
98
|
+
|
99
|
+
if has_remote
|
100
|
+
Logger.error("#{pod}:#{pod_version} exist remote binary static library, package action has been stop")
|
101
|
+
result = true
|
102
|
+
break
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
result
|
108
|
+
end
|
109
|
+
|
110
|
+
def start_build(pods_list)
|
111
|
+
is_build_success = true
|
112
|
+
|
113
|
+
pods_list.each {|pod|
|
114
|
+
Logger.separator
|
115
|
+
Logger.default("【#{pod}】 start build binary...")
|
116
|
+
Logger.separator
|
117
|
+
|
118
|
+
command = Thread.new do
|
119
|
+
each_result = @binary_builder.start_package_pod(pod)
|
120
|
+
unless each_result
|
121
|
+
is_build_success = false
|
122
|
+
Logger.error("【#{pod}】package failure!")
|
123
|
+
else
|
124
|
+
Logger.highlight("【#{pod}】package success")
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
command.join
|
129
|
+
}
|
130
|
+
|
131
|
+
exit() unless is_build_success
|
132
|
+
|
133
|
+
is_build_success
|
134
|
+
end
|
135
|
+
|
136
|
+
#Publish Command
|
137
|
+
def publish(pods_list)
|
138
|
+
is_publish_success = true
|
139
|
+
|
140
|
+
if pods_list.empty?
|
141
|
+
Logger.error("publish pods_list is empty")
|
142
|
+
is_publish_success = false
|
143
|
+
exit() unless is_publish_success
|
144
|
+
end
|
145
|
+
|
146
|
+
pods_list.each {|pod|
|
147
|
+
command = Thread.new do
|
148
|
+
pod_version = @podfile_io.get_podfile_pod_version(pod)
|
149
|
+
|
150
|
+
dest_dir = @binary_builder.detect_version_directory(pod, pod_version)
|
151
|
+
|
152
|
+
each_result = @binary_repo.push_binary_remote(pod, dest_dir, pod_version, false)
|
153
|
+
is_publish_success = false unless each_result
|
154
|
+
end
|
155
|
+
|
156
|
+
command.join
|
157
|
+
}
|
158
|
+
|
159
|
+
exit() unless is_publish_success
|
160
|
+
|
161
|
+
is_publish_success
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
#Show Command
|
167
|
+
def show()
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require "podsorz/util/logger"
|
2
|
+
require 'open3'
|
3
|
+
|
4
|
+
module PodsOrz
|
5
|
+
class BinaryRepo
|
6
|
+
attr_accessor :repo_name, :repo_url
|
7
|
+
|
8
|
+
def initialize()
|
9
|
+
@repo_name = "kuxiu_binary_specs"
|
10
|
+
@repo_url = "git@gitlab.91banban.com:ios_pods/binary-specs.git"
|
11
|
+
@source_code_repo_url = "git@gitlab.91banban.com:ios_pods/Specs.git"
|
12
|
+
end
|
13
|
+
|
14
|
+
def check_binary_repo_exist()
|
15
|
+
command = Thread.new do
|
16
|
+
has_repo = false
|
17
|
+
Open3.popen3("pod repo list") do |stdin , stdout , stderr, wait_thr|
|
18
|
+
while line = stdout.gets
|
19
|
+
has_repo = true if line.include? @repo_name
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
unless has_repo
|
24
|
+
Open3.popen3("pod repo add #{@repo_name} #{@repo_url}") do |stdin , stdout , stderr, wait_thr|
|
25
|
+
while line = stdout.gets
|
26
|
+
puts line
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Open3.popen3("pod repo update #{@repo_name}") do |stdin , stdout , stderr, wait_thr|
|
32
|
+
while line = stdout.gets
|
33
|
+
puts line
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Logger.default("#{@repo_name} is update to latest.")
|
38
|
+
end
|
39
|
+
|
40
|
+
command.join
|
41
|
+
end
|
42
|
+
|
43
|
+
def check_binary_pod_exist(pod, pod_version)
|
44
|
+
result = false
|
45
|
+
|
46
|
+
remote_version_list = fetch_remote_binary_pod_version(pod)
|
47
|
+
|
48
|
+
remote_version_list.each do |version|
|
49
|
+
if version.include? pod_version
|
50
|
+
result = true
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
result
|
56
|
+
end
|
57
|
+
|
58
|
+
def fetch_remote_binary_pod_version(pod)
|
59
|
+
version_list = []
|
60
|
+
|
61
|
+
dir_kuxiu_specs = "#{Dir.home}/.cocoapods/repos/#{@repo_name}"
|
62
|
+
dir_pod_path = File.expand_path("#{pod}", dir_kuxiu_specs)
|
63
|
+
is_dir_exit = File.directory?(dir_pod_path)
|
64
|
+
|
65
|
+
unless is_dir_exit
|
66
|
+
version_list << "0.0.0"
|
67
|
+
return version_list
|
68
|
+
end
|
69
|
+
|
70
|
+
filter_list = []
|
71
|
+
files_list = Dir.entries(dir_pod_path)
|
72
|
+
files_list.each { |e|
|
73
|
+
if /^\d{1,3}\.\d{1,3}/ =~ e.to_s
|
74
|
+
filter_list << e
|
75
|
+
end
|
76
|
+
}
|
77
|
+
|
78
|
+
if filter_list.empty?
|
79
|
+
version_list << "0.0.0"
|
80
|
+
return version_list
|
81
|
+
end
|
82
|
+
|
83
|
+
return filter_list
|
84
|
+
end
|
85
|
+
|
86
|
+
def compare_version(pod_version, git_tag)
|
87
|
+
#0 => same , -1 => less , 1 => more
|
88
|
+
result = 0
|
89
|
+
|
90
|
+
pod_version = pod_version.strip.chomp
|
91
|
+
git_tag = git_tag.strip.chomp
|
92
|
+
|
93
|
+
version_parts = pod_version.split('.')
|
94
|
+
tag_parts = git_tag.split('.')
|
95
|
+
|
96
|
+
loop_count = 0
|
97
|
+
if version_parts.size >= tag_parts.size
|
98
|
+
loop_count = version_parts.size - tag_parts.size
|
99
|
+
while loop_count > 0 do
|
100
|
+
tag_parts << "0"
|
101
|
+
loop_count = loop_count - 1
|
102
|
+
end
|
103
|
+
else
|
104
|
+
loop_count = tag_parts.size - version_parts.size
|
105
|
+
while loop_count > 0 do
|
106
|
+
version_parts << "0"
|
107
|
+
loop_count = loop_count - 1
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
loop_count = tag_parts.size
|
112
|
+
while loop_count > 0 do
|
113
|
+
v = version_parts.shift
|
114
|
+
t = tag_parts.shift
|
115
|
+
|
116
|
+
if v.to_i > t.to_i
|
117
|
+
result = 1
|
118
|
+
return result
|
119
|
+
elsif v.to_i < t.to_i
|
120
|
+
result = -1
|
121
|
+
return result
|
122
|
+
else
|
123
|
+
loop_count = loop_count -1
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
return result
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
def push_binary_remote(pod, file_path, pod_version, is_swift)
|
133
|
+
is_push_success = false
|
134
|
+
|
135
|
+
command = Thread.new do
|
136
|
+
repo_push_cmd = []
|
137
|
+
repo_push_cmd << "cd #{file_path}"
|
138
|
+
if is_swift
|
139
|
+
repo_push_cmd << "pod repo push #{@repo_name} #{pod}.podspec --sources=#{@source_code_repo_url} --allow-warnings --use-libraries --skip-import-validation --use-modular-headers --swift-version=5.0 --skip-tests"
|
140
|
+
else
|
141
|
+
repo_push_cmd << "pod repo push #{@repo_name} #{pod}.podspec --sources=#{@source_code_repo_url} --allow-warnings --use-libraries --skip-import-validation --skip-tests"
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
error_info = []
|
146
|
+
|
147
|
+
Logger.separator()
|
148
|
+
Logger.default("【#{pod}】:#{pod_version} start push binary repo remote...")
|
149
|
+
Logger.separator()
|
150
|
+
|
151
|
+
IO.popen(repo_push_cmd.join(";")) do |io|
|
152
|
+
io.each do |line|
|
153
|
+
error_info.push(line)
|
154
|
+
is_push_success = true if line.include? "Pushing the `#{@repo_name}' repo"
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
unless is_push_success
|
159
|
+
puts error_info
|
160
|
+
Logger.error("Fail: \'#{pod}\':#{pod_version} push binary repo remote fail")
|
161
|
+
else
|
162
|
+
Logger.highlight(%Q(#{pod}:#{pod_version} push repo success))
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
command.join
|
167
|
+
|
168
|
+
is_push_success
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
#Class End
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "podsorz/util/logger"
|
2
|
+
|
3
|
+
|
4
|
+
module PodsOrz
|
5
|
+
class BinaryServer
|
6
|
+
attr_accessor :remote_host
|
7
|
+
|
8
|
+
def initialize()
|
9
|
+
@remote_host = "http://192.168.6.23:8080"
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def has_remote_source(pod, version)
|
14
|
+
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module GitConfig
|
2
|
+
#App 当前版本
|
3
|
+
APP_RELEASE_VERSION = "2.0.12"
|
4
|
+
|
5
|
+
#作者姓名xiangqi简写
|
6
|
+
BRANCH_AUTHOR_SUFFIX = "xq"
|
7
|
+
end
|
8
|
+
|
9
|
+
#想要开发修改的的Pod
|
10
|
+
$FIX_POD_LIST = [
|
11
|
+
# "KXModuleOrz",
|
12
|
+
# "KXModuleQuestionRepo",
|
13
|
+
]
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
#------Binary Static library------#
|
18
|
+
#是否全部Pod以二进制静态库加载,false代表以源码显示【打包机】请用源码
|
19
|
+
$is_all_binary = false
|
20
|
+
#当is_all_binary = false 所有pod即将显示源码时,仍然希望部分Pod二进制静态库加载
|
21
|
+
$static_lib_list = [
|
22
|
+
# "AFNetworking",
|
23
|
+
]
|
24
|
+
|
25
|
+
#------Package Action------#
|
26
|
+
#当is_all_binary = false 并不是针对所有pod 打binary包,仍然希望部分pod打包成二进制静态库的Pod
|
27
|
+
$will_package_list = [
|
28
|
+
# "AFNetworking",
|
29
|
+
]
|
30
|
+
|
31
|
+
#
|
@@ -41,7 +41,7 @@ module PodsOrz
|
|
41
41
|
file_name = File.basename(file_path)
|
42
42
|
directory = File.dirname(file_path)
|
43
43
|
IO.popen("cd #{directory};touch #{file_name}") { |io|
|
44
|
-
templet_config_path = File.expand_path("
|
44
|
+
templet_config_path = File.expand_path("./orz_config_templet.rb", File.dirname(__FILE__))
|
45
45
|
File.open(templet_config_path, "r") { |templet_file|
|
46
46
|
File.open(file_path, "w+") { |file|
|
47
47
|
templet_file.readlines.each {|line|
|
@@ -3,7 +3,7 @@ require "podsorz/util/logger"
|
|
3
3
|
|
4
4
|
module PodsOrz
|
5
5
|
class PodOrzconfigParse
|
6
|
-
attr_accessor :app_release_version, :branch_author_suffix, :fix_pod_list
|
6
|
+
attr_accessor :app_release_version, :branch_author_suffix, :fix_pod_list, :is_all_binary, :static_lib_list, :will_package_list
|
7
7
|
|
8
8
|
def initialize(main_path)
|
9
9
|
orzconfig_path = File.expand_path("PodsOrzConfig.rb", main_path)
|
@@ -17,8 +17,22 @@ module PodsOrz
|
|
17
17
|
require orzconfig_path
|
18
18
|
|
19
19
|
@app_release_version = GitConfig::APP_RELEASE_VERSION
|
20
|
+
@app_release_version = "" if @app_release_version.nil?
|
21
|
+
|
20
22
|
@branch_author_suffix = GitConfig::BRANCH_AUTHOR_SUFFIX
|
23
|
+
@branch_author_suffix = "" if @branch_author_suffix.nil?
|
24
|
+
|
21
25
|
@fix_pod_list = $FIX_POD_LIST
|
26
|
+
@fix_pod_list = [] if @fix_pod_list.nil?
|
27
|
+
|
28
|
+
@is_all_binary = $is_all_binary
|
29
|
+
@is_all_binary = false if @is_all_binary.nil?
|
30
|
+
|
31
|
+
@static_lib_list = $static_lib_list
|
32
|
+
@static_lib_list = [] if @static_lib_list.nil?
|
33
|
+
|
34
|
+
@will_package_list = $will_package_list
|
35
|
+
@will_package_list = [] if @will_package_list.nil?
|
22
36
|
end
|
23
37
|
end
|
24
38
|
end
|