cocoapods-tag 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +64 -16
- data/lib/cocoapods-tag/command/tag/auto.rb +85 -0
- data/lib/cocoapods-tag/command/tag/create.rb +3 -3
- data/lib/cocoapods-tag/command/tag.rb +3 -2
- data/lib/cocoapods-tag/gem_version.rb +1 -1
- data/lib/cocoapods-tag/tag.rb +295 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab723fa1e07606d3664af7a1ec85aacd255a2782722be6c733d727f86f1e47d9
|
4
|
+
data.tar.gz: eefc4e3111d15c9504ca69e894aff85a76ba8531aff01028fdb52f75e1068173
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f7a3e6579264821c391fcd54a23fd5a9fea86ce3344b176a951825578d57a3a52b5b5c9e085b1e879bde0511f4d29c5fdcb82bb9001bf6cc6689fac1e1d1092
|
7
|
+
data.tar.gz: a282fea1a342b38eea54357ac0967910bf8a428dceae26b77a0616198a066b660baf339ac4d3ca1ef2599f0c81302c568039797e05fcff426fc4ee46be0c991e
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
## 简介
|
2
2
|
|
3
|
-
`cocoapods-tag`是一个可以方便地帮助Pod库打tag的`CocoaPods
|
3
|
+
`cocoapods-tag`是一个可以方便地帮助Pod库打tag的`CocoaPods`插件。
|
4
4
|
|
5
5
|
## 安装
|
6
6
|
|
@@ -12,25 +12,73 @@ $ gem install cocoapods-tag
|
|
12
12
|
|
13
13
|
* 查看帮助
|
14
14
|
|
15
|
-
```shell
|
16
|
-
$ pod tag --help
|
17
|
-
|
15
|
+
```shell
|
16
|
+
$ pod tag --help
|
17
|
+
$ pod tag auto --help
|
18
|
+
```
|
18
19
|
|
19
|
-
*
|
20
|
+
* 使用默认tag信息,如tag为“0.1.7”,那么tag信息为”v0.1.7“
|
20
21
|
|
21
|
-
```shell
|
22
|
-
$ pod tag
|
23
|
-
|
24
|
-
$ pod tag create
|
25
|
-
```
|
22
|
+
```shell
|
23
|
+
$ pod tag 0.1.7 "修改podspec版本号为0.1.7"
|
24
|
+
```
|
26
25
|
|
27
|
-
*
|
26
|
+
* 使用自定义tag信息
|
28
27
|
|
29
|
-
```shell
|
30
|
-
$ pod tag
|
31
|
-
```
|
28
|
+
```shell
|
29
|
+
$ pod tag 0.1.7 "修改podspec版本号为0.1.7" "版本0.1.7"
|
30
|
+
```
|
31
|
+
|
32
|
+
* 推送`podspec`到指定的`spec repo`
|
33
|
+
|
34
|
+
```shell
|
35
|
+
$ pod tag 0.1.7 "修改podspec版本号为0.1.7" "版本0.1.7" --spec-repo=xxx
|
36
|
+
```
|
37
|
+
|
38
|
+
* 跳过耗时校验
|
39
|
+
|
40
|
+
```shell
|
41
|
+
$ pod tag 0.1.7 "修改podspec版本号为0.1.7" "版本0.1.7" --spec-repo=xxx --quick
|
42
|
+
```
|
43
|
+
|
44
|
+
* 指定tag推送到的远端仓库(可以通过`git remote -v`查看)
|
32
45
|
|
33
|
-
|
46
|
+
```shell
|
47
|
+
$ pod tag 0.1.7 "修改podspec版本号为0.1.7" "版本0.1.7" --remote=origin
|
48
|
+
```
|
49
|
+
|
50
|
+
* 指定工作目录(插件执行的目录)
|
51
|
+
|
52
|
+
```shell
|
53
|
+
$ pod tag 0.1.7 "修改podspec版本号为0.1.7" --work-dir=xxx
|
54
|
+
```
|
55
|
+
|
56
|
+
* 为tag添加前后缀**(前后缀与版本号中间会自动用`-`分隔,不需要手动添加)**
|
57
|
+
|
58
|
+
以下面这行命令为例,`podspec`中的`version`为`0.1.7`,`source`字段中的`tag`为`mtxx-0.1.7-beta1`,最终推送到远端仓库的`tag`也是`mtxx-0.1.7-beta1`
|
59
|
+
|
60
|
+
```shell
|
61
|
+
$ pod tag 0.1.7 "修改podspec版本号为0.1.7" --prefix="mtxx" --suffix="beta1"
|
62
|
+
```
|
63
|
+
|
64
|
+
* 单独推送`podspec`到指定`spec repo`
|
65
|
+
|
66
|
+
```shell
|
67
|
+
$ pod tag spec-push REPO NAME.podspec
|
68
|
+
```
|
69
|
+
|
70
|
+
> 如有疑问,请使用`pod tag auto --help`查看帮助信息,里面有每个字段的解释
|
71
|
+
|
72
|
+
## 版本号
|
73
|
+
|
74
|
+
`CocoaPods`对版本号是有校验的,如果不符合规则当推送`podspec`到`spec repo`时会校验失败,具体校验正则如下:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
VERSION_PATTERN = '[0-9]+(?>\.[0-9a-zA-Z]+)*(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?'
|
78
|
+
ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/
|
79
|
+
```
|
34
80
|
|
35
|
-
|
81
|
+
大概解释一下就是:以`数字0-9`开头,中间可以包含`数字0-9`、`字母a-z A-Z`,特殊字符只能包含`.`和`-`,版本号前后可以有`0个或多个空格`
|
36
82
|
|
83
|
+
> 1. `cocoapods-tag`已经对版本号做了正则校验,不符合上面正则的版本号是无法通过的,这里写出来主要是为了提醒大家注意版本号的规范
|
84
|
+
> 2. 不建议版本号前后加空格
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'cocoapods-tag/tag'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Command
|
5
|
+
class Tag < Command
|
6
|
+
class Auto < Tag
|
7
|
+
include Pod
|
8
|
+
|
9
|
+
self.summary = '创建 tag 并 push 到远端仓库,同时可以上传 podspec 到 spec repo'
|
10
|
+
|
11
|
+
self.description = <<-DESC
|
12
|
+
#{self.summary}
|
13
|
+
|
14
|
+
`VERSION`: podspec中的version字段,如果没有prefix和suffix,version与tag一样【必填】\n
|
15
|
+
`COMMIT_MSG`: commit信息【必填】\n
|
16
|
+
`TAG_MSG`: tag信息【可选,默认为"v[tag号]",比如:tag是"0.0.1",则tag信息是"v0.0.1"】\n
|
17
|
+
|
18
|
+
e.g.\n
|
19
|
+
1.使用默认tag信息\n
|
20
|
+
pod tag 0.1.7 "修改podspec版本号为0.1.7"\n
|
21
|
+
2.使用自定义tag信息\n
|
22
|
+
pod tag 0.1.7 "修改podspec版本号为0.1.7" "版本0.1.7"\n
|
23
|
+
3.推送podspec到spec repo\n
|
24
|
+
pod tag 0.1.7 "修改podspec版本号为0.1.7" "版本0.1.7" --spec-repo=xxx\n
|
25
|
+
4.跳过耗时校验\n
|
26
|
+
pod tag 0.1.7 "修改podspec版本号为0.1.7" "版本0.1.7" --quick\n
|
27
|
+
5.指定工作目录\n
|
28
|
+
pod tag 0.1.7 "修改podspec版本号为0.1.7" --work-dir=xxx\n
|
29
|
+
6.为tag指定前后缀\n
|
30
|
+
pod tag 0.1.7 "修改podspec版本号为0.1.7" --prefix="xxx" --suffix="xxx"\n
|
31
|
+
7.指定tag推送到的远端仓库\n
|
32
|
+
pod tag 0.1.7 "修改podspec版本号为0.1.7" --remote=xxx
|
33
|
+
DESC
|
34
|
+
|
35
|
+
self.arguments = [
|
36
|
+
CLAide::Argument.new('VERSION', true ),
|
37
|
+
CLAide::Argument.new('COMMIT_MSG', true),
|
38
|
+
CLAide::Argument.new('TAG_MSG', false)
|
39
|
+
]
|
40
|
+
|
41
|
+
def self.options
|
42
|
+
[
|
43
|
+
['--quick', '跳过一些耗时校验,如:远端仓库是否已经有该tag'],
|
44
|
+
['--remote=REMOTE', '指定tag推送到的远端仓库,可以通过`git remote -v`查看'],
|
45
|
+
['--spec-repo=SPECREPO', 'podspec推送到的repo,可以通过`pod repo list`查看'],
|
46
|
+
['--work-dir=WORKDIR', '执行命令的工作区'],
|
47
|
+
['--prefix=PREFIX', 'tag前缀'],
|
48
|
+
['--suffix=SUFFIX', 'tag后缀']
|
49
|
+
].concat(super)
|
50
|
+
end
|
51
|
+
|
52
|
+
def initialize(argv)
|
53
|
+
@version = argv.shift_argument
|
54
|
+
@commit_msg = argv.shift_argument
|
55
|
+
@tag_msg = argv.shift_argument
|
56
|
+
@quick = argv.flag?('quick', false)
|
57
|
+
@remote = argv.option('remote', false)
|
58
|
+
@spec_repo = argv.option('spec-repo', nil)
|
59
|
+
@work_dir = argv.option('work-dir', nil)
|
60
|
+
@prefix = argv.option('prefix', nil)
|
61
|
+
@suffix = argv.option('suffix', nil)
|
62
|
+
@tag = @version
|
63
|
+
unless @prefix.nil?
|
64
|
+
@tag = "#{@prefix}-#{@tag}"
|
65
|
+
end
|
66
|
+
unless @suffix.nil?
|
67
|
+
@tag = "#{@tag}-#{@suffix}"
|
68
|
+
end
|
69
|
+
super
|
70
|
+
end
|
71
|
+
|
72
|
+
def run
|
73
|
+
# 传入了工作目录
|
74
|
+
unless @work_dir.nil?
|
75
|
+
raise Informative, "不存在工作目录`#{@work_dir}`" unless File.exist?(@work_dir)
|
76
|
+
Dir.chdir(@work_dir)
|
77
|
+
end
|
78
|
+
tag = Pod::Tag.new(@version, @tag, @commit_msg, @tag_msg, @spec_repo, @quick, @remote)
|
79
|
+
tag.create
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -10,7 +10,7 @@ module Pod
|
|
10
10
|
GIT_REPO = ".git".freeze
|
11
11
|
PODSPEC_EXT = %w[podspec podspec.json].freeze
|
12
12
|
|
13
|
-
self.summary = '
|
13
|
+
self.summary = '【问答的方式】创建 tag 并 push 到远端仓库,同时可以上传 podspec 到 spec repo'
|
14
14
|
|
15
15
|
self.description = <<-DESC
|
16
16
|
#{self.summary}
|
@@ -241,13 +241,13 @@ module Pod
|
|
241
241
|
print "推送commit到远端git仓库`#{@remote}/#{current_branch}`失败:#{e}".red
|
242
242
|
end
|
243
243
|
|
244
|
-
print "\n创建tag
|
244
|
+
print "\n创建tag:`#{@tag}`并推送至远端:\n".yellow
|
245
245
|
begin
|
246
246
|
`git tag -a #{@tag} -m #{@tag_msg}`
|
247
247
|
`git push #{@remote} --tags`
|
248
248
|
rescue Pod::StandardError => e
|
249
249
|
@error = e
|
250
|
-
print "创建tag
|
250
|
+
print "创建tag:`#{@tag}`并推送至远端失败:#{e}".red
|
251
251
|
end
|
252
252
|
end
|
253
253
|
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require 'cocoapods-tag/command/tag/
|
1
|
+
require 'cocoapods-tag/command/tag/auto'
|
2
|
+
# require 'cocoapods-tag/command/tag/create'
|
2
3
|
require 'cocoapods-tag/command/tag/spec_push'
|
3
4
|
|
4
5
|
module Pod
|
@@ -6,7 +7,7 @@ module Pod
|
|
6
7
|
class Tag < Command
|
7
8
|
|
8
9
|
self.abstract_command = true
|
9
|
-
self.default_subcommand = '
|
10
|
+
self.default_subcommand = 'auto'
|
10
11
|
|
11
12
|
self.summary = '🚀 方便地帮助 pod 库打 tag'
|
12
13
|
self.description = <<-DESC
|
@@ -0,0 +1,295 @@
|
|
1
|
+
require 'cocoapods-tag/helper/asker'
|
2
|
+
|
3
|
+
module Pod
|
4
|
+
class Tag
|
5
|
+
include Pod
|
6
|
+
|
7
|
+
GITHUB_DOMAIN = "github.com".freeze
|
8
|
+
GIT_REPO = ".git".freeze
|
9
|
+
PODSPEC_EXT = %w[podspec podspec.json].freeze
|
10
|
+
|
11
|
+
def initialize(version, tag, commit_msg, tag_msg, spec_repo = nil, quick = false, remote_name = nil)
|
12
|
+
@version = version || raise(Informative, "缺少必填参数`version`")
|
13
|
+
@tag = tag || raise(Informative, "缺少必填参数`tag`")
|
14
|
+
@commit_msg = commit_msg || raise(Informative, "缺少必填参数`commit_msg`")
|
15
|
+
@tag_msg = tag_msg || "v#{@tag}"
|
16
|
+
@spec_repo = spec_repo
|
17
|
+
@quick = quick
|
18
|
+
@remote = remote_name
|
19
|
+
end
|
20
|
+
|
21
|
+
public
|
22
|
+
|
23
|
+
def create
|
24
|
+
require 'cocoapods-tag/native/validator'
|
25
|
+
|
26
|
+
# 欢迎语
|
27
|
+
welcome_message
|
28
|
+
# 正则校验版本号
|
29
|
+
check_version
|
30
|
+
# 检查本地是否有 spec_repo
|
31
|
+
check_spec_repo if @spec_repo
|
32
|
+
# 检查 git repo
|
33
|
+
check_git_repo
|
34
|
+
# 加载 podspec
|
35
|
+
load_podspec
|
36
|
+
# 修改前校验 podspec
|
37
|
+
lint_podspec("\n修改前校验`#{podspec}`\n")
|
38
|
+
# 修改 podspec
|
39
|
+
modify_podspec
|
40
|
+
# 修改后校验 podspec
|
41
|
+
lint_podspec("\n修改后校验`#{podspec}`\n")
|
42
|
+
# 推送 commit 到远端
|
43
|
+
git_commit_push
|
44
|
+
# 推送 tag 到远端
|
45
|
+
git_tag_push
|
46
|
+
# 推送 podspec 到 spec repo
|
47
|
+
push_podspec_to_repo if @spec_repo
|
48
|
+
# 结束语
|
49
|
+
done_message
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def welcome_message
|
55
|
+
message = <<-MSG
|
56
|
+
👏🏻欢迎使用 `cocoapods-tag` 插件👏🏻
|
57
|
+
👏🏻version: #{CocoapodsTag::VERSION}👏🏻
|
58
|
+
|
59
|
+
MSG
|
60
|
+
print message.green
|
61
|
+
end
|
62
|
+
|
63
|
+
def done_message
|
64
|
+
print "\n🌺 恭喜你完成任务 🌺\n".green
|
65
|
+
end
|
66
|
+
|
67
|
+
# 正则校验版本号
|
68
|
+
def check_version
|
69
|
+
unless Pod::Vendor::Gem::Version.correct?(@version)
|
70
|
+
msg = <<-ERROR
|
71
|
+
版本号`#{@version}`格式不正确
|
72
|
+
版本号必须以数字`0-9`开头,可以包含数字`0-9`、字母`a-z A-Z`,特殊字符只能是`.`和`-`
|
73
|
+
具体请参考CocoaPods校验版本号的正则:
|
74
|
+
#{Pod::Vendor::Gem::Version::ANCHORED_VERSION_PATTERN}
|
75
|
+
ERROR
|
76
|
+
raise Informative, msg
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# 检查本地 spec_repo
|
81
|
+
def check_spec_repo
|
82
|
+
print "检查本地spec仓库\n".yellow
|
83
|
+
repos = `pod repo list`.split("\n").reject { |repo| repo == '' || repo =~ /^-/ }
|
84
|
+
unless repos.include?(@spec_repo)
|
85
|
+
raise Informative, "本地不存在`#{@spec_repo}`仓库,请先使用`pod repo add`添加该仓库或使用`pod repo list`查看其他仓库"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# 检查 git repo
|
90
|
+
def check_git_repo
|
91
|
+
print "检查本地git仓库\n".yellow
|
92
|
+
|
93
|
+
# 本地是否有 .git 目录
|
94
|
+
git_repo = File.join(Dir.pwd, GIT_REPO)
|
95
|
+
raise Informative, "`#{Dir.pwd}`不存在git仓库,请先使用`git init`初始化git仓库" unless File.exist?(git_repo)
|
96
|
+
|
97
|
+
# 是否与远端仓库关联
|
98
|
+
raise Informative, "本地git仓库没有与远端仓库关联,请先使用`git remote add`关联远端仓库" if remote.nil?
|
99
|
+
|
100
|
+
unless @quick
|
101
|
+
# 校验本地 git 是否与远端仓库同步
|
102
|
+
print "\n检查本地git仓库是否与远端仓库同步\n".yellow
|
103
|
+
local_commit = `git rev-parse #{remote}/HEAD`.chomp
|
104
|
+
remote_commit = `git ls-remote --head #{remote} #{current_branch}`.split("\t")[0]
|
105
|
+
unless local_commit == remote_commit
|
106
|
+
msg = <<-MSG
|
107
|
+
本地git仓库没有与远端仓库同步,请先执行以下操作:
|
108
|
+
1.`git pull`或`git fetch + git rebase`拉取最新代码
|
109
|
+
2.`git push`推送本地仓库commit
|
110
|
+
MSG
|
111
|
+
raise Informative, msg
|
112
|
+
end
|
113
|
+
|
114
|
+
# 检查本地是否已经有该 tag
|
115
|
+
print "\n检查本地仓库是否有tag:`#{@tag}`\n".yellow
|
116
|
+
raise Informative, "本地已经存在tag:#{@tag}" if `git tag`.split("\n").include?(@tag)
|
117
|
+
|
118
|
+
# 判断远端是否已经有该 tag
|
119
|
+
print "\n检查远端仓库是否有tag:`#{@tag}`\n".yellow
|
120
|
+
tags = `git ls-remote --tags #{remote}`.split("\n").select { |tag| tag.include?("refs/tags/#{@tag}") }
|
121
|
+
raise Informative, "远端仓库已经有该tag:#{@tag}" unless tags.empty?
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
# 加载 podspec
|
127
|
+
def load_podspec
|
128
|
+
raise Informative, "`#{Dir.pwd}`不存在podspec" if podspec.nil?
|
129
|
+
|
130
|
+
@spec = Specification.from_file(podspec)
|
131
|
+
raise Informative, "加载`#{podspec}`失败!" if @spec.nil?
|
132
|
+
|
133
|
+
@spec_hash = @spec.to_hash
|
134
|
+
source = @spec_hash['source']
|
135
|
+
# 目前只处理 git 这种形式
|
136
|
+
unless source['git']
|
137
|
+
raise Informative, "目前只能处理`git`这种形式"
|
138
|
+
end
|
139
|
+
# git字段为空
|
140
|
+
if source['git'] && source['git'].strip == ''
|
141
|
+
raise Informative, "source中git字段不能为空"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# 修改podspec
|
146
|
+
def modify_podspec
|
147
|
+
return if podspec.nil?
|
148
|
+
|
149
|
+
print "\n修改`#{podspec}`\n".yellow
|
150
|
+
file = File.join(Dir.pwd, "#{podspec}")
|
151
|
+
# 匹配文件名后缀
|
152
|
+
if podspec =~ /.podspec$/
|
153
|
+
modify_podspec_ruby(file)
|
154
|
+
elsif podspec =~ /.podspec.json$/
|
155
|
+
modify_podspec_json(file)
|
156
|
+
end
|
157
|
+
print "`#{podspec}` modified done\n"
|
158
|
+
end
|
159
|
+
|
160
|
+
# 修改 *.podspec
|
161
|
+
def modify_podspec_ruby(file)
|
162
|
+
org_source = @spec_hash['source']
|
163
|
+
des_source = "{ :git => '#{org_source['git']}', :tag => '#{@tag}' }"
|
164
|
+
File.open(file, 'r') do |f|
|
165
|
+
lines = []
|
166
|
+
f.each_line do |line|
|
167
|
+
if line =~ /(^\s*.+\.version\s*=\s*).*/
|
168
|
+
line = line.sub(/(^\s*.+\.version\s*=\s*).*/, "#{$1}'#{@version}'")
|
169
|
+
end
|
170
|
+
if line =~ /(^\s*.+\.source\s*=\s*).*/
|
171
|
+
line = line.sub(/(^\s*.+\.source\s*=\s*).*/, "#{$1}#{des_source}")
|
172
|
+
end
|
173
|
+
lines << line
|
174
|
+
end
|
175
|
+
File.open(file, 'w') do |f|
|
176
|
+
f.write(lines.join(""))
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
# 修改 *.podspec.json
|
182
|
+
def modify_podspec_json(file)
|
183
|
+
@spec_hash['version'] = @version
|
184
|
+
@spec_hash['source'] = {
|
185
|
+
'git'=> @spec_hash['source']['git'],
|
186
|
+
'tag'=> "#{@tag}"
|
187
|
+
}
|
188
|
+
File.open(file, 'w') do |f|
|
189
|
+
f.write(@spec_hash)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
# 推送 commit
|
194
|
+
def git_commit_push
|
195
|
+
print "\n推送commit到远端git仓库`#{remote}/#{current_branch}`\n".yellow
|
196
|
+
begin
|
197
|
+
`git add #{podspec}`
|
198
|
+
`git commit -m "#{@commit_msg}"`
|
199
|
+
`git push #{remote} #{current_branch}`
|
200
|
+
rescue Pod::StandardError => e
|
201
|
+
@error = e
|
202
|
+
print "推送commit到远端git仓库`#{remote}/#{current_branch}`失败:#{e}".red
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
# 推送 tag 到远端
|
207
|
+
def git_tag_push
|
208
|
+
print "\n创建tag:`#{@tag}`并推送至远端`#{remote}`\n".yellow
|
209
|
+
begin
|
210
|
+
`git tag -a #{@tag} -m "#{@tag_msg}"`
|
211
|
+
`git push #{remote} #{@tag}`
|
212
|
+
rescue Pod::StandardError => e
|
213
|
+
@error = e
|
214
|
+
print "创建tag:`#{@tag}`并推送至远端失败:#{e}".red
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
# 推送 podspec 到 spec repo
|
219
|
+
def push_podspec_to_repo
|
220
|
+
print "\n推送`#{podspec}`到`#{@spec_repo}`仓库\n".yellow
|
221
|
+
argvs = [
|
222
|
+
@spec_repo,
|
223
|
+
podspec,
|
224
|
+
'--allow-warnings'
|
225
|
+
]
|
226
|
+
begin
|
227
|
+
push = Pod::Command::Repo::Push.new(CLAide::ARGV.new(argvs))
|
228
|
+
push.validate!
|
229
|
+
push.run
|
230
|
+
rescue Pod::StandardError => e
|
231
|
+
@error = e
|
232
|
+
print "推送`#{podspec}`到`#{@spec_repo}`仓库失败!#{e}".red
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
# 校验 podspec
|
237
|
+
def lint_podspec(tip = "\n校验`#{podspec}`\n")
|
238
|
+
print "#{tip}".yellow
|
239
|
+
argvs = [
|
240
|
+
podspec,
|
241
|
+
'--quick',
|
242
|
+
'--allow-warnings'
|
243
|
+
]
|
244
|
+
lint = Pod::Command::Spec::Lint.new(CLAide::ARGV.new(argvs))
|
245
|
+
lint.validate!
|
246
|
+
lint.run
|
247
|
+
end
|
248
|
+
|
249
|
+
# 获取当前分支
|
250
|
+
def current_branch
|
251
|
+
@current_branch ||= begin
|
252
|
+
`git branch`.split(' ')[1]
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
# 获取当前目录下的 podspec
|
257
|
+
def podspec
|
258
|
+
@podspec ||= begin
|
259
|
+
podspec = nil
|
260
|
+
podspecs = Dir.glob("*.{#{PODSPEC_EXT.join(',')}}")
|
261
|
+
unless podspecs.empty?
|
262
|
+
podspec = podspecs.first
|
263
|
+
end
|
264
|
+
podspec
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
def asker
|
269
|
+
@asker ||= begin
|
270
|
+
Helper::Asker.new()
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
# 获取远端仓库名
|
275
|
+
def remote
|
276
|
+
@remote ||= begin
|
277
|
+
remote = nil
|
278
|
+
remotes = `git remote`.split("\n")
|
279
|
+
remote = remotes.first unless remotes.empty?
|
280
|
+
if remotes.size > 1
|
281
|
+
count = 0
|
282
|
+
selections = {}
|
283
|
+
remotes.map do |r|
|
284
|
+
count += 1
|
285
|
+
selections["#{count}"] = r
|
286
|
+
end
|
287
|
+
key = asker.ask("\n本地有多个关联的远端仓库,请选择:", true, nil, selections)
|
288
|
+
remote = remotes["#{key}".to_i - 1]
|
289
|
+
end
|
290
|
+
remote
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
end
|
295
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-tag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cocoapods
|
@@ -64,11 +64,13 @@ files:
|
|
64
64
|
- lib/cocoapods-tag.rb
|
65
65
|
- lib/cocoapods-tag/command.rb
|
66
66
|
- lib/cocoapods-tag/command/tag.rb
|
67
|
+
- lib/cocoapods-tag/command/tag/auto.rb
|
67
68
|
- lib/cocoapods-tag/command/tag/create.rb
|
68
69
|
- lib/cocoapods-tag/command/tag/spec_push.rb
|
69
70
|
- lib/cocoapods-tag/gem_version.rb
|
70
71
|
- lib/cocoapods-tag/helper/asker.rb
|
71
72
|
- lib/cocoapods-tag/native/validator.rb
|
73
|
+
- lib/cocoapods-tag/tag.rb
|
72
74
|
- lib/cocoapods_plugin.rb
|
73
75
|
- spec/command/tag_spec.rb
|
74
76
|
- spec/spec_helper.rb
|