Skip to content

Commit

Permalink
fix: rename baseDir to packageFileDir for templating (#8625)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 10, 2021
1 parent efab9be commit 855db03
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/config/__snapshots__/migration.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion lib/config/migration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}}-',
Expand Down
2 changes: 2 additions & 0 deletions lib/config/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
3 changes: 2 additions & 1 deletion lib/util/template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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.',
Expand Down
4 changes: 2 additions & 2 deletions lib/workers/repository/updates/flatten.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions lib/workers/repository/updates/generate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 855db03

Please sign in to comment.