mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-10 22:16:28 +00:00
feat: convert sourceDirectory
to a template eligible config (#32701)
Signed-off-by: Adam Setch <adam.setch@outlook.com>
This commit is contained in:
parent
ca3d35d3b2
commit
74c87b41e9
3 changed files with 42 additions and 5 deletions
|
@ -147,6 +147,7 @@ export const exposedConfigOptions = [
|
|||
'semanticCommitType',
|
||||
'separateMajorMinor',
|
||||
'separateMinorPatch',
|
||||
'sourceDirectory',
|
||||
];
|
||||
|
||||
export const allowedFields = {
|
||||
|
|
|
@ -29,6 +29,11 @@ describe('workers/repository/updates/flatten', () => {
|
|||
enabled: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
matchPackageNames: ['@monorepo/package'],
|
||||
sourceUrl: 'https://github.com/some/monorepo',
|
||||
sourceDirectory: "subfolder/{{ lookup (split packageName '/') 1 }}",
|
||||
},
|
||||
];
|
||||
config.remediations = {
|
||||
'package-lock.json': [
|
||||
|
@ -65,6 +70,17 @@ describe('workers/repository/updates/flatten', () => {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
depName: '@monorepo/package',
|
||||
updates: [
|
||||
{
|
||||
newValue: '2.0.0',
|
||||
sourceUrl: 'https://github.com/some/monorepo',
|
||||
sourceDirectory:
|
||||
"subfolder/{{ lookup (split depName '/') 1 }}",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
updateTypes: ['pin'],
|
||||
updates: [{ newValue: '2.0.0' }],
|
||||
|
@ -144,7 +160,7 @@ describe('workers/repository/updates/flatten', () => {
|
|||
],
|
||||
};
|
||||
const res = await flattenUpdates(config, packageFiles);
|
||||
expect(res).toHaveLength(14);
|
||||
expect(res).toHaveLength(15);
|
||||
expect(
|
||||
res.every(
|
||||
(upgrade) =>
|
||||
|
@ -178,16 +194,29 @@ describe('workers/repository/updates/flatten', () => {
|
|||
res.filter((update) => update.sourceRepoName)[1].sourceRepoName,
|
||||
).toBe('repo');
|
||||
expect(
|
||||
res.filter((update) => update.sourceRepoSlug)[2].sourceRepoSlug,
|
||||
res.filter((update) => update.depName === '@monorepo/package')[0],
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
depName: '@monorepo/package',
|
||||
sourceRepoOrg: 'some',
|
||||
sourceRepoName: 'monorepo',
|
||||
sourceRepo: 'some/monorepo',
|
||||
sourceRepoSlug: 'some-monorepo',
|
||||
sourceUrl: 'https://github.com/some/monorepo',
|
||||
sourceDirectory: 'subfolder/package',
|
||||
}),
|
||||
);
|
||||
expect(
|
||||
res.filter((update) => update.sourceRepoSlug)[3].sourceRepoSlug,
|
||||
).toBe('nodejs-node');
|
||||
expect(res.filter((update) => update.sourceRepo)[2].sourceRepo).toBe(
|
||||
expect(res.filter((update) => update.sourceRepo)[3].sourceRepo).toBe(
|
||||
'nodejs/node',
|
||||
);
|
||||
expect(
|
||||
res.filter((update) => update.sourceRepoOrg)[2].sourceRepoOrg,
|
||||
res.filter((update) => update.sourceRepoOrg)[3].sourceRepoOrg,
|
||||
).toBe('nodejs');
|
||||
expect(
|
||||
res.filter((update) => update.sourceRepoName)[2].sourceRepoName,
|
||||
res.filter((update) => update.sourceRepoName)[3].sourceRepoName,
|
||||
).toBe('node');
|
||||
expect(
|
||||
res.filter(
|
||||
|
|
|
@ -9,6 +9,7 @@ import { get } from '../../../modules/manager';
|
|||
import { detectSemanticCommits } from '../../../util/git/semantic';
|
||||
import { applyPackageRules } from '../../../util/package-rules';
|
||||
import { regEx } from '../../../util/regex';
|
||||
import * as template from '../../../util/template';
|
||||
import { parseUrl } from '../../../util/url';
|
||||
import type { BranchUpgradeConfig } from '../../types';
|
||||
import { generateBranchName } from './branch-name';
|
||||
|
@ -57,6 +58,12 @@ export function applyUpdateConfig(input: BranchUpgradeConfig): any {
|
|||
); // remove everything up to the last slash
|
||||
}
|
||||
}
|
||||
if (updateConfig.sourceDirectory) {
|
||||
updateConfig.sourceDirectory = template.compile(
|
||||
updateConfig.sourceDirectory,
|
||||
updateConfig,
|
||||
);
|
||||
}
|
||||
generateBranchName(updateConfig);
|
||||
return updateConfig;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue