Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(datasource/cpan): populate latest tag #32677

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
12 changes: 11 additions & 1 deletion lib/modules/datasource/cpan/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@ describe('modules/datasource/cpan/index', () => {
(body) =>
body.query.filtered.filter.and[0].term['module.name'] === 'Plack',
)
.reply(200, Fixtures.get('Plack.json'));
.reply(200, Fixtures.get('Plack.json'))
.get('/v1/module/Plack')
.reply(200, {
module: [
{
name: 'Plack',
version: '1.0048',
},
],
});
const res = await getPkgReleases({
datasource: CpanDatasource.id,
packageName: 'Plack',
Expand All @@ -86,6 +95,7 @@ describe('modules/datasource/cpan/index', () => {
releaseTimestamp: '2020-11-30T00:21:36.000Z',
version: '1.0048',
});
expect(res?.tags?.latest).toBe('1.0048');
});
});
});
15 changes: 15 additions & 0 deletions lib/modules/datasource/cpan/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ export class CpanDatasource extends Datasource {
changelogUrl: `https://metacpan.org/dist/${latestDistribution}/changes`,
homepage: `https://metacpan.org/pod/${packageName}`,
};

const latestVersionUrl = joinUrlParts(
registryUrl,
'v1/module/',
packageName,
);
const latestVersionRes = (
await this.http.getJson<MetaCpanApiFile>(latestVersionUrl)
).body;
const latestVersion = latestVersionRes.module[0].version;
RahulGautamSingh marked this conversation as resolved.
Show resolved Hide resolved

if (latestVersion) {
result.tags ??= {};
result.tags.latest ??= latestVersion;
}
}
}
return result;
Expand Down