cocoapods-jyanalyzer 0.0.6 → 0.1.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
- SHA1:
3
- metadata.gz: 46c8cf020f8fbf2bfefe6a67ccf1cdb82c5b397f
4
- data.tar.gz: 840debb8561c01b42b5702324522008bc3884ab3
2
+ SHA256:
3
+ metadata.gz: 10254162ffd1c7376e940fbba7aefe86d5e46167c077a57844d5a9f90075c5c1
4
+ data.tar.gz: 8148151ff89ff8a73909ea3b6cd13c7c87f7d922dd60bcca6ef0f169fcc02faf
5
5
  SHA512:
6
- metadata.gz: 989cc101695195e08d1699bdb9089804285eb819d91dabadf69664ff698d350b87c5a11719014a6edfeb49f4ce5f523c13eed158a4753d52ce56fe08521c32e8
7
- data.tar.gz: 79b6ca41d492d94f55511767a9f8d15c401902d750d3d5d3776d8ab187460d1b393b94df4918daacfeb7d4ed0da98055f950acc8c093844887fea93401d1e71a
6
+ metadata.gz: e712abffc2864f29fa866d5b98500622d1ad616ac93e26ef568fe8a1af44ab725bf3dd94d29c3e1c1830301a652f74f092dd3abad2225ac96f7df330947b2053
7
+ data.tar.gz: d6d275f8d8dbbdd752ac27c13c7e3fe75b64e33b4fe76167d511922042943237560cc7f9d741ab5b4f5d5b27f197e944c2b2985e6132cd0c8e660509f82d1f19
@@ -5,13 +5,14 @@ module Pod
5
5
  require 'cocoapods-jyanalyzer/command/jyanalyzer/app'
6
6
  require 'cocoapods-jyanalyzer/command/jyanalyzer/recursion'
7
7
  require 'cocoapods-jyanalyzer/command/jyanalyzer/depend'
8
+ require 'cocoapods-jyanalyzer/command/jyanalyzer/component'
8
9
 
9
10
  self.abstract_command = true
10
11
  self.default_subcommand = 'app'
11
12
  self.summary = '哈啰pod依赖分析'
12
13
 
13
14
  self.description = <<-DESC
14
- 哈啰pod依赖分析:recursion、app 这是给服务端用的,请勿使用
15
+ 哈啰pod依赖分析:recursion、app 、component 这是给服务端用的,请勿使用
15
16
 
16
17
  本地使用 depend 命令即可
17
18
  DESC
@@ -45,7 +45,7 @@ module Pod
45
45
  elsif map[0] == "api_url"
46
46
  api_url = map[1]
47
47
  else
48
- Pod::UI.puts " "
48
+
49
49
  end
50
50
  end
51
51
 
