The problem
I use Azure DevOps for development and have several projects in it.
And I am using the feeds possibility from Azure DevOps.
This means that I need to change the NPMRC each time I switch projects so that it uses the correct registry.
Or you put that in a .npmrc in the repository but then you need to still handle the authentication somehow...
What?
I thought there must be an easier way.
Inspired by the npmrc project I created my own solution, more tailored for Azure DevOps.
But you should still be able to use it as a npmrc switcher, just like the other package but with some added functionality.
Like an interactive list.
To break it down a bit what it does:
It will create an NPMRC with the provided feed-name as registry AND create a PAT that is allowed to pull data from the artifact feed.
And provide options to automatically renew the PAT.
So how to use it?
Easiest
Only one parameter is required
- feedName (the name of the Artifact feed as created in Azure DevOps)
Then there are a few defaults:
- name of the NPMRC (defaults to the directory name)
Next to the name of the NPMRC and the feedname we also need the details of the Azure DevOps Organization
and Project
.
These two values can be retrieved from the repository.url
if that is set in the package.json
- azOrganization (first part of Azure DevOps url)
- azProject (second part of Azure DevOps url)
Example Azure DevOps url: https://dev.azure.com/henkvandenbrink/kitchensink
azOrganization = henkvandenbrink
azProject = kitchensink
feedName = As specified
Full example:
snmprc create feed-name
This will generate an NPMRC with the specified feed-name as registry, the azure details are retrieved from package.json and current directory name is used as name.
More details options
When you are not able to use the defaults or you just want to have more control, you can specify all the parameters as well.
snpmrc create feed-name henkvandenbrink kitchensink directory-name
This will generate an NPMRC with the specified feed-name as registry, the azure details that are provided and directory-name is used as name.
For all other options, more information and details please go to the simple-aznpmrcs npmjs package where there is a full readme available.
Feature requested are welcome and/or pull requests.
Just another step into automating those manual steps :)
Top comments (0)