Ask Your Question
3

How can you utilize the package.json scripts to upload content to Azure Artifact?

asked 2023-05-15 06:25:54 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-05-15 06:28:01 +0000

huitzilopochtli gravatar image
  1. First, you need to have an Azure Artifacts feed and an access token to authenticate your requests.
  2. Add the @azure/devops package to your project using the command npm install --save-dev @azure/devops.
  3. Inside your package.json file, add a new script that utilizes the vsts-npm-auth command to authenticate with your Azure Artifacts feed. For example:
"scripts": {
  "azure-auth": "vsts-npm-auth -config .npmrc"
}
  1. Run the azure-auth script to authenticate your request. This will create an .npmrc file in your project root directory.
  2. Add another script that uses the npm publish command to publish your package to Azure Artifacts. Make sure to use the --registry flag to specify your Azure Artifacts feed. For example:
"scripts": {
  "azure-auth": "vsts-npm-auth -config .npmrc",
  "publish": "npm publish --registry https://pkgs.dev.azure.com/{org}/{project}/_packaging/{feedId}/npm/{scope}/dist/ --access=public"
}

Replace {org}, {project}, {feedId}, and {scope} with your own values. The --access=public flag makes your package accessible to the public.

  1. Run the publish script to upload your package to Azure Artifacts.
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-15 06:25:54 +0000

Seen: 8 times

Last updated: May 15 '23