@@ -0,0 +1,208 @@
1
+ require 'net/http'
2
+ require 'json'
3
+ require 'openssl'
4
+
5
+ module Pod
6
+ class Command
7
+ class Jyanalyzer
8
+ class Component < Jyanalyzer
9
+ include RepoUpdate
10
+ include ProjectDirectory
11
+
12
+ self.summary = '服务端使用:组件库依赖关系树、包大小, 使用: pod jyanalyzer component planId=planId api_url=api_url'
13
+ self.arguments = [
14
+ CLAide::Argument.new('POD_NAMES', false, true),
15
+ CLAide::Argument.new('TAG', true)
16
+ ]
17
+
18
+ def initialize(argv)
19
+ @pods = argv.arguments!
20
+ @podHash = Hash.new
21
+ super
22
+ end
23
+
24
+
25
+ def run
26
+
27
+ planId = ""
28
+ api_url = "https://sunflower.hellobike.cn:20000/plugin/setComponentInfo"
29
+
30
+ @pods.each do |item|
31
+ map = item.split("=")
32
+ if map[0] == "planId"
33
+ planId = map[1]
34
+ elsif map[0] == "api_url"
35
+ api_url = map[1]
36
+ else
37
+
38
+ end
39
+ end
40
+
41
+ if planId.empty?
42
+ UI.puts 'planId 不可为空'
43
+ exit 2
44
+ end
45
+
46
+
47
+ verify_podfile_exists!
48
+ installer = installer_for_config
49
+ installer.repo_update = repo_update?(:default => true)
50
+ UI.puts 'Update all pods'.yellow
51
+ installer.update = true
52
+ installer.prepare
53
+ installer.resolve_dependencies
54
+ pod_targets = installer.pod_targets;
55
+
56
+ Pod::UI.puts "组件库依赖关系树、包大小, 使用: pod jyanalyzer component"
57
+
58
+
59
+ podfile_path = "#{Config.instance.podfile_path}"
60
+ Pod::UI.puts "#{podfile_path}"
61
+
62
+ tmp_ary = podfile_path.split("/")
63
+ tmp_ary.pop
64
+
65
+ currentPath = tmp_ary.join("/")
66
+
67
+ podsPath = "#{currentPath}/Pods"
68
+ Pod::UI.puts currentPath
69
+
70
+ if File.directory?(podsPath) == false
71
+ Pod::UI.puts "#{podsPath} 不存在"
72
+ exit 2
73
+ end
74
+
75
+ body = Hash["planId" => planId,
76
+ "treePackageNodeList" => dependencies_tmp(pod_targets,podsPath)]
77
+
78
+ # Pod::UI.puts JSON.pretty_generate(body).yellow
79
+
80
+ f=File.new("component.lock","w+")
81
+ f.puts(JSON.pretty_generate(body))
82
+ f.close
83
+ return
84
+
85
+ url = URI.parse(api_url)
86
+ http = Net::HTTP.new(url.host, url.port)
87
+ http.read_timeout = 9999
88
+ http.use_ssl = true if url.scheme == "https" # enable SSL/TLS
89
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE #这个也很重要
90
+ # 设置请求参数
91
+ data = body.to_json
92
+ # 设置请求头
93
+ header = {'content-type':'application/json'}
94
+ response = http.post(url, data, header)
95
+
96
+ puts response.body
97
+ puts response.code
98
+
99
+ if "#{response.code}" == "200"
100
+ result = JSON.parse(response.body)
101
+ if result["status"] == 0
102
+ puts "请求成功"
103
+ else
104
+ puts "返回结果一异常"
105
+ exit 2
106
+ end
107
+
108
+ else
109
+ puts "请求服务器失败"
110
+ exit 2
111
+ end
112
+
113
+ puts planId
114
+
115
+ end
116
+
117
+
118
+ def type_lib(podsPath,pod_name)
119
+ type = 1
120
+ IO.popen("find #{podsPath}/#{pod_name} -name \"*.m\""){ |f|
121
+ text = f.gets
122
+ if text.nil?
123
+ type = 0
124
+ end
125
+ }
126
+ return type
127
+ end
128
+
129
+ def size_lib(podsPath,pod_name)
130
+ size=0
131
+ IO.popen("du -sk #{podsPath}/#{pod_name}"){ |f|
132
+ text = f.gets.split(" ")
133
+ size = text[0]
134
+ }
135
+ size=size.to_i*1024
136
+ return size
137
+ end
138
+
139
+ def dependencies_tmp(pods,podsPath)
140
+
141
+ names = Array.new
142
+ pods.each do |item|
143
+
144
+
145
+
146
+ childNodes = Array.new
147
+ recursive_pods = item.recursive_dependent_targets
148
+ recursive_pods.each do |recursive_item|
149
+
150
+ recursive_size = size_lib(podsPath,recursive_item.pod_name)
151
+ recursive_type = type_lib(podsPath,recursive_item.pod_name)
152
+
153
+ recursive_map = Hash["name" => recursive_item.pod_name,"version" => recursive_item.version,"size" => recursive_size,"system" => "ios","type" => recursive_type,"childNodes" => Array.new]
154
+ childNodes.push(recursive_map)
155
+ end
156
+
157
+ size = size_lib(podsPath,item.pod_name)
158
+ type = type_lib(podsPath,item.pod_name)
159
+ map = Hash["name" => item.pod_name,"version" => item.version,"size" => size,"system" => "ios","type" => type,"childNodes" => childNodes]
160
+ names.push(map)
161
+ end
162
+ return names
163
+
164
+ end
165
+
166
+ # def recursion_dependencies(pods,podsPath,i,parent_pod_name)
167
+
168
+ # names = Array.new
169
+ # pods.each do |item|
170
+ # # puts "#{item.pod_name}=====#{i}"
171
+ # size=0
172
+ # IO.popen("du -sk #{podsPath}/#{item.pod_name}"){ |f|
173
+ # text = f.gets.split(" ")
174
+ # size = text[0]
175
+ # }
176
+
177
+ # type = 1
178
+ # IO.popen("find #{podsPath}/#{item.pod_name} -name \"*.m\""){ |f|
179
+ # text = f.gets
180
+ # if text.nil?
181
+ # type = 0
182
+ # end
183
+ # }
184
+ # size=size.to_i*1024
185
+
186
+ # childNodes = Array.new
187
+ # if item.dependent_targets.empty?
188
+ # # puts "sdfdsfdsfdsfsdfdsfdsfsdfsfdsfdsf"
189
+ # else
190
+ # if @podHash.has_key?(item.pod_name)
191
+ # childNodes = @podHash[item.pod_name]
192
+ # else
193
+ # childNodes = recursion_dependencies(item.dependent_targets,podsPath,1+i,item.pod_name)
194
+ # end
195
+ # end
196
+
197
+ # map = Hash["name" => item.pod_name,"version" => item.version,"size" => size,"system" => "ios","type" => type,"childNodes" => childNodes]
198
+ # names.push(map)
199
+
200
+ # end
201
+ # @podHash[parent_pod_name] = names
202
+ # return names
203
+ # end
204
+
205
+ end
206
+ end
207
+ end
208
+ end
@@ -37,7 +37,7 @@ module Pod
37
37
  elsif map[0] == "api_url"
