mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 15:01:49 +00:00
f64ec3975a
* refactor(datasource): separate registry URLs in cache keys with a colon Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io> Co-Authored-By: Claude Sonnet 5.5 <michael.kriese+claude-code@mend.io> * fix(datasource/go): separate the remaining cache key parts with a colon Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io> * refactor(datasource): build cache keys with a shared colon-joining helper Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io> * refactor: build all cache keys with buildCacheKey Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io> * refactor(http): keep GET package cache keys as the bare URL Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io> * refactor(cache): extend cache key helper to memory cache keys Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io> * refactor(datasource/go): prefix the goproxy cache keys with their purpose Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io> --------- Co-authored-by: Claude Opus 5.5 <michael.kriese+claude-code@mend.io>
67 lines
1.9 KiB
TypeScript
67 lines
1.9 KiB
TypeScript
import { asTimestamp } from '../../../util/timestamp.ts';
|
|
import { joinUrlParts } from '../../../util/url.ts';
|
|
import { id as versioning } from '../../versioning/node/index.ts';
|
|
import { Datasource } from '../datasource.ts';
|
|
import type { GetReleasesConfig, ReleaseResult } from '../types.ts';
|
|
import { datasource, defaultRegistryUrl } from './common.ts';
|
|
import { NodeReleases } from './schema.ts';
|
|
|
|
export class NodeVersionDatasource extends Datasource {
|
|
static readonly id = datasource;
|
|
|
|
constructor() {
|
|
super(datasource);
|
|
}
|
|
|
|
override getDefaultRegistryUrls(_packageName: string): string[] {
|
|
return [defaultRegistryUrl];
|
|
}
|
|
|
|
override readonly defaultVersioning = versioning;
|
|
|
|
override readonly releaseTimestampSupport = true;
|
|
override readonly releaseTimestampNote =
|
|
'The release timestamp is determined from the `date` field.';
|
|
override readonly sourceUrlSupport = 'package';
|
|
override readonly sourceUrlNote =
|
|
'We use the URL: https://github.com/nodejs/node';
|
|
|
|
private async fetchReleases({
|
|
registryUrl,
|
|
}: GetReleasesConfig): Promise<ReleaseResult | null> {
|
|
/* v8 ignore next -- should never happen */
|
|
if (!registryUrl) {
|
|
return null;
|
|
}
|
|
const result: ReleaseResult = {
|
|
homepage: 'https://nodejs.org',
|
|
sourceUrl: 'https://github.com/nodejs/node',
|
|
registryUrl,
|
|
releases: [],
|
|
};
|
|
const body = await this.fetchJson(
|
|
joinUrlParts(registryUrl, 'index.json'),
|
|
NodeReleases,
|
|
);
|
|
result.releases.push(
|
|
...body.map(({ version, date, lts }) => ({
|
|
version,
|
|
releaseTimestamp: asTimestamp(date),
|
|
isStable: lts !== false,
|
|
})),
|
|
);
|
|
|
|
return result.releases.length ? result : null;
|
|
}
|
|
|
|
getReleases(config: GetReleasesConfig): Promise<ReleaseResult | null> {
|
|
return this.cached(
|
|
{
|
|
key: config.registryUrl!,
|
|
fallback: true,
|
|
},
|
|
() => this.fetchReleases(config),
|
|
);
|
|
}
|
|
}
|