Skip to content
Snippets Groups Projects
Commit 2be25c4a authored by Rhys Arkins's avatar Rhys Arkins
Browse files

refactor: applyUpdateConfig

parent a456c8b5
No related branches found
No related tags found
No related merge requests found
......@@ -8,11 +8,38 @@ import { LANGUAGE_DOCKER } from '../../../constants/languages';
import { getDefaultConfig } from '../../../datasource';
import { get } from '../../../manager';
import { applyPackageRules } from '../../../util/package-rules';
import { BranchUpgradeConfig } from '../../common';
import { generateBranchName } from './branch-name';
const upper = (str: string): string =>
str.charAt(0).toUpperCase() + str.substr(1);
export function applyUpdateConfig(input: BranchUpgradeConfig): any {
const updateConfig = { ...input };
delete updateConfig.packageRules;
// TODO: Remove next line once #8075 is complete
updateConfig.depNameShort ||= updateConfig.depName;
updateConfig.depNameSanitized = updateConfig.depName
? updateConfig.depName
.replace('@types/', '')
.replace('@', '')
.replace(/\//g, '-')
.replace(/\s+/g, '-')
.replace(/-+/, '-')
.toLowerCase()
: undefined;
if (
updateConfig.language === LANGUAGE_DOCKER &&
/(^|\/)node$/.exec(updateConfig.depName) &&
updateConfig.depName !== 'calico/node'
) {
updateConfig.additionalBranchPrefix = '';
updateConfig.depNameSanitized = 'node';
}
generateBranchName(updateConfig);
return updateConfig;
}
export async function flattenUpdates(
config: RenovateConfig,
packageFiles: Record<string, any[]>
......@@ -75,30 +102,7 @@ export async function flattenUpdates(
}
// Apply again in case any were added by the updateType config
updateConfig = applyPackageRules(updateConfig);
delete updateConfig.packageRules;
// TODO: Remove next line once #8075 is complete
updateConfig.depNameShort ||= updateConfig.depName;
updateConfig.depNameSanitized = updateConfig.depName
? updateConfig.depName
.replace('@types/', '')
.replace('@', '')
.replace(/\//g, '-')
.replace(/\s+/g, '-')
.replace(/-+/, '-')
.toLowerCase()
: undefined;
if (
updateConfig.language === LANGUAGE_DOCKER &&
updateConfig.depName.match(/(^|\/)node$/) &&
updateConfig.depName !== 'calico/node'
) {
updateConfig.additionalBranchPrefix = '';
updateConfig.depNameSanitized = 'node';
}
generateBranchName(updateConfig);
update.branchName = updateConfig.branchName; // for writing to cache
delete updateConfig.repoIsOnboarded;
delete updateConfig.renovateJsonPresent;
updateConfig = applyUpdateConfig(updateConfig);
updateConfig.baseDeps = packageFile.deps;
updates.push(updateConfig);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment