fix: lockfile up-to-date check when it has dependenciesMeta field (#4152)

close #4098
This commit is contained in:
Zoltan Kochan
2021-12-23 03:34:09 +02:00
committed by GitHub
parent f5e732e289
commit eb9ebd0f3e
8 changed files with 40 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"pnpm": patch
---
Install with `--frozen-lockfile` should not fail when the project has injected dependencies and a dedicated lockfile [#4098](https://github.com/pnpm/pnpm/issues/4098).

View File

@@ -0,0 +1,5 @@
---
"@pnpm/lockfile-file": patch
---
In a dedicated lockfile the `dependenciesMeta` field should be nested to `'.'` during normalization.

View File

@@ -0,0 +1,5 @@
---
"@pnpm/lockfile-file": patch
---
The `dependenciesMeta` field should be sorted after the dependencies fields.

View File

@@ -97,6 +97,7 @@ async function _read (
lockfile.importers = {
'.': {
specifiers: lockfile['specifiers'],
dependenciesMeta: lockfile['dependenciesMeta'],
},
}
delete lockfile.specifiers

View File

@@ -38,8 +38,9 @@ const ROOT_KEYS_ORDER = {
dependencies: 11,
optionalDependencies: 12,
devDependencies: 13,
importers: 14,
packages: 15,
dependenciesMeta: 14,
importers: 15,
packages: 16,
}
function compareWithPriority (priority: Record<string, number>, left: string, right: string) {

View File

@@ -1 +1,6 @@
lockfileVersion: 3
specifiers:
foo: '1'
dependenciesMeta:
foo:
injected: true

View File

@@ -1 +1,6 @@
lockfileVersion: 3
specifiers:
foo: '1'
dependenciesMeta:
foo:
injected: true

View File

@@ -15,7 +15,17 @@ test('readWantedLockfile()', async () => {
const lockfile = await readWantedLockfile(path.join('fixtures', '2'), {
ignoreIncompatible: false,
})
expect(lockfile!.lockfileVersion).toEqual(3)
expect(lockfile?.lockfileVersion).toEqual(3)
expect(lockfile?.importers).toStrictEqual({
'.': {
specifiers: {
foo: '1',
},
dependenciesMeta: {
foo: { injected: true },
},
},
})
}
try {