mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 04:52:04 -04:00
fix: current lockfile up-to-date check
This commit is contained in:
5
.changeset/smart-tables-hammer.md
Normal file
5
.changeset/smart-tables-hammer.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/get-context": minor
|
||||
---
|
||||
|
||||
Add `currentLockfileIsUpToDate` to the context.
|
||||
5
.changeset/three-pens-clap.md
Normal file
5
.changeset/three-pens-clap.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"supi": patch
|
||||
---
|
||||
|
||||
Fix current lockfile (the one at `node_modules/.pnpm/lock.yaml`) up-to-date check.
|
||||
@@ -23,6 +23,7 @@ import readLockfileFile from './readLockfiles'
|
||||
|
||||
export interface PnpmContext<T> {
|
||||
currentLockfile: Lockfile,
|
||||
currentLockfileIsUpToDate: boolean,
|
||||
existsCurrentLockfile: boolean,
|
||||
existsWantedLockfile: boolean,
|
||||
extraBinPaths: string[],
|
||||
@@ -292,6 +293,7 @@ function stringifyIncludedDeps (included: IncludedDependencies) {
|
||||
|
||||
export interface PnpmSingleContext {
|
||||
currentLockfile: Lockfile,
|
||||
currentLockfileIsUpToDate: boolean,
|
||||
existsCurrentLockfile: boolean,
|
||||
existsWantedLockfile: boolean,
|
||||
extraBinPaths: string[],
|
||||
|
||||
@@ -35,6 +35,7 @@ export default async function (
|
||||
}
|
||||
): Promise<{
|
||||
currentLockfile: Lockfile,
|
||||
currentLockfileIsUpToDate: boolean,
|
||||
existsCurrentLockfile: boolean,
|
||||
existsWantedLockfile: boolean,
|
||||
wantedLockfile: Lockfile,
|
||||
@@ -76,6 +77,7 @@ export default async function (
|
||||
}
|
||||
return {
|
||||
currentLockfile,
|
||||
currentLockfileIsUpToDate: R.equals(currentLockfile, wantedLockfile),
|
||||
existsCurrentLockfile: !!files[1],
|
||||
existsWantedLockfile: !!files[0],
|
||||
wantedLockfile,
|
||||
|
||||
@@ -64,7 +64,6 @@ import getWantedDependencies, {
|
||||
PinnedVersion,
|
||||
WantedDependency,
|
||||
} from './getWantedDependencies'
|
||||
import isCurrentLockfileUpToDate from './isCurrentLockfilesUpToDate'
|
||||
import linkPackages, {
|
||||
DependenciesGraph,
|
||||
DependenciesGraphNode,
|
||||
@@ -389,24 +388,15 @@ export async function mutateModules (
|
||||
})
|
||||
}
|
||||
|
||||
const currentLockfileIsUpToDate = isCurrentLockfileUpToDate(
|
||||
ctx.currentLockfile,
|
||||
{
|
||||
skipped: Array.from(ctx.skipped),
|
||||
wantedLockfile: ctx.wantedLockfile,
|
||||
}
|
||||
)
|
||||
// Unfortunately, the private lockfile may differ from the public one.
|
||||
// A user might run named installations on a project that has a pnpm-lock.yaml file before running a noop install
|
||||
const makePartialCurrentLockfile = !installsOnly && (
|
||||
ctx.existsWantedLockfile && !ctx.existsCurrentLockfile ||
|
||||
// TODO: this operation is quite expensive. We'll have to find a better solution to do this.
|
||||
// maybe in pnpm v2 it won't be needed. See: https://github.com/pnpm/pnpm/issues/841
|
||||
!currentLockfileIsUpToDate
|
||||
!ctx.currentLockfileIsUpToDate
|
||||
)
|
||||
const result = await installInContext(projectsToInstall, ctx, {
|
||||
...opts,
|
||||
currentLockfileIsUpToDate: !ctx.existsWantedLockfile || currentLockfileIsUpToDate,
|
||||
currentLockfileIsUpToDate: !ctx.existsWantedLockfile || ctx.currentLockfileIsUpToDate,
|
||||
makePartialCurrentLockfile,
|
||||
update: opts.update || !installsOnly,
|
||||
updateLockfileMinorVersion: true,
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import { Lockfile } from '@pnpm/lockfile-file'
|
||||
import R = require('ramda')
|
||||
|
||||
export default function (
|
||||
currentLockfile: Lockfile,
|
||||
opts: {
|
||||
skipped: string[],
|
||||
wantedLockfile: Lockfile,
|
||||
}
|
||||
) {
|
||||
const importers1 = R.keys(opts.wantedLockfile.importers)
|
||||
const importers2 = R.keys(currentLockfile.importers)
|
||||
if (importers1.length !== importers2.length || !R.equals(importers1, importers2)) {
|
||||
return false
|
||||
}
|
||||
const pkgs1 = R.keys(opts.wantedLockfile.packages)
|
||||
const pkgs2 = R.keys(currentLockfile.packages).concat(opts.skipped)
|
||||
return pkgs1.length === pkgs2.length && R.equals(pkgs1, pkgs2.sort())
|
||||
}
|
||||
Reference in New Issue
Block a user