mthegreat83
mthegreat83

Reputation: 41

what is the best practice of saving npm artifacts in artifactory?

Sorry if this sounds silly but we have very little experience with NPM, our background is maven.

We have NPM repositories setup in Artifactory and we use them to produce a package in war format. Now we are not able to decide what would be the best practice with these war packages, do we store them in a generic type repository in Artifactory ? Is there an equivalent of the mvn deploy ( mvn deploy deploys the package in Artifactory in its portable format ) for NPM ?

Upvotes: 1

Views: 3827

Answers (2)

mthegreat83
mthegreat83

Reputation: 41

Thank you Derek for your answer, after reading your reply, I feel that I didn't explain properly.

Yes npm publish will do the same thing as mvn deploy and publish in our private Artifatory, but mvn deploy publish also the artifact produced in the target folder, in NPM case the artifact produced under dist/ ( a war file in our case ) is not pushed to Artifactory, what is pushed are the source files from which you can build the war. We would like to be able to push the war to Artifactory, one of the solution we found is to use the https://www.npmjs.com/package/maven-deploy and deploy the war to a maven repository in Artifactory, but is this a good practice ? We are curious to know what other people are doing.

Upvotes: 1

Derek Atkinson
Derek Atkinson

Reputation: 53

If you're trying to deploy your package to Artifactory (which is my understanding of what mvn deploy would do), the command is npm publish. To get your package to publish to your private Artifactory repository instead of the public NPM registry, you'll need define your registry URL in your package.json and .npmrc file in the root of your project.

There's a handy walkthrough for this process within Artifactory:

  1. Navigate to your NPM repository in Artifactory
  2. Click "Set Me Up"
  3. Follow the instructions under "General" for setup—this contains the code snippet you'll need for setting up your .npmrc.
  4. Follow the instructions under "Deploy" to deploy—this contains the code snippet you'll need for setting up publishConfig in your package.json.

Artifactory's full NPM documentation is here: https://www.jfrog.com/confluence/display/RTF/Npm+Registry

Lastly, since you're less versed in NPM, here's NPM's guide to the files portion of your package.json where you define the files that will be in your published package: https://docs.npmjs.com/files/package.json#files

Upvotes: 1

Related Questions