Skip to content

Instantly share code, notes, and snippets.

@scvnc
Created December 9, 2022 23:32
Show Gist options
  • Save scvnc/0567cd25a7f61ad17713b9490d3f4af2 to your computer and use it in GitHub Desktop.
Save scvnc/0567cd25a7f61ad17713b9490d3f4af2 to your computer and use it in GitHub Desktop.
Quickly set-up your Azure Devops npm feed on Mac
#!/bin/bash
# Run this script with cURL:
# curl --silent -sLo $TMPDIR/azpat.sh https://gist.githubusercontent.com/scvnc/0567cd25a7f61ad17713b9490d3f4af2/raw/azpat.sh && bash $TMPDIR/azpat.sh
# Follows instructions from
# https://dev.azure.com/${ORG_SLUG}/${PROJECT_NAME}/_packaging?_a=connect&feed=${ORG_SLUG}
# Select npm from the side and select the "Other" tab in the Project Setup section
set -e
echo -n "What is your Azure Devops organization slug/id: "
read -r ORG_SLUG
grep -q packaging/"${ORG_SLUG}" "$HOME"/.npmrc && {
echo
echo "Warning: this repository may already be configured in .npmrc -- consider removing previous credentials."
echo
}
echo "Generate your auth token here: https://dev.azure.com/${ORG_SLUG}/_details/security/tokens"
echo -n "and then paste in your Token here: "
read -r token
BASE64_ENCODED_PERSONAL_ACCESS_TOKEN=$(echo -n ${token} | base64)
echo "
; begin auth token
//pkgs.dev.azure.com/${ORG_SLUG}/_packaging/${ORG_SLUG}/npm/registry/:username=${ORG_SLUG}
//pkgs.dev.azure.com/${ORG_SLUG}/_packaging/${ORG_SLUG}/npm/registry/:_password=$BASE64_ENCODED_PERSONAL_ACCESS_TOKEN
//pkgs.dev.azure.com/${ORG_SLUG}/_packaging/${ORG_SLUG}/npm/registry/:email=npm requires email to be set but doesn't use the value
//pkgs.dev.azure.com/${ORG_SLUG}/_packaging/${ORG_SLUG}/npm/:username=${ORG_SLUG}
//pkgs.dev.azure.com/${ORG_SLUG}/_packaging/${ORG_SLUG}/npm/:_password=$BASE64_ENCODED_PERSONAL_ACCESS_TOKEN
//pkgs.dev.azure.com/${ORG_SLUG}/_packaging/${ORG_SLUG}/npm/:email=npm requires email to be set but doesn't use the value
; end auth token
" >> $HOME/.npmrc
echo "Added azure config to ${HOME}/.npmrc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment