refactor: refactor static regex out of for loops (#13065)
This commit is contained in:
Родитель
05d7c45e62
Коммит
4f65b57225
|
@ -174,7 +174,7 @@ export async function decryptConfig(
|
|||
}
|
||||
logger.debug(`Decrypted ${eKey}`);
|
||||
if (eKey === 'npmToken') {
|
||||
const token = decryptedStr.replace(regEx(/\n$/), ''); // TODO #12071
|
||||
const token = decryptedStr.replace(regEx(/\n$/), '');
|
||||
add(token);
|
||||
logger.debug(
|
||||
{ decryptedToken: maskToken(token) },
|
||||
|
@ -191,7 +191,7 @@ export async function decryptConfig(
|
|||
} else {
|
||||
logger.debug('Appending _authToken= to end of existing npmrc');
|
||||
decryptedConfig.npmrc = decryptedConfig.npmrc.replace(
|
||||
regEx(/\n?$/), // TODO #12071
|
||||
regEx(/\n?$/),
|
||||
`\n_authToken=${token}\n`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,9 +17,11 @@ import type {
|
|||
import { mergeChildConfig } from './utils';
|
||||
|
||||
const options = getOptions();
|
||||
export function fixShortHours(input: string): string {
|
||||
return input.replace(regEx(/( \d?\d)((a|p)m)/g), '$1:00$2');
|
||||
}
|
||||
|
||||
let optionTypes: Record<string, RenovateOptions['type']>;
|
||||
|
||||
// Returns a migrated config
|
||||
export function migrateConfig(
|
||||
config: RenovateConfig,
|
||||
|
@ -157,12 +159,12 @@ export function migrateConfig(
|
|||
}
|
||||
} else if (is.string(val) && val.includes('{{baseDir}}')) {
|
||||
migratedConfig[key] = val.replace(
|
||||
regEx(/{{baseDir}}/g), // TODO #12071
|
||||
regEx(/{{baseDir}}/g),
|
||||
'{{packageFileDir}}'
|
||||
);
|
||||
} else if (is.string(val) && val.includes('{{depNameShort}}')) {
|
||||
migratedConfig[key] = val.replace(
|
||||
regEx(/{{depNameShort}}/g), // TODO #12071
|
||||
regEx(/{{depNameShort}}/g),
|
||||
'{{depName}}'
|
||||
);
|
||||
} else if (key === 'gitFs') {
|
||||
|
@ -340,6 +342,9 @@ export function migrateConfig(
|
|||
const schedules = is.string(val) ? [val] : [...(val as string[])];
|
||||
// split 'and'
|
||||
const schedulesLength = schedules.length;
|
||||
const afterBeforeRe = regEx(
|
||||
/^(.*?)(after|before) (.*?) and (after|before) (.*?)( |$)(.*)/
|
||||
);
|
||||
for (let i = 0; i < schedulesLength; i += 1) {
|
||||
if (
|
||||
schedules[i].includes(' and ') &&
|
||||
|
@ -348,28 +353,16 @@ export function migrateConfig(
|
|||
) {
|
||||
const parsedSchedule = later.parse.text(
|
||||
// We need to massage short hours first before we can parse it
|
||||
schedules[i].replace(regEx(/( \d?\d)((a|p)m)/g), '$1:00$2') // TODO #12071
|
||||
fixShortHours(schedules[i])
|
||||
).schedules[0];
|
||||
// Only migrate if the after time is greater than before, e.g. "after 10pm and before 5am"
|
||||
if (parsedSchedule?.t_a?.[0] > parsedSchedule?.t_b?.[0]) {
|
||||
const toSplit = schedules[i];
|
||||
schedules[i] = toSplit
|
||||
.replace(
|
||||
regEx(
|
||||
/^(.*?)(after|before) (.*?) and (after|before) (.*?)( |$)(.*)/
|
||||
), // TODO #12071
|
||||
'$1$2 $3 $7'
|
||||
)
|
||||
.replace(afterBeforeRe, '$1$2 $3 $7')
|
||||
.trim();
|
||||
schedules.push(
|
||||
toSplit
|
||||
.replace(
|
||||
regEx(
|
||||
/^(.*?)(after|before) (.*?) and (after|before) (.*?)( |$)(.*)/
|
||||
), // TODO #12071
|
||||
'$1$4 $5 $7'
|
||||
)
|
||||
.trim()
|
||||
toSplit.replace(afterBeforeRe, '$1$4 $5 $7').trim()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -393,10 +386,10 @@ export function migrateConfig(
|
|||
if (
|
||||
regEx(/every (mon|tues|wednes|thurs|fri|satur|sun)day$/).test(
|
||||
schedules[i]
|
||||
) // TODO #12071
|
||||
)
|
||||
) {
|
||||
schedules[i] = schedules[i].replace(
|
||||
regEx(/every ([a-z]*day)$/), // TODO #12071
|
||||
regEx(/every ([a-z]*day)$/),
|
||||
'on $1'
|
||||
);
|
||||
}
|
||||
|
@ -514,7 +507,7 @@ export function migrateConfig(
|
|||
if (is.string(migratedConfig[key])) {
|
||||
for (const [from, to] of Object.entries(migratedTemplates)) {
|
||||
migratedConfig[key] = (migratedConfig[key] as string).replace(
|
||||
regEx(from, 'g'), // TODO #12071
|
||||
regEx(from, 'g'),
|
||||
to
|
||||
);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ const ignoredNodes = [
|
|||
'prBody', // deprecated
|
||||
'minimumConfidence', // undocumented feature flag
|
||||
];
|
||||
|
||||
const tzRe = regEx(/^:timezone\((.+)\)$/);
|
||||
const rulesRe = regEx(/p.*Rules\[\d+\]$/);
|
||||
function isManagerPath(parentPath: string): boolean {
|
||||
return (
|
||||
regEx(/^regexManagers\[[0-9]+]$/).test(parentPath) ||
|
||||
|
@ -253,7 +254,6 @@ export async function validateConfig(
|
|||
}
|
||||
}
|
||||
if (key === 'extends') {
|
||||
const tzRe = regEx(/^:timezone\((.+)\)$/); // TODO #12071
|
||||
for (const subval of val) {
|
||||
if (is.string(subval)) {
|
||||
if (
|
||||
|
@ -488,7 +488,7 @@ export async function validateConfig(
|
|||
}
|
||||
if (
|
||||
(selectors.includes(key) || key === 'matchCurrentVersion') &&
|
||||
!regEx(/p.*Rules\[\d+\]$/).test(parentPath) && // Inside a packageRule // TODO #12071
|
||||
!rulesRe.test(parentPath) && // Inside a packageRule
|
||||
(parentPath || !isPreset) // top level in a preset
|
||||
) {
|
||||
errors.push({
|
||||
|
|
|
@ -109,6 +109,6 @@ export class ArtifactoryDatasource extends Datasource {
|
|||
}
|
||||
|
||||
private static parseReleaseTimestamp(rawText: string): string {
|
||||
return rawText.trim().replace(regEx(/ ?-$/), '') + 'Z'; // TODO #12071
|
||||
return rawText.trim().replace(regEx(/ ?-$/), '') + 'Z';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ async function findDigestFile(
|
|||
for (const asset of smallAssets) {
|
||||
const res = await http.get(asset.browser_download_url);
|
||||
for (const line of res.body.split('\n')) {
|
||||
const [lineDigest, lineFn] = line.split(regEx(/\s+/), 2); // TODO #12071
|
||||
const [lineDigest, lineFn] = line.split(regEx(/\s+/), 2);
|
||||
if (lineDigest === digest) {
|
||||
return {
|
||||
assetName: asset.name,
|
||||
|
|
|
@ -5,6 +5,7 @@ import { XmlDocument } from 'xmldoc';
|
|||
import { logger } from '../../logger';
|
||||
import * as packageCache from '../../util/cache/package';
|
||||
import { regEx } from '../../util/regex';
|
||||
import { ensureTrailingSlash } from '../../util/url';
|
||||
import mavenVersion from '../../versioning/maven';
|
||||
import * as mavenVersioning from '../../versioning/maven';
|
||||
import { compare } from '../../versioning/maven/compare';
|
||||
|
@ -306,7 +307,7 @@ export async function getReleases({
|
|||
registryUrl,
|
||||
}: GetReleasesConfig): Promise<ReleaseResult | null> {
|
||||
const dependency = getDependencyParts(lookupName);
|
||||
const repoUrl = registryUrl.replace(/\/?$/, '/'); // TODO #12071
|
||||
const repoUrl = ensureTrailingSlash(registryUrl);
|
||||
|
||||
logger.debug(`Looking up ${dependency.display} in repository ${repoUrl}`);
|
||||
|
||||
|
|
|
@ -183,7 +183,6 @@ async function getReleasesFromCDN(
|
|||
const line = lines[idx];
|
||||
const [name, ...versions] = line.split('/');
|
||||
if (name === lookupName.replace(regEx(/\/.*$/), '')) {
|
||||
// TODO #12071
|
||||
const releases = versions.map((version) => ({ version }));
|
||||
return { releases };
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ export class PypiDatasource extends Datasource {
|
|||
const srcPrefix = `${packageName}-`;
|
||||
const srcSuffix = '.tar.gz';
|
||||
if (srcText.startsWith(srcPrefix) && srcText.endsWith(srcSuffix)) {
|
||||
return srcText.replace(srcPrefix, '').replace(regEx(/\.tar\.gz$/), ''); // TODO #12071
|
||||
return srcText.replace(srcPrefix, '').replace(regEx(/\.tar\.gz$/), '');
|
||||
}
|
||||
|
||||
// pep-0427 wheel packages
|
||||
|
|
|
@ -123,10 +123,10 @@ export async function getUrls(
|
|||
const sourceUrl = pomXml.valueWithPath('scm.url');
|
||||
if (sourceUrl) {
|
||||
result.sourceUrl = sourceUrl
|
||||
.replace(regEx(/^scm:/), '') // TODO #12071
|
||||
.replace(regEx(/^git:/), '') // TODO #12071
|
||||
.replace(regEx(/^git@github.com:/), 'https://github.com/') // TODO #12071
|
||||
.replace(regEx(/\.git$/), ''); // TODO #12071
|
||||
.replace(regEx(/^scm:/), '')
|
||||
.replace(regEx(/^git:/), '')
|
||||
.replace(regEx(/^git@github.com:/), 'https://github.com/')
|
||||
.replace(regEx(/\.git$/), '');
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { logger } from '../../logger';
|
||||
import { regEx } from '../../util/regex';
|
||||
import { ensureTrailingSlash } from '../../util/url';
|
||||
import * as ivyVersioning from '../../versioning/ivy';
|
||||
import { compare } from '../../versioning/maven/compare';
|
||||
import { downloadHttpProtocol } from '../maven/util';
|
||||
|
@ -18,8 +19,6 @@ export const defaultRegistryUrls = [SBT_PLUGINS_REPO];
|
|||
export const defaultVersioning = ivyVersioning.id;
|
||||
export const registryStrategy = 'hunt';
|
||||
|
||||
const ensureTrailingSlash = (str: string): string => str.replace(/\/?$/, '/'); // TODO #12071
|
||||
|
||||
async function resolvePluginReleases(
|
||||
rootUrl: string,
|
||||
artifact: string,
|
||||
|
|
|
@ -46,11 +46,9 @@ export default function extractPackageFile(
|
|||
// find role and collection block
|
||||
lines.forEach((line, index) => {
|
||||
if (regEx(/^collections:/).exec(line)) {
|
||||
// TODO #12071
|
||||
positions.collections = index;
|
||||
}
|
||||
if (regEx(/^roles:/).exec(line)) {
|
||||
// TODO #12071
|
||||
positions.roles = index;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ export function extractPackageFile(content: string): PackageFile | null {
|
|||
const line = lines[lineIdx];
|
||||
const pluginsSection = regEx(
|
||||
/^(?<pluginsIndent>\s*)(-?\s*)plugins:/
|
||||
).exec(line); // TODO #12071
|
||||
).exec(line);
|
||||
if (pluginsSection) {
|
||||
logger.trace(`Matched plugins on line ${lineNumber}`);
|
||||
isPluginsSection = true;
|
||||
|
@ -25,10 +25,10 @@ export function extractPackageFile(content: string): PackageFile | null {
|
|||
logger.debug(`serviceImageLine: "${line}"`);
|
||||
const { currentIndent } = regEx(/^(?<currentIndent>\s*)/).exec(
|
||||
line
|
||||
).groups; // TODO #12071
|
||||
).groups;
|
||||
const depLineMatch = regEx(
|
||||
/^\s+(?:-\s+)?(?<depName>[^#]+)#(?<currentValue>[^:]+)/
|
||||
).exec(line); // TODO #12071
|
||||
).exec(line);
|
||||
if (currentIndent.length <= pluginsIndent.length) {
|
||||
isPluginsSection = false;
|
||||
pluginsIndent = '';
|
||||
|
|
|
@ -5,6 +5,10 @@ import { regEx } from '../../util/regex';
|
|||
import type { PackageDependency, PackageFile } from '../types';
|
||||
import { extractLockFileEntries } from './locked-version';
|
||||
|
||||
function formatContent(input: string): string {
|
||||
return input.replace(regEx(/^ {2}/), '') + '\n'; //remove leading witespace and add a new line at the end
|
||||
}
|
||||
|
||||
export async function extractPackageFile(
|
||||
content: string,
|
||||
fileName?: string
|
||||
|
@ -22,7 +26,6 @@ export async function extractPackageFile(
|
|||
sourceMatch =
|
||||
sourceMatch ||
|
||||
regEx(`^source ${delimiter}([^${delimiter}]+)${delimiter}\\s*$`).exec(
|
||||
// TODO #12071
|
||||
line
|
||||
);
|
||||
}
|
||||
|
@ -33,14 +36,14 @@ export async function extractPackageFile(
|
|||
for (const delimiter of delimiters) {
|
||||
rubyMatch =
|
||||
rubyMatch ||
|
||||
regEx(`^ruby ${delimiter}([^${delimiter}]+)${delimiter}`).exec(line); // TODO #12071
|
||||
regEx(`^ruby ${delimiter}([^${delimiter}]+)${delimiter}`).exec(line);
|
||||
}
|
||||
if (rubyMatch) {
|
||||
res.constraints = { ruby: rubyMatch[1] };
|
||||
}
|
||||
const gemMatchRegex = regEx(
|
||||
`^\\s*gem\\s+(['"])(?<depName>[^'"]+)(['"])(\\s*,\\s*(?<currentValue>(['"])[^'"]+['"](\\s*,\\s*['"][^'"]+['"])?))?`
|
||||
); // TODO #12071
|
||||
);
|
||||
const gemMatch = gemMatchRegex.exec(line);
|
||||
if (gemMatch) {
|
||||
const dep: PackageDependency = {
|
||||
|
@ -49,19 +52,19 @@ export async function extractPackageFile(
|
|||
};
|
||||
if (gemMatch.groups.currentValue) {
|
||||
const currentValue = gemMatch.groups.currentValue;
|
||||
dep.currentValue = regEx(/\s*,\s*/).test(currentValue) // TODO #12071
|
||||
dep.currentValue = regEx(/\s*,\s*/).test(currentValue)
|
||||
? currentValue
|
||||
: currentValue.slice(1, -1);
|
||||
}
|
||||
dep.datasource = RubyGemsDatasource.id;
|
||||
res.deps.push(dep);
|
||||
}
|
||||
const groupMatch = regEx(/^group\s+(.*?)\s+do/).exec(line); // TODO #12071
|
||||
const groupMatch = regEx(/^group\s+(.*?)\s+do/).exec(line);
|
||||
if (groupMatch) {
|
||||
const depTypes = groupMatch[1]
|
||||
.split(',')
|
||||
.map((group) => group.trim())
|
||||
.map((group) => group.replace(regEx(/^:/), '')); // TODO #12071
|
||||
.map((group) => group.replace(regEx(/^:/), ''));
|
||||
const groupLineNumber = lineNumber;
|
||||
let groupContent = '';
|
||||
let groupLine = '';
|
||||
|
@ -69,7 +72,7 @@ export async function extractPackageFile(
|
|||
lineNumber += 1;
|
||||
groupLine = lines[lineNumber];
|
||||
if (groupLine !== 'end') {
|
||||
groupContent += (groupLine || '').replace(regEx(/^ {2}/), '') + '\n'; // TODO #12071
|
||||
groupContent += formatContent(groupLine || '');
|
||||
}
|
||||
}
|
||||
const groupRes = await extractPackageFile(groupContent);
|
||||
|
@ -88,7 +91,7 @@ export async function extractPackageFile(
|
|||
}
|
||||
for (const delimiter of delimiters) {
|
||||
const sourceBlockMatch = regEx(
|
||||
`^source\\s+${delimiter}(.*?)${delimiter}\\s+do` // TODO #12071
|
||||
`^source\\s+${delimiter}(.*?)${delimiter}\\s+do`
|
||||
).exec(line);
|
||||
if (sourceBlockMatch) {
|
||||
const repositoryUrl = sourceBlockMatch[1];
|
||||
|
@ -104,7 +107,7 @@ export async function extractPackageFile(
|
|||
sourceLine = 'end';
|
||||
}
|
||||
if (sourceLine !== 'end') {
|
||||
sourceContent += sourceLine.replace(regEx(/^ {2}/), '') + '\n'; // TODO #12071
|
||||
sourceContent += formatContent(sourceLine);
|
||||
}
|
||||
}
|
||||
const sourceRes = await extractPackageFile(sourceContent);
|
||||
|
@ -122,7 +125,7 @@ export async function extractPackageFile(
|
|||
}
|
||||
}
|
||||
}
|
||||
const platformsMatch = regEx(/^platforms\s+(.*?)\s+do/).test(line); // TODO #12071
|
||||
const platformsMatch = regEx(/^platforms\s+(.*?)\s+do/).test(line);
|
||||
if (platformsMatch) {
|
||||
const platformsLineNumber = lineNumber;
|
||||
let platformsContent = '';
|
||||
|
@ -131,7 +134,7 @@ export async function extractPackageFile(
|
|||
lineNumber += 1;
|
||||
platformsLine = lines[lineNumber];
|
||||
if (platformsLine !== 'end') {
|
||||
platformsContent += platformsLine.replace(regEx(/^ {2}/), '') + '\n'; // TODO #12071
|
||||
platformsContent += formatContent(platformsLine);
|
||||
}
|
||||
}
|
||||
const platformsRes = await extractPackageFile(platformsContent);
|
||||
|
@ -147,7 +150,7 @@ export async function extractPackageFile(
|
|||
);
|
||||
}
|
||||
}
|
||||
const ifMatch = regEx(/^if\s+(.*?)/).test(line); // TODO #12071
|
||||
const ifMatch = regEx(/^if\s+(.*?)/).test(line);
|
||||
if (ifMatch) {
|
||||
const ifLineNumber = lineNumber;
|
||||
let ifContent = '';
|
||||
|
@ -156,7 +159,7 @@ export async function extractPackageFile(
|
|||
lineNumber += 1;
|
||||
ifLine = lines[lineNumber];
|
||||
if (ifLine !== 'end') {
|
||||
ifContent += ifLine.replace(regEx(/^ {2}/), '') + '\n'; // TODO #12071
|
||||
ifContent += formatContent(ifLine);
|
||||
}
|
||||
}
|
||||
const ifRes = await extractPackageFile(ifContent);
|
||||
|
|
|
@ -11,7 +11,7 @@ export function extractPackageFile(content: string): PackageFile | null {
|
|||
const lines = content.split('\n');
|
||||
for (let lineNumber = 0; lineNumber < lines.length; lineNumber += 1) {
|
||||
const line = lines[lineNumber];
|
||||
const orbs = regEx(/^\s*orbs:\s*$/).exec(line); // TODO #12071
|
||||
const orbs = regEx(/^\s*orbs:\s*$/).exec(line);
|
||||
if (orbs) {
|
||||
logger.trace(`Matched orbs on line ${lineNumber}`);
|
||||
let foundOrbOrNoop: boolean;
|
||||
|
@ -19,14 +19,14 @@ export function extractPackageFile(content: string): PackageFile | null {
|
|||
foundOrbOrNoop = false;
|
||||
const orbLine = lines[lineNumber + 1];
|
||||
logger.trace(`orbLine: "${orbLine}"`);
|
||||
const yamlNoop = regEx(/^\s*(#|$)/).exec(orbLine); // TODO #12071
|
||||
const yamlNoop = regEx(/^\s*(#|$)/).exec(orbLine);
|
||||
if (yamlNoop) {
|
||||
logger.debug('orbNoop');
|
||||
foundOrbOrNoop = true;
|
||||
lineNumber += 1;
|
||||
continue;
|
||||
}
|
||||
const orbMatch = regEx(/^\s+([^:]+):\s(.+)$/).exec(orbLine); // TODO #12071
|
||||
const orbMatch = regEx(/^\s+([^:]+):\s(.+)$/).exec(orbLine);
|
||||
if (orbMatch) {
|
||||
logger.trace('orbMatch');
|
||||
foundOrbOrNoop = true;
|
||||
|
@ -47,7 +47,7 @@ export function extractPackageFile(content: string): PackageFile | null {
|
|||
}
|
||||
} while (foundOrbOrNoop);
|
||||
}
|
||||
const match = regEx(/^\s*-? image:\s*'?"?([^\s'"]+)'?"?\s*$/).exec(line); // TODO #12071
|
||||
const match = regEx(/^\s*-? image:\s*'?"?([^\s'"]+)'?"?\s*$/).exec(line);
|
||||
if (match) {
|
||||
const currentFrom = match[1];
|
||||
const dep = getDep(currentFrom);
|
||||
|
|
|
@ -26,7 +26,7 @@ export function parseLine(line: string): ParsedLine {
|
|||
return result;
|
||||
}
|
||||
for (const regex of Object.values(regexMappings)) {
|
||||
const match = regex.exec(line.replace(regEx(/#.*$/), '')); // TODO #12071
|
||||
const match = regex.exec(line.replace(regEx(/#.*$/), ''));
|
||||
if (match?.groups) {
|
||||
result = { ...result, ...match.groups };
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ export async function extractPackageFile(
|
|||
}: ParsedLine = parsedLine;
|
||||
|
||||
if (source) {
|
||||
registryUrls.push(source.replace(regEx(/\/*$/), '')); // TODO #12071
|
||||
registryUrls.push(source.replace(regEx(/\/*$/), ''));
|
||||
}
|
||||
|
||||
if (depName) {
|
||||
|
|
|
@ -22,7 +22,7 @@ import type {
|
|||
* See https://github.com/composer/composer/blob/750a92b4b7aecda0e5b2f9b963f1cb1421900675/src/Composer/Repository/ComposerRepository.php#L815
|
||||
*/
|
||||
function transformRegUrl(url: string): string {
|
||||
return url.replace(regEx(/(\/packages\.json)$/), ''); // TODO #12071
|
||||
return url.replace(regEx(/(\/packages\.json)$/), '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,7 +159,7 @@ export async function extractPackageFile(
|
|||
(item) => item.name === dep.depName
|
||||
);
|
||||
if (lockedDep && semverComposer.isVersion(lockedDep.version)) {
|
||||
dep.lockedVersion = lockedDep.version.replace(regEx(/^v/i), ''); // TODO #12071
|
||||
dep.lockedVersion = lockedDep.version.replace(regEx(/^v/i), '');
|
||||
}
|
||||
}
|
||||
deps.push(dep);
|
||||
|
|
|
@ -9,7 +9,7 @@ export function extractPackageFile(content: string): PackageFile | null {
|
|||
const lines = content.split('\n');
|
||||
for (let lineNumber = 0; lineNumber < lines.length; lineNumber += 1) {
|
||||
const line = lines[lineNumber];
|
||||
const match = regEx(/^\s* image:\s*'?"?([^\s'"]+)'?"?\s*$/).exec(line); // TODO #12071
|
||||
const match = regEx(/^\s* image:\s*'?"?([^\s'"]+)'?"?\s*$/).exec(line);
|
||||
if (match) {
|
||||
const currentFrom = match[1];
|
||||
const dep = getDep(currentFrom);
|
||||
|
|
|
@ -76,7 +76,7 @@ async function getModules(
|
|||
.filter((s) => !!s);
|
||||
|
||||
for (const line of modules) {
|
||||
const [, name, path] = line.split(regEx(/submodule\.(.+?)\.path\s(.+)/)); // TODO #12071
|
||||
const [, name, path] = line.split(regEx(/submodule\.(.+?)\.path\s(.+)/));
|
||||
res.push({ name, path });
|
||||
}
|
||||
} catch (err) /* istanbul ignore next */ {
|
||||
|
@ -105,8 +105,8 @@ export default async function extractPackageFile(
|
|||
try {
|
||||
const [currentDigest] = (await git.subModule(['status', path]))
|
||||
.trim()
|
||||
.replace(regEx(/^[-+]/), '') // TODO #12071
|
||||
.split(regEx(/\s/)); // TODO #12071
|
||||
.replace(regEx(/^[-+]/), '')
|
||||
.split(regEx(/\s/));
|
||||
const subModuleUrl = await getUrl(git, gitModulesPath, name);
|
||||
// hostRules only understands HTTP URLs
|
||||
// Find HTTP URL, then apply token
|
||||
|
|
|
@ -48,7 +48,7 @@ export function extractPackageFile(
|
|||
if (config.endpoint) {
|
||||
dep.registryUrls = [
|
||||
config.endpoint.replace(regEx(/\/api\/v4\/?/), ''),
|
||||
]; // TODO #12071
|
||||
];
|
||||
}
|
||||
deps.push(dep);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ export function extractPackageFile(content: string): PackageFile | null {
|
|||
}
|
||||
}
|
||||
}
|
||||
const services = regEx(/^\s*services:\s*$/).test(line); // TODO #12071
|
||||
const services = regEx(/^\s*services:\s*$/).test(line);
|
||||
if (services) {
|
||||
logger.trace(`Matched services on line ${lineNumber}`);
|
||||
let foundImage: boolean;
|
||||
|
|
|
@ -51,12 +51,12 @@ export function extractPackageFile(content: string): PackageFile | null {
|
|||
}
|
||||
const replaceMatch = regEx(
|
||||
/^replace\s+[^\s]+[\s]+[=][>]\s+([^\s]+)\s+([^\s]+)/
|
||||
).exec(line); // TODO #12071
|
||||
).exec(line);
|
||||
if (replaceMatch) {
|
||||
const dep = getDep(lineNumber, replaceMatch, 'replace');
|
||||
deps.push(dep);
|
||||
}
|
||||
const requireMatch = regEx(/^require\s+([^\s]+)\s+([^\s]+)/).exec(line); // TODO #12071
|
||||
const requireMatch = regEx(/^require\s+([^\s]+)\s+([^\s]+)/).exec(line);
|
||||
if (requireMatch && !line.endsWith('// indirect')) {
|
||||
logger.trace({ lineNumber }, `require line: "${line}"`);
|
||||
const dep = getDep(lineNumber, requireMatch, 'require');
|
||||
|
@ -67,7 +67,7 @@ export function extractPackageFile(content: string): PackageFile | null {
|
|||
do {
|
||||
lineNumber += 1;
|
||||
line = lines[lineNumber];
|
||||
const multiMatch = regEx(/^\s+([^\s]+)\s+([^\s]+)/).exec(line); // TODO #12071
|
||||
const multiMatch = regEx(/^\s+([^\s]+)\s+([^\s]+)/).exec(line);
|
||||
logger.trace(`reqLine: "${line}"`);
|
||||
if (multiMatch && !line.endsWith('// indirect')) {
|
||||
logger.trace({ lineNumber }, `require line: "${line}"`);
|
||||
|
|
|
@ -145,12 +145,11 @@ export async function extractDependenciesFromUpdatesReport(
|
|||
if (depName.endsWith('_%%')) {
|
||||
return {
|
||||
...dep,
|
||||
depName: depName.replace(regEx(/_%%/), ''), // TODO #12071
|
||||
depName: depName.replace(regEx(/_%%/), ''),
|
||||
datasource: datasourceSbtPackage.id,
|
||||
};
|
||||
}
|
||||
if (regEx(/^%.*%$/).test(currentValue)) {
|
||||
// TODO #12071
|
||||
return { ...dep, skipReason: 'version-placeholder' };
|
||||
}
|
||||
return dep;
|
||||
|
|
|
@ -15,7 +15,7 @@ export function extractPackageFile(content: string): PackageFile | null {
|
|||
}
|
||||
|
||||
for (const line of content.split('\n')) {
|
||||
const match = regEx(/^\s*-?\s*image:\s*'?"?([^\s'"]+)'?"?\s*$/).exec(line); // TODO #12071
|
||||
const match = regEx(/^\s*-?\s*image:\s*'?"?([^\s'"]+)'?"?\s*$/).exec(line);
|
||||
if (match) {
|
||||
const currentFrom = match[1];
|
||||
const dep = getDep(currentFrom);
|
||||
|
|
|
@ -15,7 +15,7 @@ export function extractPackageFile(content: string): PackageFile | null {
|
|||
.split(',')
|
||||
.map((dep) => dep.trim())
|
||||
.filter((dep) => dep.length)
|
||||
.map((dep) => dep.split(regEx(/:(.*)/))) // TODO #12071
|
||||
.map((dep) => dep.split(regEx(/:(.*)/)))
|
||||
.map((arr) => {
|
||||
const [depName, currentValue] = arr;
|
||||
// istanbul ignore if
|
||||
|
|
|
@ -108,7 +108,9 @@ export async function extractPackageFile(
|
|||
} else {
|
||||
npmrc = config.npmrc || '';
|
||||
if (npmrc.length) {
|
||||
npmrc = npmrc.replace(/\n?$/, '\n'); // TODO #12875 add \n to front when used with re2
|
||||
if (!npmrc.endsWith('\n')) {
|
||||
npmrc += '\n';
|
||||
}
|
||||
}
|
||||
if (repoNpmrc?.includes('package-lock')) {
|
||||
logger.debug('Stripping package-lock setting from .npmrc');
|
||||
|
|
|
@ -25,6 +25,7 @@ import {
|
|||
import { branchExists, getFile, getRepoStatus } from '../../../util/git';
|
||||
import * as hostRules from '../../../util/host-rules';
|
||||
import { regEx } from '../../../util/regex';
|
||||
import { ensureTrailingSlash } from '../../../util/url';
|
||||
import type { PackageFile, PostUpdateConfig, Upgrade } from '../../types';
|
||||
import { getZeroInstallPaths } from '../extract/yarn';
|
||||
import * as lerna from './lerna';
|
||||
|
@ -376,10 +377,9 @@ async function updateYarnOffline(
|
|||
.split('\n')
|
||||
.find((line) => line.startsWith('yarn-offline-mirror '));
|
||||
if (mirrorLine) {
|
||||
const mirrorPath = mirrorLine
|
||||
.split(' ')[1]
|
||||
.replace(regEx(/"/g), '')
|
||||
.replace(regEx(/\/?$/), '/');
|
||||
const mirrorPath = ensureTrailingSlash(
|
||||
mirrorLine.split(' ')[1].replace(regEx(/"/g), '')
|
||||
);
|
||||
resolvedPaths.push(upath.join(lockFileDir, mirrorPath));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ export function processHostRules(): HostRulesResult {
|
|||
for (const hostRule of npmHostRules) {
|
||||
if (hostRule.resolvedHost) {
|
||||
let uri = hostRule.matchHost;
|
||||
uri = validateUrl(uri) ? uri.replace(regEx(/^https?:/), '') : `//${uri}/`; // TODO #12071
|
||||
uri = validateUrl(uri) ? uri.replace(regEx(/^https?:/), '') : `//${uri}/`;
|
||||
if (hostRule.token) {
|
||||
const key = hostRule.authType === 'Basic' ? '_auth' : '_authToken';
|
||||
additionalNpmrcContent.push(`${uri}:${key}=${hostRule.token}`);
|
||||
|
|
|
@ -69,7 +69,7 @@ export async function getConfiguredRegistries(
|
|||
logger.debug(`clearing registry URLs`);
|
||||
registries.length = 0;
|
||||
} else if (child.name === 'add') {
|
||||
const isHttpUrl = regEx(/^https?:\/\//i).test(child.attr.value); // TODO #12071
|
||||
const isHttpUrl = regEx(/^https?:\/\//i).test(child.attr.value);
|
||||
if (isHttpUrl) {
|
||||
let registryUrl = child.attr.value;
|
||||
if (child.attr.protocolVersion) {
|
||||
|
|
|
@ -90,18 +90,18 @@ export function extractPackageFile(
|
|||
if (registryUrls.length > 0) {
|
||||
res.registryUrls = registryUrls.map((url) => {
|
||||
// handle the optional quotes in eg. `--extra-index-url "https://foo.bar"`
|
||||
const cleaned = url.replace(regEx(/^"/), '').replace(regEx(/"$/), ''); // TODO #12071
|
||||
const cleaned = url.replace(regEx(/^"/), '').replace(regEx(/"$/), '');
|
||||
if (!GlobalConfig.get('exposeAllEnv')) {
|
||||
return cleaned;
|
||||
}
|
||||
// interpolate any environment variables
|
||||
return cleaned.replace(
|
||||
regEx(/(\$[A-Za-z\d_]+)|(\${[A-Za-z\d_]+})/g), // TODO #12071
|
||||
regEx(/(\$[A-Za-z\d_]+)|(\${[A-Za-z\d_]+})/g),
|
||||
(match) => {
|
||||
const envvar = match
|
||||
.substring(1)
|
||||
.replace(regEx(/^{/), '')
|
||||
.replace(regEx(/}$/), ''); // TODO #12071
|
||||
.replace(regEx(/}$/), '');
|
||||
const sub = process.env[envvar];
|
||||
return sub || match;
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ function parseDepExpr(
|
|||
const tokens = expr
|
||||
.trim()
|
||||
.split(regEx(/("[^"]*")/g))
|
||||
.map((x) => (regEx(/"[^"]*"/).test(x) ? x : x.replace(regEx(/[()]+/g), ''))) // TODO #12071
|
||||
.map((x) => (regEx(/"[^"]*"/).test(x) ? x : x.replace(regEx(/[()]+/g), '')))
|
||||
.join('')
|
||||
.split(regEx(/\s*(%%?)\s*|\s*classifier\s*/));
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@ import pep440 from '../../versioning/pep440';
|
|||
import type { PackageDependency, PackageFile, Result } from '../types';
|
||||
|
||||
function getSectionName(str: string): string {
|
||||
const [, sectionName] = regEx(/^\[\s*([^\s]+)\s*]\s*$/).exec(str) || []; // TODO #12071
|
||||
const [, sectionName] = regEx(/^\[\s*([^\s]+)\s*]\s*$/).exec(str) || [];
|
||||
return sectionName;
|
||||
}
|
||||
|
||||
function getSectionRecord(str: string): string {
|
||||
const [, sectionRecord] = regEx(/^([^\s]+)\s+=/).exec(str) || []; // TODO #12071
|
||||
const [, sectionRecord] = regEx(/^([^\s]+)\s+=/).exec(str) || [];
|
||||
return sectionRecord;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ export function extractPackageFile(
|
|||
const deps: PackageDependency[] = [];
|
||||
content
|
||||
.split('\n')
|
||||
.map((line) => line.replace(regEx(/[;#].*$/), '').trimRight()) // TODO #12071
|
||||
.map((line) => line.replace(regEx(/[;#].*$/), '').trimRight())
|
||||
.forEach((rawLine) => {
|
||||
let line = rawLine;
|
||||
const newSectionName = getSectionName(line);
|
||||
|
@ -75,7 +75,7 @@ export function extractPackageFile(
|
|||
} else {
|
||||
if (newSectionRecord) {
|
||||
sectionRecord = newSectionRecord;
|
||||
line = rawLine.replace(regEx(/^[^=]*=\s*/), '\t'); // TODO #12071
|
||||
line = rawLine.replace(regEx(/^[^=]*=\s*/), '\t');
|
||||
}
|
||||
const dep = parseDep(line, sectionName, sectionRecord);
|
||||
if (dep) {
|
||||
|
|
|
@ -32,7 +32,7 @@ export class TerraformProviderHash {
|
|||
|
||||
// add double space, the filename and a new line char
|
||||
rootHash.update(' ');
|
||||
const fileName = file.replace(regEx(/^.*[\\/]/), ''); // TODO #12071
|
||||
const fileName = file.replace(regEx(/^.*[\\/]/), '');
|
||||
rootHash.update(fileName);
|
||||
rootHash.update('\n');
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ export function extractTerraformProvider(
|
|||
// istanbul ignore else
|
||||
if (is.string(line)) {
|
||||
// `{` will be counted wit +1 and `}` with -1. Therefore if we reach braceCounter == 0. We have found the end of the terraform block
|
||||
const openBrackets = (line.match(regEx(/\{/g)) || []).length; // TODO #12071
|
||||
const closedBrackets = (line.match(regEx(/\}/g)) || []).length; // TODO #12071
|
||||
const openBrackets = (line.match(regEx(/\{/g)) || []).length;
|
||||
const closedBrackets = (line.match(regEx(/\}/g)) || []).length;
|
||||
braceCounter = braceCounter + openBrackets - closedBrackets;
|
||||
|
||||
// only update fields inside the root block
|
||||
|
|
|
@ -1244,7 +1244,7 @@ export async function addReviewers(
|
|||
const userReviewers = reviewers.filter((e) => !e.startsWith('team:'));
|
||||
const teamReviewers = reviewers
|
||||
.filter((e) => e.startsWith('team:'))
|
||||
.map((e) => e.replace(regEx(/^team:/), '')); // TODO #12071
|
||||
.map((e) => e.replace(regEx(/^team:/), ''));
|
||||
try {
|
||||
await githubApi.postJson(
|
||||
`repos/${
|
||||
|
|
|
@ -108,7 +108,7 @@ function checkForPlatformFailure(err: Error): void {
|
|||
}
|
||||
|
||||
function localName(branchName: string): string {
|
||||
return branchName.replace(regEx(/^origin\//), ''); // TODO #12071
|
||||
return branchName.replace(regEx(/^origin\//), '');
|
||||
}
|
||||
|
||||
async function isDirectory(dir: string): Promise<boolean> {
|
||||
|
@ -196,7 +196,7 @@ async function fetchBranchCommits(): Promise<void> {
|
|||
(await git.raw(opts))
|
||||
.split('\n')
|
||||
.filter(Boolean)
|
||||
.map((line) => line.trim().split(regEx(/\s+/))) // TODO #12071
|
||||
.map((line) => line.trim().split(regEx(/\s+/)))
|
||||
.forEach(([sha, ref]) => {
|
||||
config.branchCommits[ref.replace('refs/heads/', '')] = sha;
|
||||
});
|
||||
|
@ -488,7 +488,7 @@ export async function getFileList(): Promise<string[]> {
|
|||
.split('\n')
|
||||
.filter(Boolean)
|
||||
.filter((line) => line.startsWith('100'))
|
||||
.map((line) => line.split(regEx(/\t/)).pop()) // TODO #12071
|
||||
.map((line) => line.split(regEx(/\t/)).pop())
|
||||
.filter((file: string) =>
|
||||
submodules.every((submodule: string) => !file.startsWith(submodule))
|
||||
);
|
||||
|
|
|
@ -8,7 +8,7 @@ export function getHttpUrl(url: string, token?: string): string {
|
|||
|
||||
parsedUrl.token = token;
|
||||
|
||||
const protocol = regEx(/^https?$/).exec(parsedUrl.protocol) // TODO #12071
|
||||
const protocol = regEx(/^https?$/).exec(parsedUrl.protocol)
|
||||
? parsedUrl.protocol
|
||||
: 'https';
|
||||
return parsedUrl.toString(protocol);
|
||||
|
|
|
@ -6,18 +6,18 @@ import { regEx } from './regex';
|
|||
export function sanitizeMarkdown(markdown: string): string {
|
||||
let res = markdown;
|
||||
// Put a zero width space after every # followed by a digit
|
||||
res = res.replace(regEx(/#(\d)/gi), '#​$1'); // TODO #12071
|
||||
res = res.replace(regEx(/#(\d)/gi), '#​$1');
|
||||
// Put a zero width space after every @ symbol to prevent unintended hyperlinking
|
||||
res = res.replace(regEx(/@/g), '@​'); // TODO #12071
|
||||
res = res.replace(regEx(/(`\[?@)​/g), '$1'); // TODO #12071
|
||||
res = res.replace(regEx(/([a-z]@)​/gi), '$1'); // TODO #12071
|
||||
res = res.replace(regEx(/\/compare\/@​/g), '/compare/@'); // TODO #12071
|
||||
res = res.replace(regEx(/(\(https:\/\/[^)]*?)\.\.\.@​/g), '$1...@'); // TODO #12071
|
||||
res = res.replace(regEx(/([\s(])#(\d+)([)\s]?)/g), '$1#​$2$3'); // TODO #12071
|
||||
res = res.replace(regEx(/@/g), '@​');
|
||||
res = res.replace(regEx(/(`\[?@)​/g), '$1');
|
||||
res = res.replace(regEx(/([a-z]@)​/gi), '$1');
|
||||
res = res.replace(regEx(/\/compare\/@​/g), '/compare/@');
|
||||
res = res.replace(regEx(/(\(https:\/\/[^)]*?)\.\.\.@​/g), '$1...@');
|
||||
res = res.replace(regEx(/([\s(])#(\d+)([)\s]?)/g), '$1#​$2$3');
|
||||
// convert escaped backticks back to `
|
||||
const backTickRe = regEx(/`([^/]*?)`/g); // TODO #12071
|
||||
const backTickRe = regEx(/`([^/]*?)`/g);
|
||||
res = res.replace(backTickRe, '`$1`');
|
||||
res = res.replace(regEx(/`#​(\d+)`/g), '`#$1`'); // TODO #12071
|
||||
res = res.replace(regEx(/`#​(\d+)`/g), '`#$1`');
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ function matchesRule(
|
|||
packagePattern === '^*$' || packagePattern === '*'
|
||||
? '.*'
|
||||
: packagePattern
|
||||
); // TODO #12071
|
||||
);
|
||||
if (packageRegex.test(depName)) {
|
||||
logger.trace(`${depName} matches against ${String(packageRegex)}`);
|
||||
isMatch = true;
|
||||
|
@ -173,7 +173,7 @@ function matchesRule(
|
|||
for (const pattern of excludePackagePatterns) {
|
||||
const packageRegex = regEx(
|
||||
pattern === '^*$' || pattern === '*' ? '.*' : pattern
|
||||
); // TODO #12071
|
||||
);
|
||||
if (packageRegex.test(depName)) {
|
||||
logger.trace(`${depName} matches against ${String(packageRegex)}`);
|
||||
isMatch = true;
|
||||
|
|
|
@ -46,7 +46,7 @@ export function regEx(
|
|||
}
|
||||
|
||||
export function escapeRegExp(input: string): string {
|
||||
return input.replace(regEx(/[.*+\-?^${}()|[\]\\]/g), '\\$&'); // $& means the whole matched string // TODO #12071
|
||||
return input.replace(regEx(/[.*+\-?^${}()|[\]\\]/g), '\\$&'); // $& means the whole matched string
|
||||
}
|
||||
|
||||
const configValStart = regEx(/^!?\//);
|
||||
|
|
|
@ -49,14 +49,14 @@ function getNewValue({
|
|||
replaceValue = `$<prefix>${npm.getMinor(newVersion)}$<suffix>`;
|
||||
}
|
||||
return currentValue.replace(
|
||||
regEx(`(?<prefix>~>\\s*0\\.)\\d+(?<suffix>.*)$`), // TODO #12071
|
||||
regEx(`(?<prefix>~>\\s*0\\.)\\d+(?<suffix>.*)$`),
|
||||
replaceValue
|
||||
);
|
||||
}
|
||||
// handle special ~> 1.2 case
|
||||
if (regEx(/(~>\s*)\d+\.\d+$/).test(currentValue)) {
|
||||
return currentValue.replace(
|
||||
regEx(`(?<prefix>~>\\s*)\\d+\\.\\d+$`), // TODO #12071
|
||||
regEx(`(?<prefix>~>\\s*)\\d+\\.\\d+$`),
|
||||
`$<prefix>${npm.getMajor(newVersion)}.0`
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ export const supportedRangeStrategies = ['bump', 'extend', 'pin', 'replace'];
|
|||
|
||||
function hex2npm(input: string): string {
|
||||
return input
|
||||
.replace(regEx(/~>\s*(\d+\.\d+)$/), '^$1') // TODO #12071
|
||||
.replace(regEx(/~>\s*(\d+\.\d+\.\d+)/), '~$1') // TODO #12071
|
||||
.replace(regEx(/==|and/), '') // TODO #12071
|
||||
.replace(regEx(/~>\s*(\d+\.\d+)$/), '^$1')
|
||||
.replace(regEx(/~>\s*(\d+\.\d+\.\d+)/), '~$1')
|
||||
.replace(regEx(/==|and/), '')
|
||||
.replace('or', '||')
|
||||
.replace(regEx(/!=\s*(\d+\.\d+(\.\d+.*)?)/), '>$1 <$1') // TODO #12071
|
||||
.replace(regEx(/!=\s*(\d+\.\d+(\.\d+.*)?)/), '>$1 <$1')
|
||||
.trim();
|
||||
}
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ export function isLessThanRange(input: string, range: string): boolean {
|
|||
.split(',')
|
||||
.map((x) =>
|
||||
x
|
||||
.replace(regEx(/\s*/g), '') // TODO #12071
|
||||
.split(regEx(/(~=|==|!=|<=|>=|<|>|===)/)) // TODO #12071
|
||||
.replace(regEx(/\s*/g), '')
|
||||
.split(regEx(/(~=|==|!=|<=|>=|<|>|===)/))
|
||||
.slice(1)
|
||||
)
|
||||
.map(([op, version]) => {
|
||||
|
|
|
@ -105,7 +105,7 @@ export function rez2pep440(input: string): string {
|
|||
export function pep4402rezInclusiveBound(input: string): string {
|
||||
return input
|
||||
.split(',')
|
||||
.map((v) => v.trim().replace(regEx(/[<>=]/g), '')) // TODO #12071
|
||||
.map((v) => v.trim().replace(regEx(/[<>=]/g), ''))
|
||||
.join('..');
|
||||
}
|
||||
|
||||
|
|
|
@ -127,16 +127,15 @@ const getNewValue = ({
|
|||
const delimiter = currentValue[0];
|
||||
return newValue
|
||||
.split(',')
|
||||
.map(
|
||||
(element) =>
|
||||
element.replace(
|
||||
regEx(`^(?<whitespace>\\s*)`),
|
||||
`$<whitespace>${delimiter}`
|
||||
) // TODO #12071
|
||||
.map((element) =>
|
||||
element.replace(
|
||||
regEx(`^(?<whitespace>\\s*)`),
|
||||
`$<whitespace>${delimiter}`
|
||||
)
|
||||
)
|
||||
.map(
|
||||
(element) =>
|
||||
element.replace(/(?<whitespace>\s*)$/, `${delimiter}$<whitespace>`) // TODO #12071 #12875 adds ' at front when re2 is used
|
||||
element.replace(/(?<whitespace>\s*)$/, `${delimiter}$<whitespace>`) // TODO #12875 adds ' at front when re2 is used
|
||||
)
|
||||
.join(',');
|
||||
}
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
import later from '@breejs/later';
|
||||
import is from '@sindresorhus/is';
|
||||
import { DateTime } from 'luxon';
|
||||
import { fixShortHours } from '../../config/migration';
|
||||
import type { RenovateConfig } from '../../config/types';
|
||||
import { logger } from '../../logger';
|
||||
import { regEx } from '../../util/regex';
|
||||
|
||||
const scheduleMappings: Record<string, string> = {
|
||||
'every month': 'before 3am on the first day of the month',
|
||||
monthly: 'before 3am on the first day of the month',
|
||||
};
|
||||
|
||||
function fixShortHours(input: string): string {
|
||||
return input.replace(regEx(/( \d?\d)((a|p)m)/g), '$1:00$2');
|
||||
}
|
||||
|
||||
export function hasValidTimezone(
|
||||
timezone: string
|
||||
): [boolean] | [boolean, string] {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { platform } from '../../../platform';
|
||||
import { regEx } from '../../../util/regex';
|
||||
import * as template from '../../../util/template';
|
||||
import { ensureTrailingSlash } from '../../../util/url';
|
||||
import type { BranchConfig } from '../../types';
|
||||
import { getChangelogs } from './changelogs';
|
||||
import { getPrConfigDescription } from './config-description';
|
||||
|
@ -43,7 +44,7 @@ function massageUpdateMetadata(config: BranchConfig): void {
|
|||
let fullUrl = sourceUrl;
|
||||
if (sourceDirectory) {
|
||||
fullUrl =
|
||||
sourceUrl.replace(regEx(/\/?$/), '/') +
|
||||
ensureTrailingSlash(sourceUrl) +
|
||||
'tree/HEAD/' +
|
||||
sourceDirectory.replace('^/?/', '');
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ export function getPrUpdatesTable(config: BranchConfig): string {
|
|||
if (value) {
|
||||
res[header] = template
|
||||
.compile(value, upgrade)
|
||||
.replace(regEx(/^``$/), ''); // TODO #12071
|
||||
.replace(regEx(/^``$/), '');
|
||||
} else {
|
||||
res[header] = '';
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ export function getPrUpdatesTable(config: BranchConfig): string {
|
|||
const content = row[column]
|
||||
? row[column]
|
||||
.replace(regEx(/^@/), '@​')
|
||||
.replace(regEx(/\|/g), '\\|') // TODO #12071
|
||||
.replace(regEx(/\|/g), '\\|')
|
||||
: '';
|
||||
val += ` ${content} |`;
|
||||
}
|
||||
|
|
|
@ -68,9 +68,9 @@ export function massageBody(
|
|||
): string {
|
||||
let body = input || '';
|
||||
// Convert line returns
|
||||
body = body.replace(regEx(/\r\n/g), '\n'); // TODO #12071
|
||||
body = body.replace(regEx(/\r\n/g), '\n');
|
||||
// semantic-release cleanup
|
||||
body = body.replace(regEx(/^<a name="[^"]*"><\/a>\n/), ''); // TODO #12071
|
||||
body = body.replace(regEx(/^<a name="[^"]*"><\/a>\n/), '');
|
||||
body = body.replace(
|
||||
regEx(
|
||||
`^##? \\[[^\\]]*\\]\\(${baseUrl}[^/]*\\/[^/]*\\/compare\\/.*?\\n`,
|
||||
|
@ -78,17 +78,17 @@ export function massageBody(
|
|||
false
|
||||
),
|
||||
''
|
||||
); // TODO #12071
|
||||
);
|
||||
// Clean-up unnecessary commits link
|
||||
body = `\n${body}\n`.replace(
|
||||
regEx(`\\n${baseUrl}[^/]+\\/[^/]+\\/compare\\/[^\\n]+(\\n|$)`),
|
||||
'\n'
|
||||
); // TODO #12071
|
||||
);
|
||||
// Reduce headings size
|
||||
body = body
|
||||
.replace(regEx(/\n\s*####? /g), '\n##### ') // TODO #12071
|
||||
.replace(regEx(/\n\s*## /g), '\n#### ') // TODO #12071
|
||||
.replace(regEx(/\n\s*# /g), '\n### '); // TODO #12071
|
||||
.replace(regEx(/\n\s*####? /g), '\n##### ')
|
||||
.replace(regEx(/\n\s*## /g), '\n#### ')
|
||||
.replace(regEx(/\n\s*# /g), '\n### ');
|
||||
// Trim whitespace
|
||||
return body.trim();
|
||||
}
|
||||
|
@ -253,13 +253,13 @@ export async function getReleaseNotesMd(
|
|||
const deParenthesizedSection = section.replace(
|
||||
regEx(/[[\]()]/g),
|
||||
' '
|
||||
); // TODO #12071
|
||||
);
|
||||
const [heading] = deParenthesizedSection.split('\n');
|
||||
const title = heading
|
||||
.replace(regEx(/^\s*#*\s*/), '') // TODO #12071
|
||||
.replace(regEx(/^\s*#*\s*/), '')
|
||||
.split(' ')
|
||||
.filter(Boolean);
|
||||
let body = section.replace(regEx(/.*?\n(-{3,}\n)?/), '').trim(); // TODO #12071
|
||||
let body = section.replace(regEx(/.*?\n(-{3,}\n)?/), '').trim();
|
||||
for (const word of title) {
|
||||
if (word.includes(version) && !isUrl(word)) {
|
||||
logger.trace({ body }, 'Found release notes for v' + version);
|
||||
|
@ -268,7 +268,7 @@ export async function getReleaseNotesMd(
|
|||
const url =
|
||||
notesSourceUrl +
|
||||
'#' +
|
||||
title.join('-').replace(regEx(/[^A-Za-z0-9-]/g), ''); // TODO #12071
|
||||
title.join('-').replace(regEx(/[^A-Za-z0-9-]/g), '');
|
||||
body = massageBody(body, baseUrl);
|
||||
if (body?.length) {
|
||||
try {
|
||||
|
|
|
@ -27,7 +27,7 @@ export async function codeOwnersForPr(pr: Pr): Promise<string[]> {
|
|||
.map((line) => line.trim())
|
||||
.filter((line) => line && !line.startsWith('#'))
|
||||
.map((line) => {
|
||||
const [pattern, ...usernames] = line.split(regEx(/\s+/)); // TODO #12071
|
||||
const [pattern, ...usernames] = line.split(regEx(/\s+/));
|
||||
return {
|
||||
usernames,
|
||||
match: (path: string) => {
|
||||
|
|
|
@ -114,7 +114,7 @@ export async function detectVulnerabilityAlerts(
|
|||
vulnerableRequirements = vulnerableRequirements.replace(
|
||||
regEx(/^= /),
|
||||
'== '
|
||||
); // TODO #12071
|
||||
);
|
||||
}
|
||||
combinedAlerts[fileName] ||= {};
|
||||
combinedAlerts[fileName][datasource] ||= {};
|
||||
|
|
|
@ -18,7 +18,7 @@ export function getPrList(
|
|||
prDesc += branches.length > 1 ? `s:\n\n` : `:\n\n`;
|
||||
|
||||
for (const branch of branches) {
|
||||
const prTitleRe = regEx(/@([a-z]+\/[a-z]+)/); // TODO #12071
|
||||
const prTitleRe = regEx(/@([a-z]+\/[a-z]+)/);
|
||||
prDesc += `<details>\n<summary>${branch.prTitle.replace(
|
||||
prTitleRe,
|
||||
'@​$1'
|
||||
|
|
|
@ -19,8 +19,8 @@ function sanitizeDepName(depName: string): string {
|
|||
return depName
|
||||
.replace('@types/', '')
|
||||
.replace('@', '')
|
||||
.replace(regEx(/\//g), '-') // TODO #12071
|
||||
.replace(regEx(/\s+/g), '-') // TODO #12071
|
||||
.replace(regEx(/\//g), '-')
|
||||
.replace(regEx(/\s+/g), '-')
|
||||
.replace(regEx(/-+/), '-')
|
||||
.toLowerCase();
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ export function applyUpdateConfig(input: BranchUpgradeConfig): any {
|
|||
const parsedSourceUrl = parseUrl(updateConfig.sourceUrl);
|
||||
if (parsedSourceUrl?.pathname) {
|
||||
updateConfig.sourceRepoSlug = parsedSourceUrl.pathname
|
||||
.replace(regEx(/^\//), '') // remove leading slash // TODO #12071
|
||||
.replace(regEx(/\//g), '-') // change slashes to hyphens // TODO #12071
|
||||
.replace(regEx(/^\//), '') // remove leading slash
|
||||
.replace(regEx(/\//g), '-') // change slashes to hyphens
|
||||
.replace(regEx(/-+/g), '-'); // remove multiple hyphens
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ export function generateBranchConfig(
|
|||
}
|
||||
upgrade.commitMessagePrefix = CommitMessage.formatPrefix(semanticPrefix);
|
||||
upgrade.toLowerCase =
|
||||
regEx(/[A-Z]/).exec(upgrade.semanticCommitType) === null && // TODO #12071
|
||||
regEx(/[A-Z]/).exec(upgrade.semanticCommitType) === null &&
|
||||
!upgrade.semanticCommitType.startsWith(':');
|
||||
}
|
||||
// Compile a few times in case there are nested templates
|
||||
|
@ -179,9 +179,9 @@ export function generateBranchConfig(
|
|||
throw new Error(CONFIG_SECRETS_EXPOSED);
|
||||
}
|
||||
upgrade.commitMessage = upgrade.commitMessage.trim(); // Trim exterior whitespace
|
||||
upgrade.commitMessage = upgrade.commitMessage.replace(regEx(/\s+/g), ' '); // Trim extra whitespace inside string // TODO #12071
|
||||
upgrade.commitMessage = upgrade.commitMessage.replace(regEx(/\s+/g), ' '); // Trim extra whitespace inside string
|
||||
upgrade.commitMessage = upgrade.commitMessage.replace(
|
||||
regEx(/to vv(\d)/), // TODO #12071
|
||||
regEx(/to vv(\d)/),
|
||||
'to v$1'
|
||||
);
|
||||
if (upgrade.toLowerCase) {
|
||||
|
@ -203,7 +203,7 @@ export function generateBranchConfig(
|
|||
upgrade.prTitle = template
|
||||
.compile(upgrade.prTitle, upgrade)
|
||||
.trim()
|
||||
.replace(regEx(/\s+/g), ' '); // TODO #12071
|
||||
.replace(regEx(/\s+/g), ' ');
|
||||
// istanbul ignore if
|
||||
if (upgrade.prTitle !== sanitize(upgrade.prTitle)) {
|
||||
logger.debug(
|
||||
|
|
|
@ -31,7 +31,7 @@ export function execSnapshot(cmd: string, options?: CallOptions): ExecSnapshot {
|
|||
if (is.string(v)) {
|
||||
const val = v
|
||||
.replace(regEx(/\\(\w)/g), '/$1')
|
||||
.replace(cwd, '/root/project'); // TODO #12071
|
||||
.replace(cwd, '/root/project');
|
||||
this.update(val);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -73,7 +73,7 @@ async function generateData() {
|
|||
/** @type {string[]} */
|
||||
const contentMapAssignments = [];
|
||||
for (const file of files) {
|
||||
const key = file.replace(/\\/g, '/'); // TODO #12071
|
||||
const key = file.replace(/\\/g, '/');
|
||||
|
||||
const rawFileContent = await fs.readFile(file, 'utf8');
|
||||
const value = JSON.stringify(rawFileContent);
|
||||
|
|
Загрузка…
Ссылка в новой задаче