diff --git a/lib/datasource/packagist/index.js b/lib/datasource/packagist/index.js index 6ee2be8783302d6cd563d46c2ff5b16212dceb3f..8adeb74eb952cf0250ac2cca759fd0b42df73ac4 100644 --- a/lib/datasource/packagist/index.js +++ b/lib/datasource/packagist/index.js @@ -255,15 +255,14 @@ async function getPkgReleases({ lookupName, registryUrls }) { logger.trace(`getPkgReleases(${lookupName})`); let res; - if (is.nonEmptyArray(registryUrls)) { - for (const regUrl of registryUrls) { - res = await packageLookup(regUrl, lookupName); - if (res) { - break; - } + const registries = is.nonEmptyArray(registryUrls) + ? registryUrls + : ['https://packagist.org']; + for (const regUrl of registries) { + res = await packageLookup(regUrl, lookupName); + if (res) { + break; } - } /* istanbul ignore next */ else { - logger.debug({ lookupName }, 'No registryUrls defined'); } return res; } diff --git a/test/datasource/__snapshots__/packagist.spec.js.snap b/test/datasource/__snapshots__/packagist.spec.js.snap index 9ddefe86fbf5f7bdfdfeebbe00d22813dad7c75e..34885f5022cfa8515eca93b3d41fabc8a262d9ff 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 adds packagist source implicitly 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", + }, + ], + "sourceUrl": "https://github.com/drewm/mailchimp-api", +} +`; + exports[`datasource/packagist getPkgReleases processes real versioned data 1`] = ` Object { "homepage": "https://github.com/drewm/mailchimp-api", diff --git a/test/datasource/packagist.spec.js b/test/datasource/packagist.spec.js index 8046ab8a1a6abd1d0f1926d88441d9854813b4db..19d03c2a7ca5f5140f480406289f6bfff3ebc532 100644 --- a/test/datasource/packagist.spec.js +++ b/test/datasource/packagist.spec.js @@ -219,5 +219,16 @@ describe('datasource/packagist', () => { }) ).toMatchSnapshot(); }); + it('adds packagist source implicitly', async () => { + got.mockReturnValueOnce({ + body: JSON.parse(mailchimpJson), + }); + expect( + await datasource.getPkgReleases({ + ...config, + lookupName: 'drewm/mailchimp-api', + }) + ).toMatchSnapshot(); + }); }); });