danger-apkstats 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/apkstats/gem_version.rb +1 -1
- data/lib/apkstats/plugin.rb +74 -64
- data/spec/apkstats_spec.rb +10 -39
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e3766086cf1f908f3a553259ce56b77077cb25af31cb6f1d2c36c565d4fc62a
|
4
|
+
data.tar.gz: a8592f39aa1288898076e59e0586c3ac941a92294d65123eaad05236e9d78588
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a93c60400f8692df2701b939cd840d740990da627c530e015ef4012f652de3770d10fb339fe1db7795fb313cbfdd2854c2ac7b5e0580b69add6995e1d1ac980
|
7
|
+
data.tar.gz: b77a1fa1c2c6cff74fdeeba07b6e4d41db76cda9b691f2d702dfdd69138d15a75fcb7897cbe4a8371de9e55ed984b8ea41389efe32fbb83c10498c247f661090
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-apkstats (0.3.
|
4
|
+
danger-apkstats (0.3.1)
|
5
5
|
danger-plugin-api (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -57,7 +57,7 @@ GEM
|
|
57
57
|
guard (~> 2.1)
|
58
58
|
guard-compat (~> 1.1)
|
59
59
|
rspec (>= 2.99.0, < 4.0)
|
60
|
-
kramdown (2.
|
60
|
+
kramdown (2.3.0)
|
61
61
|
rexml
|
62
62
|
kramdown-parser-gfm (1.1.0)
|
63
63
|
kramdown (~> 2.0)
|
data/lib/apkstats/gem_version.rb
CHANGED
data/lib/apkstats/plugin.rb
CHANGED
@@ -109,91 +109,93 @@ module Danger
|
|
109
109
|
def compare_with(other_apk_filepath, do_report: true)
|
110
110
|
raise "apk filepaths must be specified" if apk_filepath.nil? || apk_filepath.empty?
|
111
111
|
|
112
|
-
base_apk = Apkstats::Entity::ApkInfo.new(
|
113
|
-
other_apk = Apkstats::Entity::ApkInfo.new(
|
112
|
+
base_apk = Apkstats::Entity::ApkInfo.new(apkanalyzer_command, apk_filepath)
|
113
|
+
other_apk = Apkstats::Entity::ApkInfo.new(apkanalyzer_command, other_apk_filepath)
|
114
114
|
|
115
|
-
|
115
|
+
result = {
|
116
116
|
base: base_apk.to_h,
|
117
117
|
other: base_apk.to_h,
|
118
118
|
diff: Apkstats::Entity::ApkInfoDiff.new(base_apk, other_apk).to_h,
|
119
|
-
}
|
120
|
-
break unless do_report
|
119
|
+
}
|
121
120
|
|
122
|
-
|
121
|
+
return result unless do_report
|
123
122
|
|
124
|
-
|
125
|
-
md << "Property | Summary" << "\n"
|
126
|
-
md << ":--- | :---" << "\n"
|
123
|
+
diff = result[:diff]
|
127
124
|
|
128
|
-
|
129
|
-
|
125
|
+
md = +"### Apk comparison results" << "\n\n"
|
126
|
+
md << "Property | Summary" << "\n"
|
127
|
+
md << ":--- | :---" << "\n"
|
130
128
|
|
131
|
-
|
132
|
-
|
129
|
+
diff[:min_sdk].tap do |min_sdk|
|
130
|
+
break if min_sdk.size == 1
|
133
131
|
|
134
|
-
|
135
|
-
|
132
|
+
md << "Min SDK Change | Before #{min_sdk[1]} / After #{min_sdk[0]}" << "\n"
|
133
|
+
end
|
136
134
|
|
137
|
-
|
138
|
-
|
135
|
+
diff[:target_sdk].tap do |target_sdk|
|
136
|
+
break if target_sdk.size == 1
|
139
137
|
|
140
|
-
|
141
|
-
|
138
|
+
md << "Target SDK Change | Before #{target_sdk[1]} / After #{target_sdk[0]}" << "\n"
|
139
|
+
end
|
142
140
|
|
143
|
-
|
144
|
-
|
141
|
+
result[:base][:file_size].tap do |file_size|
|
142
|
+
size = Apkstats::Helper::Bytes.from_b(file_size)
|
145
143
|
|
146
|
-
|
147
|
-
|
144
|
+
md << "New File Size | #{size.to_b} Bytes. (#{size.to_mb} MB) " << "\n"
|
145
|
+
end
|
148
146
|
|
149
|
-
|
150
|
-
|
147
|
+
diff[:file_size].tap do |file_size|
|
148
|
+
size = Apkstats::Helper::Bytes.from_b(file_size)
|
151
149
|
|
152
|
-
|
153
|
-
|
150
|
+
md << "File Size Change | #{size.to_s_b} Bytes. (#{size.to_s_kb} KB) " << "\n"
|
151
|
+
end
|
154
152
|
|
155
|
-
|
156
|
-
|
153
|
+
diff[:download_size].tap do |download_size|
|
154
|
+
size = Apkstats::Helper::Bytes.from_b(download_size)
|
157
155
|
|
158
|
-
|
159
|
-
|
160
|
-
end
|
156
|
+
md << "Download Size Change | #{size.to_s_b} Bytes. (#{size.to_s_kb} KB) " << "\n"
|
157
|
+
end
|
161
158
|
|
162
|
-
|
163
|
-
|
164
|
-
|
159
|
+
result[:base][:method_reference_count].tap do |method_reference_count|
|
160
|
+
md << "New Method Reference Count | #{method_reference_count}" << "\n"
|
161
|
+
end
|
165
162
|
|
166
|
-
|
167
|
-
|
168
|
-
|
163
|
+
diff[:method_reference_count].tap do |method_reference_count|
|
164
|
+
md << "Method Reference Count Change | #{method_reference_count}" << "\n"
|
165
|
+
end
|
169
166
|
|
170
|
-
|
171
|
-
|
172
|
-
|
167
|
+
result[:base][:dex_count].tap do |dex_count|
|
168
|
+
md << "New Number of dex file(s) | #{dex_count}" << "\n"
|
169
|
+
end
|
173
170
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
break if features.empty?
|
171
|
+
diff[:dex_count].tap do |dex_count|
|
172
|
+
md << "Number of dex file(s) Change | #{dex_count}" << "\n"
|
173
|
+
end
|
178
174
|
|
179
|
-
|
180
|
-
|
181
|
-
|
175
|
+
report_hash_and_arrays = lambda { |key, name|
|
176
|
+
list_up_entities = lambda { |type_key, label|
|
177
|
+
diff[key][type_key].tap do |features|
|
178
|
+
break if features.empty?
|
182
179
|
|
183
|
-
|
184
|
-
|
180
|
+
md << "#{label} | " << features.map { |f| "- #{f}" }.join("<br>").to_s << "\n"
|
181
|
+
end
|
185
182
|
}
|
186
183
|
|
187
|
-
|
188
|
-
|
189
|
-
|
184
|
+
list_up_entities.call(:new, "New #{name}")
|
185
|
+
list_up_entities.call(:removed, "Removed #{name}")
|
186
|
+
}
|
190
187
|
|
191
|
-
|
192
|
-
|
188
|
+
report_hash_and_arrays.call(:required_features, "Required Features")
|
189
|
+
report_hash_and_arrays.call(:non_required_features, "Non-required Features")
|
190
|
+
report_hash_and_arrays.call(:permissions, "Permissions")
|
191
|
+
|
192
|
+
markdown(md)
|
193
|
+
true
|
193
194
|
rescue StandardError => e
|
194
195
|
warn("apkstats failed to execute the command due to #{e.message}")
|
195
196
|
|
196
197
|
on_error(e)
|
198
|
+
false
|
197
199
|
end
|
198
200
|
|
199
201
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
@@ -287,17 +289,25 @@ module Danger
|
|
287
289
|
def apkanalyzer_command
|
288
290
|
return @apkanalyzer_command if defined?(@apkanalyzer_command)
|
289
291
|
|
290
|
-
command_path = apkanalyzer_path ||
|
291
|
-
|
292
|
+
command_path = apkanalyzer_path || `which apkanalyzer`.chomp
|
293
|
+
|
294
|
+
if command_path.empty?
|
295
|
+
sdk_path = ENV["ANDROID_HOME"] || ENV["ANDROID_SDK_ROOT"]
|
296
|
+
|
297
|
+
if sdk_path
|
298
|
+
tmp_path = File.join(sdk_path, "cmdline-tools/tools/bin/apkanalyzer")
|
299
|
+
tmp_path = File.join(sdk_path, "tools/bin/apkanalyzer") unless File.executable?(tmp_path)
|
300
|
+
|
301
|
+
command_path = tmp_path if File.executable?(tmp_path)
|
302
|
+
else
|
303
|
+
warn("apkstats will not infer the apkanalyzer path in further versions so please include apkanalyer in your PATH or specify it explicitly.")
|
304
|
+
end
|
305
|
+
end
|
292
306
|
|
293
|
-
|
294
|
-
warn("apkstats will not use ANDROID_HOME in further versions because ANDROID_HOME has been officially deprecated.")
|
295
|
-
else
|
296
|
-
raise Error, "Please specify apkanalyzer_path to execute apkstats"
|
297
|
-
end
|
307
|
+
command_path = command_path.chomp
|
298
308
|
|
299
|
-
|
300
|
-
|
309
|
+
raise Error, "Please include apkanalyer in your PATH or specify it explicitly." if command_path.empty?
|
310
|
+
raise Error, "#{command_path} is not executable." unless File.executable?(command_path)
|
301
311
|
|
302
312
|
@apkanalyzer_command = Apkstats::Command::ApkAnalyzer.new(command_path: command_path)
|
303
313
|
end
|
data/spec/apkstats_spec.rb
CHANGED
@@ -4,11 +4,6 @@ require File.expand_path("spec_helper", __dir__)
|
|
4
4
|
|
5
5
|
module Danger
|
6
6
|
describe Danger::DangerApkstats do
|
7
|
-
before do
|
8
|
-
ENV.delete("ANDROID_HOME")
|
9
|
-
ENV.delete("ANDROID_SDK_ROOT")
|
10
|
-
end
|
11
|
-
|
12
7
|
it "should be a plugin" do
|
13
8
|
expect(Danger::DangerApkstats.new(nil)).to be_a Danger::Plugin
|
14
9
|
end
|
@@ -22,48 +17,24 @@ module Danger
|
|
22
17
|
allow(apkstats.github).to receive(:pr_json).and_return(json)
|
23
18
|
end
|
24
19
|
|
25
|
-
#
|
26
|
-
|
27
|
-
|
28
|
-
it { expect { apkstats.send(:apkanalyzer_command) }.to raise_error(Danger::DangerApkstats::Error) }
|
20
|
+
describe "#compare_with" do
|
21
|
+
let(:apk_base) { fixture_path + "app-base.apk" }
|
22
|
+
let(:apk_other1) { fixture_path + "app-other1.apk" }
|
29
23
|
|
30
|
-
|
31
|
-
|
32
|
-
ENV["ANDROID_HOME"] = "dummy"
|
33
|
-
end
|
34
|
-
|
35
|
-
it { expect(apkstats.send(:apkanalyzer_command)).to be_kind_of(Apkstats::Command::ApkAnalyzer) }
|
36
|
-
end
|
24
|
+
before do
|
25
|
+
apkstats.apkanalyzer_path = `which apkanalyzer`.chomp
|
37
26
|
end
|
38
27
|
|
39
|
-
context "
|
40
|
-
|
41
|
-
apkstats.command_path = "dummy"
|
42
|
-
end
|
43
|
-
|
44
|
-
it { expect(apkstats.send(:apkanalyzer_command)).to be_kind_of(Apkstats::Command::ApkAnalyzer) }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#apkanalyzer_path=" do
|
49
|
-
context "unless analyzer_path is given" do
|
50
|
-
it { expect { apkstats.send(:apkanalyzer_command) }.to raise_error(Danger::DangerApkstats::Error) }
|
51
|
-
|
52
|
-
context "with ANDROID_HOME" do
|
53
|
-
before do
|
54
|
-
ENV["ANDROID_HOME"] = "dummy"
|
55
|
-
end
|
56
|
-
|
57
|
-
it { expect(apkstats.send(:apkanalyzer_command)).to be_kind_of(Apkstats::Command::ApkAnalyzer) }
|
58
|
-
end
|
28
|
+
context "unless apk_filepath is specified" do
|
29
|
+
it { expect(apkstats.compare_with(apk_other1, do_report: true)).to be_falsey }
|
59
30
|
end
|
60
31
|
|
61
|
-
context "
|
32
|
+
context "otherwise" do
|
62
33
|
before do
|
63
|
-
apkstats.
|
34
|
+
apkstats.apk_filepath = apk_base
|
64
35
|
end
|
65
36
|
|
66
|
-
it { expect(apkstats.
|
37
|
+
it { expect(apkstats.compare_with(apk_other1, do_report: true)).to be_truthy }
|
67
38
|
end
|
68
39
|
end
|
69
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-apkstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jumpei Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -194,7 +194,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
- !ruby/object:Gem::Version
|
195
195
|
version: '0'
|
196
196
|
requirements: []
|
197
|
-
|
197
|
+
rubyforge_project:
|
198
|
+
rubygems_version: 2.7.6.2
|
198
199
|
signing_key:
|
199
200
|
specification_version: 4
|
200
201
|
summary: This is a danger plugin to inspect android application file.
|