Skip to content

Commit

Permalink
feat(datasource/custom): expose tags in result so that we can use `…
Browse files Browse the repository at this point in the history
…followTag` (#29806)
  • Loading branch information
leonismoe committed Jun 24, 2024
1 parent 1c3dbca commit 48e6aa4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
43 changes: 43 additions & 0 deletions lib/modules/datasource/custom/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,49 @@ describe('modules/datasource/custom/index', () => {
expect(result).toEqual(expected);
});

it('return releases with tags and other optional fields for api directly exposing in renovate format', async () => {
const expected = {
releases: [
{
version: 'v1.0.0',
},
],
tags: {
latest: 'v1.0.0',
},
sourceUrl: 'https://example.com/foo.git',
sourceDirectory: '/',
changelogUrl: 'https://example.com/foo/blob/main/CHANGELOG.md',
homepage: 'https://example.com/foo',
};
const content = {
releases: [
{
version: 'v1.0.0',
},
],
tags: {
latest: 'v1.0.0',
},
sourceUrl: 'https://example.com/foo.git',
sourceDirectory: '/',
changelogUrl: 'https://example.com/foo/blob/main/CHANGELOG.md',
homepage: 'https://example.com/foo',
unknown: {},
};
httpMock.scope('https://example.com').get('/v1').reply(200, content);
const result = await getPkgReleases({
datasource: `${CustomDatasource.id}.foo`,
packageName: 'myPackage',
customDatasources: {
foo: {
defaultRegistryUrlTemplate: 'https://example.com/v1',
},
},
});
expect(result).toEqual(expected);
});

it('return releases for plain text API directly exposing in Renovate format', async () => {
const expected = {
releases: [
Expand Down
1 change: 1 addition & 0 deletions lib/modules/datasource/custom/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const ReleaseResultZodSchema = z.object({
};
}),
),
tags: z.record(z.string(), z.string()).optional(),
sourceUrl: z.string().optional(),
sourceDirectory: z.string().optional(),
changelogUrl: z.string().optional(),
Expand Down

0 comments on commit 48e6aa4

Please sign in to comment.