diff --git a/lib/datasource/packagist.js b/lib/datasource/packagist.js index 9f67fd8370da4bf38d964dbe9eb13f1adbf67804..9a5d605a9e40d5628e299f6a86bb8c9a481de933 100644 --- a/lib/datasource/packagist.js +++ b/lib/datasource/packagist.js @@ -171,8 +171,25 @@ async function getAllPackages(regUrl) { return allPackages; } +async function packagistOrgLookup(name) { + const regUrl = 'https://packagist.org'; + const pkgUrl = URL.resolve(regUrl, `/packages/${name}.json`); + const res = (await got(pkgUrl, { + json: true, + retries: 5, + })).body.package; + const dep = extractDepReleases(res.versions); + dep.name = name; + logger.trace({ dep }, 'dep'); + return dep; +} + async function packageLookup(regUrl, name) { try { + if (regUrl === 'https://packagist.org') { + const packagistResult = await packagistOrgLookup(name); + return packagistResult; + } const allPackages = await getAllPackages(regUrl); if (!allPackages) { return null; diff --git a/test/_fixtures/packagist/mailchimp-api.json b/test/_fixtures/packagist/mailchimp-api.json new file mode 100644 index 0000000000000000000000000000000000000000..9ca472a880ffee69dc587f08d81523b38aab39c5 --- /dev/null +++ b/test/_fixtures/packagist/mailchimp-api.json @@ -0,0 +1 @@ +{"package":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","time":"2013-12-18T14:08:09+00:00","maintainers":[{"name":"drewm","avatar_url":"https:\/\/www.gravatar.com\/avatar\/74c8cca18339c66ca10979569f1bb206?d=identicon"}],"versions":{"dev-master":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"dev-master","version_normalized":"9999999-dev","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"e3febc93dbe8047f0a14fea19c1efe79cecc7e98"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/e3febc93dbe8047f0a14fea19c1efe79cecc7e98","reference":"e3febc93dbe8047f0a14fea19c1efe79cecc7e98","shasum":""},"type":"library","time":"2018-02-23T09:45:38+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3","ext-curl":"*"},"require-dev":{"vlucas\/phpdotenv":"^2.0","phpunit\/phpunit":"7.0.*"}},"dev-api-v3":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"dev-api-v3","version_normalized":"dev-api-v3","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"268dca3f0e35bdc263ceb8114b24c7496c3b46f5"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/268dca3f0e35bdc263ceb8114b24c7496c3b46f5","reference":"268dca3f0e35bdc263ceb8114b24c7496c3b46f5","shasum":""},"type":"library","time":"2016-01-17T15:59:26+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"dev-api-v2":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v2 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"dev-api-v2","version_normalized":"dev-api-v2","license":["MIT"],"authors":[{"name":"Drew McLellan","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"2ace9cf087bea43d0bf9c7207d94ce93642e6262"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/2ace9cf087bea43d0bf9c7207d94ce93642e6262","reference":"2ace9cf087bea43d0bf9c7207d94ce93642e6262","shasum":""},"type":"library","time":"2016-01-17T15:57:27+00:00","autoload":{"psr-0":{"Drewm":"src\/"}},"require":{"php":"\u003E=5.3"}},"v2.5":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.5","version_normalized":"2.5.0.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"f532fa26cd6e7d17c9ba40a757d8c6bfee47dace"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/f532fa26cd6e7d17c9ba40a757d8c6bfee47dace","reference":"f532fa26cd6e7d17c9ba40a757d8c6bfee47dace","shasum":""},"type":"library","time":"2018-02-16T15:31:05+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3","ext-curl":"*"},"require-dev":{"phpunit\/phpunit":"7.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.4":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.4","version_normalized":"2.4.0.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"fe480bb652f85270227bf6d639b0026a531f21fc"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/fe480bb652f85270227bf6d639b0026a531f21fc","reference":"fe480bb652f85270227bf6d639b0026a531f21fc","shasum":""},"type":"library","time":"2017-02-16T13:24:20+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3","ext-curl":"*"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.3":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.3","version_normalized":"2.3.0.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"6a5373378f8e61284be81d6424d22fb2a3a1ff9e"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/6a5373378f8e61284be81d6424d22fb2a3a1ff9e","reference":"6a5373378f8e61284be81d6424d22fb2a3a1ff9e","shasum":""},"type":"library","time":"2016-12-21T14:50:24+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3","ext-curl":"*"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.2.3":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.2.3","version_normalized":"2.2.3.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"89b7dbc54b7ba8c2e249d6e63f66d22ecb8070f8"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/89b7dbc54b7ba8c2e249d6e63f66d22ecb8070f8","reference":"89b7dbc54b7ba8c2e249d6e63f66d22ecb8070f8","shasum":""},"type":"library","time":"2016-07-01T15:53:33+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3","ext-curl":"*"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.2.4":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.2.4","version_normalized":"2.2.4.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"89b7dbc54b7ba8c2e249d6e63f66d22ecb8070f8"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/89b7dbc54b7ba8c2e249d6e63f66d22ecb8070f8","reference":"89b7dbc54b7ba8c2e249d6e63f66d22ecb8070f8","shasum":""},"type":"library","time":"2016-07-01T15:53:33+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3","ext-curl":"*"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.2.2":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.2.2","version_normalized":"2.2.2.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"6ebcfd131fd6f3cac69be9fccb6c3f8102736952"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/6ebcfd131fd6f3cac69be9fccb6c3f8102736952","reference":"6ebcfd131fd6f3cac69be9fccb6c3f8102736952","shasum":""},"type":"library","time":"2016-07-01T09:58:24+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3","ext-curl":"*"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.2.1":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.2.1","version_normalized":"2.2.1.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"a2bf78208c49b205482c5ca884cb45a8cd266d5c"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/a2bf78208c49b205482c5ca884cb45a8cd266d5c","reference":"a2bf78208c49b205482c5ca884cb45a8cd266d5c","shasum":""},"type":"library","time":"2016-04-23T18:00:21+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3","ext-curl":"*"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.2":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.2","version_normalized":"2.2.0.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"590fb71e3493b5daba382c44f714f2e25d785814"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/590fb71e3493b5daba382c44f714f2e25d785814","reference":"590fb71e3493b5daba382c44f714f2e25d785814","shasum":""},"type":"library","time":"2016-04-23T12:43:28+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3","ext-curl":"*"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.1.3":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.1.3","version_normalized":"2.1.3.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"6188e2be5827efb6595f63ad6f01a26e84bd39f7"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/6188e2be5827efb6595f63ad6f01a26e84bd39f7","reference":"6188e2be5827efb6595f63ad6f01a26e84bd39f7","shasum":""},"type":"library","time":"2016-04-12T09:09:47+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.1.2":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.1.2","version_normalized":"2.1.2.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"f4539014e9cc96eab0f187f52eb60499518a31bb"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/f4539014e9cc96eab0f187f52eb60499518a31bb","reference":"f4539014e9cc96eab0f187f52eb60499518a31bb","shasum":""},"type":"library","time":"2016-04-06T12:41:37+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.1.1":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.1.1","version_normalized":"2.1.1.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"86f529eba05a7e4c3a3e091aed8ff056137e6251"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/86f529eba05a7e4c3a3e091aed8ff056137e6251","reference":"86f529eba05a7e4c3a3e091aed8ff056137e6251","shasum":""},"type":"library","time":"2016-04-06T08:37:20+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.1":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.1","version_normalized":"2.1.0.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"a9bf617afb5a9bcb2601f5cc23b01a7b581d5659"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/a9bf617afb5a9bcb2601f5cc23b01a7b581d5659","reference":"a9bf617afb5a9bcb2601f5cc23b01a7b581d5659","shasum":""},"type":"library","time":"2016-01-30T16:12:54+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v2.0":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v3 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v2.0","version_normalized":"2.0.0.0","license":["MIT"],"authors":[{"name":"Drew McLellan","email":"drew.mclellan@gmail.com","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"a2eb58b615aff713fcb1714e33f321712c5be3c8"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/a2eb58b615aff713fcb1714e33f321712c5be3c8","reference":"a2eb58b615aff713fcb1714e33f321712c5be3c8","shasum":""},"type":"library","time":"2016-01-17T13:08:01+00:00","autoload":{"psr-4":{"DrewM\\MailChimp\\":"src"}},"require":{"php":"\u003E=5.3"},"require-dev":{"phpunit\/phpunit":"4.0.*","vlucas\/phpdotenv":"^2.0"}},"v1.1":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v2 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v1.1","version_normalized":"1.1.0.0","license":["MIT"],"authors":[{"name":"Drew McLellan","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"707d555962442b21a75683a56bdb7cebd0a19f72"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/707d555962442b21a75683a56bdb7cebd0a19f72","reference":"707d555962442b21a75683a56bdb7cebd0a19f72","shasum":""},"type":"library","time":"2015-07-07T15:38:25+00:00","autoload":{"psr-0":{"Drewm":"src\/"}},"require":{"php":"\u003E=5.3"}},"v1.0":{"name":"drewm\/mailchimp-api","description":"Super-simple, minimum abstraction MailChimp API v2 wrapper","keywords":[],"homepage":"https:\/\/github.com\/drewm\/mailchimp-api","version":"v1.0","version_normalized":"1.0.0.0","license":["MIT"],"authors":[{"name":"Drew McLellan","homepage":"http:\/\/allinthehead.com\/"}],"source":{"type":"git","url":"https:\/\/github.com\/drewm\/mailchimp-api.git","reference":"0b763f05fe18610061b8289a399a9d0569036a50"},"dist":{"type":"zip","url":"https:\/\/api.github.com\/repos\/drewm\/mailchimp-api\/zipball\/0b763f05fe18610061b8289a399a9d0569036a50","reference":"0b763f05fe18610061b8289a399a9d0569036a50","shasum":""},"type":"library","time":"2014-05-30T16:51:39+00:00","autoload":{"psr-0":{"Drewm":"src\/"}},"require":{"php":"\u003E=5.3"}}},"type":"library","repository":"https:\/\/github.com\/drewm\/mailchimp-api","github_stars":1494,"github_watchers":96,"github_forks":401,"github_open_issues":32,"language":"PHP","dependents":57,"suggesters":3,"downloads":{"total":2243357,"monthly":116450,"daily":4785},"favers":1507}} \ No newline at end of file diff --git a/test/datasource/__snapshots__/packagist.spec.js.snap b/test/datasource/__snapshots__/packagist.spec.js.snap index 526e732619d736d0a65a5c99cb809b8fcc0630b1..134ad58b6ae23e8a12137d415a0ecd177e40cdcf 100644 --- a/test/datasource/__snapshots__/packagist.spec.js.snap +++ b/test/datasource/__snapshots__/packagist.spec.js.snap @@ -1,5 +1,90 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`datasource/packagist getPkgReleases processes real versioned data 1`] = ` +Object { + "homepage": "https://github.com/drewm/mailchimp-api", + "name": "drewm/mailchimp-api", + "releases": Array [ + Object { + "gitRef": "v1.0", + "releaseTimestamp": "2014-05-30T16:51:39+00:00", + "version": "1.0", + }, + Object { + "gitRef": "v1.1", + "releaseTimestamp": "2015-07-07T15:38:25+00:00", + "version": "1.1", + }, + Object { + "gitRef": "v2.0", + "releaseTimestamp": "2016-01-17T13:08:01+00:00", + "version": "2.0", + }, + Object { + "gitRef": "v2.1", + "releaseTimestamp": "2016-01-30T16:12:54+00:00", + "version": "2.1", + }, + Object { + "gitRef": "v2.1.1", + "releaseTimestamp": "2016-04-06T08:37:20+00:00", + "version": "2.1.1", + }, + Object { + "gitRef": "v2.1.2", + "releaseTimestamp": "2016-04-06T12:41:37+00:00", + "version": "2.1.2", + }, + Object { + "gitRef": "v2.1.3", + "releaseTimestamp": "2016-04-12T09:09:47+00:00", + "version": "2.1.3", + }, + Object { + "gitRef": "v2.2", + "releaseTimestamp": "2016-04-23T12:43:28+00:00", + "version": "2.2", + }, + Object { + "gitRef": "v2.2.1", + "releaseTimestamp": "2016-04-23T18:00:21+00:00", + "version": "2.2.1", + }, + Object { + "gitRef": "v2.2.2", + "releaseTimestamp": "2016-07-01T09:58:24+00:00", + "version": "2.2.2", + }, + Object { + "gitRef": "v2.2.3", + "releaseTimestamp": "2016-07-01T15:53:33+00:00", + "version": "2.2.3", + }, + Object { + "gitRef": "v2.2.4", + "releaseTimestamp": "2016-07-01T15:53:33+00:00", + "version": "2.2.4", + }, + Object { + "gitRef": "v2.3", + "releaseTimestamp": "2016-12-21T14:50:24+00:00", + "version": "2.3", + }, + Object { + "gitRef": "v2.4", + "releaseTimestamp": "2017-02-16T13:24:20+00:00", + "version": "2.4", + }, + Object { + "gitRef": "v2.5", + "releaseTimestamp": "2018-02-16T15:31:05+00:00", + "version": "2.5", + }, + ], + "repositoryUrl": "https://github.com/drewm/mailchimp-api", +} +`; + exports[`datasource/packagist getPkgReleases supports includes packages 1`] = ` Object { "homepage": "http://guzzlephp.org/", diff --git a/test/datasource/packagist.spec.js b/test/datasource/packagist.spec.js index e62b2628d330e7207c4d16fed4ba83470d860b58..acea0a03a659ae70ac54234e5ceb9097c5f9b9d2 100644 --- a/test/datasource/packagist.spec.js +++ b/test/datasource/packagist.spec.js @@ -8,17 +8,29 @@ jest.mock('../../lib/util/host-rules'); const includesJson = fs.readFileSync('test/_fixtures/packagist/includes.json'); const beytJson = fs.readFileSync('test/_fixtures/packagist/1beyt.json'); +const mailchimpJson = fs.readFileSync( + 'test/_fixtures/packagist/mailchimp-api.json' +); describe('datasource/packagist', () => { describe('getPkgReleases', () => { + let config; beforeEach(() => { jest.resetAllMocks(); hostRules.find = jest.fn(input => input); global.repoCache = {}; + config = { + registryUrls: [ + { + type: 'composer', + url: 'https://composer.renovatebot.com', + }, + ], + }; return global.renovateCache.rmAll(); }); it('supports custom registries', async () => { - const config = { + config = { registryUrls: [ { type: 'composer', @@ -66,7 +78,7 @@ describe('datasource/packagist', () => { }); const res = await datasource.getPkgReleases( 'pkg:packagist/vendor/package-name', - {} + config ); expect(res).toMatchSnapshot(); }); @@ -78,7 +90,7 @@ describe('datasource/packagist', () => { ); const res = await datasource.getPkgReleases( 'pkg:packagist/vendor/package-name', - {} + config ); expect(res).toBeNull(); }); @@ -90,8 +102,8 @@ describe('datasource/packagist', () => { }) ); const res = await datasource.getPkgReleases( - 'pkg:packagist/vendor/package-name', - {} + 'pkg:packagist/drewm/mailchip-api', + config ); expect(res).toBeNull(); }); @@ -116,7 +128,7 @@ describe('datasource/packagist', () => { }); const res = await datasource.getPkgReleases( 'pkg:packagist/guzzlehttp/guzzle', - {} + config ); expect(res).toMatchSnapshot(); expect(res).not.toBeNull(); @@ -155,7 +167,7 @@ describe('datasource/packagist', () => { }); const res = await datasource.getPkgReleases( 'pkg:packagist/wpackagist-plugin/1beyt', - {} + config ); expect(res).toMatchSnapshot(); expect(res).not.toBeNull(); @@ -194,9 +206,17 @@ describe('datasource/packagist', () => { }); const res = await datasource.getPkgReleases( 'pkg:packagist/some/other', - {} + config ); expect(res).toBeNull(); }); + it('processes real versioned data', async () => { + got.mockReturnValueOnce({ + body: JSON.parse(mailchimpJson), + }); + expect( + await datasource.getPkgReleases('pkg:packagist/drewm/mailchimp-api') + ).toMatchSnapshot(); + }); }); }); diff --git a/test/workers/repository/process/lookup/index.spec.js b/test/workers/repository/process/lookup/index.spec.js index 0ba2db6684e861f2a45be863379d13f7675f83d5..6e78b359aaf25e40908c84f77c2eb63f7ae6a682 100644 --- a/test/workers/repository/process/lookup/index.spec.js +++ b/test/workers/repository/process/lookup/index.spec.js @@ -941,7 +941,7 @@ describe('manager/npm/lookup', () => { config.packageFile = 'composer.json'; config.currentValue = '1.0.0'; nock('https://packagist.org') - .get('/packages.json') + .get('/packages/foo/bar.json') .reply(404); expect((await lookup.lookupUpdates(config)).updates).toMatchSnapshot(); });