Skip to content

Commit

Permalink
refactor!: prefer packageName over depName in datasource (#20221)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins authored Mar 4, 2023
1 parent 789238c commit 4bbfd40
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 95 deletions.
9 changes: 7 additions & 2 deletions lib/modules/datasource/common.ts
Original file line number Diff line number Diff line change
@@ -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
)
);
}
1 change: 1 addition & 0 deletions lib/workers/repository/process/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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`);
Expand Down
2 changes: 1 addition & 1 deletion lib/workers/repository/process/lookup/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
});

Expand Down
12 changes: 7 additions & 5 deletions lib/workers/repository/process/lookup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,17 @@ 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
res.warnings.push(warning);
return res;
}
if (dependency.deprecationMessage) {
logger.debug(`Found deprecationMessage for dependency ${packageName}`);
logger.debug(
`Found deprecationMessage for ${datasource} package ${packageName}`
);
res.deprecationMessage = dependency.deprecationMessage;
}

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down Expand Up @@ -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/",
Expand Down Expand Up @@ -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/",
Expand Down Expand Up @@ -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/",
Expand Down Expand Up @@ -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/",
Expand Down Expand Up @@ -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/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
24 changes: 12 additions & 12 deletions lib/workers/repository/update/pr/changelog/github.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand All @@ -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: [
{
Expand Down
Loading

0 comments on commit 4bbfd40

Please sign in to comment.