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 Sep 19, 2024
2 parents 955b652 + b514521 commit 795533d
Show file tree
Hide file tree
Showing 25 changed files with 356 additions and 113 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/pythonTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ jobs:
if: ${{ matrix.suite == 'pipenv' }}
run: python -m pip install pipenv

- name: Setup Twine
if: ${{ matrix.suite == 'pip' }}
run: python -m pip install twine

- name: Setup Go with cache
uses: jfrog/.github/actions/install-go-with-cache@main

Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ node("docker-xxlarge") {
repo = 'jfrog-cli'
sh 'rm -rf temp'
sh 'mkdir temp'
def goRoot = tool 'go-1.22.5'
def goRoot = tool 'go-1.23.1'
env.GOROOT="$goRoot"
env.PATH+=":${goRoot}/bin:/tmp/node-${nodeVersion}-linux-x64/bin"
env.GO111MODULE="on"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Scanned by Frogbot](https://raw.github.com/jfrog/frogbot/master/images/frogbot-badge.svg)](https://github.com/jfrog/frogbot#readme)
[![Go Report Card](https://goreportcard.com/badge/github.com/jfrog/jfrog-cli)](https://goreportcard.com/report/github.com/jfrog/jfrog-cli)
[![license](https://img.shields.io/badge/License-Apache_2.0-blue.svg?style=flat)](https://raw.githubusercontent.com/jfrog/jfrog-cli/v2/LICENSE) [![](https://img.shields.io/badge/Docs-%F0%9F%93%96-blue)](https://docs.jfrog-applications.jfrog.io/jfrog-applications/jfrog-cli)
[![Go version](https://img.shields.io/github/go-mod/go-version/jfrog/jfrog-cli)](https://tip.golang.org/doc/go1.22)
[![Go version](https://img.shields.io/github/go-mod/go-version/jfrog/jfrog-cli)](https://tip.golang.org/doc/go1.23)

</div>

Expand Down
2 changes: 1 addition & 1 deletion build/docker/full/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG repo_name_21
# Remove ${repo_name_21} to pull from Docker Hub.
FROM ${repo_name_21}/jfrog-docker/golang:1.22 as builder
FROM ${repo_name_21}/jfrog-docker/golang:1.23 as builder
ARG image_name=jfrog-cli-full
ARG cli_executable_name
WORKDIR /${image_name}
Expand Down
2 changes: 1 addition & 1 deletion build/docker/slim/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG repo_name_21
# Remove ${repo_name_21} to pull from Docker Hub.
FROM ${repo_name_21}/jfrog-docker/golang:1.22-alpine as builder
FROM ${repo_name_21}/jfrog-docker/golang:1.23.1-alpine as builder
ARG image_name=jfrog-cli
ARG cli_executable_name
WORKDIR /${image_name}
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.67.0",
"version": "2.68.0",
"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.67.0",
"version": "2.68.0",
"description": "🐸 Command-line interface for JFrog Artifactory, Xray, Distribution, Pipelines and Mission Control 🐸",
"homepage": "https://github.com/jfrog/jfrog-cli",
"preferGlobal": true,
Expand Down
126 changes: 88 additions & 38 deletions buildtools/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/jfrog/jfrog-cli-security/commands/scan"
terraformdocs "github.com/jfrog/jfrog-cli/docs/artifactory/terraform"
"github.com/jfrog/jfrog-cli/docs/artifactory/terraformconfig"
twinedocs "github.com/jfrog/jfrog-cli/docs/artifactory/twine"
"github.com/jfrog/jfrog-cli/docs/buildtools/docker"
dotnetdocs "github.com/jfrog/jfrog-cli/docs/buildtools/dotnet"
"github.com/jfrog/jfrog-cli/docs/buildtools/dotnetconfig"
Expand Down Expand Up @@ -402,6 +403,18 @@ func GetCommands() []cli.Command {
Category: buildToolsCategory,
Action: terraformCmd,
},
{
Name: "twine",
Flags: cliutils.GetCommandFlags(cliutils.Twine),
Usage: twinedocs.GetDescription(),
HelpName: corecommon.CreateUsage("twine", twinedocs.GetDescription(), twinedocs.Usage),
UsageText: twinedocs.GetArguments(),
ArgsUsage: common.CreateEnvVars(),
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Category: buildToolsCategory,
Action: twineCmd,
},
})
}

Expand All @@ -410,13 +423,11 @@ func MvnCmd(c *cli.Context) (err error) {
return err
}

configFilePath, exists, err := project.GetProjectConfFilePath(project.Maven)
configFilePath, err := getProjectConfigPathOrThrow(project.Maven, "mvn", "mvn-config")
if err != nil {
return err
}
if !exists {
return errors.New("no config file was found! Before running the mvn command on a project for the first time, the project should be configured with the mvn-config command")
}

if c.NArg() < 1 {
return cliutils.WrongNumberOfArgumentsHandler(c)
}
Expand Down Expand Up @@ -469,13 +480,11 @@ func GradleCmd(c *cli.Context) (err error) {
return err
}

configFilePath, exists, err := project.GetProjectConfFilePath(project.Gradle)
configFilePath, err := getProjectConfigPathOrThrow(project.Gradle, "gradle", "gradle-config")
if err != nil {
return err
}
if !exists {
return errors.New("no config file was found! Before running the gradle command on a project for the first time, the project should be configured with the gradle-config command")
}

// Found a config file. Continue as native command.
if c.NArg() < 1 {
return cliutils.WrongNumberOfArgumentsHandler(c)
Expand Down Expand Up @@ -525,13 +534,10 @@ func YarnCmd(c *cli.Context) error {
return err
}

configFilePath, exists, err := project.GetProjectConfFilePath(project.Yarn)
configFilePath, err := getProjectConfigPathOrThrow(project.Yarn, "yarn", "yarn-config")
if err != nil {
return err
}
if !exists {
return fmt.Errorf("no config file was found! Before running the yarn command on a project for the first time, the project should be configured using the yarn-config command")
}

yarnCmd := yarn.NewYarnCommand().SetConfigFilePath(configFilePath).SetArgs(c.Args())
return commands.Exec(yarnCmd)
Expand All @@ -544,15 +550,12 @@ func NugetCmd(c *cli.Context) error {
if c.NArg() < 1 {
return cliutils.WrongNumberOfArgumentsHandler(c)
}
configFilePath, exists, err := project.GetProjectConfFilePath(project.Nuget)

configFilePath, err := getProjectConfigPathOrThrow(project.Nuget, "nuget", "nuget-config")
if err != nil {
return err
}

if !exists {
return fmt.Errorf("no config file was found! Before running the nuget command on a project for the first time, the project should be configured using the nuget-config command")
}

rtDetails, targetRepo, useNugetV2, err := getNugetAndDotnetConfigFields(configFilePath)
if err != nil {
return err
Expand Down Expand Up @@ -584,13 +587,10 @@ func DotnetCmd(c *cli.Context) error {
}

// Get configuration file path.
configFilePath, exists, err := project.GetProjectConfFilePath(project.Dotnet)
configFilePath, err := getProjectConfigPathOrThrow(project.Dotnet, "dotnet", "dotnet-config")
if err != nil {
return err
}
if !exists {
return fmt.Errorf("no config file was found! Before running the dotnet command on a project for the first time, the project should be configured using the dotnet-config command")
}

rtDetails, targetRepo, useNugetV2, err := getNugetAndDotnetConfigFields(configFilePath)
if err != nil {
Expand Down Expand Up @@ -690,14 +690,12 @@ func goCmdVerification(c *cli.Context) (string, error) {
if c.NArg() < 1 {
return "", cliutils.WrongNumberOfArgumentsHandler(c)
}
configFilePath, exists, err := project.GetProjectConfFilePath(project.Go)

configFilePath, err := getProjectConfigPathOrThrow(project.Go, "go", "go-config")
if err != nil {
return "", err
}
// Verify config file is found.
if !exists {
return "", fmt.Errorf("no config file was found! Before running the go command on a project for the first time, the project should be configured using the go-config command")
}

log.Debug("Go config file was found in:", configFilePath)
return configFilePath, nil
}
Expand Down Expand Up @@ -887,13 +885,9 @@ func NpmPublishCmd(c *cli.Context) (err error) {
}

func GetNpmConfigAndArgs(c *cli.Context) (configFilePath string, args []string, err error) {
configFilePath, exists, err := project.GetProjectConfFilePath(project.Npm)
configFilePath, err = getProjectConfigPathOrThrow(project.Npm, "npm", "npm-config")
if err != nil {
return "", nil, err
}

if !exists {
return "", nil, errorutils.CheckErrorf("no config file was found! Before running the npm command on a project for the first time, the project should be configured using the npm-config command")
return
}
_, args = getCommandName(c.Args())
return
Expand Down Expand Up @@ -970,13 +964,9 @@ func terraformCmd(c *cli.Context) error {
}

func getTerraformConfigAndArgs(c *cli.Context) (configFilePath string, args []string, err error) {
configFilePath, exists, err := project.GetProjectConfFilePath(project.Terraform)
configFilePath, err = getProjectConfigPathOrThrow(project.Terraform, "terraform", "terraform-config")
if err != nil {
return "", nil, err
}

if !exists {
return "", nil, errors.New("no config file was found! Before running the terraform command on a project for the first time, the project should be configured using the terraform-config command")
return
}
args = cliutils.ExtractCommand(c)
return
Expand All @@ -992,3 +982,63 @@ func terraformPublishCmd(configFilePath string, args []string, c *cli.Context) e
result := terraformCmd.Result()
return cliutils.PrintBriefSummaryReport(result.SuccessCount(), result.FailCount(), cliutils.IsFailNoOp(c), err)
}

func getProjectConfigPathOrThrow(projectType project.ProjectType, cmdName, configCmdName string) (configFilePath string, err error) {
configFilePath, exists, err := project.GetProjectConfFilePath(projectType)
if err != nil {
return
}
if !exists {
return "", errorutils.CheckErrorf(getMissingConfigErrMsg(cmdName, configCmdName))
}
return
}

func getMissingConfigErrMsg(cmdName, configCmdName string) string {
return fmt.Sprintf("no config file was found! Before running the 'jf %s' command on a project for the first time, the project should be configured with the 'jf %s' command", cmdName, configCmdName)
}

func twineCmd(c *cli.Context) error {
if show, err := cliutils.ShowCmdHelpIfNeeded(c, c.Args()); show || err != nil {
return err
}
serverDetails, targetRepo, err := getTwineConfigAndArgs()
if err != nil {
return err
}
cmdName, filteredArgs := getCommandName(cliutils.ExtractCommand(c))
return python.NewTwineCommand(cmdName).SetServerDetails(serverDetails).SetTargetRepo(targetRepo).SetArgs(filteredArgs).Run()
}

func getTwineConfigAndArgs() (serverDetails *coreConfig.ServerDetails, targetRepo string, err error) {
configFilePath, err := getTwineConfigPath()
if err != nil {
return
}

vConfig, err := project.ReadConfigFile(configFilePath, project.YAML)
if err != nil {
return nil, "", fmt.Errorf("failed while reading configuration file '%s'. Error: %s", configFilePath, err.Error())
}
projectConfig, err := project.GetRepoConfigByPrefix(configFilePath, project.ProjectConfigDeployerPrefix, vConfig)
if err != nil {
return nil, "", err
}
serverDetails, err = projectConfig.ServerDetails()
if err != nil {
return nil, "", err
}
targetRepo = projectConfig.TargetRepo()
return
}

func getTwineConfigPath() (configFilePath string, err error) {
var exists bool
for _, projectType := range []project.ProjectType{project.Pip, project.Pipenv} {
configFilePath, exists, err = project.GetProjectConfFilePath(projectType)
if err != nil || exists {
return
}
}
return "", errorutils.CheckErrorf(getMissingConfigErrMsg("twine", "pip-config OR pipenv-config"))
}
12 changes: 12 additions & 0 deletions docs/artifactory/twine/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package twinedocs

var Usage = []string{"twine <twine arguments> [command options]"}

func GetDescription() string {
return "Runs twine "
}

func GetArguments() string {
return ` twine commands
Arguments and options for the twine command.`
}
Loading

0 comments on commit 795533d

Please sign in to comment.