Skip to content

Commit c13dff3

Browse files
authored
Merge pull request #69 from naostranMS/main
(feat) support `pnpm` in artifacts-helper
2 parents 37628f6 + a951ac3 commit c13dff3

File tree

5 files changed

+54
-3
lines changed

5 files changed

+54
-3
lines changed

src/artifacts-helper/NOTES.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
This installs [Azure Artifacts Credential Provider](https://github.com/microsoft/artifacts-credprovider)
2-
and optionally configures functions which shadow `dotnet`, `nuget`, `npm`, `yarn`, and `rush` which dynamically sets an authentication token
2+
and optionally configures functions which shadow `dotnet`, `nuget`, `npm`, `yarn`, `rush`, and `pnpm` which dynamically sets an authentication token
33
for pulling artifacts from a feed before running the command.
44

5-
For `npm`, `yarn`, and `rush` this requires that your `~/.npmrc` file is configured to use the ${ARTIFACTS_ACCESSTOKEN}
5+
For `npm`, `yarn`, `rush`, and `pnpm` this requires that your `~/.npmrc` file is configured to use the ${ARTIFACTS_ACCESSTOKEN}
66
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:

src/artifacts-helper/devcontainer-feature.json

+6-1
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": "2.0.2",
4+
"version": "2.0.3",
55
"description": "Configures Codespace to authenticate with Azure Artifact feeds",
66
"options": {
77
"nugetURIPrefixes": {
@@ -44,6 +44,11 @@
4444
"default": true,
4545
"description": "Create alias for rush"
4646
},
47+
"pnpmAlias": {
48+
"type": "boolean",
49+
"default": true,
50+
"description": "Create alias for pnpm"
51+
},
4752
"targetFiles": {
4853
"type": "string",
4954
"default": "DEFAULT",

src/artifacts-helper/install.sh

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ALIAS_NPM="${NPMALIAS:-"true"}"
1010
ALIAS_YARN="${YARNALIAS:-"true"}"
1111
ALIAS_NPX="${NPXALIAS:-"true"}"
1212
ALIAS_RUSH="${RUSHALIAS:-"true"}"
13+
ALIAS_PNPM="${PNPMALIAS:-"true"}"
1314
INSTALL_PIP_HELPER="${PYTHON:-"false"}"
1415
COMMA_SEP_TARGET_FILES="${TARGETFILES:-"DEFAULT"}"
1516

@@ -34,6 +35,10 @@ if [ "${ALIAS_RUSH}" = "true" ]; then
3435
ALIASES_ARR+=('rush')
3536
ALIASES_ARR+=('rush-pnpm')
3637
fi
38+
if [ "${ALIAS_PNPM}" = "true" ]; then
39+
ALIASES_ARR+=('pnpm')
40+
ALIASES_ARR+=('pnpx')
41+
fi
3742

3843
# Source /etc/os-release to get OS info
3944
. /etc/os-release
@@ -94,6 +99,11 @@ chmod +rx /usr/local/bin/run-rush.sh
9499
cp ./scripts/run-rush-pnpm.sh /usr/local/bin/run-rush-pnpm.sh
95100
chmod +rx /usr/local/bin/run-rush-pnpm.sh
96101

102+
cp ./scripts/run-pnpm.sh /usr/local/bin/run-pnpm.sh
103+
chmod +rx /usr/local/bin/run-pnpm.sh
104+
cp ./scripts/run-pnpx.sh /usr/local/bin/run-pnpx.sh
105+
chmod +rx /usr/local/bin/run-pnpx.sh
106+
97107
if [ "${INSTALL_PIP_HELPER}" = "true" ]; then
98108
USER="${_REMOTE_USER}" /tmp/install-python-keyring.sh
99109
rm /tmp/install-python-keyring.sh
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
if [ -f "${HOME}/ado-auth-helper" ]; then
4+
export ARTIFACTS_ACCESSTOKEN=$(${HOME}/ado-auth-helper get-access-token)
5+
fi
6+
7+
# Find the pnpm executable so we do not run the bash alias again
8+
PNPM_EXE=$(which pnpm)
9+
10+
${PNPM_EXE} "$@"
11+
EXIT_CODE=$?
12+
unset PNPM_EXE
13+
14+
if [ -f "${HOME}/ado-auth-helper" ]; then
15+
unset ARTIFACTS_ACCESSTOKEN
16+
fi
17+
18+
exit $EXIT_CODE
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
if [ -f "${HOME}/ado-auth-helper" ]; then
4+
export ARTIFACTS_ACCESSTOKEN=$(${HOME}/ado-auth-helper get-access-token)
5+
fi
6+
7+
# Find the pnpx executable so we do not run the bash alias again
8+
PNPX_EXE=$(which pnpx)
9+
10+
${PNPX_EXE} "$@"
11+
EXIT_CODE=$?
12+
unset PNPX_EXE
13+
14+
if [ -f "${HOME}/ado-auth-helper" ]; then
15+
unset ARTIFACTS_ACCESSTOKEN
16+
fi
17+
18+
exit $EXIT_CODE

0 commit comments

Comments
 (0)