mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
fix(composer): handle non-array repositories
This commit is contained in:
parent
b7123806f4
commit
956d198f89
6 changed files with 246 additions and 1 deletions
|
@ -187,6 +187,8 @@ async function getPkgReleases(purl, config = {}) {
|
||||||
for (const regUrl of config.registryUrls) {
|
for (const regUrl of config.registryUrls) {
|
||||||
if (regUrl.type === 'composer') {
|
if (regUrl.type === 'composer') {
|
||||||
regUrls.push(regUrl.url);
|
regUrls.push(regUrl.url);
|
||||||
|
} else if (regUrl.type === 'package') {
|
||||||
|
logger.info({ regUrl }, 'Skipping package repository entry');
|
||||||
} else if (regUrl['packagist.org'] !== false) {
|
} else if (regUrl['packagist.org'] !== false) {
|
||||||
logger.info({ regUrl }, 'Unsupported Packagist registry URL');
|
logger.info({ regUrl }, 'Unsupported Packagist registry URL');
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
const is = require('@sindresorhus/is');
|
||||||
const semverComposer = require('../../versioning')('semverComposer');
|
const semverComposer = require('../../versioning')('semverComposer');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -58,7 +59,23 @@ async function extractDependencies(content, fileName) {
|
||||||
}
|
}
|
||||||
const res = { deps, composerLock };
|
const res = { deps, composerLock };
|
||||||
if (packageJson.repositories) {
|
if (packageJson.repositories) {
|
||||||
res.registryUrls = packageJson.repositories;
|
if (is.array(packageJson.repositories)) {
|
||||||
|
res.registryUrls = packageJson.repositories;
|
||||||
|
} else if (is.object(packageJson.repositories)) {
|
||||||
|
try {
|
||||||
|
res.registryUrls = [];
|
||||||
|
for (const repository of Object.values(packageJson.repositories)) {
|
||||||
|
res.registryUrls.push(repository);
|
||||||
|
}
|
||||||
|
} catch (err) /* istanbul ignore next */ {
|
||||||
|
logger.info({ err }, 'Error extracting composer repositories');
|
||||||
|
}
|
||||||
|
} /* istanbul ignore next */ else {
|
||||||
|
logger.info(
|
||||||
|
{ repositories: packageJson.repositories },
|
||||||
|
'Unknown composer repositories'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
66
test/_fixtures/composer/composer3.json
Normal file
66
test/_fixtures/composer/composer3.json
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
{
|
||||||
|
"name": "asha23/arlo-timber-framework",
|
||||||
|
"type": "project",
|
||||||
|
"license": "MIT",
|
||||||
|
"description": "A Composer Framework to help you get WordPress with Timber up and running in around a minute",
|
||||||
|
"authors": [{
|
||||||
|
"name": "Ash Whiting",
|
||||||
|
"email": "ash_whiting@hotmail.com"
|
||||||
|
}],
|
||||||
|
"keywords": [
|
||||||
|
"Arlo", "wordpress framework", "base theme", "wordpress", "composer", "vagrant", "wp"
|
||||||
|
],
|
||||||
|
"repositories": {
|
||||||
|
"wp-packagist": {
|
||||||
|
"type": "composer",
|
||||||
|
"url": "https://wpackagist.org"
|
||||||
|
},
|
||||||
|
"theme": {
|
||||||
|
"type": "package",
|
||||||
|
"package": {
|
||||||
|
"name": "asha23/wp-seed-timber",
|
||||||
|
"type": "wordpress-theme",
|
||||||
|
"version": "1.2.6",
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://github.com/asha23/wp-seed-timber/archive/v1.2.6.zip"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"wp-sync-db": {
|
||||||
|
"type": "package",
|
||||||
|
"package": {
|
||||||
|
"name": "wp-sync-db/wp-sync-db",
|
||||||
|
"type": "wordpress-plugin",
|
||||||
|
"version": "1.5",
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://github.com/corysimmons/wp-sync-db/archive/1.6.zip"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.5",
|
||||||
|
"composer/installers": "~1.0.12",
|
||||||
|
"johnpbloch/wordpress": "*",
|
||||||
|
"vlucas/phpdotenv": "^2.0.1",
|
||||||
|
"oscarotero/env": "^1.0",
|
||||||
|
"wpackagist-plugin/tinymce-advanced": "*",
|
||||||
|
"wpackagist-plugin/acf-content-analysis-for-yoast-seo": "*",
|
||||||
|
"wpackagist-plugin/duplicate-post": "*",
|
||||||
|
"wpackagist-plugin/simple-image-sizes": "*",
|
||||||
|
"wpackagist-plugin/wordpress-seo": "*",
|
||||||
|
"wpackagist-plugin/timber-library": "*",
|
||||||
|
"wp-sync-db/wp-sync-db": "*",
|
||||||
|
"asha23/wp-seed-timber": "*"
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"installer-paths": {
|
||||||
|
"web/content/plugins/{$name}/": ["type:wordpress-plugin"],
|
||||||
|
"web/content/themes/{$name}/": ["type:wordpress-theme"]
|
||||||
|
},
|
||||||
|
"wordpress-install-dir": "web/wp",
|
||||||
|
"content-install-dir": "web/content"
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,6 +29,18 @@ describe('datasource/packagist', () => {
|
||||||
{
|
{
|
||||||
type: 'unknown',
|
type: 'unknown',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'package',
|
||||||
|
package: {
|
||||||
|
name: 'abc/def',
|
||||||
|
type: 'wordpress-theme',
|
||||||
|
version: '1.2.6',
|
||||||
|
dist: {
|
||||||
|
type: 'zip',
|
||||||
|
url: 'https://github.com/abc/def/archive/v1.2.6.zip',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'packagist.org': false,
|
'packagist.org': false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -500,6 +500,145 @@ Object {
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`lib/manager/composer/extract extractDependencies() extracts object registryUrls 1`] = `
|
||||||
|
Object {
|
||||||
|
"composerLock": false,
|
||||||
|
"deps": Array [
|
||||||
|
Object {
|
||||||
|
"currentValue": ">=5.5",
|
||||||
|
"depName": "php",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/php",
|
||||||
|
"skipReason": "unsupported",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "~1.0.12",
|
||||||
|
"depName": "composer/installers",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/composer/installers",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "*",
|
||||||
|
"depName": "johnpbloch/wordpress",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/johnpbloch/wordpress",
|
||||||
|
"skipReason": "any-version",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "^2.0.1",
|
||||||
|
"depName": "vlucas/phpdotenv",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/vlucas/phpdotenv",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "^1.0",
|
||||||
|
"depName": "oscarotero/env",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/oscarotero/env",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "*",
|
||||||
|
"depName": "wpackagist-plugin/tinymce-advanced",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/wpackagist-plugin/tinymce-advanced",
|
||||||
|
"skipReason": "any-version",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "*",
|
||||||
|
"depName": "wpackagist-plugin/acf-content-analysis-for-yoast-seo",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/wpackagist-plugin/acf-content-analysis-for-yoast-seo",
|
||||||
|
"skipReason": "any-version",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "*",
|
||||||
|
"depName": "wpackagist-plugin/duplicate-post",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/wpackagist-plugin/duplicate-post",
|
||||||
|
"skipReason": "any-version",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "*",
|
||||||
|
"depName": "wpackagist-plugin/simple-image-sizes",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/wpackagist-plugin/simple-image-sizes",
|
||||||
|
"skipReason": "any-version",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "*",
|
||||||
|
"depName": "wpackagist-plugin/wordpress-seo",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/wpackagist-plugin/wordpress-seo",
|
||||||
|
"skipReason": "any-version",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "*",
|
||||||
|
"depName": "wpackagist-plugin/timber-library",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/wpackagist-plugin/timber-library",
|
||||||
|
"skipReason": "any-version",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "*",
|
||||||
|
"depName": "wp-sync-db/wp-sync-db",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/wp-sync-db/wp-sync-db",
|
||||||
|
"skipReason": "any-version",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "*",
|
||||||
|
"depName": "asha23/wp-seed-timber",
|
||||||
|
"depType": "require",
|
||||||
|
"purl": "pkg:packagist/asha23/wp-seed-timber",
|
||||||
|
"skipReason": "any-version",
|
||||||
|
"versionScheme": "semverComposer",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"registryUrls": Array [
|
||||||
|
Object {
|
||||||
|
"type": "composer",
|
||||||
|
"url": "https://wpackagist.org",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"package": Object {
|
||||||
|
"dist": Object {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://github.com/asha23/wp-seed-timber/archive/v1.2.6.zip",
|
||||||
|
},
|
||||||
|
"name": "asha23/wp-seed-timber",
|
||||||
|
"type": "wordpress-theme",
|
||||||
|
"version": "1.2.6",
|
||||||
|
},
|
||||||
|
"type": "package",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"package": Object {
|
||||||
|
"dist": Object {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://github.com/corysimmons/wp-sync-db/archive/1.6.zip",
|
||||||
|
},
|
||||||
|
"name": "wp-sync-db/wp-sync-db",
|
||||||
|
"type": "wordpress-plugin",
|
||||||
|
"version": "1.5",
|
||||||
|
},
|
||||||
|
"type": "package",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`lib/manager/composer/extract extractDependencies() extracts registryUrls 1`] = `
|
exports[`lib/manager/composer/extract extractDependencies() extracts registryUrls 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"composerLock": false,
|
"composerLock": false,
|
||||||
|
|
|
@ -11,6 +11,10 @@ const requirements2 = fs.readFileSync(
|
||||||
'test/_fixtures/composer/composer2.json',
|
'test/_fixtures/composer/composer2.json',
|
||||||
'utf8'
|
'utf8'
|
||||||
);
|
);
|
||||||
|
const requirements3 = fs.readFileSync(
|
||||||
|
'test/_fixtures/composer/composer3.json',
|
||||||
|
'utf8'
|
||||||
|
);
|
||||||
|
|
||||||
describe('lib/manager/composer/extract', () => {
|
describe('lib/manager/composer/extract', () => {
|
||||||
describe('extractDependencies()', () => {
|
describe('extractDependencies()', () => {
|
||||||
|
@ -33,6 +37,11 @@ describe('lib/manager/composer/extract', () => {
|
||||||
expect(res).toMatchSnapshot();
|
expect(res).toMatchSnapshot();
|
||||||
expect(res.registryUrls).toHaveLength(1);
|
expect(res.registryUrls).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
it('extracts object registryUrls', async () => {
|
||||||
|
const res = await extractDependencies(requirements3, packageFile);
|
||||||
|
expect(res).toMatchSnapshot();
|
||||||
|
expect(res.registryUrls).toHaveLength(3);
|
||||||
|
});
|
||||||
it('extracts dependencies with lock file', async () => {
|
it('extracts dependencies with lock file', async () => {
|
||||||
platform.getFile.mockReturnValueOnce('some content');
|
platform.getFile.mockReturnValueOnce('some content');
|
||||||
const res = await extractDependencies(requirements1, packageFile);
|
const res = await extractDependencies(requirements1, packageFile);
|
||||||
|
|
Loading…
Reference in a new issue