diff --git a/lib/modules/datasource/common.ts b/lib/modules/datasource/common.ts index e02c77e620af85590e13e8e6d91be881754ff227..f8052e547ba7657fd297ef5e1bab85f8efdacea3 100644 --- a/lib/modules/datasource/common.ts +++ b/lib/modules/datasource/common.ts @@ -1,10 +1,15 @@ +import is from '@sindresorhus/is'; import type { GetPkgReleasesConfig } from './types'; export function isGetPkgReleasesConfig( input: unknown ): input is GetPkgReleasesConfig { return ( - (input as GetPkgReleasesConfig).datasource !== undefined && - (input as GetPkgReleasesConfig).packageName !== undefined + is.nonEmptyStringAndNotWhitespace( + (input as GetPkgReleasesConfig).datasource + ) && + is.nonEmptyStringAndNotWhitespace( + (input as GetPkgReleasesConfig).packageName + ) ); } diff --git a/lib/workers/repository/process/fetch.ts b/lib/workers/repository/process/fetch.ts index a354dae2c71bc8713e4b97a560585e489d5bd7b7..38dc52b314be76749744c3ac527a137a164ffbe2 100644 --- a/lib/workers/repository/process/fetch.ts +++ b/lib/workers/repository/process/fetch.ts @@ -47,6 +47,7 @@ async function fetchDepUpdates( depConfig = mergeChildConfig(depConfig, datasourceDefaultConfig); depConfig.versioning ??= getDefaultVersioning(depConfig.datasource); depConfig = applyPackageRules(depConfig); + depConfig.packageName ??= depConfig.depName; if (depConfig.ignoreDeps!.includes(depName!)) { // TODO: fix types (#7154) logger.debug(`Dependency: ${depName!}, is ignored`); diff --git a/lib/workers/repository/process/lookup/index.spec.ts b/lib/workers/repository/process/lookup/index.spec.ts index 555954cd670580282bc748782d232f14d136222b..1efd5c8ae30f85bafdad22877e3565c7b37c7586 100644 --- a/lib/workers/repository/process/lookup/index.spec.ts +++ b/lib/workers/repository/process/lookup/index.spec.ts @@ -1178,7 +1178,7 @@ describe('workers/repository/process/lookup/index', () => { expect(res.updates).toHaveLength(0); expect(res.warnings).toHaveLength(1); expect(res.warnings[0].message).toBe( - "Can't find version with tag foo for typescript" + "Can't find version with tag foo for npm package typescript" ); }); diff --git a/lib/workers/repository/process/lookup/index.ts b/lib/workers/repository/process/lookup/index.ts index 57c8ed1ccf5d99260537f12d4ae774f605b24c78..522745e27a0a5a1c9b1382c7b7037e5156c7a01a 100644 --- a/lib/workers/repository/process/lookup/index.ts +++ b/lib/workers/repository/process/lookup/index.ts @@ -81,7 +81,7 @@ export async function lookupUpdates( // If dependency lookup fails then warn and return const warning: ValidationMessage = { topic: packageName, - message: `Failed to look up ${datasource} dependency ${packageName}`, + message: `Failed to look up ${datasource} package ${packageName}`, }; logger.debug({ dependency: packageName, packageFile }, warning.message); // TODO: return warnings in own field @@ -89,7 +89,9 @@ export async function lookupUpdates( return res; } if (dependency.deprecationMessage) { - logger.debug(`Found deprecationMessage for dependency ${packageName}`); + logger.debug( + `Found deprecationMessage for ${datasource} package ${packageName}` + ); res.deprecationMessage = dependency.deprecationMessage; } @@ -123,7 +125,7 @@ export async function lookupUpdates( if (!taggedVersion) { res.warnings.push({ topic: packageName, - message: `Can't find version with tag ${followTag} for ${packageName}`, + message: `Can't find version with tag ${followTag} for ${datasource} package ${packageName}`, }); return res; } @@ -147,7 +149,7 @@ export async function lookupUpdates( res.warnings.push({ topic: packageName, // TODO: types (#7154) - message: `Can't find version matching ${currentValue!} for ${packageName}`, + message: `Can't find version matching ${currentValue!} for ${datasource} package ${packageName}`, }); return res; } @@ -326,7 +328,7 @@ export async function lookupUpdates( } } else if (currentValue) { logger.debug( - `Dependency ${packageName} has unsupported value ${currentValue}` + `Dependency ${packageName} has unsupported/unversioned value ${currentValue} (versioning=${config.versioning})` ); if (!pinDigests && !currentDigest) { res.skipReason = 'invalid-value'; diff --git a/lib/workers/repository/update/pr/changelog/__snapshots__/github.spec.ts.snap b/lib/workers/repository/update/pr/changelog/__snapshots__/github.spec.ts.snap index d42032437965a20de1ecd242f3018e1cbe68a857..bf1018023d13a05575c44c4a37c1203122999c36 100644 --- a/lib/workers/repository/update/pr/changelog/__snapshots__/github.spec.ts.snap +++ b/lib/workers/repository/update/pr/changelog/__snapshots__/github.spec.ts.snap @@ -6,7 +6,7 @@ exports[`workers/repository/update/pr/changelog/github getChangeLogJSON filters "project": { "apiBaseUrl": "https://api.github.com/", "baseUrl": "https://github.com/", - "depName": "@renovate/no", + "packageName": "@renovate/no", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github.com/chalk/chalk", @@ -65,7 +65,7 @@ exports[`workers/repository/update/pr/changelog/github getChangeLogJSON supports "project": { "apiBaseUrl": "https://github-enterprise.example.com/api/v3/", "baseUrl": "https://github-enterprise.example.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github-enterprise.example.com/chalk/chalk", @@ -124,7 +124,7 @@ exports[`workers/repository/update/pr/changelog/github getChangeLogJSON supports "project": { "apiBaseUrl": "https://api.github.com/", "baseUrl": "https://github.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github.com/chalk/chalk", @@ -183,7 +183,7 @@ exports[`workers/repository/update/pr/changelog/github getChangeLogJSON supports "project": { "apiBaseUrl": "https://api.github.com/", "baseUrl": "https://github.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github.com/chalk/chalk", @@ -242,7 +242,7 @@ exports[`workers/repository/update/pr/changelog/github getChangeLogJSON uses Git "project": { "apiBaseUrl": "https://api.github.com/", "baseUrl": "https://github.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github.com/chalk/chalk", @@ -301,7 +301,7 @@ exports[`workers/repository/update/pr/changelog/github getChangeLogJSON works wi "project": { "apiBaseUrl": "https://api.github.com/", "baseUrl": "https://github.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github.com/chalk/chalk", diff --git a/lib/workers/repository/update/pr/changelog/__snapshots__/gitlab.spec.ts.snap b/lib/workers/repository/update/pr/changelog/__snapshots__/gitlab.spec.ts.snap index 33f53b59be2fcf68eb0a5bfc06e95d6aac37e0e9..0b9fc65d6e3dbcbd278fad4e9404149e9ce0cdc2 100644 --- a/lib/workers/repository/update/pr/changelog/__snapshots__/gitlab.spec.ts.snap +++ b/lib/workers/repository/update/pr/changelog/__snapshots__/gitlab.spec.ts.snap @@ -6,7 +6,7 @@ exports[`workers/repository/update/pr/changelog/gitlab getChangeLogJSON handles "project": { "apiBaseUrl": "https://gitlab.com/api/v4/", "baseUrl": "https://gitlab.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "meno/dropzone", "sourceDirectory": undefined, "sourceUrl": "https://gitlab.com/meno/dropzone/", @@ -55,7 +55,7 @@ exports[`workers/repository/update/pr/changelog/gitlab getChangeLogJSON supports "project": { "apiBaseUrl": "https://gitlab-enterprise.example.com/api/v4/", "baseUrl": "https://gitlab-enterprise.example.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "meno/dropzone", "sourceDirectory": undefined, "sourceUrl": "https://gitlab-enterprise.example.com/meno/dropzone/", @@ -104,7 +104,7 @@ exports[`workers/repository/update/pr/changelog/gitlab getChangeLogJSON supports "project": { "apiBaseUrl": "https://git.test.com/api/v4/", "baseUrl": "https://git.test.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "meno/dropzone", "sourceDirectory": undefined, "sourceUrl": "https://git.test.com/meno/dropzone/", @@ -153,7 +153,7 @@ exports[`workers/repository/update/pr/changelog/gitlab getChangeLogJSON uses Git "project": { "apiBaseUrl": "https://gitlab.com/api/v4/", "baseUrl": "https://gitlab.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "meno/dropzone", "sourceDirectory": undefined, "sourceUrl": "https://gitlab.com/meno/dropzone/", @@ -222,7 +222,7 @@ exports[`workers/repository/update/pr/changelog/gitlab getChangeLogJSON uses Git "project": { "apiBaseUrl": "https://gitlab.com/api/v4/", "baseUrl": "https://gitlab.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "meno/dropzone", "sourceDirectory": undefined, "sourceUrl": "https://gitlab.com/meno/dropzone/", @@ -271,7 +271,7 @@ exports[`workers/repository/update/pr/changelog/gitlab getChangeLogJSON works wi "project": { "apiBaseUrl": "https://gitlab.com/api/v4/", "baseUrl": "https://gitlab.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "meno/dropzone", "sourceDirectory": undefined, "sourceUrl": "https://gitlab.com/meno/dropzone/", diff --git a/lib/workers/repository/update/pr/changelog/__snapshots__/index.spec.ts.snap b/lib/workers/repository/update/pr/changelog/__snapshots__/index.spec.ts.snap index febe60c2e4064e8fee3adaa147120f8047b6038f..cca6fc27ffabba283cf7aab46f27a0a91e14a638 100644 --- a/lib/workers/repository/update/pr/changelog/__snapshots__/index.spec.ts.snap +++ b/lib/workers/repository/update/pr/changelog/__snapshots__/index.spec.ts.snap @@ -6,7 +6,7 @@ exports[`workers/repository/update/pr/changelog/index getChangeLogJSON filters u "project": { "apiBaseUrl": "https://api.github.com/", "baseUrl": "https://github.com/", - "depName": "@renovate/no", + "packageName": "@renovate/no", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github.com/chalk/chalk", @@ -65,7 +65,7 @@ exports[`workers/repository/update/pr/changelog/index getChangeLogJSON supports "project": { "apiBaseUrl": "https://github-enterprise.example.com/api/v3/", "baseUrl": "https://github-enterprise.example.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github-enterprise.example.com/chalk/chalk", @@ -124,7 +124,7 @@ exports[`workers/repository/update/pr/changelog/index getChangeLogJSON supports "project": { "apiBaseUrl": "https://api.github.com/", "baseUrl": "https://github.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github.com/chalk/chalk", @@ -183,7 +183,7 @@ exports[`workers/repository/update/pr/changelog/index getChangeLogJSON supports "project": { "apiBaseUrl": "https://github-enterprise.example.com/api/v3/", "baseUrl": "https://github-enterprise.example.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github-enterprise.example.com/chalk/chalk", @@ -242,7 +242,7 @@ exports[`workers/repository/update/pr/changelog/index getChangeLogJSON supports "project": { "apiBaseUrl": "https://api.github.com/", "baseUrl": "https://github.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github.com/chalk/chalk", @@ -301,7 +301,7 @@ exports[`workers/repository/update/pr/changelog/index getChangeLogJSON uses GitH "project": { "apiBaseUrl": "https://api.github.com/", "baseUrl": "https://github.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github.com/chalk/chalk", @@ -365,7 +365,7 @@ exports[`workers/repository/update/pr/changelog/index getChangeLogJSON works wit "project": { "apiBaseUrl": "https://api.github.com/", "baseUrl": "https://github.com/", - "depName": "renovate", + "packageName": "renovate", "repository": "chalk/chalk", "sourceDirectory": undefined, "sourceUrl": "https://github.com/chalk/chalk", diff --git a/lib/workers/repository/update/pr/changelog/github.spec.ts b/lib/workers/repository/update/pr/changelog/github.spec.ts index 84419c7e26ff327892880e807ef63c097b7d4216..8571c684606ae610998a849e2e196ea29a11ba58 100644 --- a/lib/workers/repository/update/pr/changelog/github.spec.ts +++ b/lib/workers/repository/update/pr/changelog/github.spec.ts @@ -13,7 +13,7 @@ jest.mock('../../../../../modules/datasource/npm'); const upgrade = partial<BranchUpgradeConfig>({ manager: 'some-manager', branchName: '', - depName: 'renovate', + packageName: 'renovate', endpoint: 'https://api.github.com/', versioning: semverVersioning.id, currentVersion: '1.0.0', @@ -97,7 +97,7 @@ describe('workers/repository/update/pr/changelog/github', () => { project: { apiBaseUrl: 'https://api.github.com/', baseUrl: 'https://github.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github.com/chalk/chalk', @@ -122,7 +122,7 @@ describe('workers/repository/update/pr/changelog/github', () => { project: { apiBaseUrl: 'https://api.github.com/', baseUrl: 'https://github.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github.com/chalk/chalk', @@ -141,14 +141,14 @@ describe('workers/repository/update/pr/changelog/github', () => { expect( await getChangeLogJSON({ ...upgrade, - depName: '@renovate/no', + packageName: '@renovate/no', }) ).toMatchSnapshot({ hasReleaseNotes: true, project: { apiBaseUrl: 'https://api.github.com/', baseUrl: 'https://github.com/', - depName: '@renovate/no', + packageName: '@renovate/no', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github.com/chalk/chalk', @@ -174,7 +174,7 @@ describe('workers/repository/update/pr/changelog/github', () => { project: { apiBaseUrl: 'https://api.github.com/', baseUrl: 'https://github.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github.com/chalk/chalk', @@ -251,7 +251,7 @@ describe('workers/repository/update/pr/changelog/github', () => { project: { apiBaseUrl: 'https://api.github.com/', baseUrl: 'https://github.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github.com/chalk/chalk', @@ -284,7 +284,7 @@ describe('workers/repository/update/pr/changelog/github', () => { project: { apiBaseUrl: 'https://api.github.com/', baseUrl: 'https://github.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'sindresorhus/got', sourceDirectory: undefined, sourceUrl: 'https://github.com/sindresorhus/got', @@ -312,7 +312,7 @@ describe('workers/repository/update/pr/changelog/github', () => { project: { apiBaseUrl: 'https://github-enterprise.example.com/api/v3/', baseUrl: 'https://github-enterprise.example.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github-enterprise.example.com/chalk/chalk', @@ -348,7 +348,7 @@ describe('workers/repository/update/pr/changelog/github', () => { project: { apiBaseUrl: 'https://github-enterprise.example.com/api/v3/', baseUrl: 'https://github-enterprise.example.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'sindresorhus/got', sourceDirectory: undefined, sourceUrl: 'https://github-enterprise.example.com/sindresorhus/got', @@ -372,7 +372,7 @@ describe('workers/repository/update/pr/changelog/github', () => { const upgradeData = partial<BranchUpgradeConfig>({ manager: 'some-manager', branchName: '', - depName: 'correctPrefix/target', + packageName: 'correctPrefix/target', endpoint: 'https://api.github.com/', versioning: 'npm', currentVersion: '1.0.0', @@ -395,7 +395,7 @@ describe('workers/repository/update/pr/changelog/github', () => { repository: 'chalk/chalk', sourceUrl: 'https://github.com/chalk/chalk', sourceDirectory: undefined, - depName: 'correctPrefix/target', + packageName: 'correctPrefix/target', }, versions: [ { diff --git a/lib/workers/repository/update/pr/changelog/gitlab.spec.ts b/lib/workers/repository/update/pr/changelog/gitlab.spec.ts index 5f9828046e31e33ad69a1b53237a97d4fc963f0f..b0de522d1fa0359423d321af49854fe1f1226530 100644 --- a/lib/workers/repository/update/pr/changelog/gitlab.spec.ts +++ b/lib/workers/repository/update/pr/changelog/gitlab.spec.ts @@ -11,7 +11,7 @@ const upgrade = partial<BranchUpgradeConfig>({ manager: 'some-manager', branchName: '', endpoint: 'https://gitlab.com/api/v4/ ', - depName: 'renovate', + packageName: 'renovate', versioning: semverVersioning.id, currentVersion: '5.2.0', newVersion: '5.7.0', @@ -85,7 +85,7 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { project: { apiBaseUrl: 'https://gitlab.com/api/v4/', baseUrl: 'https://gitlab.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'meno/dropzone', sourceDirectory: undefined, sourceUrl: 'https://gitlab.com/meno/dropzone/', @@ -127,7 +127,7 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { project: { apiBaseUrl: 'https://gitlab.com/api/v4/', baseUrl: 'https://gitlab.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'meno/dropzone', sourceDirectory: undefined, sourceUrl: 'https://gitlab.com/meno/dropzone/', @@ -162,7 +162,7 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { project: { apiBaseUrl: 'https://gitlab.com/api/v4/', baseUrl: 'https://gitlab.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'meno/dropzone', sourceDirectory: undefined, sourceUrl: 'https://gitlab.com/meno/dropzone/', @@ -197,7 +197,7 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { project: { apiBaseUrl: 'https://gitlab.com/api/v4/', baseUrl: 'https://gitlab.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'meno/dropzone', sourceDirectory: undefined, sourceUrl: 'https://gitlab.com/meno/dropzone/', @@ -266,7 +266,7 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { project: { apiBaseUrl: 'https://gitlab-enterprise.example.com/api/v4/', baseUrl: 'https://gitlab-enterprise.example.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'meno/dropzone', sourceDirectory: undefined, sourceUrl: 'https://gitlab-enterprise.example.com/meno/dropzone/', @@ -301,7 +301,7 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { project: { apiBaseUrl: 'https://git.test.com/api/v4/', baseUrl: 'https://git.test.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'meno/dropzone', sourceDirectory: undefined, sourceUrl: 'https://git.test.com/meno/dropzone/', @@ -339,7 +339,7 @@ describe('workers/repository/update/pr/changelog/gitlab', () => { project: { apiBaseUrl: 'https://git.test.com/api/v4/', baseUrl: 'https://git.test.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'replacement/sourceurl', sourceDirectory: undefined, sourceUrl: 'https://git.test.com/replacement/sourceurl/', diff --git a/lib/workers/repository/update/pr/changelog/index.spec.ts b/lib/workers/repository/update/pr/changelog/index.spec.ts index 51748a88e5aaf0d9bc80a5bbfe4e9bf9095072fc..9fd8a4f3cdb619d4514e0129150cd950cf85808e 100644 --- a/lib/workers/repository/update/pr/changelog/index.spec.ts +++ b/lib/workers/repository/update/pr/changelog/index.spec.ts @@ -16,7 +16,7 @@ const githubReleasesMock = jest.spyOn(githubGraphql, 'queryReleases'); const upgrade = partial<BranchConfig>({ endpoint: 'https://api.github.com/', - depName: 'renovate', + packageName: 'renovate', versioning: semverVersioning.id, currentVersion: '1.0.0', newVersion: '3.0.0', @@ -105,7 +105,7 @@ describe('workers/repository/update/pr/changelog/index', () => { project: { apiBaseUrl: 'https://api.github.com/', baseUrl: 'https://github.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github.com/chalk/chalk', @@ -140,7 +140,7 @@ describe('workers/repository/update/pr/changelog/index', () => { project: { apiBaseUrl: 'https://api.github.com/', baseUrl: 'https://github.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github.com/chalk/chalk', @@ -163,14 +163,14 @@ describe('workers/repository/update/pr/changelog/index', () => { httpMock.scope(githubApiHost).get(/.*/).reply(200, []).persist(); const res = await getChangeLogJSON({ ...upgrade, - depName: '@renovate/no', + packageName: '@renovate/no', }); expect(res).toMatchSnapshot({ hasReleaseNotes: true, project: { apiBaseUrl: 'https://api.github.com/', baseUrl: 'https://github.com/', - depName: '@renovate/no', + packageName: '@renovate/no', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github.com/chalk/chalk', @@ -199,7 +199,7 @@ describe('workers/repository/update/pr/changelog/index', () => { project: { apiBaseUrl: 'https://api.github.com/', baseUrl: 'https://github.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github.com/chalk/chalk', @@ -279,7 +279,7 @@ describe('workers/repository/update/pr/changelog/index', () => { project: { apiBaseUrl: 'https://api.github.com/', baseUrl: 'https://github.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github.com/chalk/chalk', @@ -319,7 +319,7 @@ describe('workers/repository/update/pr/changelog/index', () => { project: { apiBaseUrl: 'https://github-enterprise.example.com/api/v3/', baseUrl: 'https://github-enterprise.example.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github-enterprise.example.com/chalk/chalk', @@ -357,7 +357,7 @@ describe('workers/repository/update/pr/changelog/index', () => { project: { apiBaseUrl: 'https://github-enterprise.example.com/api/v3/', baseUrl: 'https://github-enterprise.example.com/', - depName: 'renovate', + packageName: 'renovate', repository: 'chalk/chalk', sourceDirectory: undefined, sourceUrl: 'https://github-enterprise.example.com/chalk/chalk', diff --git a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts index 9810c7dba4ad97f778fd1c9583909c3af57dd379..6baea97bde0ada7a33aefbcd8ad36d1e8ba52c4c 100644 --- a/lib/workers/repository/update/pr/changelog/release-notes.spec.ts +++ b/lib/workers/repository/update/pr/changelog/release-notes.spec.ts @@ -324,7 +324,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/repository', - depName: 'some', + packageName: 'some', }, partial<ChangeLogRelease>({ version: '1.0.0', @@ -359,7 +359,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', }, partial<ChangeLogRelease>({ version: '1.0.1', @@ -401,7 +401,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', }, partial<ChangeLogRelease>({ version: '1.0.1', @@ -443,7 +443,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', }, partial<ChangeLogRelease>({ version: '1.0.1', @@ -485,7 +485,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', }, partial<ChangeLogRelease>({ version: '1.0.1', @@ -527,7 +527,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', }, partial<ChangeLogRelease>({ version: '1.0.1', @@ -562,7 +562,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', }, partial<ChangeLogRelease>({ version: '1.0.1', @@ -606,7 +606,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', }, partial<ChangeLogRelease>({ version: '1.0.1', @@ -650,7 +650,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', }, partial<ChangeLogRelease>({ version: '1.0.1', @@ -693,7 +693,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', }, partial<ChangeLogRelease>({ version: '1.0.1', @@ -730,7 +730,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...gitlabProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', apiBaseUrl: 'https://api.gitlab.com/', }, partial<ChangeLogRelease>({ @@ -767,7 +767,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...gitlabProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', apiBaseUrl: 'https://api.gitlab.com/', }, partial<ChangeLogRelease>({ @@ -804,7 +804,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...gitlabProject, repository: 'some/other-repository', - depName: 'other', + packageName: 'other', apiBaseUrl: 'https://api.gitlab.com/', }, partial<ChangeLogRelease>({ @@ -827,7 +827,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { const res = await getReleaseNotes( partial<ChangeLogProject>({ repository: 'some/repository', - depName: 'other', + packageName: 'other', apiBaseUrl: 'https://api.lol.lol/', baseUrl: 'https://lol.lol/', }), @@ -841,11 +841,11 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { }); it('handles same version but different repo releases', async () => { - const depName = 'correctTagPrefix/exampleDep'; + const packageName = 'correctTagPrefix/exampleDep'; githubReleasesMock.mockResolvedValueOnce([ { id: 1, - version: `${depName}@1.0.0`, + version: `${packageName}@1.0.0`, releaseTimestamp: '2020-01-01', url: 'correct/url/tag.com', name: 'some/dep', @@ -872,7 +872,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/other-repository', - depName: 'exampleDep', + packageName: 'exampleDep', }, partial<ChangeLogRelease>({ version: '1.0.0', @@ -906,7 +906,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => { { ...githubProject, repository: 'some/other-repository', - depName: 'exampleDep', + packageName: 'exampleDep', }, partial<ChangeLogRelease>({ version: '1.0.0', diff --git a/lib/workers/repository/update/pr/changelog/release-notes.ts b/lib/workers/repository/update/pr/changelog/release-notes.ts index 2cb7d2fbae582f5c09bc98ead90c34e142261315..2f8bff66a658e156271aed0c89e63a34e1420136 100644 --- a/lib/workers/repository/update/pr/changelog/release-notes.ts +++ b/lib/workers/repository/update/pr/changelog/release-notes.ts @@ -125,15 +125,15 @@ export async function getReleaseNotes( release: ChangeLogRelease, config: BranchUpgradeConfig ): Promise<ChangeLogNotes | null> { - const { depName, repository } = project; + const { packageName, repository } = project; const { version, gitRef } = release; // TODO: types (#7154) - logger.trace(`getReleaseNotes(${repository}, ${version}, ${depName!})`); + logger.trace(`getReleaseNotes(${repository}, ${version}, ${packageName!})`); const releases = await getCachedReleaseList(project, release); logger.trace({ releases }, 'Release list from getReleaseList'); let releaseNotes: ChangeLogNotes | null = null; - let matchedRelease = getExactReleaseMatch(depName!, version, releases); + let matchedRelease = getExactReleaseMatch(packageName!, version, releases); if (is.undefined(matchedRelease)) { // no exact match of a release then check other cases matchedRelease = releases.find( @@ -158,11 +158,11 @@ export async function getReleaseNotes( } function getExactReleaseMatch( - depName: string, + packageName: string, version: string, releases: ChangeLogNotes[] ): ChangeLogNotes | undefined { - const exactReleaseReg = regEx(`${depName}[@_-]v?${version}`); + const exactReleaseReg = regEx(`${packageName}[@_-]v?${version}`); const candidateReleases = releases.filter((r) => r.tag?.endsWith(version)); const matchedRelease = candidateReleases.find((r) => exactReleaseReg.test(r.tag!) diff --git a/lib/workers/repository/update/pr/changelog/source-github.ts b/lib/workers/repository/update/pr/changelog/source-github.ts index a3bcb339086f10dcdfea5b3be9891066635e3e06..39712f42aabd380700409ae8bf30c009889b6410 100644 --- a/lib/workers/repository/update/pr/changelog/source-github.ts +++ b/lib/workers/repository/update/pr/changelog/source-github.ts @@ -38,7 +38,7 @@ export async function getChangeLogJSON( const newVersion = config.newVersion!; const sourceUrl = config.sourceUrl!; const sourceDirectory = config.sourceDirectory!; - const depName = config.depName!; + const packageName = config.packageName!; const manager = config.manager; if (sourceUrl === 'https://github.com/DefinitelyTyped/DefinitelyTyped') { logger.trace('No release notes for @types'); @@ -60,19 +60,19 @@ export async function getChangeLogJSON( if (host!.endsWith('.github.com') || host === 'github.com') { if (!GlobalConfig.get('githubTokenWarn')) { logger.debug( - { manager, depName, sourceUrl }, + { manager, packageName, sourceUrl }, 'GitHub token warning has been suppressed. Skipping release notes retrieval' ); return null; } logger.warn( - { manager, depName, sourceUrl }, + { manager, packageName, sourceUrl }, 'No github.com token has been configured. Skipping release notes retrieval' ); return { error: 'MissingGithubToken' }; } logger.debug( - { manager, depName, sourceUrl }, + { manager, packageName, sourceUrl }, 'Repository URL does not match any known github hosts - skipping changelog retrieval' ); return null; @@ -99,7 +99,7 @@ export async function getChangeLogJSON( .sort((a, b) => version.sortVersions(a.version, b.version)); if (validReleases.length < 2) { - logger.debug(`Not enough valid releases for dep ${depName}`); + logger.debug(`Not enough valid releases for dep ${packageName}`); return null; } @@ -109,7 +109,12 @@ export async function getChangeLogJSON( if (!tags) { tags = await getCachedTags(apiBaseUrl, repository); } - const tagName = findTagOfRelease(version, depName, release.version, tags); + const tagName = findTagOfRelease( + version, + packageName, + release.version, + tags + ); if (tagName) { return tagName; } @@ -122,7 +127,7 @@ export async function getChangeLogJSON( const cacheNamespace = 'changelog-github-release'; function getCacheKey(prev: string, next: string): string { - return `${slugifyUrl(sourceUrl)}:${depName}:${prev}:${next}`; + return `${slugifyUrl(sourceUrl)}:${packageName}:${prev}:${next}`; } const changelogReleases: ChangeLogRelease[] = []; @@ -173,7 +178,7 @@ export async function getChangeLogJSON( repository, sourceUrl, sourceDirectory, - depName, + packageName, }, versions: changelogReleases, }; @@ -185,12 +190,12 @@ export async function getChangeLogJSON( function findTagOfRelease( version: allVersioning.VersioningApi, - depName: string, + packageName: string, depNewVersion: string, tags: string[] ): string | undefined { - const regex = regEx(`(?:${depName}|release)[@-]`, undefined, false); - const excactReleaseRegex = regEx(`${depName}[@-_]v?${depNewVersion}`); + const regex = regEx(`(?:${packageName}|release)[@-]`, undefined, false); + const excactReleaseRegex = regEx(`${packageName}[@-_]v?${depNewVersion}`); const exactTagsList = tags.filter((tag) => { return excactReleaseRegex.test(tag); }); diff --git a/lib/workers/repository/update/pr/changelog/source-gitlab.ts b/lib/workers/repository/update/pr/changelog/source-gitlab.ts index 4fa2ebe0adf38a1025b3a65308b5612c198a1631..2b003f51c64a619ee190476f352500aa16e1db12 100644 --- a/lib/workers/repository/update/pr/changelog/source-gitlab.ts +++ b/lib/workers/repository/update/pr/changelog/source-gitlab.ts @@ -38,7 +38,7 @@ export async function getChangeLogJSON( const currentVersion = config.currentVersion!; const newVersion = config.newVersion!; const sourceUrl = config.sourceUrl!; - const depName = config.depName!; + const packageName = config.packageName!; const sourceDirectory = config.sourceDirectory!; logger.trace('getChangeLogJSON for gitlab'); @@ -81,7 +81,7 @@ export async function getChangeLogJSON( if (!tags) { tags = await getCachedTags(apiBaseUrl, versioning, repository); } - const regex = regEx(`(?:${depName}|release)[@-]`, undefined, false); + const regex = regEx(`(?:${packageName}|release)[@-]`, undefined, false); const tagName = tags .filter((tag) => version.isVersion(tag.replace(regex, ''))) .find((tag) => version.equals(tag.replace(regex, ''), release.version)); @@ -95,7 +95,7 @@ export async function getChangeLogJSON( } function getCacheKey(prev: string, next: string): string { - return `${slugifyUrl(sourceUrl)}:${depName}:${prev}:${next}`; + return `${slugifyUrl(sourceUrl)}:${packageName}:${prev}:${next}`; } const changelogReleases: ChangeLogRelease[] = []; @@ -144,7 +144,7 @@ export async function getChangeLogJSON( type: 'gitlab', repository, sourceUrl, - depName, + packageName, sourceDirectory, }, versions: changelogReleases, diff --git a/lib/workers/repository/update/pr/changelog/types.ts b/lib/workers/repository/update/pr/changelog/types.ts index 025c1a834e5ca3271ffc50ae50adcb5c63acf313..23c4747a057e1353df96c5e0f07f29bca9d35ca4 100644 --- a/lib/workers/repository/update/pr/changelog/types.ts +++ b/lib/workers/repository/update/pr/changelog/types.ts @@ -24,7 +24,7 @@ export interface ChangeLogRelease { } export interface ChangeLogProject { - depName?: string; + packageName?: string; type: 'github' | 'gitlab'; apiBaseUrl?: string; baseUrl: string;