Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(composer): ignorePlatformReqs #5937

Merged
merged 10 commits into from Apr 11, 2020
4 changes: 4 additions & 0 deletions docs/usage/self-hosted-configuration.md
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions lib/config/__snapshots__/index.spec.ts.snap
Expand Up @@ -29,6 +29,7 @@ Object {
"commitMessageSuffix": null,
"commitMessageTopic": "dependency {{depName}}",
"compatibility": Object {},
"composerIgnorePlatformReqs": true,
"configWarningReuseIssue": true,
"dockerMapDotfiles": false,
"dockerUser": null,
Expand Down Expand Up @@ -161,6 +162,7 @@ Object {
"commitMessageSuffix": null,
"commitMessageTopic": "dependency {{depName}}",
"compatibility": Object {},
"composerIgnorePlatformReqs": true,
"configWarningReuseIssue": true,
"description": Array [],
"digest": Object {
Expand Down Expand Up @@ -389,6 +391,7 @@ Object {
"commitMessageSuffix": null,
"commitMessageTopic": "dependency {{depName}}",
"compatibility": Object {},
"composerIgnorePlatformReqs": true,
"configWarningReuseIssue": true,
"description": Array [],
"digest": Object {
Expand Down
8 changes: 8 additions & 0 deletions lib/config/definitions.ts
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions lib/manager/common.ts
Expand Up @@ -39,6 +39,7 @@ export interface UpdateArtifactsConfig extends ManagerConfig {
isLockFileMaintenance?: boolean;
compatibility?: Record<string, string>;
cacheDir?: string;
composerIgnorePlatformReqs?: boolean;
postUpdateOptions?: string[];
ignoreScripts?: boolean;

Expand Down
23 changes: 23 additions & 0 deletions lib/manager/composer/__snapshots__/artifacts.spec.ts.snap
Expand Up @@ -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 {
Expand Down
21 changes: 21 additions & 0 deletions lib/manager/composer/artifacts.spec.ts
Expand Up @@ -33,6 +33,7 @@ const config = {
localDir: join('/tmp/github/some/repo'),
cacheDir: join('/tmp/renovate/cache'),
dockerUser: 'foobar',
composerIgnorePlatformReqs: true,
};

describe('.updateArtifacts()', () => {
Expand Down Expand Up @@ -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();
});
});
5 changes: 4 additions & 1 deletion lib/manager/composer/artifacts.ts
Expand Up @@ -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';
}
Expand Down