cocoapods-dev-env 1.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +20 -0
- data/cocoapods-dev-env.gemspec +1 -0
- data/lib/cocoapods/dev/env/version.rb +1 -1
- data/lib/cocoapods_plugin.rb +213 -146
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3afe919528275cf8b10ba4dc9f641fb314d41973a20b3af3a04f4eb7d6b2490f
|
4
|
+
data.tar.gz: 89636fb4ea8ac5450f61b682a1e472bfaa2265d3488240c674135baa2bbcf78b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88e9376cedc8fbee56febc9339c05f032bd7dba76793fba50145aa7f612af8f60331b8c523018c922d71c0083e5167e2220b6bf92b3f3c84b2c664343d591519
|
7
|
+
data.tar.gz: d32ccb577e9f11f1d935f12009ba6c60db7f6c4aef447ffe730f310afb20ed82e63aa858fe6157d318bf9b8e3c96fad7655093fdf9207e583101a9a3bafaeda2
|
data/.gitignore
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cocoapods-dev-env (2.0.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
rake (10.5.0)
|
10
|
+
|
11
|
+
PLATFORMS
|
12
|
+
ruby
|
13
|
+
|
14
|
+
DEPENDENCIES
|
15
|
+
bundler (~> 2.0)
|
16
|
+
cocoapods-dev-env!
|
17
|
+
rake (~> 10.0)
|
18
|
+
|
19
|
+
BUNDLED WITH
|
20
|
+
2.1.4
|
data/cocoapods-dev-env.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
|
+
spec.add_dependency 'luna-binary-uploader'
|
31
32
|
spec.add_development_dependency "bundler", "~> 2.0"
|
32
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
33
34
|
end
|
data/lib/cocoapods_plugin.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "file_processer"
|
2
|
+
require "luna-binary-uploader"
|
2
3
|
|
3
4
|
Pod::HooksManager.register('cocoapods-dev-env', :pre_install) do |installer|
|
4
5
|
podfile = installer.podfile
|
@@ -23,10 +24,14 @@ module Pod
|
|
23
24
|
def self.keyword
|
24
25
|
:dev_env # 'dev'/'beta'/'release'
|
25
26
|
end
|
27
|
+
def self.binary_key
|
28
|
+
:dev_env_use_binary # true / false
|
29
|
+
end
|
26
30
|
UI.message "🎉 plugin cocoapods-dev-env loaded 🎉".green
|
27
31
|
end
|
28
32
|
class Podfile
|
29
33
|
class TargetDefinition
|
34
|
+
attr_reader :binary_repo_url
|
30
35
|
|
31
36
|
def searchAndOpenLocalExample(path)
|
32
37
|
_currentDir = Dir.pwd
|
@@ -182,6 +187,7 @@ class Podfile
|
|
182
187
|
end
|
183
188
|
|
184
189
|
## --- option for setting using prebuild framework ---
|
190
|
+
|
185
191
|
def parse_pod_dev_env(name, requirements)
|
186
192
|
options = requirements.last
|
187
193
|
pod_name = Specification.root_name(name)
|
@@ -194,177 +200,238 @@ class Podfile
|
|
194
200
|
else
|
195
201
|
requirements.push(last_options)
|
196
202
|
end
|
197
|
-
|
198
|
-
|
199
|
-
end
|
200
|
-
if options.is_a?(Hash)
|
203
|
+
elsif options.is_a?(Hash)
|
204
|
+
use_binary = options.delete(Pod::DevEnv::binary_key)
|
201
205
|
dev_env = options.delete(Pod::DevEnv::keyword)
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
git = options.delete(:git)
|
207
|
-
branch = options.delete(:branch)
|
208
|
-
tag = options.delete(:tag)
|
209
|
-
path = options.delete(:path)
|
210
|
-
if path == nil
|
211
|
-
path = "./developing_pods/#{pod_name}"
|
206
|
+
|
207
|
+
deal_dev_env_with_options(dev_env, options, pod_name, name, requirements)
|
208
|
+
if dev_env != 'dev'
|
209
|
+
useBinary(dev_env, pod_name, use_binary, options, requirements)
|
212
210
|
end
|
213
|
-
|
214
|
-
|
211
|
+
|
212
|
+
|
213
|
+
if dev_env || use_binary
|
214
|
+
$processedPodsOptions[pod_name] = options.clone
|
215
|
+
requirements.pop if options.empty?
|
215
216
|
end
|
216
|
-
|
217
|
-
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def deal_dev_env_with_options(dev_env, options, pod_name, name, requirements)
|
221
|
+
if dev_env == nil
|
222
|
+
return
|
223
|
+
end
|
224
|
+
UI.message "pod #{name.green} dev-env: #{dev_env.green}"
|
225
|
+
git = options.delete(:git)
|
226
|
+
branch = options.delete(:branch)
|
227
|
+
tag = options.delete(:tag)
|
228
|
+
path = options.delete(:path)
|
229
|
+
if path == nil
|
230
|
+
path = "./developing_pods/#{pod_name}"
|
231
|
+
end
|
232
|
+
if git == nil || git.length == 0
|
233
|
+
raise "💔 #{pod_name.yellow} 未定义:git => 'xxx'库地址"
|
234
|
+
end
|
235
|
+
if branch == nil || branch.length == 0
|
236
|
+
raise "💔 #{pod_name.yellow} 未定义:branch => 'xxx'"
|
237
|
+
end
|
238
|
+
if tag == nil || tag.length == 0
|
239
|
+
raise "💔 #{pod_name.yellow} 未定义:tag => 'xxx', tag 将会作为 dev模式下载最新代码检查的依据,beta模式引用的tag 以及 release模式引用的版本号"
|
240
|
+
end
|
241
|
+
|
242
|
+
if dev_env == 'subtree'
|
243
|
+
if !File.directory?(path)
|
244
|
+
_toplevelDir = `git rev-parse --show-toplevel`
|
245
|
+
_currentDir = `pwd`
|
246
|
+
_subtreeDir = path
|
247
|
+
if _currentDir != _toplevelDir
|
248
|
+
Dir.chdir(_toplevelDir)
|
249
|
+
_end = path
|
250
|
+
if _end[0,2] == './'
|
251
|
+
_end = _end[1, _end.length - 1]
|
252
|
+
else
|
253
|
+
_end = '/' + _end
|
254
|
+
end
|
255
|
+
_subtreeDir = './' + _currentDir[_toplevelDir.length, _currentDir.length - _toplevelDir.length] + path
|
256
|
+
end
|
257
|
+
_cmd = "git subtree add --prefix #{_subtreeDir} #{git} #{branch} --squash"
|
258
|
+
UI.puts _cmd
|
259
|
+
system(_cmd)
|
260
|
+
Dir.chdir(_currentDir)
|
218
261
|
end
|
219
|
-
|
220
|
-
|
262
|
+
options[:path] = path
|
263
|
+
if requirements.length >= 2
|
264
|
+
requirements.delete_at(0)
|
221
265
|
end
|
266
|
+
UI.message "pod #{pod_name.green} enabled #{"subtree".green}-mode 🍺"
|
267
|
+
elsif dev_env == 'dev'
|
268
|
+
# 开发模式,使用path方式引用本地的submodule git库
|
269
|
+
if !File.directory?(path)
|
270
|
+
UI.puts "add submodule for #{pod_name.green}".yellow
|
271
|
+
_cmd = "git submodule add --force -b #{branch} #{git} #{path}"
|
272
|
+
UI.puts _cmd
|
273
|
+
system(_cmd)
|
222
274
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
Dir.chdir(_toplevelDir)
|
230
|
-
_end = path
|
231
|
-
if _end[0,2] == './'
|
232
|
-
_end = _end[1, _end.length - 1]
|
233
|
-
else
|
234
|
-
_end = '/' + _end
|
235
|
-
end
|
236
|
-
_subtreeDir = './' + _currentDir[_toplevelDir.length, _currentDir.length - _toplevelDir.length] + path
|
237
|
-
end
|
238
|
-
_cmd = "git subtree add --prefix #{_subtreeDir} #{git} #{branch} --squash"
|
275
|
+
_currentDir = Dir.pwd
|
276
|
+
Dir.chdir(path)
|
277
|
+
|
278
|
+
curGitRemoteUrl = `git remote get-url origin`.rstrip()
|
279
|
+
if curGitRemoteUrl == git
|
280
|
+
_cmd = "git reset --hard"
|
239
281
|
UI.puts _cmd
|
240
282
|
system(_cmd)
|
241
|
-
Dir.chdir(_currentDir)
|
242
283
|
end
|
243
|
-
|
244
|
-
|
245
|
-
|
284
|
+
Dir.chdir(_currentDir)
|
285
|
+
|
286
|
+
# if inputNeedJumpForReson("本地库#{pod_name} 开发模式加载完成,是否自动打开Example工程")
|
287
|
+
# searchAndOpenLocalExample(path)
|
288
|
+
# end
|
289
|
+
if !checkTagIsEqualToHead(tag, path) && !checkTagIsEqualToHead("#{tag}_beta", path)
|
290
|
+
raise "💔 #{pod_name.yellow} branch:#{branch.yellow} 与 tag:#{tag.yellow}[_beta] 内容不同步,请自行确认所用分支和tag后重新执行 pod install"
|
246
291
|
end
|
247
|
-
|
248
|
-
|
249
|
-
#
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
292
|
+
else
|
293
|
+
# if inputNeedJumpForReson("本地库#{pod_name} 处于开发模式,是否自动打开Example工程")
|
294
|
+
# searchAndOpenLocalExample(path)
|
295
|
+
# end
|
296
|
+
end
|
297
|
+
options[:path] = path
|
298
|
+
if requirements.length >= 2
|
299
|
+
requirements.delete_at(0)
|
300
|
+
end
|
301
|
+
UI.message "pod #{pod_name.green} enabled #{"dev".green}-mode 🍺"
|
302
|
+
elsif dev_env == 'beta'
|
303
|
+
# Beta模式,使用tag引用远端git库的代码
|
304
|
+
originTag = tag
|
305
|
+
tag = "#{tag}_beta"
|
306
|
+
if File.directory?(path)
|
307
|
+
# 从Dev模式刚刚切换过来,需要打tag并且push
|
308
|
+
UI.puts "release beta-version for #{pod_name.green}".yellow
|
309
|
+
_currentDir = Dir.pwd
|
310
|
+
Dir.chdir(path)
|
311
|
+
# 已经进入到podspec的文件夹中了
|
312
|
+
checkGitStatusAndPush(pod_name) # push一下
|
313
|
+
ret = checkRemoteTagExist(tag)
|
314
|
+
if ret == true
|
315
|
+
# tag已经存在,要么没改动,要么已经手动打过tag,要么是需要引用老版本tag的代码
|
316
|
+
if checkTagOrBranchIsEqalToHead(tag, "./")
|
317
|
+
UI.puts "#{pod_name.green} 检测到未做任何调整,或已手动打过Tag"
|
318
|
+
else
|
319
|
+
if !inputNeedJumpForReson("是否跳过beta发布并删除本地submodule(直接引用远端库)")
|
320
|
+
raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 且与当前Commit不对应. 请确认拉到本地之后已经在podfile中手动修改tag版本号"
|
321
|
+
end
|
272
322
|
end
|
273
323
|
else
|
274
|
-
#
|
275
|
-
|
276
|
-
#
|
324
|
+
# tag不存在,
|
325
|
+
changeVersionInCocoapods(pod_name, originTag)
|
326
|
+
checkGitStatusAndPush(pod_name) # 再push一下
|
327
|
+
addGitTagAndPush(tag, pod_name)
|
277
328
|
end
|
278
|
-
|
279
|
-
|
280
|
-
|
329
|
+
Dir.chdir(_currentDir)
|
330
|
+
checkAndRemoveSubmodule(path)
|
331
|
+
end
|
332
|
+
options[:git] = git
|
333
|
+
options[:tag] = tag
|
334
|
+
if requirements.length >= 2
|
335
|
+
requirements.delete_at(0)
|
336
|
+
end
|
337
|
+
UI.message "enabled #{"beta".green}-mode for #{pod_name.green}"
|
338
|
+
elsif dev_env == 'release'
|
339
|
+
# Release模式,直接使用远端对应的版本
|
340
|
+
if File.directory?(path)
|
341
|
+
UI.puts "release release-version for #{pod_name.green}".yellow
|
342
|
+
_currentDir = Dir.pwd
|
343
|
+
Dir.chdir(path)
|
344
|
+
verboseParamStr = ""
|
345
|
+
if Config.instance.verbose
|
346
|
+
verboseParamStr = " --verbose"
|
281
347
|
end
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
checkGitStatusAndPush(pod_name) # push一下
|
294
|
-
ret = checkRemoteTagExist(tag)
|
295
|
-
if ret == true
|
296
|
-
# tag已经存在,要么没改动,要么已经手动打过tag,要么是需要引用老版本tag的代码
|
297
|
-
if checkTagOrBranchIsEqalToHead(tag, "./")
|
298
|
-
UI.puts "#{pod_name.green} 检测到未做任何调整,或已手动打过Tag"
|
299
|
-
else
|
300
|
-
if !inputNeedJumpForReson("是否跳过beta发布并删除本地submodule(直接引用远端库)")
|
301
|
-
raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 且与当前Commit不对应. 请确认拉到本地之后已经在podfile中手动修改tag版本号"
|
302
|
-
end
|
303
|
-
end
|
348
|
+
ret = system("pod lib lint --skip-import-validation --fail-fast --allow-warnings#{getReposStrForLint()}#{verboseParamStr}")
|
349
|
+
if ret != true
|
350
|
+
raise "💔 #{pod_name.yellow} lint 失败"
|
351
|
+
end
|
352
|
+
checkGitStatusAndPush(pod_name)
|
353
|
+
changeVersionInCocoapods(pod_name, tag)
|
354
|
+
checkGitStatusAndPush(pod_name)
|
355
|
+
ret = addGitTagAndPush(tag, pod_name)
|
356
|
+
if ret == false
|
357
|
+
if checkTagOrBranchIsEqalToHead(tag, "./")
|
358
|
+
UI.puts "#{pod_name.green} 已经打过tag".yellow
|
304
359
|
else
|
305
|
-
# tag
|
306
|
-
changeVersionInCocoapods(pod_name, originTag)
|
307
|
-
checkGitStatusAndPush(pod_name) # 再push一下
|
308
|
-
addGitTagAndPush(tag, pod_name)
|
360
|
+
raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 请确认已经手动修改tag版本号"
|
309
361
|
end
|
310
|
-
Dir.chdir(_currentDir)
|
311
|
-
checkAndRemoveSubmodule(path)
|
312
362
|
end
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
363
|
+
## TODO:: 发布到的目标库名称需要用变量设置
|
364
|
+
repoAddrs = getUserRepoAddress()
|
365
|
+
cmd = "pod repo push #{repoAddrs} #{pod_name}.podspec --skip-import-validation --allow-warnings --use-modular-headers#{getReposStrForLint()}#{verboseParamStr}"
|
366
|
+
UI.puts cmd.green
|
367
|
+
ret = system(cmd)
|
368
|
+
if ret != true
|
369
|
+
raise "💔 #{pod_name.yellow} 发布失败"
|
317
370
|
end
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
371
|
+
## 到最后统一执行,判断如果当次release过
|
372
|
+
`pod repo update`
|
373
|
+
Dir.chdir(_currentDir)
|
374
|
+
checkAndRemoveSubmodule(path)
|
375
|
+
end
|
376
|
+
if requirements.length < 2
|
377
|
+
requirements.insert(0, "#{tag}")
|
378
|
+
end
|
379
|
+
UI.message "enabled #{"release".green}-mode for #{pod_name.green}"
|
380
|
+
else
|
381
|
+
raise "💔 :dev_env 必须要设置成 dev/beta/release之一,不接受其他值"
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
def useBinary(dev_env, pod_name, use_binary, options, requirements)
|
386
|
+
if use_binary && use_binary == true
|
387
|
+
options.delete(:git)
|
388
|
+
options.delete(:tag)
|
389
|
+
options.delete(:path)
|
390
|
+
options[:source] = binary_repo_url
|
391
|
+
else
|
392
|
+
if options[:source] == nil
|
393
|
+
begin
|
394
|
+
sources = find_pod_repos(pod_name).sources.select{|item| item.url.downcase != binary_repo_url.downcase } if options.empty?
|
395
|
+
if sources != nil
|
396
|
+
if sources.length >= 2
|
397
|
+
p "#{pod_name} 有多个source #{sources}"
|
398
|
+
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
|
340
399
|
else
|
341
|
-
|
400
|
+
source_url = sources.first.url
|
342
401
|
end
|
343
402
|
end
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
end
|
352
|
-
## 到最后统一执行,判断如果当次release过
|
353
|
-
`pod repo update`
|
354
|
-
Dir.chdir(_currentDir)
|
355
|
-
checkAndRemoveSubmodule(path)
|
356
|
-
end
|
357
|
-
if requirements.length < 2
|
358
|
-
requirements.insert(0, "#{tag}")
|
403
|
+
options[:source] = source_url if source_url != nil
|
404
|
+
UI.puts "#{pod_name} :source=> #{options[:source]} by cocoapods-dev-env".yellow if options[:source] != nil
|
405
|
+
|
406
|
+
rescue => exception
|
407
|
+
UI.puts "#{pod_name} exception:#{exception}".red
|
408
|
+
else
|
409
|
+
|
359
410
|
end
|
360
|
-
UI.message "enabled #{"release".green}-mode for #{pod_name.green}"
|
361
|
-
else
|
362
|
-
raise "💔 :dev_env 必须要设置成 dev/beta/release之一,不接受其他值"
|
363
411
|
end
|
364
|
-
$processedPodsOptions[pod_name] = options.clone
|
365
|
-
requirements.pop if options.empty?
|
366
412
|
end
|
367
413
|
end
|
414
|
+
|
415
|
+
def binary_repo_url
|
416
|
+
if @binary_repo_url == nil
|
417
|
+
@binary_repo_url = Luna::Binary::Common.instance.binary_repo_url #从luna-binary-uploader里获取binary_repo_url
|
418
|
+
end
|
419
|
+
return @binary_repo_url
|
420
|
+
end
|
421
|
+
|
422
|
+
def find_pod_repos(pod_name) #等同pod search
|
423
|
+
sets = Pod::Config.instance.sources_manager.search_by_name(pod_name)
|
424
|
+
if sets.count == 1
|
425
|
+
set = sets.first
|
426
|
+
elsif sets.map(&:name).include?(pod_name)
|
427
|
+
set = sets.find { |s| s.name == pod_name }
|
428
|
+
else
|
429
|
+
names = sets.map(&:name) * ', '
|
430
|
+
raise Informative, "More than one spec found for '#{pod_name}':\n#{names}"
|
431
|
+
end
|
432
|
+
return set
|
433
|
+
end
|
434
|
+
|
368
435
|
# ---- patch method ----
|
369
436
|
# We want modify `store_pod` method, but it's hard to insert a line in the
|
370
437
|
# implementation. So we patch a method called in `store_pod`.
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoapods-dev-env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 吴锡苗
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: luna-binary-uploader
|
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'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,6 +62,7 @@ files:
|
|
48
62
|
- ".gitignore"
|
49
63
|
- CODE_OF_CONDUCT.md
|
50
64
|
- Gemfile
|
65
|
+
- Gemfile.lock
|
51
66
|
- LICENSE.txt
|
52
67
|
- README.md
|
53
68
|
- Rakefile
|
@@ -80,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
95
|
- !ruby/object:Gem::Version
|
81
96
|
version: '0'
|
82
97
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
98
|
+
rubygems_version: 3.0.3
|
84
99
|
signing_key:
|
85
100
|
specification_version: 4
|
86
101
|
summary: a cocoapod plugin for dev in mutipods
|