From b15909f8df7f5ec06be23f5110b8b1839671c33b Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Fri, 30 Mar 2018 17:00:51 +0200
Subject: [PATCH] feat: enabledManagers (#1755)

feat: enabledManagers
---
 lib/config/definitions.js                     |  7 ++++++
 lib/manager/index.js                          | 14 +++++++++++
 test/manager/index.spec.js                    |  9 +++++++
 .../2017-10-05-configuration-options.md       | 24 ++++++++++++++++++-
 4 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/lib/config/definitions.js b/lib/config/definitions.js
index bcbb6896b6..caeb6b8fbf 100644
--- a/lib/config/definitions.js
+++ b/lib/config/definitions.js
@@ -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',
diff --git a/lib/manager/index.js b/lib/manager/index.js
index 3868e48f2f..71a1a880bf 100644
--- a/lib/manager/index.js
+++ b/lib/manager/index.js
@@ -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
diff --git a/test/manager/index.spec.js b/test/manager/index.spec.js
index bacf248198..9ca1451dbf 100644
--- a/test/manager/index.spec.js
+++ b/test/manager/index.spec.js
@@ -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',
diff --git a/website/docs/_posts/2017-10-05-configuration-options.md b/website/docs/_posts/2017-10-05-configuration-options.md
index a90dcb14a8..8918998520 100644
--- a/website/docs/_posts/2017-10-05-configuration-options.md
+++ b/website/docs/_posts/2017-10-05-configuration-options.md
@@ -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.
 
-- 
GitLab