mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 07:50:47 +00:00
a473e73b3e
Adds a custom oxlint rule renovate/v8-ignore-no-count that flags the count form '/* v8 ignore next <N> */'. The count is not honored by vitest's ast-v8-to-istanbul hint parser, which captures only the keyword (if/else/next/file); 'next' always exempts exactly the next AST node. Trailing counts therefore suggest a line range that is never applied and mislead readers. The rule is autofixable (drops the count, preserving actual behavior) and has been applied to all existing occurrences.
69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
import { logger } from '../../../logger/index.ts';
|
|
import * as nugetVersioning from '../../versioning/nuget/index.ts';
|
|
import { Datasource } from '../datasource.ts';
|
|
import type { GetReleasesConfig, ReleaseResult } from '../types.ts';
|
|
import { isCrossOriginPaginationAllowed } from '../util.ts';
|
|
import { parseRegistryUrl } from './common.ts';
|
|
import { NugetV2Api } from './v2.ts';
|
|
import { NugetV3Api } from './v3.ts';
|
|
|
|
// https://api.nuget.org/v3/index.json is a default official nuget feed
|
|
export const nugetOrg = 'https://api.nuget.org/v3/index.json';
|
|
|
|
export class NugetDatasource extends Datasource {
|
|
static readonly id = 'nuget';
|
|
|
|
override readonly defaultRegistryUrls = [nugetOrg];
|
|
|
|
override readonly defaultVersioning = nugetVersioning.id;
|
|
|
|
override readonly registryStrategy = 'merge';
|
|
|
|
override readonly releaseTimestampSupport = true;
|
|
override readonly releaseTimestampNote =
|
|
'For the v2 API, the release timestamp is determined from the `Published` tag. And, for the v3 API, the release timestamp is determined from the `published` field in the results.';
|
|
override readonly sourceUrlSupport = 'package';
|
|
override readonly sourceUrlNote =
|
|
'For the v2 API, the source URL is determined from the `ProjectUrl` tag. And, for the v3 API, the source URL is determined from the `metadata.repository@url` field in the results.';
|
|
|
|
readonly v2Api = new NugetV2Api();
|
|
|
|
readonly v3Api = new NugetV3Api();
|
|
|
|
constructor() {
|
|
super(NugetDatasource.id);
|
|
}
|
|
|
|
async getReleases({
|
|
packageName,
|
|
registryUrl,
|
|
}: GetReleasesConfig): Promise<ReleaseResult | null> {
|
|
logger.trace(`nuget.getReleases(${packageName})`);
|
|
/* v8 ignore next -- should never happen */
|
|
if (!registryUrl) {
|
|
return null;
|
|
}
|
|
const { feedUrl, protocolVersion } = parseRegistryUrl(registryUrl);
|
|
if (protocolVersion === 2) {
|
|
return this.v2Api.getReleases(
|
|
this.http,
|
|
feedUrl,
|
|
packageName,
|
|
isCrossOriginPaginationAllowed(NugetDatasource.id),
|
|
);
|
|
}
|
|
if (protocolVersion === 3) {
|
|
const queryUrl = await this.v3Api.getResourceUrl(this.http, feedUrl);
|
|
if (queryUrl) {
|
|
return this.v3Api.getReleases(
|
|
this.http,
|
|
feedUrl,
|
|
queryUrl,
|
|
packageName,
|
|
);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|