Skip to content

Commit 06b81b7

Browse files
(feat) Support rush in artifacts-helper (#52)
* (feat) Support `rush` in artifacts-helper * Update devcontainer-feature.json Bump version --------- Co-authored-by: Mark Phippard <[email protected]>
1 parent 7079cde commit 06b81b7

File tree

6 files changed

+69
-6
lines changed

6 files changed

+69
-6
lines changed

src/artifacts-helper/NOTES.md

Lines changed: 2 additions & 2 deletions
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 an alias for `dotnet`, `nuget`, `npm`, and `yarn` that dynamically sets an authentication token
2+
and optionally configures an alias for `dotnet`, `nuget`, `npm`, `yarn`, and `rush` that dynamically sets an authentication token
33
for pulling artifacts from a feed before running the command.
44

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Configures Codespace to authenticate with Azure Artifact feeds
2222
| npmAlias | Create alias for npm | boolean | true |
2323
| yarnAlias | Create alias for yarn | boolean | true |
2424
| npxAlias | Create alias for npx | boolean | true |
25+
| rushAlias | Create alias for rush | boolean | true |
2526

2627
## Customizations
2728

@@ -30,10 +31,10 @@ Configures Codespace to authenticate with Azure Artifact feeds
3031
- `ms-codespaces-tools.ado-codespaces-auth`
3132

3233
This installs [Azure Artifacts Credential Provider](https://github.com/microsoft/artifacts-credprovider)
33-
and optionally configures an alias for `dotnet`, `nuget`, `npm`, and `yarn` that dynamically sets an authentication token
34+
and optionally configures an alias for `dotnet`, `nuget`, `npm`, `yarn`, and `rush` that dynamically sets an authentication token
3435
for pulling artifacts from a feed before running the command.
3536

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

src/artifacts-helper/devcontainer-feature.json

Lines changed: 6 additions & 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.4",
4+
"version": "1.0.5",
55
"description": "Configures Codespace to authenticate with Azure Artifact feeds",
66
"options": {
77
"nugetURIPrefixes": {
@@ -38,6 +38,11 @@
3838
"type": "boolean",
3939
"default": true,
4040
"description": "Create alias for npx"
41+
},
42+
"rushAlias": {
43+
"type": "boolean",
44+
"default": true,
45+
"description": "Create alias for rush"
4146
}
4247
},
4348
"installsAfter": [

src/artifacts-helper/install.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ALIAS_NUGET="${NUGETALIAS:-"true"}"
99
ALIAS_NPM="${NPMALIAS:-"true"}"
1010
ALIAS_YARN="${YARNALIAS:-"true"}"
1111
ALIAS_NPX="${NPXALIAS:-"true"}"
12+
ALIAS_RUSH="${RUSHALIAS:-"true"}"
1213

1314
# Source /etc/os-release to get OS info
1415
. /etc/os-release
@@ -63,6 +64,11 @@ chmod +rx /usr/local/bin/write-npm.sh
6364
cp ./scripts/run-npx.sh /usr/local/bin/run-npx.sh
6465
chmod +rx /usr/local/bin/run-npx.sh
6566

67+
cp ./scripts/run-rush.sh /usr/local/bin/run-rush.sh
68+
chmod +rx /usr/local/bin/run-rush.sh
69+
cp ./scripts/run-rush-pnpm.sh /usr/local/bin/run-rush-pnpm.sh
70+
chmod +rx /usr/local/bin/run-rush-pnpm.sh
71+
6672

6773
if command -v sudo >/dev/null 2>&1; then
6874
if [ "root" != "$_REMOTE_USER" ]; then
@@ -85,7 +91,14 @@ if command -v sudo >/dev/null 2>&1; then
8591
if [ "${ALIAS_NPX}" = "true" ]; then
8692
sudo -u ${_REMOTE_USER} bash -c "echo 'alias npx=/usr/local/bin/run-npx.sh' >> ~/.bashrc"
8793
sudo -u ${_REMOTE_USER} bash -c "echo 'alias npx=/usr/local/bin/run-npx.sh' >> ~/.zshrc"
88-
fi
94+
fi
95+
if [ "${ALIAS_RUSH}" = "true" ]; then
96+
sudo -u ${_REMOTE_USER} bash -c "echo 'alias rush=/usr/local/bin/run-rush.sh' >> ~/.bashrc"
97+
sudo -u ${_REMOTE_USER} bash -c "echo 'alias rush=/usr/local/bin/run-rush.sh' >> ~/.zshrc"
98+
99+
sudo -u ${_REMOTE_USER} bash -c "echo 'alias rush-pnpm=/usr/local/bin/run-rush-pnpm.sh' >> ~/.bashrc"
100+
sudo -u ${_REMOTE_USER} bash -c "echo 'alias rush-pnpm=/usr/local/bin/run-rush-pnpm.sh' >> ~/.zshrc"
101+
fi
89102
sudo -u ${_REMOTE_USER} bash -c "/tmp/install-provider.sh ${USENET6}"
90103
rm /tmp/install-provider.sh
91104
exit 0
@@ -117,6 +130,14 @@ if [ "${ALIAS_NPX}" = "true" ]; then
117130
sudo -u ${_REMOTE_USER} bash -c "echo 'alias npx=/usr/local/bin/run-npx.sh' >> /etc/zsh/zshrc || true
118131
fi
119132

133+
if [ "${ALIAS_RUSH}" = "true" ]; then
134+
sudo -u ${_REMOTE_USER} bash -c "echo 'alias rush=/usr/local/bin/run-rush.sh' >> /etc/bash.bashrc || true
135+
sudo -u ${_REMOTE_USER} bash -c "echo 'alias rush=/usr/local/bin/run-rush.sh' >> /etc/zsh/zshrc || true
136+
137+
sudo -u ${_REMOTE_USER} bash -c "echo 'alias rush-pnpm=/usr/local/bin/run-rush-pnpm.sh' >> /etc/bash.bashrc || true
138+
sudo -u ${_REMOTE_USER} bash -c "echo 'alias rush-pnpm=/usr/local/bin/run-rush-pnpm.sh' >> /etc/zsh/zshrc || true
139+
fi
140+
120141
rm /tmp/install-provider.sh
121142

122143
exit 0
Lines changed: 18 additions & 0 deletions
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 rush-pnpm executable so we do not run the bash alias again
8+
RUSH_PNPM_EXE=$(which rush-pnpm)
9+
10+
${RUSH_PNPM_EXE} "$@"
11+
EXIT_CODE=$?
12+
unset RUSH_PNPM_EXE
13+
14+
if [ -f "${HOME}/ado-auth-helper" ]; then
15+
unset ARTIFACTS_ACCESSTOKEN
16+
fi
17+
18+
exit $EXIT_CODE
Lines changed: 18 additions & 0 deletions
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 rush executable so we do not run the bash alias again
8+
RUSH_EXE=$(which rush)
9+
10+
${RUSH_EXE} "$@"
11+
EXIT_CODE=$?
12+
unset RUSH_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)