cocoapods-dev-env 0.2.4 → 0.9.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 +4 -4
- data/README.md +5 -0
- data/lib/cocoapods/dev/env/version.rb +1 -1
- data/lib/cocoapods_plugin.rb +123 -36
- 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: 7ca8013b453d1e257cce0f668f9d55b690728054807b87d80307d234e33bb651
|
4
|
+
data.tar.gz: 24604dcbcdef57ce2cf10a2a0e376e417e3eb3336664a8dbb086d299ba7822d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 650079c36c495a2a9384972b92a40ffc770031c4158914e54e1e7e69c45e2937b88a3080d5dbb7eaa13b9aaed248aea545cd6383acaef36613f82d684d3ea1d9
|
7
|
+
data.tar.gz: 7f30ffe0691428cc7b50ebbfb86c6b3d3d77ede2b6edd657fc3fb7d44b002cfff1735f65c095c3a518a2288760a85c515138a9a8e08d7ebed440740430e2749d
|
data/README.md
CHANGED
@@ -54,6 +54,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
54
54
|
|
55
55
|
Bug reports and pull requests are welcome on GitHub at https://github.com/YoudaoMobile/cocoapods-dev-env. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
56
56
|
|
57
|
+
1. How to develop: put gem in your project and exec `bundle exec pod install`
|
58
|
+
2. How to packagae: `rake build`
|
59
|
+
3. How to release: `rake release` or `gem push ./pkg/cocoapods-dev-env-0.2.2.gem`
|
60
|
+
|
61
|
+
|
57
62
|
## License
|
58
63
|
|
59
64
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
Pod::HooksManager.register('cocoapods-dev-env', :pre_install) do |installer|
|
2
2
|
podfile = installer.podfile
|
3
3
|
#puts installer.instance_variables
|
4
|
+
# forbidden submodule not cloned
|
5
|
+
`
|
6
|
+
git submodule update --init --recursive
|
7
|
+
`
|
4
8
|
end
|
5
9
|
|
6
10
|
Pod::HooksManager.register('cocoapods-dev-env', :post_install) do |installer|
|
@@ -16,6 +20,7 @@ module Pod
|
|
16
20
|
def self.keyword
|
17
21
|
:dev_env # 'dev'/'beta'/'release'
|
18
22
|
end
|
23
|
+
puts "🎉 plugin cocoapods-dev-env loaded 🎉".green
|
19
24
|
end
|
20
25
|
class Podfile
|
21
26
|
class TargetDefinition
|
@@ -46,7 +51,11 @@ class Podfile
|
|
46
51
|
Dir.chdir(path)
|
47
52
|
result = `git describe --abbrev=4 HEAD`
|
48
53
|
Dir.chdir(currentDir)
|
49
|
-
|
54
|
+
if result.include?(tag)
|
55
|
+
return true
|
56
|
+
else
|
57
|
+
return checkTagOrBranchIsEqalToHead(tag, path)
|
58
|
+
end
|
50
59
|
end
|
51
60
|
|
52
61
|
# 这个函数有问题有时候拿不到相同的commit id
|
@@ -60,13 +69,69 @@ class Podfile
|
|
60
69
|
return (headCommitID.length > 0 && headCommitID == tagCommitID)
|
61
70
|
end
|
62
71
|
|
72
|
+
def checkGitStatusAndPush(pod_name)
|
73
|
+
output = `git status -s`
|
74
|
+
puts output
|
75
|
+
if output.length == 0
|
76
|
+
output = `git status`
|
77
|
+
if output.include?("push")
|
78
|
+
ret = system("git push")
|
79
|
+
if ret != true
|
80
|
+
raise "💔 #{pod_name.yellow} push 失败"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
else
|
84
|
+
raise "💔 #{pod_name.yellow} 有未提交的数据"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def addGitTagAndPush(tag, pod_name)
|
89
|
+
ret = system("git tag #{tag}")
|
90
|
+
if ret == true
|
91
|
+
ret = system("git push origin #{tag}")
|
92
|
+
if ret != true
|
93
|
+
raise "💔 #{pod_name.yellow} push tag 失败"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
return ret
|
97
|
+
end
|
98
|
+
|
99
|
+
def inputNeedJumpForReson(str)
|
100
|
+
puts str
|
101
|
+
puts '是(Y), 否(N)'
|
102
|
+
input = STDIN.gets
|
103
|
+
if input[0,1] == "Y"
|
104
|
+
return true
|
105
|
+
else
|
106
|
+
return false
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def getUserRepoAddress()
|
111
|
+
if podfile.sources.size == 0
|
112
|
+
raise "💔 发布release必须配置仓库的地址, e.g.: source 'https://github.com/CocoaPods/Specs.git'"
|
113
|
+
end
|
114
|
+
index = nil
|
115
|
+
begin
|
116
|
+
UI.puts "\n\n⌨️ 请输入要发布到的cocoapods仓库序号, 按回车确认: ".yellow
|
117
|
+
num = 1
|
118
|
+
podfile.sources.each do |source|
|
119
|
+
UI.puts "#{num.to_s.yellow}. #{source.green}"
|
120
|
+
num += 1
|
121
|
+
end
|
122
|
+
index = STDIN.gets.to_i - 1
|
123
|
+
end until (index >= 0 && index < podfile.sources.size)
|
124
|
+
source = podfile.sources[index]
|
125
|
+
return source
|
126
|
+
end
|
127
|
+
|
63
128
|
## --- option for setting using prebuild framework ---
|
64
129
|
def parse_pod_dev_env(name, requirements)
|
65
130
|
options = requirements.last
|
66
131
|
pod_name = Specification.root_name(name)
|
67
132
|
last_options = $processedPodsOptions[pod_name]
|
68
133
|
if (last_options != nil)
|
69
|
-
UI.
|
134
|
+
UI.message "#{name.green} use last_options: #{last_options.to_s.green}"
|
70
135
|
if options != nil && options.is_a?(Hash)
|
71
136
|
requirements[requirements.length - 1] = last_options
|
72
137
|
else
|
@@ -80,7 +145,7 @@ class Podfile
|
|
80
145
|
if dev_env == nil
|
81
146
|
return
|
82
147
|
end
|
83
|
-
UI.
|
148
|
+
UI.message "pod #{name.green} dev-env: #{dev_env.green}"
|
84
149
|
git = options.delete(:git)
|
85
150
|
branch = options.delete(:branch)
|
86
151
|
tag = options.delete(:tag)
|
@@ -88,57 +153,49 @@ class Podfile
|
|
88
153
|
if path == nil
|
89
154
|
path = "./developing_pods/#{pod_name}"
|
90
155
|
end
|
156
|
+
if git == nil || git.length == 0
|
157
|
+
raise "💔 #{pod_name.yellow} 未定义:git => 'xxx'库地址"
|
158
|
+
end
|
159
|
+
if branch == nil || branch.length == 0
|
160
|
+
raise "💔 #{pod_name.yellow} 未定义:branch => 'xxx'"
|
161
|
+
end
|
162
|
+
if tag == nil || tag.length == 0
|
163
|
+
raise "💔 #{pod_name.yellow} 未定义:tag => 'xxx', tag 将会作为 dev模式下载最新代码检查的依据,beta模式引用的tag 以及 release模式引用的版本号"
|
164
|
+
end
|
91
165
|
if dev_env == 'dev'
|
92
166
|
# 开发模式,使用path方式引用本地的submodule git库
|
93
167
|
if !File.directory?(path)
|
94
|
-
UI.puts "
|
168
|
+
UI.puts "add submodule for #{pod_name.green}".yellow
|
169
|
+
# TODO 这个命令要想办法展示实际报错信息
|
95
170
|
`git submodule add --force -b #{branch} #{git} #{path}`
|
96
171
|
|
97
172
|
if !checkTagIsEqualToHead(tag, path) && !checkTagIsEqualToHead("#{tag}_beta", path)
|
98
|
-
raise "#{pod_name} branch:#{branch} 与 tag:#{tag}[_beta] 内容不同步,请自行确认所用分支和tag后重新执行 pod install"
|
173
|
+
raise "💔 #{pod_name.yellow} branch:#{branch.yellow} 与 tag:#{tag.yellow}[_beta] 内容不同步,请自行确认所用分支和tag后重新执行 pod install"
|
99
174
|
end
|
100
175
|
end
|
101
176
|
options[:path] = path
|
102
177
|
if requirements.length >= 2
|
103
178
|
requirements.delete_at(0)
|
104
179
|
end
|
105
|
-
UI.
|
180
|
+
UI.message "enabled #{"dev".green}-mode for #{pod_name.green}"
|
106
181
|
elsif dev_env == 'beta'
|
107
182
|
# Beta模式,使用tag引用远端git库的代码
|
108
183
|
tag = "#{tag}_beta"
|
109
184
|
if File.directory?(path)
|
110
185
|
# 从Dev模式刚刚切换过来,需要打tag并且push
|
111
|
-
UI.puts "
|
112
|
-
if tag == nil || tag.length == 0
|
113
|
-
raise "#{pod_name} 未定义tag"
|
114
|
-
end
|
186
|
+
UI.puts "release beta-version for #{pod_name.green}".yellow
|
115
187
|
currentDir = Dir.pwd
|
116
188
|
Dir.chdir(path)
|
117
|
-
|
118
|
-
puts output
|
119
|
-
if output.length == 0
|
120
|
-
output = `git status`
|
121
|
-
if output.include?("push")
|
122
|
-
ret = system("git push")
|
123
|
-
if ret != true
|
124
|
-
raise "#{pod_name} push 失败"
|
125
|
-
end
|
126
|
-
end
|
127
|
-
else
|
128
|
-
raise "有未提交的数据"
|
129
|
-
end
|
189
|
+
checkGitStatusAndPush(pod_name)
|
130
190
|
## TODO:: 检查tag版本号与podspec里的版本号是否一致
|
131
|
-
ret =
|
132
|
-
if ret
|
133
|
-
ret = system("git push origin #{tag}")
|
134
|
-
if ret != true
|
135
|
-
raise "#{pod_name} push tag 失败"
|
136
|
-
end
|
137
|
-
else
|
191
|
+
ret = addGitTagAndPush(tag, pod_name)
|
192
|
+
if ret != true
|
138
193
|
if checkTagOrBranchIsEqalToHead(tag, "./")
|
139
|
-
UI.puts "#{pod_name} 没做任何调整,切换回beta"
|
194
|
+
UI.puts "#{pod_name.green} 没做任何调整,切换回beta"
|
140
195
|
else
|
141
|
-
|
196
|
+
if !inputNeedJumpForReson("是否跳过beta发布并删除本地submodule(直接引用远端库)")
|
197
|
+
raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 请确认已经手动修改tag版本号"
|
198
|
+
end
|
142
199
|
end
|
143
200
|
end
|
144
201
|
Dir.chdir(currentDir)
|
@@ -149,15 +206,45 @@ class Podfile
|
|
149
206
|
if requirements.length >= 2
|
150
207
|
requirements.delete_at(0)
|
151
208
|
end
|
152
|
-
UI.
|
209
|
+
UI.message "enabled #{"beta".green}-mode for #{pod_name.green}"
|
153
210
|
elsif dev_env == 'release'
|
154
211
|
# Release模式,直接使用远端对应的版本
|
155
|
-
# 需要考虑从dev直接跳跃到release的情况,需要谨慎处理,给予报错或执行两次的操作
|
156
212
|
if File.directory?(path)
|
213
|
+
UI.puts "release release-version for #{pod_name.green}".yellow
|
214
|
+
currentDir = Dir.pwd
|
215
|
+
Dir.chdir(path)
|
216
|
+
ret = system("pod lib lint --allow-warnings")
|
217
|
+
if ret != true
|
218
|
+
raise "💔 #{pod_name.yellow} lint 失败"
|
219
|
+
end
|
220
|
+
checkGitStatusAndPush(pod_name)
|
221
|
+
## TODO:: 检查tag版本号与podspec里的版本号是否一致
|
222
|
+
ret = addGitTagAndPush(tag, pod_name)
|
223
|
+
if ret == false
|
224
|
+
if checkTagOrBranchIsEqalToHead(tag, "./")
|
225
|
+
UI.puts "#{pod_name.green} 已经打过tag".yellow
|
226
|
+
else
|
227
|
+
raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 请确认已经手动修改tag版本号"
|
228
|
+
end
|
229
|
+
end
|
230
|
+
## TODO:: 发布到的目标库名称需要用变量设置
|
231
|
+
repoAddrs = getUserRepoAddress()
|
232
|
+
cmd = "pod repo push #{repoAddrs} #{pod_name}.podspec --allow-warnings"
|
233
|
+
ret = system(cmd)
|
234
|
+
if ret != true
|
235
|
+
raise "💔 #{pod_name.yellow} 发布失败"
|
236
|
+
end
|
237
|
+
## 到最后统一执行,判断如果当次release过
|
238
|
+
`pod repo update`
|
239
|
+
Dir.chdir(currentDir)
|
157
240
|
checkAndRemoveSubmodule(path)
|
158
241
|
end
|
242
|
+
if requirements.length < 2
|
243
|
+
requirements.insert(0, "#{tag}")
|
244
|
+
end
|
245
|
+
UI.message "enabled #{"release".green}-mode for #{pod_name.green}"
|
159
246
|
else
|
160
|
-
raise ":dev_env 必须要设置成 dev/beta/release之一,不接受其他值"
|
247
|
+
raise "💔 :dev_env 必须要设置成 dev/beta/release之一,不接受其他值"
|
161
248
|
end
|
162
249
|
$processedPodsOptions[pod_name] = options
|
163
250
|
requirements.pop if options.empty?
|
@@ -174,4 +261,4 @@ class Podfile
|
|
174
261
|
end
|
175
262
|
end
|
176
263
|
end
|
177
|
-
end
|
264
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-dev-env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 吴锡苗
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|