gct 0.2.5 → 0.2.6

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: 53c7ada5071bbd9de394ab1ea7a2ea4abc3c4c41c4ff396082d69d132f0c1759
4
- data.tar.gz: 85fbcd6384cc4b83e7a2c5773e5935b1f857e85aa752be3d4c82afb37c92d6c5
3
+ metadata.gz: fcbe1a0b358a5d2f8579f1dcdbc323a94c390ad1d022ea362955399c158572b6
4
+ data.tar.gz: 7bbf206c9c77fbff1d2e101cd1156167ad758b2d9092038ec8f7cb9081005375
5
5
  SHA512:
6
- metadata.gz: eff41d2c1e874150d59d86b37960d5a363d1f7ee05e66c1eef9ab917b1f03dca4722bf35b170481bd115de8e58943223b11e30201c6e9a186552b722492b2433
7
- data.tar.gz: 0254aa3ecd8276b0d17023fc86ea1ad9f7b6a6e1e3718e12eba9d791a8e7e6cedbfe6145cd006de1f4675b9a976be818ed9d344c7e4b17e8d388115ef0aa383d
6
+ metadata.gz: 9180c790294328532eaa45342f656b16fcf7689b53d7d93bb68fdde1357a72bcaaf6621df390869d085be924130730c2166ddc47583ef357ddba94fe3f562478
7
+ data.tar.gz: 0f6fd44317552e8a3be79ae42b65b69cd8bf4a9bd585f5ad0ecc06d22073dd87bca49047191dfca57d50c9d84ab90cf090db0ce393a0e05a71866d91b82dbe4f
@@ -1,3 +1,5 @@
1
+ require 'cocoapods'
2
+
1
3
  module Gct
2
4
  class Command
3
5
  class Spec < Command
@@ -20,24 +22,61 @@ module Gct
20
22
  end
21
23
 
22
24
  def run
23
- check_pod_spec
25
+ lint_spec
26
+ end
27
+
28
+ def generate_podfile(pod_name, spec_path)
29
+ Pod::Podfile.new do
30
+ install! 'cocoapods', :integrate_targets => false
31
+ inhibit_all_warnings!
32
+ source 'https://gi-dev.ccrgt.com/ios/iOSCRGTPodSource.git'
33
+ target 'App' do
34
+ platform :ios, 10.0
35
+ pod pod_name, :podspec => spec_path, :inhibit_warnings => false
36
+ end
37
+ end
24
38
  end
25
39
 
26
- def check_pod_spec
27
- puts ""
28
- puts "需要一点时间,请耐心等待".green
29
- system "pod spec lint --sources='https://gi-dev.ccrgt.com/ios/iOSCRGTPodSource.git' --use-libraries --allow-warnings"
30
- Dir.foreach(Dir.pwd) do |file|
31
- if file.to_s.include?'.podspec'
32
- IO.foreach(file.to_s) { |line|
33
- if line.include?("GCT.R")
34
- puts ""
35
- puts "[WARNING] 'GCT.R': GCT.R依赖不建议放在podspec中,建议放在podfile中".yellow
36
- break
40
+ def lint_spec
41
+ spec_file = Pathname.glob('*.podspec').first
42
+ raise "在 #{Dir.pwd} 目录下找不到podspec文件".red if spec_file.nil?
43
+
44
+ spec_path = spec_file.realpath
45
+ spec = Pod::Specification.from_file(spec_file)
46
+
47
+ puts ''
48
+ Pod::UI.section('校验组件循环引用'.green) do
49
+ sandbox = Pod::Sandbox.new(Pod::Config.instance.sandbox_root)
50
+ podfile = generate_podfile(spec.name, spec_path)
51
+ installer = Pod::Installer.new(sandbox, podfile)
52
+ %i(prepare resolve_dependencies download_dependencies write_lockfiles).each { |m| installer.send(m) }
53
+ end
54
+
55
+ puts ''
56
+ Pod::UI.section('校验组件包含关系'.green) do
57
+ specific_bussiness_line_pods = %w[
58
+ GCT.R
59
+ ].freeze
60
+ specific_pods = []
61
+ if spec.dependencies.length > 0
62
+ specific_pods = spec.dependencies.select do |dep|
63
+ specific_bussiness_line_pods.include?(dep.root_name)
64
+ end
65
+ end
66
+ if spec.subspecs.length > 0
67
+ spec.subspecs.each do |subspec|
68
+ new_specific_pods = []
69
+ new_specific_pods = subspec.dependencies.select do |dep|
70
+ specific_bussiness_line_pods.include?(dep.root_name)
37
71
  end
38
- }
39
- break
72
+ specific_pods = specific_pods + new_specific_pods
73
+ end
74
+ end
75
+
76
+ if specific_pods.any?
77
+ raise "podspec 不建议包含组件 #{specific_pods.map(&:name).join(', ')}".red
40
78
  end
79
+ puts '业务线私有组件包含关系校验完毕'.green
41
80
  end
42
81
  end
43
82
  end
data/lib/gct/version.rb CHANGED
@@ -2,5 +2,5 @@ module Gct
2
2
  # freeze 冻结对象,将对象变成一个常量
3
3
  # unless 右边的代码块成立,才会运行左边的代码块
4
4
  # defined? 是用来判断本地变量是否存在,也可用来判断是否存在方法
5
- VERSION = "0.2.5".freeze unless defined? Gct::VERSION
5
+ VERSION = "0.2.6".freeze unless defined? Gct::VERSION
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - jieming
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-14 00:00:00.000000000 Z
11
+ date: 2020-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler