diff --git a/docs/usage/self-hosted-configuration.md b/docs/usage/self-hosted-configuration.md index bde2700322f2cd0cf800155929d9a333b98624e6..0afac48edc82377616598128cad768583250ade4 100644 --- a/docs/usage/self-hosted-configuration.md +++ b/docs/usage/self-hosted-configuration.md @@ -40,6 +40,10 @@ Set this to `docker` instead to use docker-based binaries. Configure this directory if you want to change which directory Renovate uses for storing cache data. If left unconfigured, it will typically be a temporary directory like `/tmp/renovate/cache/`. If you configure this to be different to the `baseDir`, it means you can have one location for repo data and another for cache data. +## composerIgnorePlatformReqs + +Set to `false` to prevent usage of `--ignore-platform-reqs` in the composer package manager. + ## dockerMapDotfiles This is used if you want to map "dotfiles" from your host computer home directory to containers that Renovate creates, e.g. for updating lock files. Currently applicable to `.npmrc` only. diff --git a/lib/config/__snapshots__/index.spec.ts.snap b/lib/config/__snapshots__/index.spec.ts.snap index caa3805ac078cd99014ddc28688de3155dd03176..14a9feb09b1bf1647d80edd754a494aeb3c65614 100644 --- a/lib/config/__snapshots__/index.spec.ts.snap +++ b/lib/config/__snapshots__/index.spec.ts.snap @@ -29,6 +29,7 @@ Object { "commitMessageSuffix": null, "commitMessageTopic": "dependency {{depName}}", "compatibility": Object {}, + "composerIgnorePlatformReqs": true, "configWarningReuseIssue": true, "dockerMapDotfiles": false, "dockerUser": null, @@ -161,6 +162,7 @@ Object { "commitMessageSuffix": null, "commitMessageTopic": "dependency {{depName}}", "compatibility": Object {}, + "composerIgnorePlatformReqs": true, "configWarningReuseIssue": true, "description": Array [], "digest": Object { @@ -389,6 +391,7 @@ Object { "commitMessageSuffix": null, "commitMessageTopic": "dependency {{depName}}", "compatibility": Object {}, + "composerIgnorePlatformReqs": true, "configWarningReuseIssue": true, "description": Array [], "digest": Object { diff --git a/lib/config/definitions.ts b/lib/config/definitions.ts index bbde257d65822ed09fd45c8f040f322dab5a795a..6aa2dd7bfc81fa39633a6d7a1631a81ac44ec9c6 100644 --- a/lib/config/definitions.ts +++ b/lib/config/definitions.ts @@ -270,6 +270,14 @@ const options: RenovateOptions[] = [ admin: true, type: 'string', }, + { + name: 'composerIgnorePlatformReqs', + description: + 'Enable / disable use of --ignore-platform-reqs in the composer package manager.', + type: 'boolean', + default: true, + admin: true, + }, // Log options { name: 'logLevel', diff --git a/lib/manager/common.ts b/lib/manager/common.ts index 6869a3da2ed5a4de623a0c7389d20e4aa019904a..8bdb65973be0728ad573e3c2de58ffef9be0b298 100644 --- a/lib/manager/common.ts +++ b/lib/manager/common.ts @@ -39,6 +39,7 @@ export interface UpdateArtifactsConfig extends ManagerConfig { isLockFileMaintenance?: boolean; compatibility?: Record<string, string>; cacheDir?: string; + composerIgnorePlatformReqs?: boolean; postUpdateOptions?: string[]; ignoreScripts?: boolean; diff --git a/lib/manager/composer/__snapshots__/artifacts.spec.ts.snap b/lib/manager/composer/__snapshots__/artifacts.spec.ts.snap index a7479466237f3f363a80adc57a9afdb0e4546420..36ff55166f603bcd4ca0ebad30db340cc88e4650 100644 --- a/lib/manager/composer/__snapshots__/artifacts.spec.ts.snap +++ b/lib/manager/composer/__snapshots__/artifacts.spec.ts.snap @@ -22,6 +22,29 @@ Array [ ] `; +exports[`.updateArtifacts() disables ignorePlatformReqs 1`] = ` +Array [ + Object { + "cmd": "composer update --with-dependencies --no-ansi --no-interaction --no-scripts --no-autoloader", + "options": Object { + "cwd": "/tmp/github/some/repo", + "encoding": "utf-8", + "env": Object { + "COMPOSER_CACHE_DIR": "/tmp/renovate/cache/others/composer", + "HOME": "/home/user", + "HTTPS_PROXY": "https://example.com", + "HTTP_PROXY": "http://example.com", + "LANG": "en_US.UTF-8", + "LC_ALL": "en_US", + "NO_PROXY": "localhost", + "PATH": "/tmp/path", + }, + "timeout": 900000, + }, + }, +] +`; + exports[`.updateArtifacts() performs lockFileMaintenance 1`] = ` Array [ Object { diff --git a/lib/manager/composer/artifacts.spec.ts b/lib/manager/composer/artifacts.spec.ts index 531da69608df44b58b8205669ba8c78a4f97d5b8..78c53d7f78a903f84599c822ba31b76bf61e26ab 100644 --- a/lib/manager/composer/artifacts.spec.ts +++ b/lib/manager/composer/artifacts.spec.ts @@ -33,6 +33,7 @@ const config = { localDir: join('/tmp/github/some/repo'), cacheDir: join('/tmp/renovate/cache'), dockerUser: 'foobar', + composerIgnorePlatformReqs: true, }; describe('.updateArtifacts()', () => { @@ -208,4 +209,24 @@ describe('.updateArtifacts()', () => { }) ).rejects.toThrow(); }); + it('disables ignorePlatformReqs', async () => { + platform.getFile.mockResolvedValueOnce('Current composer.lock'); + const execSnapshots = mockExecAll(exec); + fs.readFile.mockReturnValueOnce('New composer.lock' as any); + platform.getRepoStatus.mockResolvedValue({ + modified: ['composer.lock'], + } as StatusResult); + expect( + await composer.updateArtifacts({ + packageFileName: 'composer.json', + updatedDeps: [], + newPackageFileContent: '{}', + config: { + ...config, + composerIgnorePlatformReqs: false, + }, + }) + ).not.toBeNull(); + expect(execSnapshots).toMatchSnapshot(); + }); }); diff --git a/lib/manager/composer/artifacts.ts b/lib/manager/composer/artifacts.ts index bd67233582d4a6090b3b5002076f7d78b4beeb4e..9af135a4787b81f57411853612e840c99da1f7c5 100644 --- a/lib/manager/composer/artifacts.ts +++ b/lib/manager/composer/artifacts.ts @@ -117,7 +117,10 @@ export async function updateArtifacts({ args = ('update ' + updatedDeps.join(' ')).trim() + ' --with-dependencies'; } - args += ' --ignore-platform-reqs --no-ansi --no-interaction'; + if (config.composerIgnorePlatformReqs) { + args += ' --ignore-platform-reqs'; + } + args += ' --no-ansi --no-interaction'; if (global.trustLevel !== 'high' || config.ignoreScripts) { args += ' --no-scripts --no-autoloader'; }