forked from microsoft/dev-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18222d8
commit 69fabdd
Showing
3 changed files
with
204 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#--------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# 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 beta 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 | ||
|
||
# Get the full path of the current directory | ||
$full_path = Resolve-Path . | ||
|
||
# Get the latest beta Dev Proxy version | ||
Write-Host "Getting latest beta Dev Proxy version..." | ||
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/dev-proxy/releases?per_page=1" -ErrorAction Stop | ||
$version = $response[0].tag_name | ||
Write-Host "Latest beta version is $version" | ||
|
||
# Download Dev Proxy | ||
Write-Host "Downloading Dev Proxy $version..." | ||
$base_url = "https://github.com/microsoft/dev-proxy/releases/download/$version/dev-proxy" | ||
|
||
# Check system architecture | ||
$os = $PSVersionTable.OS | ||
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture | ||
|
||
if ($os -match "Windows") { | ||
if ($arch -eq "X64") { | ||
$url = "$base_url-win-x64-$version.zip" | ||
} elseif ($arch -eq "X86") { | ||
$url = "$base_url-win-x86-$version.zip" | ||
} else { | ||
Write-Host "Unsupported architecture $arch. Aborting" | ||
exit 1 | ||
} | ||
} elseif ($os -match "Linux") { | ||
if ($arch -eq "X64") { | ||
$url = "$base_url-linux-x64-$version.zip" | ||
} else { | ||
Write-Host "Unsupported architecture $arch. Aborting" | ||
exit 1 | ||
} | ||
} elseif ($os -match "Darwin") { | ||
if ($arch -eq "X64") { | ||
$url = "$base_url-osx-x64-$version.zip" | ||
} else { | ||
Write-Host "Unsupported architecture $arch. Aborting" | ||
exit 1 | ||
} | ||
} else { | ||
Write-Host "Unsupported OS $os. Aborting" | ||
exit 1 | ||
} | ||
|
||
Invoke-WebRequest -Uri $url -OutFile devproxy.zip -ErrorAction Stop | ||
Add-Type -AssemblyName System.IO.Compression.FileSystem | ||
Expand-Archive -Path devproxy.zip -DestinationPath . -Force -ErrorAction Stop | ||
Remove-Item devproxy.zip | ||
|
||
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.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.CurrentUserAllHosts" | ||
Write-Host " devproxy --help" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env bash | ||
#--------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# 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 beta 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 "" | ||
|
||
if [ -t 0 ]; then | ||
# Terminal is interactive, prompt the user | ||
read -p "Continue (y/n)? " -n1 -r response | ||
else | ||
# Not interactive | ||
response='y' | ||
fi | ||
|
||
if [[ "$response" != [yY] ]]; then | ||
echo -e "\nExiting" | ||
exit 1 | ||
fi | ||
|
||
if [ -t 0 ]; then | ||
echo -e "\n" | ||
fi | ||
|
||
mkdir devproxy | ||
cd devproxy | ||
full_path=$(pwd) | ||
|
||
set -e # Terminates program immediately if any command below exits with a non-zero exit status | ||
|
||
echo "Getting latest beta Dev Proxy version..." | ||
version=$(curl -s "https://api.github.com/repos/microsoft/dev-proxy/releases?per_page=1" | awk -F: '/"tag_name"/ {print $2}' | sed 's/[", ]//g') | ||
echo "Latest beta version is $version" | ||
|
||
echo "Downloading Dev Proxy $version..." | ||
|
||
base_url="https://github.com/microsoft/dev-proxy/releases/download/$version/dev-proxy" | ||
|
||
if [ "$(uname)" == "Darwin" ]; then | ||
ARCH="$(uname -m)" | ||
if [ ${ARCH} == "arm64" ]; then | ||
echo "unsupported architecture ${ARCH}. Aborting"; exit 1; | ||
elif [ ${ARCH} == "x86_64" ]; then | ||
curl -sL -o ./devproxy.zip "$base_url-osx-x64-$version.zip" || { echo "Cannot install Dev Proxy. Aborting"; exit 1; } | ||
else | ||
echo "unsupported architecture ${ARCH}" | ||
exit | ||
fi | ||
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then | ||
ARCH="$(uname -m)" | ||
if [ "$(expr substr ${ARCH} 1 5)" == "arm64" ] || [ "$(expr substr ${ARCH} 1 7)" == "aarch64" ]; then | ||
echo "unsupported architecture ${ARCH}. Aborting"; exit 1; | ||
elif [ "$(expr substr ${ARCH} 1 6)" == "x86_64" ]; then | ||
curl -sL -o ./devproxy.zip "$base_url-linux-x64-$version.zip" || { echo "Cannot install Dev Proxy. Aborting"; exit 1; } | ||
else | ||
echo "unsupported architecture ${ARCH}" | ||
exit | ||
fi | ||
fi | ||
|
||
unzip -o ./devproxy.zip -d ./ | ||
rm ./devproxy.zip | ||
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 | ||
echo -e "\n# Dev Proxy\nexport PATH=\$PATH:$full_path" >> $HOME/.zshrc | ||
fileUsed="~/.zshrc" | ||
elif [[ -e ~/.bashrc ]]; then | ||
echo -e "\n# Dev Proxy\nexport PATH=\$PATH:$full_path" >> $HOME/.bashrc | ||
fileUsed="~/.bashrc" | ||
else | ||
echo -e "\n# Dev Proxy\nexport PATH=\$PATH:$full_path" >> $HOME/.bash_profile | ||
fileUsed="~/.bash_profile" | ||
fi | ||
fi | ||
|
||
echo "Dev Proxy $version installed!" | ||
echo "" | ||
echo "To get started, run:" | ||
if [[ "$fileUsed" != "" ]]; then | ||
echo " source $fileUsed" | ||
fi | ||
echo " devproxy -h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters