{"action":"created","comment":{"url":"https://api.github.com/repos/renovatebot/renovate/pulls/comments/244208273","pull_request_review_id":188155177,"id":244208273,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDIwODI3Mw==","diff_hunk":"@@ -0,0 +1,128 @@\n+const _ = require('lodash');\n+const got = require('got');\n+const url = require('url');\n+const fs = require('fs-extra');\n+const xmlParser = require('fast-xml-parser');\n+\n+module.exports = {\n+  getPkgReleases,\n+  resetCache,\n+};\n+\n+let map = new Map();\n+\n+function resetCache() {\n+  map = new Map();\n+}\n+\n+// eslint-disable-next-line no-unused-vars\n+async function getPkgReleases(purl, config) {\n+  const versions = [];\n+  const dependency = getDependencyParts(purl);\n+  const repositories = getRepositories(purl);\n+  logger.debug(\n+    `Found ${repositories.length} repositories for ${dependency.display}`\n+  );\n+  for (let i = 0; i < repositories.length; i += 1) {\n+    const repoUrl = repositories[i];\n+    logger.debug(\n+      `Looking up ${dependency.display} in repository #${i} - ${repoUrl}`\n+    );\n+    const mavenMetadata = await downloadMavenMetadata(dependency, repoUrl);\n+    if (mavenMetadata) {\n+      const newVersions = extractVersions(mavenMetadata).filter(\n+        version => !versions.includes(version)\n+      );\n+      versions.push(...newVersions);\n+      logger.debug(`Found ${newVersions.length} new versions for ${dependency.display} in repository ${repoUrl}`); // prettier-ignore\n+    }\n+  }\n+\n+  if (versions.length === 0) {\n+    logger.warn(`No versions found for ${dependency.display} in ${repositories.length} repositories`); // prettier-ignore\n+    return null;\n+  }\n+  logger.debug(`Found ${versions.length} versions for ${dependency.display}`);\n+\n+  return {\n+    ...dependency,\n+    releases: versions.map(v => ({ version: v })),\n+  };\n+}\n+\n+function getDependencyParts(purl) {\n+  return {\n+    display: `${purl.namespace}:${purl.name}`,\n+    group: purl.namespace,\n+    name: purl.name,\n+    version: purl.version,\n+    dependencyUrl: purl.namespace.replace(/\\./g, '/') + `/${purl.name}`,\n+  };\n+}\n+\n+function getRepositories(purl) {\n+  return purl.qualifiers.repository_url.split(',').map(url => {\n+    if (!url.endsWith('/')) {\n+      return url + '/';\n+    }\n+    return url;\n+  });\n+}\n+\n+async function downloadMavenMetadata(dependency, repoUrl) {\n+  const pkgUrl = new url.URL(\n+    `${dependency.dependencyUrl}/maven-metadata.xml`,\n+    repoUrl\n+  );\n+  let mavenMetadata;\n+  switch (pkgUrl.protocol) {\n+    case 'file:':\n+      mavenMetadata = await downloadFileProtocol(pkgUrl);\n+      break;\n+    case 'http:':\n+    case 'https:':\n+      mavenMetadata = await downloadHttpProtocol(pkgUrl);\n+      break;\n+    default:\n+      logger.error(\n+        `Invalid protocol ${pkgUrl.protocol} in repository ${repoUrl}`\n+      );\n+      return null;\n+  }\n+  if (!mavenMetadata) {\n+    logger.debug(`${dependency.display} not found in repository ${repoUrl}`);\n+  }\n+  return mavenMetadata;\n+}\n+\n+function extractVersions(mavenMetadata) {\n+  const doc = xmlParser.parse(mavenMetadata);","path":"lib/datasource/maven.js","position":99,"original_position":99,"commit_id":"f04800b3d3a1a6f145435a7d1029bee56c5cb54b","original_commit_id":"03446ec7e3bc02e6ab1f8298c6cebc2ee978e7ea","user":{"login":"corecanarias","id":2401444,"node_id":"MDQ6VXNlcjI0MDE0NDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2401444?v=4","gravatar_id":"","url":"https://api.github.com/users/corecanarias","html_url":"https://github.com/corecanarias","followers_url":"https://api.github.com/users/corecanarias/followers","following_url":"https://api.github.com/users/corecanarias/following{/other_user}","gists_url":"https://api.github.com/users/corecanarias/gists{/gist_id}","starred_url":"https://api.github.com/users/corecanarias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corecanarias/subscriptions","organizations_url":"https://api.github.com/users/corecanarias/orgs","repos_url":"https://api.github.com/users/corecanarias/repos","events_url":"https://api.github.com/users/corecanarias/events{/privacy}","received_events_url":"https://api.github.com/users/corecanarias/received_events","type":"User","site_admin":false},"body":"It doesn't throw any exception the returned document is empty which is handled by lodash","created_at":"2018-12-27T18:56:07Z","updated_at":"2018-12-27T18:56:08Z","html_url":"https://github.com/renovatebot/renovate/pull/2995#discussion_r244208273","pull_request_url":"https://api.github.com/repos/renovatebot/renovate/pulls/2995","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/renovatebot/renovate/pulls/comments/244208273"},"html":{"href":"https://github.com/renovatebot/renovate/pull/2995#discussion_r244208273"},"pull_request":{"href":"https://api.github.com/repos/renovatebot/renovate/pulls/2995"}},"in_reply_to_id":243823025},"pull_request":{"url":"https://api.github.com/repos/renovatebot/renovate/pulls/2995","id":240753872,"node_id":"MDExOlB1bGxSZXF1ZXN0MjQwNzUzODcy","html_url":"https://github.com/renovatebot/renovate/pull/2995","diff_url":"https://github.com/renovatebot/renovate/pull/2995.diff","patch_url":"https://github.com/renovatebot/renovate/pull/2995.patch","issue_url":"https://api.github.com/repos/renovatebot/renovate/issues/2995","number":2995,"state":"open","locked":false,"title":"feat: maven datasource (WIP)","user":{"login":"corecanarias","id":2401444,"node_id":"MDQ6VXNlcjI0MDE0NDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2401444?v=4","gravatar_id":"","url":"https://api.github.com/users/corecanarias","html_url":"https://github.com/corecanarias","followers_url":"https://api.github.com/users/corecanarias/followers","following_url":"https://api.github.com/users/corecanarias/following{/other_user}","gists_url":"https://api.github.com/users/corecanarias/gists{/gist_id}","starred_url":"https://api.github.com/users/corecanarias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corecanarias/subscriptions","organizations_url":"https://api.github.com/users/corecanarias/orgs","repos_url":"https://api.github.com/users/corecanarias/repos","events_url":"https://api.github.com/users/corecanarias/events{/privacy}","received_events_url":"https://api.github.com/users/corecanarias/received_events","type":"User","site_admin":false},"body":"<!--\r\n    Before submitting a Pull Request, please ensure you have signed the CLA using this GitHub App:\r\n    https://cla-assistant.io/renovateapp/renovate\r\n-->\r\n\r\nThis PR adds the maven repository to be used for java projects\r\n\r\nCloses #2985 <!-- Ideally each PR should be closing an open issue -->\r\n","created_at":"2018-12-24T10:28:19Z","updated_at":"2018-12-27T18:56:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0f01ec91af2e8d05f179d0adc0cfa5259275cf62","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/renovatebot/renovate/pulls/2995/commits","review_comments_url":"https://api.github.com/repos/renovatebot/renovate/pulls/2995/comments","review_comment_url":"https://api.github.com/repos/renovatebot/renovate/pulls/comments{/number}","comments_url":"https://api.github.com/repos/renovatebot/renovate/issues/2995/comments","statuses_url":"https://api.github.com/repos/renovatebot/renovate/statuses/f04800b3d3a1a6f145435a7d1029bee56c5cb54b","head":{"label":"corecanarias:only_maven_datasource","ref":"only_maven_datasource","sha":"f04800b3d3a1a6f145435a7d1029bee56c5cb54b","user":{"login":"corecanarias","id":2401444,"node_id":"MDQ6VXNlcjI0MDE0NDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2401444?v=4","gravatar_id":"","url":"https://api.github.com/users/corecanarias","html_url":"https://github.com/corecanarias","followers_url":"https://api.github.com/users/corecanarias/followers","following_url":"https://api.github.com/users/corecanarias/following{/other_user}","gists_url":"https://api.github.com/users/corecanarias/gists{/gist_id}","starred_url":"https://api.github.com/users/corecanarias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corecanarias/subscriptions","organizations_url":"https://api.github.com/users/corecanarias/orgs","repos_url":"https://api.github.com/users/corecanarias/repos","events_url":"https://api.github.com/users/corecanarias/events{/privacy}","received_events_url":"https://api.github.com/users/corecanarias/received_events","type":"User","site_admin":false},"repo":{"id":151704877,"node_id":"MDEwOlJlcG9zaXRvcnkxNTE3MDQ4Nzc=","name":"renovate","full_name":"corecanarias/renovate","private":false,"owner":{"login":"corecanarias","id":2401444,"node_id":"MDQ6VXNlcjI0MDE0NDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/2401444?v=4","gravatar_id":"","url":"https://api.github.com/users/corecanarias","html_url":"https://github.com/corecanarias","followers_url":"https://api.github.com/users/corecanarias/followers","following_url":"https://api.github.com/users/corecanarias/following{/other_user}","gists_url":"https://api.github.com/users/corecanarias/gists{/gist_id}","starred_url":"https://api.github.com/users/corecanarias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/corecanarias/subscriptions","organizations_url":"https://api.github.com/users/corecanarias/orgs","repos_url":"https://api.github.com/users/corecanarias/repos","events_url":"https://api.github.com/users/corecanarias/events{/privacy}","received_events_url":"https://api.github.com/users/corecanarias/received_events","type":"User","site_admin":false},"html_url":"https://github.com/corecanarias/renovate","description":"Multi-language dependency update automation. Flexible, so you don't need to be.","fork":true,"url":"https://api.github.com/repos/corecanarias/renovate","forks_url":"https://api.github.com/repos/corecanarias/renovate/forks","keys_url":"https://api.github.com/repos/corecanarias/renovate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/corecanarias/renovate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/corecanarias/renovate/teams","hooks_url":"https://api.github.com/repos/corecanarias/renovate/hooks","issue_events_url":"https://api.github.com/repos/corecanarias/renovate/issues/events{/number}","events_url":"https://api.github.com/repos/corecanarias/renovate/events","assignees_url":"https://api.github.com/repos/corecanarias/renovate/assignees{/user}","branches_url":"https://api.github.com/repos/corecanarias/renovate/branches{/branch}","tags_url":"https://api.github.com/repos/corecanarias/renovate/tags","blobs_url":"https://api.github.com/repos/corecanarias/renovate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/corecanarias/renovate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/corecanarias/renovate/git/refs{/sha}","trees_url":"https://api.github.com/repos/corecanarias/renovate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/corecanarias/renovate/statuses/{sha}","languages_url":"https://api.github.com/repos/corecanarias/renovate/languages","stargazers_url":"https://api.github.com/repos/corecanarias/renovate/stargazers","contributors_url":"https://api.github.com/repos/corecanarias/renovate/contributors","subscribers_url":"https://api.github.com/repos/corecanarias/renovate/subscribers","subscription_url":"https://api.github.com/repos/corecanarias/renovate/subscription","commits_url":"https://api.github.com/repos/corecanarias/renovate/commits{/sha}","git_commits_url":"https://api.github.com/repos/corecanarias/renovate/git/commits{/sha}","comments_url":"https://api.github.com/repos/corecanarias/renovate/comments{/number}","issue_comment_url":"https://api.github.com/repos/corecanarias/renovate/issues/comments{/number}","contents_url":"https://api.github.com/repos/corecanarias/renovate/contents/{+path}","compare_url":"https://api.github.com/repos/corecanarias/renovate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/corecanarias/renovate/merges","archive_url":"https://api.github.com/repos/corecanarias/renovate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/corecanarias/renovate/downloads","issues_url":"https://api.github.com/repos/corecanarias/renovate/issues{/number}","pulls_url":"https://api.github.com/repos/corecanarias/renovate/pulls{/number}","milestones_url":"https://api.github.com/repos/corecanarias/renovate/milestones{/number}","notifications_url":"https://api.github.com/repos/corecanarias/renovate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/corecanarias/renovate/labels{/name}","releases_url":"https://api.github.com/repos/corecanarias/renovate/releases{/id}","deployments_url":"https://api.github.com/repos/corecanarias/renovate/deployments","created_at":"2018-10-05T10:28:05Z","updated_at":"2018-11-05T09:22:16Z","pushed_at":"2018-12-27T18:52:36Z","git_url":"git://github.com/corecanarias/renovate.git","ssh_url":"git@github.com:corecanarias/renovate.git","clone_url":"https://github.com/corecanarias/renovate.git","svn_url":"https://github.com/corecanarias/renovate","homepage":"https://renovatebot.com","size":17123,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"renovatebot:master","ref":"master","sha":"b08b2f17d161a363feb7809a889fb8d4394fc116","user":{"login":"renovatebot","id":38656520,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4NjU2NTIw","avatar_url":"https://avatars2.githubusercontent.com/u/38656520?v=4","gravatar_id":"","url":"https://api.github.com/users/renovatebot","html_url":"https://github.com/renovatebot","followers_url":"https://api.github.com/users/renovatebot/followers","following_url":"https://api.github.com/users/renovatebot/following{/other_user}","gists_url":"https://api.github.com/users/renovatebot/gists{/gist_id}","starred_url":"https://api.github.com/users/renovatebot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renovatebot/subscriptions","organizations_url":"https://api.github.com/users/renovatebot/orgs","repos_url":"https://api.github.com/users/renovatebot/repos","events_url":"https://api.github.com/users/renovatebot/events{/privacy}","received_events_url":"https://api.github.com/users/renovatebot/received_events","type":"Organization","site_admin":false},"repo":{"id":76734068,"node_id":"MDEwOlJlcG9zaXRvcnk3NjczNDA2OA==","name":"renovate","full_name":"renovatebot/renovate","private":false,"owner":{"login":"renovatebot","id":38656520,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM4NjU2NTIw","avatar_url":"https://avatars2.githubusercontent.com/u/38656520?v=4","gravatar_id":"","url":"https://api.github.com/users/renovatebot","html_url":"https://github.com/renovatebot","followers_url":"https://api.github.com/users/renovatebot/followers","following_url":"https://api.github.com/users/renovatebot/following{/other_user}","gists_url":"https://api.github.com/users/renovatebot/gists{/gist_id}","starred_url":"https://api.github.com/users/renovatebot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/renovatebot/subscriptions","organizations_url":"https://api.github.com/users/renovatebot/orgs","repos_url":"https://api.github.com/users/renovatebot/repos","events_url":"https://api.github.com/users/renovatebot/events{/privacy}","received_events_url":"https://api.github.com/users/renovatebot/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/renovatebot/renovate","description":"Multi-language dependency update automation. Flexible, so you don't need to be.","fork":false,"url":"https://api.github.com/repos/renovatebot/renovate","forks_url":"https://api.github.com/repos/renovatebot/renovate/forks","keys_url":"https://api.github.com/repos/renovatebot/renovate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/renovatebot/renovate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/renovatebot/renovate/teams","hooks_url":"https://api.github.com/repos/renovatebot/renovate/hooks","issue_events_url":"https://api.github.com/repos/renovatebot/renovate/issues/events{/number}","events_url":"https://api.github.com/repos/renovatebot/renovate/events","assignees_url":"https://api.github.com/repos/renovatebot/renovate/assignees{/user}","branches_url":"https://api.github.com/repos/renovatebot/renovate/branches{/branch}","tags_url":"https://api.github.com/repos/renovatebot/renovate/tags","blobs_url":"https://api.github.com/repos/renovatebot/renovate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/renovatebot/renovate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/renovatebot/renovate/git/refs{/sha}","trees_url":"https://api.github.com/repos/renovatebot/renovate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/renovatebot/renovate/statuses/{sha}","languages_url":"https://api.github.com/repos/renovatebot/renovate/languages","stargazers_url":"https://api.github.com/repos/renovatebot/renovate/stargazers","contributors_url":"https://api.github.com/repos/renovatebot/renovate/contributors","subscribers_url":"https://api.github.com/repos/renovatebot/renovate/subscribers","subscription_url":"https://api.github.com/repos/renovatebot/renovate/subscription","commits_url":"https://api.github.com/repos/renovatebot/renovate/commits{/sha}","git_commits_url":"https://api.github.com/repos/renovatebot/renovate/git/commits{/sha}","comments_url":"https://api.github.com/repos/renovatebot/renovate/comments{/number}","issue_comment_url":"https://api.github.com/repos/renovatebot/renovate/issues/comments{/number}","contents_url":"https://api.github.com/repos/renovatebot/renovate/contents/{+path}","compare_url":"https://api.github.com/repos/renovatebot/renovate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/renovatebot/renovate/merges","archive_url":"https://api.github.com/repos/renovatebot/renovate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/renovatebot/renovate/downloads","issues_url":"https://api.github.com/repos/renovatebot/renovate/issues{/number}","pulls_url":"https://api.github.com/repos/renovatebot/renovate/pulls{/number}","milestones_url":"https://api.github.com/repos/renovatebot/renovate/milestones{/number}","notifications_url":"https://api.github.com/repos/renovatebot/renovate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/renovatebot/renovate/labels{/name}","releases_url":"https://api.github.com/repos/renovatebot/renovate/releases{/id}","deployments_url":"https://api.github.com/repos/renovatebot/renovate/deployments","created_at":"2016-12-17T16:21:21Z","updated_at":"2018-12-27T17:22:18Z","pushed_at":"2018-12-27T18:52:37Z","git_url":"git://github.com/renovatebot/renovate.git","ssh_url":"git@github.com:renovatebot/renovate.git","clone_url":"https://github.com/renovatebot/renovate.git","svn_url":"https://github.com/renovatebot/renovate","homepage":"https://renovatebot.com","size":17057,"stargazers_count":1141,"watchers_count":1141,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":159,"mirror_url":null,"archived":false,"open_issues_count":205,"license":{"key":"agpl-3.0","name":"GNU Affero General Public License v3.0","spdx_id":"AGPL-3.0","url":"https://api.github.com/licenses/agpl-3.0","node_id":"MDc6TGljZW5zZTE="},"forks":159,"open_issues":205,"watchers":1141,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/renovatebot/renovate/pulls/2995"},"html":{"href":"https://github.com/renovatebot/renovate/pull/2995"},"issue":{"href":"https://api.github.com/repos/renovatebot/renovate/issues/2995"},"comments":{"href":"https://api.github.com/repos/renovatebot/renovate/issues/2995/comments"},"review_comments":{"href":"https://api.github.com/repos/renovatebot/renovate/pulls/2995/comments"},"review_comment":{"href":"https://api.github.com/repos/renovatebot/renovate/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/renovatebot/renovate/pulls/2995/commits"},"statuses":{"href":"https://api.github.com/repos/renovatebot/renovate/statuses/f04800b3d3a1a6f145435a7d1029bee56c5cb54b"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"corecanarias"}}