-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The new installers are here! Now with 100% more powershell
- Loading branch information
Showing
3 changed files
with
141 additions
and
43 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,80 @@ | ||
#!/usr/bin/env pwsh | ||
# Copyright 2018 the Deno authors. All rights reserved. MIT license. | ||
# TODO(everyone): Keep this script simple and easily auditable. | ||
|
||
$ErrorActionPreference = 'Stop' | ||
|
||
if ($v) { | ||
$Version = "v${v}" | ||
} | ||
if ($args.Length -eq 1) { | ||
$Version = $args.Get(0) | ||
} | ||
|
||
$FlyctlInstall = $env:FLYCTL_INSTALL | ||
$BinDir = if ($FlyctlInstall) { | ||
"$FlyctlInstall\bin" | ||
} else { | ||
"$Home\.fly\bin" | ||
} | ||
|
||
$FlyctlTgz = "$BinDir\flyctl.tar.gz" | ||
$FlyctlExe = "$BinDir\flyctl.exe" | ||
$Target = 'Windows_x86_64' | ||
|
||
# GitHub requires TLS 1.2 | ||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | ||
|
||
$FlyctlUri = if (!$Version) { | ||
$Response = Invoke-WebRequest 'https://github.com/superfly/flyctl/releases' -UseBasicParsing | ||
if ($PSVersionTable.PSEdition -eq 'Core') { | ||
$Response.Links | | ||
Where-Object { $_.href -like "/superfly/flyctl/releases/download/*/flyctl_*.*.*_${Target}.tar.gz" } | | ||
ForEach-Object { 'https://github.com' + $_.href } | | ||
Select-Object -First 1 | ||
} else { | ||
$HTMLFile = New-Object -Com HTMLFile | ||
if ($HTMLFile.IHTMLDocument2_write) { | ||
$HTMLFile.IHTMLDocument2_write($Response.Content) | ||
} else { | ||
$ResponseBytes = [Text.Encoding]::Unicode.GetBytes($Response.Content) | ||
$HTMLFile.write($ResponseBytes) | ||
} | ||
$HTMLFile.getElementsByTagName('a') | | ||
Where-Object { $_.href -like "about:/superfly/flyctl/releases/download/*/flyctl_*.*.*_${Target}.tar.gz" } | | ||
ForEach-Object { $_.href -replace 'about:', 'https://github.com' } | | ||
Select-Object -First 1 | ||
} | ||
} else { | ||
"https://github.com/denoland/deno/releases/download/${Version}/deno_${Version}_${Target}.tar.gz" | ||
} | ||
|
||
if (!(Test-Path $BinDir)) { | ||
New-Item $BinDir -ItemType Directory | Out-Null | ||
} | ||
|
||
Invoke-WebRequest $FlyctlUri -OutFile $FlyctlTgz -UseBasicParsing | ||
|
||
tar xvzCf $BinDir $FlyctlTgz | ||
|
||
# if (Get-Command Expand-Archive -ErrorAction SilentlyContinue) { | ||
# Expand-Archive $DenoZip -Destination $BinDir -Force | ||
# } else { | ||
# if (Test-Path $DenoExe) { | ||
# Remove-Item $DenoExe | ||
# } | ||
# Add-Type -AssemblyName System.IO.Compression.FileSystem | ||
# [IO.Compression.ZipFile]::ExtractToDirectory($DenoZip, $BinDir) | ||
# } | ||
|
||
Remove-Item $FlyctlTgz | ||
|
||
$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 "Flyctl was installed successfully to $FlyctlExe" | ||
Write-Output "Run 'flyctl --help' to get started" |
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,61 @@ | ||
#!/bin/sh | ||
# Based on Deno installer: Copyright 2019 the Deno authors. All rights reserved. MIT license. | ||
# TODO(everyone): Keep this script simple and easily auditable. | ||
|
||
set -e | ||
|
||
if [ "$(uname -m)" != "x86_64" ]; then | ||
echo "Error: Unsupported architecture $(uname -m). Only x64 binaries are available." 1>&2 | ||
exit 1 | ||
fi | ||
|
||
# We are using tar and its inbuilt uncompress - no need to check for command availability | ||
|
||
case $(uname -s) in | ||
Darwin) target="macOS_x86_64" ;; | ||
*) target="Linux_x86_64" ;; | ||
esac | ||
|
||
if [ $# -eq 0 ]; then | ||
flyctl_asset_path=$( | ||
curl -sSf https://github.com/superfly/flyctl/releases | | ||
grep -E -o "/superfly/flyctl/releases/download/.*/flyctl_[0-9]+\\.[0-9]+\\.[0-9]+_${target}.tar.gz" | | ||
head -n 1 | ||
) | ||
if [ ! "$flyctl_asset_path" ]; then | ||
echo "Error: Unable to find latest Flyctl release on GitHub." 1>&2 | ||
exit 1 | ||
fi | ||
flyctl_uri="https://github.com${flyctl_asset_path}" | ||
else | ||
flyctl_uri="https://github.com/superfly/flyctl/releases/download/${1}/deno-${target}.tar.gz" | ||
fi | ||
|
||
flyctl_install="${FLYCTL_INSTALL:-$HOME/.fly}" | ||
|
||
bin_dir="$flyctl_install/bin" | ||
exe="$bin_dir/flyctl" | ||
|
||
if [ ! -d "$bin_dir" ]; then | ||
mkdir -p "$bin_dir" | ||
fi | ||
|
||
curl --fail --location --progress-bar --output "$exe.tar.gz" "$flyctl_uri" | ||
cd "$bin_dir" | ||
tar xzf "$exe.tar.gz" | ||
chmod +x "$exe" | ||
rm "$exe.tar.gz" | ||
|
||
echo "Flyctl was installed successfully to $exe" | ||
if command -v flyctl >/dev/null; then | ||
echo "Run 'flyctl --help' to get started" | ||
else | ||
case $SHELL in | ||
/bin/zsh) shell_profile=".zshrc" ;; | ||
*) shell_profile=".bash_profile" ;; | ||
esac | ||
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)" | ||
echo " export FLYCTL_INSTALL=\"$flyctl_install\"" | ||
echo " export PATH=\"\$FLYCTL_INSTALL/bin:\$PATH\"" | ||
echo "Run '$exe --help' to get started" | ||
fi |