diff --git a/buildtools/cli.go b/buildtools/cli.go index 383c87e30..3e2842198 100644 --- a/buildtools/cli.go +++ b/buildtools/cli.go @@ -3,10 +3,10 @@ package buildtools import ( "errors" "fmt" - "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/packagemanagerlogin" + "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/setup" "github.com/jfrog/jfrog-cli-core/v2/utils/ioutils" "github.com/jfrog/jfrog-cli-security/utils/techutils" - "github.com/jfrog/jfrog-cli/docs/buildtools/setmeup" + setupdocs "github.com/jfrog/jfrog-cli/docs/buildtools/setup" "os" "strconv" "strings" @@ -74,13 +74,13 @@ const ( func GetCommands() []cli.Command { return cliutils.GetSortedCommands(cli.CommandsByName{ { - Name: "setmeup", - Flags: cliutils.GetCommandFlags(cliutils.Setmeup), - Usage: setmeup.GetDescription(), - HelpName: corecommon.CreateUsage("setmeup", setmeup.GetDescription(), setmeup.Usage), + Name: "setup", + Flags: cliutils.GetCommandFlags(cliutils.Setup), + Usage: setupdocs.GetDescription(), + HelpName: corecommon.CreateUsage("setup", setupdocs.GetDescription(), setupdocs.Usage), ArgsUsage: common.CreateEnvVars(), BashComplete: corecommon.CreateBashCompletionFunc(), - Action: packageManagerLoginInteractiveCmd, + Action: setupCmd, }, { Name: "mvn-config", @@ -941,11 +941,35 @@ func NpmPublishCmd(c *cli.Context) (err error) { return } -func packageManagerLoginInteractiveCmd(c *cli.Context) (err error) { - allSupportedPackageManagers := packagemanagerlogin.GetSupportedPackageManagersList() +func setupCmd(c *cli.Context) (err error) { + var packageManager project.ProjectType + packageManagerStr := c.Args().Get(0) + // If the package manager was provided as an argument, validate it. + if packageManagerStr != "" { + packageManager = project.FromString(packageManagerStr) + if !setup.IsSupportedPackageManager(packageManager) { + return errorutils.CheckErrorf("The package manager %s is not supported", packageManagerStr) + } + } else { + // If the package manager wasn't provided as an argument, select it interactively. + packageManager, err = selectPackageManagerInteractively() + if err != nil { + return + } + } + setupCmd := setup.NewSetupCommand(packageManager) + artDetails, err := cliutils.CreateArtifactoryDetailsByFlags(c) + if err != nil { + return err + } + setupCmd.SetServerDetails(artDetails).SetRepoName(c.String("repo")).SetProjectKey(c.String(cliutils.Project)) + return commands.Exec(setupCmd) +} + +func selectPackageManagerInteractively() (selectedPackageManager project.ProjectType, err error) { + allSupportedPackageManagers := setup.GetSupportedPackageManagersList() var selected string var selectableItems []ioutils.PromptItem - var selectedPackageManager project.ProjectType for _, packageManager := range allSupportedPackageManagers { selectableItems = append(selectableItems, ioutils.PromptItem{Option: packageManager.String(), TargetValue: &selected}) } @@ -957,19 +981,10 @@ func packageManagerLoginInteractiveCmd(c *cli.Context) (err error) { return } if selectedPackageManager == -1 { - return errorutils.CheckErrorf("No package manager was selected") - } - return packageManagerLoginCmd(c, selectedPackageManager) -} - -func packageManagerLoginCmd(c *cli.Context, buildTool project.ProjectType) (err error) { - packageManagerLoginCmd := packagemanagerlogin.NewPackageManagerLoginCommand(buildTool) - artDetails, err := cliutils.CreateArtifactoryDetailsByFlags(c) - if err != nil { - return err + err = errorutils.CheckErrorf("No package manager was selected") + return } - packageManagerLoginCmd.SetServerDetails(artDetails) - return commands.Exec(packageManagerLoginCmd) + return } func GetNpmConfigAndArgs(c *cli.Context) (configFilePath string, args []string, err error) { diff --git a/docs/buildtools/setmeup/help.go b/docs/buildtools/setup/help.go similarity index 91% rename from docs/buildtools/setmeup/help.go rename to docs/buildtools/setup/help.go index 6a80f813d..d80931995 100644 --- a/docs/buildtools/setmeup/help.go +++ b/docs/buildtools/setup/help.go @@ -1,4 +1,4 @@ -package setmeup +package setup var Usage = []string{"setmeup [command options]"} diff --git a/go.mod b/go.mod index 0c00fd2c7..24988ae3c 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/jfrog/jfrog-cli-core/v2 v2.57.3 github.com/jfrog/jfrog-cli-platform-services v1.4.0 github.com/jfrog/jfrog-cli-security v1.13.6 - github.com/jfrog/jfrog-client-go v1.48.5 + github.com/jfrog/jfrog-client-go v1.48.6 github.com/jszwec/csvutil v1.10.0 github.com/manifoldco/promptui v0.9.0 github.com/stretchr/testify v1.10.0 @@ -83,7 +83,7 @@ require ( github.com/hashicorp/go-retryablehttp v0.7.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/jedib0t/go-pretty/v6 v6.6.3 // indirect + github.com/jedib0t/go-pretty/v6 v6.6.5 // indirect github.com/jfrog/froggit-go v1.16.2 // indirect github.com/jfrog/jfrog-apps-config v1.0.1 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect @@ -92,7 +92,7 @@ require ( github.com/klauspost/pgzip v1.2.6 // indirect github.com/ktrysmt/go-bitbucket v0.9.80 // indirect github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect - github.com/magiconair/properties v1.8.7 // indirect + github.com/magiconair/properties v1.8.9 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect @@ -156,7 +156,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.31.0 // indirect golang.org/x/mod v0.22.0 // indirect - golang.org/x/net v0.31.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/oauth2 v0.20.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect @@ -168,7 +168,9 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.31.1-0.20241213094134-8e118077b14a +replace github.com/jfrog/jfrog-cli-core/v2 => github.com/sverdlov93/jfrog-cli-core/v2 v2.0.2-0.20250106151024-2733b6069962 + +replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20250106143359-de902d8b8495 // replace github.com/jfrog/jfrog-cli-security => github.com/EyalDelarea/jfrog-cli-security v0.0.0-20241121103043-02719f295f02 diff --git a/go.sum b/go.sum index 8ccbef25b..93283f5da 100644 --- a/go.sum +++ b/go.sum @@ -157,8 +157,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jedib0t/go-pretty/v6 v6.6.3 h1:nGqgS0tgIO1Hto47HSaaK4ac/I/Bu7usmdD3qvs0WvM= -github.com/jedib0t/go-pretty/v6 v6.6.3/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E= +github.com/jedib0t/go-pretty/v6 v6.6.5 h1:9PgMJOVBedpgYLI56jQRJYqngxYAAzfEUua+3NgSqAo= +github.com/jedib0t/go-pretty/v6 v6.6.5/go.mod h1:Uq/HrbhuFty5WSVNfjpQQe47x16RwVGXIveNGEyGtHs= github.com/jfrog/archiver/v3 v3.6.1 h1:LOxnkw9pOn45DzCbZNFV6K0+6dCsQ0L8mR3ZcujO5eI= github.com/jfrog/archiver/v3 v3.6.1/go.mod h1:VgR+3WZS4N+i9FaDwLZbq+jeU4B4zctXL+gL4EMzfLw= github.com/jfrog/build-info-go v1.10.7 h1:10NVHYg0193gJpQft+S4WQfvYMtj5jlwwhJRvkFJtBE= @@ -171,14 +171,12 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w= github.com/jfrog/jfrog-cli-artifactory v0.1.11 h1:tYGQpkGZVHwYxApKhMXgY1V25QaLFaTbjsoq0l3Bf4w= github.com/jfrog/jfrog-cli-artifactory v0.1.11/go.mod h1:rVBTbanRnG9CXyAYRJ2O6h2fJMa+fsGB+3swUB/qEt0= -github.com/jfrog/jfrog-cli-core/v2 v2.57.3 h1:xqVHCIgcaJoRmLe79Qks1+9wIO7NigMjLFI9hRqL3sQ= -github.com/jfrog/jfrog-cli-core/v2 v2.57.3/go.mod h1:+43WrzRL8GIRde9YMwEQpXPzwZC1JZlZjO/K2ZsyJHc= github.com/jfrog/jfrog-cli-platform-services v1.4.0 h1:g6A30+tOfXd1h6VASeNwH+5mhs5bPQJ0MFzZs/4nlvs= github.com/jfrog/jfrog-cli-platform-services v1.4.0/go.mod h1:Ky4SDXuMeaiNP/5zMT1YSzIuXG+cNYYOl8BaEA7Awbc= github.com/jfrog/jfrog-cli-security v1.13.6 h1:gm8TnGTlprMJbRga0cujeoN2xal7Pagd2kDkUfclvrw= github.com/jfrog/jfrog-cli-security v1.13.6/go.mod h1:NarJyhl8Kh0HL6br74oeStIosLmCjA7atLYxZIFHJc4= -github.com/jfrog/jfrog-client-go v1.48.5 h1:q8v8oZ2HwwVw6+ZCwKbuIpUmxpWUeZzvTASQl/QKxKw= -github.com/jfrog/jfrog-client-go v1.48.5/go.mod h1:2ySOMva54L3EYYIlCBYBTcTgqfrrQ19gtpA/MWfA/ec= +github.com/jfrog/jfrog-client-go v1.28.1-0.20250106143359-de902d8b8495 h1:cPugIRHCJxE+QWW9TlvOlTWPcVI1wTRgAujQZk4I4VI= +github.com/jfrog/jfrog-client-go v1.28.1-0.20250106143359-de902d8b8495/go.mod h1:2ySOMva54L3EYYIlCBYBTcTgqfrrQ19gtpA/MWfA/ec= github.com/jszwec/csvutil v1.10.0 h1:upMDUxhQKqZ5ZDCs/wy+8Kib8rZR8I8lOR34yJkdqhI= github.com/jszwec/csvutil v1.10.0/go.mod h1:/E4ONrmGkwmWsk9ae9jpXnv9QT8pLHEPcCirMFhxG9I= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= @@ -208,8 +206,8 @@ github.com/ktrysmt/go-bitbucket v0.9.80 h1:S+vZTXKx/VG5yCaX4I3Bmwo8lxWr4ifvuHdTb github.com/ktrysmt/go-bitbucket v0.9.80/go.mod h1:b8ogWEGxQMWoeFnT1ZE4aHIPGindI+9z/zAW/OVFjk0= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= -github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= -github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= @@ -336,6 +334,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/sverdlov93/jfrog-cli-core/v2 v2.0.2-0.20250106151024-2733b6069962 h1:uS2NRiCahpZuF5J+nPPr+pkBVy5+nccIvrqHnNN5Pjc= +github.com/sverdlov93/jfrog-cli-core/v2 v2.0.2-0.20250106151024-2733b6069962/go.mod h1:LfKvCRXbvwgE0V6aX3/GabkzCedghXq0Y6lmsEuxr44= github.com/terminalstatic/go-xsd-validate v0.1.5 h1:RqpJnf6HGE2CB/lZB1A8BYguk8uRtcvYAPLCF15qguo= github.com/terminalstatic/go-xsd-validate v0.1.5/go.mod h1:18lsvYFofBflqCrvo1umpABZ99+GneNTw2kEEc8UPJw= github.com/testcontainers/testcontainers-go v0.34.0 h1:5fbgF0vIN5u+nD3IWabQwRybuB4GY8G2HHgCkbMzMHo= @@ -429,8 +429,8 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= -golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= -golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo= golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= diff --git a/utils/cliutils/commandsflags.go b/utils/cliutils/commandsflags.go index eb110e786..286926c76 100644 --- a/utils/cliutils/commandsflags.go +++ b/utils/cliutils/commandsflags.go @@ -33,7 +33,7 @@ const ( BuildAddGit = "build-add-git" BuildCollectEnv = "build-collect-env" GitLfsClean = "git-lfs-clean" - Setmeup = "setmeup" + Setup = "setup" Mvn = "mvn" MvnConfig = "mvn-config" CocoapodsConfig = "cocoapods-config" @@ -2091,8 +2091,8 @@ var commandFlags = map[string][]string{ SyncStatus: { branch, repository, serverId, }, - Setmeup: { - serverId, url, user, password, accessToken, + Setup: { + serverId, url, user, password, accessToken, Project, repo, }, }