From 464dcc3b76f0df75c91264df073f308963949a95 Mon Sep 17 00:00:00 2001 From: Bernardo <37117272+bernardo-martinez@users.noreply.github.com> Date: Sun, 8 Dec 2024 17:35:11 +0100 Subject: [PATCH] fix(hex): Relax case in typing of schema (#32963) Co-authored-by: Sergei Zharinov --- .../hex/__fixtures__/private_package.json | 4 +++- .../hex/__snapshots__/index.spec.ts.snap | 1 + lib/modules/datasource/hex/index.spec.ts | 1 + lib/modules/datasource/hex/schema.ts | 22 ++++++++++++++----- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/modules/datasource/hex/__fixtures__/private_package.json b/lib/modules/datasource/hex/__fixtures__/private_package.json index 7ae091e20e2a49..b03d1e49edbda2 100644 --- a/lib/modules/datasource/hex/__fixtures__/private_package.json +++ b/lib/modules/datasource/hex/__fixtures__/private_package.json @@ -19,7 +19,9 @@ "licenses": [ "MIT" ], - "links": {}, + "links": { + "GitHub": "https://github.com/renovate_test/private_package" + }, "maintainers": [] }, "name": "private_package", diff --git a/lib/modules/datasource/hex/__snapshots__/index.spec.ts.snap b/lib/modules/datasource/hex/__snapshots__/index.spec.ts.snap index 08679d5bffbb36..c03ac339be668f 100644 --- a/lib/modules/datasource/hex/__snapshots__/index.spec.ts.snap +++ b/lib/modules/datasource/hex/__snapshots__/index.spec.ts.snap @@ -104,6 +104,7 @@ exports[`modules/datasource/hex/index getReleases processes a private repo with "version": "0.1.1", }, ], + "sourceUrl": "https://github.com/renovate_test/private_package", } `; diff --git a/lib/modules/datasource/hex/index.spec.ts b/lib/modules/datasource/hex/index.spec.ts index 6b762cd862d44f..49e01abacd41d9 100644 --- a/lib/modules/datasource/hex/index.spec.ts +++ b/lib/modules/datasource/hex/index.spec.ts @@ -168,6 +168,7 @@ describe('modules/datasource/hex/index', () => { expect(result).toEqual({ homepage: 'https://hex.pm/packages/renovate_test/private_package', + sourceUrl: 'https://github.com/renovate_test/private_package', registryUrl: 'https://hex.pm', releases: [ { releaseTimestamp: '2021-08-04T15:26:26.500Z', version: '0.1.0' }, diff --git a/lib/modules/datasource/hex/schema.ts b/lib/modules/datasource/hex/schema.ts index 6f5bd14b6d192b..a04aa81a49f399 100644 --- a/lib/modules/datasource/hex/schema.ts +++ b/lib/modules/datasource/hex/schema.ts @@ -8,9 +8,21 @@ export const HexRelease = z html_url: z.string().optional(), meta: z .object({ - links: z.object({ - Github: z.string(), - }), + links: z + .record(z.string()) + .transform((links) => + Object.fromEntries( + Object.entries(links).map(([key, value]) => [ + key.toLowerCase(), + value, + ]), + ), + ) + .pipe( + z.object({ + github: z.string(), + }), + ), }) .nullable() .catch(null), @@ -53,8 +65,8 @@ export const HexRelease = z releaseResult.homepage = hexResponse.html_url; } - if (hexResponse.meta?.links?.Github) { - releaseResult.sourceUrl = hexResponse.meta.links.Github; + if (hexResponse.meta?.links?.github) { + releaseResult.sourceUrl = hexResponse.meta.links.github; } return releaseResult;