Skip to content

Commit

Permalink
Updates setup script. Closes microsoft#464, microsoft#479 (microsoft#480
Browse files Browse the repository at this point in the history
)
  • Loading branch information
waldekmastykarz authored Jan 9, 2024
1 parent 6655096 commit 1d3af48
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
36 changes: 31 additions & 5 deletions scripts/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
# Licensed under the MIT License. See License in the project root for license information.
#---------------------------------------------------------------------------------------------

Write-Host ""
Write-Host "This script installs Dev Proxy on your machine. It runs the following steps:"
Write-Host ""
Write-Host "1. Create the 'devproxy' directory in the current working folder"
Write-Host "2. Download the latest Dev Proxy release"
Write-Host "3. Unzip the release in the devproxy directory"
Write-Host "4. Configure devproxy and its files as executable (Linux and macOS only)"
Write-Host "5. Add the devproxy directory to your PATH environment variable in `$PROFILE.CurrentUserAllHosts"
Write-Host ""
Write-Host "Continue (y/n)? " -NoNewline
$response = [System.Console]::ReadKey().KeyChar

if ($response -notin @('y', 'Y')) {
Write-Host "`nExiting"
exit 1
}

Write-Host "`n"

New-Item -ItemType Directory -Force -Path .\devproxy -ErrorAction Stop | Out-Null
Set-Location .\devproxy | Out-Null

Expand Down Expand Up @@ -56,16 +75,23 @@ Add-Type -AssemblyName System.IO.Compression.FileSystem
Expand-Archive -Path devproxy.zip -DestinationPath . -Force -ErrorAction Stop
Remove-Item devproxy.zip

if (!(Test-Path $PROFILE)) {
New-Item -ItemType File -Force -Path $PROFILE
if ($os -match "Linux" -or $os -match "Darwin") {
Write-Host "Configuring devproxy and its files as executable..."
chmod +x ./devproxy ./libe_sqlite3.dylib
}

if (!(Test-Path $PROFILE.CurrentUserAllHosts)) {
Write-Host "Creating `$PROFILE.CurrentUserAllHosts..."
New-Item -ItemType File -Force -Path $PROFILE.CurrentUserAllHosts | Out-Null
}

if (!(Select-String -Path $PROFILE -Pattern "devproxy")) {
Add-Content -Path $PROFILE -Value "$([Environment]::NewLine)`$env:PATH += `"$([IO.Path]::PathSeparator)$full_path`""
if (!(Select-String -Path $PROFILE.CurrentUserAllHosts -Pattern "devproxy")) {
Write-Host "Adding devproxy to `$PROFILE.CurrentUserAllHosts..."
Add-Content -Path $PROFILE.CurrentUserAllHosts -Value "$([Environment]::NewLine)`$env:PATH += `"$([IO.Path]::PathSeparator)$full_path`""
}

Write-Host "Dev Proxy $version installed!"
Write-Host
Write-Host "To get started, run:"
Write-Host " . $PROFILE"
Write-Host " . `$PROFILE.CurrentUserAllHosts"
Write-Host " devproxy --help"
24 changes: 23 additions & 1 deletion scripts/setup.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@
# Licensed under the MIT License. See License in the project root for license information.
#---------------------------------------------------------------------------------------------

echo ""
echo "This script installs Dev Proxy on your machine. It runs the following steps:"
echo ""
echo "1. Create the 'devproxy' directory in the current working folder"
echo "2. Download the latest Dev Proxy release"
echo "3. Unzip the release in the devproxy directory"
echo "4. Configure devproxy and its files as executable"
echo "5. Add the devproxy directory to your PATH environment variable in your shell profile"
echo ""
echo -n "Continue (y/n)? "

read -n1 -r response
if [[ "$response" != [yY] ]]; then
echo -e "\nExiting"
exit 1
fi

echo -e "\n"

mkdir devproxy
cd devproxy
full_path=$(pwd)
Expand Down Expand Up @@ -42,7 +61,10 @@ fi

unzip -o ./devproxy.zip -d ./
rm ./devproxy.zip
chmod +x ./devproxy
echo "Configuring devproxy and its files as executable..."
chmod +x ./devproxy ./libe_sqlite3.dylib

echo "Adding devproxy to the PATH environment variable in your shell profile..."

if [[ ":$PATH:" != *":$full_path:"* ]]; then
if [[ -e ~/.zshrc ]]; then
Expand Down

0 comments on commit 1d3af48

Please sign in to comment.