-
Notifications
You must be signed in to change notification settings - Fork 255
Support npm publish using native npm client with .npmrc via --use-npmrc flag #2952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
useNpmRc: cli.BoolFlag{ | ||
Name: useNpmRc, | ||
Usage: "[Default: false] Set to true if you'd like to use the .npmrc file for configurations. Note: This flag would invoke npm native client behind the scenes, has performance implications and does not support deployment view and detailed summary` `", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useNpmRc: cli.BoolFlag{ | |
Name: useNpmRc, | |
Usage: "[Default: false] Set to true if you'd like to use the .npmrc file for configurations. Note: This flag would invoke npm native client behind the scenes, has performance implications and does not support deployment view and detailed summary` `", | |
}, | |
useNpmRc: cli.BoolFlag{ | |
Name: useNPMRC, | |
Usage: "[Default: false] Set to true to use the .npmrc file for publish. Note: This flag would invoke npm native client behind the scenes, has performance implications and does not support deployment view and detailed summary` `", | |
}, |
@@ -1797,8 +1800,8 @@ func GetGradleDeployedArtifacts() []string { | |||
} | |||
} | |||
|
|||
func GetNpmDeployedScopedArtifacts(isNpm7 bool) []string { | |||
path := NpmRepo + "/@jscope/jfrog-cli-tests/-/@jscope/" | |||
func GetNpmDeployedScopedArtifacts(npmRepo string, isNpm7 bool) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this change required?
return | ||
} | ||
|
||
func publishUsingNpmrc(configFilePath string, buildNumber string) (npm.NpmPublishCommand, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does sample output looks with --use-npmrc
?
legacyCommand: "rt npm-publish", | ||
repo: repoName, | ||
wd: npmProjectPath, | ||
validationFunc: validateNpmPublish, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validateNpmPublish
is validating published module using artifact properties but --use-npmrc flag will not fail when it is not able to set properties. Is there any other way to validate the published artifact using --use-npmrc
?
wd, err := os.Getwd() | ||
assert.NoError(t, err, "Failed to get current dir") | ||
defer clientTestUtils.ChangeDirAndAssert(t, wd) | ||
buildNumber := strconv.Itoa(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buildNumber := strconv.Itoa(1) | |
buildNumber := "1" |
just wondering why not directly to string?
addNpmScopeRegistryToNpmRc(t, npmProjectPath, packageJsonPath, npmVersion) | ||
} | ||
|
||
npmpCmd, err := publishUsingNpmrc(configFilePath, buildNumber) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it npmp
?
result := npmpCmd.Result() | ||
assert.NotNil(t, result) | ||
|
||
validateNpmLocalBuildInfo(t, tests.NpmBuildName, buildNumber, moduleName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we creating build info as well with --use-npmrc
?
@@ -285,6 +393,14 @@ func initNpmProjectTest(t *testing.T) (npmProjectPath string) { | |||
return | |||
} | |||
|
|||
func initNpmPublishRcProjectTest(t *testing.T, projectName string) (npmProjectPath string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func initNpmPublishRcProjectTest(t *testing.T, projectName string) (npmProjectPath string) { | |
func initNpmPublishviaNPMRCTest(t *testing.T, projectName string) (npmProjectPath string) { |
// we do not support deployment view and detailed summary when using npmrc for publishing since | ||
// TransferDetails is not available to us |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// we do not support deployment view and detailed summary when using npmrc for publishing since | |
// TransferDetails is not available to us | |
// Deployment view and Detailed summary is not supported when using npmrc for publishing since transfer details are not available. |
dev
branch.go vet ./...
.go fmt ./...
.This PR introduces a new implementation for the npm publish command that supports both the existing and the updated approach.
--use-npmrc
has been added to opt into the updated publish flow..npmrc
configuration, unlike the older approach which depended on jf config.a. npmPublishHandler: Uses the npm client.
b. rtPublishHandler: Retains the original behavior using Artifactory upload (rt).
depends on: