mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 15:01:49 +00:00
fc57966a6e
* fix(datasource): document `first` as the default registry strategy The `hunt` JSDoc claimed to be the default for an undefined `registryStrategy`, but the `Datasource` base class sets `first`, so the `?? 'hunt'` fallback in the registry was only reachable from a test double. Make the field required on `DatasourceApi`, move the "default" note to `first`, drop the fallback, and delete the five overrides that restated the base default. * test(datasource): set registryStrategy on the object-literal datasource doubles `registryStrategy` is required on `DatasourceApi` since this PR, and the two object-literal doubles added with the GraalVM datasource (#40497) did not set it, which failed the type check.
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { logger } from '../../../logger/index.ts';
|
|
import { ExternalHostError } from '../../../types/errors/external-host-error.ts';
|
|
import { HttpError } from '../../../util/http/index.ts';
|
|
import { joinUrlParts } from '../../../util/url.ts';
|
|
import * as devboxVersioning from '../../versioning/devbox/index.ts';
|
|
import { Datasource } from '../datasource.ts';
|
|
import type { GetReleasesConfig, ReleaseResult } from '../types.ts';
|
|
import { datasource, defaultRegistryUrl } from './common.ts';
|
|
import { DevboxResponse } from './schema.ts';
|
|
|
|
export class DevboxDatasource extends Datasource {
|
|
static readonly id = datasource;
|
|
|
|
constructor() {
|
|
super(datasource);
|
|
}
|
|
|
|
override supportsCustomRegistry(_packageName: string): boolean {
|
|
return true;
|
|
}
|
|
override readonly releaseTimestampSupport = true;
|
|
|
|
override readonly defaultVersioning = devboxVersioning.id;
|
|
|
|
override getDefaultRegistryUrls(_packageName: string): string[] {
|
|
return [defaultRegistryUrl];
|
|
}
|
|
|
|
async getReleases({
|
|
registryUrl,
|
|
packageName,
|
|
}: GetReleasesConfig): Promise<ReleaseResult | null> {
|
|
const res: ReleaseResult = {
|
|
releases: [],
|
|
};
|
|
|
|
logger.trace({ registryUrl, packageName }, 'fetching devbox release');
|
|
|
|
const devboxPkgUrl = joinUrlParts(
|
|
registryUrl!,
|
|
`/pkg?name=${encodeURIComponent(packageName)}`,
|
|
);
|
|
|
|
try {
|
|
const response = await this.http.getJson(devboxPkgUrl, DevboxResponse);
|
|
res.releases = response.body.releases;
|
|
res.homepage = response.body.homepage;
|
|
} catch (err) {
|
|
if (err instanceof HttpError && err.response?.statusCode !== 404) {
|
|
throw new ExternalHostError(err);
|
|
}
|
|
this.handleGenericErrors(err);
|
|
}
|
|
return res.releases.length ? res : null;
|
|
}
|
|
}
|