mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
feat(datasource/conda): support custom registries (#17809)
This commit is contained in:
parent
87910eb417
commit
699a5cf8a6
3 changed files with 58 additions and 5 deletions
|
@ -3,7 +3,7 @@
|
|||
exports[`modules/datasource/conda/index getReleases processes real data 1`] = `
|
||||
{
|
||||
"homepage": "http://anaconda.org/anaconda/pytest",
|
||||
"registryUrl": "https://api.anaconda.org/package/",
|
||||
"registryUrl": "https://api.anaconda.org/package",
|
||||
"releases": [
|
||||
{
|
||||
"version": "2.3.3",
|
||||
|
|
|
@ -3,6 +3,7 @@ import { Fixtures } from '../../../../test/fixtures';
|
|||
import * as httpMock from '../../../../test/http-mock';
|
||||
import { EXTERNAL_HOST_ERROR } from '../../../constants/error-messages';
|
||||
import { datasource, defaultRegistryUrl } from './common';
|
||||
import { CondaDatasource } from './index';
|
||||
|
||||
const depName = 'main/pytest';
|
||||
const depUrl = `/${depName}`;
|
||||
|
@ -61,5 +62,52 @@ describe('modules/datasource/conda/index', () => {
|
|||
expect(res).toMatchSnapshot();
|
||||
expect(res?.releases).toHaveLength(94);
|
||||
});
|
||||
|
||||
it('returns null without registryUrl', async () => {
|
||||
const condaDatasource = new CondaDatasource();
|
||||
const res = await condaDatasource.getReleases({
|
||||
registryUrl: '',
|
||||
packageName: depName,
|
||||
});
|
||||
expect(res).toBeNull();
|
||||
});
|
||||
|
||||
it('supports multiple custom datasource urls', async () => {
|
||||
const depName = 'pytest';
|
||||
httpMock
|
||||
.scope('https://api.anaconda.org/package/rapids')
|
||||
.get(`/${depName}`)
|
||||
.reply(404);
|
||||
httpMock
|
||||
.scope('https://api.anaconda.org/package/conda-forge')
|
||||
.get(`/${depName}`)
|
||||
.reply(200, {
|
||||
html_url: 'http://anaconda.org/anaconda/pytest',
|
||||
dev_url: 'https://github.com/pytest-dev/pytest/',
|
||||
versions: ['2.7.0', '2.5.1', '2.6.0'],
|
||||
});
|
||||
const config = {
|
||||
registryUrls: [
|
||||
'https://api.anaconda.org/package/rapids',
|
||||
'https://api.anaconda.org/package/conda-forge',
|
||||
'https://api.anaconda.org/package/nvidia',
|
||||
],
|
||||
};
|
||||
const res = await getPkgReleases({
|
||||
...config,
|
||||
datasource,
|
||||
depName,
|
||||
});
|
||||
expect(res).toMatchObject({
|
||||
homepage: 'http://anaconda.org/anaconda/pytest',
|
||||
registryUrl: 'https://api.anaconda.org/package/conda-forge',
|
||||
releases: [
|
||||
{ version: '2.5.1' },
|
||||
{ version: '2.6.0' },
|
||||
{ version: '2.7.0' },
|
||||
],
|
||||
sourceUrl: 'https://github.com/pytest-dev/pytest',
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,6 +2,7 @@ import { logger } from '../../../logger';
|
|||
import { ExternalHostError } from '../../../types/errors/external-host-error';
|
||||
import { cache } from '../../../util/cache/package/decorator';
|
||||
import { HttpError } from '../../../util/http';
|
||||
import { joinUrlParts } from '../../../util/url';
|
||||
import { Datasource } from '../datasource';
|
||||
import type { GetReleasesConfig, Release, ReleaseResult } from '../types';
|
||||
import { datasource, defaultRegistryUrl } from './common';
|
||||
|
@ -14,7 +15,9 @@ export class CondaDatasource extends Datasource {
|
|||
super(datasource);
|
||||
}
|
||||
|
||||
override readonly customRegistrySupport = false;
|
||||
override readonly customRegistrySupport = true;
|
||||
|
||||
override readonly registryStrategy = 'hunt';
|
||||
|
||||
override readonly defaultRegistryUrls = [defaultRegistryUrl];
|
||||
|
||||
|
@ -33,9 +36,11 @@ export class CondaDatasource extends Datasource {
|
|||
}: GetReleasesConfig): Promise<ReleaseResult | null> {
|
||||
logger.trace({ registryUrl, packageName }, 'fetching conda package');
|
||||
|
||||
// TODO: types (#7154)
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
const url = `${registryUrl}${packageName}`;
|
||||
if (!registryUrl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const url = joinUrlParts(registryUrl, packageName);
|
||||
|
||||
const result: ReleaseResult = {
|
||||
releases: [],
|
||||
|
|
Loading…
Reference in a new issue