From 93eac02825c852ad6c8d4bcd73cf82f2fb0b4ff2 Mon Sep 17 00:00:00 2001 From: Rhys Koedijk Date: Tue, 1 Oct 2024 18:58:56 +1300 Subject: [PATCH] Fix "unknown package manager" error (#1377) --- .../utils/dependabot/parseConfigFile.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/extension/tasks/dependabotV2/utils/dependabot/parseConfigFile.ts b/extension/tasks/dependabotV2/utils/dependabot/parseConfigFile.ts index df6b6d77..5440cf0a 100644 --- a/extension/tasks/dependabotV2/utils/dependabot/parseConfigFile.ts +++ b/extension/tasks/dependabotV2/utils/dependabot/parseConfigFile.ts @@ -150,6 +150,40 @@ function parseUpdates(config: any): IDependabotUpdate[] { throw new Error("The value 'package-ecosystem' in dependency update config is missing"); } + // Remap the package ecyosystem name from config to a value that dependabot-core/cli understands. + // Config values: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem + // Core/CLI values: https://github.com/dependabot/dependabot-core/blob/main/common/lib/dependabot/config/file.rb + dependabotUpdate['package-ecosystem'] = (() => { + const ecosystem = dependabotUpdate['package-ecosystem'].toLowerCase(); + switch (ecosystem) { + case 'devcontainer': + return 'devcontainers'; + case 'github-actions': + return 'github_actions'; + case 'gitsubmodule': + return 'submodules'; + case 'gomod': + return 'go_modules'; + case 'mix': + return 'hex'; + case 'npm': + return 'npm_and_yarn'; + // Additional aliases, for convenience + case 'pipenv': + return 'pip'; + case 'pip-compile': + return 'pip'; + case 'poetry': + return 'pip'; + case 'pnpm': + return 'npm_and_yarn'; + case 'yarn': + return 'npm_and_yarn'; + default: + return ecosystem; + } + })(); + // zero is a valid value if (!dependabotUpdate['open-pull-requests-limit'] && dependabotUpdate['open-pull-requests-limit'] !== 0) { dependabotUpdate['open-pull-requests-limit'] = 5;