Skip to content

Commit

Permalink
feat(package-rules): warn for depName fallback (#28547)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Apr 22, 2024
1 parent 52ae77c commit fa732c4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
19 changes: 17 additions & 2 deletions docs/usage/configuration-options.md
Expand Up @@ -2886,6 +2886,12 @@ See also `excludePackageNames`.

The above will configure `rangeStrategy` to `pin` only for the package `angular`.

<!-- prettier-ignore -->
!!! note
`matchPackageNames` will try matching `packageName` first and then fall back to matching `depName`.
If the fallback is used, Renovate will log a warning, because the fallback will be removed in a future release.
Use `matchDepNames` instead.

### matchPackagePatterns

Use this field if you want to have one or more package names patterns in your package rule.
Expand All @@ -2904,6 +2910,12 @@ See also `excludePackagePatterns`.

The above will configure `rangeStrategy` to `replace` for any package starting with `angular`.

<!-- prettier-ignore -->
!!! note
`matchPackagePatterns` will try matching `packageName` first and then fall back to matching `depName`.
If the fallback is used, Renovate will log a warning, because the fallback will be removed in a future release.
Use `matchDepPatterns` instead.

### matchPackagePrefixes

Use this field to match a package prefix without needing to write a regex expression.
Expand All @@ -2922,8 +2934,11 @@ See also `excludePackagePrefixes`.

Like the earlier `matchPackagePatterns` example, the above will configure `rangeStrategy` to `replace` for any package starting with `angular`.

`matchPackagePrefixes` will match against `packageName` first, and then `depName`, however `depName` matching is deprecated and will be removed in a future major release.
If matching against `depName`, use `matchDepPatterns` instead.
<!-- prettier-ignore -->
!!! note
`matchPackagePrefixes` will try matching `packageName` first and then fall back to matching `depName`.
If the fallback is used, Renovate will log a warning, because the fallback will be removed in a future release.
Use `matchDepPatterns` instead.

### matchSourceUrlPrefixes

Expand Down
4 changes: 2 additions & 2 deletions lib/util/package-rules/package-names.spec.ts
Expand Up @@ -54,7 +54,7 @@ describe('util/package-rules/package-names', () => {
},
);
expect(result).toBeTrue();
expect(logger.logger.once.info).toHaveBeenCalled();
expect(logger.logger.once.warn).toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -108,7 +108,7 @@ describe('util/package-rules/package-names', () => {
},
);
expect(result).toBeTrue();
expect(logger.logger.once.info).toHaveBeenCalled();
expect(logger.logger.once.warn).toHaveBeenCalled();
});
});
});
4 changes: 2 additions & 2 deletions lib/util/package-rules/package-names.ts
Expand Up @@ -21,7 +21,7 @@ export class PackageNameMatcher extends Matcher {
}

if (matchPackageNames.includes(depName)) {
logger.once.info(
logger.once.warn(
{ packageRule, packageName, depName },
'Use matchDepNames instead of matchPackageNames',
);
Expand All @@ -48,7 +48,7 @@ export class PackageNameMatcher extends Matcher {
}

if (excludePackageNames.includes(depName)) {
logger.once.info(
logger.once.warn(
{ packageRule, packageName, depName },
'Use excludeDepNames instead of excludePackageNames',
);
Expand Down
4 changes: 2 additions & 2 deletions lib/util/package-rules/package-patterns.ts
Expand Up @@ -39,7 +39,7 @@ export class PackagePatternsMatcher extends Matcher {
return true;
}
if (matchPatternsAgainstName(matchPackagePatterns, depName)) {
logger.once.info(
logger.once.warn(
{ packageRule, packageName, depName },
'Use matchDepPatterns instead of matchPackagePatterns',
);
Expand Down Expand Up @@ -70,7 +70,7 @@ export class PackagePatternsMatcher extends Matcher {
}

if (matchPatternsAgainstName(excludePackagePatterns, depName)) {
logger.once.info(
logger.once.warn(
{ packageRule, packageName, depName },
'Use excludeDepPatterns instead of excludePackagePatterns',
);
Expand Down
4 changes: 2 additions & 2 deletions lib/util/package-rules/package-prefixes.ts
Expand Up @@ -23,7 +23,7 @@ export class PackagePrefixesMatcher extends Matcher {
return true;
}
if (matchPackagePrefixes.some((prefix) => depName.startsWith(prefix))) {
logger.once.info(
logger.once.warn(
{ packageName, depName },
'Use matchDepPatterns instead of matchPackagePrefixes',
);
Expand Down Expand Up @@ -52,7 +52,7 @@ export class PackagePrefixesMatcher extends Matcher {
return true;
}
if (excludePackagePrefixes.some((prefix) => depName.startsWith(prefix))) {
logger.once.info(
logger.once.warn(
{ packageName, depName },
'Use excludeDepPatterns instead of excludePackagePrefixes',
);
Expand Down

0 comments on commit fa732c4

Please sign in to comment.