cocoapods-wxpodhook 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cocoapods-wxpodhook/gem_version.rb +1 -1
- data/lib/cocoapods-wxpodhook/helper.rb +186 -3
- data/lib/cocoapods-wxpodhook/hooks.rb +3 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98eae3fed55bdca59bd55933acae9878a516f953afe2c200fe12a3096e058987
|
4
|
+
data.tar.gz: ed8226948a1a37cb0a751a2697f052d33b726ee7c5c314fc2e7b2f5f031e3cf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 275583bf075c84b96d65f31e3040ddbfaefbbc9222fb17c62bd05eab4abda3403380ced625e370f41f645c54b5a4553a4c81c878a2abf14c84b660ddc97a4d9f
|
7
|
+
data.tar.gz: 0e8ab8b448ec565c5bad70fc795fef407a2e5067517b782689bc4a4da15668b4c651fa8d9ff2d85466fcb90ae4e8aa004fb578f2b0763ec4225a31095a7ece02
|
@@ -1,7 +1,190 @@
|
|
1
|
+
require 'cocoapods'
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'find'
|
5
|
+
|
6
|
+
def put_redMsg(message)
|
7
|
+
puts "\033[31m #{message} \033[0m"
|
8
|
+
end
|
9
|
+
|
1
10
|
module CocoapodsWxpodhook
|
2
|
-
class
|
3
|
-
|
4
|
-
|
11
|
+
class Helper
|
12
|
+
|
13
|
+
# 自动更新repo(官方Repo和阿里云repo不再自动更新list中)
|
14
|
+
def AutoUpdateRepo
|
15
|
+
|
16
|
+
before = Time.new();
|
17
|
+
|
18
|
+
put_redMsg("开始自动更新网校应用的集团Repo仓库")
|
19
|
+
|
20
|
+
cocoapods_repo_path = File.join(ENV["HOME"], ".cocoapods/repos")
|
21
|
+
|
22
|
+
# 拿到待更新的repo名称
|
23
|
+
repo_names = Dir.children(cocoapods_repo_path)
|
24
|
+
repo_names.each do |repo_name|
|
25
|
+
if repo_name.include?("100tal-")
|
26
|
+
puts repo_name
|
27
|
+
`pod repo update #{repo_name}`
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
after = Time.new();
|
32
|
+
|
33
|
+
time = after.to_i - before.to_i
|
34
|
+
|
35
|
+
put_redMsg("更新Repo仓库完成,耗时#{time} 秒")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
#一键更新除官方和阿里云的Repo仓库
|
42
|
+
module Pod
|
43
|
+
class Command
|
44
|
+
class UpdateAllrepo < Command
|
45
|
+
self.summary = <<-SUMMARY
|
46
|
+
SUMMARY
|
47
|
+
|
48
|
+
self.description = <<-DESC
|
49
|
+
DESC
|
50
|
+
|
51
|
+
self.arguments = []
|
52
|
+
|
53
|
+
def run
|
54
|
+
CocoapodsWxpodhook::Helper.new().AutoUpdateRepo();
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# 一键更新组件
|
62
|
+
module Pod
|
63
|
+
class Command
|
64
|
+
class UpdateAll < Command
|
65
|
+
self.summary = <<-SUMMARY
|
66
|
+
更新该Podfile下所有使用Repo库管理的组件,不支持传入额外参数
|
67
|
+
SUMMARY
|
68
|
+
|
69
|
+
self.description = <<-DESC
|
70
|
+
更新该Podfile下所有使用Repo库管理的组件,不支持传入额外参数
|
71
|
+
DESC
|
72
|
+
|
73
|
+
self.arguments = []
|
74
|
+
|
75
|
+
# 版本号对比
|
76
|
+
def version_isEqual(curversion, repoversion)
|
77
|
+
if curversion == repoversion
|
78
|
+
return true
|
79
|
+
else
|
80
|
+
if repoversion.start_with?(curversion)
|
81
|
+
# 截取剩下的字符串
|
82
|
+
splitedStr = repoversion.delete(curversion)
|
83
|
+
splitedStrArr = splitedStr.split(".")
|
84
|
+
sum = 0
|
85
|
+
puts "abcdefg #{splitedStrArr}"
|
86
|
+
splitedStrArr.each do |item|
|
87
|
+
sum += item.to_i
|
88
|
+
end
|
89
|
+
|
90
|
+
if sum == 0
|
91
|
+
return true
|
92
|
+
else
|
93
|
+
return false
|
94
|
+
end
|
95
|
+
else
|
96
|
+
return false
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
# 拿到待更新的组件名
|
103
|
+
def getPrepareUpdateComponents(prepareUpdateComponentsPath)
|
104
|
+
|
105
|
+
prepareUpdateComponents = Array.new();
|
106
|
+
|
107
|
+
# prepareUpdateComponentsPath不存在的异常需要处理
|
108
|
+
file = File.open(prepareUpdateComponentsPath)
|
109
|
+
file.each_line {|line|
|
110
|
+
if line.start_with?("- ")
|
111
|
+
# puts "**** #{line}"
|
112
|
+
# line内容的示例如下: - AFNetworking 3.2.0 -> 3.2.0 (latest version 4.0.1)
|
113
|
+
array = line.split(' ')
|
114
|
+
if array.size > 4
|
115
|
+
# 拿到组件名
|
116
|
+
component_name = array[1]
|
117
|
+
|
118
|
+
# 拿到当前的版本号
|
119
|
+
component_curversion = array[2]
|
120
|
+
|
121
|
+
# 拿到repo中的版本号
|
122
|
+
component_repoversion = array[4]
|
123
|
+
|
124
|
+
# 如果版本号不相等则认为需要更新
|
125
|
+
if !self.version_isEqual(component_curversion, component_repoversion)
|
126
|
+
prepareUpdateComponents.push(component_name)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
}
|
131
|
+
file.close
|
132
|
+
|
133
|
+
# 删除文件
|
134
|
+
FileUtils.rm_r(prepareUpdateComponentsPath)
|
135
|
+
|
136
|
+
return prepareUpdateComponents
|
137
|
+
end
|
138
|
+
|
139
|
+
def run
|
140
|
+
|
141
|
+
before = Time.new
|
142
|
+
|
143
|
+
# 先更新repo
|
144
|
+
#CocoapodsWxpodhook::Helper.new().AutoUpdateRepo();
|
145
|
+
|
146
|
+
# 先拿到当前脚本执行的文件路径
|
147
|
+
currentFilePath = Dir.pwd
|
148
|
+
|
149
|
+
# 待更新的组件txt目录
|
150
|
+
prepareUpdateComponentsPath = File.join(currentFilePath, "prepareUpdateComponents.txt")
|
151
|
+
|
152
|
+
# puts prepareUpdateComponentsPath
|
153
|
+
|
154
|
+
# 先删除已存在的txt文件
|
155
|
+
if FileTest.exist?(prepareUpdateComponentsPath)
|
156
|
+
FileUtils.rm_r(prepareUpdateComponentsPath)
|
157
|
+
end
|
158
|
+
|
159
|
+
put_redMsg("组件是否需要更新比对中")
|
160
|
+
|
161
|
+
# 先执行pod outdated
|
162
|
+
`pod outdated --no-repo-update > #{prepareUpdateComponentsPath}`
|
163
|
+
|
164
|
+
# 解析txt文件,拿到待更新的组件数组
|
165
|
+
componentArr = self.getPrepareUpdateComponents(prepareUpdateComponentsPath)
|
166
|
+
|
167
|
+
prepareUpdateComponentStr = componentArr.join(" ")
|
168
|
+
|
169
|
+
if componentArr.size == 0 || prepareUpdateComponentStr.length == 0
|
170
|
+
put_redMsg("暂无需要更新的组件")
|
171
|
+
return
|
172
|
+
end
|
173
|
+
|
174
|
+
put_redMsg("待更新的组件列表如下 \n #{prepareUpdateComponentStr}")
|
175
|
+
|
176
|
+
put_redMsg("开始更新组件 \n #{prepareUpdateComponentStr}")
|
177
|
+
|
178
|
+
# 执行pod update
|
179
|
+
`pod update #{prepareUpdateComponentStr} --no-repo-update`
|
180
|
+
|
181
|
+
now = Time.new();
|
182
|
+
|
183
|
+
time = now.to_i - before.to_i;
|
184
|
+
|
185
|
+
put_redMsg("组件更新完毕,共耗时 #{time}秒")
|
186
|
+
|
187
|
+
end
|
5
188
|
end
|
6
189
|
end
|
7
190
|
end
|
@@ -2,26 +2,11 @@ require 'cocoapods'
|
|
2
2
|
require 'cocoapods-wxpodhook/helper'
|
3
3
|
|
4
4
|
module CocoapodsWxpodhook
|
5
|
-
|
5
|
+
|
6
6
|
# Registers for CocoaPods plugin hooks
|
7
7
|
|
8
8
|
Pod::HooksManager.register('cocoapods-wxpodhook', :pre_install) do |context|
|
9
|
-
|
10
|
-
|
11
|
-
# 网校内部二进制Repo库
|
12
|
-
`pod repo update 100tal-wangxiao_xueyanios_podbins-binlibraryspec`
|
13
|
-
|
14
|
-
# 网校内部源码Repo库
|
15
|
-
`pod repo update 100tal-wangxiao_xueyanios_components-specs`
|
16
|
-
|
17
|
-
# 集团内部Repo库
|
18
|
-
`pod repo update 100tal-tal_internal_pods-talinternalpodrepo`
|
19
|
-
|
20
|
-
# 集团题拍拍Repo库
|
21
|
-
`pod repo update 100tal-jituan_qingzhou_qingzhou-qz_ios_specs`
|
22
|
-
|
23
|
-
# 集团用户中心SDK Repo库
|
24
|
-
`pod repo update 100tal-tal_ucenter_sdk-ios_spec`
|
25
|
-
puts "\033[31m 更新Repo仓库完成 \033[0m"
|
9
|
+
# 自动更新repo
|
10
|
+
CocoapodsWxpodhook::Helper.new().AutoUpdateRepo();
|
26
11
|
end
|
27
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-wxpodhook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- leev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|