mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-06 00:06:06 -04:00
* fix: depPath format used in time pruning The local `refToRelative` helper in `lockfileFormatConverters.ts` produced dependency paths with a leading slash (e.g. `/foo@1.0.0`), while the keys stored in the `time` field do not have one (e.g. `foo@1.0.0`). Because of this mismatch, `rootDepPaths.has(depPath)` always returned false inside `pruneTimeInLockfile`, so `pickBy` filtered out every entry and the entire `time` field was cleared on every install. Fix by replacing the local helper with `refToRelative` from `@pnpm/dependency-path`, which produces the correct format. * chore: add pnpm to changeset Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Zoltan Kochan <z@kochan.io> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
96 lines
2.2 KiB
TypeScript
96 lines
2.2 KiB
TypeScript
import { LOCKFILE_VERSION } from '@pnpm/constants'
|
|
import type { ProjectId } from '@pnpm/types'
|
|
|
|
import { convertToLockfileFile } from '../lib/lockfileFormatConverters.js'
|
|
|
|
test('empty overrides and neverBuiltDependencies are removed during lockfile normalization', () => {
|
|
expect(convertToLockfileFile({
|
|
lockfileVersion: LOCKFILE_VERSION,
|
|
overrides: {},
|
|
patchedDependencies: {},
|
|
packages: {},
|
|
importers: {
|
|
['foo' as ProjectId]: {
|
|
dependencies: {
|
|
bar: 'link:../bar',
|
|
},
|
|
specifiers: {
|
|
bar: 'link:../bar',
|
|
},
|
|
},
|
|
},
|
|
})).toStrictEqual({
|
|
lockfileVersion: LOCKFILE_VERSION,
|
|
importers: {
|
|
foo: {
|
|
dependencies: {
|
|
bar: {
|
|
version: 'link:../bar',
|
|
specifier: 'link:../bar',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
})
|
|
|
|
test('redundant fields are removed from "time"', () => {
|
|
expect(convertToLockfileFile({
|
|
lockfileVersion: LOCKFILE_VERSION,
|
|
packages: {},
|
|
importers: {
|
|
['foo' as ProjectId]: {
|
|
dependencies: {
|
|
bar: '1.0.0',
|
|
},
|
|
devDependencies: {
|
|
foo: '1.0.0(react@18.0.0)',
|
|
},
|
|
optionalDependencies: {
|
|
qar: '1.0.0',
|
|
},
|
|
specifiers: {
|
|
bar: '1.0.0',
|
|
foo: '1.0.0',
|
|
qar: '1.0.0',
|
|
},
|
|
},
|
|
},
|
|
time: {
|
|
'bar@1.0.0': '2021-02-11T22:54:29.120Z',
|
|
'foo@1.0.0': '2021-02-11T22:54:29.120Z',
|
|
'qar@1.0.0': '2021-02-11T22:54:29.120Z',
|
|
'zoo@1.0.0': '2021-02-11T22:54:29.120Z',
|
|
},
|
|
})).toStrictEqual({
|
|
lockfileVersion: LOCKFILE_VERSION,
|
|
importers: {
|
|
foo: {
|
|
dependencies: {
|
|
bar: {
|
|
version: '1.0.0',
|
|
specifier: '1.0.0',
|
|
},
|
|
},
|
|
devDependencies: {
|
|
foo: {
|
|
version: '1.0.0(react@18.0.0)',
|
|
specifier: '1.0.0',
|
|
},
|
|
},
|
|
optionalDependencies: {
|
|
qar: {
|
|
version: '1.0.0',
|
|
specifier: '1.0.0',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
time: {
|
|
'bar@1.0.0': '2021-02-11T22:54:29.120Z',
|
|
'foo@1.0.0': '2021-02-11T22:54:29.120Z',
|
|
'qar@1.0.0': '2021-02-11T22:54:29.120Z',
|
|
},
|
|
})
|
|
})
|