mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-23 01:21:55 -04:00
refactor: resolve dependencies
This commit is contained in:
@@ -4,14 +4,12 @@ import {
|
||||
type LockfileResolution,
|
||||
type PackageSnapshot,
|
||||
pruneSharedLockfile,
|
||||
type ResolvedDependencies,
|
||||
} from '@pnpm/prune-lockfile'
|
||||
import { type DirectoryResolution, type Resolution } from '@pnpm/resolver-base'
|
||||
import { type Registries } from '@pnpm/types'
|
||||
import * as dp from '@pnpm/dependency-path'
|
||||
import getNpmTarballUrl from 'get-npm-tarball-url'
|
||||
import { type KeyValuePair } from 'ramda'
|
||||
import mergeRight from 'ramda/src/mergeRight'
|
||||
import partition from 'ramda/src/partition'
|
||||
import { type SafePromiseDefer } from 'safe-promise-defer'
|
||||
import { depPathToRef } from './depPathToRef'
|
||||
@@ -79,12 +77,10 @@ function toLockfileDependency (
|
||||
opts.lockfileIncludeTarballUrl
|
||||
)
|
||||
const newResolvedDeps = updateResolvedDeps(
|
||||
{},
|
||||
opts.updatedDeps,
|
||||
opts.depGraph
|
||||
)
|
||||
const newResolvedOptionalDeps = updateResolvedDeps(
|
||||
{},
|
||||
opts.updatedOptionalDeps,
|
||||
opts.depGraph
|
||||
)
|
||||
@@ -196,15 +192,11 @@ function toLockfileDependency (
|
||||
return result
|
||||
}
|
||||
|
||||
// previous resolutions should not be removed from lockfile
|
||||
// as installation might not reanalyze the whole dependency graph
|
||||
// the `depth` property defines how deep should dependencies be checked
|
||||
function updateResolvedDeps (
|
||||
prevResolvedDeps: ResolvedDependencies,
|
||||
updatedDeps: Array<{ alias: string, depPath: string }>,
|
||||
depGraph: DependenciesGraph
|
||||
) {
|
||||
const newResolvedDeps = Object.fromEntries(
|
||||
return Object.fromEntries(
|
||||
updatedDeps
|
||||
.map(({ alias, depPath }): KeyValuePair<string, string> => {
|
||||
if (depPath.startsWith('link:')) {
|
||||
@@ -221,10 +213,6 @@ function updateResolvedDeps (
|
||||
]
|
||||
})
|
||||
)
|
||||
return mergeRight(
|
||||
prevResolvedDeps,
|
||||
newResolvedDeps
|
||||
)
|
||||
}
|
||||
|
||||
function toLockfileResolution (
|
||||
|
||||
Reference in New Issue
Block a user