Skip to content

Commit

Permalink
Fix npm output and some syntax issues (#900)
Browse files Browse the repository at this point in the history
  • Loading branch information
sverdlov93 authored Aug 20, 2023
1 parent 5593b81 commit 42a2e0e
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 96 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on:
pull_request:
jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macOS-latest ]
os: [ ubuntu, windows, macOS ]
env:
GOPROXY: direct
GRADLE_OPTS: -Dorg.gradle.daemon=false
Expand Down
10 changes: 5 additions & 5 deletions artifactory/commands/buildinfo/publish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,16 @@ func TestPrintBuildInfoLink(t *testing.T) {
config.ServerDetails{ArtifactoryUrl: "http://localhost:8082/artifactory/"}, "http://localhost:8082/ui/builds/test/1/" + buildTime + "/published?buildRepo=cli-build-info&projectKey=cli"},
}

for _, linkType := range linkTypes {
for i := range linkTypes {
buildPubConf := &BuildPublishCommand{
linkType.buildInfoConf,
&linkType.serverDetails,
linkTypes[i].buildInfoConf,
&linkTypes[i].serverDetails,
nil,
true,
nil,
}
buildPubComService, err := buildPubConf.getBuildInfoUiUrl(linkType.majorVersion, linkType.buildTime)
buildPubComService, err := buildPubConf.getBuildInfoUiUrl(linkTypes[i].majorVersion, linkTypes[i].buildTime)
assert.NoError(t, err)
assert.Equal(t, buildPubComService, linkType.expected)
assert.Equal(t, buildPubComService, linkTypes[i].expected)
}
}
1 change: 0 additions & 1 deletion artifactory/commands/npm/npmcommand.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ func (ca *NpmCommand) Run() (err error) {
if err = ca.collectDependencies(); err != nil {
return
}
log.Info(fmt.Sprintf("npm %s finished successfully.", ca.cmdName))
return
}

Expand Down
3 changes: 1 addition & 2 deletions artifactory/commands/transfer/settings.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package transfer

