cocoapods-wxpodhook 0.0.1 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac28f4b1b48d44af2268e32861defd741aef85654790d33e3a56be1d7dc560aa
4
- data.tar.gz: 0ad5b533dc2ea39eae1a15e5de3fc70d8859d8cfdc5797bc86ed3fe3928c9cab
3
+ metadata.gz: b96c8b419561bf6b5ddcccfc6b3c699af840e635685914a3812c66a8fe79f433
4
+ data.tar.gz: a51c3c57c5f52f7197f0908538678478e8fc7c9827087cba11fc434389ba1250
5
5
  SHA512:
6
- metadata.gz: 3c4cc39aaa82a77a6ec206bb17fd9f602d4a130d8cf77e54960a28a5c05a95657a6d4a8718b61e8d06d5f3cc9d24e855d73308803cdf02941bab52da06d0f71d
7
- data.tar.gz: 0e838bfbee9376fe8ae5885ad9711dc4f77b4660e28441b7979c2f0defb9ca59579c7704dc1975b81e9defc548cdd1900d742a6adce396ebacd9dd0bcedd834e
6
+ metadata.gz: 6ea35b6e7ad33f790fdd2d5272b2063132a01d6983a875721a3acd8c065fa631a78b83ac05c05d127cb0e3b72b19ae74d07634c4dc7f20b99c0df2d8d8bcd1bb
7
+ data.tar.gz: 66a45a304b535703b4aba80bec10446d6cdfd2923a6361ec3cb3ef4f7d6eef413ca8c16ebe791345c609ec196e62044b8ffbc413f28e81d33e3a1a372fb3e05f
@@ -1,3 +1,3 @@
1
1
  module CocoapodsWxpodhook
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,7 +1,210 @@
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 LeevSync
3
- def logTest
4
- puts "我爱北京天安门"
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
+ module Pod
42
+ class Command
43
+
44
+ class WxhookVersion < Command
45
+ def run
46
+ puts "当前版本 #{CocoapodsWxpodhook::VERSION}"
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+
53
+
54
+ #一键更新除官方和阿里云的Repo仓库
55
+ module Pod
56
+ class Command
57
+ class UpdateAllrepo < Command
58
+ self.summary = <<-SUMMARY
59
+ 一键更新网校自有的repo仓库
60
+ SUMMARY
61
+
62
+ self.description = <<-DESC
63
+ 一键更新网校自有的repo仓库
64
+ DESC
65
+
66
+ self.arguments = []
67
+
68
+ def run
69
+ CocoapodsWxpodhook::Helper.new().AutoUpdateRepo();
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+
76
+ # 一键更新组件
77
+ module Pod
78
+ class Command
79
+ class UpdateAll < Command
80
+ self.summary = <<-SUMMARY
81
+ 更新该Podfile下所有使用Repo库管理的组件,不支持传入额外参数
82
+ SUMMARY
83
+
84
+ self.description = <<-DESC
85
+ 更新该Podfile下所有使用Repo库管理的组件,不支持传入额外参数
86
+ DESC
87
+
88
+ self.arguments = []
89
+
90
+ # 版本号对比
91
+ def version_isEqual(curversion, repoversion)
92
+ if curversion == repoversion
93
+ return true
94
+ else
95
+ if repoversion.start_with?(curversion)
96
+ # 截取剩下的字符串
97
+ splitedStr = repoversion.delete(curversion)
98
+ splitedStrArr = splitedStr.split(".")
99
+ sum = 0
100
+ splitedStrArr.each do |item|
101
+ sum += item.to_i
102
+ end
103
+
104
+ if sum == 0
105
+ return true
106
+ else
107
+ return false
108
+ end
109
+ else
110
+ return false
111
+ end
112
+ end
113
+
114
+ end
115
+
116
+ # 拿到待更新的组件名
117
+ def getPrepareUpdateComponents(prepareUpdateComponentsPath)
118
+
119
+ prepareUpdateComponents = Array.new();
120
+
121
+ # prepareUpdateComponentsPath不存在的异常需要处理
122
+ file = File.open(prepareUpdateComponentsPath)
123
+ file.each_line {|line|
124
+ if line.start_with?("- ")
125
+ # puts "**** #{line}"
126
+ # line内容的示例如下: - AFNetworking 3.2.0 -> 3.2.0 (latest version 4.0.1)
127
+ array = line.split(' ')
128
+ if array.size > 4
129
+ # 拿到组件名
130
+ component_name = array[1]
131
+
132
+ # 拿到当前的版本号
133
+ component_curversion = array[2]
134
+
135
+ # 拿到repo中的版本号
136
+ component_repoversion = array[4]
137
+
138
+ # 如果版本号不相等则认为需要更新
139
+ if !self.version_isEqual(component_curversion, component_repoversion)
140
+ prepareUpdateComponents.push(component_name)
141
+ end
142
+ end
143
+ end
144
+ }
145
+ file.close
146
+
147
+ # 删除文件
148
+ FileUtils.rm_r(prepareUpdateComponentsPath)
149
+
150
+ return prepareUpdateComponents
151
+ end
152
+
153
+ def run
154
+
155
+ before = Time.new
156
+
157
+ # 先更新repo
158
+ CocoapodsWxpodhook::Helper.new().AutoUpdateRepo();
159
+
160
+ # 先拿到当前脚本执行的文件路径
161
+ currentFilePath = Dir.pwd
162
+
163
+ # 待更新的组件txt目录
164
+ prepareUpdateComponentsPath = File.join(currentFilePath, "prepareUpdateComponents.txt")
165
+
166
+ # puts prepareUpdateComponentsPath
167
+
168
+ # 先删除已存在的txt文件
169
+ if FileTest.exist?(prepareUpdateComponentsPath)
170
+ FileUtils.rm_r(prepareUpdateComponentsPath)
171
+ end
172
+
173
+ put_redMsg("组件是否需要更新比对中")
174
+
175
+ # 先执行pod outdated
176
+ success = system("pod outdated --no-repo-update > #{prepareUpdateComponentsPath}")
177
+ if !success
178
+ put_redMsg("pod outdated失败")
179
+ textAll = File.read(prepareUpdateComponentsPath)
180
+ put_redMsg(textAll)
181
+ return
182
+ end
183
+
184
+ # 解析txt文件,拿到待更新的组件数组
185
+ componentArr = self.getPrepareUpdateComponents(prepareUpdateComponentsPath)
186
+
187
+ prepareUpdateComponentStr = componentArr.join(" ")
188
+
189
+ if componentArr.size == 0 || prepareUpdateComponentStr.length == 0
190
+ put_redMsg("暂无需要更新的组件")
191
+ return
192
+ end
193
+
194
+ put_redMsg("待更新的组件列表如下 \n #{prepareUpdateComponentStr}")
195
+
196
+ put_redMsg("开始更新组件 \n #{prepareUpdateComponentStr}")
197
+
198
+ # 执行pod update
199
+ system("pod update #{prepareUpdateComponentStr} --no-repo-update")
200
+
201
+ now = Time.new();
202
+
203
+ time = now.to_i - before.to_i;
204
+
205
+ put_redMsg("组件更新完毕,共耗时 #{time}秒")
206
+
207
+ end
5
208
  end
6
209
  end
7
210
  end
@@ -2,26 +2,11 @@ require 'cocoapods'
2
2
  require 'cocoapods-wxpodhook/helper'
3
3
 
4
4
  module CocoapodsWxpodhook
5
- puts "=============="
5
+
6
6
  # Registers for CocoaPods plugin hooks
7
7
 
8
8
  Pod::HooksManager.register('cocoapods-wxpodhook', :pre_install) do |context|
9
- puts "\033[31m 开始自动更新Repo仓库(阿里云及官方repo库不会自动更新) \033[0m"
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.1
4
+ version: 0.0.5
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-19 00:00:00.000000000 Z
11
+ date: 2021-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler