mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
docs(regex): add regex flavor information (#26797)
This commit is contained in:
parent
08d5416f0b
commit
57450586c3
1 changed files with 10 additions and 5 deletions
|
@ -1,5 +1,9 @@
|
|||
With the `regex` manager you can configure Renovate so it finds dependencies that are not detected by its other built-in package managers.
|
||||
|
||||
Renovate supports the `ECMAScript (JavaScript)` flavor of regex.
|
||||
|
||||
Renovate uses the `uhop/node-re2` package that provides bindings for [`google/re2`](https://github.com/google/re2).
|
||||
Read about [`uhop/node-re2`'s limitations in their readme](https://github.com/uhop/node-re2#limitations-things-re2-does-not-support).
|
||||
The `regex` manager is unique in Renovate because:
|
||||
|
||||
- It is configurable via regex named capture groups
|
||||
|
@ -29,11 +33,11 @@ Configuration-wise, it works like this:
|
|||
- You can optionally have a `packageName` capture group or a `packageNameTemplate` if it differs from `depName`
|
||||
- You must have either a `datasource` capture group or a `datasourceTemplate` config field
|
||||
- You can optionally have a `depType` capture group or a `depTypeTemplate` config field
|
||||
- You can optionally have a `versioning` capture group or a `versioningTemplate` config field. If neither are present, `semver-coerced` will be used as the default
|
||||
- You can optionally have a `versioning` capture group or a `versioningTemplate` config field. If neither are present, Renovate will use `semver-coerced` as the default
|
||||
- You can optionally have an `extractVersion` capture group or an `extractVersionTemplate` config field
|
||||
- You can optionally have a `currentDigest` capture group.
|
||||
- You can optionally have a `registryUrl` capture group or a `registryUrlTemplate` config field. If it's a valid URL, it will be converted to the `registryUrls` field as a single-length array.
|
||||
- You can optionally have an `indentation` capture group. It must be either empty or whitespace only, otherwise it will be reset to an empty string.
|
||||
- You can optionally have a `currentDigest` capture group
|
||||
- You can optionally have a `registryUrl` capture group or a `registryUrlTemplate` config field. If it's a valid URL, it will be converted to the `registryUrls` field as a single-length array
|
||||
- You can optionally have an `indentation` capture group. It must be either empty or whitespace only, otherwise it will be reset to an empty string
|
||||
|
||||
### Regular Expression Capture Groups
|
||||
|
||||
|
@ -51,6 +55,7 @@ RUN curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version ${YARN_VER
|
|||
You would need to capture the `currentValue` with a named capture group, like this: `ENV YARN_VERSION=(?<currentValue>.*?)\\n`.
|
||||
|
||||
If you're looking for an online regex testing tool that supports capture groups, try [regex101.com](<https://regex101.com/?flavor=javascript&flags=g®ex=ENV%20YARN_VERSION%3D(%3F%3CcurrentValue%3E.*%3F)%5Cn&testString=FROM%20node%3A12%0AENV%20YARN_VERSION%3D1.19.1%0ARUN%20curl%20-o-%20-L%20https%3A%2F%2Fyarnpkg.com%2Finstall.sh%20%7C%20bash%20-s%20--%20--version%20%24%7BYARN_VERSION%7D>).
|
||||
You must select the `ECMAScript (JavaScript)` flavor of regex.
|
||||
Be aware that backslashes (`'\'`) of the resulting regex have to still be escaped e.g. `\n\s` --> `\\n\\s`.
|
||||
You can use the Code Generator in the sidebar and copy the regex in the generated "Alternative syntax" comment into JSON.
|
||||
|
||||
|
@ -121,7 +126,7 @@ You could configure Renovate to update the `Dockerfile` like this:
|
|||
}
|
||||
```
|
||||
|
||||
We could drop the `versioningTemplate` because Renovate defaults to `∆semver-coerced` versioning.
|
||||
We could drop the `versioningTemplate` because Renovate defaults to `semver-coerced` versioning.
|
||||
But we included the `versioningTemplate` config option to show you why we call these fields _templates_: because they are compiled using Handlebars and so can be composed from values you collect in named capture groups.
|
||||
|
||||
You should use triple brace `{{{ }}}` templates like `{{{versioning}}}` to be safe.
|
||||
|
|
Loading…
Reference in a new issue