diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 index dd930d26..1b8af368 100644 --- a/scripts/setup.ps1 +++ b/scripts/setup.ps1 @@ -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 @@ -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" \ No newline at end of file diff --git a/scripts/setup.sh b/scripts/setup.sh old mode 100644 new mode 100755 index fc3b8eec..6efa4af0 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -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) @@ -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