Skip to content

Commit 6583684

Browse files
committed
Improve repositores code
Signed-off-by: Michael Sverdlov <[email protected]>
1 parent bb36015 commit 6583684

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

artifactory/commands/npm/login.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package npm
22

33
import (
4-
"github.com/jfrog/gofrog/version"
54
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/repository"
65
cmdutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils"
76
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
@@ -13,10 +12,7 @@ import (
1312
)
1413

1514
type NpmLoginCommand struct {
16-
commandName string
17-
npmVersion *version.Version
18-
repoUrl string
19-
executablePath string
15+
commandName string
2016
CommonArgs
2117
}
2218

artifactory/commands/utils/npmcmdutils_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func TestConfigureRegistry_Yarn(t *testing.T) {
140140
// Verify that the correct .yarnrc entry was added
141141
fileContent, err := os.ReadFile(yarnrcPath)
142142
assert.NoError(t, err)
143-
expectedRegistryLine := fmt.Sprintf("registry \"%sapi/npm/my-repo-virtual\"", testArtifactoryUrl)
143+
expectedRegistryLine := fmt.Sprintf("registry \"%s/api/npm/my-repo-virtual\"", testArtifactoryUrl)
144144
assert.Contains(t, string(fileContent), expectedRegistryLine)
145145
}
146146

@@ -214,15 +214,12 @@ func TestHandleAnonymousAccess_Npm(t *testing.T) {
214214
nm := setupNpmrcManager(project.Npm)
215215
// Set basic auth credentials to be removed on the by the anonymous access method.
216216
assert.NoError(t, nm.handleNpmrcBasicAuth("user", "password"))
217+
assert.FileExists(t, tempNpmrcPath)
217218

218219
err := nm.handleNpmAnonymousAccess()
219220
assert.NoError(t, err)
220-
221-
// Verify that the auth entries were removed from .npmrc
222-
fileContent, err := os.ReadFile(tempNpmrcPath)
223-
assert.NoError(t, err)
224-
assert.NotContains(t, string(fileContent), "_auth")
225-
assert.NotContains(t, string(fileContent), "_authToken")
221+
// Verify that .npmrc was deleted because it should be empty.
222+
assert.NoFileExists(t, tempNpmrcPath)
226223
}
227224

228225
// Test for handling anonymous access in yarn.

artifactory/commands/yarn/login.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package yarn
22

33
import (
4-
"github.com/jfrog/gofrog/version"
54
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/repository"
65
cmdutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/utils"
76
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
@@ -13,11 +12,9 @@ import (
1312
)
1413

1514
type YarnLoginCommand struct {
16-
commandName string
17-
npmVersion *version.Version
18-
executablePath string
19-
repo string
20-
serverDetails *config.ServerDetails
15+
commandName string
16+
repo string
17+
serverDetails *config.ServerDetails
2118
}
2219

2320
func NewYarnLoginCommand() *YarnLoginCommand {

0 commit comments

Comments
 (0)