feat: improve compatibility with nexus private npm repo (#1965)

as nexus hosted npm repository does not automatically 'extracts' any value from the published versions we have to manually pick the repository and namepage fields from the latest version if not already defined in the reponse root
This commit is contained in:
Marco Massarotto 2018-05-13 20:39:30 +01:00 committed by Rhys Arkins
parent 57552d5d2b
commit 4b5efca7a7

View file

@ -141,8 +141,14 @@ async function getDependency(name, retries = 5) {
await delay(5000 / retries); await delay(5000 / retries);
return getDependency(name, 0); return getDependency(name, 0);
} }
const latestVersion = res.versions[res['dist-tags'].latest];
res.repository = res.repository || latestVersion.repository;
res.homepage = res.homepage || latestVersion.homepage;
// Determine repository URL // Determine repository URL
let repositoryUrl; let repositoryUrl;
if (res.repository) { if (res.repository) {
repositoryUrl = parse(res.repository.url); repositoryUrl = parse(res.repository.url);
} }
@ -156,8 +162,7 @@ async function getDependency(name, retries = 5) {
repositoryUrl, repositoryUrl,
versions: res.versions, versions: res.versions,
'dist-tags': res['dist-tags'], 'dist-tags': res['dist-tags'],
'renovate-config': 'renovate-config': latestVersion['renovate-config'],
res.versions[res['dist-tags'].latest]['renovate-config'],
}; };
Object.keys(dep.versions).forEach(version => { Object.keys(dep.versions).forEach(version => {
// We don't use any of the version payload currently // We don't use any of the version payload currently