cocoapods-jyanalyzer 0.0.7 → 0.0.8

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: 065ac6f330b3c81e5bb4a008098c2aa6857df2865cea600127b9e03c84bca894
4
+ data.tar.gz: 789ad4c5c2e651f51787f94e832f9dd1d8cf617074812814454f42cfa03b7904
5
5
  SHA512:
6
- metadata.gz: fb9e34baa4ca0ab7d8f90665343b1f398281600f566733362231fa7422f81dde1085fad5b44504550e2fcd89d416b0f0998b44c811c0137ce45439203d9ffdac
7
- data.tar.gz: 4a5fb873c6bf6dc1308a00d4cb9ce81d1a9bad58ba554e38de7d182c09fc1aa46bf1f3e9613826003133dda896f3416d35617b1efbc26c43a25da37919fac00e
6
+ metadata.gz: 299b138441f344e526b3739bc21dc92efa36c0df4cf0e974d4a72fffaa3862385cfcc44ccb83b6b6177f72d5db66e0322ca1c4000b8b323c06dbd609fb3fd300
7
+ data.tar.gz: fe398af85b4659b5e20fff4d3c37d3e212da3559188d70ba9fc8b5b7411f597d2879e114cd3f5ce836541276b85857296fabda7787d5a1cfd391ea880bd4ea04
@@ -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,146 @@
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
+ currentPath = "/Users/huanglei/Documents/HelloTrip_iOS_New/EasyBike"
59
+ podsPath = "#{currentPath}/Pods"
60
+ Pod::UI.puts currentPath
61
+
62
+ if File.directory?(podsPath) == false
63
+ Pod::UI.puts "#{podsPath} 不存在"
64
+ exit 2
65
+ end
66
+
67
+ body = Hash["planId" => planId,
68
+ "treePackageNodeList" => recursion_dependencies(pod_targets,podsPath,0,"APP")]
69
+
70
+ # Pod::UI.puts JSON.pretty_generate(body).yellow
71
+
72
+ url = URI.parse(api_url)
73
+ http = Net::HTTP.new(url.host, url.port)
74
+ http.read_timeout = 9999
75
+ http.use_ssl = true if url.scheme == "https" # enable SSL/TLS
76
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE #这个也很重要
77
+ # 设置请求参数
78
+ data = body.to_json
79
+ # 设置请求头
80
+ header = {'content-type':'application/json'}
81
+ response = http.post(url, data, header)
82
+
83
+ puts response.body
84
+ puts response.code
85
+
86
+ if "#{response.code}" == "200"
87
+ result = JSON.parse(response.body)
88
+ if result["status"] == 0
89
+ puts "请求成功"
90
+ else
91
+ puts "返回结果一异常"
92
+ exit 2
93
+ end
94
+
95
+ else
96
+ puts "请求服务器失败"
97
+ exit 2
98
+ end
99
+
100
+ puts planId
101
+
102
+ end
103
+
104
+ def recursion_dependencies(pods,podsPath,i,parent_pod_name)
105
+
106
+ names = Array.new
107
+ pods.each do |item|
108
+ # puts "#{item.pod_name}=====#{i}"
109
+ size=0
110
+ IO.popen("du -sk #{podsPath}/#{item.pod_name}"){ |f|
111
+ text = f.gets.split(" ")
112
+ size = text[0]
113
+ }
114
+
115
+ type = 1
116
+ IO.popen("find #{podsPath}/#{item.pod_name} -name \"*.m\""){ |f|
117
+ text = f.gets
118
+ if text.nil?
119
+ type = 0
120
+ end
121
+ }
122
+ size=size.to_i*1024
123
+
124
+ childNodes = Array.new
125
+ if item.dependent_targets.empty?
126
+ # puts "sdfdsfdsfdsfsdfdsfdsfsdfsfdsfdsf"
127
+ else
128
+ if @podHash.has_key?(item.pod_name)
129
+ childNodes = @podHash[item.pod_name]
130
+ else
131
+ childNodes = recursion_dependencies(item.dependent_targets,podsPath,1+i,item.pod_name)
132
+ end
133
+ end
134
+
135
+ map = Hash["name" => item.pod_name,"version" => item.version,"size" => size,"system" => "ios","type" => type,"childNodes" => childNodes]
136
+ names.push(map)
137
+
138
+ end
139
+ @podHash[parent_pod_name] = names
140
+ return names
141
+ end
142
+
143
+ end
144
+ end
145
+ end
146
+ end
@@ -1,3 +1,3 @@
1
1
  module CocoapodsJyanalyzer
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
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.0.8
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-07-23 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: []