Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pnpm add @teambit/bit should succeed #4813

Merged
merged 3 commits into from May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/wet-needles-remain.md
@@ -0,0 +1,6 @@
---
"@pnpm/resolve-dependencies": patch
"pnpm": patch
---

Correctly detect repeated dependency sequence during resolution.
27 changes: 27 additions & 0 deletions packages/core/test/install/deepRecursive.ts
@@ -0,0 +1,27 @@
import { prepareEmpty } from '@pnpm/prepare'
import { addDependenciesToPackage } from '@pnpm/core'
import isCI from 'is-ci'
import exists from 'path-exists'
import { testDefaults } from '../utils'

const testSkipOnCI = isCI ? test.skip : test

// Looks like GitHub Actions have reduced memory limit for Node.js,
// so it fails in CI at the moment.
testSkipOnCI('a package with a huge amount of circular dependencies and many peer dependencies should successfully be resolved', async () => {
prepareEmpty()

await addDependenciesToPackage({},
['@teambit/bit@0.0.745'],
await testDefaults({
fastUnpack: true,
lockfileOnly: true,
registries: {
'@teambit': 'https://node.bit.dev/',
},
strictPeerDependencies: false,
})
)

expect(await exists('pnpm-lock.yaml')).toBeTruthy()
})
4 changes: 2 additions & 2 deletions packages/resolve-dependencies/src/nodeIdUtils.ts
Expand Up @@ -3,8 +3,8 @@ export function nodeIdContainsSequence (nodeId: string, pkgId1: string, pkgId2:
pkgIds.pop()
const pkg1Index = pkgIds.indexOf(pkgId1)
if (pkg1Index === -1) return false
const pkg2Index = pkgIds.indexOf(pkgId2)
return pkg2Index > -1 && pkg1Index < pkg2Index
const pkg2Index = pkgIds.lastIndexOf(pkgId2)
return pkg1Index < pkg2Index
}

export function createNodeId (parentNodeId: string, pkgId: string) {
Expand Down
5 changes: 5 additions & 0 deletions packages/resolve-dependencies/test/nodeIdUtils.test.ts
@@ -0,0 +1,5 @@
import { nodeIdContainsSequence } from '../lib/nodeIdUtils'

test('nodeIdContainsSequence()', () => {
expect(nodeIdContainsSequence('>.>b>a>c>b>a>', 'a', 'b')).toBeTruthy()
})