Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
legomushroom committed Aug 20, 2020
0 parents commit 526e71a
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Codespaces in Codespaces

[<img title="Run in Codespace in one click" src="https://cdn.jsdelivr.net/gh/bookish-potato/codespaces-in-codespaces@f097ccddfc401ab6b09d233dc47c3efa3f9513f6/images/badge.svg">](https://github.com/features/codespaces)

Bootstrap script to run Codespaces Workbench in a GitHub Codespace.

### Use

Please follow instructions on the [vscs wiki page](https://github.com/microsoft/vssaas-planning/wiki/Codespaces-Workbench-in-a-GitHub-Codespace). Don't have access? Join the [vscode-vssaas team](https://repos.opensource.microsoft.com/microsoft/teams/vscode-vssaas) on [opensource.microsoft.com](https://repos.opensource.microsoft.com/microsoft/teams/vscode-vssaas).

### Issues/Feedback

- Feedback appreciated, create issues on [vscs planning](https://github.com/microsoft/vssaas-planning) repo if anything 🤗
- Ping [@legomushroom](https://github.com/legomushroom) if cannot get desired support in the GitHub issues (`olsolomk` if inside Microsoft) 🏓
6 changes: 6 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- add the `--pristine` option that will reset to the GitHub main branch
- VSCode UI shows too many git updates/changes
- improve docs on local DNS setup
- explore if we can have DNS/proxy inside the codespace
- don't use PAT in remote name
- connect to GH Codespace from VSC Desktop docs: https://docs.github.com/en/github/developing-online-with-codespaces/connecting-to-your-codespace-from-visual-studio-code
23 changes: 23 additions & 0 deletions images/badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
170 changes: 170 additions & 0 deletions script/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#!/bin/bash

clear

source ~/.bashrc

if [ -f ~/.cs-envirnment ]; then
source ~/.cs-envirnment
fi

GREETINGS=("Bonjour" "Hello" "Salam" "Привет" "Вітаю" "Hola" "Zdravo" "Ciao" "Salut" "Hallo" "Nǐ hǎo" "Xin chào" "Yeoboseyo" "Aloha" "Namaskaram" "Wannakam" "Dzień dobry")
GREETING=${GREETINGS[$RANDOM % ${#GREETINGS[@]} ]}

echo -e $PALETTE_WHITE"\n
~+
* +
' |
+ .-.,=\"\`\`\"=. - o -
'=/_ \ |
* | '=._ |
\ \`=./\`, '
. '=.__.=' \`=' *
+ +
O * ' .
"$PALETTE_RESET

echo -e $PALETTE_GREEN"\n\n 🖖 👽 $GREETING, Codespacer 👽 🖖\n"$PALETTE_RESET

sleep 1s

echo -e $PALETTE_PURPLE"\n🏃 Lets setup the Codespace"$PALETTE_RESET

sleep 0.25s

unset AZ_DO_USERNAME_SUFFIX;
if [ -z "$AZ_DO_USERNAME" ]; then
AZ_DO_USERNAME_SUFFIX=""
else
AZ_DO_USERNAME_SUFFIX=$PALETTE_CYAN"(➥ to reuse *$AZ_DO_USERNAME*)"$PALETTE_RESET
fi

echo -e $PALETTE_CYAN"\n- Please provide your AzDO username\n"$PALETTE_RESET

printf " ↳ AzDO Username$AZ_DO_USERNAME_SUFFIX: $PALETTE_PURPLE"

read AZ_DO_USERNAME_INPUT

echo -e " $PALETTE_RESET"

if [ -z "$AZ_DO_USERNAME_INPUT" ]; then
if [ -z "$AZ_DO_USERNAME" ]; then
echo -e $PALETTE_RED" 🗿 No name - no fame"$PALETTE_RESET
exit 1
else
AZ_DO_USERNAME_INPUT=$AZ_DO_USERNAME
echo -e $PALETTE_DIM" * reusing *$AZ_DO_USERNAME_INPUT* as AzDO username.\n"$PALETTE_RESET
fi
fi

IFS=@ read -r username domain <<< "$AZ_DO_USERNAME_INPUT"
if [ ! -z "$domain" ]; then
AZ_DO_USERNAME_INPUT="$username"
echo -e $PALETTE_DIM" * using *$AZ_DO_USERNAME_INPUT* as AzDO username.\n"$PALETTE_RESET
fi

if [ "$AZ_DO_USERNAME" != "$AZ_DO_USERNAME_INPUT" ]; then
export AZ_DO_USERNAME=$AZ_DO_USERNAME_INPUT

echo "export AZ_DO_USERNAME=$AZ_DO_USERNAME" >> ~/.bashrc
fi

echo -e $PALETTE_CYAN"- Thanks, *$AZ_DO_USERNAME*! Please provide your AzDO PAT\n"$PALETTE_RESET

unset AZ_DO_PASSWORD_SUFFIX;
if [ -z "$AZ_DO_PAT" ]; then
AZ_DO_PASSWORD_SUFFIX=""
else
AZ_DO_PASSWORD_SUFFIX=$PALETTE_CYAN"(➥ to reuse old PAT)"$PALETTE_RESET
fi

# reading the PAT
unset CHARCOUNT
unset AZ_DO_PAT_INPUT
PROMPT=" ↳ PAT code[R/W] + packaging[R]$AZ_DO_PASSWORD_SUFFIX: $PALETTE_PURPLE"

stty -echo

CHARCOUNT=0
while IFS= read -p "$PROMPT" -r -s -n 1 CHAR
do
# Enter - accept password
if [[ $CHAR == $'\0' ]] ; then
break
fi

# Backspace
if [[ $CHAR == $'\177' ]] ; then
if [ $CHARCOUNT -gt 0 ] ; then
CHARCOUNT=$((CHARCOUNT-1))
PROMPT=$'\b \b'
AZ_DO_PAT_INPUT="${PASSWORD%?}"
else
PROMPT=''
fi
else
CHARCOUNT=$((CHARCOUNT+1))
PROMPT='*'
AZ_DO_PAT_INPUT+="$CHAR"
fi
done

stty echo
echo -e " "$PALETTE_RESET

# check if PAT set
if [ -z ${AZ_DO_PAT_INPUT} ]; then
if [ -z "$AZ_DO_PAT" ]; then
echo -e $PALETTE_RED"\n 🐢 No PAT - Zero FLOPS per watt\n"$PALETTE_RESET
exit 1
else
AZ_DO_PAT_INPUT=$AZ_DO_PAT
echo -e $PALETTE_DIM"\n * reusing the old PAT."$PALETTE_RESET
fi
fi

git remote remove azdo
git remote add azdo https://$AZ_DO_USERNAME:$AZ_DO_PAT_INPUT@devdiv.visualstudio.com/OnlineServices/_git/vsclk-core

echo -e $PALETTE_LIGHT_YELLOW"\n ⌬ Fetching the repo\n"$PALETTE_RESET

git reset --hard
git checkout main

git branch --track github-main

# clone the AzDO repo
git pull azdo master:main --force --no-tags

if [ "$AZ_DO_PAT" != "$AZ_DO_PAT_INPUT" ]; then
export AZ_DO_PAT=$AZ_DO_PAT_INPUT
AZ_DO_PAT_BASE64=$(echo -n $AZ_DO_PAT | base64)
# replace env variable reference in the .npmrc
sed -i -E "s/_password=.+$/_password=$AZ_DO_PAT_BASE64/g" ~/.npmrc
# write the token to the env file
echo -e "export AZ_DO_PAT=$AZ_DO_PAT" >> ~/.cs-envirnment
fi

if [ ! -d $CSCLIENT ]; then
echo -e $PALETTE_RED"\n ❗ Could not clone the \`vsclk-core\` repo, are the credentials correct?\n"$PALETTE_RESET
exit 1
fi

# setup NuGet feeds
FEED_NAME="vssaas-sdk"
dotnet nuget remove source $FEED_NAME
dotnet nuget add source "https://devdiv.pkgs.visualstudio.com/_packaging/vssaas-sdk/nuget/v3/index.json" -n $FEED_NAME -u "devdiv" -p "$AZ_DO_PAT" --store-password-in-clear-text

FEED_NAME="Cascade"
dotnet nuget remove source $FEED_NAME
dotnet nuget add source "https://devdiv.pkgs.visualstudio.com/_packaging/Cascade/nuget/v3/index.json" -n $FEED_NAME -u "devdiv" -p "$AZ_DO_PAT" --store-password-in-clear-text

# go to `Website`
cd $CSCLIENT
# initialize the codespace
yarn setup:codespace
# go to `Website`
cd $CSCLIENT

exec bash

0 comments on commit 526e71a

Please sign in to comment.