cocoapods-entitlements-statistics 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b18c67b431404139e32390800cee36de2c9443a053716f29832d32d22424954a
4
- data.tar.gz: be771fb8171db38589b66f32155b946958d5d34b79b4ace92f8e8e6ea146bbd5
3
+ metadata.gz: 0cb97840e23a6699edbe0a827dec35d8ac76ceb69709276bf6765a13c566fe05
4
+ data.tar.gz: 44fe7389d0f48d49dc3df9c6c457b788e6185d189c4950ae49fab305cefd17bb
5
5
  SHA512:
6
- metadata.gz: e3596496a3b67f9ae0cb268fe08118f415ca5e9073cea82017bb8176cef932158b44768cfbcebb9b7185b74ff293420895f2221c8aa02d069ebae6dc04305c70
7
- data.tar.gz: 9c740e1c280ab955be62a9f51a7678bc07a50c5a28d16049cedf1964283f17ec0c12d87a6cab6710c0540821f6da7a888130264b3e7ca0d72b63a2288951f1a1
6
+ metadata.gz: 7886af55c784583ac693a70dcc89fa89a52e01862d2335c33218f77a7857038c466472aab51e205deb9a86636bbe17da8fb04db05b13a509d5a98a40c62cea22
7
+ data.tar.gz: 2858653482d7d2a9a788ea47903524644e954e96c9e72cfcaf679048682e2bd9008737073ae7639303f0b6e805512f8beb419423a51e652535a729f57543e30b
data/Gemfile CHANGED
@@ -2,8 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in cocoapods-entitlements-statistics.gemspec
4
4
  gemspec
5
- gem 'crimp'
6
- gem 'zip'
5
+
7
6
 
8
7
  group :development do
9
8
  gem 'cocoapods'
@@ -14,5 +13,6 @@ group :development do
14
13
  gem 'prettybacon'
15
14
  gem 'crimp'
16
15
  gem 'zip'
16
+ gem 'terminal-table'
17
17
 
18
18
  end
data/Gemfile.lock ADDED
@@ -0,0 +1,132 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cocoapods-entitlements-statistics (0.0.2)
5
+ CFPropertyList (>= 2.3.4, < 3.1.0)
6
+ crimp
7
+ rubyzip (>= 1.2, < 3.0)
8
+ yaml
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ CFPropertyList (3.0.6)
14
+ rexml
15
+ activesupport (7.0.4.3)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ tzinfo (~> 2.0)
20
+ addressable (2.8.4)
21
+ public_suffix (>= 2.0.2, < 6.0)
22
+ algoliasearch (1.27.5)
23
+ httpclient (~> 2.8, >= 2.8.3)
24
+ json (>= 1.5.1)
25
+ atomos (0.1.3)
26
+ bacon (1.2.0)
27
+ claide (1.1.0)
28
+ cocoapods (1.12.0)
29
+ addressable (~> 2.8)
30
+ claide (>= 1.0.2, < 2.0)
31
+ cocoapods-core (= 1.12.0)
32
+ cocoapods-deintegrate (>= 1.0.3, < 2.0)
33
+ cocoapods-downloader (>= 1.6.0, < 2.0)
34
+ cocoapods-plugins (>= 1.0.0, < 2.0)
35
+ cocoapods-search (>= 1.0.0, < 2.0)
36
+ cocoapods-trunk (>= 1.6.0, < 2.0)
37
+ cocoapods-try (>= 1.1.0, < 2.0)
38
+ colored2 (~> 3.1)
39
+ escape (~> 0.0.4)
40
+ fourflusher (>= 2.3.0, < 3.0)
41
+ gh_inspector (~> 1.0)
42
+ molinillo (~> 0.8.0)
43
+ nap (~> 1.0)
44
+ ruby-macho (>= 2.3.0, < 3.0)
45
+ xcodeproj (>= 1.21.0, < 2.0)
46
+ cocoapods-core (1.12.0)
47
+ activesupport (>= 5.0, < 8)
48
+ addressable (~> 2.8)
49
+ algoliasearch (~> 1.0)
50
+ concurrent-ruby (~> 1.1)
51
+ fuzzy_match (~> 2.0.4)
52
+ nap (~> 1.0)
53
+ netrc (~> 0.11)
54
+ public_suffix (~> 4.0)
55
+ typhoeus (~> 1.0)
56
+ cocoapods-deintegrate (1.0.5)
57
+ cocoapods-downloader (1.6.3)
58
+ cocoapods-plugins (1.0.0)
59
+ nap
60
+ cocoapods-search (1.0.1)
61
+ cocoapods-trunk (1.6.0)
62
+ nap (>= 0.8, < 2.0)
63
+ netrc (~> 0.11)
64
+ cocoapods-try (1.2.0)
65
+ colored2 (3.1.2)
66
+ concurrent-ruby (1.2.2)
67
+ crimp (1.0.0)
68
+ deepsort
69
+ deepsort (0.4.5)
70
+ escape (0.0.4)
71
+ ethon (0.16.0)
72
+ ffi (>= 1.15.0)
73
+ ffi (1.15.5)
74
+ fourflusher (2.3.1)
75
+ fuzzy_match (2.0.4)
76
+ gh_inspector (1.1.3)
77
+ httpclient (2.8.3)
78
+ i18n (1.12.0)
79
+ concurrent-ruby (~> 1.0)
80
+ json (2.6.3)
81
+ minitest (5.18.0)
82
+ mocha (2.0.2)
83
+ ruby2_keywords (>= 0.0.5)
84
+ mocha-on-bacon (0.2.3)
85
+ mocha (>= 0.13.0)
86
+ molinillo (0.8.0)
87
+ nanaimo (0.3.0)
88
+ nap (1.1.0)
89
+ netrc (0.11.0)
90
+ prettybacon (0.0.2)
91
+ bacon (~> 1.2)
92
+ public_suffix (4.0.7)
93
+ rake (13.0.6)
94
+ rexml (3.2.5)
95
+ ruby-macho (2.5.1)
96
+ ruby2_keywords (0.0.5)
97
+ rubyzip (2.3.2)
98
+ terminal-table (3.0.2)
99
+ unicode-display_width (>= 1.1.1, < 3)
100
+ typhoeus (1.4.0)
101
+ ethon (>= 0.9.0)
102
+ tzinfo (2.0.6)
103
+ concurrent-ruby (~> 1.0)
104
+ unicode-display_width (2.4.2)
105
+ xcodeproj (1.22.0)
106
+ CFPropertyList (>= 2.3.3, < 4.0)
107
+ atomos (~> 0.1.3)
108
+ claide (>= 1.0.2, < 2.0)
109
+ colored2 (~> 3.1)
110
+ nanaimo (~> 0.3.0)
111
+ rexml (~> 3.2.4)
112
+ yaml (0.2.1)
113
+ zip (2.0.2)
114
+
115
+ PLATFORMS
116
+ x86_64-darwin-21
117
+
118
+ DEPENDENCIES
119
+ bacon
120
+ bundler (>= 1.12)
121
+ cocoapods
122
+ cocoapods-entitlements-statistics!
123
+ crimp
124
+ mocha
125
+ mocha-on-bacon
126
+ prettybacon
127
+ rake
128
+ terminal-table
129
+ zip
130
+
131
+ BUNDLED WITH
132
+ 2.4.10
data/README.md CHANGED
@@ -6,16 +6,25 @@ iOS app 权限统计, 使用cocoapods plugin 触发
6
6
  ## 安装
7
7
 
8
8
  ```shell
9
- # 下载Releases v0.0.1 gem文件,然后进入下载目录执行下面命令
10
- sudo gem install cocoapods-entitlements-statistics-0.0.1.gem
9
+ sudo gem install cocoapods-entitlements-statistics
11
10
  ```
12
11
 
13
12
  ## 使用
14
13
 
14
+ 在Gemfile中声明插件
15
+
16
+ ```ruby
17
+ source "https://rubygems.org"
18
+ #声明
19
+ gem 'cocoapods-entitlements-statistics'
20
+ ...
21
+ ```
22
+
23
+
15
24
  在 Podfile 文件添加插件引用
16
25
 
17
26
  ```ruby
18
- #引入插件, 可以自定义 report_path, 默认在(iOS)项目根目录
27
+ #引入, 可以自定义 report_path, 默认在(iOS)项目根目录
19
28
  plugin 'cocoapods-entitlements-statistics', :report_path => '/Users/rd01/Desktop'
20
29
  #plugin 'cocoapods-entitlements-statistics'
21
30
 
@@ -34,6 +43,10 @@ Pod installation complete! There are 75 dependencies from the Podfile and 116 to
34
43
 
35
44
  ```
36
45
 
46
+ > 也可以手动执行cli 命令
47
+ >
48
+ > 仓库地址: https://github.com/olaola-chat/cli-app_permission_statistics
49
+
37
50
  ## 说明
38
51
 
39
52
  ##### 版本权限统计
@@ -102,11 +115,19 @@ remove capabilitys :
102
115
  #### 涉及的文件
103
116
 
104
117
  * info.plist
105
- * Runner.entitlements Capabilitys被添加后的,Xcode自动创建plist格式文件,里面包含相关Capability的声明、设置
118
+ * Runner.entitlements
119
+
120
+ Capabilitys被添加后的,Xcode自动创建plist格式文件,里面包含相关Capability的声明、设置
121
+
106
122
  * {embedded/xxx-xx-xx}.mobileprovision
107
- 包括里面的Entitlements字段, 保存一些 Capabilitys被添加后的 声明、设置
123
+
124
+ embedded.mobileprovision 存在于IPA包中,被发送到Appstore,真正安装的app 却没有这个文件
125
+
126
+ xxx-xx-xx.mobileprovision 在打包成IPA前用于工程签名的描述文件
127
+ 两者基本一致,包括里面的Entitlements字段, 保存一些 Capabilitys被添加后的 声明、设置
108
128
  * Runner.xcodeproj
109
- 工程文件SystemCapabilities字段包含了一些Capabilitys声明
129
+
130
+ 工程文件SystemCapabilities字段包含了一些Capabilitys 的开关字段
110
131
 
111
132
  相关文档:
112
133
 
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'bundler', '>= 1.12'
25
25
  spec.add_dependency 'rubyzip', '>= 1.2', '< 3.0'
26
26
  spec.add_development_dependency 'rake'
27
+ spec.add_development_dependency 'terminal-table'
27
28
  end
@@ -3,6 +3,7 @@
3
3
  require_relative "helper"
4
4
  require 'fileutils'
5
5
  require 'yaml'
6
+ require 'terminal-table'
6
7
 
7
8
  module AppEntitlementsStatistics
8
9
 
@@ -13,25 +14,28 @@ module AppEntitlementsStatistics
13
14
  attr_reader :report_path
14
15
  attr_reader :identifier
15
16
 
16
- def initialize(identifier,report_path: nil, store_path: nil)
17
+ def initialize(identifier,report_path = nil,store_path = nil)
17
18
  @identifier = identifier
18
19
  @report_path = report_path
19
20
  @store_path = store_path
20
21
  end
21
22
 
22
- def analyze
23
- load_version
24
- return singleGenerate unless @versions.length > 1
25
- pre_version = @versions[1]
26
- cur_version = @versions[0]
27
- pre_entitlements = load_entitlements_yaml(pre_version)
28
- cur_entitlements = load_entitlements_yaml(cur_version)
23
+ def analyze(versions=[])
24
+ versions.sort{|x,y| y<=>x } unless versions.size < 2
25
+ if versions.length < 2
26
+ load_version
27
+ return singleGenerate unless @versions.length > 1
28
+ else
29
+ @versions = versions
30
+ end
31
+ pre_entitlements = load_entitlements_yaml(@versions[1])
32
+ cur_entitlements = load_entitlements_yaml(@versions[0])
29
33
  return "" unless pre_entitlements.any?
