diff --git a/lib/config/types.ts b/lib/config/types.ts index 2aa2cd155230eb1c4825c4f2b401a9985c4a5f58..9853144a82dd292827a5db02c2fd5f30ad04d1a2 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -3,7 +3,7 @@ import type { PlatformId } from '../constants'; import type { LogLevelRemap } from '../logger/types'; import type { CustomManager } from '../modules/manager/custom/types'; import type { RepoSortMethod, SortMethod } from '../modules/platform/types'; -import type { HostRule } from '../types'; +import type { HostRule, SkipReason } from '../types'; import type { GitNoVerifyOption } from '../util/git/types'; import type { MergeConfidence } from '../util/merge-confidence/types'; @@ -544,6 +544,8 @@ export interface PackageRuleInputConfig extends Record<string, unknown> { releaseTimestamp?: string | null; repository?: string; currentVersionTimestamp?: string; + enabled?: boolean; + skipReason?: SkipReason; } export interface ConfigMigration { diff --git a/lib/types/skip-reason.ts b/lib/types/skip-reason.ts index 5517d34c0c8563b222297b3872787f78d4965126..2d2ff12a3379a2ea0473b26a8bd16dbd3dc772eb 100644 --- a/lib/types/skip-reason.ts +++ b/lib/types/skip-reason.ts @@ -26,6 +26,7 @@ export type SkipReason = | 'no-source' | 'non-hex-dep-types' | 'not-a-version' + | 'package-rules' | 'path-dependency' | 'placeholder-url' | 'unknown-engines' diff --git a/lib/util/package-rules/index.spec.ts b/lib/util/package-rules/index.spec.ts index 6a6a7dc01407ba42f51474a8f848b1daf14e10ac..b47ca9e99b877f059ffd37be089586539ad853c7 100644 --- a/lib/util/package-rules/index.spec.ts +++ b/lib/util/package-rules/index.spec.ts @@ -210,6 +210,34 @@ describe('util/package-rules/index', () => { expect(res2.automerge).toBeFalse(); }); + it('sets skipReason=package-rules if enabled=false', () => { + const dep: any = { + depName: 'foo', + packageRules: [ + { + enabled: false, + }, + ], + }; + const res = applyPackageRules(dep); + expect(res.enabled).toBeFalse(); + expect(res.skipReason).toBe('package-rules'); + }); + + it('skips skipReason=package-rules if enabled=true', () => { + const dep: any = { + enabled: false, + depName: 'foo', + packageRules: [ + { + enabled: false, + }, + ], + }; + const res = applyPackageRules(dep); + expect(res.skipReason).toBeUndefined(); + }); + it('matches anything if missing inclusive rules', () => { const config: TestConfig = { packageRules: [ diff --git a/lib/util/package-rules/index.ts b/lib/util/package-rules/index.ts index 9fee74a23bd82149be1acac833aeabba2dcf474d..f625ea5b24462fc9dd5c524525cbb880781c645e 100644 --- a/lib/util/package-rules/index.ts +++ b/lib/util/package-rules/index.ts @@ -80,6 +80,9 @@ export function applyPackageRules<T extends PackageRuleInputConfig>( lower: true, }); } + if (toApply.enabled === false && config.enabled !== false) { + config.skipReason = 'package-rules'; + } config = mergeChildConfig(config, toApply); } }