feat: minimumReleaseAgeExclude support patterns (#9984)

close #9983

---------

Co-authored-by: Zoltan Kochan <z@kochan.io>
This commit is contained in:
btea
2025-09-17 22:45:01 +08:00
committed by GitHub
parent 02f8b690ad
commit 3a58aaa3e3
7 changed files with 34 additions and 3 deletions

View File

@@ -0,0 +1,14 @@
---
"pnpm": patch
"@pnpm/resolve-dependencies": patch
---
`minimumReleaseAgeExclude` config support patterns. For instance:
```yaml
minimumReleaseAge: 1440
minimumReleaseAgeExclude:
- '@eslint/*'
```
Related PR: [#9984](https://github.com/pnpm/pnpm/pull/9984).

View File

@@ -22,3 +22,12 @@ test('minimumReleaseAge is ignored for packages in the minimumReleaseAgeExclude
expect(manifest.dependencies!['is-odd']).toEqual('~0.1.2')
})
test('minimumReleaseAge is ignored for packages in the minimumReleaseAgeExclude array, using a pattern', async () => {
prepareEmpty()
const opts = testDefaults({ minimumReleaseAge, minimumReleaseAgeExclude: ['is-*'] })
const { updatedManifest: manifest } = await addDependenciesToPackage({}, ['is-odd@0.1'], opts)
expect(manifest.dependencies!['is-odd']).toEqual('~0.1.2')
})

View File

@@ -44,6 +44,7 @@
"@pnpm/lockfile.types": "workspace:*",
"@pnpm/lockfile.utils": "workspace:*",
"@pnpm/manifest-utils": "workspace:*",
"@pnpm/matcher": "workspace:*",
"@pnpm/npm-resolver": "workspace:*",
"@pnpm/patching.config": "workspace:*",
"@pnpm/patching.types": "workspace:*",

View File

@@ -177,7 +177,7 @@ export interface ResolutionContext {
missingPeersOfChildrenByPkgId: Record<PkgResolutionId, { depth: number, missingPeersOfChildren: MissingPeersOfChildren }>
hoistPeers?: boolean
maximumPublishedBy?: Date
minimumReleaseAgeExclude?: string[]
minimumReleaseAgeExclude?: (pkgName: string) => boolean
}
export interface MissingPeerInfo {
@@ -1311,7 +1311,7 @@ async function resolveDependency (
(
ctx.minimumReleaseAgeExclude == null ||
wantedDependency.alias == null ||
!ctx.minimumReleaseAgeExclude.includes(wantedDependency.alias)
!ctx.minimumReleaseAgeExclude(wantedDependency.alias)
)
) {
publishedBy = options.publishedBy

View File

@@ -2,6 +2,7 @@ import { resolveFromCatalog } from '@pnpm/catalogs.resolver'
import { type Catalogs } from '@pnpm/catalogs.types'
import { type LockfileObject } from '@pnpm/lockfile.types'
import { globalWarn } from '@pnpm/logger'
import { createMatcher } from '@pnpm/matcher'
import { type PatchGroupRecord } from '@pnpm/patching.config'
import { type PreferredVersions, type Resolution, type WorkspacePackages } from '@pnpm/resolver-base'
import { type StoreController } from '@pnpm/store-controller-types'
@@ -196,7 +197,7 @@ export async function resolveDependencyTree<T> (
hoistPeers: autoInstallPeers || opts.dedupePeerDependents,
allPeerDepNames: new Set(),
maximumPublishedBy: opts.minimumReleaseAge ? new Date(Date.now() - opts.minimumReleaseAge * 60 * 1000) : undefined,
minimumReleaseAgeExclude: opts.minimumReleaseAgeExclude,
minimumReleaseAgeExclude: opts.minimumReleaseAgeExclude ? createMatcher(opts.minimumReleaseAgeExclude) : undefined,
}
const resolveArgs: ImporterToResolve[] = importers.map((importer) => {

View File

@@ -15,6 +15,9 @@
{
"path": "../../catalogs/types"
},
{
"path": "../../config/matcher"
},
{
"path": "../../fetching/pick-fetcher"
},

3
pnpm-lock.yaml generated
View File

@@ -6044,6 +6044,9 @@ importers:
'@pnpm/manifest-utils':
specifier: workspace:*
version: link:../../pkg-manifest/manifest-utils
'@pnpm/matcher':
specifier: workspace:*
version: link:../../config/matcher
'@pnpm/npm-resolver':
specifier: workspace:*
version: link:../../resolving/npm-resolver