30
34
  return "" unless cur_entitlements.any?
31
35
 
32
- capabilities_diff = analyze_capabilities_diff(pre_entitlements,cur_entitlements)
33
- usage_descs_diff = analyze_usage_descs_diff(pre_entitlements,cur_entitlements);
34
- report_path = generate(capabilities_diff,usage_descs_diff)
36
+ capabilities_diff = analyze_diff(pre_entitlements,cur_entitlements)
37
+ report_path = generate(capabilities_diff)
38
+ puts report_path
35
39
  report_path
36
40
  end
37
41
 
@@ -48,28 +52,26 @@ module AppEntitlementsStatistics
48
52
  report_path
49
53
  end
50
54
 
51
- def generate(capabilities_diff,usage_descs_diff)
55
+
56
+ def generate(capabilities_diff)
52
57
  return unless @versions.length > 1
53
58
  cur_version = @versions[0]
54
59
  pre_version = @versions[1]
55
-
56
- output = "\n" + "compared #{cur_version} #{pre_version}"
60
+ output = ""
57
61
  output += "\n" + capabilities_diff unless capabilities_diff.empty?
58
- output += "\n" + usage_descs_diff unless usage_descs_diff.empty?
59
- output += "\n\nThere is no difference between the two versions \n\n" unless (!capabilities_diff.empty? && !usage_descs_diff.empty?)
62
+ output += "\n\nThere is no difference between the two versions 【 #{@versions[0]} vs #{@versions[1]}】\n\n" unless !capabilities_diff.empty?
60
63
  # puts output
61
-
62
64
  output += "\n\n\n#{cur_version} entitlements list: "
63
65
  output += "\n" + read_each_line(cur_version)
64
66
  output += "\n" + "----------------------------------------"
65
67
  output += "\n\n#{pre_version} entitlements list: "
66
68
  output += "\n" + read_each_line(pre_version)
67
- output += "\n" + "----------------------------------------"
68
69
 
69
70
  report_path = report_file_name(path: @report_path)
70
71
  File.open(report_path, 'w') { |file|
71
72
  file.write(output)
72
73
  }
74
+ # puts "detail file: #{File.expand_path(report_path)}"
73
75
  report_path
74
76
  end
75
77
 
@@ -99,120 +101,97 @@ module AppEntitlementsStatistics
99
101
  yaml_content
100
102
  end
101
103
 
102
- def analyze_capabilities_diff(pre,cur)
104
+ def analyze_diff(pre,cur)
103
105
  output = ""
104
106
  cur_capabilities_summary = cur['Capabilities_Summary']
105
107
  pre_capabilities_summary = pre['Capabilities_Summary']
106
- cur_capabilities = cur['Capabilities']
107
- pre_capabilities = pre['Capabilities']
108
- output = ""
108
+
109
+ cur_usage_descs_summary = cur['PermissionsUsageDescription_Summary']
110
+ pre_usage_descs_summary = pre['PermissionsUsageDescription_Summary']
111
+
112
+ # cur_capabilities = cur['Capabilities']
113
+ # pre_capabilities = pre['Capabilities']
114
+
115
+ # cur_usage_descs = cur['PermissionsUsageDescription']
116
+ # pre_usage_descs = pre['PermissionsUsageDescription']
117
+
109
118
  # 修改
110
119
  comm_capabilities = cur_capabilities_summary.keys & pre_capabilities_summary.keys
111
- modifys = modifys_cur = modifys_pre = ""
120
+ modifyed_rows = []
112
121
  comm_capabilities.each do |key|
113
122
  if cur_capabilities_summary[key] != pre_capabilities_summary[key]
