feat: enabledManagers (#1755)

feat: enabledManagers
This commit is contained in:
Rhys Arkins 2018-03-30 17:00:51 +02:00 committed by GitHub
parent b98a834e99
commit b15909f8df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 1 deletions

View file

@ -259,6 +259,13 @@ const options = [
cli: false,
admin: true,
},
{
name: 'enabledManagers',
description:
'A list of package managers to enable. If defined, then all managers not on the list are disabled.',
type: 'list',
stage: 'repository',
},
{
name: 'packageFiles',
description: 'Package file paths',

View file

@ -39,6 +39,20 @@ async function detectPackageFiles(config) {
);
for (const manager of managerList) {
logger.debug(`Detecting package files (${manager})`);
const { parentManager } = managers[manager];
// Check if the user has a whitelist of managers
if (
config.enabledManagers &&
config.enabledManagers.length &&
!(
config.enabledManagers.includes(manager) ||
config.enabledManagers.includes(parentManager)
)
) {
logger.debug(manager + ' is not on the enabledManagers list');
continue; // eslint-disable-line no-continue
}
// Check if the manager is manually disabled
if (!(config[manager] && config[manager].enabled)) {
logger.debug(manager + ' is disabled');
continue; // eslint-disable-line no-continue

View file

@ -20,6 +20,15 @@ describe('manager', () => {
warnings: [],
};
});
it('skips if not in enabledManagers list', async () => {
platform.getFileList.mockReturnValueOnce([
'package.json',
'backend/package.json',
]);
config.enabledManagers = ['docker'];
const res = await manager.detectPackageFiles(config);
expect(res).toHaveLength(0);
});
it('adds package files to object', async () => {
platform.getFileList.mockReturnValueOnce([
'package.json',

View file

@ -286,6 +286,28 @@ To disable Renovate for `dependencies` but keep it for `devDependencies` you cou
}
```
## enabledManagers
A list of package managers to enable. If defined, then all managers not on the list are disabled.
| name | value |
| ------- | ----- |
| type | list |
| default | [] |
This is a way to "whitelist" certain package managers and disable all others.
By default, as Renovate supports more package managers we enable them once they are stable, but for some people only interested in perhaps npm dependencies, it can feel like "whack-a-mole" to keep disabling new ones you don't want.
This works for both managers (e.g. npm, circleci, nvm, etc) as well as "parent" managers (docker or node).
Example:
````json
{
"enabledManagers": ["npm"]
}
## encrypted
A configuration object containing strings encrypted with Renovate's public key.
@ -386,7 +408,7 @@ By default, Renovate will "slugify" the groupName to determine the branch name.
```json
"groupName": "eslint packages",
"groupSlug": "eslint"
```
````
And then the branchName would be `renovate/eslint` instead.