Skip to content

Commit

Permalink
Improve upload archive progress bar
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Sverdlov <[email protected]>
  • Loading branch information
sverdlov93 committed Jan 6, 2025
1 parent ab6d11b commit c2c2298
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 41 deletions.
59 changes: 37 additions & 22 deletions buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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})
}
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package setmeup
package setup

var Usage = []string{"setmeup [command options]"}

Expand Down
12 changes: 7 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
6 changes: 3 additions & 3 deletions utils/cliutils/commandsflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
},
}

Expand Down

0 comments on commit c2c2298

Please sign in to comment.