sjpush 0.0.5 → 0.0.6
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/sjpush.rb +195 -124
- 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: 9e1f8e002e9f71c269fc7d6ea03a49ff826073c2188551c67302cd5241a0750c
|
|
4
|
+
data.tar.gz: 96d0bae632e7786bd741df69dd10328e9f54c04b4d5bdb043fdca48ca01f5174
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d51fc71d1b75a2838adad014563ce560820a4f730048ff0e59c717957374267314893ecdde3e02723c93d0ad9b4957d26c27e40954a390b4a74541069ae0dd37
|
|
7
|
+
data.tar.gz: 6a2056029e7fb080d0c3f0e6a0a5aa3b44daf218f731753f7d3cf4f22a2f6402355ce2e333fd49269f14ef5a00e0302b2579ebf5463535abc16e2d7eaaf2b0e6
|
data/lib/sjpush.rb
CHANGED
|
@@ -1,84 +1,132 @@
|
|
|
1
1
|
#require "sjpush/version"
|
|
2
2
|
#!/usr/bin/env ruby
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-1. 自动写协议
|
|
15
|
-
-2. 自动补全懒加载
|
|
16
|
-
|
|
17
|
-
输入`exit`退出脚本
|
|
18
|
-
===============================================
|
|
19
|
-
DESC
|
|
20
|
-
|
|
21
|
-
$seq_git_commit = 1
|
|
22
|
-
$seq_git_push_master = 2
|
|
23
|
-
$seq_git_add_tag = 3
|
|
24
|
-
$seq_pod_release = 4
|
|
25
|
-
$seq_git_delete_tag = 5
|
|
26
|
-
|
|
27
|
-
$seq_lazy_protocol = -1
|
|
28
|
-
$seq_lazy_property = -2
|
|
4
|
+
class ActionHandler
|
|
5
|
+
# 定义类方法
|
|
6
|
+
class << self
|
|
7
|
+
# 获取当前的分支
|
|
8
|
+
def getCurBranch()
|
|
9
|
+
# strip! 删除开头和末尾的空白字符
|
|
10
|
+
commands = IO.readlines(".git/HEAD").first.strip!;
|
|
11
|
+
commands.sub!(/ref: refs\/heads\//, "")
|
|
12
|
+
end
|
|
13
|
+
end
|
|
29
14
|
|
|
30
|
-
|
|
15
|
+
class << self
|
|
16
|
+
def getPodspec()
|
|
17
|
+
Dir["*.podspec"].last
|
|
18
|
+
end
|
|
31
19
|
|
|
32
|
-
|
|
20
|
+
def updatePodspecVerAction()
|
|
21
|
+
s = ActionHandler.getPodspec()
|
|
22
|
+
if s.nil?
|
|
23
|
+
puts "已退出, 未搜索到 podspec 文件"
|
|
24
|
+
exit
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
contents = String.new
|
|
28
|
+
File.new(s, "r").each_line do |line|
|
|
29
|
+
regex = "s.version([^']+)'([^']+)'*"
|
|
30
|
+
if /#{regex}/ =~ line
|
|
31
|
+
v = ($2.to_i + 1).to_s
|
|
32
|
+
regex = "'[^']+'"
|
|
33
|
+
line = line.sub!(/#{regex}/, "'#{v}'")
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
contents += line
|
|
37
|
+
end
|
|
38
|
+
file = File.new(s, "w")
|
|
39
|
+
file.syswrite(contents)
|
|
40
|
+
file.close
|
|
41
|
+
|
|
42
|
+
puts "podspec 版本已更新"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def getPodspecVersion()
|
|
46
|
+
s = ActionHandler.getPodspec()
|
|
47
|
+
if s.nil?
|
|
48
|
+
puts "已退出, 未搜索到 podspec 文件"
|
|
49
|
+
exit
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
File.new(s, "r").each_line do |line|
|
|
53
|
+
regex = "s.version([^']+)'([^']+)'*"
|
|
54
|
+
if /#{regex}/ =~ line
|
|
55
|
+
@version = $2.to_i
|
|
56
|
+
break
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
return @version
|
|
61
|
+
end
|
|
62
|
+
end
|
|
33
63
|
|
|
34
|
-
class Git
|
|
35
64
|
def initialize()
|
|
36
|
-
@
|
|
65
|
+
@commands = String.new
|
|
37
66
|
end
|
|
38
67
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
68
|
+
|
|
69
|
+
# - Actions -
|
|
70
|
+
|
|
71
|
+
def addCommand(order)
|
|
72
|
+
if @commands.length == 0
|
|
73
|
+
@commands << order
|
|
74
|
+
else
|
|
75
|
+
@commands << " && #{order}"
|
|
44
76
|
end
|
|
45
77
|
end
|
|
46
|
-
|
|
47
|
-
def
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
78
|
+
|
|
79
|
+
def submitInfoAction()
|
|
80
|
+
if @commitInfo.nil?
|
|
81
|
+
puts "请输入提交信息:"
|
|
82
|
+
@commitInfo = gets.strip!
|
|
83
|
+
end
|
|
84
|
+
return @commitInfo
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def commitAction()
|
|
88
|
+
submit = submitInfoAction()
|
|
89
|
+
addCommand "git add ."
|
|
90
|
+
addCommand "git commit -m '#{submit}'"
|
|
52
91
|
end
|
|
53
92
|
|
|
54
|
-
def
|
|
55
|
-
|
|
93
|
+
def pushAction()
|
|
94
|
+
addCommand "git push origin #{ActionHandler.getCurBranch()}"
|
|
56
95
|
end
|
|
57
96
|
|
|
58
|
-
def
|
|
97
|
+
def addNewTagAction()
|
|
59
98
|
puts "请输入新的标签:"
|
|
60
99
|
newTag = gets.strip!
|
|
61
|
-
|
|
62
|
-
|
|
100
|
+
|
|
101
|
+
submit = submitInfoAction()
|
|
102
|
+
addCommand "git tag -a '#{newTag}' -m '#{submit}'"
|
|
103
|
+
addCommand "git push origin #{newTag}"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def addNewTagForPodspecVersionAction()
|
|
107
|
+
version = ActionHandler.getPodspecVersion()
|
|
108
|
+
submit = submitInfoAction()
|
|
109
|
+
addCommand "git tag -a '#{version}' -m '#{submit}'"
|
|
110
|
+
addCommand "git push origin #{version}"
|
|
63
111
|
end
|
|
64
112
|
|
|
65
|
-
def
|
|
113
|
+
def deleteTagAction()
|
|
66
114
|
puts "请输入要删除的标签:"
|
|
67
115
|
tag = gets.strip!
|
|
68
|
-
|
|
69
|
-
|
|
116
|
+
addCommand "git tag -d #{tag}"
|
|
117
|
+
addCommand "git push origin :#{tag}"
|
|
70
118
|
end
|
|
71
119
|
|
|
72
|
-
def
|
|
73
|
-
|
|
74
|
-
if
|
|
75
|
-
puts "已退出, 未搜索到
|
|
120
|
+
def podReleaseAction()
|
|
121
|
+
s = ActionHandler.getPodspec()
|
|
122
|
+
if s.nil?
|
|
123
|
+
puts "已退出, 未搜索到 podspec 文件"
|
|
76
124
|
exit
|
|
77
125
|
end
|
|
78
|
-
|
|
126
|
+
addCommand "pod repo push lanwuzheRepo #{s} --allow-warnings --use-libraries"
|
|
79
127
|
end
|
|
80
|
-
|
|
81
|
-
def
|
|
128
|
+
|
|
129
|
+
def executeCommands
|
|
82
130
|
puts <<-DESC
|
|
83
131
|
|
|
84
132
|
|
|
@@ -87,85 +135,108 @@ class Git
|
|
|
87
135
|
|
|
88
136
|
|
|
89
137
|
DESC
|
|
90
|
-
system @
|
|
138
|
+
system @commands
|
|
91
139
|
puts "操作完成"
|
|
92
140
|
end
|
|
93
|
-
end
|
|
94
141
|
|
|
95
142
|
|
|
96
|
-
def
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
143
|
+
def handleSeq(seq)
|
|
144
|
+
if seq == $seq_commit.to_i
|
|
145
|
+
commitAction()
|
|
146
|
+
elsif seq == $seq_push_current_branch.to_i
|
|
147
|
+
pushAction()
|
|
148
|
+
elsif seq == $seq_add_tag.to_i
|
|
149
|
+
puts "\n是否使用Podspec中的版本作为标签? [ Yes / NO ]"
|
|
150
|
+
r = gets
|
|
151
|
+
if r.casecmp("Yes") == 1
|
|
152
|
+
addNewTagForPodspecVersionAction()
|
|
153
|
+
else
|
|
154
|
+
addNewTagAction()
|
|
155
|
+
end
|
|
156
|
+
elsif seq == $seq_release.to_i
|
|
157
|
+
podReleaseAction()
|
|
158
|
+
elsif seq == $seq_delete_tag.to_i
|
|
159
|
+
deleteTagAction()
|
|
160
|
+
elsif seq == $seq_update_podspec_version.to_i
|
|
161
|
+
ActionHandler.updatePodspecVerAction()
|
|
162
|
+
elsif seq == $seq_lazy_protocol.to_i
|
|
163
|
+
require 'sjProtocol'
|
|
164
|
+
exit
|
|
165
|
+
elsif seq == $seq_lazy_property.to_i
|
|
166
|
+
require 'sjScript'
|
|
167
|
+
exit
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
nextCommand(seq)
|
|
104
171
|
end
|
|
105
|
-
git.pushMaster
|
|
106
|
-
end
|
|
107
172
|
|
|
108
|
-
def whetherAddNewTag(git)
|
|
109
|
-
# 询问是否添加新的标签
|
|
110
|
-
# Git - Add Tag
|
|
111
|
-
puts "\n是否添加标签? [ Yes / NO ]"
|
|
112
|
-
needAddTag = gets
|
|
113
|
-
if needAddTag.casecmp("Yes") != 1
|
|
114
|
-
git.exec
|
|
115
|
-
exit
|
|
116
|
-
end
|
|
117
|
-
git.addNewTag
|
|
118
|
-
end
|
|
119
173
|
|
|
120
|
-
def
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
174
|
+
def nextCommand(beforeSeq)
|
|
175
|
+
if beforeSeq == $seq_commit.to_i
|
|
176
|
+
# 询问是否推送到主干上
|
|
177
|
+
# ActionHandler - Push
|
|
178
|
+
puts "\n是否推送到 #{ActionHandler.getCurBranch()}? [ Yes / NO ]"
|
|
179
|
+
r = gets
|
|
180
|
+
if r.casecmp("Yes") == 1
|
|
181
|
+
handleSeq($seq_push_current_branch.to_i)
|
|
182
|
+
end
|
|
183
|
+
elsif beforeSeq == $seq_push_current_branch.to_i
|
|
184
|
+
puts "\n是否添加标签? [ Yes / NO ]"
|
|
185
|
+
r = gets
|
|
186
|
+
if r.casecmp("Yes") == 1
|
|
187
|
+
handleSeq($seq_add_tag.to_i)
|
|
188
|
+
end
|
|
189
|
+
elsif beforeSeq == $seq_add_tag.to_i
|
|
190
|
+
# 询问是否发布pod
|
|
191
|
+
# Pod - Release
|
|
192
|
+
puts "\n是否发布pod版本? [ Yes / NO ]"
|
|
193
|
+
r = gets
|
|
194
|
+
if r.casecmp("Yes") == 1
|
|
195
|
+
handleSeq($seq_release.to_i)
|
|
196
|
+
end
|
|
197
|
+
elsif beforeSeq == $seq_update_podspec_version.to_i
|
|
198
|
+
puts "\n是否提交变更? [ Yes / NO ]"
|
|
199
|
+
r = gets
|
|
200
|
+
if r.casecmp("Yes") == 1
|
|
201
|
+
handleSeq($seq_commit.to_i)
|
|
202
|
+
end
|
|
203
|
+
end
|
|
128
204
|
end
|
|
129
|
-
git.podRelease
|
|
130
205
|
end
|
|
131
206
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
end
|
|
143
|
-
end
|
|
207
|
+
seqs = [
|
|
208
|
+
$seq_update_podspec_version = "0. Podspec版本+1",
|
|
209
|
+
$seq_commit = "1. 提交变更",
|
|
210
|
+
$seq_push_current_branch = "2. 推送到当前分支(#{ActionHandler.getCurBranch()})",
|
|
211
|
+
$seq_add_tag = "3. 添加新的标签",
|
|
212
|
+
$seq_release = "4. pod发布(pod repo push ..repo ..podspec)",
|
|
213
|
+
$seq_delete_tag = "5. 删除标签",
|
|
214
|
+
$seq_lazy_protocol = "6. 自动写协议",
|
|
215
|
+
$seq_lazy_property = "7. 自动补全懒加载",
|
|
216
|
+
]
|
|
144
217
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
elsif seq == $seq_git_add_tag
|
|
154
|
-
git.addNewTag
|
|
155
|
-
elsif seq == $seq_pod_release
|
|
156
|
-
git.podRelease
|
|
157
|
-
elsif seq == $seq_git_delete_tag
|
|
158
|
-
git.deleteTag
|
|
159
|
-
elsif seq == $seq_lazy_protocol
|
|
160
|
-
require 'sjProtocol'
|
|
161
|
-
exit
|
|
162
|
-
elsif seq == $seq_lazy_property
|
|
163
|
-
require 'sjScript'
|
|
164
|
-
exit
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
considerNextTask(seq, git)
|
|
168
|
-
git.exec
|
|
218
|
+
require "pp"
|
|
219
|
+
|
|
220
|
+
# - seqs -
|
|
221
|
+
puts "\n"
|
|
222
|
+
puts "请输入操作序号:"
|
|
223
|
+
puts "\n"
|
|
224
|
+
seqs.each do |s|
|
|
225
|
+
puts s
|
|
169
226
|
end
|
|
227
|
+
puts "\n"
|
|
228
|
+
|
|
229
|
+
# - exit -
|
|
230
|
+
puts "输入`exit`退出脚本"
|
|
231
|
+
|
|
232
|
+
puts "\n"
|
|
233
|
+
puts "================== 等待操作 =================="
|
|
234
|
+
|
|
235
|
+
seq = gets
|
|
236
|
+
|
|
237
|
+
exit if seq.casecmp('exit') == 1
|
|
170
238
|
|
|
171
|
-
|
|
239
|
+
handler = ActionHandler.new
|
|
240
|
+
puts "\n\n"
|
|
241
|
+
handler.handleSeq(seq.to_i)
|
|
242
|
+
handler.executeCommands()
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sjpush
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SanJiang
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-03-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: 用于辅助git提交
|
|
14
14
|
email:
|