@@ -1571,6 +1571,7 @@ t.test('more peer dep conflicts', t => {
1571
1571
} ,
1572
1572
error : true ,
1573
1573
} ,
1574
+
1574
1575
'prod dep directly on conflicted peer, older' : {
1575
1576
pkg : {
1576
1577
dependencies : {
@@ -1580,6 +1581,7 @@ t.test('more peer dep conflicts', t => {
1580
1581
} ,
1581
1582
error : true ,
1582
1583
} ,
1584
+
1583
1585
'prod dep directly on conflicted peer, full peer set, newer' : {
1584
1586
pkg : {
1585
1587
dependencies : {
@@ -1592,6 +1594,7 @@ t.test('more peer dep conflicts', t => {
1592
1594
} ,
1593
1595
error : true ,
1594
1596
} ,
1597
+
1595
1598
'prod dep directly on conflicted peer, full peer set, older' : {
1596
1599
pkg : {
1597
1600
dependencies : {
@@ -1604,6 +1607,7 @@ t.test('more peer dep conflicts', t => {
1604
1607
} ,
1605
1608
error : true ,
1606
1609
} ,
1610
+
1607
1611
'prod dep directly on conflicted peer, meta peer set, older' : {
1608
1612
pkg : {
1609
1613
dependencies : {
@@ -1615,6 +1619,7 @@ t.test('more peer dep conflicts', t => {
1615
1619
} ,
1616
1620
error : true ,
1617
1621
} ,
1622
+
1618
1623
'dep indirectly on conflicted peer' : {
1619
1624
pkg : {
1620
1625
dependencies : {
@@ -1624,6 +1629,7 @@ t.test('more peer dep conflicts', t => {
1624
1629
} ,
1625
1630
error : true ,
1626
1631
} ,
1632
+
1627
1633
'collision forcing duplication, order 1' : {
1628
1634
pkg : {
1629
1635
dependencies : {
@@ -1634,6 +1640,7 @@ t.test('more peer dep conflicts', t => {
1634
1640
error : false ,
1635
1641
resolvable : true ,
1636
1642
} ,
1643
+
1637
1644
'collision forcing duplication, order 2' : {
1638
1645
pkg : {
1639
1646
dependencies : {
@@ -1644,6 +1651,7 @@ t.test('more peer dep conflicts', t => {
1644
1651
error : false ,
1645
1652
resolvable : true ,
1646
1653
} ,
1654
+
1647
1655
'collision forcing duplication via add, order 1' : {
1648
1656
pkg : {
1649
1657
dependencies : {
@@ -1654,6 +1662,7 @@ t.test('more peer dep conflicts', t => {
1654
1662
error : false ,
1655
1663
resolvable : true ,
1656
1664
} ,
1665
+
1657
1666
'collision forcing duplication via add, order 2' : {
1658
1667
pkg : {
1659
1668
dependencies : {
@@ -1664,6 +1673,7 @@ t.test('more peer dep conflicts', t => {
1664
1673
error : false ,
1665
1674
resolvable : true ,
1666
1675
} ,
1676
+
1667
1677
'collision forcing metadep duplication, order 1' : {
1668
1678
pkg : {
1669
1679
dependencies : {
@@ -1674,6 +1684,7 @@ t.test('more peer dep conflicts', t => {
1674
1684
error : false ,
1675
1685
resolvable : true ,
1676
1686
} ,
1687
+
1677
1688
'collision forcing metadep duplication, order 2' : {
1678
1689
pkg : {
1679
1690
dependencies : {
@@ -1684,6 +1695,7 @@ t.test('more peer dep conflicts', t => {
1684
1695
error : false ,
1685
1696
resolvable : true ,
1686
1697
} ,
1698
+
1687
1699
'direct collision forcing metadep duplication, order 1' : {
1688
1700
pkg : {
1689
1701
dependencies : {
@@ -1694,6 +1706,7 @@ t.test('more peer dep conflicts', t => {
1694
1706
error : false ,
1695
1707
resolvable : true ,
1696
1708
} ,
1709
+
1697
1710
'direct collision forcing metadep duplication, order 2' : {
1698
1711
pkg : {
1699
1712
dependencies : {
@@ -1704,6 +1717,7 @@ t.test('more peer dep conflicts', t => {
1704
1717
error : false ,
1705
1718
resolvable : true ,
1706
1719
} ,
1720
+
1707
1721
'dep with conflicting peers' : {
1708
1722
pkg : {
1709
1723
dependencies : {
@@ -1714,6 +1728,7 @@ t.test('more peer dep conflicts', t => {
1714
1728
// but it is a conflict in a peerSet that the root is sourcing.
1715
1729
error : true ,
1716
1730
} ,
1731
+
1717
1732
'metadeps with conflicting peers' : {
1718
1733
pkg : {
1719
1734
dependencies : {
@@ -1722,6 +1737,7 @@ t.test('more peer dep conflicts', t => {
1722
1737
} ,
1723
1738
error : false ,
1724
1739
} ,
1740
+
1725
1741
'metadep conflict that warns because source is target' : {
1726
1742
pkg : {
1727
1743
dependencies : {
@@ -1732,6 +1748,7 @@ t.test('more peer dep conflicts', t => {
1732
1748
error : false ,
1733
1749
resolvable : false ,
1734
1750
} ,
1751
+
1735
1752
'metadep conflict triggering the peerConflict code path' : {
1736
1753
pkg : {
1737
1754
dependencies : {
@@ -1743,6 +1760,7 @@ t.test('more peer dep conflicts', t => {
1743
1760
resolvable : false ,
1744
1761
} ,
1745
1762
} )
1763
+
1746
1764
t . jobs = cases . length
1747
1765
t . plan ( cases . length )
1748
1766
@@ -2494,3 +2512,90 @@ t.test('do not ERESOLVE on peerOptionals that are ignored anyway', t => {
2494
2512
} )
2495
2513
}
2496
2514
} )
2515
+
2516
+ t . test ( 'allow ERESOLVE to be forced when not in the source' , async t => {
2517
+ const types = [
2518
+ 'peerDependencies' ,
2519
+ 'optionalDependencies' ,
2520
+ 'devDependencies' ,
2521
+ 'dependencies' ,
2522
+ ]
2523
+
2524
+ // in these tests, the deps are both of the same type. b has a peerOptional
2525
+ // dep on peer, and peer is a direct dependency of the root.
2526
+ t . test ( 'both direct and peer of the same type' , t => {
2527
+ t . plan ( types . length )
2528
+ const pj = type => ( {
2529
+ name : '@isaacs/conflicted-peer-optional-from-dev-dep' ,
2530
+ version : '1.2.3' ,
2531
+ [ type ] : {
2532
+ '@isaacs/conflicted-peer-optional-from-dev-dep-peer' : '1' ,
2533
+ '@isaacs/conflicted-peer-optional-from-dev-dep-b' : '' ,
2534
+ } ,
2535
+ } )
2536
+
2537
+ for ( const type of types ) {
2538
+ t . test ( type , async t => {
2539
+ const path = t . testdir ( {
2540
+ 'package.json' : JSON . stringify ( pj ( type ) ) ,
2541
+ } )
2542
+ t . matchSnapshot ( await printIdeal ( path , { force : true } ) , 'use the force' )
2543
+ t . rejects ( printIdeal ( path ) , { code : 'ERESOLVE' } , 'no force' )
2544
+ } )
2545
+ }
2546
+ } )
2547
+
2548
+ // in these, the peer is a peer dep of the root, and b is a different type
2549
+ t . test ( 'peer is peer, b is some other type' , t => {
2550
+ t . plan ( types . length - 1 )
2551
+ const pj = type => ( {
2552
+ name : '@isaacs/conflicted-peer-optional-from-dev-dep' ,
2553
+ version : '1.2.3' ,
2554
+ peerDependencies : {
2555
+ '@isaacs/conflicted-peer-optional-from-dev-dep-b' : '' ,
2556
+ } ,
2557
+ [ type ] : {
2558
+ '@isaacs/conflicted-peer-optional-from-dev-dep-peer' : '1' ,
2559
+ } ,
2560
+ } )
2561
+ for ( const type of types ) {
2562
+ if ( type === 'peerDependencies' )
2563
+ continue
2564
+ t . test ( type , async t => {
2565
+ const path = t . testdir ( {
2566
+ 'package.json' : JSON . stringify ( pj ( type ) ) ,
2567
+ } )
2568
+ t . matchSnapshot ( await printIdeal ( path , { force : true } ) , 'use the force' )
2569
+ t . rejects ( printIdeal ( path ) , { code : 'ERESOLVE' } , 'no force' )
2570
+ } )
2571
+ }
2572
+ } )
2573
+
2574
+ // in these, b is a peer dep, and peer is some other type
2575
+ t . test ( 'peer is peer, b is some other type' , t => {
2576
+ t . plan ( types . length - 1 )
2577
+ const pj = type => ( {
2578
+ name : '@isaacs/conflicted-peer-optional-from-dev-dep' ,
2579
+ version : '1.2.3' ,
2580
+ peerDependencies : {
2581
+ '@isaacs/conflicted-peer-optional-from-dev-dep-peer' : '1' ,
2582
+ } ,
2583
+ [ type ] : {
2584
+ '@isaacs/conflicted-peer-optional-from-dev-dep-b' : '' ,
2585
+ } ,
2586
+ } )
2587
+ for ( const type of types ) {
2588
+ if ( type === 'peerDependencies' )
2589
+ continue
2590
+ t . test ( type , async t => {
2591
+ const path = t . testdir ( {
2592
+ 'package.json' : JSON . stringify ( pj ( type ) ) ,
2593
+ } )
2594
+ t . matchSnapshot ( await printIdeal ( path , { force : true } ) , 'use the force' )
2595
+ t . rejects ( printIdeal ( path ) , { code : 'ERESOLVE' } , 'no force' )
2596
+ } )
2597
+ }
2598
+ } )
2599
+
2600
+ t . end ( )
2601
+ } )
0 commit comments