From c7f74e3f915d9ec80c819f86d444d144d62a124c Mon Sep 17 00:00:00 2001
From: Oleg Krivtsov <olegkrivtsov@gmail.com>
Date: Wed, 20 Oct 2021 21:56:28 +0700
Subject: [PATCH] feat(config): migrate yarn -> npm in enabledManagers (#11965)

---
 lib/config/__snapshots__/migration.spec.ts.snap | 3 +++
 lib/config/migration.spec.ts                    | 1 +
 lib/config/migration.ts                         | 6 ++++++
 3 files changed, 10 insertions(+)

diff --git a/lib/config/__snapshots__/migration.spec.ts.snap b/lib/config/__snapshots__/migration.spec.ts.snap
index 6b6cedf07c..c8d0575831 100644
--- a/lib/config/__snapshots__/migration.spec.ts.snap
+++ b/lib/config/__snapshots__/migration.spec.ts.snap
@@ -102,6 +102,9 @@ Object {
   "dependencyDashboard": true,
   "dependencyDashboardTitle": "foo",
   "enabled": true,
+  "enabledManagers": Array [
+    "npm",
+  ],
   "exposeAllEnv": true,
   "extends": Array [
     ":automergeBranch",
diff --git a/lib/config/migration.spec.ts b/lib/config/migration.spec.ts
index b725ec180f..198addc4a4 100644
--- a/lib/config/migration.spec.ts
+++ b/lib/config/migration.spec.ts
@@ -155,6 +155,7 @@ describe('config/migration', () => {
           },
         ],
         raiseDeprecationWarnings: false,
+        enabledManagers: ['yarn'],
       } as any;
       const parentConfig = { ...defaultConfig, semanticCommits: 'disabled' };
       const { isMigrated, migratedConfig } = configMigration.migrateConfig(
diff --git a/lib/config/migration.ts b/lib/config/migration.ts
index e6a3903afe..d0482ef5aa 100644
--- a/lib/config/migration.ts
+++ b/lib/config/migration.ts
@@ -100,6 +100,11 @@ export function migrateConfig(
         } else if (val !== 'enabled' && val !== 'disabled') {
           migratedConfig.semanticCommits = 'auto';
         }
+      } else if (key === 'enabledManagers' && is.array(val)) {
+        // Replace yarn with npm, since yarn actually uses npm as package manager
+        migratedConfig.enabledManagers = migratedConfig.enabledManagers.map(
+          (element) => (element === 'yarn' ? 'npm' : element)
+        );
       } else if (parentKey === 'hostRules' && key === 'platform') {
         migratedConfig.hostType = val;
         delete migratedConfig.platform;
@@ -550,6 +555,7 @@ export function migrateConfig(
         }
         delete migratedConfig[key];
       }
+
       const migratedTemplates = {
         fromVersion: 'currentVersion',
         newValueMajor: 'newMajor',
-- 
GitLab