cocoapods-tag 0.0.1
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 +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/lib/cocoapods-tag/command/tag/create.rb +320 -0
- data/lib/cocoapods-tag/command/tag/spec_push.rb +53 -0
- data/lib/cocoapods-tag/command/tag.rb +22 -0
- data/lib/cocoapods-tag/command.rb +1 -0
- data/lib/cocoapods-tag/gem_version.rb +3 -0
- data/lib/cocoapods-tag/helper/asker.rb +65 -0
- data/lib/cocoapods-tag/native/validator.rb +9 -0
- data/lib/cocoapods-tag.rb +1 -0
- data/lib/cocoapods_plugin.rb +1 -0
- data/spec/command/tag_spec.rb +12 -0
- data/spec/spec_helper.rb +50 -0
- metadata +100 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 0fc5297e51950ca49c7e6862bcd9ccaa7707c88b1568df30ed32cc165cb05d48
|
|
4
|
+
data.tar.gz: adf8df13f96690d4d98eeb08d801d7570f255eabc8d16ad395ccfb71d7815fd5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9cd6328f564dcfe676bd940258a0a1d8701ecc1eff4451fa856c6808cb64d475d2659db869424ee316ecdcb589533ee37b045dfb1ea1b3a2b779c5cadb715713
|
|
7
|
+
data.tar.gz: 1e83a70c3ea110853d6fa97ef376cd121848567ec681b08949de3c0f2bde6e6b14fd660abbd4313de613523d72f6848baeb08b8a884d746841aba3b9584c59b2
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2022 Jensen <zys2@meitu.com>
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
## 简介
|
|
2
|
+
|
|
3
|
+
`cocoapods-tag`是一个可以方便地帮助Pod库打tag的`CocoaPods`插件,插件采用问答的方式提示用户输入相应内容,简单、方便、快捷。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
$ gem install cocoapods-tag
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 使用
|
|
12
|
+
|
|
13
|
+
* 查看帮助
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
$ pod tag --help
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
* 创建tag并push到远端,并询问是否上传podspec到spec repo
|
|
20
|
+
|
|
21
|
+
```shell
|
|
22
|
+
$ pod tag
|
|
23
|
+
# 或
|
|
24
|
+
$ pod tag create
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
* 上传podspec到spec repo
|
|
28
|
+
|
|
29
|
+
```shell
|
|
30
|
+
$ pod tag spec-push REPO NAME.podspec
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 演示gif
|
|
34
|
+
|
|
35
|
+
<img src='./cocoapods-tag.gif' width='100%' />
|
|
36
|
+
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
require 'cocoapods-tag/helper/asker'
|
|
2
|
+
|
|
3
|
+
module Pod
|
|
4
|
+
class Command
|
|
5
|
+
class Tag < Command
|
|
6
|
+
class Create < Tag
|
|
7
|
+
include Pod
|
|
8
|
+
|
|
9
|
+
GITHUB_DOMAIN = "github.com".freeze
|
|
10
|
+
GIT_REPO = ".git".freeze
|
|
11
|
+
PODSPEC_EXT = %w[podspec podspec.json].freeze
|
|
12
|
+
|
|
13
|
+
self.summary = '创建 tag 并 push 到远端仓库,同时可以上传 podspec 到 spec repo'
|
|
14
|
+
|
|
15
|
+
self.description = <<-DESC
|
|
16
|
+
#{self.summary}
|
|
17
|
+
DESC
|
|
18
|
+
|
|
19
|
+
def initialize(argv)
|
|
20
|
+
super
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def run
|
|
24
|
+
require 'cocoapods-tag/native/validator'
|
|
25
|
+
|
|
26
|
+
# 欢迎提示
|
|
27
|
+
asker.welcome_message
|
|
28
|
+
# 检查本地 git 仓库
|
|
29
|
+
check_git_repo?
|
|
30
|
+
# 加载 podspec
|
|
31
|
+
load_podspec
|
|
32
|
+
# 提示用户输入 version
|
|
33
|
+
ask_version
|
|
34
|
+
# 提示用户输入前缀
|
|
35
|
+
ask_prefix
|
|
36
|
+
# 提示用户输入后缀
|
|
37
|
+
ask_suffix
|
|
38
|
+
# 提示用户输入 commit msg 和 tag msg
|
|
39
|
+
ask_commit_tag_msg
|
|
40
|
+
# 询问用户推送到哪个远端仓库
|
|
41
|
+
ask_remote
|
|
42
|
+
# 提示用户确认
|
|
43
|
+
ask_sure
|
|
44
|
+
# 修改 podspec
|
|
45
|
+
modify_podspec
|
|
46
|
+
# 推送 tag 到远端
|
|
47
|
+
git_tag_push
|
|
48
|
+
# 询问用户是否推送 podspec 到 spec 仓库
|
|
49
|
+
ask_push_podspec_to_repo
|
|
50
|
+
# 结束提示
|
|
51
|
+
asker.done_message if @error.nil?
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
# 加载 podspec
|
|
57
|
+
def load_podspec
|
|
58
|
+
unless check_podspec_exist?
|
|
59
|
+
raise Informative, "`#{Dir.pwd}`不存在podspec"
|
|
60
|
+
end
|
|
61
|
+
@spec = Specification.from_file(@podspecs.first)
|
|
62
|
+
raise Informative, "加载`#{@podspecs.first}`失败!" if @spec.nil?
|
|
63
|
+
@spec_hash = @spec.to_hash
|
|
64
|
+
source = @spec_hash['source']
|
|
65
|
+
# 目前只处理 git 这种形式
|
|
66
|
+
unless source['git']
|
|
67
|
+
raise Informative, "目前只能处理`git`这种形式"
|
|
68
|
+
end
|
|
69
|
+
# git字段为空
|
|
70
|
+
if source['git'] && source['git'].strip == ''
|
|
71
|
+
raise Informative, "source中git字段不能为空"
|
|
72
|
+
end
|
|
73
|
+
# 判断 source 中是否包含 github.com
|
|
74
|
+
if source['git'] && source['git'].include?(GITHUB_DOMAIN)
|
|
75
|
+
message = "\n`#{@podspecs.first}`的source中包含`#{GITHUB_DOMAIN}`,请确认是否正确?"
|
|
76
|
+
answer = asker.ask(message, true, nil, { '1' => '正确✅', '2' => '错误❌' })
|
|
77
|
+
if answer == '2'
|
|
78
|
+
exit("\n程序终止\n")
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
# 修改前校验一次 podspec
|
|
82
|
+
lint_podspec("\n修改前校验`#{@podspecs.first}`:\n")
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# 检查 git repo
|
|
86
|
+
def check_git_repo?
|
|
87
|
+
print "检查git仓库:\n".yellow
|
|
88
|
+
|
|
89
|
+
git_repo = File.join(Dir.pwd, GIT_REPO)
|
|
90
|
+
raise Informative, "`#{Dir.pwd}`不存在git仓库,请先使用`git init`初始化git仓库" unless File.exist?(git_repo)
|
|
91
|
+
|
|
92
|
+
remotes = `git remote`.split("\n")
|
|
93
|
+
raise Informative, "本地git仓库没有与远端仓库关联,请先使用`git remote add`关联远端仓库" if remotes.empty?
|
|
94
|
+
|
|
95
|
+
local_commit = `git rev-parse HEAD`.chomp
|
|
96
|
+
remote_commit = `git ls-remote --head`.split("\t")[0]
|
|
97
|
+
raise Informative, "本地git仓库没有与远端同步,请先执行`git pull`或`git fetch + git rebase`拉取最新代码" unless local_commit == remote_commit
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# 提示用户输入版本号
|
|
101
|
+
def ask_version
|
|
102
|
+
question = "\n请输入版本号(用于修改`podspec`中的`version`):"
|
|
103
|
+
pre_answer = @spec_hash['version']
|
|
104
|
+
regx = {
|
|
105
|
+
"tip" => "版本号中间必须有'.'且每一位只支持数字,如:0.1、1.1.2等",
|
|
106
|
+
"pattern" => /^(\d+\.)+\d+$/
|
|
107
|
+
}
|
|
108
|
+
@version = asker.ask(question, true, pre_answer, nil, regx)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# 提示用户输入前缀
|
|
112
|
+
def ask_prefix
|
|
113
|
+
question = "\n请输入tag前缀:"
|
|
114
|
+
@prefix = asker.ask(question)
|
|
115
|
+
print "无前缀\n" if @prefix.size == 0
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# 提示用户输入后缀
|
|
119
|
+
def ask_suffix
|
|
120
|
+
question = "\n请输入tag后缀:"
|
|
121
|
+
@suffix = asker.ask(question)
|
|
122
|
+
print "无后缀\n" if @suffix.size == 0
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# 提示用户输入 commit msg 和 tag msg
|
|
126
|
+
def ask_commit_tag_msg
|
|
127
|
+
@commit_msg = asker.ask("\n请输入commit信息:", true)
|
|
128
|
+
@tag_msg = asker.ask("\n请输入tag信息:", true)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# 询问用户推送到哪个远端仓库
|
|
132
|
+
def ask_remote
|
|
133
|
+
remotes = `git remote`.split("\n")
|
|
134
|
+
@remote = remotes[0] unless remotes.empty?
|
|
135
|
+
if remotes.size > 1
|
|
136
|
+
count = 0
|
|
137
|
+
selections = {}
|
|
138
|
+
remotes.map do |remote|
|
|
139
|
+
count += 1
|
|
140
|
+
selections["#{count}"] = remote
|
|
141
|
+
end
|
|
142
|
+
key = asker.ask("\n请选择推送到的远端仓库:", true, nil, selections)
|
|
143
|
+
@remote = remotes["#{key}".to_i]
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# 提示用户确认信息
|
|
148
|
+
def ask_sure
|
|
149
|
+
@tag = "#{@prefix}#{@version}#{@suffix}"
|
|
150
|
+
question = <<-Q
|
|
151
|
+
|
|
152
|
+
请确认以下信息:
|
|
153
|
+
——————————————————————————————————————
|
|
154
|
+
|tag: #{@tag}
|
|
155
|
+
|version: #{@version}
|
|
156
|
+
|commit_msg: #{@commit_msg}
|
|
157
|
+
|tag_msg: #{@tag_msg}
|
|
158
|
+
|current_branch: #{current_branch}
|
|
159
|
+
|remote: #{@remote}
|
|
160
|
+
——————————————————————————————————————
|
|
161
|
+
Q
|
|
162
|
+
selections = {'1'=> '确认', '2'=> '取消'}
|
|
163
|
+
answer = asker.ask(question, true, nil, selections)
|
|
164
|
+
if answer == 2
|
|
165
|
+
exit("\n程序终止\n")
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# 修改podspec
|
|
170
|
+
def modify_podspec
|
|
171
|
+
if @podspecs.nil? || @podspecs.empty?
|
|
172
|
+
return
|
|
173
|
+
end
|
|
174
|
+
podspec = @podspecs.first
|
|
175
|
+
file = File.join(Dir.pwd, "#{podspec}")
|
|
176
|
+
# 匹配文件名后缀
|
|
177
|
+
if podspec =~ /.podspec$/
|
|
178
|
+
modify_podspec_ruby(file)
|
|
179
|
+
elsif podspec =~ /.podspec.json$/
|
|
180
|
+
modify_podspec_json(file)
|
|
181
|
+
end
|
|
182
|
+
# 修改完再次校验 podspec
|
|
183
|
+
lint_podspec("\n修改后校验`#{@podspecs.first}`:\n")
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# 修改 *.podspec
|
|
187
|
+
def modify_podspec_ruby(file)
|
|
188
|
+
org_source = @spec_hash['source']
|
|
189
|
+
des_source = "{ :git => '#{org_source['git']}', :tag => '#{@tag}' }"
|
|
190
|
+
File.open(file, 'r') do |f|
|
|
191
|
+
lines = []
|
|
192
|
+
f.each_line do |line|
|
|
193
|
+
if line =~ /(^\s*.+\.version\s*=\s*).*/
|
|
194
|
+
line = line.sub(/(^\s*.+\.version\s*=\s*).*/, "#{$1}'#{@version}'")
|
|
195
|
+
end
|
|
196
|
+
if line =~ /(^\s*.+\.source\s*=\s*).*/
|
|
197
|
+
line = line.sub(/(^\s*.+\.source\s*=\s*).*/, "#{$1}#{des_source}")
|
|
198
|
+
end
|
|
199
|
+
lines << line
|
|
200
|
+
end
|
|
201
|
+
File.open(file, 'w') do |f|
|
|
202
|
+
f.write(lines.join(""))
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# 修改 *.podspec.json
|
|
208
|
+
def modify_podspec_json(file)
|
|
209
|
+
@spec_hash['version'] = @version
|
|
210
|
+
@spec_hash['source'] = {
|
|
211
|
+
'git'=> @spec_hash['source']['git'],
|
|
212
|
+
'tag'=> "#{@tag}"
|
|
213
|
+
}
|
|
214
|
+
File.open(file, 'w') do |f|
|
|
215
|
+
f.write(@spec_hash)
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# 校验 podspec
|
|
220
|
+
def lint_podspec(tip = "\n校验`#{@podspecs.first}`:\n")
|
|
221
|
+
print "#{tip}".yellow
|
|
222
|
+
argvs = [
|
|
223
|
+
@podspecs.first,
|
|
224
|
+
'--quick',
|
|
225
|
+
'--allow-warnings'
|
|
226
|
+
]
|
|
227
|
+
lint = Pod::Command::Spec::Lint.new(CLAide::ARGV.new(argvs))
|
|
228
|
+
lint.validate!
|
|
229
|
+
lint.run
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# 推送 tag 到远端
|
|
233
|
+
def git_tag_push
|
|
234
|
+
print "\n推送commit到远端git仓库`#{@remote}/#{current_branch}`:\n".yellow
|
|
235
|
+
begin
|
|
236
|
+
`git add #{@podspecs.first}`
|
|
237
|
+
`git commit -m #{@commit_msg}`
|
|
238
|
+
`git push #{@remote} #{current_branch}`
|
|
239
|
+
rescue Pod::StandardError => e
|
|
240
|
+
@error = e
|
|
241
|
+
print "推送commit到远端git仓库`#{@remote}/#{current_branch}`失败:#{e}".red
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
print "\n创建tag:#{@tag}并推送至远端:\n".yellow
|
|
245
|
+
begin
|
|
246
|
+
`git tag -a #{@tag} -m #{@tag_msg}`
|
|
247
|
+
`git push #{@remote} --tags`
|
|
248
|
+
rescue Pod::StandardError => e
|
|
249
|
+
@error = e
|
|
250
|
+
print "创建tag:#{@tag}并推送至远端失败:#{e}".red
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
# 询问用户是否推送 podspec 到 spec 仓库
|
|
255
|
+
def ask_push_podspec_to_repo
|
|
256
|
+
answer = asker.ask("\n是否推送podspec到spec仓库?", true, nil, {'1'=> 'YES', '2' => 'NO'})
|
|
257
|
+
if answer == '1'
|
|
258
|
+
@spec_repo = asker.ask("\n请输入本地spec仓库名称(可以通过`pod repo list`查看):", true)
|
|
259
|
+
repos = `pod repo list`.split("\n").reject { |repo| repo == '' || repo =~ /^-/ }
|
|
260
|
+
unless repos.include?(@spec_repo)
|
|
261
|
+
print "本地不存在`#{@spec_repo}`仓库,请先`pod repo add`添加该仓库\n"
|
|
262
|
+
return
|
|
263
|
+
end
|
|
264
|
+
unless @spec_repo == ''
|
|
265
|
+
push_podspec_to_repo
|
|
266
|
+
end
|
|
267
|
+
else
|
|
268
|
+
print "跳过推送podspec到spec仓库\n"
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# 推送 podspec 到 spec repo
|
|
273
|
+
def push_podspec_to_repo
|
|
274
|
+
print "\n推送`#{@podspecs.first}`到`#{@spec_repo}`仓库".yellow
|
|
275
|
+
argvs = [
|
|
276
|
+
@spec_repo,
|
|
277
|
+
@podspecs.first,
|
|
278
|
+
'--allow-warnings'
|
|
279
|
+
]
|
|
280
|
+
begin
|
|
281
|
+
push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
|
|
282
|
+
push.validate!
|
|
283
|
+
push.run
|
|
284
|
+
rescue Pod::StandardError => e
|
|
285
|
+
@error = e
|
|
286
|
+
print "推送`#{@podspecs.first}`到`#{@spec_repo}`仓库失败!#{e}".red
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def exit(status = -1, msg)
|
|
291
|
+
print "#{msg}".red
|
|
292
|
+
Process.exit(status)
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
def asker
|
|
296
|
+
@asker ||= begin
|
|
297
|
+
Helper::Asker.new()
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
# 获取当前分支
|
|
302
|
+
def current_branch
|
|
303
|
+
@current_branch ||= begin
|
|
304
|
+
`git branch`.split(' ')[1]
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# 检查当前目录是否有podspec
|
|
309
|
+
def check_podspec_exist?
|
|
310
|
+
@podspecs = Dir.glob("*.{#{PODSPEC_EXT.join(',')}}")
|
|
311
|
+
if @podspecs.empty?
|
|
312
|
+
return false
|
|
313
|
+
end
|
|
314
|
+
true
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
module Pod
|
|
3
|
+
class Command
|
|
4
|
+
class Tag < Command
|
|
5
|
+
class SpecPush < Tag
|
|
6
|
+
|
|
7
|
+
self.summary = '上传 podspec 到 spec 仓库,自动跳过 xcodebuild 编译校验'
|
|
8
|
+
|
|
9
|
+
self.description = <<-DESC
|
|
10
|
+
#{self.summary}
|
|
11
|
+
DESC
|
|
12
|
+
|
|
13
|
+
self.arguments = [
|
|
14
|
+
CLAide::Argument.new('REPO', true ),
|
|
15
|
+
CLAide::Argument.new('NAME.podspec', true )
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
def initialize(argv)
|
|
19
|
+
@repo = argv.shift_argument
|
|
20
|
+
@podspec = argv.shift_argument
|
|
21
|
+
super
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def run
|
|
25
|
+
require 'cocoapods-tag/native/validator'
|
|
26
|
+
|
|
27
|
+
unless @repo
|
|
28
|
+
raise Informative, "请输入spec repo"
|
|
29
|
+
end
|
|
30
|
+
unless @podspec
|
|
31
|
+
raise Informative, "请输入要上传的podspec"
|
|
32
|
+
end
|
|
33
|
+
UI.title "推送`#{@podspec}`到`#{@repo}`仓库".yellow do
|
|
34
|
+
argvs = [
|
|
35
|
+
@repo,
|
|
36
|
+
@podspec,
|
|
37
|
+
'--allow-warnings'
|
|
38
|
+
]
|
|
39
|
+
begin
|
|
40
|
+
push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
|
|
41
|
+
push.validate!
|
|
42
|
+
push.run
|
|
43
|
+
rescue Pod::StandardError => e
|
|
44
|
+
@error = e
|
|
45
|
+
print "推送`#{@podspec}`到`#{@repo}`仓库失败!#{e}".red
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'cocoapods-tag/command/tag/create'
|
|
2
|
+
require 'cocoapods-tag/command/tag/spec_push'
|
|
3
|
+
|
|
4
|
+
module Pod
|
|
5
|
+
class Command
|
|
6
|
+
class Tag < Command
|
|
7
|
+
|
|
8
|
+
self.abstract_command = true
|
|
9
|
+
self.default_subcommand = 'create'
|
|
10
|
+
|
|
11
|
+
self.summary = '🚀 方便地帮助 pod 库打 tag'
|
|
12
|
+
self.description = <<-DESC
|
|
13
|
+
#{self.summary}
|
|
14
|
+
DESC
|
|
15
|
+
|
|
16
|
+
def initialize(argv)
|
|
17
|
+
super
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'cocoapods-tag/command/tag'
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require 'cocoapods-tag/gem_version.rb'
|
|
2
|
+
|
|
3
|
+
class Helper
|
|
4
|
+
class Asker
|
|
5
|
+
|
|
6
|
+
def ask(question, required = false, pre_answer = nil, selections = nil, regx = nil )
|
|
7
|
+
question_msg = "#{question}\n"
|
|
8
|
+
question_msg += "旧值:#{pre_answer}\n" if pre_answer
|
|
9
|
+
keys = []
|
|
10
|
+
if selections && selections.is_a?(Hash)
|
|
11
|
+
keys = selections.keys
|
|
12
|
+
selections.each do |k, v|
|
|
13
|
+
question_msg += "#{k}:#{v}\n"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
print question_msg.yellow
|
|
17
|
+
answer = ''
|
|
18
|
+
loop do
|
|
19
|
+
show_prompt
|
|
20
|
+
answer = STDIN.gets.chomp.strip
|
|
21
|
+
# 判断是否为空
|
|
22
|
+
if required && answer == ''
|
|
23
|
+
print "该项为必填项\n"
|
|
24
|
+
next
|
|
25
|
+
end
|
|
26
|
+
# 判断是否符合正则
|
|
27
|
+
if regx && regx.is_a?(Hash)
|
|
28
|
+
tip = regx['tip']
|
|
29
|
+
pattern = regx['pattern']
|
|
30
|
+
unless answer =~ pattern
|
|
31
|
+
print "#{tip}\n"
|
|
32
|
+
next
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
# 有固定选项 && 输入的值不在选项中
|
|
36
|
+
if selections && !keys.include?(answer)
|
|
37
|
+
print "请输入#{keys}中的一个值:\n"
|
|
38
|
+
next
|
|
39
|
+
end
|
|
40
|
+
break
|
|
41
|
+
end
|
|
42
|
+
answer
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def welcome_message
|
|
46
|
+
message = <<-MSG
|
|
47
|
+
👏🏻欢迎使用 `cocoapods-tag` 插件👏🏻
|
|
48
|
+
👏🏻version: #{CocoapodsTag::VERSION}👏🏻
|
|
49
|
+
|
|
50
|
+
MSG
|
|
51
|
+
print message.green
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def done_message
|
|
55
|
+
print "\n🌺 恭喜你完成任务 🌺\n".green
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def show_prompt
|
|
61
|
+
print '> '.green
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'cocoapods-tag/gem_version'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'cocoapods-tag/command'
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
|
3
|
+
$:.unshift((ROOT + 'lib').to_s)
|
|
4
|
+
$:.unshift((ROOT + 'spec').to_s)
|
|
5
|
+
|
|
6
|
+
require 'bundler/setup'
|
|
7
|
+
require 'bacon'
|
|
8
|
+
require 'mocha-on-bacon'
|
|
9
|
+
require 'pretty_bacon'
|
|
10
|
+
require 'pathname'
|
|
11
|
+
require 'cocoapods'
|
|
12
|
+
|
|
13
|
+
Mocha::Configuration.prevent(:stubbing_non_existent_method)
|
|
14
|
+
|
|
15
|
+
require 'cocoapods_plugin'
|
|
16
|
+
|
|
17
|
+
#-----------------------------------------------------------------------------#
|
|
18
|
+
|
|
19
|
+
module Pod
|
|
20
|
+
|
|
21
|
+
# Disable the wrapping so the output is deterministic in the tests.
|
|
22
|
+
#
|
|
23
|
+
UI.disable_wrap = true
|
|
24
|
+
|
|
25
|
+
# Redirects the messages to an internal store.
|
|
26
|
+
#
|
|
27
|
+
module UI
|
|
28
|
+
@output = ''
|
|
29
|
+
@warnings = ''
|
|
30
|
+
|
|
31
|
+
class << self
|
|
32
|
+
attr_accessor :output
|
|
33
|
+
attr_accessor :warnings
|
|
34
|
+
|
|
35
|
+
def puts(message = '')
|
|
36
|
+
@output << "#{message}\n"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def warn(message = '', actions = [])
|
|
40
|
+
@warnings << "#{message}\n"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def print(message)
|
|
44
|
+
@output << message
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
#-----------------------------------------------------------------------------#
|
metadata
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: cocoapods-tag
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jensen
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-04-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: cocoapods
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: bundler
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rake
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
description: 方便地帮助pod库打tag的CocoaPods插件
|
|
56
|
+
email:
|
|
57
|
+
- zys2@meitu.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- LICENSE.txt
|
|
63
|
+
- README.md
|
|
64
|
+
- lib/cocoapods-tag.rb
|
|
65
|
+
- lib/cocoapods-tag/command.rb
|
|
66
|
+
- lib/cocoapods-tag/command/tag.rb
|
|
67
|
+
- lib/cocoapods-tag/command/tag/create.rb
|
|
68
|
+
- lib/cocoapods-tag/command/tag/spec_push.rb
|
|
69
|
+
- lib/cocoapods-tag/gem_version.rb
|
|
70
|
+
- lib/cocoapods-tag/helper/asker.rb
|
|
71
|
+
- lib/cocoapods-tag/native/validator.rb
|
|
72
|
+
- lib/cocoapods_plugin.rb
|
|
73
|
+
- spec/command/tag_spec.rb
|
|
74
|
+
- spec/spec_helper.rb
|
|
75
|
+
homepage: https://github.com/Zhangyanshen/cocoapods-tag.git
|
|
76
|
+
licenses:
|
|
77
|
+
- MIT
|
|
78
|
+
metadata: {}
|
|
79
|
+
post_install_message:
|
|
80
|
+
rdoc_options: []
|
|
81
|
+
require_paths:
|
|
82
|
+
- lib
|
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - ">="
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '0'
|
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '0'
|
|
93
|
+
requirements: []
|
|
94
|
+
rubygems_version: 3.1.2
|
|
95
|
+
signing_key:
|
|
96
|
+
specification_version: 4
|
|
97
|
+
summary: 方便地帮助pod库打tag的CocoaPods插件,可以校验podspec的合法性
|
|
98
|
+
test_files:
|
|
99
|
+
- spec/command/tag_spec.rb
|
|
100
|
+
- spec/spec_helper.rb
|