Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrog-ecosystem committed Feb 10, 2025
2 parents 8800f64 + 12a5ce0 commit cd4cbbf
Show file tree
Hide file tree
Showing 33 changed files with 690 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nugetTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Install .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.x'
dotnet-version: '8.x'

- name: Install NuGet
uses: nuget/setup-nuget@v2
Expand Down
25 changes: 13 additions & 12 deletions artifactory/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package artifactory
import (
"errors"
"fmt"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/python"
"github.com/jfrog/jfrog-cli/docs/artifactory/cocoapodsconfig"
"github.com/jfrog/jfrog-cli/docs/artifactory/swiftconfig"
"os"
Expand All @@ -13,19 +14,19 @@ import (
"github.com/jfrog/jfrog-cli/utils/accesstoken"

"github.com/jfrog/gofrog/version"
coregeneric "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferinstall"
"github.com/jfrog/jfrog-cli/docs/artifactory/transferplugininstall"

"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/buildinfo"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/curl"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/dotnet"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/oc"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/permissiontarget"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/python"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/replication"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/repository"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/buildinfo"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/container"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/curl"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/dotnet"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/generic"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/oc"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/permissiontarget"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/replication"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/repository"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transfer"
transferconfigcore "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferconfig"
transferfilescore "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/transferfiles"
Expand Down Expand Up @@ -1249,7 +1250,7 @@ func pingCmd(c *cli.Context) error {
if err != nil {
return err
}
pingCmd := generic.NewPingCommand()
pingCmd := coregeneric.NewPingCommand()
pingCmd.SetServerDetails(artDetails)
err = commands.Exec(pingCmd)
resString := clientutils.IndentJson(pingCmd.Response())
Expand Down Expand Up @@ -1870,7 +1871,7 @@ func buildScanLegacyCmd(c *cli.Context) error {

func checkBuildScanError(err error) error {
// If the build was found vulnerable, exit with ExitCodeVulnerableBuild.
if err == utils.GetBuildScanError() {
if errors.Is(err, utils.GetBuildScanError()) {
return coreutils.CliError{ExitCode: coreutils.ExitCodeVulnerableBuild, ErrorMsg: err.Error()}
}
// If the scan operation failed, for example due to HTTP timeout, exit with ExitCodeError.
Expand Down
2 changes: 1 addition & 1 deletion artifactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/jfrog/archiver/v3"
gofrogio "github.com/jfrog/gofrog/io"
"github.com/jfrog/gofrog/version"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/generic"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
commonCliUtils "github.com/jfrog/jfrog-cli-core/v2/common/cliutils"
"github.com/jfrog/jfrog-cli-core/v2/common/commands"
Expand Down
2 changes: 1 addition & 1 deletion build/npm/v2-jf/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/npm/v2-jf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jfrog-cli-v2-jf",
"version": "2.73.2",
"version": "2.73.3",
"description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸",
"homepage": "https://github.com/jfrog/jfrog-cli",
"preferGlobal": true,
Expand Down
2 changes: 1 addition & 1 deletion build/npm/v2/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/npm/v2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jfrog-cli-v2",
"version": "2.73.2",
"version": "2.73.3",
"description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸",
"homepage": "https://github.com/jfrog/jfrog-cli",
"preferGlobal": true,
Expand Down
4 changes: 2 additions & 2 deletions buildinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import (
"strings"
"testing"

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

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

"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/generic"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
coretests "github.com/jfrog/jfrog-cli-core/v2/utils/tests"
Expand Down
93 changes: 83 additions & 10 deletions buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ package buildtools
import (
"errors"
"fmt"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/python"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/setup"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/utils/ioutils"
"github.com/jfrog/jfrog-cli-security/utils/techutils"
setupdocs "github.com/jfrog/jfrog-cli/docs/buildtools/setup"
"os"
"strconv"
"strings"

"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/dotnet"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/golang"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/gradle"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/mvn"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/npm"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/python"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/terraform"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/container"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/dotnet"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/golang"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/gradle"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/mvn"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/npm"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/terraform"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/yarn"
commandsUtils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/yarn"
containerutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container"
"github.com/jfrog/jfrog-cli-core/v2/common/build"
commonCliUtils "github.com/jfrog/jfrog-cli-core/v2/common/cliutils"
Expand Down Expand Up @@ -65,11 +69,23 @@ import (
)

const (
buildToolsCategory = "Build Tools"
buildToolsCategory = "Package Managers:"
)

func GetCommands() []cli.Command {
return cliutils.GetSortedCommands(cli.CommandsByName{
{
// Currently, the setup command is hidden from the help menu, till it will be released as GA.
Hidden: true,
Name: "setup",
Flags: cliutils.GetCommandFlags(cliutils.Setup),
Usage: setupdocs.GetDescription(),
HelpName: corecommon.CreateUsage("setup", setupdocs.GetDescription(), setupdocs.Usage),
ArgsUsage: common.CreateEnvVars(),
UsageText: setupdocs.GetArguments(),
BashComplete: corecommon.CreateBashCompletionFunc(setup.GetSupportedPackageManagersList()...),
Action: setupCmd,
},
{
Name: "mvn-config",
Aliases: []string{"mvnc"},
Expand Down Expand Up @@ -929,6 +945,63 @@ func NpmPublishCmd(c *cli.Context) (err error) {
return
}

func setupCmd(c *cli.Context) (err error) {
if c.NArg() > 1 {
return cliutils.WrongNumberOfArgumentsHandler(c)
}
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 cliutils.PrintHelpAndReturnError(fmt.Sprintf("The package manager %s is not supported", packageManagerStr), c)
}
} 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
}
repoName := c.String("repo")
if repoName != "" {
// If a repository was provided, validate it exists in Artifactory.
if err = validateRepoExists(repoName, artDetails); err != nil {
return err
}
}
setupCmd.SetServerDetails(artDetails).SetRepoName(repoName).SetProjectKey(cliutils.GetProject(c))
return commands.Exec(setupCmd)
}

// validateRepoExists checks if the specified repository exists in Artifactory.
func validateRepoExists(repoName string, artDetails *coreConfig.ServerDetails) error {
serviceDetails, err := artDetails.CreateArtAuthConfig()
if err != nil {
return err
}
return utils.ValidateRepoExists(repoName, serviceDetails)
}

func selectPackageManagerInteractively() (selectedPackageManager project.ProjectType, err error) {
var selected string
var selectableItems []ioutils.PromptItem
for _, packageManager := range setup.GetSupportedPackageManagersList() {
selectableItems = append(selectableItems, ioutils.PromptItem{Option: packageManager, TargetValue: &selected})
}
err = ioutils.SelectString(selectableItems, "Please select a package manager to set up:", false, func(item ioutils.PromptItem) {
*item.TargetValue = item.Option
selectedPackageManager = project.FromString(*item.TargetValue)
})
return
}

func GetNpmConfigAndArgs(c *cli.Context) (configFilePath string, args []string, err error) {
configFilePath, err = getProjectConfigPathOrThrow(project.Npm, "npm", "npm-config")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion buildtools/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package buildtools

import (
corecommon "github.com/jfrog/jfrog-cli-core/v2/docs/common"
"github.com/jfrog/jfrog-cli/docs/artifactory/npmpublish"
"github.com/jfrog/jfrog-cli/docs/buildtools/dockerpull"
"github.com/jfrog/jfrog-cli/docs/buildtools/dockerpush"
"github.com/jfrog/jfrog-cli/docs/buildtools/npmci"
"github.com/jfrog/jfrog-cli/docs/buildtools/npminstall"
"github.com/jfrog/jfrog-cli/docs/buildtools/npmpublish"
"github.com/jfrog/jfrog-cli/docs/common"
"github.com/jfrog/jfrog-cli/utils/cliutils"
"github.com/urfave/cli"
Expand Down
2 changes: 1 addition & 1 deletion distribution/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package distribution

import (
"errors"
distributionCommands "github.com/jfrog/jfrog-cli-artifactory/distribution/commands"
commonCliUtils "github.com/jfrog/jfrog-cli-core/v2/common/cliutils"
"github.com/jfrog/jfrog-cli-core/v2/common/commands"
"github.com/jfrog/jfrog-cli-core/v2/common/spec"
distributionCommands "github.com/jfrog/jfrog-cli-core/v2/distribution/commands"
coreCommonDocs "github.com/jfrog/jfrog-cli-core/v2/docs/common"
coreConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli/docs/artifactory/releasebundlecreate"
Expand Down
4 changes: 2 additions & 2 deletions docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (

"github.com/jfrog/build-info-go/entities"
"github.com/jfrog/gofrog/version"
coreContainer "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/container"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
coreContainer "github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/container"
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/generic"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container"
"github.com/jfrog/jfrog-cli-core/v2/common/build"
Expand Down
18 changes: 18 additions & 0 deletions docs/buildtools/setup/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package setup

import (
"github.com/jfrog/jfrog-cli-artifactory/artifactory/commands/setup"
"strings"
)

var Usage = []string{"setup [command options]",
"setup <package manager> [command options]"}

func GetDescription() string {
return "An interactive command to configure your local package manager (e.g., npm, pip) to work with JFrog Artifactory."
}

func GetArguments() string {
return ` package manager
The package manager to configure. Supported package managers are: ` + strings.Join(setup.GetSupportedPackageManagersList(), ", ") + "."
}
Loading

0 comments on commit cd4cbbf

Please sign in to comment.