fix: address review feedback for minimumReleaseAgeLoose

- Wire minimumReleaseAgeLoose to strictPublishedByCheck in dlx resolver
- Strengthen loose fallback test assertion to verify specific version
- Update add command test name to reflect loose mode dependency
This commit is contained in:
Zoltan Kochan
2026-04-09 16:57:55 +02:00
parent 3a02df4e49
commit bfd38cdc15
3 changed files with 6 additions and 3 deletions

View File

@@ -106,6 +106,7 @@ export async function handler (
configByUri: opts.configByUri,
fullMetadata,
filterMetadata: fullMetadata,
strictPublishedByCheck: Boolean(opts.minimumReleaseAge) && opts.minimumReleaseAgeLoose === false,
retry: {
factor: opts.fetchRetryFactor,
maxTimeout: opts.fetchRetryMaxtimeout,

View File

@@ -367,7 +367,7 @@ test('add: fail trying to install @pnpm/exe', async () => {
expect(err.code).toBe('ERR_PNPM_GLOBAL_PNPM_INSTALL')
})
test('minimumReleaseAge makes install fail if there is no version that was published before the cutoff', async () => {
test('minimumReleaseAge with minimumReleaseAgeLoose disabled makes install fail if there is no version that was published before the cutoff', async () => {
prepareEmpty()
const isOdd011ReleaseDate = new Date(2016, 11, 7 - 2) // 0.1.1 was released at 2016-12-07T07:18:01.205Z

View File

@@ -66,11 +66,13 @@ test('minimumReleaseAge applies to versions not in minimumReleaseAgeExclude', as
test('minimumReleaseAgeLoose falls back to immature version when no mature version satisfies the range', async () => {
prepareEmpty()
// With loose mode (default), falls back to installing an immature version
// With loose mode (default), falls back to installing an immature version.
// The fallback picks the lowest matching version (0.1.0), which differs from
// normal resolution without minimumReleaseAge that would pick the highest (0.1.2).
const opts = testDefaults({ minimumReleaseAge: allImmatureMinimumReleaseAge })
const { updatedManifest: manifest } = await addDependenciesToPackage({}, ['is-odd@0.1'], opts)
expect(manifest.dependencies!['is-odd']).toBeTruthy()
expect(manifest.dependencies!['is-odd']).toBe('~0.1.0')
})
test('minimumReleaseAge throws when no mature version satisfies the range and loose mode is disabled', async () => {