cocoapods-jyanalyzer 0.0.5 → 0.1.0

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: 0eba382f610b90bcb5ed3fb439e1024179f8af65
4
- data.tar.gz: e525039d928e690e1799ead6f11eaa214df70762
2
+ SHA256:
3
+ metadata.gz: c73d688b827972b8d432237eea62f5b7f02e913250948321660b8d85bc94de3b
4
+ data.tar.gz: 3e45a7082b32d8079d624f8e51fe8a9a6675833c4bb624d9fd8f6f9bcc76f1f8
5
5
  SHA512:
6
- metadata.gz: 3f6a0cbce5500130a2b050af71c6969d3d13a02dd0a3f9777c55fe5dd0d0a8741ad56047f24f9c452863928758da01eadbc40081829d2f43e7cc823705c84bed
7
- data.tar.gz: 1a138fa0210e1bc83338f29f13e297a89188eee5fa9eeb79ad35b46ab315e10ce086df3f82ab9fecb9fd977f7645349c36dd91fca9e580ca3c5db51bfe4f79a8
6
+ metadata.gz: 26c203c68439f6f56713e6dcdb28be48e10942873f4ae56bfcca68afd402f18d0bd295e18c8957c46c8297e3769f3eb34dc334bea8dbe410d89737ce5a263c7f
7
+ data.tar.gz: 2cb685504c78d8042f4b07ebec46ef034587c946ad426c3a85f14771537ff4ee10cb4a8077707109084393f6c86b9cf17df4d783e4ed0ec66470e073da1fd768
@@ -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
 
@@ -89,7 +89,7 @@ module Pod
89
89
  "componentId" => componentId,
90
90
  "appDependLibraryVOList" => names]
91
91
 
92
- Pod::UI.puts JSON.pretty_generate(body).yellow
92
+ # Pod::UI.puts JSON.pretty_generate(body).yellow
93
93
 
94
94
 
95
95
  url = URI.parse(api_url)
@@ -102,8 +102,8 @@ module Pod
102
102
  header = {'content-type':'application/json'}
103
103
  response = http.post(url, data, header)
104
104
 
105
- puts response.body
106
- puts response.code
105
+ # puts response.body
106
+ # puts response.code
107
107
 
108
108
  if "#{response.code}" == "200"
109
109
  result = JSON.parse(response.body)
@@ -0,0 +1,161 @@
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
+ Pod::UI.puts "#{tmp_ary}"
65
+
66
+ currentPath = tmp_ary.join("/")
67
+ Pod::UI.puts "#{currentPath}"
68
+ exit 2
69
+
70
+ podsPath = "#{currentPath}/Pods"
71
+ Pod::UI.puts currentPath
72
+
73
+ if File.directory?(podsPath) == false
74
+ Pod::UI.puts "#{podsPath} 不存在"
75
+ exit 2
76
+ end
77
+
78
+ body = Hash["planId" => planId,
79
+ "treePackageNodeList" => recursion_dependencies(pod_targets,podsPath,0,"APP")]
80
+
81
+ # Pod::UI.puts JSON.pretty_generate(body).yellow
82
+
83
+ f=File.new("component.lock","w+")
84
+ f.puts(JSON.pretty_generate(body))
85
+ f.close
86
+
87
+ url = URI.parse(api_url)
88
+ http = Net::HTTP.new(url.host, url.port)
89
+ http.read_timeout = 9999
90
+ http.use_ssl = true if url.scheme == "https" # enable SSL/TLS
91
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE #这个也很重要
92
+ # 设置请求参数
93
+ data = body.to_json
94
+ # 设置请求头
95
+ header = {'content-type':'application/json'}
96
+ response = http.post(url, data, header)
97
+
98
+ puts response.body
99
+ puts response.code
100
+
101
+ if "#{response.code}" == "200"
102
+ result = JSON.parse(response.body)
103
+ if result["status"] == 0
104
+ puts "请求成功"
105
+ else
106
+ puts "返回结果一异常"
107
+ exit 2
108
+ end
109
+
110
+ else
111
+ puts "请求服务器失败"
112
+ exit 2
113
+ end
114
+
115
+ puts planId
116
+
117
+ end
118
+
119
+ def recursion_dependencies(pods,podsPath,i,parent_pod_name)
120
+
121
+ names = Array.new
122
+ pods.each do |item|
123
+ # puts "#{item.pod_name}=====#{i}"
124
+ size=0
125
+ IO.popen("du -sk #{podsPath}/#{item.pod_name}"){ |f|
126
+ text = f.gets.split(" ")
127
+ size = text[0]
128
+ }
129
+
130
+ type = 1
131
+ IO.popen("find #{podsPath}/#{item.pod_name} -name \"*.m\""){ |f|
132
+ text = f.gets
133
+ if text.nil?
134
+ type = 0
135
+ end
136
+ }
137
+ size=size.to_i*1024
138
+
139
+ childNodes = Array.new
140
+ if item.dependent_targets.empty?
141
+ # puts "sdfdsfdsfdsfsdfdsfdsfsdfsfdsfdsf"
142
+ else
143
+ if @podHash.has_key?(item.pod_name)
144
+ childNodes = @podHash[item.pod_name]
145
+ else
146
+ childNodes = recursion_dependencies(item.dependent_targets,podsPath,1+i,item.pod_name)
147
+ end
148
+ end
149
+
150
+ map = Hash["name" => item.pod_name,"version" => item.version,"size" => size,"system" => "ios","type" => type,"childNodes" => childNodes]
151
+ names.push(map)
152
+
153
+ end
154
+ @podHash[parent_pod_name] = names
155
+ return names
156
+ end
157
+
158
+ end
159
+ end
160
+ end
161
+ 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
 
@@ -91,7 +91,7 @@ module Pod
91
91
  "branch" => branch,
92
92
  "packageId" => packageId,
93
93
  "libraryDependList" => names]
94
- Pod::UI.puts JSON.pretty_generate(body).yellow
94
+ # Pod::UI.puts JSON.pretty_generate(body).yellow
95
95
 
96
96
  url = URI.parse(api_url)
97
97
  http = Net::HTTP.new(url.host, url.port)
@@ -102,8 +102,8 @@ module Pod
102
102
  # 设置请求头
103
103
  header = {'content-type':'application/json'}
104
104
  response = http.post(url, data, header)
105
- puts response.body
106
- puts response.code
105
+ # puts response.body
106
+ # puts response.code
107
107
 
108
108
  if "#{response.code}" == "200"
109
109
  result = JSON.parse(response.body)
@@ -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.5"
2
+ VERSION = "0.1.0"
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.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - 黄磊
8
- autorequire:
7
+ - leo
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-10 00:00:00.000000000 Z
11
+ date: 2020-07-29 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: []