38
38
  api_url = map[1]
39
39
  else
40
- Pod::UI.puts " "
40
+ # Pod::UI.puts " "
41
41
  end
42
42
  end
43
43
 
@@ -131,7 +131,7 @@ module Pod
131
131
  names.push(map)
132
132
 
133
133
  if item.dependent_targets.empty?
134
- puts ""
134
+ # puts ""
135
135
  else
136
136
  news = recursion_dependencies(item)
137
137
  names = names + news
@@ -1,3 +1,3 @@
1
1
  module CocoapodsJyanalyzer
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-jyanalyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - leo
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-20 00:00:00.000000000 Z
11
+ date: 2020-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -49,6 +49,7 @@ files:
49
49
  - lib/cocoapods-jyanalyzer/command.rb
50
50
  - lib/cocoapods-jyanalyzer/command/jyanalyzer.rb
51
51
  - lib/cocoapods-jyanalyzer/command/jyanalyzer/app.rb
52
+ - lib/cocoapods-jyanalyzer/command/jyanalyzer/component.rb
52
53
  - lib/cocoapods-jyanalyzer/command/jyanalyzer/depend.rb
53
54
  - lib/cocoapods-jyanalyzer/command/jyanalyzer/recursion.rb
54
55
  - lib/cocoapods-jyanalyzer/gem_version.rb
@@ -57,7 +58,7 @@ homepage: https://github.com/EXAMPLE/cocoapods-jyanalyzer
57
58
  licenses:
58
59
  - MIT
59
60
  metadata: {}
60
- post_install_message:
61
+ post_install_message:
61
62
  rdoc_options: []
62
63
  require_paths:
63
64
  - lib
@@ -72,9 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
73
  - !ruby/object:Gem::Version
73
74
  version: '0'
74
75
  requirements: []
75
- rubyforge_project:
76
- rubygems_version: 2.6.14
77
- signing_key:
76
+ rubygems_version: 3.1.4
77
+ signing_key:
78
78
  specification_version: 4
79
79
  summary: A longer description of cocoapods-jyanalyzer.
80
80
  test_files: []