1

I have an Artifactory server (service). I set up a local repository there that I am using for hosting Unity packages. I figured out how to setup scoped packages that Unity Package Manager can see. It's all working pretty well. My only issue is with command line deploying of the artifacts. From what I read it looks like I need to use "npm publish" to deploy. When I call npm "publish" on the tarball file (package file) that I have, it doesn't get uploaded (deployed) to the server. I have to manually upload it using the web UI. The command itself doesn't fail - it prints out list of files, version, name, etc. And ends with something like this

<package name>@x.x.x

What is the point of the (npm) publish command if that's not how you upload (deploy) packages? What is the proper way to upload packages to Artifactory without using the web interface?

Btw, I started with this tutorial: Medium Article. I get similar output when i run publish command locally, so it seems like that should be uploading the package for me, but it doesn't. Another note: i do use scoped packages - i used all of the instructions that Artifactory and that tutorial provides. I get no errors anywhere. Just nothing happens when i publish.

Any suggestions?

This is the command I run:

npm publish <packagename>.x.x.x.tgz --registry http://<server>artifactory/api/npm/unity_packages/<scope>

I saw this thread thread, but I would rather not use curl (i have to replicate this setup on various machines, so less moving parts is better for me) and it is also super old, so i figured there is a newer / better way to deploy.

I can also "npm install" packages that I deployed using the web UI, so I do't think it's a permission issue.

Sample output:

 npm publish --registry http://artifactory.ops.aws.somecompany.net/artifactory/api/npm/unity_packages/
npm notice 
npm notice   @com.somecompany/com.somecompany.dependencypackageproject@0.1.207
npm notice === Tarball Contents === 
npm notice 388B   DependencyPackageProject.asmdef     
npm notice 611B   Source/Floater.cs                   
npm notice 1.1kB  package_internal.json               
npm notice 1.1kB  package.json                        
npm notice 2.1kB  Material/FloaterMaterial.mat        
npm notice 166B   DependencyPackageProject.asmdef.meta
npm notice 155B   Scenes/DPP_SampleScene.unity.meta   
npm notice 243B   Source/Floater.cs.meta              
npm notice 182B   Material/FloaterMaterial.mat.meta   
npm notice 154B   Prefabs/FloaterPrefab.prefab.meta   
npm notice 172B   Material.meta                       
npm notice 158B   package_internal.json.meta          
npm notice 158B   package.json.meta                   
npm notice 172B   Prefabs.meta                        
npm notice 172B   Scenes.meta                         
npm notice 172B   Source.meta                         
npm notice 4.0kB  Prefabs/FloaterPrefab.prefab        
npm notice 10.3kB Scenes/DPP_SampleScene.unity        
npm notice === Tarball Details === 
npm notice name:          @com.somecompany/com.somecompany.dependencypackageproject
npm notice version:       0.1.207                                              
npm notice package size:  5.5 kB                                               
npm notice unpacked size: 21.4 kB                                              
npm notice shasum:        77188f8f599877d7a6a41bbcb1800057a3fe1646             
npm notice integrity:     sha512-vbtkwkiEacQl/[...]dPb8xlhO36odg==             
npm notice total files:   18                                                   
npm notice 
+ @com.somecompany/com.somecompany.dependencypackageproject@0.1.207
TylerH
  • 20,799
  • 66
  • 75
  • 101
SpaceBear
  • 832
  • 3
  • 8
  • 22
  • Are you referring to the npm publish command? when you try to publish are you getting an error? please share more details like the exact command you are running, any error message you are getting in the npm client/artifactory – Dror Bereznitsky Oct 11 '20 at 13:49
  • @DrorBereznitsky I updated the questions with more details. But, no errors anywhere that I can see. I checked the logs in the .npm/_logs, but no errors there. – SpaceBear Oct 11 '20 at 19:08
  • try running the npm command with --loglevel verbose – Dror Bereznitsky Oct 14 '20 at 07:30
  • @DrorBereznitsky the only useful thing i got out of that is this: npm http fetch PUT 308 http://artifactory.ops.aws.somecompany.net/artifactory/api/npm/unity_packages/com.somecompany.testpackageproject 188ms It certainly feels like it is being uploaded, but I dont see it on the server – SpaceBear Oct 15 '20 at 17:16
  • Please check the Artifactory access.log and look for something similar to 2020-10-12 14:30:56,951 [ACCEPTED DEPLOY] npm-local:@user/craftyjs-npm-example/-/@user/craftyjs-npm-example-1.0.0.tgz for client : admin / 127.0.0.1. and in the artifactory.log try looking for something like Deploying npm package '@user/craftyjs-npm-example/-/@user/craftyjs-npm-example-1.0.0.tgz' into repo 'npm-local' – Dror Bereznitsky Oct 15 '20 at 19:08

1 Answers1

2

In order to publish a scoped npm package to Artifactory using the npm client you need to:

(1) Make sure your package is created as a scoped package as described in the npm documentation

(2) Associate the relevant Artifactory npm repository (for example npm-local) with the scope you are using, by updating your .npmrc configuration file. The file should also contain the authentication information.
You can follow the instructions in the Artifactory documentation. Your .npmrc file should look similar to the following:

@drorb:registry=http://localhost:8081/artifactory/api/npm/npm-local/
//localhost:8081/artifactory/api/npm/npm-local/:_password=*********
//localhost:8081/artifactory/api/npm/npm-local/:username=drorb
//localhost:8081/artifactory/api/npm/npm-local/:email=*****@gmail.com
//localhost:8081/artifactory/api/npm/npm-local/:always-auth=true

(3) Use the npm publish command, for example

npm publish craftyjs-npm-example-1.0.0.tgz  --registry http://localhost:8081/artifactory/api/npm/npm-local/

Output of the publish command should be similar to

npm notice
npm notice   @drorb/craftyjs-npm-example@1.0.0
npm notice === Tarball Contents ===
npm notice 662B package.json
npm notice 587B .npmignore
npm notice 116B README.md
npm notice 195B game.js
npm notice === Tarball Details ===
npm notice name:          @drorb/craftyjs-npm-example
npm notice version:       1.0.0
npm notice package size:  1.6 kB
npm notice unpacked size: 1.6 kB
npm notice shasum:        8ee8bdbfac6ae92fcdcdc7441793671ce59a3584
npm notice integrity:     sha512-4DA3LCwO+vuCo[...]FYPGTtxOrg6UQ==
npm notice total files:   4
npm notice
Dror Bereznitsky
  • 20,048
  • 3
  • 48
  • 57
  • 1
    that's exactly what i do. i get no errors at all and my output looks basically the same. I added it to the question since it's too long to post here – SpaceBear Oct 13 '20 at 21:17
  • Also, turns out you don't need to create a tarball at all, you can just call the publish command from the root of the package – SpaceBear Oct 13 '20 at 21:20