Skip to content

Commit

Permalink
fix: chectl update and default commands (#2837)
Browse files Browse the repository at this point in the history
* fix: chectl update and default commands

Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha authored Dec 7, 2023
1 parent 59da0a4 commit 4775c57
Show file tree
Hide file tree
Showing 4 changed files with 275 additions and 203 deletions.
61 changes: 57 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ USAGE
<!-- commands -->
* [`chectl autocomplete [SHELL]`](#chectl-autocomplete-shell)
* [`chectl cacert:export`](#chectl-cacertexport)
* [`chectl commands`](#chectl-commands)
* [`chectl dashboard:open`](#chectl-dashboardopen)
* [`chectl help [COMMANDS]`](#chectl-help-commands)
* [`chectl server:debug`](#chectl-serverdebug)
Expand Down Expand Up @@ -174,6 +175,38 @@ DESCRIPTION

_See code: [src/commands/cacert/export.ts](https://github.com/che-incubator/chectl/blob/v0.0.2/src/commands/cacert/export.ts)_

## `chectl commands`

list all the commands

```
USAGE
$ chectl commands [--json] [-h] [--hidden] [--tree] [--columns <value> | -x] [--filter <value>] [--no-header
| [--csv | --no-truncate]] [--output csv|json|yaml | | ] [--sort <value>]
FLAGS
-h, --help Show CLI help.
-x, --extended show extra columns
--columns=<value> only show provided columns (comma-separated)
--csv output is csv format [alias: --output=csv]
--filter=<value> filter property by partial string matching, ex: name=foo
--hidden show hidden commands
--no-header hide table header from output
--no-truncate do not truncate output to fit screen
--output=<option> output in a more machine friendly format
<options: csv|json|yaml>
--sort=<value> property to sort by (prepend '-' for descending)
--tree show tree of commands
GLOBAL FLAGS
--json Format output as json.
DESCRIPTION
list all the commands
```

_See code: [@oclif/plugin-commands](https://github.com/oclif/plugin-commands/blob/v3.0.7/src/commands/commands.ts)_

## `chectl dashboard:open`

Open Eclipse Che dashboard
Expand Down Expand Up @@ -212,7 +245,7 @@ DESCRIPTION
Display help for chectl.
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.20/src/commands/help.ts)_
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.7/src/commands/help.ts)_

## `chectl server:debug`

Expand Down Expand Up @@ -627,16 +660,36 @@ update the chectl CLI

```
USAGE
$ chectl update [CHANNEL] [--from-local]
$ chectl update [CHANNEL] [-a] [--force] [-i | -v <value>]
FLAGS
--from-local interactively choose an already installed version
-a, --available See available versions.
-i, --interactive Interactively select version to install. This is ignored if a channel is provided.
-v, --version=<value> Install a specific version.
--force Force a re-download of the requested version.
DESCRIPTION
update the chectl CLI
EXAMPLES
Update to the stable channel:
$ chectl update stable
Update to a specific version:
$ chectl update --version 1.0.0
Interactively select version:
$ chectl update --interactive
See available versions:
$ chectl update --available
```

_See code: [@oclif/plugin-update](https://github.com/oclif/plugin-update/blob/v1.5.0/src/commands/update.ts)_
_See code: [@oclif/plugin-update](https://github.com/oclif/plugin-update/blob/v4.1.4/dist/commands/update.ts)_

## `chectl version`

Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"@oclif/core": "^3.0.4",
"@oclif/parser": "^3.8.17",
"@oclif/plugin-autocomplete": "^2.3.9",
"@oclif/plugin-help": "^5.2.20",
"@oclif/plugin-update": "^1",
"@oclif/plugin-commands": "^3.0.7",
"@oclif/plugin-help": "^6.0.7",
"@oclif/plugin-update": "^4.1.4",
"@oclif/plugin-version": "^2.0.1",
"@octokit/rest": "^19.0.5",
"analytics-node": "^6.2.0",
Expand Down Expand Up @@ -97,7 +98,7 @@
"-v"
],
"topicSeparator": ":",
"default": ".",
"default": "commands",
"commands": "./lib/commands",
"hooks": {
"prerun": "./lib/hooks/prerun/new-version-warning",
Expand All @@ -111,7 +112,8 @@
"@oclif/plugin-autocomplete",
"@oclif/plugin-help",
"@oclif/plugin-update",
"@oclif/plugin-version"
"@oclif/plugin-version",
"@oclif/plugin-commands"
],
"topics": {
"server": {
Expand Down
11 changes: 6 additions & 5 deletions src/utils/command-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
* Red Hat, Inc. - initial API and implementation
*/

import UpdateCommand from '@oclif/plugin-update/lib/commands/update'
import { ux } from '@oclif/core'
import * as notifier from 'node-notifier'
import {newError} from './utls'
import {getProjectName, newError} from './utls'
import {CheCtlContext, CliContext} from '../context'
import * as fs from 'node:fs'
import {CheCtlVersion} from './chectl-version'
import {EclipseChe} from '../tasks/installers/eclipse-che/eclipse-che'
import * as execa from 'execa'
import * as path from 'node:path'
import {CheCtlVersion} from './chectl-version'

/**
* Returns command success message with execution time.
Expand Down Expand Up @@ -68,8 +69,8 @@ export async function askForChectlUpdateIfNeeded(): Promise<void> {
if (await CheCtlVersion.isCheCtlUpdateAvailable(ctx[CliContext.CLI_CACHE_DIR])) {
ux.info(`A more recent version of chectl is available. To deploy the latest version of ${EclipseChe.PRODUCT_NAME}, update the chectl tool first.`)
if (await ux.confirm('Do you want to update chectl now? [y/n]')) {
// Update chectl
await UpdateCommand.run([])
const bin = path.join(__dirname, '..', '..', 'bin', getProjectName())

Check warning on line 72 in src/utils/command-utils.ts

View workflow job for this annotation

GitHub Actions / build-and-deploy

Do not use "__dirname"
await execa(bin, ['update'], {stdout: 'inherit', stderr: 'inherit', timeout: 60_000})
ux.exit(0)
}
}
Expand Down
Loading

0 comments on commit 4775c57

Please sign in to comment.