2

Context

I have an NPM package that I want to have deployed into a private Azure DevOps NPM Registry. We have two types of the package, namely production and a beta. I ran into an issue with Azure DevOps, that it currently doesn't support tagging when publishing a new package (it removes the tags e.g. beta when published).

Question

My question is how do you guys handle this scenario and what is the best practice in Azure DevOps when you have two versions (production and beta) of an NPM package?

SOK
  • 515
  • 6
  • 21

1 Answers1

0

Best practice for production/beta in Azure DevOps NPM Registry

Not sure if my workaround is the best best practice, this is more a matter of taste.

The workaround I used is that define the pre-release version in the package.json with different branches, like:

{
  "version": "1.0.0-bate",
  "name": "asp.net",
  "devDependencies": {
    "jquery": "3.4.1"
  },
  "scripts": {}
}

Then publish it with npm task, we could get the pre-release version in the artifact:

enter image description here

Hope this helps.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • 1
    Thanks for the reply Leo. So if I understand your solution correctly; you are doing the following in a CI/CD pipeline. 1) Edit the package.json and postfixing the version number with "-bate". 2) Publishing the NPM as normally. 3) Do you have a task to automatically assign the package to the prerelease view? Furthermore, how do you handle that all packages are automatically assigned to the "latest" view? – SOK Feb 11 '20 at 07:05
  • @SOK, Yes. -`Do you have a task to automatically assign the package to the prerelease view` You could use the extension Promote package to Release View https://marketplace.visualstudio.com/items?itemName=rvo.vsts-promotepackage-task and rest api https://github.com/MicrosoftDocs/vsts-docs/issues/2333 to automatically assign the package. Not clear the latest question, if this question related to your previous question? If yes, update the question with more info and images, if not, I suggest that you could open a new thread, we recommend one thread per issue. Thanks. – Leo Liu Feb 11 '20 at 07:25
  • Thanks for your feedback @Leo. I used your solution and postfixed the two releases with 'beta' and 'production' and afterward tagged them respectfully with npm publish. The npm registry in Azure tags all packages published with 'latest' so developers have to install the package with either package@beta or package@production to avoid the 'latest' issue in Azure. – SOK Feb 14 '20 at 22:57