podfileDep 2.7.2 → 2.7.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae55279a9a22e9cdd486adbb80433ad4ec1ef897baca726eea54a654c1f06da9
4
- data.tar.gz: 27c89dde2f63e38c88b35692303ab98cfbb684438d9b97750c30202cfdced38a
3
+ metadata.gz: fd86186ee4e29edf2c1a363f77ff6eed8b78445dab0830eb172a014dae91f619
4
+ data.tar.gz: 1134f5a9bf7020bd167a8e845a9d23523a82a177d20c886e3877e7593f792a22
5
5
  SHA512:
6
- metadata.gz: 2261974654acd832845fbd96c9b4f32c1c170efe01094f44624fa287b822ec52fa09263b72d1fc5e6a4cd96ce150fecf84a3647b73818c497359495f95236461
7
- data.tar.gz: e2ef0dc88f6823518d35cf6a365524ef00ab67b4840a440513769816fff6c7935b228072811fad24f8535c83cc614a55ec74c5a5cdc07824ca4378c6a816454f
6
+ metadata.gz: 6890edd1b1ac0e947e084c9873116d7b8a748af0ff8bdf5558576f85884a97add27de496927d111e8fcf803245225a567d3fea291e53e7ad6e69bb518bdb83d5
7
+ data.tar.gz: 13a1ea977b94493d50a344b19ef7416cdfd4873bd25f2fb4a7852e15c1ea096dd76562b1425ffcd57ca0ff87bcc6b1ac561d7e74d1e4d2ac7cb06d04e4615807
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
1
  ## [Released]
2
+ ### [2.7.4] - 2024-08-13
3
+ - 修复pod dep正向依赖数量错误的问题
4
+
5
+ ### [2.7.3] - 2024-08-12
6
+ - 新增:同时也支持打印出正向依赖
7
+
2
8
  ### [2.7.2] - 2024-08-09
3
9
  - pod install all命令丢失的问题
4
10
 
@@ -4,16 +4,17 @@ module Pod
4
4
  class Command
5
5
  class Dep < Command
6
6
 
7
- self.summary = '从Podfile.lock文件里检索出依赖反转后的情况'
7
+ self.summary = '从Podfile.lock文件里检索打印出组件的正向/反向依赖'
8
8
 
9
9
  self.description = <<-DESC
10
- 从Podfile.lock文件里检索出依赖反转后的情况
10
+ 从Podfile.lock文件里检索打印出组件的正向/反向依赖
11
11
  DESC
12
12
 
13
13
  def self.options
14
14
  [
15
15
  %w[--name=xx xx为要查询的组件的名字],
16
- %w[--sort 输出反转依赖时按数量从小到大排序],
16
+ %w[--sort 输出依赖时按数量从小到大排序],
17
+ %w[--forward 输出正向依赖],
17
18
  ].concat(super).reject { |(name, _)| (name == '--no-ansi' or name == '--silent' or name == '--allow-root' or name == '--verbose') }
18
19
  end
19
20
 
@@ -22,6 +23,7 @@ module Pod
22
23
  puts "插件版本号: #{PodfileDep::VERSION}"
23
24
  @name = argv.option('name')
24
25
  @sort_count = argv.flag?('sort', false)
26
+ @forward = argv.flag?('forward', false)
25
27
  end
26
28
 
27
29
  def run
@@ -29,6 +31,7 @@ module Pod
29
31
  finder = Pod::DepFinder.new
30
32
  finder.find_name = @name
31
33
  finder.sort_count = @sort_count
34
+ finder.forward = @forward
32
35
  finder.find
33
36
  end
34
37
  end
@@ -13,6 +13,9 @@ module Pod
13
13
  # @param [bool] 是否按数量从小到大排序
14
14
  attr_accessor :sort_count
15
15
 
16
+ # @param [bool] 是否打印正向依赖
17
+ attr_accessor :forward
18
+
16
19
  def initialize
17
20
  super
18
21
  init_lock
@@ -34,64 +37,99 @@ module Pod
34
37
  def find
35
38
 
36
39
  if @find_name
37
- find_for_name
40
+ find_single_dep
38
41
  else
