cocoapods-dev-env 2.1.8 → 2.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cocoapods/dev/env/version.rb +1 -1
- data/lib/cocoapods_plugin.rb +3 -617
- data/lib/dev_env_entry.rb +389 -0
- data/lib/dev_env_utils.rb +169 -0
- data/lib/resolver_binary.rb +116 -0
- data/lib/resolver_universal_dependency.rb +127 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1282e851ae9b54c7bd13e7e05fe72de11a5a56662e1ecdc3af66745eb752e1d
|
4
|
+
data.tar.gz: 30f1d0e013d4d56f9f4ff6ea165f6e60d0b8e2a5385a8df85695872e7935507b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f7628345e1abff5bddcd84d006a11e98e13d2b3cf8b03ab6c15f3e90760ea4087ecc12952544c89960ded37ddf76108133516b0f8097b4259325f0712a8889f
|
7
|
+
data.tar.gz: 7036a12b59e37c374a8377836a5968bf56424ad16b1e9f7d2adb4526b589ebd45c86da355fd8febdceac61f3459eb368425b22429d48c53917f94c412147cb9e
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -1,617 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require '
|
4
|
-
require 'luna-binary-uploader'
|
5
|
-
|
6
|
-
Pod::HooksManager.register('cocoapods-dev-env', :pre_install) do |installer|
|
7
|
-
# puts installer.instance_variables
|
8
|
-
# forbidden submodule not cloned
|
9
|
-
# 会引起submodule HEAD回滚,不靠谱,先注释掉
|
10
|
-
# `
|
11
|
-
# git submodule update --init --recursive
|
12
|
-
# `
|
13
|
-
end
|
14
|
-
|
15
|
-
Pod::HooksManager.register('cocoapods-dev-env', :post_install) do |installer|
|
16
|
-
# puts installer.instance_variables
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
$processedPodsState = Hash.new
|
21
|
-
$processedPodsOptions = Hash.new
|
22
|
-
|
23
|
-
$podFileContentPodNameHash = Hash.new
|
24
|
-
|
25
|
-
$parentPodlockDependencyHash = Hash.new
|
26
|
-
|
27
|
-
$processedParentPods = Hash.new # 从父项目里读出来的pod当次已经下载或者加载过了就不需要再做一遍
|
28
|
-
|
29
|
-
$parrentPath = '../../../'
|
30
|
-
|
31
|
-
module Pod
|
32
|
-
class Dependency
|
33
|
-
def setRequirement(requirement)
|
34
|
-
@requirement = requirement
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
module Pod
|
41
|
-
|
42
|
-
class Resolver
|
43
|
-
|
44
|
-
def search_for(dependency)
|
45
|
-
UI.message "fake search_for" + dependency.inspect
|
46
|
-
if $podFileContentPodNameHash.has_key?(dependency.root_name)
|
47
|
-
# 双重保证已经存在在pofile里的不再重复下载覆盖成父项目的配置
|
48
|
-
UI.message "parrent extenal source has downloaded"
|
49
|
-
else
|
50
|
-
parentPodInfo = $parentPodlockDependencyHash[dependency.root_name]
|
51
|
-
if parentPodInfo != nil
|
52
|
-
dependency.external_source = parentPodInfo.external_source
|
53
|
-
dependency.setRequirement(parentPodInfo.requirement)
|
54
|
-
#dependency.external_source = Hash[:path => '../../ZYSDK']
|
55
|
-
# dependency.external_source = Hash.new
|
56
|
-
UI.message "fake create_set_from_sources, changeexternal:" + dependency.inspect
|
57
|
-
dep = dependency
|
58
|
-
if !$processedParentPods.has_key?(dependency.root_name) && dependency.external_source != nil
|
59
|
-
$processedParentPods[dependency.root_name] = true
|
60
|
-
# 这里有缺陷: 已经下载过的不需要再下载了,但是不下载又进不到系统里,导致最后没有使用指定的依赖
|
61
|
-
# 这个没用 podfile.pod(dependency.root_name, dependency.external_source)
|
62
|
-
# if sandbox.specification_path(dep.root_name).nil? ||
|
63
|
-
# !dep.external_source[:path].nil? ||
|
64
|
-
# !sandbox.pod_dir(dep.root_name).directory? ||
|
65
|
-
# checkout_requires_update?(dep)
|
66
|
-
# # 已经存在就不再下载
|
67
|
-
source = ExternalSources.from_dependency(dependency, podfile.defined_in_file, true)
|
68
|
-
source.fetch(sandbox)
|
69
|
-
# end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
aggregate_for_dependency(dependency).search(dependency)
|
75
|
-
|
76
|
-
@search[dependency] ||= begin
|
77
|
-
additional_requirements = if locked_requirement = requirement_for_locked_pod_named(dependency.name)
|
78
|
-
[locked_requirement]
|
79
|
-
else
|
80
|
-
Array(@podfile_requirements_by_root_name[dependency.root_name])
|
81
|
-
end
|
82
|
-
|
83
|
-
specifications_for_dependency(dependency, additional_requirements).freeze
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
class DevEnv
|
89
|
-
def self.keyword
|
90
|
-
:dev_env # 'dev'/'beta'/'release'
|
91
|
-
end
|
92
|
-
def self.binary_key
|
93
|
-
:dev_env_use_binary # true / false
|
94
|
-
end
|
95
|
-
UI.message "🎉 plugin cocoapods-dev-env loaded 🎉".green
|
96
|
-
end
|
97
|
-
class Podfile
|
98
|
-
module DSL
|
99
|
-
def use_parent_lock_info!(option = true)
|
100
|
-
case option
|
101
|
-
when true, false
|
102
|
-
if !option
|
103
|
-
$parrentPath = ''
|
104
|
-
TargetDefinition.cleanParrentLockFile()
|
105
|
-
end
|
106
|
-
when Hash
|
107
|
-
$parrentPath = option.fetch(:path)
|
108
|
-
TargetDefinition.readParrentLockFile()
|
109
|
-
else
|
110
|
-
raise ArgumentError, "Got `#{option.inspect}`, should be a boolean or hash."
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
class TargetDefinition
|
116
|
-
attr_reader :binary_repo_url
|
117
|
-
attr_reader :binary_source
|
118
|
-
|
119
|
-
def searchAndOpenLocalExample(path)
|
120
|
-
_currentDir = Dir.pwd
|
121
|
-
Dir.chdir(path)
|
122
|
-
Dir.chdir("Example")
|
123
|
-
`pod install`
|
124
|
-
projPaths = Dir::glob("*.xcworkspace")
|
125
|
-
if projPaths.count > 0
|
126
|
-
`open -a Terminal ./`
|
127
|
-
`open #{projPaths[0]}`
|
128
|
-
end
|
129
|
-
Dir.chdir(_currentDir)
|
130
|
-
end
|
131
|
-
|
132
|
-
def checkAndRemoveSubmodule(path)
|
133
|
-
_currentDir = Dir.pwd
|
134
|
-
Dir.chdir(path)
|
135
|
-
output = `git status -s`
|
136
|
-
puts output
|
137
|
-
if output.length == 0
|
138
|
-
output = `git status`
|
139
|
-
if output.include?("push")
|
140
|
-
raise "submodule #{path} 移除失败,有推送的修改"
|
141
|
-
end
|
142
|
-
else
|
143
|
-
raise "submodule #{path} 移除失败,有未提交的修改"
|
144
|
-
end
|
145
|
-
Dir.chdir(_currentDir)
|
146
|
-
`
|
147
|
-
git submodule deinit #{path}
|
148
|
-
rm -rf #{path}
|
149
|
-
git rm #{path}
|
150
|
-
`
|
151
|
-
end
|
152
|
-
|
153
|
-
def checkTagIsEqualToHead(tag, path)
|
154
|
-
_currentDir = Dir.pwd
|
155
|
-
Dir.chdir(path)
|
156
|
-
result = `git describe --abbrev=4 HEAD`
|
157
|
-
Dir.chdir(_currentDir)
|
158
|
-
if result.include?(tag)
|
159
|
-
return true
|
160
|
-
else
|
161
|
-
return checkTagOrBranchIsEqalToHead(tag, path)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
# 这个函数有问题有时候拿不到相同的commit id
|
166
|
-
def checkTagOrBranchIsEqalToHead(branchOrTag, path)
|
167
|
-
_currentDir = Dir.pwd
|
168
|
-
Dir.chdir(path)
|
169
|
-
headCommitID = `git rev-parse HEAD`
|
170
|
-
tagCommitID = `git rev-parse #{branchOrTag}`
|
171
|
-
UI.puts "#{`pwd`} headCommitID:#{headCommitID} \n #{branchOrTag}ComitID:#{tagCommitID}"
|
172
|
-
Dir.chdir(_currentDir)
|
173
|
-
return (headCommitID.length > 0 && headCommitID == tagCommitID)
|
174
|
-
end
|
175
|
-
|
176
|
-
def checkGitStatusAndPush(pod_name)
|
177
|
-
output = `git status -s`
|
178
|
-
puts output
|
179
|
-
if output.length == 0
|
180
|
-
output = `git status`
|
181
|
-
if output.include?("push")
|
182
|
-
ret = system("git push")
|
183
|
-
if ret != true
|
184
|
-
raise "💔 #{pod_name.yellow} push 失败"
|
185
|
-
end
|
186
|
-
end
|
187
|
-
else
|
188
|
-
raise "💔 #{pod_name.yellow} 有未提交的数据"
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
def checkRemoteTagExist(tag)
|
193
|
-
`git push --tags`
|
194
|
-
ret = system("git ls-remote --exit-code origin refs/tags/#{tag}")
|
195
|
-
return ret
|
196
|
-
end
|
197
|
-
|
198
|
-
def addGitTagAndPush(tag, pod_name)
|
199
|
-
ret = system("git tag #{tag}")
|
200
|
-
if ret == true
|
201
|
-
ret = system("git push origin #{tag}")
|
202
|
-
if ret != true
|
203
|
-
raise "💔 #{pod_name.yellow} push tag 失败"
|
204
|
-
end
|
205
|
-
end
|
206
|
-
return ret
|
207
|
-
end
|
208
|
-
|
209
|
-
def inputNeedJumpForReson(str)
|
210
|
-
if ARGV.include? '--silent'
|
211
|
-
return false
|
212
|
-
end
|
213
|
-
|
214
|
-
puts str.green
|
215
|
-
puts '是(Y), 任意其他输入或直接回车跳过'.green
|
216
|
-
input = STDIN.gets
|
217
|
-
if input[0,1] == "Y"
|
218
|
-
return true
|
219
|
-
else
|
220
|
-
return false
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
def getReposStrForLint()
|
225
|
-
if podfile.sources.size == 0
|
226
|
-
return ""
|
227
|
-
end
|
228
|
-
str = " --sources="
|
229
|
-
podfile.sources.each do |source|
|
230
|
-
str += source
|
231
|
-
str += ","
|
232
|
-
end
|
233
|
-
UI.puts str
|
234
|
-
return str
|
235
|
-
end
|
236
|
-
|
237
|
-
def getUserRepoAddress()
|
238
|
-
if podfile.sources.size == 0
|
239
|
-
raise "💔 发布release必须配置仓库的地址, e.g.: source 'https://github.com/CocoaPods/Specs.git'"
|
240
|
-
end
|
241
|
-
index = nil
|
242
|
-
begin
|
243
|
-
UI.puts "\n\n⌨️ 请输入要发布到的cocoapods仓库序号, 按回车确认: ".yellow
|
244
|
-
num = 1
|
245
|
-
podfile.sources.each do |source|
|
246
|
-
UI.puts "#{num.to_s.yellow}. #{source.green}"
|
247
|
-
num += 1
|
248
|
-
end
|
249
|
-
index = STDIN.gets.to_i - 1
|
250
|
-
end until (index >= 0 && index < podfile.sources.size)
|
251
|
-
source = podfile.sources[index]
|
252
|
-
UI.puts "#{"选择了发布到: ".yellow}. #{source.green}(#{index + 1})"
|
253
|
-
return source
|
254
|
-
end
|
255
|
-
|
256
|
-
def changeVersionInCocoapods(name, newVersion)
|
257
|
-
if (newVersion == nil)
|
258
|
-
UI.puts "💔 切换版本号的版本现在为空,无法设置版本号".yellow
|
259
|
-
return
|
260
|
-
end
|
261
|
-
newVersion = get_pure_version(newVersion)
|
262
|
-
specName = name + ".podspec"
|
263
|
-
FileProcesserManager.new(specName,
|
264
|
-
[
|
265
|
-
FileProcesser.new(-> (fileContent) {
|
266
|
-
return fileContent.gsub(/(\.version *= *')(.*')/, "\\1" + newVersion + "'")
|
267
|
-
})
|
268
|
-
]).process()
|
269
|
-
`git add #{specName}
|
270
|
-
git commit -m "Mod: 修改版本号为:#{newVersion} by cocoapods_dev_env plugin"`
|
271
|
-
end
|
272
|
-
|
273
|
-
## --- hook的入口函数 ---
|
274
|
-
def parse_pod_dev_env(name, requirements)
|
275
|
-
options = requirements.last
|
276
|
-
pod_name = Specification.root_name(name)
|
277
|
-
last_options = $processedPodsOptions[pod_name]
|
278
|
-
$podFileContentPodNameHash[pod_name] = true
|
279
|
-
|
280
|
-
if (last_options != nil)
|
281
|
-
UI.message "#{name.green} use last_options: #{last_options.to_s.green}"
|
282
|
-
if options != nil && options.is_a?(Hash)
|
283
|
-
requirements[requirements.length - 1] = last_options
|
284
|
-
else
|
285
|
-
requirements.push(last_options)
|
286
|
-
end
|
287
|
-
elsif options.is_a?(Hash)
|
288
|
-
use_binary = options.delete(Pod::DevEnv::binary_key)
|
289
|
-
dev_env = options.delete(Pod::DevEnv::keyword)
|
290
|
-
|
291
|
-
# 主功能,根据dev_env标记来管理使用代码的方式
|
292
|
-
deal_dev_env_with_options(dev_env, options, pod_name, name, requirements)
|
293
|
-
|
294
|
-
# 处理二进制
|
295
|
-
if dev_env != 'dev'
|
296
|
-
binary_processer(dev_env, pod_name, use_binary, options, requirements)
|
297
|
-
end
|
298
|
-
|
299
|
-
|
300
|
-
if dev_env || use_binary
|
301
|
-
$processedPodsOptions[pod_name] = options.clone
|
302
|
-
requirements.pop if options.empty?
|
303
|
-
end
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
## --- 主功能函数 ---
|
308
|
-
def deal_dev_env_with_options(dev_env, options, pod_name, name, requirements)
|
309
|
-
if dev_env == nil
|
310
|
-
return
|
311
|
-
end
|
312
|
-
UI.message "pod #{name.green} dev-env: #{dev_env.green}"
|
313
|
-
git = options.delete(:git)
|
314
|
-
branch = options.delete(:branch)
|
315
|
-
tag = options.delete(:tag)
|
316
|
-
path = options.delete(:path)
|
317
|
-
if path == nil
|
318
|
-
path = "./developing_pods/#{pod_name}"
|
319
|
-
end
|
320
|
-
if git == nil || git.length == 0
|
321
|
-
raise "💔 #{pod_name.yellow} 未定义:git => 'xxx'库地址"
|
322
|
-
end
|
323
|
-
if branch == nil || branch.length == 0
|
324
|
-
raise "💔 #{pod_name.yellow} 未定义:branch => 'xxx'"
|
325
|
-
end
|
326
|
-
if tag == nil || tag.length == 0
|
327
|
-
raise "💔 #{pod_name.yellow} 未定义:tag => 'xxx', tag 将会作为 dev模式下载最新代码检查的依据,beta模式引用的tag 以及 release模式引用的版本号"
|
328
|
-
end
|
329
|
-
|
330
|
-
if dev_env == 'subtree'
|
331
|
-
if !File.directory?(path)
|
332
|
-
_toplevelDir = `git rev-parse --show-toplevel`
|
333
|
-
_currentDir = `pwd`
|
334
|
-
_subtreeDir = path
|
335
|
-
if _currentDir != _toplevelDir
|
336
|
-
Dir.chdir(_toplevelDir)
|
337
|
-
_end = path
|
338
|
-
if _end[0,2] == './'
|
339
|
-
_end = _end[1, _end.length - 1]
|
340
|
-
else
|
341
|
-
_end = '/' + _end
|
342
|
-
end
|
343
|
-
_subtreeDir = './' + _currentDir[_toplevelDir.length, _currentDir.length - _toplevelDir.length] + path
|
344
|
-
end
|
345
|
-
_cmd = "git subtree add --prefix #{_subtreeDir} #{git} #{branch} --squash"
|
346
|
-
UI.puts _cmd
|
347
|
-
system(_cmd)
|
348
|
-
Dir.chdir(_currentDir)
|
349
|
-
end
|
350
|
-
options[:path] = path
|
351
|
-
if requirements.length >= 2
|
352
|
-
requirements.delete_at(0)
|
353
|
-
end
|
354
|
-
UI.message "pod #{pod_name.green} enabled #{"subtree".green}-mode 🍺"
|
355
|
-
elsif dev_env == 'dev'
|
356
|
-
# 开发模式,使用path方式引用本地的submodule git库
|
357
|
-
if !File.directory?(path)
|
358
|
-
UI.puts "add submodule for #{pod_name.green}".yellow
|
359
|
-
_cmd = "git submodule add --force -b #{branch} #{git} #{path}"
|
360
|
-
UI.puts _cmd
|
361
|
-
system(_cmd)
|
362
|
-
|
363
|
-
_currentDir = Dir.pwd
|
364
|
-
Dir.chdir(path)
|
365
|
-
|
366
|
-
curGitRemoteUrl = `git remote get-url origin`.rstrip()
|
367
|
-
if curGitRemoteUrl == git
|
368
|
-
_cmd = "git reset --hard"
|
369
|
-
UI.puts _cmd
|
370
|
-
system(_cmd)
|
371
|
-
_cmd = "git pull"
|
372
|
-
UI.puts _cmd
|
373
|
-
system(_cmd)
|
374
|
-
end
|
375
|
-
Dir.chdir(_currentDir)
|
376
|
-
|
377
|
-
# if inputNeedJumpForReson("本地库#{pod_name} 开发模式加载完成,是否自动打开Example工程")
|
378
|
-
# searchAndOpenLocalExample(path)
|
379
|
-
# end
|
380
|
-
if !checkTagIsEqualToHead(tag, path) && !checkTagIsEqualToHead("#{tag}_beta", path)
|
381
|
-
raise "💔 #{pod_name.yellow} branch:#{branch.yellow} 与 tag:#{tag.yellow}[_beta] 内容不同步,请自行确认所用分支和tag后重新执行 pod install"
|
382
|
-
end
|
383
|
-
else
|
384
|
-
# if inputNeedJumpForReson("本地库#{pod_name} 处于开发模式,是否自动打开Example工程")
|
385
|
-
# searchAndOpenLocalExample(path)
|
386
|
-
# end
|
387
|
-
end
|
388
|
-
options[:path] = path
|
389
|
-
if requirements.length >= 2
|
390
|
-
requirements.delete_at(0)
|
391
|
-
end
|
392
|
-
UI.message "pod #{pod_name.green} enabled #{"dev".green}-mode 🍺"
|
393
|
-
elsif dev_env == 'beta'
|
394
|
-
# Beta模式,使用tag引用远端git库的代码
|
395
|
-
originTag = tag
|
396
|
-
tag = "#{tag}_beta"
|
397
|
-
if File.directory?(path)
|
398
|
-
# 从Dev模式刚刚切换过来,需要打tag并且push
|
399
|
-
UI.puts "try to release beta-version for #{pod_name.green}".yellow
|
400
|
-
_currentDir = Dir.pwd
|
401
|
-
Dir.chdir(path)
|
402
|
-
# 已经进入到podspec的文件夹中了
|
403
|
-
checkGitStatusAndPush(pod_name) # push一下
|
404
|
-
ret = checkRemoteTagExist(tag)
|
405
|
-
if ret == true
|
406
|
-
# tag已经存在,要么没改动,要么已经手动打过tag,要么是需要引用老版本tag的代码
|
407
|
-
if checkTagOrBranchIsEqalToHead(tag, "./")
|
408
|
-
UI.puts "#{pod_name.green} 检测到未做任何调整,或已手动打过Tag,直接引用远端库"
|
409
|
-
else
|
410
|
-
if !inputNeedJumpForReson("#{pod_name.green} 检测到已经存在#{tag.yellow}的tag,且与当前本地节点不同,是否跳过beta发布并删除本地submodule(直接引用远端库)")
|
411
|
-
raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 且与当前Commit不对应. 请确认拉到本地之后已经在podfile中手动修改tag版本号"
|
412
|
-
end
|
413
|
-
end
|
414
|
-
else
|
415
|
-
# tag不存在,
|
416
|
-
changeVersionInCocoapods(pod_name, originTag)
|
417
|
-
checkGitStatusAndPush(pod_name) # 再push一下
|
418
|
-
addGitTagAndPush(tag, pod_name)
|
419
|
-
end
|
420
|
-
Dir.chdir(_currentDir)
|
421
|
-
checkAndRemoveSubmodule(path)
|
422
|
-
end
|
423
|
-
options[:git] = git
|
424
|
-
options[:tag] = tag
|
425
|
-
if requirements.length >= 2
|
426
|
-
requirements.delete_at(0)
|
427
|
-
end
|
428
|
-
UI.message "enabled #{"beta".green}-mode for #{pod_name.green}"
|
429
|
-
elsif dev_env == 'release'
|
430
|
-
# Release模式,直接使用远端对应的版本
|
431
|
-
if File.directory?(path)
|
432
|
-
UI.puts "release release-version for #{pod_name.green}".yellow
|
433
|
-
_currentDir = Dir.pwd
|
434
|
-
Dir.chdir(path)
|
435
|
-
verboseParamStr = ""
|
436
|
-
if Config.instance.verbose
|
437
|
-
verboseParamStr = " --verbose"
|
438
|
-
end
|
439
|
-
ret = system("pod lib lint --skip-import-validation --fail-fast --allow-warnings#{getReposStrForLint()}#{verboseParamStr}")
|
440
|
-
if ret != true
|
441
|
-
raise "💔 #{pod_name.yellow} lint 失败"
|
442
|
-
end
|
443
|
-
checkGitStatusAndPush(pod_name)
|
444
|
-
changeVersionInCocoapods(pod_name, tag)
|
445
|
-
checkGitStatusAndPush(pod_name)
|
446
|
-
ret = addGitTagAndPush(tag, pod_name)
|
447
|
-
if ret == false
|
448
|
-
if checkTagOrBranchIsEqalToHead(tag, "./")
|
449
|
-
UI.puts "#{pod_name.green} 已经打过tag".yellow
|
450
|
-
else
|
451
|
-
raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 请确认已经手动修改tag版本号"
|
452
|
-
end
|
453
|
-
end
|
454
|
-
## TODO:: 发布到的目标库名称需要用变量设置
|
455
|
-
repoAddrs = getUserRepoAddress()
|
456
|
-
cmd = "pod repo push #{repoAddrs} #{pod_name}.podspec --skip-import-validation --allow-warnings --use-modular-headers#{getReposStrForLint()}#{verboseParamStr}"
|
457
|
-
UI.puts cmd.green
|
458
|
-
ret = system(cmd)
|
459
|
-
if ret != true
|
460
|
-
raise "💔 #{pod_name.yellow} 发布失败"
|
461
|
-
end
|
462
|
-
## 到最后统一执行,判断如果当次release过
|
463
|
-
`pod repo update`
|
464
|
-
Dir.chdir(_currentDir)
|
465
|
-
checkAndRemoveSubmodule(path)
|
466
|
-
end
|
467
|
-
if requirements.length < 2
|
468
|
-
requirements.insert(0, "#{get_pure_version(tag)}")
|
469
|
-
end
|
470
|
-
UI.message "enabled #{"release".green}-mode for #{pod_name.green}"
|
471
|
-
else
|
472
|
-
raise "💔 :dev_env 必须要设置成 dev/beta/release之一,不接受其他值"
|
473
|
-
end
|
474
|
-
end
|
475
|
-
|
476
|
-
def binary_processer(dev_env, pod_name, use_binary, options, requirements)
|
477
|
-
if use_binary && use_binary == true
|
478
|
-
if options[:tag] != nil
|
479
|
-
begin
|
480
|
-
version = get_pure_version(options[:tag])
|
481
|
-
spec = binary_source.specification_path(pod_name, Version.new(version))
|
482
|
-
if spec
|
483
|
-
if requirements.length < 2
|
484
|
-
options.delete(:git)
|
485
|
-
options.delete(:path)
|
486
|
-
options.delete(:tag)
|
487
|
-
options[:source] = binary_repo_url
|
488
|
-
requirements.insert(0, "#{version}")
|
489
|
-
else
|
490
|
-
UI.puts "pod '#{pod_name}' :tag => #{options[:tag]} version: #{version} 对应的版本,但是已经标记版本号#{requirements}, 不知道用哪个".red
|
491
|
-
end
|
492
|
-
else
|
493
|
-
UI.puts "pod '#{pod_name}' :tag => #{options[:tag]} version: #{version} 没有找到: tag 对应的版本".red
|
494
|
-
end
|
495
|
-
rescue => exception
|
496
|
-
UI.puts "pod '#{pod_name}' :tag => #{options[:tag]} version: #{version} 没有找到: tag 对应的版本".red
|
497
|
-
else
|
498
|
-
|
499
|
-
end
|
500
|
-
else
|
501
|
-
options.delete(:git)
|
502
|
-
options.delete(:path)
|
503
|
-
options.delete(:tag)
|
504
|
-
options[:source] = binary_repo_url
|
505
|
-
end
|
506
|
-
|
507
|
-
else
|
508
|
-
if options[:source] == nil
|
509
|
-
begin
|
510
|
-
sources = find_pod_repos(pod_name).sources.select{|item| item.url.downcase != binary_repo_url.downcase } if options.empty?
|
511
|
-
if sources != nil
|
512
|
-
if sources.length >= 2
|
513
|
-
UI.puts "#{pod_name.green} 有多个source #{sources}".yellow
|
514
|
-
source_url = sources.detect{|item| item.url.downcase != Pod::TrunkSource::TRUNK_REPO_URL.downcase && item.url.downcase != "https://github.com/CocoaPods/Specs.git".downcase}.url
|
515
|
-
else
|
516
|
-
source_url = sources.first.url
|
517
|
-
end
|
518
|
-
end
|
519
|
-
options[:source] = source_url if source_url != nil
|
520
|
-
rescue => exception
|
521
|
-
UI.puts "#{pod_name} exception:#{exception}".red
|
522
|
-
else
|
523
|
-
|
524
|
-
end
|
525
|
-
end
|
526
|
-
end
|
527
|
-
UI.puts "#{pod_name.green} :source=> #{options[:source].green} by cocoapods-dev-env" if options[:source] != nil
|
528
|
-
UI.message "#{pod_name.yellow} options #{options} by cocoapods-dev-env" if options[:source] != nil
|
529
|
-
UI.message "#{pod_name.yellow} requirements #{requirements} by cocoapods-dev-env" if options[:source] != nil
|
530
|
-
end
|
531
|
-
|
532
|
-
def binary_repo_url
|
533
|
-
if @binary_repo_url == nil
|
534
|
-
@binary_repo_url = Luna::Binary::Common.instance.binary_repo_url #从luna-binary-uploader里获取binary_repo_url
|
535
|
-
end
|
536
|
-
return @binary_repo_url
|
537
|
-
end
|
538
|
-
|
539
|
-
def binary_source
|
540
|
-
if @binary_source == nil
|
541
|
-
@binary_source = Pod::Config.instance.sources_manager.all.detect{|item| item.url.downcase == binary_repo_url.downcase}
|
542
|
-
end
|
543
|
-
return @binary_source
|
544
|
-
end
|
545
|
-
|
546
|
-
def get_pure_version(version)
|
547
|
-
return version.split.last.scan(/\d+/).join('.')
|
548
|
-
end
|
549
|
-
|
550
|
-
def find_pod_repos(pod_name) #等同pod search
|
551
|
-
sets = Pod::Config.instance.sources_manager.search_by_name(pod_name)
|
552
|
-
if sets.count == 1
|
553
|
-
set = sets.first
|
554
|
-
elsif sets.map(&:name).include?(pod_name)
|
555
|
-
set = sets.find { |s| s.name == pod_name }
|
556
|
-
else
|
557
|
-
names = sets.map(&:name) * ', '
|
558
|
-
raise Informative, "More than one spec found for '#{pod_name}':\n#{names}"
|
559
|
-
end
|
560
|
-
return set
|
561
|
-
end
|
562
|
-
|
563
|
-
# ---- patch method ----
|
564
|
-
# We want modify `store_pod` method, but it's hard to insert a line in the
|
565
|
-
# implementation. So we patch a method called in `store_pod`.
|
566
|
-
old_method = instance_method(:parse_inhibit_warnings)
|
567
|
-
|
568
|
-
define_method(:parse_inhibit_warnings) do |name, requirements|
|
569
|
-
parse_pod_dev_env(name, requirements)
|
570
|
-
old_method.bind(self).(name, requirements)
|
571
|
-
end
|
572
|
-
|
573
|
-
def self.cleanParrentLockFile()
|
574
|
-
$parentPodlockDependencyHash = Hash.new
|
575
|
-
end
|
576
|
-
|
577
|
-
# 类方法
|
578
|
-
def self.readParrentLockFile()
|
579
|
-
# 获取路径(之后外边直接配置)
|
580
|
-
localPath = Pathname.new(Dir.pwd + "/" + $parrentPath)
|
581
|
-
lockPath ||= localPath + "Podfile.lock"
|
582
|
-
# 读取lockfile
|
583
|
-
_lockfile = Pod::Lockfile.from_file(lockPath)
|
584
|
-
if _lockfile == nil
|
585
|
-
UI.message "dev_env, 读取父库的lockfile找不到对应路径的lock文件:" + lockPath.inspect
|
586
|
-
return
|
587
|
-
end
|
588
|
-
# 读取lockfile中的依赖信息,用于之后提取使用,其中数据为 Pod::Dependency类型
|
589
|
-
localPodsMaps = Hash.new()
|
590
|
-
localpods = _lockfile.dependencies
|
591
|
-
localpods.each do |dep|
|
592
|
-
# 数据为 Pod::Dependency类型
|
593
|
-
if (dep.external_source == nil && dep.requirement == nil) || localPodsMaps.has_key?(dep.root_name)
|
594
|
-
next
|
595
|
-
end
|
596
|
-
if dep.external_source == nil && dep.requirement.to_s == '>= 0'
|
597
|
-
# dependence里可能没有版本信息(很奇怪,从version里单独取一下,写死版本限制)
|
598
|
-
version = _lockfile.version(dep.root_name)
|
599
|
-
dep.setRequirement(Requirement.new(version))
|
600
|
-
end
|
601
|
-
if dep.local?
|
602
|
-
dep.external_source[:path] = $parrentPath + dep.external_source[:path]
|
603
|
-
end
|
604
|
-
# 测试代码 UI.puts "测试获取父项目podlock里的pod依赖列表: " + dep.inspect
|
605
|
-
localPodsMaps[dep.root_name] = dep
|
606
|
-
end
|
607
|
-
$parentPodlockDependencyHash = localPodsMaps
|
608
|
-
# 读取 示例: ydASRInfo = localPodsMaps['YDASR']
|
609
|
-
# UI.puts ydASRInfo.inspect
|
610
|
-
# UI.puts "YDASR path:\n" + ydASRInfo.external_source[:path]
|
611
|
-
end
|
612
|
-
|
613
|
-
readParrentLockFile()
|
614
|
-
end
|
615
|
-
end
|
616
|
-
end
|
617
|
-
|
1
|
+
require 'dev_env_entry'
|
2
|
+
require 'resolver_binary'
|
3
|
+
require 'resolver_universal_dependency'
|