import (
"errors"
"fmt"
"strconv"

Expand Down Expand Up @@ -36,7 +35,7 @@ func (tst *TransferSettingsCommand) Run() error {
ioutils.ScanFromConsole("Set the maximum number of working threads", &threadsNumberInput, currThreadsNumber)
threadsNumber, err := strconv.Atoi(threadsNumberInput)
if err != nil || threadsNumber < 1 || threadsNumber > MaxThreadsLimit {
return errorutils.CheckError(errors.New("the value must be a number between 1 and " + strconv.Itoa(MaxThreadsLimit)))
return errorutils.CheckErrorf("the value must be a number between 1 and " + strconv.Itoa(MaxThreadsLimit))
}
conf := &utils.TransferSettings{ThreadsNumber: threadsNumber}
err = utils.SaveTransferSettings(conf)
Expand Down
7 changes: 4 additions & 3 deletions artifactory/commands/yarn/yarn.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (
)

const (
YarnrcFileName = ".yarnrc.yml"
YarnrcBackupFileName = "jfrog.yarnrc.backup"
NpmScopesConfigName = "npmScopes"
YarnrcFileName = ".yarnrc.yml"
YarnrcBackupFileName = "jfrog.yarnrc.backup"
NpmScopesConfigName = "npmScopes"
//#nosec G101
yarnNpmRegistryServerEnv = "YARN_NPM_REGISTRY_SERVER"
yarnNpmAuthIndent = "YARN_NPM_AUTH_IDENT"
yarnNpmAlwaysAuth = "YARN_NPM_ALWAYS_AUTH"
Expand Down
16 changes: 10 additions & 6 deletions artifactory/utils/container/buildinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ func TestManifestConfig(t *testing.T) {
assert.Len(t, dependencies, 2)
}

// #nosec G602
func createManifestConfig() (map[string]*utils.ResultItem, string) {
config := make(map[string]*utils.ResultItem, 0)
config := make(map[string]*utils.ResultItem)
config["manifest.json"] = dummySearchResults
config["sha__123"] = dummySearchResults
return config, "sha:123"
Expand All @@ -73,7 +74,7 @@ func TestManifestConfigNoManifestFound(t *testing.T) {
}

func createEmptyManifestConfig() (map[string]*utils.ResultItem, string) {
config := make(map[string]*utils.ResultItem, 0)
config := make(map[string]*utils.ResultItem)
return config, "sha:123"
}

Expand All @@ -83,7 +84,7 @@ func TestManifestConfigNoLayer(t *testing.T) {
}

func createManifestConfigWithNoLayer() (map[string]*utils.ResultItem, string) {
config := make(map[string]*utils.ResultItem, 0)
config := make(map[string]*utils.ResultItem)
config["manifest.json"] = dummySearchResults
return config, "sha:123"
}
Expand All @@ -95,14 +96,15 @@ func TestGetDependenciesFromManifestLayer(t *testing.T) {
assert.Len(t, dependencies, 1)
}

// #nosec G602
func createManifestConfigWithLayer() (map[string]*utils.ResultItem, *manifest) {
manifest := &manifest{
Layers: []layer{{
Digest: "sha:1",
MediaType: "MediaType",
}},
}
searchResults := make(map[string]*utils.ResultItem, 0)
searchResults := make(map[string]*utils.ResultItem)
searchResults["manifest.json"] = dummySearchResults
searchResults["sha__1"] = dummySearchResults
searchResults["sha__2"] = dummySearchResults
Expand All @@ -115,6 +117,7 @@ func TestMissingDependenciesInManifestLayer(t *testing.T) {
assert.ErrorContains(t, err, "Could not find layer: sha__2 in Artifactory")
}

// #nosec G602
func createManifestConfigWithMissingLayer() (map[string]*utils.ResultItem, *manifest) {
manifest := &manifest{
Layers: []layer{
Expand All @@ -129,7 +132,7 @@ func createManifestConfigWithMissingLayer() (map[string]*utils.ResultItem, *mani
},
},
}
searchResults := make(map[string]*utils.ResultItem, 0)
searchResults := make(map[string]*utils.ResultItem)
searchResults["manifest.json"] = dummySearchResults
searchResults["sha__1"] = dummySearchResults
return searchResults, manifest
Expand All @@ -142,6 +145,7 @@ func TestForeignDependenciesInManifestLayer(t *testing.T) {
assert.Len(t, dependencies, 1)
}

// #nosec G602
func createManifestConfigWithForeignLayer() (map[string]*utils.ResultItem, *manifest) {
manifest := &manifest{
Layers: []layer{
Expand All @@ -156,7 +160,7 @@ func createManifestConfigWithForeignLayer() (map[string]*utils.ResultItem, *mani
},
},
}
searchResults := make(map[string]*utils.ResultItem, 0)
searchResults := make(map[string]*utils.ResultItem)
searchResults["manifest.json"] = dummySearchResults
searchResults["sha__1"] = dummySearchResults
return searchResults, manifest
Expand Down
3 changes: 1 addition & 2 deletions general/envsetup/envsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package envsetup
import (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"github.com/google/uuid"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
Expand Down Expand Up @@ -245,7 +244,7 @@ func (ftc *EnvSetupCommand) scanAndValidateJFrogPasswordFromConsole(server *conf
}
log.Output(err.Error())
}
err = errorutils.CheckError(errors.New("bad credentials: Wrong password. "))
err = errorutils.CheckErrorf("bad credentials: Wrong password. ")
return
}

Expand Down
30 changes: 15 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ require (
github.com/jfrog/jfrog-client-go v1.31.4
github.com/magiconair/properties v1.8.7
github.com/manifoldco/promptui v0.9.0
github.com/owenrumney/go-sarif/v2 v2.1.3
github.com/owenrumney/go-sarif/v2 v2.2.0
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/spf13/viper v1.15.0
github.com/spf13/viper v1.16.0
github.com/stretchr/testify v1.8.4
github.com/urfave/cli v1.22.14
github.com/vbauerster/mpb/v7 v7.5.3
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b
golang.org/x/mod v0.11.0
golang.org/x/sync v0.2.0
golang.org/x/term v0.10.0
golang.org/x/text v0.11.0
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
golang.org/x/mod v0.12.0
golang.org/x/sync v0.3.0
golang.org/x/term v0.11.0
golang.org/x/text v0.12.0
gopkg.in/yaml.v3 v3.0.1
)

Expand Down Expand Up @@ -67,7 +67,7 @@ require (
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pierrec/lz4/v4 v4.1.15 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/term v1.1.0 // indirect
Expand All @@ -76,25 +76,25 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/skeema/knownhosts v1.2.0 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/ulikunitz/xz v0.5.9 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/net v0.13.0 // indirect; indirectmake
golang.org/x/sys v0.10.0 // indirect
golang.org/x/tools v0.7.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect; indirectmake
golang.org/x/sys v0.11.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)

// replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.28.1-0.20230803140217-0a5f43783ae8

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230803131422-8230595ceb86
replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.9-0.20230820165857-52ff32c4d8eb

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.6-0.20230418122323-2bf299dd6d27
Loading

0 comments on commit 42a2e0e

Please sign in to comment.