Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) support pnpm in artifacts-helper #69

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/artifacts-helper/NOTES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
This installs [Azure Artifacts Credential Provider](https://github.com/microsoft/artifacts-credprovider)
and optionally configures functions which shadow `dotnet`, `nuget`, `npm`, `yarn`, and `rush` which dynamically sets an authentication token
and optionally configures functions which shadow `dotnet`, `nuget`, `npm`, `yarn`, `rush`, and `pnpm` which dynamically sets an authentication token
for pulling artifacts from a feed before running the command.

For `npm`, `yarn`, and `rush` this requires that your `~/.npmrc` file is configured to use the ${ARTIFACTS_ACCESSTOKEN}
For `npm`, `yarn`, `rush`, and `pnpm` this requires that your `~/.npmrc` file is configured to use the ${ARTIFACTS_ACCESSTOKEN}
environment variable for the `authToken`. A helper script has been added that you can use to write your `~/.npmrc`
file during your setup process, though there are many ways you could accomplish this. To use the script, run it like
this:
Expand Down
7 changes: 6 additions & 1 deletion src/artifacts-helper/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Azure Artifacts Credential Helper",
"id": "artifacts-helper",
"version": "2.0.2",
"version": "2.0.3",
"description": "Configures Codespace to authenticate with Azure Artifact feeds",
"options": {
"nugetURIPrefixes": {
Expand Down Expand Up @@ -44,6 +44,11 @@
"default": true,
"description": "Create alias for rush"
},
"pnpmAlias": {
"type": "boolean",
"default": true,
"description": "Create alias for pnpm"
},
"targetFiles": {
"type": "string",
"default": "DEFAULT",
Expand Down
10 changes: 10 additions & 0 deletions src/artifacts-helper/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ALIAS_NPM="${NPMALIAS:-"true"}"
ALIAS_YARN="${YARNALIAS:-"true"}"
ALIAS_NPX="${NPXALIAS:-"true"}"
ALIAS_RUSH="${RUSHALIAS:-"true"}"
ALIAS_PNPM="${PNPMALIAS:-"true"}"
INSTALL_PIP_HELPER="${PYTHON:-"false"}"
COMMA_SEP_TARGET_FILES="${TARGETFILES:-"DEFAULT"}"

Expand All @@ -34,6 +35,10 @@ if [ "${ALIAS_RUSH}" = "true" ]; then
ALIASES_ARR+=('rush')
ALIASES_ARR+=('rush-pnpm')
fi
if [ "${ALIAS_PNPM}" = "true" ]; then
ALIASES_ARR+=('pnpm')
ALIASES_ARR+=('pnpx')
fi

# Source /etc/os-release to get OS info
. /etc/os-release
Expand Down Expand Up @@ -94,6 +99,11 @@ chmod +rx /usr/local/bin/run-rush.sh
cp ./scripts/run-rush-pnpm.sh /usr/local/bin/run-rush-pnpm.sh
chmod +rx /usr/local/bin/run-rush-pnpm.sh

cp ./scripts/run-pnpm.sh /usr/local/bin/run-pnpm.sh
chmod +rx /usr/local/bin/run-pnpm.sh
cp ./scripts/run-pnpx.sh /usr/local/bin/run-pnpx.sh
chmod +rx /usr/local/bin/run-pnpx.sh

if [ "${INSTALL_PIP_HELPER}" = "true" ]; then
USER="${_REMOTE_USER}" /tmp/install-python-keyring.sh
rm /tmp/install-python-keyring.sh
Expand Down
18 changes: 18 additions & 0 deletions src/artifacts-helper/scripts/run-pnpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if [ -f "${HOME}/ado-auth-helper" ]; then
export ARTIFACTS_ACCESSTOKEN=$(${HOME}/ado-auth-helper get-access-token)
fi

# Find the pnpm executable so we do not run the bash alias again
PNPM_EXE=$(which pnpm)

${PNPM_EXE} "$@"
EXIT_CODE=$?
unset PNPM_EXE

if [ -f "${HOME}/ado-auth-helper" ]; then
unset ARTIFACTS_ACCESSTOKEN
fi

exit $EXIT_CODE
18 changes: 18 additions & 0 deletions src/artifacts-helper/scripts/run-pnpx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if [ -f "${HOME}/ado-auth-helper" ]; then
export ARTIFACTS_ACCESSTOKEN=$(${HOME}/ado-auth-helper get-access-token)
fi

# Find the pnpx executable so we do not run the bash alias again
PNPX_EXE=$(which pnpx)

${PNPX_EXE} "$@"
EXIT_CODE=$?
unset PNPX_EXE

if [ -f "${HOME}/ado-auth-helper" ]; then
unset ARTIFACTS_ACCESSTOKEN
fi

exit $EXIT_CODE
Loading