1 import * as rubygemsPlugin from './rubygems'; 2 import * as mvnPlugin from 'snyk-mvn-plugin'; 3 import * as gradlePlugin from 'snyk-gradle-plugin'; 4 import * as sbtPlugin from 'snyk-sbt-plugin'; 5 import * as pythonPlugin from 'snyk-python-plugin'; 6 import * as goPlugin from 'snyk-go-plugin'; 7 import * as nugetPlugin from 'snyk-nuget-plugin'; 8 import * as phpPlugin from 'snyk-php-plugin'; 9 import * as nodejsPlugin from './nodejs-plugin'; 10 import * as cocoapodsPlugin from '@snyk/snyk-cocoapods-plugin'; 11 import * as hexPlugin from '@snyk/snyk-hex-plugin'; 12 import * as swiftPlugin from 'snyk-swiftpm-plugin'; 13 import * as types from './types'; 14 import { SupportedPackageManagers } from '../package-managers'; 15 import { UnsupportedPackageManagerError } from '../errors'; 16 17 export function loadPlugin( 18 packageManager: SupportedPackageManagers | undefined, 19 ): types.Plugin { 20 switch (packageManager) { 21 case 'npm': { 22 return nodejsPlugin; 23 } 24 case 'rubygems': { 25 return rubygemsPlugin; 26 } 27 case 'maven': { 28 return mvnPlugin; 29 } 30 case 'gradle': { 31 return gradlePlugin; 32 } 33 case 'sbt': { 34 return sbtPlugin; 35 } 36 case 'yarn': { 37 return nodejsPlugin; 38 } 39 case 'pip': 40 case 'poetry': { 41 return pythonPlugin; 42 } 43 case 'golangdep': 44 case 'gomodules': 45 case 'govendor': { 46 return goPlugin; 47 } 48 case 'nuget': { 49 return nugetPlugin; 50 } 51 case 'paket': { 52 return nugetPlugin; 53 } 54 case 'composer': { 55 return phpPlugin; 56 } 57 case 'cocoapods': { 58 return cocoapodsPlugin; 59 } 60 case 'hex': { 61 return hexPlugin; 62 } 63 case 'swift': { 64 return swiftPlugin; 65 } 66 default: { 67 throw new UnsupportedPackageManagerError(packageManager); 68 } 69 } 70 }