Skip to content

Commit 861d780

Browse files
authored
Use authToken in npmrc (#27)
1 parent 333a376 commit 861d780

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/artifacts-helper/NOTES.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ and optionally configures an alias for `dotnet`, `nuget`, `npm`, and `yarn` that
33
for pulling artifacts from a feed before running the command.
44

55
For `npm` and `yarn` this requires that your `~/.npmrc` file is configured to use the ${ARTIFACTS_ACCESSTOKEN}
6-
environment variable for the password. A helper script has been added that you can use to write your `~/.npmrc`
6+
environment variable for the `authToken`. A helper script has been added that you can use to write your `~/.npmrc`
77
file during your setup process, though there are many ways you could accomplish this. To use the script, run it like
88
this:
99

@@ -14,7 +14,16 @@ write-npm.sh pkgs.dev.azure.com/orgname/projectname/_packaging/feed3/npm usernam
1414
```
1515

1616
You must pass the feed name to the script, but you can optionally provide a username and email if desired. Defaults
17-
are put in place if they are not provided.
17+
are put in place if they are not provided. An example of the `.npmrc` file created is this:
18+
19+
```
20+
//pkgs.dev.azure.com/orgname/projectname/_packaging/feed1/npm/registry/:username=codespaces
21+
//pkgs.dev.azure.com/orgname/projectname/_packaging/feed1/npm/registry/:_authToken=${ARTIFACTS_ACCESSTOKEN}
22+
//pkgs.dev.azure.com/orgname/projectname/_packaging/feed1/npm/registry/:email=codespaces@github.com
23+
//pkgs.dev.azure.com/orgname/projectname/_packaging/feed1/npm/:username=codespaces
24+
//pkgs.dev.azure.com/orgname/projectname/_packaging/feed1/npm/:_authToken=${ARTIFACTS_ACCESSTOKEN}
25+
//pkgs.dev.azure.com/orgname/projectname/_packaging/feed1/npm/:email=codespaces@github.com
26+
```
1827

1928
## OS Support
2029

src/artifacts-helper/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Azure Artifacts Credential Helper",
33
"id": "artifacts-helper",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"description": "Configures Codespace to authenticate with Azure Artifact feeds",
66
"options": {
77
"nugetURIPrefixes": {

src/artifacts-helper/scripts/write-npm.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ if [ "${ARTIFACTS_FEED}" = "required" ]; then
1212
fi
1313

1414
echo "//${ARTIFACTS_FEED}/registry/:username=${FEED_USER}" >> ${HOME}/.npmrc
15-
echo "//${ARTIFACTS_FEED}/registry/:_password=\${ARTIFACTS_ACCESSTOKEN}" >> ${HOME}/.npmrc
15+
echo "//${ARTIFACTS_FEED}/registry/:_authToken=\${ARTIFACTS_ACCESSTOKEN}" >> ${HOME}/.npmrc
1616
echo "//${ARTIFACTS_FEED}/registry/:email=${FEED_EMAIL}" >> ${HOME}/.npmrc
1717
echo "//${ARTIFACTS_FEED}/:username=${FEED_USER}" >> ${HOME}/.npmrc
18-
echo "//${ARTIFACTS_FEED}/:_password=\${ARTIFACTS_ACCESSTOKEN}" >> ${HOME}/.npmrc
18+
echo "//${ARTIFACTS_FEED}/:_authToken=\${ARTIFACTS_ACCESSTOKEN}" >> ${HOME}/.npmrc
1919
echo "//${ARTIFACTS_FEED}/:email=${FEED_EMAIL}" >> ${HOME}/.npmrc

0 commit comments

Comments
 (0)