Skip to content

Commit 93eac02

Browse files
author
Rhys Koedijk
authored
Fix "unknown package manager" error (#1377)
1 parent f7c491c commit 93eac02

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

extension/tasks/dependabotV2/utils/dependabot/parseConfigFile.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,40 @@ function parseUpdates(config: any): IDependabotUpdate[] {
150150
throw new Error("The value 'package-ecosystem' in dependency update config is missing");
151151
}
152152

153+
// Remap the package ecyosystem name from config to a value that dependabot-core/cli understands.
154+
// Config values: https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
155+
// Core/CLI values: https://github.com/dependabot/dependabot-core/blob/main/common/lib/dependabot/config/file.rb
156+
dependabotUpdate['package-ecosystem'] = (() => {
157+
const ecosystem = dependabotUpdate['package-ecosystem'].toLowerCase();
158+
switch (ecosystem) {
159+
case 'devcontainer':
160+
return 'devcontainers';
161+
case 'github-actions':
162+
return 'github_actions';
163+
case 'gitsubmodule':
164+
return 'submodules';
165+
case 'gomod':
166+
return 'go_modules';
167+
case 'mix':
168+
return 'hex';
169+
case 'npm':
170+
return 'npm_and_yarn';
171+
// Additional aliases, for convenience
172+
case 'pipenv':
173+
return 'pip';
174+
case 'pip-compile':
175+
return 'pip';
176+
case 'poetry':
177+
return 'pip';
178+
case 'pnpm':
179+
return 'npm_and_yarn';
180+
case 'yarn':
181+
return 'npm_and_yarn';
182+
default:
183+
return ecosystem;
184+
}
185+
})();
186+
153187
// zero is a valid value
154188
if (!dependabotUpdate['open-pull-requests-limit'] && dependabotUpdate['open-pull-requests-limit'] !== 0) {
155189
dependabotUpdate['open-pull-requests-limit'] = 5;

0 commit comments

Comments
 (0)