From d96a1331cd0a706d1a88413813f63d8d58744a92 Mon Sep 17 00:00:00 2001 From: secustor Date: Fri, 5 Nov 2021 22:15:42 +0100 Subject: [PATCH 1/4] refactor(regex): functions to util.ts and strategies.ts --- lib/manager/regex/index.ts | 168 +------------------------------- lib/manager/regex/strategies.ts | 82 ++++++++++++++++ lib/manager/regex/utils.ts | 95 ++++++++++++++++++ 3 files changed, 179 insertions(+), 166 deletions(-) create mode 100644 lib/manager/regex/strategies.ts create mode 100644 lib/manager/regex/utils.ts diff --git a/lib/manager/regex/index.ts b/lib/manager/regex/index.ts index beb11affa4ce36..7557012ad67dc5 100644 --- a/lib/manager/regex/index.ts +++ b/lib/manager/regex/index.ts @@ -1,180 +1,16 @@ -import { URL } from 'url'; -import { logger } from '../../logger'; -import { regEx } from '../../util/regex'; -import * as template from '../../util/template'; import type { CustomExtractConfig, PackageDependency, PackageFile, Result, } from '../types'; -import type { ExtractionTemplate } from './types'; +import { handleAny, handleCombination, handleRecursive } from './strategies'; +import { validMatchFields } from './utils'; export const defaultConfig = { pinDigests: false, }; -const validMatchFields = [ - 'depName', - 'lookupName', - 'currentValue', - 'currentDigest', - 'datasource', - 'versioning', - 'extractVersion', - 'registryUrl', - 'depType', -]; - -function regexMatchAll(regex: RegExp, content: string): RegExpMatchArray[] { - const matches: RegExpMatchArray[] = []; - let matchResult; - do { - matchResult = regex.exec(content); - if (matchResult) { - matches.push(matchResult); - } - } while (matchResult); - return matches; -} - -function createDependency( - extractionTemplate: ExtractionTemplate, - config: CustomExtractConfig, - dep?: PackageDependency -): PackageDependency { - const dependency = dep || {}; - const { groups, replaceString } = extractionTemplate; - - function updateDependency(field: string, value: string): void { - switch (field) { - case 'registryUrl': - // check if URL is valid and pack inside an array - try { - const url = new URL(value).toString(); - dependency.registryUrls = [url]; - } catch (err) { - logger.warn({ value }, 'Invalid regex manager registryUrl'); - } - break; - default: - dependency[field] = value; - break; - } - } - - for (const field of validMatchFields) { - const fieldTemplate = `${field}Template`; - if (config[fieldTemplate]) { - try { - const compiled = template.compile(config[fieldTemplate], groups, false); - updateDependency(field, compiled); - } catch (err) { - logger.warn( - { template: config[fieldTemplate] }, - 'Error compiling template for custom manager' - ); - return null; - } - } else if (groups[field]) { - updateDependency(field, groups[field]); - } - } - dependency.replaceString = replaceString; - return dependency; -} - -function handleAny( - content: string, - packageFile: string, - config: CustomExtractConfig -): PackageDependency[] { - return config.matchStrings - .map((matchString) => regEx(matchString, 'g')) - .flatMap((regex) => regexMatchAll(regex, content)) // match all regex to content, get all matches, reduce to single array - .map((matchResult) => - createDependency( - { groups: matchResult.groups, replaceString: matchResult[0] }, - config - ) - ); -} - -function mergeGroups( - mergedGroup: Record, - secondGroup: Record -): Record { - return { ...mergedGroup, ...secondGroup }; -} - -export function mergeExtractionTemplate( - base: ExtractionTemplate, - addition: ExtractionTemplate -): ExtractionTemplate { - return { - groups: mergeGroups(base.groups, addition.groups), - replaceString: addition.replaceString ?? base.replaceString, - }; -} - -function handleCombination( - content: string, - packageFile: string, - config: CustomExtractConfig -): PackageDependency[] { - const matches = config.matchStrings - .map((matchString) => regEx(matchString, 'g')) - .flatMap((regex) => regexMatchAll(regex, content)); // match all regex to content, get all matches, reduce to single array - - if (!matches.length) { - return []; - } - - const extraction = matches - .map((match) => ({ - groups: match.groups, - replaceString: match?.groups?.currentValue ? match[0] : undefined, - })) - .reduce((base, addition) => mergeExtractionTemplate(base, addition)); - return [createDependency(extraction, config)]; -} - -function handleRecursive( - content: string, - packageFile: string, - config: CustomExtractConfig, - index = 0, - combinedGroups: Record = {} -): PackageDependency[] { - const regexes = config.matchStrings.map((matchString) => - regEx(matchString, 'g') - ); - // abort if we have no matchString anymore - if (regexes[index] == null) { - return []; - } - return regexMatchAll(regexes[index], content).flatMap((match) => { - // if we have a depName and a currentValue which have the minimal viable definition - if (match?.groups?.depName && match?.groups?.currentValue) { - return createDependency( - { - groups: mergeGroups(combinedGroups, match.groups), - replaceString: match[0], - }, - config - ); - } - - return handleRecursive( - match[0], - packageFile, - config, - index + 1, - mergeGroups(combinedGroups, match.groups || {}) - ); - }); -} - export function extractPackageFile( content: string, packageFile: string, diff --git a/lib/manager/regex/strategies.ts b/lib/manager/regex/strategies.ts new file mode 100644 index 00000000000000..d187641527aa8c --- /dev/null +++ b/lib/manager/regex/strategies.ts @@ -0,0 +1,82 @@ +import { regEx } from '../../util/regex'; +import { CustomExtractConfig, PackageDependency } from '../types'; +import { + createDependency, + mergeExtractionTemplate, + mergeGroups, + regexMatchAll, +} from './utils'; + +export function handleAny( + content: string, + packageFile: string, + config: CustomExtractConfig +): PackageDependency[] { + return config.matchStrings + .map((matchString) => regEx(matchString, 'g')) + .flatMap((regex) => regexMatchAll(regex, content)) // match all regex to content, get all matches, reduce to single array + .map((matchResult) => + createDependency( + { groups: matchResult.groups, replaceString: matchResult[0] }, + config + ) + ); +} + +export function handleCombination( + content: string, + packageFile: string, + config: CustomExtractConfig +): PackageDependency[] { + const matches = config.matchStrings + .map((matchString) => regEx(matchString, 'g')) + .flatMap((regex) => regexMatchAll(regex, content)); // match all regex to content, get all matches, reduce to single array + + if (!matches.length) { + return []; + } + + const extraction = matches + .map((match) => ({ + groups: match.groups, + replaceString: match?.groups?.currentValue ? match[0] : undefined, + })) + .reduce((base, addition) => mergeExtractionTemplate(base, addition)); + return [createDependency(extraction, config)]; +} + +export function handleRecursive( + content: string, + packageFile: string, + config: CustomExtractConfig, + index = 0, + combinedGroups: Record = {} +): PackageDependency[] { + const regexes = config.matchStrings.map((matchString) => + regEx(matchString, 'g') + ); + // abort if we have no matchString anymore + if (regexes[index] == null) { + return []; + } + return regexMatchAll(regexes[index], content).flatMap((match) => { + // if we have a depName and a currentValue which have the minimal viable definition + if (match?.groups?.depName && match?.groups?.currentValue) { + return createDependency( + { + groups: mergeGroups(combinedGroups, match.groups), + replaceString: match[0], + }, + config + ); + } + + return handleRecursive( + match[0], + packageFile, + config, + index + 1, + mergeGroups(combinedGroups, match.groups || {}) + ); + }); +} diff --git a/lib/manager/regex/utils.ts b/lib/manager/regex/utils.ts new file mode 100644 index 00000000000000..1c7f5ddefd02da --- /dev/null +++ b/lib/manager/regex/utils.ts @@ -0,0 +1,95 @@ +import { URL } from 'url'; +import { logger } from '../../logger'; +import * as template from '../../util/template'; +import { CustomExtractConfig, PackageDependency } from '../types'; +import { ExtractionTemplate } from './types'; + +export const validMatchFields = [ + 'depName', + 'lookupName', + 'currentValue', + 'currentDigest', + 'datasource', + 'versioning', + 'extractVersion', + 'registryUrl', + 'depType', +]; + +export function createDependency( + extractionTemplate: ExtractionTemplate, + config: CustomExtractConfig, + dep?: PackageDependency +): PackageDependency { + const dependency = dep || {}; + const { groups, replaceString } = extractionTemplate; + + function updateDependency(field: string, value: string): void { + switch (field) { + case 'registryUrl': + // check if URL is valid and pack inside an array + try { + const url = new URL(value).toString(); + dependency.registryUrls = [url]; + } catch (err) { + logger.warn({ value }, 'Invalid regex manager registryUrl'); + } + break; + default: + dependency[field] = value; + break; + } + } + + for (const field of validMatchFields) { + const fieldTemplate = `${field}Template`; + if (config[fieldTemplate]) { + try { + const compiled = template.compile(config[fieldTemplate], groups, false); + updateDependency(field, compiled); + } catch (err) { + logger.warn( + { template: config[fieldTemplate] }, + 'Error compiling template for custom manager' + ); + return null; + } + } else if (groups[field]) { + updateDependency(field, groups[field]); + } + } + dependency.replaceString = replaceString; + return dependency; +} + +export function regexMatchAll( + regex: RegExp, + content: string +): RegExpMatchArray[] { + const matches: RegExpMatchArray[] = []; + let matchResult; + do { + matchResult = regex.exec(content); + if (matchResult) { + matches.push(matchResult); + } + } while (matchResult); + return matches; +} + +export function mergeGroups( + mergedGroup: Record, + secondGroup: Record +): Record { + return { ...mergedGroup, ...secondGroup }; +} + +export function mergeExtractionTemplate( + base: ExtractionTemplate, + addition: ExtractionTemplate +): ExtractionTemplate { + return { + groups: mergeGroups(base.groups, addition.groups), + replaceString: addition.replaceString ?? base.replaceString, + }; +} From b52c967c49e67ab31de0e90a2920265ada0791e0 Mon Sep 17 00:00:00 2001 From: secustor Date: Fri, 5 Nov 2021 23:00:37 +0100 Subject: [PATCH 2/4] refactor(regex): change MatchstringStrategy to enum --- lib/config/types.ts | 6 +++++- lib/manager/regex/index.spec.ts | 25 +++++++++++++------------ lib/manager/regex/index.ts | 7 ++++--- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/lib/config/types.ts b/lib/config/types.ts index 07cbe71eb1d6e2..0faf876a413c9a 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -234,7 +234,11 @@ export type UpdateType = | 'rollback' | 'bump'; -export type MatchStringsStrategy = 'any' | 'recursive' | 'combination'; +export enum MatchStringsStrategy { + ANY = 'any', + RECURSIVE = 'recursive', + COMBINATION = 'combination', +} export type MergeStrategy = | 'auto' diff --git a/lib/manager/regex/index.spec.ts b/lib/manager/regex/index.spec.ts index 62e3fdc024a241..c1bb5c6af5d406 100644 --- a/lib/manager/regex/index.spec.ts +++ b/lib/manager/regex/index.spec.ts @@ -1,4 +1,5 @@ import { loadFixture } from '../../../test/util'; +import { MatchStringsStrategy } from '../../config/types'; import { logger } from '../../logger'; import type { CustomExtractConfig } from '../types'; import { defaultConfig, extractPackageFile } from '.'; @@ -195,7 +196,7 @@ describe('manager/regex/index', () => { 'prometheus_image:\\s*"(?.*)"\\s*\\/\\/', 'prometheus_version:\\s*"(?.*)"\\s*\\/\\/', ], - matchStringsStrategy: 'combination', + matchStringsStrategy: MatchStringsStrategy.COMBINATION, datasourceTemplate: 'docker', }; const res = await extractPackageFile( @@ -215,7 +216,7 @@ describe('manager/regex/index', () => { 'prometheus_tag:\\s*"(?.*)"\\s*\\/\\/', 'prometheus_version:\\s*"(?.*)"\\s*\\/\\/', ], - matchStringsStrategy: 'combination', + matchStringsStrategy: MatchStringsStrategy.COMBINATION, datasourceTemplate: 'docker', depNameTemplate: '{{{ registry }}}/{{{ repository }}}', }; @@ -235,7 +236,7 @@ describe('manager/regex/index', () => { '.*_image:\\s*"(?.*)"\\s*\\/\\/', '.*_version:\\s*"(?.*)"\\s*\\/\\/', ], - matchStringsStrategy: 'combination', + matchStringsStrategy: MatchStringsStrategy.COMBINATION, datasourceTemplate: 'docker', }; const res = await extractPackageFile( @@ -248,7 +249,7 @@ describe('manager/regex/index', () => { }); it('extracts with combination strategy and registry url', async () => { const config: CustomExtractConfig = { - matchStringsStrategy: 'combination', + matchStringsStrategy: MatchStringsStrategy.COMBINATION, matchStrings: [ 'CHART_VERSION: (?.*?)\n', 'CHART_REPOSITORY_URL: "(?.*?)"', @@ -267,7 +268,7 @@ describe('manager/regex/index', () => { it('extracts with combination strategy and templates', async () => { const config: CustomExtractConfig = { - matchStringsStrategy: 'combination', + matchStringsStrategy: MatchStringsStrategy.COMBINATION, matchStrings: [ 'CHART_REPOSITORY_URL: "(?.*)\\/(?[a-z]+)\\/"', 'CHART_VERSION: (?.*?)\n', @@ -286,7 +287,7 @@ describe('manager/regex/index', () => { it('extracts with combination strategy and empty file', async () => { const config: CustomExtractConfig = { - matchStringsStrategy: 'combination', + matchStringsStrategy: MatchStringsStrategy.COMBINATION, matchStrings: [ 'CHART_REPOSITORY_URL: "(?.*)\\/(?[a-z]+)\\/"', 'CHART_VERSION: (?.*?)\n', @@ -304,7 +305,7 @@ describe('manager/regex/index', () => { '"group1":\\s*\\{[^}]*}', '"name":\\s*"(?.*)"[^"]*"type":\\s*"(?.*)"[^"]*"value":\\s*"(?.*)"', ], - matchStringsStrategy: 'recursive', + matchStringsStrategy: MatchStringsStrategy.RECURSIVE, }; const res = await extractPackageFile( exampleJsonContent, @@ -320,7 +321,7 @@ describe('manager/regex/index', () => { '"group.{1}":\\s*\\{[^}]*}', '"name":\\s*"(?.*)"[^"]*"type":\\s*"(?.*)"[^"]*"value":\\s*"(?.*)"', ], - matchStringsStrategy: 'recursive', + matchStringsStrategy: MatchStringsStrategy.RECURSIVE, }; const res = await extractPackageFile( exampleJsonContent, @@ -337,7 +338,7 @@ describe('manager/regex/index', () => { '"test":\\s*\\{[^}]*}', '"name":\\s*"(?.*)"[^"]*"type":\\s*"(?.*)"[^"]*"value":\\s*"(?.*)"', ], - matchStringsStrategy: 'recursive', + matchStringsStrategy: MatchStringsStrategy.RECURSIVE, }; const res = await extractPackageFile( exampleJsonContent, @@ -350,7 +351,7 @@ describe('manager/regex/index', () => { it('extracts with recursive strategy and fail because of not sufficient regexes', async () => { const config: CustomExtractConfig = { matchStrings: ['"group.{1}":\\s*\\{[^}]*}'], - matchStringsStrategy: 'recursive', + matchStringsStrategy: MatchStringsStrategy.RECURSIVE, }; const res = await extractPackageFile( exampleJsonContent, @@ -363,7 +364,7 @@ describe('manager/regex/index', () => { it('extracts with recursive strategy and fail because there is no match', async () => { const config: CustomExtractConfig = { matchStrings: ['"trunk.{1}":\\s*\\{[^}]*}'], - matchStringsStrategy: 'recursive', + matchStringsStrategy: MatchStringsStrategy.RECURSIVE, }; const res = await extractPackageFile( exampleJsonContent, @@ -380,7 +381,7 @@ describe('manager/regex/index', () => { '"(?[^"]*)":\\s*\\{[^}]*}', '"name":\\s*"(?.*)"[^"]*"type":\\s*"(?.*)"[^"]*"value":\\s*"(?.*)"', ], - matchStringsStrategy: 'recursive', + matchStringsStrategy: MatchStringsStrategy.RECURSIVE, depNameTemplate: '{{{ first }}}/{{{ second }}}/{{{ depName }}}', }; const res = await extractPackageFile( diff --git a/lib/manager/regex/index.ts b/lib/manager/regex/index.ts index 7557012ad67dc5..dddcae70cae87d 100644 --- a/lib/manager/regex/index.ts +++ b/lib/manager/regex/index.ts @@ -1,3 +1,4 @@ +import { MatchStringsStrategy } from '../../config/types'; import type { CustomExtractConfig, PackageDependency, @@ -19,13 +20,13 @@ export function extractPackageFile( let deps: PackageDependency[]; switch (config.matchStringsStrategy) { default: - case 'any': + case MatchStringsStrategy.ANY: deps = handleAny(content, packageFile, config); break; - case 'combination': + case MatchStringsStrategy.COMBINATION: deps = handleCombination(content, packageFile, config); break; - case 'recursive': + case MatchStringsStrategy.RECURSIVE: deps = handleRecursive(content, packageFile, config); break; } From 8f1e3892e4fc0b83eab321a0ca80e880dfcbfff4 Mon Sep 17 00:00:00 2001 From: secustor Date: Sat, 6 Nov 2021 17:59:12 +0100 Subject: [PATCH 3/4] Revert "refactor(regex): change MatchstringStrategy to enum" This reverts commit b52c967c49e67ab31de0e90a2920265ada0791e0. --- lib/config/types.ts | 6 +----- lib/manager/regex/index.spec.ts | 25 ++++++++++++------------- lib/manager/regex/index.ts | 7 +++---- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/lib/config/types.ts b/lib/config/types.ts index 0faf876a413c9a..07cbe71eb1d6e2 100644 --- a/lib/config/types.ts +++ b/lib/config/types.ts @@ -234,11 +234,7 @@ export type UpdateType = | 'rollback' | 'bump'; -export enum MatchStringsStrategy { - ANY = 'any', - RECURSIVE = 'recursive', - COMBINATION = 'combination', -} +export type MatchStringsStrategy = 'any' | 'recursive' | 'combination'; export type MergeStrategy = | 'auto' diff --git a/lib/manager/regex/index.spec.ts b/lib/manager/regex/index.spec.ts index c1bb5c6af5d406..62e3fdc024a241 100644 --- a/lib/manager/regex/index.spec.ts +++ b/lib/manager/regex/index.spec.ts @@ -1,5 +1,4 @@ import { loadFixture } from '../../../test/util'; -import { MatchStringsStrategy } from '../../config/types'; import { logger } from '../../logger'; import type { CustomExtractConfig } from '../types'; import { defaultConfig, extractPackageFile } from '.'; @@ -196,7 +195,7 @@ describe('manager/regex/index', () => { 'prometheus_image:\\s*"(?.*)"\\s*\\/\\/', 'prometheus_version:\\s*"(?.*)"\\s*\\/\\/', ], - matchStringsStrategy: MatchStringsStrategy.COMBINATION, + matchStringsStrategy: 'combination', datasourceTemplate: 'docker', }; const res = await extractPackageFile( @@ -216,7 +215,7 @@ describe('manager/regex/index', () => { 'prometheus_tag:\\s*"(?.*)"\\s*\\/\\/', 'prometheus_version:\\s*"(?.*)"\\s*\\/\\/', ], - matchStringsStrategy: MatchStringsStrategy.COMBINATION, + matchStringsStrategy: 'combination', datasourceTemplate: 'docker', depNameTemplate: '{{{ registry }}}/{{{ repository }}}', }; @@ -236,7 +235,7 @@ describe('manager/regex/index', () => { '.*_image:\\s*"(?.*)"\\s*\\/\\/', '.*_version:\\s*"(?.*)"\\s*\\/\\/', ], - matchStringsStrategy: MatchStringsStrategy.COMBINATION, + matchStringsStrategy: 'combination', datasourceTemplate: 'docker', }; const res = await extractPackageFile( @@ -249,7 +248,7 @@ describe('manager/regex/index', () => { }); it('extracts with combination strategy and registry url', async () => { const config: CustomExtractConfig = { - matchStringsStrategy: MatchStringsStrategy.COMBINATION, + matchStringsStrategy: 'combination', matchStrings: [ 'CHART_VERSION: (?.*?)\n', 'CHART_REPOSITORY_URL: "(?.*?)"', @@ -268,7 +267,7 @@ describe('manager/regex/index', () => { it('extracts with combination strategy and templates', async () => { const config: CustomExtractConfig = { - matchStringsStrategy: MatchStringsStrategy.COMBINATION, + matchStringsStrategy: 'combination', matchStrings: [ 'CHART_REPOSITORY_URL: "(?.*)\\/(?[a-z]+)\\/"', 'CHART_VERSION: (?.*?)\n', @@ -287,7 +286,7 @@ describe('manager/regex/index', () => { it('extracts with combination strategy and empty file', async () => { const config: CustomExtractConfig = { - matchStringsStrategy: MatchStringsStrategy.COMBINATION, + matchStringsStrategy: 'combination', matchStrings: [ 'CHART_REPOSITORY_URL: "(?.*)\\/(?[a-z]+)\\/"', 'CHART_VERSION: (?.*?)\n', @@ -305,7 +304,7 @@ describe('manager/regex/index', () => { '"group1":\\s*\\{[^}]*}', '"name":\\s*"(?.*)"[^"]*"type":\\s*"(?.*)"[^"]*"value":\\s*"(?.*)"', ], - matchStringsStrategy: MatchStringsStrategy.RECURSIVE, + matchStringsStrategy: 'recursive', }; const res = await extractPackageFile( exampleJsonContent, @@ -321,7 +320,7 @@ describe('manager/regex/index', () => { '"group.{1}":\\s*\\{[^}]*}', '"name":\\s*"(?.*)"[^"]*"type":\\s*"(?.*)"[^"]*"value":\\s*"(?.*)"', ], - matchStringsStrategy: MatchStringsStrategy.RECURSIVE, + matchStringsStrategy: 'recursive', }; const res = await extractPackageFile( exampleJsonContent, @@ -338,7 +337,7 @@ describe('manager/regex/index', () => { '"test":\\s*\\{[^}]*}', '"name":\\s*"(?.*)"[^"]*"type":\\s*"(?.*)"[^"]*"value":\\s*"(?.*)"', ], - matchStringsStrategy: MatchStringsStrategy.RECURSIVE, + matchStringsStrategy: 'recursive', }; const res = await extractPackageFile( exampleJsonContent, @@ -351,7 +350,7 @@ describe('manager/regex/index', () => { it('extracts with recursive strategy and fail because of not sufficient regexes', async () => { const config: CustomExtractConfig = { matchStrings: ['"group.{1}":\\s*\\{[^}]*}'], - matchStringsStrategy: MatchStringsStrategy.RECURSIVE, + matchStringsStrategy: 'recursive', }; const res = await extractPackageFile( exampleJsonContent, @@ -364,7 +363,7 @@ describe('manager/regex/index', () => { it('extracts with recursive strategy and fail because there is no match', async () => { const config: CustomExtractConfig = { matchStrings: ['"trunk.{1}":\\s*\\{[^}]*}'], - matchStringsStrategy: MatchStringsStrategy.RECURSIVE, + matchStringsStrategy: 'recursive', }; const res = await extractPackageFile( exampleJsonContent, @@ -381,7 +380,7 @@ describe('manager/regex/index', () => { '"(?[^"]*)":\\s*\\{[^}]*}', '"name":\\s*"(?.*)"[^"]*"type":\\s*"(?.*)"[^"]*"value":\\s*"(?.*)"', ], - matchStringsStrategy: MatchStringsStrategy.RECURSIVE, + matchStringsStrategy: 'recursive', depNameTemplate: '{{{ first }}}/{{{ second }}}/{{{ depName }}}', }; const res = await extractPackageFile( diff --git a/lib/manager/regex/index.ts b/lib/manager/regex/index.ts index dddcae70cae87d..7557012ad67dc5 100644 --- a/lib/manager/regex/index.ts +++ b/lib/manager/regex/index.ts @@ -1,4 +1,3 @@ -import { MatchStringsStrategy } from '../../config/types'; import type { CustomExtractConfig, PackageDependency, @@ -20,13 +19,13 @@ export function extractPackageFile( let deps: PackageDependency[]; switch (config.matchStringsStrategy) { default: - case MatchStringsStrategy.ANY: + case 'any': deps = handleAny(content, packageFile, config); break; - case MatchStringsStrategy.COMBINATION: + case 'combination': deps = handleCombination(content, packageFile, config); break; - case MatchStringsStrategy.RECURSIVE: + case 'recursive': deps = handleRecursive(content, packageFile, config); break; } From 055288f1ea31f11576b454fd40e84dff3db5e222 Mon Sep 17 00:00:00 2001 From: secustor Date: Sat, 6 Nov 2021 18:09:56 +0100 Subject: [PATCH 4/4] refactor(regex): add type annotation --- lib/manager/regex/strategies.ts | 2 +- lib/manager/regex/utils.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/manager/regex/strategies.ts b/lib/manager/regex/strategies.ts index d187641527aa8c..75a476f0d7311a 100644 --- a/lib/manager/regex/strategies.ts +++ b/lib/manager/regex/strategies.ts @@ -1,5 +1,5 @@ import { regEx } from '../../util/regex'; -import { CustomExtractConfig, PackageDependency } from '../types'; +import type { CustomExtractConfig, PackageDependency } from '../types'; import { createDependency, mergeExtractionTemplate, diff --git a/lib/manager/regex/utils.ts b/lib/manager/regex/utils.ts index 1c7f5ddefd02da..c5059f9882f7ac 100644 --- a/lib/manager/regex/utils.ts +++ b/lib/manager/regex/utils.ts @@ -1,8 +1,8 @@ import { URL } from 'url'; import { logger } from '../../logger'; import * as template from '../../util/template'; -import { CustomExtractConfig, PackageDependency } from '../types'; -import { ExtractionTemplate } from './types'; +import type { CustomExtractConfig, PackageDependency } from '../types'; +import type { ExtractionTemplate } from './types'; export const validMatchFields = [ 'depName',