mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-30 13:02:03 -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> {
|
export interface PnpmContext<T> {
|
||||||
currentLockfile: Lockfile,
|
currentLockfile: Lockfile,
|
||||||
|
currentLockfileIsUpToDate: boolean,
|
||||||
existsCurrentLockfile: boolean,
|
existsCurrentLockfile: boolean,
|
||||||
existsWantedLockfile: boolean,
|
existsWantedLockfile: boolean,
|
||||||
extraBinPaths: string[],
|
extraBinPaths: string[],
|
||||||
@@ -292,6 +293,7 @@ function stringifyIncludedDeps (included: IncludedDependencies) {
|
|||||||
|
|
||||||
export interface PnpmSingleContext {
|
export interface PnpmSingleContext {
|
||||||
currentLockfile: Lockfile,
|
currentLockfile: Lockfile,
|
||||||
|
currentLockfileIsUpToDate: boolean,
|
||||||
existsCurrentLockfile: boolean,
|
existsCurrentLockfile: boolean,
|
||||||
existsWantedLockfile: boolean,
|
existsWantedLockfile: boolean,
|
||||||
extraBinPaths: string[],
|
extraBinPaths: string[],
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ export default async function (
|
|||||||
}
|
}
|
||||||
): Promise<{
|
): Promise<{
|
||||||
currentLockfile: Lockfile,
|
currentLockfile: Lockfile,
|
||||||
|
currentLockfileIsUpToDate: boolean,
|
||||||
existsCurrentLockfile: boolean,
|
existsCurrentLockfile: boolean,
|
||||||
existsWantedLockfile: boolean,
|
existsWantedLockfile: boolean,
|
||||||
wantedLockfile: Lockfile,
|
wantedLockfile: Lockfile,
|
||||||
@@ -76,6 +77,7 @@ export default async function (
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
currentLockfile,
|
currentLockfile,
|
||||||
|
currentLockfileIsUpToDate: R.equals(currentLockfile, wantedLockfile),
|
||||||
existsCurrentLockfile: !!files[1],
|
existsCurrentLockfile: !!files[1],
|
||||||
existsWantedLockfile: !!files[0],
|
existsWantedLockfile: !!files[0],
|
||||||
wantedLockfile,
|
wantedLockfile,
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ import getWantedDependencies, {
|
|||||||
PinnedVersion,
|
PinnedVersion,
|
||||||
WantedDependency,
|
WantedDependency,
|
||||||
} from './getWantedDependencies'
|
} from './getWantedDependencies'
|
||||||
import isCurrentLockfileUpToDate from './isCurrentLockfilesUpToDate'
|
|
||||||
import linkPackages, {
|
import linkPackages, {
|
||||||
DependenciesGraph,
|
DependenciesGraph,
|
||||||
DependenciesGraphNode,
|
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.
|
// 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
|
// A user might run named installations on a project that has a pnpm-lock.yaml file before running a noop install
|
||||||
const makePartialCurrentLockfile = !installsOnly && (
|
const makePartialCurrentLockfile = !installsOnly && (
|
||||||
ctx.existsWantedLockfile && !ctx.existsCurrentLockfile ||
|
ctx.existsWantedLockfile && !ctx.existsCurrentLockfile ||
|
||||||
// TODO: this operation is quite expensive. We'll have to find a better solution to do this.
|
!ctx.currentLockfileIsUpToDate
|
||||||
// maybe in pnpm v2 it won't be needed. See: https://github.com/pnpm/pnpm/issues/841
|
|
||||||
!currentLockfileIsUpToDate
|
|
||||||
)
|
)
|
||||||
const result = await installInContext(projectsToInstall, ctx, {
|
const result = await installInContext(projectsToInstall, ctx, {
|
||||||
...opts,
|
...opts,
|
||||||
currentLockfileIsUpToDate: !ctx.existsWantedLockfile || currentLockfileIsUpToDate,
|
currentLockfileIsUpToDate: !ctx.existsWantedLockfile || ctx.currentLockfileIsUpToDate,
|
||||||
makePartialCurrentLockfile,
|
makePartialCurrentLockfile,
|
||||||
update: opts.update || !installsOnly,
|
update: opts.update || !installsOnly,
|
||||||
updateLockfileMinorVersion: true,
|
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