cocoapods-jyanalyzer 0.0.7 → 0.1.2

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: 61b25ff821265b621573e1252ad9373330f7c710
4
- data.tar.gz: deed1e8f73c21d645a79340a0d6e585bbf19a73b
2
+ SHA256:
3
+ metadata.gz: 4e773a5bc5378f554be194194224b350a404dfbc16620c871f1b1219f8c5341f
4
+ data.tar.gz: 891dbfa3284b0f560519b022ea6a49ca6c9c4220a29b139f9e69a27d22ac1950
5
5
  SHA512:
6
- metadata.gz: fb9e34baa4ca0ab7d8f90665343b1f398281600f566733362231fa7422f81dde1085fad5b44504550e2fcd89d416b0f0998b44c811c0137ce45439203d9ffdac
7
- data.tar.gz: 4a5fb873c6bf6dc1308a00d4cb9ce81d1a9bad58ba554e38de7d182c09fc1aa46bf1f3e9613826003133dda896f3416d35617b1efbc26c43a25da37919fac00e
6
+ metadata.gz: 9cad2e2f6a1f31faa793c8e074c908cc83b2401e1d1b11a5fd1baccadda45e03bed1f04842697ad23df5e3cb7632de784610e8a341cccd1871793dea6f932c54
7
+ data.tar.gz: 8e1ab511b267b4e4ae5195065949fdf7274f9e264b999c85cfdf40656c2674c8bc2c5da3fcad02fba0e557d3a843e1afeb2c1582e0efdb416f39d0fb9bed8aa0
@@ -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
@@ -0,0 +1,205 @@
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
+ childNodes = Array.new
145
+ recursive_pods = item.recursive_dependent_targets
146
+ recursive_pods.each do |recursive_item|
147
+
148
+ recursive_size = size_lib(podsPath,recursive_item.pod_name)
149
+ recursive_type = type_lib(podsPath,recursive_item.pod_name)
150
+
151
+ recursive_map = Hash["name" => recursive_item.pod_name,"version" => recursive_item.version,"size" => recursive_size,"system" => "ios","type" => recursive_type,"childNodes" => Array.new]
152
+ childNodes.push(recursive_map)
153
+ end
154
+
155
+ size = size_lib(podsPath,item.pod_name)
156
+ type = type_lib(podsPath,item.pod_name)
157
+ map = Hash["name" => item.pod_name,"version" => item.version,"size" => size,"system" => "ios","type" => type,"childNodes" => childNodes]
158
+ names.push(map)
159
+ end
160
+ return names
161
+ end
162
+
163
+ # def recursion_dependencies(pods,podsPath,i,parent_pod_name)
164
+
165
+ # names = Array.new
166
+ # pods.each do |item|
167
+ # # puts "#{item.pod_name}=====#{i}"
168
+ # size=0
169
+ # IO.popen("du -sk #{podsPath}/#{item.pod_name}"){ |f|
170
+ # text = f.gets.split(" ")
171
+ # size = text[0]
172
+ # }
173
+
174
+ # type = 1
175
+ # IO.popen("find #{podsPath}/#{item.pod_name} -name \"*.m\""){ |f|
176
+ # text = f.gets
177
+ # if text.nil?
178
+ # type = 0
179
+ # end
180
+ # }
181
+ # size=size.to_i*1024
182
+
183
+ # childNodes = Array.new
184
+ # if item.dependent_targets.empty?
185
+ # # puts "sdfdsfdsfdsfsdfdsfdsfsdfsfdsfdsf"
186
+ # else
187
+ # if @podHash.has_key?(item.pod_name)
188
+ # childNodes = @podHash[item.pod_name]
189
+ # else
190
+ # childNodes = recursion_dependencies(item.dependent_targets,podsPath,1+i,item.pod_name)
191
+ # end
192
+ # end
193
+
194
+ # map = Hash["name" => item.pod_name,"version" => item.version,"size" => size,"system" => "ios","type" => type,"childNodes" => childNodes]
195
+ # names.push(map)
196
+
197
+ # end
198
+ # @podHash[parent_pod_name] = names
199
+ # return names
200
+ # end
201
+
202
+ end
203
+ end
204
+ end
205
+ end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsJyanalyzer
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.2"
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.7
4
+ version: 0.1.2
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: []