Skip to content

Commit cd4cbbf

Browse files
Merge remote-tracking branch 'origin/dev' into v2
2 parents 8800f64 + 12a5ce0 commit cd4cbbf

33 files changed

+690
-127
lines changed

.github/workflows/nugetTests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- name: Install .NET
5050
uses: actions/setup-dotnet@v4
5151
with:
52-
dotnet-version: '6.x'
52+
dotnet-version: '8.x'
5353

5454
- name: Install NuGet
5555
uses: nuget/setup-nuget@v2

artifactory/cli.go

+13-12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package artifactory
33
import (
44
"errors"
55
"fmt"
6+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/python"
67
"github.com/jfrog/jfrog-cli/docs/artifactory/cocoapodsconfig"
78
"github.com/jfrog/jfrog-cli/docs/artifactory/swiftconfig"
89
"os"
@@ -13,19 +14,19 @@ import (
1314
"github.com/jfrog/jfrog-cli/utils/accesstoken"
1415

1516
"github.com/jfrog/gofrog/version"
17+
coregeneric "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
1618
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferinstall"
1719
"github.com/jfrog/jfrog-cli/docs/artifactory/transferplugininstall"
1820

19-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/buildinfo"
20-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container"
21-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/curl"
22-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/dotnet"
23-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
24-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/oc"
25-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/permissiontarget"
26-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/python"
27-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/replication"
28-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/repository"
21+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/buildinfo"
22+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/container"
23+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/curl"
24+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/dotnet"
25+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/generic"
26+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/oc"
27+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/permissiontarget"
28+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/replication"
29+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/repository"
2930
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transfer"
3031
transferconfigcore "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferconfig"
3132
transferfilescore "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferfiles"
@@ -1249,7 +1250,7 @@ func pingCmd(c *cli.Context) error {
12491250
if err != nil {
12501251
return err
12511252
}
1252-
pingCmd := generic.NewPingCommand()
1253+
pingCmd := coregeneric.NewPingCommand()
12531254
pingCmd.SetServerDetails(artDetails)
12541255
err = commands.Exec(pingCmd)
12551256
resString := clientutils.IndentJson(pingCmd.Response())
@@ -1870,7 +1871,7 @@ func buildScanLegacyCmd(c *cli.Context) error {
18701871

18711872
func checkBuildScanError(err error) error {
18721873
// If the build was found vulnerable, exit with ExitCodeVulnerableBuild.
1873-
if err == utils.GetBuildScanError() {
1874+
if errors.Is(err, utils.GetBuildScanError()) {
18741875
return coreutils.CliError{ExitCode: coreutils.ExitCodeVulnerableBuild, ErrorMsg: err.Error()}
18751876
}
18761877
// If the scan operation failed, for example due to HTTP timeout, exit with ExitCodeError.

artifactory_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"github.com/jfrog/archiver/v3"
3030
gofrogio "github.com/jfrog/gofrog/io"
3131
"github.com/jfrog/gofrog/version"
32-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
32+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/generic"
3333
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
3434
commonCliUtils "github.com/jfrog/jfrog-cli-core/v2/common/cliutils"
3535
"github.com/jfrog/jfrog-cli-core/v2/common/commands"

build/npm/v2-jf/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/npm/v2-jf/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jfrog-cli-v2-jf",
3-
"version": "2.73.2",
3+
"version": "2.73.3",
44
"description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸",
55
"homepage": "https://github.com/jfrog/jfrog-cli",
66
"preferGlobal": true,

build/npm/v2/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/npm/v2/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jfrog-cli-v2",
3-
"version": "2.73.2",
3+
"version": "2.73.3",
44
"description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸",
55
"homepage": "https://github.com/jfrog/jfrog-cli",
66
"preferGlobal": true,

buildinfo_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import (
1010
"strings"
1111
"testing"
1212

13-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/formats"
13+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/formats"
1414
clientTestUtils "github.com/jfrog/jfrog-client-go/utils/tests"
1515

1616
buildinfo "github.com/jfrog/build-info-go/entities"
1717
"github.com/jfrog/jfrog-cli-core/v2/common/build"
1818
"github.com/jfrog/jfrog-cli-core/v2/common/spec"
1919
"github.com/jfrog/jfrog-client-go/utils/log"
2020

21-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
21+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/generic"
2222
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
2323
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
2424
coretests "github.com/jfrog/jfrog-cli-core/v2/utils/tests"

buildtools/cli.go

+83-10
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@ package buildtools
33
import (
44
"errors"
55
"fmt"
6+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/python"
7+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/setup"
8+
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
9+
"github.com/jfrog/jfrog-cli-core/v2/utils/ioutils"
610
"github.com/jfrog/jfrog-cli-security/utils/techutils"
11+
setupdocs "github.com/jfrog/jfrog-cli/docs/buildtools/setup"
712
"os"
813
"strconv"
914
"strings"
1015

11-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container"
12-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/dotnet"
13-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/golang"
14-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/gradle"
15-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/mvn"
16-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/npm"
17-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/python"
18-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/terraform"
16+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/container"
17+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/dotnet"
18+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/golang"
19+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/gradle"
20+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/mvn"
21+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/npm"
22+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/terraform"
23+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/yarn"
1924
commandsUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils"
20-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/yarn"
2125
containerutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container"
2226
"github.com/jfrog/jfrog-cli-core/v2/common/build"
2327
commonCliUtils "github.com/jfrog/jfrog-cli-core/v2/common/cliutils"
@@ -65,11 +69,23 @@ import (
6569
)
6670

6771
const (
68-
buildToolsCategory = "Build Tools"
72+
buildToolsCategory = "Package Managers:"
6973
)
7074

7175
func GetCommands() []cli.Command {
7276
return cliutils.GetSortedCommands(cli.CommandsByName{
77+
{
78+
// Currently, the setup command is hidden from the help menu, till it will be released as GA.
79+
Hidden: true,
80+
Name: "setup",
81+
Flags: cliutils.GetCommandFlags(cliutils.Setup),
82+
Usage: setupdocs.GetDescription(),
83+
HelpName: corecommon.CreateUsage("setup", setupdocs.GetDescription(), setupdocs.Usage),
84+
ArgsUsage: common.CreateEnvVars(),
85+
UsageText: setupdocs.GetArguments(),
86+
BashComplete: corecommon.CreateBashCompletionFunc(setup.GetSupportedPackageManagersList()...),
87+
Action: setupCmd,
88+
},
7389
{
7490
Name: "mvn-config",
7591
Aliases: []string{"mvnc"},
@@ -929,6 +945,63 @@ func NpmPublishCmd(c *cli.Context) (err error) {
929945
return
930946
}
931947

948+
func setupCmd(c *cli.Context) (err error) {
949+
if c.NArg() > 1 {
950+
return cliutils.WrongNumberOfArgumentsHandler(c)
951+
}
952+
var packageManager project.ProjectType
953+
packageManagerStr := c.Args().Get(0)
954+
// If the package manager was provided as an argument, validate it.
955+
if packageManagerStr != "" {
956+
packageManager = project.FromString(packageManagerStr)
957+
if !setup.IsSupportedPackageManager(packageManager) {
958+
return cliutils.PrintHelpAndReturnError(fmt.Sprintf("The package manager %s is not supported", packageManagerStr), c)
959+
}
960+
} else {
961+
// If the package manager wasn't provided as an argument, select it interactively.
962+
packageManager, err = selectPackageManagerInteractively()
963+
if err != nil {
964+
return
965+
}
966+
}
967+
setupCmd := setup.NewSetupCommand(packageManager)
968+
artDetails, err := cliutils.CreateArtifactoryDetailsByFlags(c)
969+
if err != nil {
970+
return err
971+
}
972+
repoName := c.String("repo")
973+
if repoName != "" {
974+
// If a repository was provided, validate it exists in Artifactory.
975+
if err = validateRepoExists(repoName, artDetails); err != nil {
976+
return err
977+
}
978+
}
979+
setupCmd.SetServerDetails(artDetails).SetRepoName(repoName).SetProjectKey(cliutils.GetProject(c))
980+
return commands.Exec(setupCmd)
981+
}
982+
983+
// validateRepoExists checks if the specified repository exists in Artifactory.
984+
func validateRepoExists(repoName string, artDetails *coreConfig.ServerDetails) error {
985+
serviceDetails, err := artDetails.CreateArtAuthConfig()
986+
if err != nil {
987+
return err
988+
}
989+
return utils.ValidateRepoExists(repoName, serviceDetails)
990+
}
991+
992+
func selectPackageManagerInteractively() (selectedPackageManager project.ProjectType, err error) {
993+
var selected string
994+
var selectableItems []ioutils.PromptItem
995+
for _, packageManager := range setup.GetSupportedPackageManagersList() {
996+
selectableItems = append(selectableItems, ioutils.PromptItem{Option: packageManager, TargetValue: &selected})
997+
}
998+
err = ioutils.SelectString(selectableItems, "Please select a package manager to set up:", false, func(item ioutils.PromptItem) {
999+
*item.TargetValue = item.Option
1000+
selectedPackageManager = project.FromString(*item.TargetValue)
1001+
})
1002+
return
1003+
}
1004+
9321005
func GetNpmConfigAndArgs(c *cli.Context) (configFilePath string, args []string, err error) {
9331006
configFilePath, err = getProjectConfigPathOrThrow(project.Npm, "npm", "npm-config")
9341007
if err != nil {

buildtools/help.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package buildtools
22

33
import (
44
corecommon "github.com/jfrog/jfrog-cli-core/v2/docs/common"
5+
"github.com/jfrog/jfrog-cli/docs/artifactory/npmpublish"
56
"github.com/jfrog/jfrog-cli/docs/buildtools/dockerpull"
67
"github.com/jfrog/jfrog-cli/docs/buildtools/dockerpush"
78
"github.com/jfrog/jfrog-cli/docs/buildtools/npmci"
89
"github.com/jfrog/jfrog-cli/docs/buildtools/npminstall"
9-
"github.com/jfrog/jfrog-cli/docs/buildtools/npmpublish"
1010
"github.com/jfrog/jfrog-cli/docs/common"
1111
"github.com/jfrog/jfrog-cli/utils/cliutils"
1212
"github.com/urfave/cli"

distribution/cli.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package distribution
22

33
import (
44
"errors"
5+
distributionCommands "github.com/jfrog/jfrog-cli-artifactory/distribution/commands"
56
commonCliUtils "github.com/jfrog/jfrog-cli-core/v2/common/cliutils"
67
"github.com/jfrog/jfrog-cli-core/v2/common/commands"
78
"github.com/jfrog/jfrog-cli-core/v2/common/spec"
8-
distributionCommands "github.com/jfrog/jfrog-cli-core/v2/distribution/commands"
99
coreCommonDocs "github.com/jfrog/jfrog-cli-core/v2/docs/common"
1010
coreConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config"
1111
"github.com/jfrog/jfrog-cli/docs/artifactory/releasebundlecreate"

docker_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414

1515
"github.com/jfrog/build-info-go/entities"
1616
"github.com/jfrog/gofrog/version"
17-
coreContainer "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container"
18-
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
17+
coreContainer "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/container"
18+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/generic"
1919
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
2020
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container"
2121
"github.com/jfrog/jfrog-cli-core/v2/common/build"

docs/buildtools/setup/help.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package setup
2+
3+
import (
4+
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/setup"
5+
"strings"
6+
)
7+
8+
var Usage = []string{"setup [command options]",
9+
"setup <package manager> [command options]"}
10+
11+
func GetDescription() string {
12+
return "An interactive command to configure your local package manager (e.g., npm, pip) to work with JFrog Artifactory."
13+
}
14+
15+
func GetArguments() string {
16+
return ` package manager
17+
The package manager to configure. Supported package managers are: ` + strings.Join(setup.GetSupportedPackageManagersList(), ", ") + "."
18+
}

0 commit comments

Comments
 (0)