diff --git a/README.md b/README.md index 9682b37..820846f 100644 --- a/README.md +++ b/README.md @@ -23,13 +23,13 @@ iwr https://deno.land/x/install/install.ps1 -useb | iex **With Shell:** ```sh -curl -fsSL https://deno.land/x/install/install.sh | sh -s v0.2.10 +curl -fsSL https://deno.land/x/install/install.sh | sh -s v0.38.0 ``` **With PowerShell:** ```powershell -iwr https://deno.land/x/install/install.ps1 -useb -outf install.ps1; .\install.ps1 v0.2.10 +iwr https://deno.land/x/install/install.ps1 -useb -outf install.ps1; .\install.ps1 v0.38.0 ``` ## Install via Package Manager @@ -40,7 +40,7 @@ iwr https://deno.land/x/install/install.ps1 -useb -outf install.ps1; .\install.p scoop install deno ``` -**With [Homebrew](https://brew.sh/):** +**With [Homebrew](https://formulae.brew.sh/formula/deno):** ```sh brew install deno @@ -59,13 +59,13 @@ choco install deno ```sh asdf plugin-add deno https://github.com/asdf-community/asdf-deno.git -asdf install deno 0.2.10 +asdf install deno 0.38.0 # Activate globally with: -asdf global deno 0.2.10 +asdf global deno 0.38.0 # Activate locally in the current folder with: -asdf local deno 0.2.10 +asdf local deno 0.38.0 ``` **With [Scoop](https://github.com/lukesampson/scoop/wiki/Switching-Ruby-And-Python-Versions):** @@ -105,17 +105,16 @@ scoop reset deno ## Compatibility - The Shell installer can be used on Windows via the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/about). -- The PowerShell installer can be used on Linux and Mac thanks to [PowerShell Core](https://docs.microsoft.com/en-us/powershell/scripting). ## Known Issues ### Running scripts is disabled ``` -PS C:\> iwr https://deno.land/x/install/install.ps1 -useb -outf install.ps1; .\install.ps1 v0.2.10 +PS C:\> iwr https://deno.land/x/install/install.ps1 -useb -outf install.ps1; .\install.ps1 v0.38.0 .\install.ps1 : File C:\install.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:71 -+ ... /x/install/install.ps1 -useb -outf install.ps1; .\install.ps1 v0.2.10 ++ ... /x/install/install.ps1 -useb -outf install.ps1; .\install.ps1 v0.38.0 + ~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnauthorizedAccess diff --git a/install.ps1 b/install.ps1 index 18d77ae..9ad567b 100644 --- a/install.ps1 +++ b/install.ps1 @@ -15,44 +15,16 @@ if ($PSVersionTable.PSEdition -ne 'Core') { $DenoInstall = $env:DENO_INSTALL $BinDir = if ($DenoInstall) { - if ($IsWindows) { "$DenoInstall\bin" - } else { - "$DenoInstall/bin" - } } elseif ($IsWindows) { "$Home\.deno\bin" -} else { - "$Home/.local/bin" } -$Zip = if ($IsWindows) { - 'zip' -} else { - 'gz' -} +$DenoZip = "$BinDir\deno.zip" -$DenoZip = if ($IsWindows) { - "$BinDir\deno.$Zip" -} else { - "$BinDir/deno.$Zip" -} +$DenoExe = "$BinDir\deno.exe" -$DenoExe = if ($IsWindows) { - "$BinDir\deno.exe" -} else { - "$BinDir/deno" -} - -$OS = if ($IsWindows) { - 'win' -} else { - if ($IsMacOS) { - 'osx' - } else { - 'linux' - } -} +$Target = 'x86_64-pc-windows-msvc' # GitHub requires TLS 1.2 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 @@ -61,7 +33,7 @@ $DenoUri = if (!$Version) { $Response = Invoke-WebRequest 'https://github.com/denoland/deno/releases' -UseBasicParsing if ($PSVersionTable.PSEdition -eq 'Core') { $Response.Links | - Where-Object { $_.href -like "/denoland/deno/releases/download/*/deno_${OS}_x64.$Zip" } | + Where-Object { $_.href -like "/denoland/deno/releases/download/*/deno-${Target}.zip" } | ForEach-Object { 'https://github.com' + $_.href } | Select-Object -First 1 } else { @@ -73,12 +45,12 @@ $DenoUri = if (!$Version) { $HTMLFile.write($ResponseBytes) } $HTMLFile.getElementsByTagName('a') | - Where-Object { $_.href -like "about:/denoland/deno/releases/download/*/deno_${OS}_x64.$Zip" } | + Where-Object { $_.href -like "about:/denoland/deno/releases/download/*/deno_${Target}.zip" } | ForEach-Object { $_.href -replace 'about:', 'https://github.com' } | Select-Object -First 1 } } else { - "https://github.com/denoland/deno/releases/download/$Version/deno_${OS}_x64.$Zip" + "https://github.com/denoland/deno/releases/download/$Version/deno-${Target}.zip" } if (!(Test-Path $BinDir)) { @@ -87,30 +59,14 @@ if (!(Test-Path $BinDir)) { Invoke-WebRequest $DenoUri -OutFile $DenoZip -UseBasicParsing -if ($IsWindows) { - Expand-Archive $DenoZip -Destination $BinDir -Force - Remove-Item $DenoZip -} else { - gunzip -df $DenoZip -} +Expand-Archive $DenoZip -Destination $BinDir -Force +Remove-Item $DenoZip -if ($IsWindows) { - $User = [EnvironmentVariableTarget]::User - $Path = [Environment]::GetEnvironmentVariable('Path', $User) - if (!(";$Path;".ToLower() -like "*;$BinDir;*".ToLower())) { - [Environment]::SetEnvironmentVariable('Path', "$Path;$BinDir", $User) - $Env:Path += ";$BinDir" - } - Write-Output "Deno was installed successfully to $DenoExe" - Write-Output "Run 'deno --help' to get started" -} else { - chmod +x "$BinDir/deno" - Write-Output "Deno was installed successfully to $DenoExe" - if (Get-Command deno -ErrorAction SilentlyContinue) { - Write-Output "Run 'deno --help' to get started" - } else { - Write-Output "Manually add the directory to your `$HOME/.bash_profile (or similar)" - Write-Output " export PATH=`"${BinDir}:`$PATH`"" - Write-Output "Run '$DenoExe --help' to get started" - } +$User = [EnvironmentVariableTarget]::User +$Path = [Environment]::GetEnvironmentVariable('Path', $User) +if (!(";$Path;".ToLower() -like "*;$BinDir;*".ToLower())) { + [Environment]::SetEnvironmentVariable('Path', "$Path;$BinDir", $User) + $Env:Path += ";$BinDir" } +Write-Output "Deno was installed successfully to $DenoExe" +Write-Output "Run 'deno --help' to get started" diff --git a/install.sh b/install.sh index 702f449..4f8e7a9 100755 --- a/install.sh +++ b/install.sh @@ -5,16 +5,11 @@ set -e case $(uname -s) in -Darwin) os="osx" ;; -*) os="linux" ;; +Darwin) target="x86_64-apple-darwin" ;; +*) target="x86_64-unknown-linux-gnu" ;; esac -case $(uname -m) in -x86_64) arch="x86_64" ;; -*) arch="other" ;; -esac - -if [ "$arch" = "other" ]; then +if [ $(uname -m) != "x86_64" ]; then echo "Unsupported architecture $(uname -m). Only x64 binaries are available." exit fi @@ -22,13 +17,13 @@ fi if [ $# -eq 0 ]; then deno_asset_path=$( command curl -sSf https://github.com/denoland/deno/releases | - command grep -o "/denoland/deno/releases/download/.*/deno_${os}_x64\\.gz" | + command grep -o "/denoland/deno/releases/download/.*/deno-${target}\\.zip" | command head -n 1 ) if [ ! "$deno_asset_path" ]; then exit 1; fi deno_uri="https://github.com${deno_asset_path}" else - deno_uri="https://github.com/denoland/deno/releases/download/${1}/deno_${os}_x64.gz" + deno_uri="https://github.com/denoland/deno/releases/download/${1}/deno-${target}.zip" fi deno_install="${DENO_INSTALL:-$HOME/.local}" @@ -39,9 +34,11 @@ if [ ! -d "$bin_dir" ]; then mkdir -p "$bin_dir" fi -curl -fL# -o "$exe.gz" "$deno_uri" -gunzip -df "$exe.gz" +curl --fail --location --progress-bar --output "$exe.zip" "$deno_uri" +cd "$bin_dir" +unzip "$exe.zip" chmod +x "$exe" +rm "$exe.zip" echo "Deno was installed successfully to $exe" if command -v deno >/dev/null; then diff --git a/install_test.ps1 b/install_test.ps1 index c95011e..213cc13 100755 --- a/install_test.ps1 +++ b/install_test.ps1 @@ -2,10 +2,6 @@ $ErrorActionPreference = 'Stop' -if ($PSVersionTable.PSEdition -ne 'Core') { - $IsWindows = $true -} - if (!(Get-PSRepository)) { Register-PSRepository -Default } @@ -18,33 +14,18 @@ if (!(Get-Module PSScriptAnalyzer -ListAvailable)) { Invoke-ScriptAnalyzer *.ps1 -EnableExit -Exclude PSAvoidAssignmentToAutomaticVariable # Test that we can install the latest version at the default location. -if ($IsWindows) { - Remove-Item "~\.deno" -Recurse -Force -ErrorAction SilentlyContinue -} else { - Remove-Item "~/.local/bin/deno" -Force -ErrorAction SilentlyContinue -} +Remove-Item "~\.deno" -Recurse -Force -ErrorAction SilentlyContinue $env:DENO_INSTALL = "" .\install.ps1 -if ($IsWindows) { - ~\.deno\bin\deno.exe --version -} else { - ~/.local/bin/deno --version -} +~\.deno\bin\deno.exe --version # Test that we can install a specific version at a custom location. -if ($IsWindows) { - Remove-Item "~\deno-0.13.0" -Recurse -Force -ErrorAction SilentlyContinue - $env:DENO_INSTALL = "$Home\deno-0.13.0" -} else { - Remove-Item "~/deno-0.13.0" -Recurse -Force -ErrorAction SilentlyContinue - $env:DENO_INSTALL = "$Home/deno-0.13.0" -} -.\install.ps1 v0.13.0 -$DenoVersion = if ($IsWindows) { - ~\deno-0.13.0\bin\deno.exe --version -} else { - ~/deno-0.13.0/bin/deno --version -} -if (!($DenoVersion -like '*0.13.0*')) { +Remove-Item "~\deno-0.38.0" -Recurse -Force -ErrorAction SilentlyContinue +$env:DENO_INSTALL = "$Home\deno-0.38.0" + +.\install.ps1 v0.38.0 +$DenoVersion = ~\deno-0.38.0\bin\deno.exe --version + +if (!($DenoVersion -like '*0.38.0*')) { throw $DenoVersion } diff --git a/install_test.sh b/install_test.sh index 994827a..accb885 100755 --- a/install_test.sh +++ b/install_test.sh @@ -12,7 +12,7 @@ sh ./install.sh ~/.local/bin/deno --version # Test that we can install a specific version at a custom location. -rm -rf ~/deno-0.13.0 -export DENO_INSTALL="$HOME/deno-0.13.0" -./install.sh v0.13.0 -~/deno-0.13.0/bin/deno --version | grep 0.13.0 +rm -rf ~/deno-0.38.0 +export DENO_INSTALL="$HOME/deno-0.38.0" +./install.sh v0.38.0 +~/deno-0.38.0/bin/deno --version | grep 0.38.0