mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-23 23:29:17 -05:00
fix: save the lockfile in the new format even if it is up-to-date (#7984)
This commit is contained in:
7
.changeset/soft-eyes-judge.md
Normal file
7
.changeset/soft-eyes-judge.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@pnpm/core": patch
|
||||
"pnpm": patch
|
||||
"@pnpm/lockfile-file": patch
|
||||
---
|
||||
|
||||
The lockfile should be saved in the new format even if it is up-to-date.
|
||||
@@ -19,6 +19,7 @@ import _mapValues from 'ramda/src/map'
|
||||
import omit from 'ramda/src/omit'
|
||||
import pickBy from 'ramda/src/pickBy'
|
||||
import pick from 'ramda/src/pick'
|
||||
import { LOCKFILE_VERSION } from '@pnpm/constants'
|
||||
|
||||
export interface NormalizeLockfileOpts {
|
||||
forceSharedFormat: boolean
|
||||
@@ -57,7 +58,7 @@ export function convertToLockfileFile (lockfile: Lockfile, opts: NormalizeLockfi
|
||||
...lockfile,
|
||||
snapshots,
|
||||
packages,
|
||||
lockfileVersion: lockfile.lockfileVersion.toString(),
|
||||
lockfileVersion: LOCKFILE_VERSION,
|
||||
importers: mapValues(lockfile.importers, convertProjectSnapshotToInlineSpecifiersFormat),
|
||||
}
|
||||
return normalizeLockfile(newLockfile, opts)
|
||||
|
||||
@@ -351,9 +351,10 @@ export async function mutateModules (
|
||||
throw new LockfileConfigMismatchError(outdatedLockfileSettingName!)
|
||||
}
|
||||
}
|
||||
const upToDateLockfileMajorVersion = ctx.wantedLockfile.lockfileVersion.toString().startsWith(`${LOCKFILE_MAJOR_VERSION}.`)
|
||||
let needsFullResolution = outdatedLockfileSettings ||
|
||||
opts.fixLockfile ||
|
||||
!ctx.wantedLockfile.lockfileVersion.toString().startsWith(`${LOCKFILE_MAJOR_VERSION}.`) && ctx.wantedLockfile.lockfileVersion !== LOCKFILE_VERSION_V6 ||
|
||||
!upToDateLockfileMajorVersion && ctx.wantedLockfile.lockfileVersion !== LOCKFILE_VERSION_V6 ||
|
||||
opts.forceFullResolution
|
||||
if (needsFullResolution) {
|
||||
ctx.wantedLockfile.settings = {
|
||||
@@ -470,7 +471,7 @@ Note that in CI environments, this setting is enabled by default.`,
|
||||
wantedLockfile: maybeOpts.ignorePackageManifest ? undefined : ctx.wantedLockfile,
|
||||
useLockfile: opts.useLockfile && ctx.wantedLockfileIsModified,
|
||||
})
|
||||
if (opts.useLockfile && opts.saveLockfile && opts.mergeGitBranchLockfiles) {
|
||||
if (opts.useLockfile && opts.saveLockfile && opts.mergeGitBranchLockfiles || !upToDateLockfileMajorVersion) {
|
||||
await writeLockfiles({
|
||||
currentLockfile: ctx.currentLockfile,
|
||||
currentLockfileDir: ctx.virtualStoreDir,
|
||||
|
||||
Reference in New Issue
Block a user