39
- find_all
42
+ find_all_dep
43
+ end
44
+
45
+ puts "\n基础命令(默认输出反向依赖):pod dep"
46
+ unless @forward
47
+ puts "==> 输出所有正向依赖,可加参数 --forward".yellow
48
+ end
49
+ unless @sort_count
50
+ puts "==> 按数量从少到多排序,可加参数 --sort".yellow
51
+ end
52
+ unless @find_name
53
+ puts "==> 查询单个依赖的情况,可使用参数 --name=xx".yellow
40
54
  end
55
+
41
56
  end
42
57
 
43
- def find_all
58
+ def find_all_dep
44
59
 
45
- reverse_map = Hash.new
60
+ result_map = Hash.new
46
61
  # 循环遍历lockfile对象中的PODS数组
47
62
  @lockfile_content['PODS'].each do |pod|
48
63
  # 拿到所有的组件名
49
64
  key = pod.is_a?(Hash) ? pod.keys[0] : pod
50
65
  key = key.split(" (")[0]
51
- results = find_with_name(key)
52
-
53
- reverse_map[key] = results
54
66
 
67
+ if @forward
68
+ result_map[key] = pod.is_a?(Hash) ? pod.values[0] : Array.new
69
+ else
70
+ result_map[key] = find_reverse_with_name(key)
71
+ end
55
72
  end
56
73
 
57
- puts ""
58
- sorted_hash = reverse_map
74
+ msg = @forward ? "正向依赖" : "反向依赖"
75
+ puts "打印#{msg}"
76
+
77
+ sorted_hash = result_map
59
78
  if @sort_count
60
- puts "反转后依赖如下(数量从少到多):"
61
- sorted_hash = Hash[reverse_map.sort_by { |key, value| value.length }]
62
- else
63
- puts "反转后依赖如下:"
79
+ puts "数量从少到多"
80
+ sorted_hash = Hash[result_map.sort_by { |key, value| value.length }]
64
81
  end
65
82
 
66
83
  sorted_hash.each do |key, array|
67
- puts "依赖#{key}的组件有(#{array.length}个):".green
84
+ if @forward
85
+ puts "组件#{key}的依赖有(#{array.length}个):".green
86
+ else
87
+ puts "依赖#{key}的组件有(#{array.length}个):".green
88
+ end
89
+
68
90
  array.each do |obj|
69
91
  puts obj
70
92
  end
71
93
  puts "\n"
72
94
  end
73
-
74
- unless @sort_count
75
- puts "==> 按数量从少到多排序,可使用pod dep --sort".yellow
76
- end
77
- puts "==> 查询单个依赖的情况,可使用pod dep --name=xx".yellow
78
95
  end
79
96
 
80
- def find_for_name
81
- results = find_with_name(@find_name)
97
+ def find_single_dep
82
98
 
83
- if results.empty?
84
- puts "组件#{@find_name}没有被任何其他组件依赖"
85
- return
99
+ # 反向依赖查询结果
100
+ results = find_reverse_with_name(@find_name)
101
+ puts "依赖#{@find_name}的组件有(#{results.length}个):".green
102
+ results.each do |res|
103
+ puts res
86
104
  end
87
105
 
88
- puts "依赖#{@find_name}的组件有:".green
89
- results.each do |res|
106
+ puts "\n"
107
+
108
+ # 正向依赖查询结果
109
+ forward_results = find_forward_with_name(@find_name)
110
+ puts "#{@find_name}依赖的组件有(#{forward_results.length}个):".green
111
+ forward_results.each do |res|
90
112
  puts res
91
113
  end
114
+
115
+ end
116
+
117
+ def find_forward_with_name(name)
118
+ results = Array.new
119
+ @lockfile_content['PODS'].each do |pod|
120
+ # 拿到所有的组件名
121
+ key = pod.is_a?(Hash) ? pod.keys[0] : pod
122
+ key = key.split(" (")[0]
123
+ if key == name and pod.is_a?(Hash)
124
+ pod.each_value do |value|
125
+ results << value
126
+ end
127
+ end
128
+ end
129
+ results
92
130
  end
93
131
 
94
- def find_with_name(name)
132
+ def find_reverse_with_name(name)
95
133
  results = Array.new
96
134
  # 循环遍历lockfile对象中的PODS数组
97
135
  @lockfile_content['PODS'].each do |pod|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PodfileDep
4
- VERSION = "2.7.2"
4
+ VERSION = "2.7.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: podfileDep
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.2
4
+ version: 2.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - 王帅朋
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-09 00:00:00.000000000 Z
11
+ date: 2024-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods