@teambit/pnpm 1.0.1284 → 1.0.1285
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.
- package/dist/load-pnpm-esm.cjs +8 -5
- package/dist/lockfile-deps-graph-converter.js +42 -0
- package/dist/lockfile-deps-graph-converter.js.map +1 -1
- package/dist/lockfile-deps-graph-converter.spec.js +280 -0
- package/dist/lockfile-deps-graph-converter.spec.js.map +1 -1
- package/dist/pnpm.package-manager.spec.js +56 -0
- package/dist/pnpm.package-manager.spec.js.map +1 -1
- package/dist/{preview-1792610244914.js → preview-1792613016226.js} +2 -2
- package/load-pnpm-esm.cjs +8 -5
- package/package.json +6 -5
|
@@ -1473,6 +1473,286 @@ describe('convertGraphToLockfile on invalid graph', () => {
|
|
|
1473
1473
|
(0, _chai().expect)(error?.message).eq(`Failed to generate a valid lockfile. The "packages['foo@1.0.0']" entry doesn't have a "resolution" field.`);
|
|
1474
1474
|
});
|
|
1475
1475
|
});
|
|
1476
|
+
|
|
1477
|
+
// A graph is stored by a workspace whose root may provide a different version of a package than
|
|
1478
|
+
// the root of the install restoring it (the capsules root pins the env's peers). pnpm resolves
|
|
1479
|
+
// peers from the root and dedupes satisfiable ranges to it, so the restored lockfile must not keep
|
|
1480
|
+
// the workspace's other version next to the root's one.
|
|
1481
|
+
describe('convertGraphToLockfile with a root manifest that provides a package the graph resolved to another version', () => {
|
|
1482
|
+
const rootDir = process.cwd();
|
|
1483
|
+
const compDir = _path().default.resolve('comps/comp1');
|
|
1484
|
+
const helmetSnapshot = '@types/react-helmet@6.1.6';
|
|
1485
|
+
const peerSnapshot = 'react-types-peer@1.0.0(@types/react@18.2.23)';
|
|
1486
|
+
const resolve = async () => ({
|
|
1487
|
+
resolution: {
|
|
1488
|
+
integrity: '0000'
|
|
1489
|
+
}
|
|
1490
|
+
});
|
|
1491
|
+
function createGraph(opts = {}) {
|
|
1492
|
+
const typesReactDep = opts.peerKeyed ? peerSnapshot : '@types/react@18.2.23';
|
|
1493
|
+
const packages = new Map([[helmetSnapshot, {
|
|
1494
|
+
resolution: {
|
|
1495
|
+
integrity: 'sha512-helmet'
|
|
1496
|
+
}
|
|
1497
|
+
}], ['@types/react@18.2.23', opts.typesReactUnresolved ? {} : {
|
|
1498
|
+
resolution: {
|
|
1499
|
+
integrity: 'sha512-react18'
|
|
1500
|
+
}
|
|
1501
|
+
}], ['react-types-peer@1.0.0', {
|
|
1502
|
+
resolution: {
|
|
1503
|
+
integrity: 'sha512-peer'
|
|
1504
|
+
},
|
|
1505
|
+
peerDependencies: {
|
|
1506
|
+
'@types/react': '*'
|
|
1507
|
+
}
|
|
1508
|
+
}]]);
|
|
1509
|
+
const edges = [{
|
|
1510
|
+
id: _objects().DependenciesGraph.ROOT_EDGE_ID,
|
|
1511
|
+
neighbours: [{
|
|
1512
|
+
id: helmetSnapshot,
|
|
1513
|
+
name: '@types/react-helmet',
|
|
1514
|
+
specifier: '6.1.6',
|
|
1515
|
+
lifecycle: 'dev'
|
|
1516
|
+
}]
|
|
1517
|
+
}, {
|
|
1518
|
+
id: helmetSnapshot,
|
|
1519
|
+
neighbours: [{
|
|
1520
|
+
id: typesReactDep
|
|
1521
|
+
}]
|
|
1522
|
+
}, {
|
|
1523
|
+
id: peerSnapshot,
|
|
1524
|
+
attr: {
|
|
1525
|
+
pkgId: 'react-types-peer@1.0.0'
|
|
1526
|
+
},
|
|
1527
|
+
neighbours: [{
|
|
1528
|
+
id: '@types/react@18.2.23'
|
|
1529
|
+
}]
|
|
1530
|
+
}];
|
|
1531
|
+
return new (_objects().DependenciesGraph)({
|
|
1532
|
+
packages,
|
|
1533
|
+
edges,
|
|
1534
|
+
overrides: opts.overrides
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
function convert(rootManifest, graph = createGraph()) {
|
|
1538
|
+
return (0, _lockfileDepsGraphConverter().convertGraphToLockfile)(graph, {
|
|
1539
|
+
manifests: {
|
|
1540
|
+
[rootDir]: rootManifest,
|
|
1541
|
+
[compDir]: {
|
|
1542
|
+
devDependencies: {
|
|
1543
|
+
'@types/react-helmet': '6.1.6'
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
},
|
|
1547
|
+
rootDir,
|
|
1548
|
+
resolve
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
it('should drop a reference to another version of a package the root pins, so the install resolves it to the root version', async () => {
|
|
1552
|
+
const lockfile = await convert({
|
|
1553
|
+
dependencies: {
|
|
1554
|
+
'@types/react': '17.0.87'
|
|
1555
|
+
}
|
|
1556
|
+
});
|
|
1557
|
+
(0, _chai().expect)(lockfile.snapshots[helmetSnapshot]).to.eql({
|
|
1558
|
+
dependencies: {}
|
|
1559
|
+
});
|
|
1560
|
+
(0, _chai().expect)(lockfile.packages['@types/react@18.2.23']).to.equal(undefined);
|
|
1561
|
+
(0, _chai().expect)(lockfile.snapshots['@types/react@18.2.23']).to.equal(undefined);
|
|
1562
|
+
});
|
|
1563
|
+
it('should drop a peer resolution of the other version', async () => {
|
|
1564
|
+
const lockfile = await convert({
|
|
1565
|
+
dependencies: {
|
|
1566
|
+
'@types/react': '17.0.87'
|
|
1567
|
+
}
|
|
1568
|
+
}, createGraph({
|
|
1569
|
+
peerKeyed: true
|
|
1570
|
+
}));
|
|
1571
|
+
(0, _chai().expect)(lockfile.snapshots[peerSnapshot]).to.eql({
|
|
1572
|
+
dependencies: {}
|
|
1573
|
+
});
|
|
1574
|
+
(0, _chai().expect)(lockfile.packages['@types/react@18.2.23']).to.equal(undefined);
|
|
1575
|
+
});
|
|
1576
|
+
it('should keep a regular dependency when the root specifier is a range, a tag or a link', async () => {
|
|
1577
|
+
for (const specifier of ['^17.0.0', 'latest', 'link:../types-react']) {
|
|
1578
|
+
const lockfile = await convert({
|
|
1579
|
+
dependencies: {
|
|
1580
|
+
'@types/react': specifier
|
|
1581
|
+
}
|
|
1582
|
+
});
|
|
1583
|
+
(0, _chai().expect)(lockfile.snapshots[helmetSnapshot], specifier).to.eql({
|
|
1584
|
+
dependencies: {
|
|
1585
|
+
'@types/react': '18.2.23'
|
|
1586
|
+
}
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
});
|
|
1590
|
+
it('should drop a peer resolution whatever the root specifier is, since pnpm resolves peers from the root', async () => {
|
|
1591
|
+
for (const specifier of ['^17.0.0', 'latest', 'link:../types-react', 'npm:@types/react@17.0.87']) {
|
|
1592
|
+
const lockfile = await convert({
|
|
1593
|
+
dependencies: {
|
|
1594
|
+
'@types/react': specifier
|
|
1595
|
+
}
|
|
1596
|
+
}, createGraph({
|
|
1597
|
+
peerKeyed: true
|
|
1598
|
+
}));
|
|
1599
|
+
(0, _chai().expect)(lockfile.snapshots[peerSnapshot], specifier).to.eql({
|
|
1600
|
+
dependencies: {}
|
|
1601
|
+
});
|
|
1602
|
+
(0, _chai().expect)(lockfile.packages['@types/react@18.2.23'], specifier).to.equal(undefined);
|
|
1603
|
+
}
|
|
1604
|
+
});
|
|
1605
|
+
it('should keep the reference when it is already the root version, however the root spells it', async () => {
|
|
1606
|
+
for (const specifier of ['18.2.23', 'v18.2.23']) {
|
|
1607
|
+
const lockfile = await convert({
|
|
1608
|
+
dependencies: {
|
|
1609
|
+
'@types/react': specifier
|
|
1610
|
+
}
|
|
1611
|
+
});
|
|
1612
|
+
(0, _chai().expect)(lockfile.snapshots[helmetSnapshot], specifier).to.eql({
|
|
1613
|
+
dependencies: {
|
|
1614
|
+
'@types/react': '18.2.23'
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
const peerLockfile = await convert({
|
|
1618
|
+
dependencies: {
|
|
1619
|
+
'@types/react': specifier
|
|
1620
|
+
}
|
|
1621
|
+
}, createGraph({
|
|
1622
|
+
peerKeyed: true
|
|
1623
|
+
}));
|
|
1624
|
+
(0, _chai().expect)(peerLockfile.snapshots[peerSnapshot], specifier).to.eql({
|
|
1625
|
+
dependencies: {
|
|
1626
|
+
'@types/react': '18.2.23'
|
|
1627
|
+
}
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
});
|
|
1631
|
+
it('should keep the reference when the root provides the package only as an optional dependency', async () => {
|
|
1632
|
+
const lockfile = await convert({
|
|
1633
|
+
optionalDependencies: {
|
|
1634
|
+
'@types/react': '17.0.87'
|
|
1635
|
+
}
|
|
1636
|
+
});
|
|
1637
|
+
(0, _chai().expect)(lockfile.snapshots[helmetSnapshot]).to.eql({
|
|
1638
|
+
dependencies: {
|
|
1639
|
+
'@types/react': '18.2.23'
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1642
|
+
});
|
|
1643
|
+
it('should keep the reference when an override targets the package', async () => {
|
|
1644
|
+
for (const overrides of [{
|
|
1645
|
+
'@types/react-helmet>@types/react': '^18.0.0'
|
|
1646
|
+
}, {
|
|
1647
|
+
'@types/react@*': '18.2.23'
|
|
1648
|
+
}]) {
|
|
1649
|
+
const lockfile = await convert({
|
|
1650
|
+
dependencies: {
|
|
1651
|
+
'@types/react': '17.0.87'
|
|
1652
|
+
}
|
|
1653
|
+
}, createGraph({
|
|
1654
|
+
overrides
|
|
1655
|
+
}));
|
|
1656
|
+
(0, _chai().expect)(lockfile.snapshots[helmetSnapshot]).to.eql({
|
|
1657
|
+
dependencies: {
|
|
1658
|
+
'@types/react': '18.2.23'
|
|
1659
|
+
}
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
});
|
|
1663
|
+
it('should not send a package the dedupe orphaned to the resolver', async () => {
|
|
1664
|
+
const lockfile = await (0, _lockfileDepsGraphConverter().convertGraphToLockfile)(createGraph({
|
|
1665
|
+
typesReactUnresolved: true
|
|
1666
|
+
}), {
|
|
1667
|
+
manifests: {
|
|
1668
|
+
[rootDir]: {
|
|
1669
|
+
dependencies: {
|
|
1670
|
+
'@types/react': '17.0.87'
|
|
1671
|
+
}
|
|
1672
|
+
},
|
|
1673
|
+
[compDir]: {
|
|
1674
|
+
devDependencies: {
|
|
1675
|
+
'@types/react-helmet': '6.1.6'
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
},
|
|
1679
|
+
rootDir,
|
|
1680
|
+
resolve: async wantedDep => {
|
|
1681
|
+
if (wantedDep.alias === '@types/react') throw new Error('ENOTFOUND');
|
|
1682
|
+
return {
|
|
1683
|
+
resolution: {
|
|
1684
|
+
integrity: '0000'
|
|
1685
|
+
}
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
});
|
|
1689
|
+
(0, _chai().expect)(lockfile.packages['@types/react@18.2.23']).to.equal(undefined);
|
|
1690
|
+
});
|
|
1691
|
+
it('should not take an inherited object property name, e.g. "constructor", for a package the root provides', async () => {
|
|
1692
|
+
const packages = new Map([['dependent@1.0.0', {
|
|
1693
|
+
resolution: {
|
|
1694
|
+
integrity: 'sha512-dependent'
|
|
1695
|
+
},
|
|
1696
|
+
peerDependencies: {
|
|
1697
|
+
react: '*'
|
|
1698
|
+
}
|
|
1699
|
+
}], ['constructor@1.0.0', {
|
|
1700
|
+
resolution: {
|
|
1701
|
+
integrity: 'sha512-constructor'
|
|
1702
|
+
}
|
|
1703
|
+
}]]);
|
|
1704
|
+
const edges = [{
|
|
1705
|
+
id: _objects().DependenciesGraph.ROOT_EDGE_ID,
|
|
1706
|
+
neighbours: [{
|
|
1707
|
+
id: 'dependent@1.0.0',
|
|
1708
|
+
name: 'dependent',
|
|
1709
|
+
specifier: '1.0.0',
|
|
1710
|
+
lifecycle: 'runtime'
|
|
1711
|
+
}]
|
|
1712
|
+
}, {
|
|
1713
|
+
id: 'dependent@1.0.0',
|
|
1714
|
+
neighbours: [{
|
|
1715
|
+
id: 'constructor@1.0.0'
|
|
1716
|
+
}]
|
|
1717
|
+
}];
|
|
1718
|
+
const lockfile = await (0, _lockfileDepsGraphConverter().convertGraphToLockfile)(new (_objects().DependenciesGraph)({
|
|
1719
|
+
packages,
|
|
1720
|
+
edges
|
|
1721
|
+
}), {
|
|
1722
|
+
manifests: {
|
|
1723
|
+
[rootDir]: {
|
|
1724
|
+
dependencies: {
|
|
1725
|
+
'@types/react': '17.0.87'
|
|
1726
|
+
}
|
|
1727
|
+
},
|
|
1728
|
+
[compDir]: {
|
|
1729
|
+
dependencies: {
|
|
1730
|
+
dependent: '1.0.0'
|
|
1731
|
+
}
|
|
1732
|
+
}
|
|
1733
|
+
},
|
|
1734
|
+
rootDir,
|
|
1735
|
+
resolve
|
|
1736
|
+
});
|
|
1737
|
+
(0, _chai().expect)(lockfile.snapshots['dependent@1.0.0']).to.eql({
|
|
1738
|
+
dependencies: {
|
|
1739
|
+
constructor: '1.0.0'
|
|
1740
|
+
}
|
|
1741
|
+
});
|
|
1742
|
+
});
|
|
1743
|
+
it('should leave the graph alone when the root has no such dependency', async () => {
|
|
1744
|
+
const lockfile = await convert({
|
|
1745
|
+
dependencies: {
|
|
1746
|
+
react: '18.3.1'
|
|
1747
|
+
}
|
|
1748
|
+
});
|
|
1749
|
+
(0, _chai().expect)(lockfile.snapshots[helmetSnapshot]).to.eql({
|
|
1750
|
+
dependencies: {
|
|
1751
|
+
'@types/react': '18.2.23'
|
|
1752
|
+
}
|
|
1753
|
+
});
|
|
1754
|
+
});
|
|
1755
|
+
});
|
|
1476
1756
|
describe('pnpmfileChecksum', () => {
|
|
1477
1757
|
const componentDir = 'comps/comp1';
|
|
1478
1758
|
function createLockfile(pnpmfileChecksum) {
|