114
- modifys_cur += "\n" + '- ' + key + ': ' + cur_capabilities[key].to_s
115
- modifys_pre += "\n" + '- ' + key + ': ' + pre_capabilities[key].to_s
123
+ modifyed_rows << [ '- ' + key ]
116
124
  end
117
125
  end
118
126
 
119
- modifys += "\n" + @versions[0] unless modifys_cur.empty?
120
- modifys += modifys_cur unless modifys_cur.empty?
121
- modifys += "\n" + @versions[1] unless modifys_pre.empty?
122
- modifys += modifys_pre unless modifys_pre.empty?
123
-
124
- #新增
125
- add_capabilities = cur_capabilities_summary.keys - pre_capabilities_summary.keys
126
- adds = ""
127
- add_capabilities.each do |key|
128
- adds += "\n" + '- ' + key + ': ' + cur_capabilities[key].to_s
129
- end
130
-
131
- #移除
132
- remove_capabilities = pre_capabilities_summary.keys - cur_capabilities_summary.keys
133
- removes = ""
134
- remove_capabilities.each do |key|
135
- removes += "\n" + '- ' + key + ': ' + pre_capabilities[key].to_s
136
- end
137
-
138
- if !modifys.empty?
139
- output += "\n" + "modify capabilitys : "
140
- output += modifys
141
- output += "\n------------------------------"
142
- end
143
-
144
- if !adds.empty?
145
- output += "\n" + "add capabilitys : "
146
- output += adds
147
- output += "\n------------------------------"
148
- end
149
-
150
- if !removes.empty?
151
- output += "\n" + "remove capabilitys : "
152
- output += removes
153
- output += "\n------------------------------"
154
- end
155
-
156
- output
157
- end
158
-
159
- def analyze_usage_descs_diff(pre,cur)
160
- output = ""
161
- cur_usage_descs_summary = cur['PermissionsUsageDescription_Summary']
162
- pre_usage_descs_summary = pre['PermissionsUsageDescription_Summary']
163
-
164
- cur_usage_descs = cur['PermissionsUsageDescription']
165
- pre_usage_descs = pre['PermissionsUsageDescription']
166
-
167
- # 修改
168
127
  comm_usage_descs = cur_usage_descs_summary.keys & pre_usage_descs_summary.keys
169
- modifys = modifys_cur = modifys_pre = ""
170
128
  comm_usage_descs.each do |key|
171
129
  if cur_usage_descs_summary[key] != pre_usage_descs_summary[key]
172
- modifys_cur += "\n" + '- ' + key + ': ' + cur_usage_descs[key].to_s
173
- modifys_pre += "\n" + '- ' + key + ': ' + pre_usage_descs[key].to_s
130
+ modifyed_rows << [ '- ' + key ]
174
131
  end
175
132
  end
176
133
 
177
- modifys += "\n" + @versions[0] unless modifys_cur.empty?
178
- modifys += modifys_cur unless modifys_cur.empty?
179
- modifys += "\n" + @versions[1] unless modifys_pre.empty?
180
- modifys += modifys_pre unless modifys_pre.empty?
181
134
 
182
135
  #新增
136
+ add_capabilities = cur_capabilities_summary.keys - pre_capabilities_summary.keys
137
+ added_rows = []
138
+ add_capabilities.each do |key|
139
+ added_rows << ['- ' + key ] #+ ': ' + cur_capabilities[key].to_s
140
+ end
141
+
183
142
  add_usage_descs = cur_usage_descs_summary.keys - pre_usage_descs_summary.keys
184
- adds = ""
185
143
  add_usage_descs.each do |key|
186
- adds += "\n" + '- ' + key + ': ' + cur_usage_descs[key].to_s
144
+ added_rows << [ '- ' + key ] #+ ': ' + cur_usage_descs[key].to_s
187
145
  end
188
146
 
189
147
  #移除
