podfileDep 2.7.2 → 2.7.3

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: ae55279a9a22e9cdd486adbb80433ad4ec1ef897baca726eea54a654c1f06da9
4
- data.tar.gz: 27c89dde2f63e38c88b35692303ab98cfbb684438d9b97750c30202cfdced38a
3
+ metadata.gz: a9c50dcd0ef1d84316383fc2cc0ea1e2a1c0a53461b5684c8a416e1c94ce9127
4
+ data.tar.gz: 5a500fc64a446707546c6afa585d5200ae03f138fa1f37f31471a41ea5e7990b
5
5
  SHA512:
6
- metadata.gz: 2261974654acd832845fbd96c9b4f32c1c170efe01094f44624fa287b822ec52fa09263b72d1fc5e6a4cd96ce150fecf84a3647b73818c497359495f95236461
7
- data.tar.gz: e2ef0dc88f6823518d35cf6a365524ef00ab67b4840a440513769816fff6c7935b228072811fad24f8535c83cc614a55ec74c5a5cdc07824ca4378c6a816454f
6
+ metadata.gz: a68534a545c042bf936d3ca98db19fbc337cb7494df62dde144c3db7e18b197578efd37ab8e379c36496a02003ddeeb0d21f8026f95705cbf2d894851784564d
7
+ data.tar.gz: 1caafd84cdd5bdedbcc51d6bdab701711c2fbf35e90cd934a51938bdeb00b4db364f268cbd5c71de11b5a303b8238f0bdea8a48fa2068757726ed7a80332566e
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
1
  ## [Released]
2
+ ### [2.7.3] - 2024-08-12
3
+ - 新增:同时也支持打印出正向依赖
4
+
2
5
  ### [2.7.2] - 2024-08-09
3
6
  - pod install all命令丢失的问题
4
7
 
@@ -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 : 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.3"
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.3
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-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cocoapods