mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-31 21:42:15 -04:00
fix: don't silently skip an optional dependency if it cannot be resolved from a mature version (#10289)
close #10270
This commit is contained in:
8
.changeset/fair-nights-grow.md
Normal file
8
.changeset/fair-nights-grow.md
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
"@pnpm/resolve-dependencies": patch
|
||||
"@pnpm/npm-resolver": patch
|
||||
"@pnpm/default-reporter": patch
|
||||
"@pnpm/outdated": patch
|
||||
---
|
||||
|
||||
Don't silently skip an optional dependency if it cannot be resolved from a version that satisfies the `minimumReleaseAge` setting [#10270](https://github.com/pnpm/pnpm/issues/10270).
|
||||
5
.changeset/flat-clowns-type.md
Normal file
5
.changeset/flat-clowns-type.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/npm-resolver": major
|
||||
---
|
||||
|
||||
Changed the error code for no matching version that satisfies the maturity configuration.
|
||||
@@ -70,6 +70,7 @@ function getErrorInfo (logObj: Log, config?: Config): ErrorInfo | null {
|
||||
case 'ERR_PNPM_MISSING_TIME':
|
||||
return { title: err.message, body: 'If you cannot fix this registry issue, then set "resolution-mode" to "highest".' }
|
||||
case 'ERR_PNPM_NO_MATCHING_VERSION':
|
||||
case 'ERR_PNPM_NO_MATURE_MATCHING_VERSION':
|
||||
return formatNoMatchingVersion(err, logObj as unknown as { packageMeta: PackageMeta, immatureVersion?: string })
|
||||
case 'ERR_PNPM_RECURSIVE_FAIL':
|
||||
return formatRecursiveCommandSummary(logObj as any) // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
|
||||
@@ -1359,7 +1359,7 @@ async function resolveDependency (
|
||||
bareSpecifier: wantedDependency.bareSpecifier,
|
||||
version: wantedDependency.alias ? wantedDependency.bareSpecifier : undefined,
|
||||
}
|
||||
if (wantedDependency.optional && err.code !== 'ERR_PNPM_TRUST_DOWNGRADE') {
|
||||
if (wantedDependency.optional && err.code !== 'ERR_PNPM_TRUST_DOWNGRADE' && err.code !== 'ERR_PNPM_NO_MATURE_MATCHING_VERSION') {
|
||||
skippedOptionalDependencyLogger.debug({
|
||||
details: err.toString(),
|
||||
package: wantedDependencyDetails,
|
||||
|
||||
@@ -73,7 +73,7 @@ export class NoMatchingVersionError extends PnpmError {
|
||||
} else {
|
||||
errorMessage = `No matching version found for ${dep} while fetching it from ${opts.registry}`
|
||||
}
|
||||
super('NO_MATCHING_VERSION', errorMessage)
|
||||
super(opts.publishedBy ? 'NO_MATURE_MATCHING_VERSION' : 'NO_MATCHING_VERSION', errorMessage)
|
||||
this.packageMeta = opts.packageMeta
|
||||
this.immatureVersion = opts.immatureVersion
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ export async function getManifest (
|
||||
})
|
||||
return resolution?.manifest ?? null
|
||||
} catch (err) {
|
||||
if ((err as { code?: string }).code === 'ERR_PNPM_NO_MATCHING_VERSION' && opts.publishedBy) {
|
||||
if ((err as { code?: string }).code === 'ERR_PNPM_NO_MATURE_MATCHING_VERSION' && opts.publishedBy) {
|
||||
// No versions found that meet the minimumReleaseAge requirement
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ test('getManifest() with minimumReleaseAge filters latest when too new', async (
|
||||
|
||||
// Simulate latest version being too new
|
||||
const error = new Error('No matching version found') as Error & { code?: string }
|
||||
error.code = 'ERR_PNPM_NO_MATCHING_VERSION'
|
||||
error.code = 'ERR_PNPM_NO_MATURE_MATCHING_VERSION'
|
||||
throw error
|
||||
})
|
||||
|
||||
@@ -109,7 +109,7 @@ test('getManifest() handles NO_MATCHING_VERSION error gracefully', async () => {
|
||||
|
||||
const resolve: ResolveFunction = jest.fn(async function () {
|
||||
const error = new Error('No matching version found') as Error & { code?: string }
|
||||
error.code = 'ERR_PNPM_NO_MATCHING_VERSION'
|
||||
error.code = 'ERR_PNPM_NO_MATURE_MATCHING_VERSION'
|
||||
throw error
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user