148
+ remove_capabilities = pre_capabilities_summary.keys - cur_capabilities_summary.keys
149
+ removed_rows = []
150
+ remove_capabilities.each do |key|
151
+ removed_rows << ['- ' + key ] #+ ': ' + pre_capabilities[key].to_s
152
+ end
153
+
190
154
  remove_usage_descs = pre_usage_descs_summary.keys - cur_usage_descs_summary.keys
191
- removes = ""
192
155
  remove_usage_descs.each do |key|
193
- removes += "\n" + '- ' + key + ': ' + pre_usage_descs[key].to_s
156
+ removed_rows << [ '- ' + key ] #+ ': ' + pre_usage_descs[key].to_s
194
157
  end
195
158
 
196
- if !modifys.empty?
197
- output += "\n" + "modify permissions usage description : "
198
- output += modifys
199
- output += "\n------------------------------"
159
+ # Summary
160
+ max_count = [modifyed_rows.size,added_rows.size,removed_rows.size].max
161
+ if max_count == 0
162
+ return output
200
163
  end
201
164
 
202
- if !adds.empty?
203
- output += "\n" + "add permissions usage description : "
204
- output += adds
205
- output += "\n------------------------------"
165
+ table = Terminal::Table.new do |t|
166
+ t.title = "Compared #{@versions[0]} to #{@versions[1]} Summary"
167
+ t.add_row ["Modifyed", modifyed_rows.size ]
168
+ t.add_row ["New", added_rows.size ]
169
+ t.add_row ["Remove", removed_rows.size ]
206
170
  end
171
+ output += table.to_s + "\n\n"
207
172
 
208
- if !removes.empty?
209
- output += "\n" + "remove permissions usage description : "
210
- output += removes
211
- output += "\n------------------------------"
173
+ def get_value(arr,n)
174
+ return "" unless arr.length > n
175
+ return arr[n].first unless arr.length == 0
176
+ return ""
212
177
  end
213
178
 
179
+ detail_table = Terminal::Table.new do |t|
180
+ t.headings = ['Modifyed', 'New', 'Remove']
181
+ (0..max_count-1).each do |n|
182
+ t.add_row [
183
+ get_value(modifyed_rows,n),
184
+ get_value(added_rows,n),
185
+ get_value(removed_rows,n),
186
+ ]
187
+ end
188
+ end
189
+ output += detail_table.to_s + "\n\n"
214
190
  output
215
- end
191
+ end
192
+
216
193
  end
194
+ end
217
195
 
218
- end
196
+ obj = AppEntitlementsStatistics::Analyzer.new('com.ola.chat')
197
+ obj.analyze(["5.3.0","5.2.0"])
@@ -34,7 +34,7 @@ module AppEntitlementsStatistics
34
34
  end
35
35
 
36
36
  def report_file_name(path: nil)
37
- path = path ? "#{path}/entitlements_statistics" : "entitlements_statistics"
37
+ path = path.nil? ? "#{path}/entitlements_statistics" : "entitlements_statistics"
38
38
  FileUtils.mkdir_p(path) unless File.exists?(path)
39
39
  file_name = "#{path}/analyze_report"
40
40
  file_name
@@ -1,3 +1,3 @@
1
1
  module CocoapodsEntitlementsStatistics
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-entitlements-statistics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - bin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-03 00:00:00.000000000 Z
11
+ date: 2023-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yaml
@@ -106,6 +106,20 @@ dependencies:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
+ - !ruby/object:Gem::Dependency
110
+ name: terminal-table
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
109
123
  description: A short description of cocoapods-entitlements-statistics.
110
124
  email:
111
125
  - tang.bin@olaola.chat
@@ -115,6 +129,7 @@ extra_rdoc_files: []
115
129
  files:
116
130
  - ".gitignore"
117
131
  - Gemfile
132
+ - Gemfile.lock
118
133
  - LICENSE.txt
119
134
  - README.md
120
135
  - Rakefile