danger-wcc 0.1.1 → 0.1.2
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 +4 -4
- data/lib/version.rb +1 -1
- data/lib/wcc/util/yarn_info.rb +16 -2
- data/lib/wcc/yarn_deduplicate.rb +2 -3
- data/spec/wcc/dependencies_spec.rb +1 -0
- data/spec/wcc/yarn_deduplicate_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5129a6e15f66a145fda1a0791144cfe4b4735150
|
4
|
+
data.tar.gz: 90d46909a0c85b829aaea23b543b99a61b2141f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a695fb8019f7d4e90dd6499ec656e579719737dbb173fc524d17bab8162d2b8438a44f6a205d38f2b10e32ff289856fc2730eec8be54a9d0aec0294fdc2cb6b
|
7
|
+
data.tar.gz: 9e30b7eadb23699642caf8c56345121b741e9d2d91f74d574c3c3365a1b38c9f487ba0b78a23c3d6544d50540abcafa964fc417943c6094935abb77c219d32f6
|
data/lib/version.rb
CHANGED
data/lib/wcc/util/yarn_info.rb
CHANGED
@@ -6,9 +6,23 @@ class Danger::DangerWCC::Util
|
|
6
6
|
@yarn_lock ||= File.readlines(@options[:lockfile] || 'yarn.lock')
|
7
7
|
end
|
8
8
|
|
9
|
-
def package_json_dependencies
|
9
|
+
def package_json_dependencies # rubocop:disable Metrics/AbcSize
|
10
10
|
@package_json_dependencies ||=
|
11
|
-
|
11
|
+
begin
|
12
|
+
root = JSON.parse(File.read('package.json'))
|
13
|
+
(root['dependencies']&.keys || []).tap do |deps|
|
14
|
+
workspaces = root['workspaces']
|
15
|
+
next unless workspaces && !workspaces.empty?
|
16
|
+
|
17
|
+
# Add in deps from all workspaces
|
18
|
+
workspaces.each do |ws|
|
19
|
+
Dir.glob(File.join(ws, 'package.json')).each do |package_file|
|
20
|
+
d = JSON.parse(File.read(package_file))['dependencies']&.keys
|
21
|
+
deps.concat(d || [])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
12
26
|
end
|
13
27
|
|
14
28
|
def package_json_changes
|
data/lib/wcc/yarn_deduplicate.rb
CHANGED
@@ -48,15 +48,14 @@ class Danger::DangerWCC < Danger::Plugin
|
|
48
48
|
warning = line.content.match(DEDUPE_REGEXP)
|
49
49
|
return unless warning
|
50
50
|
|
51
|
-
pkg,
|
51
|
+
pkg, _semver, wanted, got = warning.captures
|
52
52
|
|
53
53
|
idx = yarn_info.find_index_in_lockfile(
|
54
54
|
pkg, got
|
55
55
|
)
|
56
56
|
msg = <<~HEREDOC
|
57
57
|
You have an opportunity to deduplicate "#{pkg}".
|
58
|
-
It
|
59
|
-
was installed alongside it.
|
58
|
+
It's using #{got} but could use the existing version #{wanted}.
|
60
59
|
|
61
60
|
You can fix this by running :
|
62
61
|
`npx yarn-deduplicate -s fewer --packages "#{pkg}"`
|
@@ -22,6 +22,7 @@ module Danger
|
|
22
22
|
.and_return(load_fixture('dependencies/yarn.lock').split("\n"))
|
23
23
|
allow(File).to receive(:read).with('package.json')
|
24
24
|
.and_return(load_fixture('dependencies/package.json'))
|
25
|
+
allow(Dir).to receive(:glob).and_return([])
|
25
26
|
end
|
26
27
|
|
27
28
|
describe 'yarn dependencies' do
|
@@ -40,8 +40,8 @@ module Danger
|
|
40
40
|
expect(warnings[0].message)
|
41
41
|
.to include('You have an opportunity to deduplicate "@babel/core".')
|
42
42
|
expect(warnings[0].message)
|
43
|
-
.to include('It
|
44
|
-
'
|
43
|
+
.to include('It\'s using 7.4.0 but could use the existing version '\
|
44
|
+
'7.12.10.')
|
45
45
|
expect(warnings[0].message)
|
46
46
|
.to include('npx yarn-deduplicate -s fewer --packages "@babel/core"')
|
47
47
|
expect(warnings[0].file).to eq('yarn.lock')
|