Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -3439,10 +3439,15 @@ $exists(deprecationMessage)
$exists(vulnerabilityFixVersion)
manager = 'dockerfile' and depType = 'final'
updateType = 'major' and newVersionAgeInDays < 7
$detectPlatform(sourceUrl) = "github"
```

`matchJsonata` accepts an array of strings, and will return `true` if any of those JSONata expressions evaluate to `true`.

Renovate provides the following custom JSONata functions:

- `$detectPlatform(url)` - Takes a URL string and returns the detected platform (`azure`, `bitbucket`, `bitbucket-server`, `forgejo`, `gitea`, `github`, `gitlab`) or `null`.

### matchManagers

Use this field to restrict rules to a particular package manager. e.g.
Expand Down
7 changes: 5 additions & 2 deletions lib/modules/manager/maven/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
The `maven` manager focuses on extracting dependencies from `pom.xml`. It uses the official Maven versioning scheme.
The `maven` manager focuses on extracting dependencies from `pom.xml`.
It uses the official Maven versioning scheme.
XML files must declare official namespaces to be parsed correctly (see Maven documentation on [`pom.xml`](https://maven.apache.org/pom.html), [`extensions.xml`](https://maven.apache.org/configure.html#mvn-extensions-xml-file)).

It also supports [Image Customizations](https://docs.spring.io/spring-boot/maven-plugin/build-image.html#build-image.customization) of `spring-boot`'s OCI packaging. Usage of `registryAliases` is possible only for container image references.
It also supports [Image Customizations](https://docs.spring.io/spring-boot/maven-plugin/build-image.html#build-image.customization) of `spring-boot`'s OCI packaging.
Usage of `registryAliases` is possible only for container image references.

### Limitations

Expand Down
28 changes: 28 additions & 0 deletions lib/util/jsonata.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ describe('util/jsonata', () => {
expect(getExpression('foo[')).toBeInstanceOf(Error);
});

describe('$detectPlatform', () => {
it('should return platform for known URL', async () => {
const expression = getExpression(
'$detectPlatform("https://github.com/foo/bar")',
);
expect(expression).not.toBeInstanceOf(Error);
// make typescript happy
if (expression instanceof Error) {
throw expression;
}
const result = await expression.evaluate({});
expect(result).toBe('github');
});

it('should return null for unknown URL', async () => {
const expression = getExpression(
'$detectPlatform("https://unknown.example.com")',
);
expect(expression).not.toBeInstanceOf(Error);
// make typescript happy
if (expression instanceof Error) {
throw expression;
}
const result = await expression.evaluate({});
expect(result).toBeNull();
});
});

describe('concurrent evaluation', () => {
beforeEach(() => {
memCache.init();
Expand Down
6 changes: 6 additions & 0 deletions lib/util/jsonata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import jsonata from 'jsonata';
import * as memCache from './cache/memory/index.ts';
import { detectPlatform } from './common.ts';
import { toSha256 } from './hash.ts';

export interface JsonataExpression {
Expand All @@ -16,6 +17,11 @@ export function getExpression(input: string): JsonataExpression | Error {
let result: jsonata.Expression | Error;
try {
const expression = jsonata(input);
expression.registerFunction(
'detectPlatform',
(url: string) => detectPlatform(url),
'<s-:s>',
);
// Wrap the evaluate method to default bindings to {} for concurrent evaluation safety.
// This prevents race conditions when the same cached expression is evaluated
// concurrently with different data. See #40311 for background.
Expand Down
18 changes: 18 additions & 0 deletions lib/util/package-rules/jsonata.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,22 @@ describe('util/package-rules/jsonata', () => {
);
expect(result).toBeFalse();
});

describe('$detectPlatform', () => {
it('should return true when sourceUrl matches platform', async () => {
const result = await matcher.matches(
{ sourceUrl: 'https://github.com/foo/bar' },
{ matchJsonata: ['$detectPlatform(sourceUrl) = "github"'] },
);
expect(result).toBeTrue();
});

it('should return false when sourceUrl does not match platform', async () => {
const result = await matcher.matches(
{ sourceUrl: 'https://gitlab.com/foo/bar' },
{ matchJsonata: ['$detectPlatform(sourceUrl) = "github"'] },
);
expect(result).toBeFalse();
});
});
});
2 changes: 1 addition & 1 deletion lib/util/template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const allowedFields = {
manager: 'The (package) manager which detected the dependency',
newDigest: 'The new digest value',
newDigestShort:
'A shorted version of newDigest, for use when the full digest is too long to be conveniently displayed',
'A shortened version of newDigest, for use when the full digest is too long to be conveniently displayed',
newMajor:
'The major version of the new version. e.g. "3" if the new version is "3.1.0"',
newMinor:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
"eslint-plugin-oxlint": "1.51.0",
"expect-more-jest": "5.5.0",
"globals": "17.4.0",
"graphql": "16.13.0",
"graphql": "16.13.1",
"husky": "9.1.7",
"jest-extended": "7.0.0",
"lint-staged": "16.3.2",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading