cocoapods-dev-env 1.0.0 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d24f5687a5869c6b2a4b22a0e105c6aae21bc9bfcdc8a3eb502b6b1b3234cc4
4
- data.tar.gz: c6c18b0fe87691bcb8d02c2797a5699c720fd5826dd9c0ea6aab5af9b4c652f3
3
+ metadata.gz: 3afe919528275cf8b10ba4dc9f641fb314d41973a20b3af3a04f4eb7d6b2490f
4
+ data.tar.gz: 89636fb4ea8ac5450f61b682a1e472bfaa2265d3488240c674135baa2bbcf78b
5
5
  SHA512:
6
- metadata.gz: f067f655efe01bfe0feb2d8f17b64ee783f0389138ce1c59dfd605be402937fb116fa90ceb67b494594f081605c3fe57d5fb2e526ba63b597fe6d7a511bea636
7
- data.tar.gz: b31c7e4d5ed3af8bd3c58b3439665a237d9e6e654197108ab3b740a41f4bffdbd7fd8503d229b8db6eda304e32d74e25657ea666d65c43f9bab108d2ab78a6de
6
+ metadata.gz: 88e9376cedc8fbee56febc9339c05f032bd7dba76793fba50145aa7f612af8f60331b8c523018c922d71c0083e5167e2220b6bf92b3f3c84b2c664343d591519
7
+ data.tar.gz: d32ccb577e9f11f1d935f12009ba6c60db7f6c4aef447ffe730f310afb20ed82e63aa858fe6157d318bf9b8e3c96fad7655093fdf9207e583101a9a3bafaeda2
data/.gitignore CHANGED
@@ -6,3 +6,4 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ vendor/
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
@@ -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
@@ -1,7 +1,7 @@
1
1
  module Cocoapods
2
2
  module Dev
3
3
  module Env
4
- VERSION = "1.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
6
6
  end
7
7
  end
@@ -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
- return
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
- if dev_env == nil
203
- return
204
- end
205
- UI.message "pod #{name.green} dev-env: #{dev_env.green}"
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
- if git == nil || git.length == 0
214
- raise "💔 #{pod_name.yellow} 未定义:git => 'xxx'库地址"
211
+
212
+
213
+ if dev_env || use_binary
214
+ $processedPodsOptions[pod_name] = options.clone
215
+ requirements.pop if options.empty?
215
216
  end
216
- if branch == nil || branch.length == 0
217
- raise "💔 #{pod_name.yellow} 未定义:branch => 'xxx'"
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
- if tag == nil || tag.length == 0
220
- raise "💔 #{pod_name.yellow} 未定义:tag => 'xxx', tag 将会作为 dev模式下载最新代码检查的依据,beta模式引用的tag 以及 release模式引用的版本号"
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
- if dev_env == 'subtree'
224
- if !File.directory?(path)
225
- _toplevelDir = `git rev-parse --show-toplevel`
226
- _currentDir = `pwd`
227
- _subtreeDir = path
228
- if _currentDir != _toplevelDir
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
- options[:path] = path
244
- if requirements.length >= 2
245
- requirements.delete_at(0)
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
- UI.message "pod #{pod_name.green} enabled #{"subtree".green}-mode 🍺"
248
- elsif dev_env == 'dev'
249
- # 开发模式,使用path方式引用本地的submodule git库
250
- if !File.directory?(path)
251
- UI.puts "add submodule for #{pod_name.green}".yellow
252
- _cmd = "git submodule add --force -b #{branch} #{git} #{path}"
253
- UI.puts _cmd
254
- system(_cmd)
255
-
256
- _currentDir = Dir.pwd
257
- Dir.chdir(path)
258
-
259
- curGitRemoteUrl = `git remote get-url origin`.rstrip()
260
- if curGitRemoteUrl == git
261
- _cmd = "git reset --hard"
262
- UI.puts _cmd
263
- system(_cmd)
264
- end
265
- Dir.chdir(_currentDir)
266
-
267
- # if inputNeedJumpForReson("本地库#{pod_name} 开发模式加载完成,是否自动打开Example工程")
268
- # searchAndOpenLocalExample(path)
269
- # end
270
- if !checkTagIsEqualToHead(tag, path) && !checkTagIsEqualToHead("#{tag}_beta", path)
271
- raise "💔 #{pod_name.yellow} branch:#{branch.yellow} 与 tag:#{tag.yellow}[_beta] 内容不同步,请自行确认所用分支和tag后重新执行 pod install"
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
- # if inputNeedJumpForReson("本地库#{pod_name} 处于开发模式,是否自动打开Example工程")
275
- # searchAndOpenLocalExample(path)
276
- # end
324
+ # tag不存在,
325
+ changeVersionInCocoapods(pod_name, originTag)
326
+ checkGitStatusAndPush(pod_name) # 再push一下
327
+ addGitTagAndPush(tag, pod_name)
277
328
  end
278
- options[:path] = path
279
- if requirements.length >= 2
280
- requirements.delete_at(0)
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
- UI.message "pod #{pod_name.green} enabled #{"dev".green}-mode 🍺"
283
- elsif dev_env == 'beta'
284
- # Beta模式,使用tag引用远端git库的代码
285
- originTag = tag
286
- tag = "#{tag}_beta"
287
- if File.directory?(path)
288
- # 从Dev模式刚刚切换过来,需要打tag并且push
289
- UI.puts "release beta-version for #{pod_name.green}".yellow
290
- _currentDir = Dir.pwd
291
- Dir.chdir(path)
292
- # 已经进入到podspec的文件夹中了
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
- options[:git] = git
314
- options[:tag] = tag
315
- if requirements.length >= 2
316
- requirements.delete_at(0)
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
- UI.message "enabled #{"beta".green}-mode for #{pod_name.green}"
319
- elsif dev_env == 'release'
320
- # Release模式,直接使用远端对应的版本
321
- if File.directory?(path)
322
- UI.puts "release release-version for #{pod_name.green}".yellow
323
- _currentDir = Dir.pwd
324
- Dir.chdir(path)
325
- verboseParamStr = ""
326
- if Config.instance.verbose
327
- verboseParamStr = " --verbose"
328
- end
329
- ret = system("pod lib lint --skip-import-validation --fail-fast --allow-warnings#{getReposStrForLint()}#{verboseParamStr}")
330
- if ret != true
331
- raise "💔 #{pod_name.yellow} lint 失败"
332
- end
333
- checkGitStatusAndPush(pod_name)
334
- changeVersionInCocoapods(pod_name, tag)
335
- checkGitStatusAndPush(pod_name)
336
- ret = addGitTagAndPush(tag, pod_name)
337
- if ret == false
338
- if checkTagOrBranchIsEqalToHead(tag, "./")
339
- UI.puts "#{pod_name.green} 已经打过tag".yellow
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
- raise "💔 #{pod_name.yellow} tag:#{tag.yellow} 已存在, 请确认已经手动修改tag版本号"
400
+ source_url = sources.first.url
342
401
  end
343
402
  end
344
- ## TODO:: 发布到的目标库名称需要用变量设置
345
- repoAddrs = getUserRepoAddress()
346
- cmd = "pod repo push #{repoAddrs} #{pod_name}.podspec --skip-import-validation --allow-warnings --use-modular-headers#{getReposStrForLint()}#{verboseParamStr}"
347
- UI.puts cmd.green
348
- ret = system(cmd)
349
- if ret != true
350
- raise "💔 #{pod_name.yellow} 发布失败"
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: 1.0.0
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-06-23 00:00:00.000000000 Z
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.2.5
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