danger-wcc 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/version.rb +1 -1
- data/lib/wcc/dependencies.rb +38 -12
- data/lib/wcc/plugin.rb +11 -3
- data/lib/wcc/{dependencies → util}/yarn_info.rb +5 -4
- data/lib/wcc/yarn_deduplicate.rb +72 -0
- data/spec/fixtures/dependencies/package.json_second_level_effect.diff +17 -0
- data/spec/fixtures/dependencies/package.json_second_level_effect.json +133 -0
- data/spec/fixtures/dependencies/yarn.lock_second_level_effect.lock +20022 -0
- data/spec/fixtures/dependencies/yarn_list_second_level_effect.txt +1243 -0
- data/spec/fixtures/dependencies/yarn_list_second_level_effect.txt.diff +141 -0
- data/spec/fixtures/yarn_deduplicate/list.a.txt +293 -0
- data/spec/fixtures/yarn_deduplicate/list.b.txt +295 -0
- data/spec/fixtures/yarn_deduplicate/list.diff +11 -0
- data/spec/fixtures/yarn_deduplicate/yarn.lock +20031 -0
- data/spec/wcc/dependencies_spec.rb +36 -2
- data/spec/wcc/plugin_spec.rb +7 -3
- data/spec/wcc/yarn_deduplicate_spec.rb +57 -0
- metadata +28 -7
@@ -42,7 +42,7 @@ module Danger
|
|
42
42
|
# act
|
43
43
|
subject.perform
|
44
44
|
|
45
|
-
expect(@dangerfile.violation_report[:
|
45
|
+
expect(@dangerfile.violation_report[:warnings])
|
46
46
|
.to eq([Violation.new(
|
47
47
|
'Dangerous change! react-instantsearch was updated '\
|
48
48
|
'from 5.3.2 to 5.7.0 without a corresponding '\
|
@@ -78,7 +78,7 @@ module Danger
|
|
78
78
|
# act
|
79
79
|
subject.perform
|
80
80
|
|
81
|
-
expect(@dangerfile.violation_report[:
|
81
|
+
expect(@dangerfile.violation_report[:warnings])
|
82
82
|
.to eq([Violation.new(
|
83
83
|
'Dangerous change! lodash was updated '\
|
84
84
|
'from 4.17.15 to 4.18.1 without a corresponding '\
|
@@ -90,6 +90,40 @@ module Danger
|
|
90
90
|
type: :error
|
91
91
|
)])
|
92
92
|
end
|
93
|
+
|
94
|
+
it 'ignores all changes when top level major version changes' do
|
95
|
+
allow(File).to receive(:readlines).with('yarn.lock')
|
96
|
+
.and_return(
|
97
|
+
load_fixture('dependencies/yarn.lock_second_level_effect.lock')
|
98
|
+
.split("\n")
|
99
|
+
)
|
100
|
+
allow(File).to receive(:read).with('package.json')
|
101
|
+
.and_return(
|
102
|
+
load_fixture('dependencies/'\
|
103
|
+
'package.json_second_level_effect.json')
|
104
|
+
)
|
105
|
+
|
106
|
+
allow(subject).to receive(:run_and_diff)
|
107
|
+
.with(/yarn list/)
|
108
|
+
.and_return(load_fixture(
|
109
|
+
'dependencies/yarn_list_second_level_effect.txt.diff'
|
110
|
+
))
|
111
|
+
allow(@git).to receive(:diff)
|
112
|
+
.and_return(
|
113
|
+
[
|
114
|
+
load_diff(
|
115
|
+
'package.json',
|
116
|
+
'dependencies/package.json_second_level_effect'
|
117
|
+
)
|
118
|
+
]
|
119
|
+
)
|
120
|
+
|
121
|
+
# act
|
122
|
+
subject.perform
|
123
|
+
|
124
|
+
expect(@dangerfile.violation_report[:warnings].map(&:message))
|
125
|
+
.to eq([])
|
126
|
+
end
|
93
127
|
end
|
94
128
|
end
|
95
129
|
end
|
data/spec/wcc/plugin_spec.rb
CHANGED
@@ -17,11 +17,14 @@ module Danger
|
|
17
17
|
|
18
18
|
describe 'all' do
|
19
19
|
it 'runs all default and passes default options' do
|
20
|
-
%i[
|
20
|
+
%i[
|
21
|
+
rubocop_exceptions todos brakeman
|
22
|
+
dependencies yarn_deduplicate
|
23
|
+
].each do |check|
|
21
24
|
expect(@my_plugin).to receive(check)
|
22
25
|
.with({})
|
23
26
|
end
|
24
|
-
%i[commit_lint reek jshint].each do |check|
|
27
|
+
%i[commit_lint flay reek jshint].each do |check|
|
25
28
|
expect(@my_plugin).to_not receive(check)
|
26
29
|
end
|
27
30
|
|
@@ -47,6 +50,7 @@ module Danger
|
|
47
50
|
it 'runs only enabled checks' do
|
48
51
|
options = {
|
49
52
|
rubocop_exceptions: false,
|
53
|
+
yarn_deduplicate: false,
|
50
54
|
todos: false,
|
51
55
|
brakeman: false,
|
52
56
|
reek: true
|
@@ -54,7 +58,7 @@ module Danger
|
|
54
58
|
|
55
59
|
# expect
|
56
60
|
expect(@my_plugin).to receive(:reek)
|
57
|
-
expect(@my_plugin).to receive(:
|
61
|
+
expect(@my_plugin).to receive(:dependencies)
|
58
62
|
expect(@my_plugin).to_not receive(:rubocop_exceptions)
|
59
63
|
expect(@my_plugin).to_not receive(:commit_lint)
|
60
64
|
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('../spec_helper', __dir__)
|
4
|
+
|
5
|
+
module Danger
|
6
|
+
describe Danger::DangerWCC do
|
7
|
+
before do
|
8
|
+
@dangerfile = testing_dangerfile
|
9
|
+
@my_plugin = @dangerfile.wcc
|
10
|
+
@git = @dangerfile.git
|
11
|
+
@github = @dangerfile.github
|
12
|
+
|
13
|
+
allow(@github).to receive(:pr_json)
|
14
|
+
.and_return(JSON.parse(load_fixture('github_pr.json')))
|
15
|
+
allow(subject).to receive(:run)
|
16
|
+
.with(/npm/)
|
17
|
+
.and_return('')
|
18
|
+
allow(subject).to receive(:run_and_diff)
|
19
|
+
.and_return(load_fixture('yarn_deduplicate/list.diff'))
|
20
|
+
|
21
|
+
allow(File).to receive(:exist?).and_call_original
|
22
|
+
allow(File).to receive(:read).and_call_original
|
23
|
+
allow(File).to receive(:exist?).with('yarn.lock')
|
24
|
+
.and_return(true)
|
25
|
+
allow(File).to receive(:readlines).with('yarn.lock')
|
26
|
+
.and_return(load_fixture('yarn_deduplicate/yarn.lock').split("\n"))
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'yarn_deduplicate' do
|
30
|
+
let(:subject) { Danger::DangerWCC::YarnDeduplicate.new(@my_plugin) }
|
31
|
+
|
32
|
+
it 'runs yarn-deduplicate and parses diff' do
|
33
|
+
# act
|
34
|
+
subject.perform
|
35
|
+
|
36
|
+
# assert
|
37
|
+
warnings = @dangerfile.violation_report[:warnings]
|
38
|
+
expect(warnings.length).to eq(2)
|
39
|
+
|
40
|
+
expect(warnings[0].message)
|
41
|
+
.to include('You have an opportunity to deduplicate "@babel/core".')
|
42
|
+
expect(warnings[0].message)
|
43
|
+
.to include('It wants >=7.1.0 and could unify with 7.12.10,'\
|
44
|
+
' but instead 7.4.0')
|
45
|
+
expect(warnings[0].message)
|
46
|
+
.to include('npx yarn-deduplicate -s fewer --packages "@babel/core"')
|
47
|
+
expect(warnings[0].file).to eq('yarn.lock')
|
48
|
+
expect(warnings[0].line).to eq(24)
|
49
|
+
|
50
|
+
expect(warnings[1].message)
|
51
|
+
.to include('npx yarn-deduplicate -s fewer --packages "@babel/core"')
|
52
|
+
expect(warnings[1].file).to eq('yarn.lock')
|
53
|
+
expect(warnings[1].line).to eq(24)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-wcc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Watermark Dev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -294,14 +294,15 @@ files:
|
|
294
294
|
- lib/wcc/default.jshintrc
|
295
295
|
- lib/wcc/defaults.reek
|
296
296
|
- lib/wcc/dependencies.rb
|
297
|
-
- lib/wcc/dependencies/yarn_info.rb
|
298
297
|
- lib/wcc/github.rb
|
299
298
|
- lib/wcc/jshint.rb
|
300
299
|
- lib/wcc/plugin.rb
|
301
300
|
- lib/wcc/reek.rb
|
302
301
|
- lib/wcc/rubocop_exceptions.rb
|
303
302
|
- lib/wcc/todos.rb
|
303
|
+
- lib/wcc/util/yarn_info.rb
|
304
304
|
- lib/wcc/utils.rb
|
305
|
+
- lib/wcc/yarn_deduplicate.rb
|
305
306
|
- spec/fixtures/brakeman/a.tmp
|
306
307
|
- spec/fixtures/brakeman/b.tmp
|
307
308
|
- spec/fixtures/brakeman/brakeman.diff
|
@@ -310,8 +311,13 @@ files:
|
|
310
311
|
- spec/fixtures/dependencies/package.json.diff
|
311
312
|
- spec/fixtures/dependencies/package.json_patch_bumps_minor.diff
|
312
313
|
- spec/fixtures/dependencies/package.json_patch_bumps_minor.json
|
314
|
+
- spec/fixtures/dependencies/package.json_second_level_effect.diff
|
315
|
+
- spec/fixtures/dependencies/package.json_second_level_effect.json
|
313
316
|
- spec/fixtures/dependencies/yarn.lock
|
314
317
|
- spec/fixtures/dependencies/yarn.lock_patch_bumps_minor.lock
|
318
|
+
- spec/fixtures/dependencies/yarn.lock_second_level_effect.lock
|
319
|
+
- spec/fixtures/dependencies/yarn_list_second_level_effect.txt
|
320
|
+
- spec/fixtures/dependencies/yarn_list_second_level_effect.txt.diff
|
315
321
|
- spec/fixtures/dependencies/yarn_minor_version.diff
|
316
322
|
- spec/fixtures/dependencies/yarn_minor_version.txt
|
317
323
|
- spec/fixtures/dependencies/yarn_old.txt
|
@@ -342,6 +348,10 @@ files:
|
|
342
348
|
- spec/fixtures/todo_link_same_line.diff
|
343
349
|
- spec/fixtures/todo_no_link.diff
|
344
350
|
- spec/fixtures/todo_removed.diff
|
351
|
+
- spec/fixtures/yarn_deduplicate/list.a.txt
|
352
|
+
- spec/fixtures/yarn_deduplicate/list.b.txt
|
353
|
+
- spec/fixtures/yarn_deduplicate/list.diff
|
354
|
+
- spec/fixtures/yarn_deduplicate/yarn.lock
|
345
355
|
- spec/fixtures_helper.rb
|
346
356
|
- spec/spec_helper.rb
|
347
357
|
- spec/wcc/commit_lint_spec.rb
|
@@ -353,12 +363,13 @@ files:
|
|
353
363
|
- spec/wcc/rubocop_exceptions_spec.rb
|
354
364
|
- spec/wcc/todos_spec.rb
|
355
365
|
- spec/wcc/utils_spec.rb
|
366
|
+
- spec/wcc/yarn_deduplicate_spec.rb
|
356
367
|
- spec/wcc_spec.rb
|
357
368
|
homepage: https://github.com/watermarkchurch/danger-wcc
|
358
369
|
licenses:
|
359
370
|
- Apache-2.0
|
360
371
|
metadata: {}
|
361
|
-
post_install_message:
|
372
|
+
post_install_message:
|
362
373
|
rdoc_options: []
|
363
374
|
require_paths:
|
364
375
|
- lib
|
@@ -373,9 +384,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
373
384
|
- !ruby/object:Gem::Version
|
374
385
|
version: '0'
|
375
386
|
requirements: []
|
376
|
-
rubyforge_project:
|
387
|
+
rubyforge_project:
|
377
388
|
rubygems_version: 2.5.2
|
378
|
-
signing_key:
|
389
|
+
signing_key:
|
379
390
|
specification_version: 4
|
380
391
|
summary: A Danger plugin for Watermark Church custom rules.
|
381
392
|
test_files:
|
@@ -387,8 +398,13 @@ test_files:
|
|
387
398
|
- spec/fixtures/dependencies/package.json.diff
|
388
399
|
- spec/fixtures/dependencies/package.json_patch_bumps_minor.diff
|
389
400
|
- spec/fixtures/dependencies/package.json_patch_bumps_minor.json
|
401
|
+
- spec/fixtures/dependencies/package.json_second_level_effect.diff
|
402
|
+
- spec/fixtures/dependencies/package.json_second_level_effect.json
|
390
403
|
- spec/fixtures/dependencies/yarn.lock
|
391
404
|
- spec/fixtures/dependencies/yarn.lock_patch_bumps_minor.lock
|
405
|
+
- spec/fixtures/dependencies/yarn.lock_second_level_effect.lock
|
406
|
+
- spec/fixtures/dependencies/yarn_list_second_level_effect.txt
|
407
|
+
- spec/fixtures/dependencies/yarn_list_second_level_effect.txt.diff
|
392
408
|
- spec/fixtures/dependencies/yarn_minor_version.diff
|
393
409
|
- spec/fixtures/dependencies/yarn_minor_version.txt
|
394
410
|
- spec/fixtures/dependencies/yarn_old.txt
|
@@ -419,6 +435,10 @@ test_files:
|
|
419
435
|
- spec/fixtures/todo_link_same_line.diff
|
420
436
|
- spec/fixtures/todo_no_link.diff
|
421
437
|
- spec/fixtures/todo_removed.diff
|
438
|
+
- spec/fixtures/yarn_deduplicate/list.a.txt
|
439
|
+
- spec/fixtures/yarn_deduplicate/list.b.txt
|
440
|
+
- spec/fixtures/yarn_deduplicate/list.diff
|
441
|
+
- spec/fixtures/yarn_deduplicate/yarn.lock
|
422
442
|
- spec/fixtures_helper.rb
|
423
443
|
- spec/spec_helper.rb
|
424
444
|
- spec/wcc/commit_lint_spec.rb
|
@@ -430,4 +450,5 @@ test_files:
|
|
430
450
|
- spec/wcc/rubocop_exceptions_spec.rb
|
431
451
|
- spec/wcc/todos_spec.rb
|
432
452
|
- spec/wcc/utils_spec.rb
|
453
|
+
- spec/wcc/yarn_deduplicate_spec.rb
|
433
454
|
- spec/wcc_spec.rb
|