mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-30 02:28:18 -05:00
fix: should respect ignore patterns in updateConfig.ignoreDependencies (#6590)
close #6548
This commit is contained in:
7
.changeset/sour-zebras-confess.md
Normal file
7
.changeset/sour-zebras-confess.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@pnpm/plugin-commands-installation": patch
|
||||
"@pnpm/plugin-commands-outdated": patch
|
||||
"@pnpm/outdated": major
|
||||
---
|
||||
|
||||
Should respect ignore patterns in updateConfig.ignoreDependencies [#6548](https://github.com/pnpm/pnpm/issues/6548)
|
||||
@@ -192,7 +192,7 @@ async function interactiveUpdate (
|
||||
const outdatedPkgsOfProjects = await outdatedDepsOfProjects(projects, input, {
|
||||
...opts,
|
||||
compatible: opts.latest !== true,
|
||||
ignoreDependencies: new Set(rootProject?.manifest?.pnpm?.updateConfig?.ignoreDependencies ?? []),
|
||||
ignoreDependencies: rootProject?.manifest?.pnpm?.updateConfig?.ignoreDependencies,
|
||||
include,
|
||||
retry: {
|
||||
factor: opts.fetchRetryFactor,
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
} from '@pnpm/types'
|
||||
import * as dp from '@pnpm/dependency-path'
|
||||
import semver from 'semver'
|
||||
import { createMatcher } from '@pnpm/matcher'
|
||||
|
||||
export * from './createManifestGetter'
|
||||
|
||||
@@ -38,7 +39,7 @@ export async function outdated (
|
||||
compatible?: boolean
|
||||
currentLockfile: Lockfile | null
|
||||
getLatestManifest: GetLatestManifestFunction
|
||||
ignoreDependencies?: Set<string>
|
||||
ignoreDependencies?: string[]
|
||||
include?: IncludedDependencies
|
||||
lockfileDir: string
|
||||
manifest: ProjectManifest
|
||||
@@ -58,6 +59,8 @@ export async function outdated (
|
||||
|
||||
const outdated: OutdatedPackage[] = []
|
||||
|
||||
const ignoreDependenciesMatcher = opts.ignoreDependencies?.length ? createMatcher(opts.ignoreDependencies) : undefined
|
||||
|
||||
await Promise.all(
|
||||
DEPENDENCIES_FIELDS.map(async (depType) => {
|
||||
if (
|
||||
@@ -78,7 +81,7 @@ export async function outdated (
|
||||
|
||||
if (
|
||||
ref.startsWith('file:') || // ignoring linked packages. (For backward compatibility)
|
||||
opts.ignoreDependencies?.has(alias)
|
||||
ignoreDependenciesMatcher?.(alias)
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export async function outdatedDepsOfProjects (
|
||||
args: string[],
|
||||
opts: Omit<ManifestGetterOptions, 'fullMetadata' | 'lockfileDir'> & {
|
||||
compatible?: boolean
|
||||
ignoreDependencies?: Set<string>
|
||||
ignoreDependencies?: string[]
|
||||
include: IncludedDependencies
|
||||
} & Partial<Pick<ManifestGetterOptions, 'fullMetadata' | 'lockfileDir'>>
|
||||
): Promise<OutdatedPackage[][]> {
|
||||
|
||||
@@ -530,3 +530,142 @@ test('outdated() should [] when there is no dependency', async () => {
|
||||
})
|
||||
expect(outdatedPkgs).toStrictEqual([])
|
||||
})
|
||||
|
||||
test('should ignore dependencies as expected', async () => {
|
||||
const outdatedPkgs = await outdated({
|
||||
currentLockfile: {
|
||||
importers: {
|
||||
'.': {
|
||||
dependencies: {
|
||||
'from-github': 'github.com/blabla/from-github/d5f8d5500f7faf593d32e134c1b0043ff69151b4',
|
||||
},
|
||||
devDependencies: {
|
||||
'is-negative': '1.0.0',
|
||||
'is-positive': '1.0.0',
|
||||
},
|
||||
optionalDependencies: {
|
||||
'linked-1': 'link:../linked-1',
|
||||
'linked-2': 'file:../linked-2',
|
||||
},
|
||||
specifiers: {
|
||||
'from-github': 'github:blabla/from-github#d5f8d5500f7faf593d32e134c1b0043ff69151b4',
|
||||
'is-negative': '^2.1.0',
|
||||
'is-positive': '^1.0.0',
|
||||
},
|
||||
},
|
||||
},
|
||||
lockfileVersion: 5,
|
||||
packages: {
|
||||
'/is-negative/2.1.0': {
|
||||
dev: true,
|
||||
resolution: {
|
||||
integrity: 'sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=',
|
||||
},
|
||||
},
|
||||
'/is-positive/1.0.0': {
|
||||
dev: true,
|
||||
resolution: {
|
||||
integrity: 'sha512-xxzPGZ4P2uN6rROUa5N9Z7zTX6ERuE0hs6GUOc/cKBLF2NqKc16UwqHMt3tFg4CO6EBTE5UecUasg+3jZx3Ckg==',
|
||||
},
|
||||
},
|
||||
'github.com/blabla/from-github/d5f8d5500f7faf593d32e134c1b0043ff69151b4': {
|
||||
name: 'from-github',
|
||||
version: '1.1.0',
|
||||
|
||||
dev: false,
|
||||
resolution: {
|
||||
tarball: 'https://codeload.github.com/blabla/from-github/tar.gz/d5f8d5500f7faf593d32e134c1b0043ff69151b3',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
getLatestManifest,
|
||||
lockfileDir: 'project',
|
||||
manifest: {
|
||||
name: 'wanted-shrinkwrap',
|
||||
version: '1.0.0',
|
||||
dependencies: {
|
||||
'from-github': 'github:blabla/from-github#d5f8d5500f7faf593d32e134c1b0043ff69151b4',
|
||||
'from-github-2': 'github:blabla/from-github-2#d5f8d5500f7faf593d32e134c1b0043ff69151b4',
|
||||
},
|
||||
devDependencies: {
|
||||
'is-negative': '^2.1.0',
|
||||
'is-positive': '^3.1.0',
|
||||
},
|
||||
},
|
||||
prefix: 'project',
|
||||
wantedLockfile: {
|
||||
importers: {
|
||||
'.': {
|
||||
dependencies: {
|
||||
'from-github': 'github.com/blabla/from-github/d5f8d5500f7faf593d32e134c1b0043ff69151b3',
|
||||
'from-github-2': 'github.com/blabla/from-github-2/d5f8d5500f7faf593d32e134c1b0043ff69151b3',
|
||||
},
|
||||
devDependencies: {
|
||||
'is-negative': '1.1.0',
|
||||
'is-positive': '3.1.0',
|
||||
},
|
||||
optionalDependencies: {
|
||||
'linked-1': 'link:../linked-1',
|
||||
'linked-2': 'file:../linked-2',
|
||||
},
|
||||
specifiers: {
|
||||
'from-github': 'github:blabla/from-github#d5f8d5500f7faf593d32e134c1b0043ff69151b4',
|
||||
'from-github-2': 'github:blabla/from-github-2#d5f8d5500f7faf593d32e134c1b0043ff69151b4',
|
||||
'is-negative': '^2.1.0',
|
||||
'is-positive': '^3.1.0',
|
||||
},
|
||||
},
|
||||
},
|
||||
lockfileVersion: 5,
|
||||
packages: {
|
||||
'/is-negative/1.1.0': {
|
||||
resolution: {
|
||||
integrity: 'sha1-8Nhjd6oVpkw0lh84rCqb4rQKEYc=',
|
||||
},
|
||||
},
|
||||
'/is-positive/3.1.0': {
|
||||
resolution: {
|
||||
integrity: 'sha512-8ND1j3y9/HP94TOvGzr69/FgbkX2ruOldhLEsTWwcJVfo4oRjwemJmJxt7RJkKYH8tz7vYBP9JcKQY8CLuJ90Q==',
|
||||
},
|
||||
},
|
||||
'github.com/blabla/from-github-2/d5f8d5500f7faf593d32e134c1b0043ff69151b3': {
|
||||
name: 'from-github-2',
|
||||
version: '1.0.0',
|
||||
|
||||
resolution: {
|
||||
tarball: 'https://codeload.github.com/blabla/from-github-2/tar.gz/d5f8d5500f7faf593d32e134c1b0043ff69151b3',
|
||||
},
|
||||
},
|
||||
'github.com/blabla/from-github/d5f8d5500f7faf593d32e134c1b0043ff69151b3': {
|
||||
name: 'from-github',
|
||||
version: '1.0.0',
|
||||
|
||||
resolution: {
|
||||
tarball: 'https://codeload.github.com/blabla/from-github/tar.gz/d5f8d5500f7faf593d32e134c1b0043ff69151b3',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
registries: {
|
||||
default: 'https://registry.npmjs.org/',
|
||||
},
|
||||
ignoreDependencies: [
|
||||
'from-*',
|
||||
'is-negative',
|
||||
],
|
||||
})
|
||||
expect(outdatedPkgs).toStrictEqual([
|
||||
{
|
||||
alias: 'is-positive',
|
||||
belongsTo: 'devDependencies',
|
||||
current: '1.0.0',
|
||||
latestManifest: {
|
||||
name: 'is-positive',
|
||||
version: '3.1.0',
|
||||
},
|
||||
packageName: 'is-positive',
|
||||
wanted: '3.1.0',
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
@@ -181,7 +181,7 @@ export async function handler (
|
||||
const [outdatedPackages] = await outdatedDepsOfProjects(packages, params, {
|
||||
...opts,
|
||||
fullMetadata: opts.long,
|
||||
ignoreDependencies: new Set(manifest?.pnpm?.updateConfig?.ignoreDependencies ?? []),
|
||||
ignoreDependencies: manifest?.pnpm?.updateConfig?.ignoreDependencies,
|
||||
include,
|
||||
retry: {
|
||||
factor: opts.fetchRetryFactor,
|
||||
|
||||
@@ -56,7 +56,7 @@ export async function outdatedRecursive (
|
||||
const outdatedPackagesByProject = await outdatedDepsOfProjects(pkgs, params, {
|
||||
...opts,
|
||||
fullMetadata: opts.long,
|
||||
ignoreDependencies: new Set(rootManifest?.manifest?.pnpm?.updateConfig?.ignoreDependencies ?? []),
|
||||
ignoreDependencies: rootManifest?.manifest?.pnpm?.updateConfig?.ignoreDependencies,
|
||||
retry: {
|
||||
factor: opts.fetchRetryFactor,
|
||||
maxTimeout: opts.fetchRetryMaxtimeout,
|
||||
|
||||
Reference in New Issue
Block a user