Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,39 @@ control it:
`<method>` is one of `homebrew`, `scoop`, `npm`, `package`, or `script`. Use
`package` to silence the notice when the OS manages updates.

(For the `platform` command, the prefix is `PLATFORMSH_CLI_` instead of
`UPSUN_CLI_`.)
## Configuration

You can override configuration in the user config file,
`~/.upsun-cli/config.yaml`. The available keys are in
[legacy/config-defaults.yaml](legacy/config-defaults.yaml).

Environment variables include:

- `UPSUN_CLI_TOKEN`: an API token, for non-interactive use such as CI. An API
token can act as the account that created it, so use a separate machine
account to limit its access. Interactively, prefer `upsun auth:api-token-login`.
- `UPSUN_CLI_DEBUG=1`: enable debug output. This can print HTTP request details,
including access tokens.
- `UPSUN_CLI_DEFAULT_TIMEOUT`: the timeout in seconds for most API requests
(default 30).
- `UPSUN_CLI_DISABLE_CACHE=1`: disable caching. To clear the cache once, run
`upsun clear-cache`.
- `UPSUN_CLI_HOME`: override the home directory, which contains `.upsun-cli`.
- `UPSUN_CLI_NO_INTERACTION=1`: disable interaction, like `--no-interaction`.
This skips confirmation questions.
- `UPSUN_CLI_SESSION_ID`: switch user session (default `default`). See also
`upsun session:switch`.
- `UPSUN_CLI_AUTO_LOAD_SSH_CERT=0`: disable automatically loading an SSH
certificate when running login or SSH commands.
- `UPSUN_CLI_SHELL_CONFIG_FILE`: the shell config file that `self:install`
writes to (an absolute path). Set it to an empty string to skip writing one.
- `UPSUN_CLI_REPORT_DEPRECATIONS=1`: show PHP deprecation notices in debug mode
(`-vvv`).
- `NO_COLOR=1` or `CLICOLOR_FORCE=0`/`1`: turn colors off or force them on.
- `http_proxy` or `https_proxy`: use an HTTP proxy.

The `UPSUN_CLI_` prefix and the `.upsun-cli` directory come from the CLI's
embedded config, so other builds of the CLI may use different ones.

## Building

Expand Down
2 changes: 1 addition & 1 deletion docs/design/update-message-install-detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ is shown even when the user cannot act on it usefully:
## Non-goals

- Silent or unattended self-update. Updates are only ever performed after an
explicit interactive prompt. `self:update` (the PHP command) stays disabled.
explicit interactive prompt. The PHP `self:update` command has been removed.
- Auto-running privileged or remote-code upgrades (`sudo`, `curl … | sh`). For
those channels we print the command rather than executing it (see Phase 2).
- Changing the network-check throttle, the CI gate, or the TTY gate.
Expand Down
1 change: 0 additions & 1 deletion internal/config/platformsh-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ application:

disabled_commands:
- self:install
- self:update

service:
name: "Upsun (formerly Platform.sh)"
Expand Down
1 change: 0 additions & 1 deletion internal/config/upsun-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ application:

disabled_commands:
- self:install
- self:update
- local:build
- local:drush-aliases
- project:variable:delete
Expand Down
1 change: 0 additions & 1 deletion internal/legacy/cert_store_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ func openMachineRootStore(t *testing.T) windows.Handle {
return store
}


// withoutHanging fails the test if fn does not return in time.
func withoutHanging(t *testing.T, description string, fn func() error) {
t.Helper()
Expand Down
1 change: 1 addition & 0 deletions internal/legacy/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func (c *CLIWrapper) Exec(ctx context.Context, args ...string) error {
cmd.Env = append(
cmd.Env,
"CLI_CONFIG_FILE="+filepath.Join(cacheDir, configBasename),
// Stops update checks in wrapper processes the PHP CLI spawns, e.g. via SSH config.
envPrefix+"UPDATES_CHECK=0",
Comment thread
pjcdawkins marked this conversation as resolved.
envPrefix+"MIGRATE_CHECK=0",
envPrefix+"APPLICATION_PROMPT_SELF_INSTALL=0",
Expand Down
1 change: 0 additions & 1 deletion legacy/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
->in(__DIR__)
->notPath([
'config/cache/container.php', // Ignore generated file
'dist/installer.php', // Keep old PHP compatibility
'tests/data', // Ignore test data
])
;
Expand Down
49 changes: 0 additions & 49 deletions legacy/.platform.app.yaml

This file was deleted.

62 changes: 0 additions & 62 deletions legacy/CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion legacy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.2-cli
FROM php:8.4-cli

ARG USER_ID
ARG GROUP_ID
Expand Down
122 changes: 25 additions & 97 deletions legacy/README.md
Original file line number Diff line number Diff line change
@@ -1,113 +1,41 @@
The **Legacy** CLI is the legacy version of the command-line interface for [Upsun (formerly Platform.sh)](https://upsun.com).
# Legacy PHP CLI

For the **current Upsun CLI**, check [this repository](https://github.com/platformsh/cli).
This directory contains the PHP layer of the Upsun CLI. It is built into a
phar and embedded in the Go wrapper, which runs it with its own PHP binary.
Commands not implemented in Go are passed to it.

## Install
It was merged in from the archived
[platformsh/legacy-cli](https://github.com/platformsh/legacy-cli) repository.
Changes are now made here.

To install the CLI, use either [Homebrew](https://brew.sh/) (on Linux, macOS, or the Windows Subsystem for Linux) or [Scoop](https://scoop.sh/) (on Windows):
See the [root README](../README.md) for installing, configuring and building
the CLI.

### HomeBrew
## Development

```console
brew install upsun/tap/platformsh-cli
```

### Scoop

```console
scoop bucket add platformsh https://github.com/platformsh/homebrew-tap.git
scoop install platform
```

### Manual installation

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

### Legacy installer

_This installation method is considered legacy and is discouraged, use one of the methods above instead. Starting with version 5.x, this installation method will not be supported._
Install dependencies:

In order to use the Legacy installer, you need to have an operating system supported by PHP (Linux, OS X, or Windows) and PHP 8.2 or higher, with the following extensions: `curl`, `json`, `pcre`, and `phar`.

Run this command to install the CLI using the legacy installer, given that you have PHP already installed:

```console
curl -sS https://platform.sh/cli/installer | php
```sh
composer install
```

In some Windows terminals you may need `php.exe` instead of `php`.

## Upgrade

Upgrade using the same tool:
Run the PHP CLI from source:

### HomeBrew

```console
brew upgrade platformsh-cli
```sh
./bin/platform
```

### Scoop
Run linters (php-cs-fixer and PHPStan) and unit tests:

```console
scoop update platform
```sh
make lint
make test
```

## Usage

You can run this CLI in your shell by typing `platform`.

platform

Use the 'list' command to get a list of available options and commands:

platform list

## Authentication

There are two ways to authenticate:

1. The recommended way is `platform login`, which lets you log in via a web browser, including via third-party providers such as Google, GitHub, GitLab and Bitbucket.

2. If using a browser is not possible, use an [API token](https://docs.upsun.com/anchors/fixed/cli/api-token/).

An interactive command is available for this: `platform auth:api-token-login`

For non-interactive uses such as scripts or CI systems, set the API token in an environment variable named `PLATFORMSH_CLI_TOKEN`. This can be insecure if not handled properly, although it is appropriate for systems such as CircleCI, Jenkins and GitLab.

*_Warning_*: An API token can act as the account that created it, with no restrictions. Use a separate machine account to limit the token's access.

## Customization

You can configure the CLI via the user configuration file `~/.platformsh/config.yaml`.

The possible keys that can be overridden are in the [config-defaults.yaml](/config-defaults.yaml) and [config.yaml](/config.yaml) files.

Other customization is available via environment variables, including:

* `PLATFORMSH_CLI_DEBUG`: set to 1 to enable debugging. _Warning_: this could print HTTP request information in the terminal, including sensitive access tokens.
* `PLATFORMSH_CLI_DEFAULT_TIMEOUT`: the timeout (in seconds) for most individual API requests. The default is 30.
* `PLATFORMSH_CLI_DISABLE_CACHE`: set to 1 to disable caching
* `PLATFORMSH_CLI_HOME`: override the home directory (inside which the .platformsh directory is stored)
* `PLATFORMSH_CLI_NO_COLOR`: set to 1 to disable colors in output
* `PLATFORMSH_CLI_NO_INTERACTION`: set to 1 to disable interaction (useful for scripting). Equivalent to the `--no-interaction` command-line option. _Warning_: this will bypass any confirmation questions.
* `PLATFORMSH_CLI_SESSION_ID`: change user session (default 'default'). The `session:switch` command (beta) is now available as an alternative.
* `PLATFORMSH_CLI_SHELL_CONFIG_FILE`: specify the shell configuration file that the installer should write to (as an absolute path). If not set, a file such as `~/.bashrc` will be chosen automatically. Set this to an empty string to disable writing to a shell config file.
* `PLATFORMSH_CLI_TOKEN`: an API token. *_Warning_*: An API token can act as the account that created it, with no restrictions. Use a separate machine account to limit the token's access. Additionally, storing a secret in an environment variable can be insecure. It may be better to use the `auth:api-token-login` command. The environment variable is preferable on CI systems like Jenkins and GitLab.
* `PLATFORMSH_CLI_UPDATES_CHECK`: set to 0 to disable the automatic updates check
* `PLATFORMSH_CLI_SSH_AUTO_LOAD_CERT`: set to 0 to disable automatic loading of an SSH certificate when running login or SSH commands
* `PLATFORMSH_CLI_REPORT_DEPRECATIONS`: set to 1 to enable PHP deprecation notices (suppressed by default). They will only be displayed in debug mode (`-vvv`).
* `CLICOLOR_FORCE`: set to 1 or 0 to force colorized output on or off, respectively
* `http_proxy` or `https_proxy`: specify an HTTP proxy

## Known issues

### Caching

The CLI caches details of your projects and their environments, and some other
information. These caches could become out-of-date. You can clear caches with
the command `platform clear-cache` (or `platform cc` for short).
After changing services or commands, delete the cached container
(`make clean`).

## Contributing
To build the embedded phar, run `make single` from the repository root.

See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute to the CLI.
A Docker development environment is available: copy `.env-dist` to `.env`,
then run `docker-compose up -d` and `docker-compose exec cli bash`.
12 changes: 2 additions & 10 deletions legacy/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Platform.sh CLI",
"license": "MIT",
"require": {
"php": ">=8.2",
"php": ">=8.4",
"doctrine/cache": "~1.5",
"guzzlehttp/guzzle": "^7",
"platformsh/console-form": "^1@beta",
Expand All @@ -14,25 +14,17 @@
"symfony/filesystem": "^7",
"symfony/process": "^7",
"symfony/event-dispatcher": "^7",
"padraic/phar-updater": "^1.0",
"symfony/dependency-injection": "^7",
"symfony/config": "^7",
"ext-json": "*",
"composer/ca-bundle": "^1.3",
"khill/php-duration": "^1.1",
"symfony/polyfill-mbstring": "^1.19",
"symfony/polyfill-iconv": "^1.19",
"padraic/humbug_get_contents": "dev-allow-php-8 as 1.1.3",
"platformsh/oauth2": "^1@beta",
"giggsey/libphonenumber-for-php-lite": "^8.13",
"symfony/var-dumper": "^7.3"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/pjcdawkins/humbug_get_contents"
}
],
"suggest": {
"drush/drush": "For Drupal projects"
},
Expand Down Expand Up @@ -66,7 +58,7 @@
],
"config": {
"platform": {
"php": "8.2"
"php": "8.4"
}
},
"scripts": {
Expand Down
Loading
Loading