mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-10 18:18:56 -04:00
fix(package-requester): the version in the bundled manifest should be… (#4037)
This commit is contained in:
5
.changeset/late-zoos-walk.md
Normal file
5
.changeset/late-zoos-walk.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/package-requester": patch
|
||||
---
|
||||
|
||||
The version in the bundled manifest should always be normalized.
|
||||
@@ -68,6 +68,13 @@ const pickBundledManifest = pick([
|
||||
'version',
|
||||
])
|
||||
|
||||
function normalizeBundledManifest (manifest: DependencyManifest): BundledManifest {
|
||||
return {
|
||||
...pickBundledManifest(manifest),
|
||||
version: semver.clean(manifest.version ?? '0.0.0', { loose: true }) ?? manifest.version,
|
||||
}
|
||||
}
|
||||
|
||||
export default function (
|
||||
opts: {
|
||||
engineStrict?: boolean
|
||||
@@ -458,7 +465,7 @@ Actual package in the store by the given integrity: ${pkgFilesIndex.name}@${pkgF
|
||||
})
|
||||
if (manifest != null) {
|
||||
manifest()
|
||||
.then((manifest) => bundledManifest.resolve(pickBundledManifest(manifest)))
|
||||
.then((manifest) => bundledManifest.resolve(normalizeBundledManifest(manifest)))
|
||||
.catch(bundledManifest.reject)
|
||||
}
|
||||
finishing.resolve(undefined)
|
||||
@@ -485,7 +492,7 @@ Actual package in the store by the given integrity: ${pkgFilesIndex.name}@${pkgF
|
||||
: undefined
|
||||
if (fetchManifest != null) {
|
||||
fetchManifest()
|
||||
.then((manifest) => bundledManifest.resolve(pickBundledManifest(manifest)))
|
||||
.then((manifest) => bundledManifest.resolve(normalizeBundledManifest(manifest)))
|
||||
.catch(bundledManifest.reject)
|
||||
}
|
||||
const fetchedPackage = await ctx.requestsQueue.add(async () => ctx.fetch(
|
||||
|
||||
@@ -945,3 +945,29 @@ test('throw exception if the package data in the store differs from the expected
|
||||
await expect(files()).resolves.toStrictEqual(expect.anything())
|
||||
}
|
||||
})
|
||||
|
||||
test('the version in the bundled manifest should be normalized', async () => {
|
||||
const storeDir = tempy.directory()
|
||||
const cafs = createCafsStore(storeDir)
|
||||
|
||||
const requestPackage = createPackageRequester({
|
||||
resolve,
|
||||
fetchers,
|
||||
cafs,
|
||||
networkConcurrency: 1,
|
||||
storeDir,
|
||||
verifyStoreIntegrity: true,
|
||||
})
|
||||
|
||||
const pkgResponse = await requestPackage({ alias: 'react-terminal', pref: '1.2.1' }, {
|
||||
downloadPriority: 0,
|
||||
lockfileDir: tempy.directory(),
|
||||
preferredVersions: {},
|
||||
projectDir: tempy.directory(),
|
||||
registry,
|
||||
})
|
||||
await expect(pkgResponse.bundledManifest!()).resolves.toStrictEqual(expect.objectContaining({
|
||||
version: '1.2.1',
|
||||
}))
|
||||
await pkgResponse.finishing!()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user