danger-wcc 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: c6061afcb81994d044747055b405da083c2a8f68
4
- data.tar.gz: 9113729ee91c5f20f20bcbdc7dc193c8767a4118
3
+ metadata.gz: 5129a6e15f66a145fda1a0791144cfe4b4735150
4
+ data.tar.gz: 90d46909a0c85b829aaea23b543b99a61b2141f0
5
5
  SHA512:
6
- metadata.gz: 1912d4617cea797c14e831c2fe0ba7669b85153944169f1345611eca4e4c4b6de6c3963f3735d6b1e1e51a76c29d2756534b59edbef3f15f0c56e2c78288ba3b
7
- data.tar.gz: cabc48b95b641fdc38a403e6587788d5268a2c6325ab9542252e203c7fbb4968961e1d2bce2e3210804c5b343732b6575eee311f53194187234aeae88caaaa49
6
+ metadata.gz: 0a695fb8019f7d4e90dd6499ec656e579719737dbb173fc524d17bab8162d2b8438a44f6a205d38f2b10e32ff289856fc2730eec8be54a9d0aec0294fdc2cb6b
7
+ data.tar.gz: 9e30b7eadb23699642caf8c56345121b741e9d2d91f74d574c3c3365a1b38c9f487ba0b78a23c3d6544d50540abcafa964fc417943c6094935abb77c219d32f6
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DangerWCC
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -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
- JSON.parse(File.read('package.json'))['dependencies']&.keys || []
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
@@ -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, semver, wanted, got = warning.captures
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 wants #{semver} and could unify with #{wanted}, but instead #{got}
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 wants >=7.1.0 and could unify with 7.12.10,'\
44
- ' but instead 7.4.0')
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')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-wcc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watermark Dev