mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-27 07:50:47 +00:00
3ed45d1efd
* fix(datasource): replace getJsonUnchecked with validated getJson in misc+merge-confidence group Replaces all getJsonUnchecked calls with Zod-validated getJson calls in: - crate: adds CrateMetadataSchema to existing schema.ts - conan: uses existing ConanJSON schema directly - puppet-forge: new schema.ts with PuppetModuleSchema - conda: new schema.ts with CondaPackageSchema - repology: new schema.ts with RepologyPackagesSchema - jenkins-plugins: new schema.ts, parameterizes helper with ZodType<T> - custom/formats/json: uses z.unknown() for user-defined responses - merge-confidence: adds inline MergeConfidenceResponseSchema Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: correct nullable/optional schema fields for crate, jenkins-plugins, puppet-forge - crate: remove .optional() from all CrateMetadata fields to match string|null type - jenkins-plugins: use .default({}) instead of .optional() for plugins fields so schemas match required Record types; widen ZodType input to unknown; update JenkinsPluginVersion.releaseTimestamp to Timestamp|null to match MaybeTimestamp output - puppet-forge: change releases from .optional() to .default([]) to match Release[] type Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: migrate zod/v3 imports to zod/v4 in misc datasources and merge-confidence Update remaining zod/v3 imports in files added/modified by the getJsonUnchecked migration to use zod/v4 as required after the upstream migration. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore minor improvements * remove unnecessary types and reintroduce nullable where necessary * refactor: move logic into transform * test: add tests to improve coverage * chore removed some unused types * remove type declaration --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { Datasource } from '../datasource.ts';
|
|
import type { GetReleasesConfig, ReleaseResult } from '../types.ts';
|
|
import { PUPPET_FORGE } from './common.ts';
|
|
import { PuppetModule } from './schema.ts';
|
|
|
|
export class PuppetForgeDatasource extends Datasource {
|
|
static id = 'puppet-forge';
|
|
|
|
constructor() {
|
|
super(PuppetForgeDatasource.id);
|
|
}
|
|
|
|
override readonly defaultRegistryUrls = [PUPPET_FORGE];
|
|
|
|
override readonly releaseTimestampSupport = true;
|
|
override readonly releaseTimestampNote =
|
|
'The release timestamp is determined from the `created_at` field from the response.';
|
|
|
|
async getReleases({
|
|
packageName,
|
|
registryUrl,
|
|
}: GetReleasesConfig): Promise<ReleaseResult | null> {
|
|
// https://forgeapi.puppet.com
|
|
const moduleSlug = packageName.replace('/', '-');
|
|
const url = `${registryUrl}/v3/modules/${moduleSlug}?exclude_fields=current_release`;
|
|
|
|
let result: ReleaseResult;
|
|
|
|
try {
|
|
const response = await this.http.getJson(url, PuppetModule);
|
|
result = response.body;
|
|
} catch (err) {
|
|
this.handleGenericErrors(err);
|
|
}
|
|
|
|
if (!result.releases.length) {
|
|
return null;
|
|
}
|
|
|
|
for (const release of result.releases) {
|
|
release.registryUrl = registryUrl;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|