Skip to content

Commit

Permalink
fix(hex): Relax case in typing of schema (#32963)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergei Zharinov <[email protected]>
  • Loading branch information
bernardo-martinez and zharinov authored Dec 8, 2024
1 parent 9c29755 commit 464dcc3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lib/modules/datasource/hex/__fixtures__/private_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"licenses": [
"MIT"
],
"links": {},
"links": {
"GitHub": "https://github.com/renovate_test/private_package"
},
"maintainers": []
},
"name": "private_package",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
`;

Expand Down
1 change: 1 addition & 0 deletions lib/modules/datasource/hex/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
22 changes: 17 additions & 5 deletions lib/modules/datasource/hex/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 464dcc3

Please sign in to comment.