mirror of
https://github.com/pnpm/pnpm.git
synced 2026-03-31 13:32:18 -04:00
committed by
Zoltan Kochan
parent
4794c61dd1
commit
0d3798c216
6
.changeset/chubby-rockets-see.md
Normal file
6
.changeset/chubby-rockets-see.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-script-runners": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
Fixed `minimumReleaseAgeExclude` not being respected by `pnpm dlx` [#10338](https://github.com/pnpm/pnpm/issues/10338).
|
||||
@@ -39,6 +39,7 @@
|
||||
"@pnpm/command": "workspace:*",
|
||||
"@pnpm/common-cli-options-help": "workspace:*",
|
||||
"@pnpm/config": "workspace:*",
|
||||
"@pnpm/config.version-policy": "workspace:*",
|
||||
"@pnpm/core-loggers": "workspace:*",
|
||||
"@pnpm/crypto.hash": "workspace:*",
|
||||
"@pnpm/deps.status": "workspace:*",
|
||||
|
||||
@@ -6,6 +6,7 @@ import { createResolver } from '@pnpm/client'
|
||||
import { parseWantedDependency } from '@pnpm/parse-wanted-dependency'
|
||||
import { OUTPUT_OPTIONS } from '@pnpm/common-cli-options-help'
|
||||
import { type Config, types } from '@pnpm/config'
|
||||
import { createPackageVersionPolicy } from '@pnpm/config.version-policy'
|
||||
import { createHexHash } from '@pnpm/crypto.hash'
|
||||
import { PnpmError } from '@pnpm/error'
|
||||
import { add } from '@pnpm/plugin-commands-installation'
|
||||
@@ -82,7 +83,7 @@ export type DlxCommandOptions = {
|
||||
package?: string[]
|
||||
shellMode?: boolean
|
||||
allowBuild?: string[]
|
||||
} & Pick<Config, 'extraBinPaths' | 'registries' | 'reporter' | 'userAgent' | 'cacheDir' | 'dlxCacheMaxAge' | 'useNodeVersion' | 'symlink'> & Omit<add.AddCommandOptions, 'rootProjectManifestDir'> & PnpmSettings
|
||||
} & Pick<Config, 'extraBinPaths' | 'minimumReleaseAgeExclude' | 'registries' | 'reporter' | 'userAgent' | 'cacheDir' | 'dlxCacheMaxAge' | 'useNodeVersion' | 'symlink'> & Omit<add.AddCommandOptions, 'rootProjectManifestDir'> & PnpmSettings
|
||||
|
||||
export async function handler (
|
||||
opts: DlxCommandOptions,
|
||||
@@ -112,6 +113,9 @@ export async function handler (
|
||||
})
|
||||
const resolvedPkgAliases: string[] = []
|
||||
const publishedBy = opts.minimumReleaseAge ? new Date(Date.now() - opts.minimumReleaseAge * 60 * 1000) : undefined
|
||||
const publishedByExclude = opts.minimumReleaseAgeExclude
|
||||
? createPackageVersionPolicy(opts.minimumReleaseAgeExclude)
|
||||
: undefined
|
||||
const resolvedPkgs = await Promise.all(pkgs.map(async (pkg) => {
|
||||
const { alias, bareSpecifier } = parseWantedDependency(pkg) || {}
|
||||
if (alias == null) return pkg
|
||||
@@ -124,6 +128,7 @@ export async function handler (
|
||||
preferredVersions: {},
|
||||
projectDir: opts.dir,
|
||||
publishedBy,
|
||||
publishedByExclude,
|
||||
})
|
||||
return resolved.id
|
||||
}))
|
||||
|
||||
@@ -388,6 +388,26 @@ test('dlx should fail when the requested package does not meet the minimum age r
|
||||
).rejects.toThrow(/Version 0\.3\.4 \(released .+\) of shx does not meet the minimumReleaseAge constraint/)
|
||||
})
|
||||
|
||||
test('dlx should respect minimumReleaseAgeExclude', async () => {
|
||||
prepareEmpty()
|
||||
|
||||
await dlx.handler({
|
||||
...DEFAULT_OPTS,
|
||||
dir: path.resolve('project'),
|
||||
storeDir: path.resolve('store'),
|
||||
cacheDir: path.resolve('cache'),
|
||||
minimumReleaseAge: 60 * 24 * 10000,
|
||||
minimumReleaseAgeExclude: ['*'],
|
||||
registries: {
|
||||
// We must use the public registry instead of verdaccio here
|
||||
// because verdaccio has the "times" field in the abbreviated metadata too.
|
||||
default: 'https://registry.npmjs.org/',
|
||||
},
|
||||
}, ['shx@0.3.4', 'touch', 'foo'])
|
||||
|
||||
expect(fs.existsSync('foo')).toBeTruthy()
|
||||
})
|
||||
|
||||
test('dlx with catalog', async () => {
|
||||
prepareEmpty()
|
||||
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
{
|
||||
"path": "../../config/config"
|
||||
},
|
||||
{
|
||||
"path": "../../config/version-policy"
|
||||
},
|
||||
{
|
||||
"path": "../../crypto/hash"
|
||||
},
|
||||
|
||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
@@ -2856,6 +2856,9 @@ importers:
|
||||
'@pnpm/config':
|
||||
specifier: workspace:*
|
||||
version: link:../../config/config
|
||||
'@pnpm/config.version-policy':
|
||||
specifier: workspace:*
|
||||
version: link:../../config/version-policy
|
||||
'@pnpm/core-loggers':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/core-loggers
|
||||
@@ -6461,6 +6464,9 @@ importers:
|
||||
'@pnpm/config':
|
||||
specifier: workspace:*
|
||||
version: link:../config/config
|
||||
'@pnpm/config.version-policy':
|
||||
specifier: workspace:*
|
||||
version: link:../config/version-policy
|
||||
'@pnpm/constants':
|
||||
specifier: workspace:*
|
||||
version: link:../packages/constants
|
||||
|
||||
@@ -86,6 +86,7 @@
|
||||
"@pnpm/command": "workspace:*",
|
||||
"@pnpm/common-cli-options-help": "workspace:*",
|
||||
"@pnpm/config": "workspace:*",
|
||||
"@pnpm/config.version-policy": "workspace:*",
|
||||
"@pnpm/constants": "workspace:*",
|
||||
"@pnpm/core-loggers": "workspace:*",
|
||||
"@pnpm/crypto.hash": "workspace:*",
|
||||
|
||||
@@ -54,6 +54,9 @@
|
||||
{
|
||||
"path": "../config/plugin-commands-config"
|
||||
},
|
||||
{
|
||||
"path": "../config/version-policy"
|
||||
},
|
||||
{
|
||||
"path": "../crypto/hash"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user