Skip to content
Snippets Groups Projects
Commit 00de6f2e authored by Rhys Arkins's avatar Rhys Arkins
Browse files

feat: datasource manual source URLs

Adds central location to define manual source URLs for packages.
parent 0f0bae4b
No related merge requests found
......@@ -20,6 +20,8 @@ const datasources = {
terraform,
};
// Use this object to define changelog URLs for packages
// Only necessary when the changelog data cannot be found in the package's source repository
const manualChangelogUrls = {
npm: {
firebase: 'https://firebase.google.com/support/release-notes/js',
......@@ -46,6 +48,23 @@ const manualChangelogUrls = {
},
};
// Use this object to define manual source URLs for packages
// Only necessary if the datasource is unable to locate the source URL itself
const manualSourceUrls = {
docker: {
node: 'https://github.com/nodejs/node',
},
kubernetes: {
node: 'https://github.com/nodejs/node',
},
npm: {
node: 'https://github.com/nodejs/node',
},
nvm: {
node: 'https://github.com/nodejs/node',
},
};
async function getPkgReleases(purlStr, config) {
const purl = parse(purlStr);
if (!purl) {
......@@ -64,6 +83,12 @@ async function getPkgReleases(purlStr, config) {
res.changelogUrl =
manualChangelogUrls[purl.type][purl.fullname.toLowerCase()];
}
if (
manualSourceUrls[purl.type] &&
manualSourceUrls[purl.type][purl.fullname.toLowerCase()]
) {
res.sourceUrl = manualSourceUrls[purl.type][purl.fullname.toLowerCase()];
}
if (
!res.sourceUrl &&
res.changelogUrl &&
......
......@@ -6,3 +6,9 @@ Object {
"sourceUrl": "https://github.com/react-native-community/react-native-releases",
}
`;
exports[`datasource/index adds sourceUrl 1`] = `
Object {
"sourceUrl": "https://github.com/nodejs/node",
}
`;
......@@ -20,4 +20,10 @@ describe('datasource/index', () => {
expect(res.changelogUrl).toBeDefined();
expect(res.sourceUrl).toBeDefined();
});
it('adds sourceUrl', async () => {
npmDatasource.getPkgReleases.mockReturnValue({});
const res = await datasource.getPkgReleases('pkg:npm/node');
expect(res).toMatchSnapshot();
expect(res.sourceUrl).toBeDefined();
});
});
......@@ -88,7 +88,7 @@ Object {
"version": "8.1.0",
},
],
"sourceUrl": null,
"sourceUrl": "https://github.com/nodejs/node",
"updates": Array [
Object {
"blockedByPin": true,
......@@ -134,7 +134,7 @@ Object {
"changelogUrl": undefined,
"homepage": undefined,
"releases": Array [],
"sourceUrl": null,
"sourceUrl": "https://github.com/nodejs/node",
"updates": Array [
Object {
"newDigest": "sha256:abcdef1234567890",
......@@ -159,7 +159,7 @@ Object {
"version": "8.1.0",
},
],
"sourceUrl": null,
"sourceUrl": "https://github.com/nodejs/node",
"updates": Array [
Object {
"canBeUnpublished": undefined,
......@@ -859,7 +859,7 @@ Object {
"version": "9",
},
],
"sourceUrl": null,
"sourceUrl": "https://github.com/nodejs/node",
"updates": Array [
Object {
"canBeUnpublished": undefined,
......@@ -893,7 +893,7 @@ Object {
"version": "9.0",
},
],
"sourceUrl": null,
"sourceUrl": "https://github.com/nodejs/node",
"updates": Array [
Object {
"canBeUnpublished": undefined,
......@@ -942,7 +942,7 @@ Object {
"version": "8.2.5",
},
],
"sourceUrl": null,
"sourceUrl": "https://github.com/nodejs/node",
"updates": Array [
Object {
"canBeUnpublished": undefined,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment