mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
refactor: applyUpdateConfig
This commit is contained in:
parent
a456c8b5ab
commit
2be25c4ae6
1 changed files with 28 additions and 24 deletions
|
@ -8,11 +8,38 @@ import { LANGUAGE_DOCKER } from '../../../constants/languages';
|
||||||
import { getDefaultConfig } from '../../../datasource';
|
import { getDefaultConfig } from '../../../datasource';
|
||||||
import { get } from '../../../manager';
|
import { get } from '../../../manager';
|
||||||
import { applyPackageRules } from '../../../util/package-rules';
|
import { applyPackageRules } from '../../../util/package-rules';
|
||||||
|
import { BranchUpgradeConfig } from '../../common';
|
||||||
import { generateBranchName } from './branch-name';
|
import { generateBranchName } from './branch-name';
|
||||||
|
|
||||||
const upper = (str: string): string =>
|
const upper = (str: string): string =>
|
||||||
str.charAt(0).toUpperCase() + str.substr(1);
|
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(
|
export async function flattenUpdates(
|
||||||
config: RenovateConfig,
|
config: RenovateConfig,
|
||||||
packageFiles: Record<string, any[]>
|
packageFiles: Record<string, any[]>
|
||||||
|
@ -75,30 +102,7 @@ export async function flattenUpdates(
|
||||||
}
|
}
|
||||||
// Apply again in case any were added by the updateType config
|
// Apply again in case any were added by the updateType config
|
||||||
updateConfig = applyPackageRules(updateConfig);
|
updateConfig = applyPackageRules(updateConfig);
|
||||||
delete updateConfig.packageRules;
|
updateConfig = applyUpdateConfig(updateConfig);
|
||||||
// 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.baseDeps = packageFile.deps;
|
updateConfig.baseDeps = packageFile.deps;
|
||||||
updates.push(updateConfig);
|
updates.push(updateConfig);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue