mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-26 07:20:39 +00:00
a53aaf4141
* refactor(java-version): extract adoptium HTTP logic from datasource class Move getPageReleases and the Adoptium fetch logic out of the JavaVersionDatasource class into a standalone adoptium.ts module. This makes the code easier to test in isolation and decouples Adoptium-specific logic from the datasource class. No behavior change — customRegistrySupport remains false, and the hardcoded adoptiumRegistryUrl replaces the previously injected defaultRegistryUrl (which was always the same value). * fix(java-version): remove unused adoptiumRegistryUrl import from test * test(java-version): use partial helper in spec * refactor(java-version): extract adoptium HTTP logic from datasource class * fix(java-version): pass Adoptium schema to HTTP client * test(java-version): move Adoptium test to module spec * chore(ci): retrigger failed checks
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { logger } from '../../../logger/index.ts';
|
|
import { withCache } from '../../../util/cache/package/with-cache.ts';
|
|
import { Datasource } from '../datasource.ts';
|
|
import type { GetReleasesConfig, ReleaseResult } from '../types.ts';
|
|
import { adoptiumRegistryUrl, getAdoptiumReleases } from './adoptium.ts';
|
|
import { datasource, parsePackage } from './common.ts';
|
|
|
|
export class JavaVersionDatasource extends Datasource {
|
|
static readonly id = datasource;
|
|
|
|
constructor() {
|
|
super(datasource);
|
|
}
|
|
|
|
override readonly customRegistrySupport = false;
|
|
|
|
override readonly defaultRegistryUrls = [adoptiumRegistryUrl];
|
|
|
|
override readonly caching = true;
|
|
|
|
private async _getReleases({
|
|
packageName,
|
|
}: GetReleasesConfig): Promise<ReleaseResult | null> {
|
|
const pkgConfig = parsePackage(packageName);
|
|
logger.trace({ packageName, pkgConfig }, 'fetching java release');
|
|
|
|
try {
|
|
return await getAdoptiumReleases(this.http, pkgConfig);
|
|
} catch (err) {
|
|
this.handleGenericErrors(err);
|
|
}
|
|
}
|
|
|
|
getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {
|
|
return withCache(
|
|
{
|
|
namespace: `datasource-${datasource}`,
|
|
key: `${config.registryUrl}:${config.packageName}`,
|
|
fallback: true,
|
|
},
|
|
() => this._getReleases(config),
|
|
);
|
|
}
|
|
}
|