From 855db036d50e78c2f4a65f6aa39873cd566a9869 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Thu, 11 Feb 2021 00:39:06 +0100 Subject: [PATCH] fix: rename baseDir to packageFileDir for templating (#8625) --- lib/config/__snapshots__/migration.spec.ts.snap | 2 +- lib/config/migration.spec.ts | 2 +- lib/config/migration.ts | 2 ++ lib/util/template/index.ts | 3 ++- lib/workers/repository/updates/flatten.ts | 4 ++-- lib/workers/repository/updates/generate.spec.ts | 4 ++-- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/config/__snapshots__/migration.spec.ts.snap b/lib/config/__snapshots__/migration.spec.ts.snap index c9ddeae2f7..17374dfdea 100644 --- a/lib/config/__snapshots__/migration.spec.ts.snap +++ b/lib/config/__snapshots__/migration.spec.ts.snap @@ -85,7 +85,7 @@ Object { "next", ], "binarySource": "global", - "branchName": "{{{branchPrefix}}}{{{additionalBranchPrefix}}}{{{branchTopic}}}", + "branchName": "{{{branchPrefix}}}{{{additionalBranchPrefix}}}{{{branchTopic}}}{{{packageFileDir}}}", "branchPrefix": "renovate/", "commitMessage": "{{#if semanticCommitType}}{{semanticCommitType}}{{#if semanticCommitScope}}({{semanticCommitScope}}){{/if}}: {{/if}}some commit message", "commitMessageExtra": "{{currentValue}} something", diff --git a/lib/config/migration.spec.ts b/lib/config/migration.spec.ts index b100b13eda..4c717514a1 100644 --- a/lib/config/migration.spec.ts +++ b/lib/config/migration.spec.ts @@ -48,7 +48,7 @@ describe('config/migration', () => { upgradeInRange: true, automergeType: 'branch-push', branchName: - '{{{branchPrefix}}}{{{managerBranchPrefix}}}{{{branchTopic}}}', + '{{{branchPrefix}}}{{{managerBranchPrefix}}}{{{branchTopic}}}{{{baseDir}}}', baseBranch: 'next', managerBranchPrefix: 'foo', branchPrefix: 'renovate/{{parentDir}}-', diff --git a/lib/config/migration.ts b/lib/config/migration.ts index 82cd06f92f..dea44c6607 100644 --- a/lib/config/migration.ts +++ b/lib/config/migration.ts @@ -164,6 +164,8 @@ export function migrateConfig( } else if (val === false) { migratedConfig.rangeStrategy = 'replace'; } + } else if (is.string(val) && val.includes('{{baseDir}}')) { + migratedConfig[key] = val.replace(/{{baseDir}}/g, '{{packageFileDir}}'); } else if (key === 'gitFs') { delete migratedConfig.gitFs; } else if (key === 'rebaseStalePrs') { diff --git a/lib/util/template/index.ts b/lib/util/template/index.ts index d48b980ea3..7ff0914c5a 100644 --- a/lib/util/template/index.ts +++ b/lib/util/template/index.ts @@ -38,7 +38,6 @@ export const exposedConfigOptions = [ export const allowedFields = { baseBranch: 'The baseBranch for this branch/PR', - baseDir: 'The full directory with path that the dependency has been found in', body: 'The body of the release notes', currentValue: 'The extracted current value of the dependency being updated', currentVersion: 'The current version that is being updated', @@ -76,6 +75,8 @@ export const allowedFields = { 'The new value in the upgrade. Can be a range or version e.g. "^3.0.0" or "3.1.0"', newVersion: 'The new version in the upgrade.', packageFile: 'The filename that the dependency was found in', + packageFileDir: + 'The directory with full path where the packageFile was found', parentDir: 'The name of the directory that the dependency was found in, without full path', platform: 'VCS platform in use, e.g. "github", "gitlab", etc.', diff --git a/lib/workers/repository/updates/flatten.ts b/lib/workers/repository/updates/flatten.ts index e8d884c556..e5dd2d39a3 100644 --- a/lib/workers/repository/updates/flatten.ts +++ b/lib/workers/repository/updates/flatten.ts @@ -36,10 +36,10 @@ export async function flattenUpdates( } if (packagePath.length > 0) { packageFileConfig.parentDir = packagePath[packagePath.length - 1]; - packageFileConfig.baseDir = packagePath.join('/'); + packageFileConfig.packageFileDir = packagePath.join('/'); } else { packageFileConfig.parentDir = ''; - packageFileConfig.baseDir = ''; + packageFileConfig.packageFileDir = ''; } for (const dep of packageFile.deps) { if (dep.updates.length) { diff --git a/lib/workers/repository/updates/generate.spec.ts b/lib/workers/repository/updates/generate.spec.ts index 1430a6a1d7..f9d438e343 100644 --- a/lib/workers/repository/updates/generate.spec.ts +++ b/lib/workers/repository/updates/generate.spec.ts @@ -315,10 +315,10 @@ describe('workers/repository/updates/generate', () => { ...defaultConfig, depName: 'some-dep', packageFile: 'foo/bar/package.json', - baseDir: 'foo/bar', + packageFileDir: 'foo/bar', semanticCommits: 'enabled', semanticCommitType: 'chore', - semanticCommitScope: '{{baseDir}}', + semanticCommitScope: '{{packageFileDir}}', newValue: '1.2.0', isSingleVersion: true, toVersion: '1.2.0', -- GitLab