Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Upsun CLI

> [!IMPORTANT]
> **This repository has been migrated to [upsun/cli](https://github.com/upsun/cli).**
>
> Please use the new repository for all future installations, updates, and issue reporting.
>
> To install the CLI from the new location:
> ```console
> curl -fsSL https://raw.githubusercontent.com/upsun/cli/main/installer.sh | bash
> ```
>
> Existing installations will continue to work, but we recommend migrating to the new repository.

The **Upsun CLI** is the official command-line interface for [Upsun](https://upsun.com) (formerly Platform.sh).

This repository hosts the source code and releases of the CLI.
Expand Down Expand Up @@ -30,7 +42,7 @@ scoop install platform
Use the bash installer for an automated installation, using the most preferable way for your system.

```console
curl -fsSL https://raw.githubusercontent.com/platformsh/cli/main/installer.sh | bash
curl -fsSL https://raw.githubusercontent.com/upsun/cli/main/installer.sh | bash
```

The installer is configurable using the following environment variables:
Expand All @@ -56,19 +68,19 @@ nix profile install nixpkgs#upsun
<details>
<summary>Force the CLI to be installed using the raw method</summary>

curl -fsSL https://raw.githubusercontent.com/platformsh/cli/main/installer.sh | INSTALL_METHOD=raw bash
curl -fsSL https://raw.githubusercontent.com/upsun/cli/main/installer.sh | INSTALL_METHOD=raw bash
</details>

<details>
<summary>Install a specific version</summary>

curl -fsSL https://raw.githubusercontent.com/platformsh/cli/main/installer.sh | VERSION=4.0.1 bash
curl -fsSL https://raw.githubusercontent.com/upsun/cli/main/installer.sh | VERSION=4.0.1 bash
</details>

<details>
<summary>Install the CLI in a user owned directory</summary>

curl -fsSL https://raw.githubusercontent.com/platformsh/cli/main/installer.sh | INSTALL_METHOD=raw INSTALL_DIR=$HOME/.local/bin bash
curl -fsSL https://raw.githubusercontent.com/upsun/cli/main/installer.sh | INSTALL_METHOD=raw INSTALL_DIR=$HOME/.local/bin bash
</details>

### Alpine
Expand Down Expand Up @@ -139,7 +151,7 @@ yum install -y platformsh-cli

### Manual installation

For manual installation, you can also [download the latest binaries](https://github.com/platformsh/cli/releases/latest).
For manual installation, you can also [download the latest binaries](https://github.com/upsun/cli/releases/latest).

## Upgrade

Expand All @@ -160,7 +172,7 @@ scoop update platform
### Bash installer

```console
curl -fsSL https://raw.githubusercontent.com/platformsh/cli/main/installer.sh | bash
curl -fsSL https://raw.githubusercontent.com/upsun/cli/main/installer.sh | bash
```

### Alpine
Expand Down
82 changes: 78 additions & 4 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set -euo pipefail
# Define this to force install method
: "${INSTALL_METHOD:=}"

: "${URL:=https://github.com/platformsh/cli/releases/download}"
: "${URL:=https://github.com/upsun/cli/releases/download}"

# Force Upsun CLI installation in this directory instead of system directory
: "${INSTALL_DIR:=}"
Expand All @@ -32,6 +32,12 @@ set -euo pipefail
: "${BUILD_NUMBER:=}"
: "${RUN_ID:=}"

# Skip migration prompt (set to any value to skip)
: "${SKIP_MIGRATION_PROMPT:=}"

# New repository URL
NEW_REPO_INSTALLER="https://raw.githubusercontent.com/upsun/cli/main/installer.sh"

# global variables
binary="platform"
vendor_name="Upsun (formerly Platform.sh)"
Expand Down Expand Up @@ -164,11 +170,70 @@ function exit_with_error() {
exit 1
}

function output_stderr {
builtin echo -e "$1" >&2
}

function show_migration_warning {
output_stderr ""
output_stderr "\033[33m+-------------------------------------------------------------------------------------+\033[0m"
output_stderr "\033[33m| |\033[0m"
output_stderr "\033[33m| WARNING: This repository (platformsh/cli) has been migrated to upsun/cli |\033[0m"
output_stderr "\033[33m| |\033[0m"
output_stderr "\033[33m| Please use the new installer: |\033[0m"
output_stderr "\033[33m| curl -fsSL $NEW_REPO_INSTALLER | bash |\033[0m"
output_stderr "\033[33m| |\033[0m"
output_stderr "\033[33m+-------------------------------------------------------------------------------------+\033[0m"
output_stderr ""
}

function prompt_migration_continue {
# Skip prompt if flag is set
if [ ! -z "${SKIP_MIGRATION_PROMPT}" ]; then
return
fi

# Skip prompt if running in CI
if is_ci; then
return
fi

# Skip prompt if not running interactively
if ! is_interactive; then
return
fi

# Read from /dev/tty to get input even when script is piped
read -r -p " Do you want to continue with this installer? [y/N] " response < /dev/tty

case "$response" in
[yY][eE][sS]|[yY])
output ""
output " Continuing with installation from platformsh/cli..." "info"
output ""
;;
*)
output ""
output " Installation cancelled." "info"
output " To install from the new repository, run:" "info"
output " curl -fsSL ${NEW_REPO_INSTALLER} | bash" "info"
output ""
exit 0
;;
esac
}

function intro() {
local title="$vendor_name CLI Installer"

output "$(create_table "$title")" "heading"

# Always show migration warning to stderr
show_migration_warning

# Prompt user to continue if interactive and not in CI
prompt_migration_continue

output "\nChecking environment" "heading"
}

Expand Down Expand Up @@ -219,13 +284,13 @@ function check_curl() {
output " [*] cURL is installed" "success"
if gh auth status >/dev/null 2>&1; then
GITHUB_TOKEN="$(gh auth token)"
if ! github_curl https://api.github.com/repos/platformsh/cli/releases/latest >/dev/null 2>&1; then
if ! github_curl https://api.github.com/repos/upsun/cli/releases/latest >/dev/null 2>&1; then
GITHUB_TOKEN=""
else
output " [*] Using GitHub auth from the gh CLI" "success"
fi
elif [ ! -z "${GITHUB_TOKEN}" ]; then
if ! github_curl https://api.github.com/repos/platformsh/cli/releases/latest >/dev/null 2>&1; then
if ! github_curl https://api.github.com/repos/upsun/cli/releases/latest >/dev/null 2>&1; then
GITHUB_TOKEN=""
else
output " [*] Using GitHub auth from the GITHUB_TOKEN env variable" "success"
Expand All @@ -249,7 +314,7 @@ function check_gzip() {

function check_version() {
if [ -z "${VERSION}" ]; then
version=$(curl -I https://github.com/platformsh/cli/releases/latest 2>/dev/null | awk -F/ -v RS='\r\n' '/platformsh.cli.releases.tag/ {printf "%s", $NF}')
version=$(curl -I https://github.com/upsun/cli/releases/latest 2>/dev/null | awk -F/ -v RS='\r\n' '/upsun.cli.releases.tag/ {printf "%s", $NF}')
output " [*] No version specified, using latest ($version)" "success"
else
output " [*] Version ${VERSION} specified" "success"
Expand Down Expand Up @@ -537,6 +602,15 @@ function is_ci {
fi
}

function is_interactive {
# Check if stdin is a terminal (TTY)
if [ -t 0 ]; then
return 0
else
return 1
fi
}

function install_raw() {
# Start downloading the right version
output "\nDownloading the $vendor_name CLI" "heading"
Expand Down
4 changes: 2 additions & 2 deletions internal/config/platformsh-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# These are settings for the 'platform' command, which is available for backwards compatibility.
wrapper:
homebrew_tap: platformsh/tap/platformsh-cli
github_repo: platformsh/cli
homebrew_tap: upsun/tap/platformsh-cli
github_repo: upsun/cli

application:
name: 'Upsun CLI (Platform.sh compatibility)'
Expand Down
4 changes: 2 additions & 2 deletions internal/config/upsun-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# See ../internal/config/schema.go for the required keys
wrapper:
homebrew_tap: platformsh/tap/upsun-cli
github_repo: platformsh/cli
homebrew_tap: upsun/tap/upsun-cli
github_repo: upsun/cli

application:
name: "Upsun CLI"
Expand Down