Skip to content
Snippets Groups Projects
Unverified Commit 24af2926 authored by Michael Kriese's avatar Michael Kriese Committed by GitHub
Browse files

docs(manager): update regexManager (#5765)

parent 4addc283
No related branches found
No related tags found
No related merge requests found
...@@ -8,17 +8,27 @@ describe('manager metadata', () => { ...@@ -8,17 +8,27 @@ describe('manager metadata', () => {
.filter(name => !name.startsWith('__')) .filter(name => !name.startsWith('__'))
.sort(); .sort();
test.each(managerList)('%s has readme with no h1 or h2', async manager => { test.each(managerList)('%s has readme with no h1 or h2', async manager => {
let readme; let readme: string;
try { try {
readme = await fs.readFile(`${__dirname}/${manager}/readme.md`, 'utf8'); readme = await fs.readFile(`${__dirname}/${manager}/readme.md`, 'utf8');
} catch (err) { } catch (err) {
// do nothing // do nothing
} }
expect(readme).toBeDefined(); expect(readme).toBeDefined();
const lines = readme.split('\n');
let isCode = false;
const res: string[] = [];
for (const line of lines) {
if (line.startsWith('```')) {
isCode = !isCode;
} else if (!isCode) {
res.push(line);
}
}
expect( expect(
readme res.some(line => line.startsWith('# ') || line.startsWith('## '))
.split('\n')
.some(line => line.startsWith('# ') || line.startsWith('## '))
).toBe(false); ).toBe(false);
}); });
}); });
...@@ -22,6 +22,7 @@ Configuration-wise, it works like this: ...@@ -22,6 +22,7 @@ Configuration-wise, it works like this:
- You can optionally have a `lookupName` capture group or a `lookupNameTemplate` if it differs from `depName` - You can optionally have a `lookupName` capture group or a `lookupNameTemplate` if it differs from `depName`
- You must have either a `datasource` capture group or a `datasourceTemplate` config field - You must have either a `datasource` capture group or a `datasourceTemplate` config field
- You can optionally have a `versioning` capture group or a `versioningTemplate` config field. If neither are present, `semver` will be used as the default - You can optionally have a `versioning` capture group or a `versioningTemplate` config field. If neither are present, `semver` will be used as the default
- You can optionally have a `currentDigest` capture group.
### Regular Expression Capture Groups ### Regular Expression Capture Groups
...@@ -29,7 +30,7 @@ To be fully effective with the regex manager, you will need to understand regula ...@@ -29,7 +30,7 @@ To be fully effective with the regex manager, you will need to understand regula
Consider this `Dockerfile`: Consider this `Dockerfile`:
``` ```Dockerfile
FROM node:12 FROM node:12
ENV YARN_VERSION=1.19.1 ENV YARN_VERSION=1.19.1
RUN curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version ${YARN_VERSION} RUN curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version ${YARN_VERSION}
...@@ -60,11 +61,17 @@ In many cases, named capture groups alone won't be enough and you'll need to con ...@@ -60,11 +61,17 @@ In many cases, named capture groups alone won't be enough and you'll need to con
Let's say that your `Dockerfile` has many `ENV` variables you want to keep updated and you prefer not to write one `regexManagers` rule per variable. Instead you could enhance your `Dockerfile` like the following: Let's say that your `Dockerfile` has many `ENV` variables you want to keep updated and you prefer not to write one `regexManagers` rule per variable. Instead you could enhance your `Dockerfile` like the following:
``` ```Dockerfile
ENV NODE_VERSION=10.19.0 # github-tags/nodejs/node&versioning=node ARG IMAGE=node:12@sha256:6e5264cd4cfaefd7174b2bc10c7f9a1c2b99d98d127fc57a802d264da9fb43bd
ENV COMPOSER_VERSION=1.9.3 # github-releases/composer/composer FROM ${IMAGE}
ENV DOCKER_VERSION=19.03.1 # github-releases/docker/docker-ce&versioning=docker # renovate: datasource=github-tags depName=nodejs/node versioning=node
ENV YARN_VERSION=1.19.1 # npm/yarn ENV NODE_VERSION=10.19.0
# renovate: datasource=github-releases depName=composer/composer
ENV COMPOSER_VERSION=1.9.3
# renovate: datasource=docker depName=docker versioning=docker
ENV DOCKER_VERSION=19.03.1
# renovate: datasource=npm depName=yarn
ENV YARN_VERSION=1.19.1
``` ```
The above (obviously not a complete `Dockerfile`, but abbreviated for this example), could then be supported accordingly: The above (obviously not a complete `Dockerfile`, but abbreviated for this example), could then be supported accordingly:
...@@ -75,9 +82,16 @@ The above (obviously not a complete `Dockerfile`, but abbreviated for this examp ...@@ -75,9 +82,16 @@ The above (obviously not a complete `Dockerfile`, but abbreviated for this examp
{ {
"fileMatch": ["^Dockerfile$"], "fileMatch": ["^Dockerfile$"],
"matchStrings": [ "matchStrings": [
"ENV .*?_VERSION=(?<currentValue>.*) # (?<datasource>.*?)/(?<depName>.*?)(\\&versioning=(?<versioning>.*?))?\\s" "datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sENV .*?_VERSION=(?<currentValue>.*)\\s"
], ],
"versioningTemplate": "{{#if versioning}}{{versioning}}{{else}}semver{{/if}}" "versioningTemplate": "{{#if versioning}}{{versioning}}{{else}}semver{{/if}}"
},
{
"fileMatch": ["^Dockerfile$"],
"matchStrings": [
"ARG IMAGE=(?<depName>.*?):(?<currentValue>.*?)@(?<currentDigest>sha256:[a-f0-9]+)s"
],
"datasourceTemplate": "docker"
} }
] ]
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment