diff --git a/artifactory/commands/setup/setup.go b/artifactory/commands/setup/setup.go index ab9118255..82f9c19d1 100644 --- a/artifactory/commands/setup/setup.go +++ b/artifactory/commands/setup/setup.go @@ -71,14 +71,19 @@ func NewSetupCommand(packageManager project.ProjectType) *SetupCommand { } } -// GetSupportedPackageManagersList returns a sorted list of supported package managers. -func GetSupportedPackageManagersList() []project.ProjectType { +// GetSupportedPackageManagersList returns a sorted list of supported package manager names as strings. +func GetSupportedPackageManagersList() []string { allSupportedPackageManagers := maps.Keys(packageManagerToRepositoryPackageType) // Sort keys based on their natural enum order slices.SortFunc(allSupportedPackageManagers, func(a, b project.ProjectType) int { return int(a) - int(b) }) - return allSupportedPackageManagers + // Convert enums to their string representation + result := make([]string, len(allSupportedPackageManagers)) + for i, manager := range allSupportedPackageManagers { + result[i] = manager.String() + } + return result } func IsSupportedPackageManager(packageManager project.ProjectType) bool { diff --git a/artifactory/commands/setup/setup_test.go b/artifactory/commands/setup/setup_test.go index a3dedbb20..725ec5da2 100644 --- a/artifactory/commands/setup/setup_test.go +++ b/artifactory/commands/setup/setup_test.go @@ -371,9 +371,9 @@ func testBuildToolLoginCommandConfigureDotnetNuget(t *testing.T, packageManager func TestGetSupportedPackageManagersList(t *testing.T) { result := GetSupportedPackageManagersList() - // Check that Go is before Pip, and Pip is before Npm using GreaterOrEqual - assert.GreaterOrEqual(t, slices.Index(result, project.Pip), slices.Index(result, project.Go), "Go should come before Pip") - assert.GreaterOrEqual(t, slices.Index(result, project.Npm), slices.Index(result, project.Pip), "Pip should come before Npm") + // Check that "Go" is before "Pip", and "Pip" is before "Npm" + assert.GreaterOrEqual(t, slices.Index(result, project.Go.String()), slices.Index(result, project.Pip.String()), "Go should come before Pip") + assert.GreaterOrEqual(t, slices.Index(result, project.Pip.String()), slices.Index(result, project.Npm.String()), "Pip should come before Npm") } func TestIsSupportedPackageManager(t *testing.T) {