Skip to content

Commit

Permalink
refactor!: use packageName and not depName for datasource lookups (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 23, 2023
1 parent 9fbe4a2 commit 0592942
Show file tree
Hide file tree
Showing 73 changed files with 704 additions and 678 deletions.
4 changes: 1 addition & 3 deletions lib/modules/datasource/artifactory/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const testRegistryUrl = 'https://jfrog.company.com/artifactory';
const testLookupName = 'project';
const testConfig = {
registryUrls: [testRegistryUrl],
depName: testLookupName,
packageName: testLookupName,
};
const fixtureReleasesAsFolders = Fixtures.get('releases-as-folders.html');
const fixtureReleasesAsFiles = Fixtures.get('releases-as-files.html');
Expand Down Expand Up @@ -70,7 +70,6 @@ describe('modules/datasource/artifactory/index', () => {
.reply(200, '<html>\n<h1>Header</h1>\n<a>1.3.0</a>\n<hmtl/>');
const res = await getPkgReleases({
registryUrls: [testRegistryUrl, secondRegistryUrl],
depName: testLookupName,
datasource,
packageName: testLookupName,
});
Expand All @@ -81,7 +80,6 @@ describe('modules/datasource/artifactory/index', () => {
it('returns null without registryUrl + warning', async () => {
const res = await getPkgReleases({
datasource,
depName: testLookupName,
packageName: testLookupName,
});
expect(logger.warn).toHaveBeenCalledTimes(1);
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/artifactory/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Artifactory is the recommended registry for Conan packages.

This datasource returns releases from given custom `registryUrl`(s).

The target URL is composed by the `registryUrl` and the `packageName`, which defaults to `depName` when `packageName` is not defined.
The target URL is composed by the `registryUrl` and the `packageName`.

The release timestamp is taken from the date in the directory listing, and is assumed to be in UTC time.
18 changes: 9 additions & 9 deletions lib/modules/datasource/aws-machine-image/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ describe('modules/datasource/aws-machine-image/index', () => {
mockDescribeImagesCommand(mockEmpty);
const res = await getDigest({
datasource,
depName:
packageName:
'[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["without newValue, without returned images to be null"]}]',
});
expect(res).toBeNull();
Expand All @@ -286,7 +286,7 @@ describe('modules/datasource/aws-machine-image/index', () => {
mockDescribeImagesCommand(mock1Image);
const res = await getDigest({
datasource,
depName:
packageName:
'[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["without newValue, with one matching image to return that image"]}]',
});
expect(res).toStrictEqual(image3.Name);
Expand All @@ -296,7 +296,7 @@ describe('modules/datasource/aws-machine-image/index', () => {
mockDescribeImagesCommand(mock3Images);
const res = await getDigest({
datasource,
depName:
packageName:
'[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["without newValue, with 3 matching image to return the newest image"]}]',
});
expect(res).toStrictEqual(image3.Name);
Expand All @@ -307,7 +307,7 @@ describe('modules/datasource/aws-machine-image/index', () => {
const res = await getDigest(
{
datasource,
depName:
packageName:
'[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["with matching newValue, with 3 matching image to return the matching image"]}]',
},
image1.ImageId
Expand All @@ -320,7 +320,7 @@ describe('modules/datasource/aws-machine-image/index', () => {
const res = await getDigest(
{
datasource,
depName:
packageName:
'[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["with not matching newValue, with 3 matching images to return the matching image"]}]',
},
'will never match'
Expand All @@ -334,7 +334,7 @@ describe('modules/datasource/aws-machine-image/index', () => {
mockDescribeImagesCommand(mockEmpty);
const res = await getPkgReleases({
datasource,
depName:
packageName:
'[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["without returned images to be null"]}]',
});
expect(res).toBeNull();
Expand All @@ -344,7 +344,7 @@ describe('modules/datasource/aws-machine-image/index', () => {
mockDescribeImagesCommand(mock1Image);
const res = await getPkgReleases({
datasource,
depName:
packageName:
'[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["with one matching image to return that image"]}]',
});
expect(res).toStrictEqual({
Expand All @@ -363,7 +363,7 @@ describe('modules/datasource/aws-machine-image/index', () => {
mockDescribeImagesCommand({ Images: [image2] });
const res = await getPkgReleases({
datasource,
depName:
packageName:
'[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["with one deprecated matching image to return that image"]}]',
});
expect(res).toStrictEqual({
Expand All @@ -382,7 +382,7 @@ describe('modules/datasource/aws-machine-image/index', () => {
mockDescribeImagesCommand(mock3Images);
const res = await getPkgReleases({
datasource,
depName:
packageName:
'[{"Name":"owner-id","Values":["602401143452"]},{"Name":"name","Values":["with 3 matching image to return the newest image"]}]',
});
expect(res).toStrictEqual({
Expand Down
6 changes: 3 additions & 3 deletions lib/modules/datasource/aws-rds/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('modules/datasource/aws-rds/index', () => {
});
const res = await getPkgReleases({
datasource: AwsRdsDataSource.id,
depName: '[{"Name":"engine","Values":["mysql"]}]',
packageName: '[{"Name":"engine","Values":["mysql"]}]',
});
expect(res).toBeNull();
});
Expand All @@ -117,7 +117,7 @@ describe('modules/datasource/aws-rds/index', () => {
});
const res = await getPkgReleases({
datasource: AwsRdsDataSource.id,
depName: '[{"Name":"engine","Values":["mysql"]}]',
packageName: '[{"Name":"engine","Values":["mysql"]}]',
});
expect(res).toStrictEqual({
releases: [
Expand All @@ -136,7 +136,7 @@ describe('modules/datasource/aws-rds/index', () => {
});
const res = await getPkgReleases({
datasource: AwsRdsDataSource.id,
depName: '[{"Name":"engine","Values":["mysql"]}]',
packageName: '[{"Name":"engine","Values":["mysql"]}]',
});
expect(res).toStrictEqual({
releases: [
Expand Down
8 changes: 4 additions & 4 deletions lib/modules/datasource/azure-pipelines-tasks/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('modules/datasource/azure-pipelines-tasks/index', () => {
expect(
await getPkgReleases({
datasource: AzurePipelinesTasksDatasource.id,
depName: 'unknown',
packageName: 'unknown',
})
).toBeNull();
});
Expand All @@ -15,7 +15,7 @@ describe('modules/datasource/azure-pipelines-tasks/index', () => {
expect(
await getPkgReleases({
datasource: AzurePipelinesTasksDatasource.id,
depName: 'AutomatedAnalysis',
packageName: 'AutomatedAnalysis',
})
).toEqual({ releases: [{ version: '0.171.0' }, { version: '0.198.0' }] });
});
Expand All @@ -24,7 +24,7 @@ describe('modules/datasource/azure-pipelines-tasks/index', () => {
expect(
await getPkgReleases({
datasource: AzurePipelinesTasksDatasource.id,
depName: 'AutomatedAnalysis-Marketplace',
packageName: 'AutomatedAnalysis-Marketplace',
})
).toEqual({ releases: [{ version: '0.171.0' }, { version: '0.198.0' }] });
});
Expand All @@ -33,7 +33,7 @@ describe('modules/datasource/azure-pipelines-tasks/index', () => {
expect(
await getPkgReleases({
datasource: AzurePipelinesTasksDatasource.id,
depName: 'automatedanalysis',
packageName: 'automatedanalysis',
})
).toEqual({ releases: [{ version: '0.171.0' }, { version: '0.198.0' }] });
});
Expand Down
8 changes: 4 additions & 4 deletions lib/modules/datasource/bitbucket-tags/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('modules/datasource/bitbucket-tags/index', () => {
.reply(200, body);
const res = await getPkgReleases({
datasource,
depName: 'some/dep2',
packageName: 'some/dep2',
});
expect(res).toMatchSnapshot();
expect(res?.releases).toHaveLength(3);
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('modules/datasource/bitbucket-tags/index', () => {
.reply(200, body);
const res = await getDigest({
datasource,
depName: 'some/dep2',
packageName: 'some/dep2',
});
expect(res).toMatchSnapshot();
expect(res).toBeString();
Expand All @@ -94,7 +94,7 @@ describe('modules/datasource/bitbucket-tags/index', () => {
.reply(200, body);
const res = await getDigest({
datasource,
depName: 'some/dep2',
packageName: 'some/dep2',
});
expect(res).toBeNull();
});
Expand All @@ -116,7 +116,7 @@ describe('modules/datasource/bitbucket-tags/index', () => {
const res = await getDigest(
{
datasource,
depName: 'some/dep2',
packageName: 'some/dep2',
},
'v1.0.0'
);
Expand Down
20 changes: 10 additions & 10 deletions lib/modules/datasource/cdnjs/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('modules/datasource/cdnjs/index', () => {
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
depName: 'foo/bar',
packageName: 'foo/bar',
})
).rejects.toThrow(EXTERNAL_HOST_ERROR);
});
Expand All @@ -28,7 +28,7 @@ describe('modules/datasource/cdnjs/index', () => {
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
depName: 'foo/bar',
packageName: 'foo/bar',
})
).rejects.toThrow(EXTERNAL_HOST_ERROR);
});
Expand All @@ -38,7 +38,7 @@ describe('modules/datasource/cdnjs/index', () => {
expect(
await getPkgReleases({
datasource: CdnJsDatasource.id,
depName: 'foo/bar',
packageName: 'foo/bar',
})
).toBeNull();
});
Expand All @@ -51,7 +51,7 @@ describe('modules/datasource/cdnjs/index', () => {
expect(
await getPkgReleases({
datasource: CdnJsDatasource.id,
depName: 'doesnotexist/doesnotexist',
packageName: 'doesnotexist/doesnotexist',
})
).toBeNull();
});
Expand All @@ -61,7 +61,7 @@ describe('modules/datasource/cdnjs/index', () => {
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
depName: 'foo/bar',
packageName: 'foo/bar',
})
).rejects.toThrow(EXTERNAL_HOST_ERROR);
});
Expand All @@ -71,7 +71,7 @@ describe('modules/datasource/cdnjs/index', () => {
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
depName: 'foo/bar',
packageName: 'foo/bar',
})
).rejects.toThrow(EXTERNAL_HOST_ERROR);
});
Expand All @@ -81,7 +81,7 @@ describe('modules/datasource/cdnjs/index', () => {
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
depName: 'foo/bar',
packageName: 'foo/bar',
})
).rejects.toThrow(EXTERNAL_HOST_ERROR);
});
Expand All @@ -91,7 +91,7 @@ describe('modules/datasource/cdnjs/index', () => {
await expect(
getPkgReleases({
datasource: CdnJsDatasource.id,
depName: 'foo/bar',
packageName: 'foo/bar',
})
).rejects.toThrow(EXTERNAL_HOST_ERROR);
});
Expand All @@ -103,7 +103,7 @@ describe('modules/datasource/cdnjs/index', () => {
.reply(200, Fixtures.get('d3-force.json'));
const res = await getPkgReleases({
datasource: CdnJsDatasource.id,
depName: 'd3-force/d3-force.js',
packageName: 'd3-force/d3-force.js',
});
expect(res).toMatchSnapshot();
});
Expand All @@ -115,7 +115,7 @@ describe('modules/datasource/cdnjs/index', () => {
.reply(200, Fixtures.get('bulma.json'));
const res = await getPkgReleases({
datasource: CdnJsDatasource.id,
depName: 'bulma/only/0.7.5/style.css',
packageName: 'bulma/only/0.7.5/style.css',
});
expect(res).toMatchSnapshot();
});
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/datasource/clojure/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ function mockGenericPackage(opts: MockOpts = {}) {
}
}
function get(
depName = 'org.example:package',
packageName = 'org.example:package',
...registryUrls: string[]
): Promise<ReleaseResult | null> {
const conf = { versioning, datasource: ClojureDatasource.id, depName };
const conf = { versioning, datasource: ClojureDatasource.id, packageName };
return getPkgReleases(registryUrls ? { ...conf, registryUrls } : conf);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/datasource/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export function isGetPkgReleasesConfig(
): input is GetPkgReleasesConfig {
return (
(input as GetPkgReleasesConfig).datasource !== undefined &&
(input as GetPkgReleasesConfig).depName !== undefined
(input as GetPkgReleasesConfig).packageName !== undefined
);
}
4 changes: 2 additions & 2 deletions lib/modules/datasource/conan/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const conanDatasourceRegex = regEx(
);

export function getConanPackage(packageName: string): ConanPackage {
const depName = packageName.split('/')[0];
const conanName = packageName.split('/')[0];
const userAndChannel = packageName.split('@')[1];
return { depName, userAndChannel };
return { conanName, userAndChannel };
}
Loading

0 comments on commit 0592942

Please sign in to comment.