Skip to content

Commit e79312f

Browse files
authored
Support npm run native (jfrog#3359)
1 parent c83edaa commit e79312f

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/jfrog/build-info-go v1.13.1-0.20260130140656-2d0d5593fccf
2020
github.com/jfrog/gofrog v1.7.6
2121
github.com/jfrog/jfrog-cli-application v1.0.2-0.20260202095705-3657239cde88
22-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260210060138-bbe22834d469
22+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260217053715-8c4de790d46d
2323
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260202114755-cec5fd702f50
2424
github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20260202100913-d9ee9476845a
2525
github.com/jfrog/jfrog-cli-platform-services v1.10.1-0.20251205121610-171eb9b0000e
@@ -257,8 +257,6 @@ replace github.com/gfleury/go-bitbucket-v1 => github.com/gfleury/go-bitbucket-v1
257257

258258
replace github.com/ktrysmt/go-bitbucket => github.com/ktrysmt/go-bitbucket v0.9.80
259259

260-
//replace github.com/jfrog/jfrog-cli-artifactory => github.com/naveenku-jfrog/jfrog-cli-artifactory v0.0.0-20260205125834-9726cdd29d6d
261-
262260
//replace github.com/jfrog/jfrog-cli-core/v2 => ../jfrog-cli-core
263261

264262
// replace github.com/jfrog/jfrog-cli-artifactory => github.com/fluxxBot/jfrog-cli-artifactory v0.0.0-20260130044429-464a5025d08a

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ github.com/jfrog/jfrog-apps-config v1.0.1 h1:mtv6k7g8A8BVhlHGlSveapqf4mJfonwvXYL
419419
github.com/jfrog/jfrog-apps-config v1.0.1/go.mod h1:8AIIr1oY9JuH5dylz2S6f8Ym2MaadPLR6noCBO4C22w=
420420
github.com/jfrog/jfrog-cli-application v1.0.2-0.20260202095705-3657239cde88 h1:KP6SmrduuGMMsMfHhBATv5I3W1iTtjBojtqEkPHBWk4=
421421
github.com/jfrog/jfrog-cli-application v1.0.2-0.20260202095705-3657239cde88/go.mod h1:xum2HquWO5uExa/A7MQs3TgJJVEeoqTR+6Z4mfBr1Xw=
422-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260210060138-bbe22834d469 h1:uCC03HffS+KPfd9rmW61jAmv7fi8FyJwUrw4FfioIYM=
423-
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260210060138-bbe22834d469/go.mod h1:1GKFtQs/5/3HRp1JyMHMQVT9lxzXR+YecO6dWdRThNs=
422+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260217053715-8c4de790d46d h1:kKPrjRz5RnmFVtjm3F8QGrnlFcFX6c2GQyKwkY1/V24=
423+
github.com/jfrog/jfrog-cli-artifactory v0.8.1-0.20260217053715-8c4de790d46d/go.mod h1:1GKFtQs/5/3HRp1JyMHMQVT9lxzXR+YecO6dWdRThNs=
424424
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260202114755-cec5fd702f50 h1:u3NvevCPC5ygeOMv39XSlpIOCt7PhLtFWR2XZ0QkKaU=
425425
github.com/jfrog/jfrog-cli-core/v2 v2.60.1-0.20260202114755-cec5fd702f50/go.mod h1:+Hnaikp/xCSPD/q7txxRy4Zc0wzjW/usrCSf+6uONSQ=
426426
github.com/jfrog/jfrog-cli-evidence v0.8.3-0.20260202100913-d9ee9476845a h1:lTOAhUjKcOmM/0Kbj4V+I/VHPlW7YNAhIEVpGnCM5mI=

npm_test.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,18 @@ func TestNpmInstallClientNative(t *testing.T) {
235235

236236
packageJsonPath := npmProjectDirectory + "/package.json"
237237
moduleName := readModuleId(t, packageJsonPath, npmVersion)
238-
runJfrogCli(t, "npm", "i", "--run-native=true", "--build-name="+tests.NpmBuildName, "--build-number="+buildNumber)
238+
// Set JFROG_RUN_NATIVE=true for native npm mode
239+
clientTestUtils.SetEnvAndAssert(t, "JFROG_RUN_NATIVE", "true")
240+
defer clientTestUtils.UnSetEnvAndAssert(t, "JFROG_RUN_NATIVE")
241+
242+
runJfrogCli(t, "npm", "i", "--build-name="+tests.NpmBuildName, "--build-number="+buildNumber)
239243
validateNpmLocalBuildInfo(t, tests.NpmBuildName, buildNumber, moduleName)
240244
assert.NoError(t, artifactoryCli.Exec("bp", tests.NpmBuildName, buildNumber))
241245

242246
npmTest := npmTestParams{
243-
testName: "npm with run-native",
247+
testName: "npm with run-native (JFROG_RUN_NATIVE=true)",
244248
buildNumber: buildNumber,
245-
npmArgs: "--run-native=true",
249+
npmArgs: "",
246250
}
247251

248252
validateNpmInstall(t, npmTest, isNpm7(npmVersion))
@@ -265,6 +269,7 @@ func createNpmrcForTesting(t *testing.T, configFilePath string) (err error) {
265269
}
266270

267271
func publishUsingNpmrc(configFilePath string, buildNumber string) (npm.NpmPublishCommand, error) {
272+
// Use deprecated --run-native flag to test backward compatibility (shows deprecation warning)
268273
args := []string{"--run-native=true", "--build-name=" + tests.NpmBuildName, "--build-number=" + buildNumber}
269274
npmpCmd := npm.NewNpmPublishCommand()
270275
npmpCmd.SetConfigFilePath(configFilePath).SetArgs(args)
@@ -578,6 +583,8 @@ func initNpmTest(t *testing.T) {
578583
if !*tests.TestNpm {
579584
t.Skip("Skipping Npm test. To run Npm test add the '-test.npm=true' option.")
580585
}
586+
// Ensure JFROG_RUN_NATIVE is not set (clean state for non-native tests)
587+
_ = os.Unsetenv("JFROG_RUN_NATIVE")
581588
createJfrogHomeConfig(t, true)
582589
}
583590

@@ -851,14 +858,18 @@ func TestNpmPublishWithWorkspacesRunNative(t *testing.T) {
851858
npmProjectPath := initNpmWorkspacesProjectTest(t)
852859
configFilePath := filepath.Join(npmProjectPath, ".jfrog", "projects", "npm.yaml")
853860

854-
// Create npmrc for run-native functionality
861+
// Create npmrc for native functionality
855862
err = createNpmrcForTesting(t, configFilePath)
856863
assert.NoError(t, err)
857864

858-
// Add build info parameters with run-native flag
865+
// Set JFROG_RUN_NATIVE=true for native npm mode
866+
clientTestUtils.SetEnvAndAssert(t, "JFROG_RUN_NATIVE", "true")
867+
defer clientTestUtils.UnSetEnvAndAssert(t, "JFROG_RUN_NATIVE")
868+
869+
// Add build info parameters
859870
buildName := tests.NpmBuildName + "-workspaces-native"
860871
buildNumber := "890"
861-
args := []string{"--workspaces", "--build-name=" + buildName, "--build-number=" + buildNumber, "--run-native"}
872+
args := []string{"--workspaces", "--build-name=" + buildName, "--build-number=" + buildNumber}
862873

863874
npmpCmd := npm.NewNpmPublishCommand()
864875
npmpCmd.SetConfigFilePath(configFilePath).SetArgs(args)

utils/cliutils/commandsflags.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1745,7 +1745,7 @@ var flagsMap = map[string]cli.Flag{
17451745
},
17461746
runNative: cli.BoolFlag{
17471747
Name: runNative,
1748-
Usage: "[Default: false] Set to true if you'd like to use the native client configurations. Note: This flag would invoke native client behind the scenes, has performance implications and does not support deployment view and detailed summary` `",
1748+
Usage: "[Default: false][DEPRECATED: Use JFROG_RUN_NATIVE=true environment variable instead] Set to true if you'd like to use the native client configurations. Note: This flag would invoke native client behind the scenes, has performance implications and does not support deployment view and detailed summary` `",
17491749
},
17501750
npmWorkspaces: cli.BoolFlag{
17511751
Name: npmWorkspaces,

0 commit comments

Comments
 (0)