From e5cee648f25329bceaea6661a8065c5e2e6eccf4 Mon Sep 17 00:00:00 2001 From: myarmolinsky Date: Thu, 26 Sep 2024 13:01:19 -0400 Subject: [PATCH] Add alias `device-type list` for command `devices supported` Change-type: minor --- completion/_balena | 10 +-- completion/balena-completion.bash | 10 +-- docs/balena-cli.md | 82 +++++++++++-------- src/commands/app/create.ts | 4 +- src/commands/block/create.ts | 4 +- src/commands/config/generate.ts | 2 +- src/commands/device-type/list.ts | 16 ++-- src/commands/device/register.ts | 2 +- src/commands/fleet/create.ts | 4 +- src/commands/os/download.ts | 2 +- src/commands/os/versions.ts | 2 +- src/errors.ts | 2 +- src/utils/common-flags.ts | 2 +- tests/commands/device-type/list.spec.ts | 8 +- tests/commands/help.spec.ts | 2 +- .../pkg/expected-warnings-darwin-arm64.txt | 2 +- .../pkg/expected-warnings-darwin-x64.txt | 2 +- .../pkg/expected-warnings-linux-arm64.txt | 2 +- .../pkg/expected-warnings-linux-x64.txt | 2 +- .../pkg/expected-warnings-win32-x64.txt | 2 +- 20 files changed, 88 insertions(+), 74 deletions(-) diff --git a/completion/_balena b/completion/_balena index 21ee47b2..0058ceab 100644 --- a/completion/_balena +++ b/completion/_balena @@ -8,14 +8,14 @@ _balena() { local context state line curcontext="$curcontext" # Valid top-level completions - main_commands=( api-key app block build config deploy device devices env fleet internal join leave local login logout organization os preload push release settings ssh-key support tag util version whoami ) + main_commands=( api-key app block build config deploy device device-type env fleet internal join leave local login logout organization os preload push release settings ssh-key support tag util version whoami ) # Sub-completions api_key_cmds=( generate list revoke ) app_cmds=( create ) block_cmds=( create ) config_cmds=( generate inject read reconfigure write ) + device_type_cmds=( list ) device_cmds=( deactivate detect identify init list local-mode logs move note os-update pin public-url purge reboot register rename restart rm shutdown ssh start-service stop-service track-fleet tunnel ) - devices_cmds=( supported ) env_cmds=( list rename rm set ) fleet_cmds=( create list pin purge rename restart rm track-latest ) internal_cmds=( osinit ) @@ -55,12 +55,12 @@ _balena_sec_cmds() { "config") _describe -t config_cmds 'config_cmd' config_cmds "$@" && ret=0 ;; + "device-type") + _describe -t device_type_cmds 'device-type_cmd' device_type_cmds "$@" && ret=0 + ;; "device") _describe -t device_cmds 'device_cmd' device_cmds "$@" && ret=0 ;; - "devices") - _describe -t devices_cmds 'devices_cmd' devices_cmds "$@" && ret=0 - ;; "env") _describe -t env_cmds 'env_cmd' env_cmds "$@" && ret=0 ;; diff --git a/completion/balena-completion.bash b/completion/balena-completion.bash index 78c9c32f..3aa1c25b 100644 --- a/completion/balena-completion.bash +++ b/completion/balena-completion.bash @@ -7,14 +7,14 @@ _balena_complete() local cur prev # Valid top-level completions - main_commands="api-key app block build config deploy device devices env fleet internal join leave local login logout organization os preload push release settings ssh-key support tag util version whoami" + main_commands="api-key app block build config deploy device device-type env fleet internal join leave local login logout organization os preload push release settings ssh-key support tag util version whoami" # Sub-completions api_key_cmds="generate list revoke" app_cmds="create" block_cmds="create" config_cmds="generate inject read reconfigure write" + device_type_cmds="list" device_cmds="deactivate detect identify init list local-mode logs move note os-update pin public-url purge reboot register rename restart rm shutdown ssh start-service stop-service track-fleet tunnel" - devices_cmds="supported" env_cmds="list rename rm set" fleet_cmds="create list pin purge rename restart rm track-latest" internal_cmds="osinit" @@ -49,12 +49,12 @@ _balena_complete() config) COMPREPLY=( $(compgen -W "$config_cmds" -- $cur) ) ;; + device-type) + COMPREPLY=( $(compgen -W "$device_type_cmds" -- $cur) ) + ;; device) COMPREPLY=( $(compgen -W "$device_cmds" -- $cur) ) ;; - devices) - COMPREPLY=( $(compgen -W "$devices_cmds" -- $cur) ) - ;; env) COMPREPLY=( $(compgen -W "$env_cmds" -- $cur) ) ;; diff --git a/docs/balena-cli.md b/docs/balena-cli.md index de2a8d55..5c4bccf8 100644 --- a/docs/balena-cli.md +++ b/docs/balena-cli.md @@ -193,6 +193,10 @@ are encouraged to regularly update the balena CLI to the latest version. - [build](#build) - [deploy](#deploy) +- Device-type + + - [device-type list](#device-type-list) + - Devices - [device deactivate](#device-deactivate) @@ -220,7 +224,6 @@ are encouraged to regularly update the balena CLI to the latest version. - [device stop-service](#device-stop-service) - [device track-fleet](#device-track-fleet) - [device tunnel](#device-tunnel) - - [devices supported](#devices-supported) - Environment Variables @@ -397,7 +400,7 @@ should be provided. Organization handles can be listed with the `balena organization list` command. The app's default device type is specified with the `--type` option. -The `balena devices supported` command can be used to list the available +The `balena device-type list` command can be used to list the available device types. Interactive dropdowns will be shown for selection if no device type or @@ -426,7 +429,7 @@ handle of the organization the app should belong to #### -t, --type TYPE -app device type (Check available types with `balena devices supported`) +app device type (Check available types with `balena device-type list`) # Authentication @@ -527,7 +530,7 @@ should be provided. Organization handles can be listed with the `balena organization list` command. The block's default device type is specified with the `--type` option. -The `balena devices supported` command can be used to list the available +The `balena device-type list` command can be used to list the available device types. Interactive dropdowns will be shown for selection if no device type or @@ -556,7 +559,7 @@ handle of the organization the block should belong to #### -t, --type TYPE -block device type (Check available types with `balena devices supported`) +block device type (Check available types with `balena device-type list`) # Config @@ -638,7 +641,7 @@ custom device key - note that this is only supported on balenaOS 2.0.3+ #### --deviceType DEVICETYPE -device type slug (run 'balena devices supported' for possible values) +device type slug (run 'balena device-type list' for possible values) #### --generate-device-api-key @@ -1220,6 +1223,38 @@ Docker host TLS certificate file Docker host TLS key file +# Device-type + +## device-type list + +### Aliases + +- `devices supported` + + +To use one of the aliases, replace `device-type list` with the alias. + +### Description + +List the device types supported by balena (like 'raspberrypi3' or 'intel-nuc'). + +The --json option is recommended when scripting the output of this command, +because the JSON format is less likely to change and it better represents data +types like lists and empty strings (for example, the ALIASES column contains a +list of zero or more values). The 'jq' utility may be helpful in shell scripts +(https://stedolan.github.io/jq/manual/). + +Examples: + + $ balena device-type list + $ balena device-type list --json + +### Options + +#### -j, --json + +produce JSON output instead of tabular output + # Devices ## device deactivate @@ -1826,7 +1861,7 @@ custom uuid #### --deviceType DEVICETYPE -device type slug (run 'balena devices supported' for possible values) +device type slug (run 'balena device-type list' for possible values) ## device rename @@ -2138,29 +2173,6 @@ device UUID or fleet name/slug port mapping in the format [:[localIP:]localPort] -## devices supported - -### Description - -List the supported device types (like 'raspberrypi3' or 'intel-nuc'). - -The --json option is recommended when scripting the output of this command, -because the JSON format is less likely to change and it better represents data -types like lists and empty strings (for example, the ALIASES column contains a -list of zero or more values). The 'jq' utility may be helpful in shell scripts -(https://stedolan.github.io/jq/manual/). - -Examples: - - $ balena devices supported - $ balena devices supported --json - -### Options - -#### -j, --json - -produce JSON output instead of tabular output - # Environment Variables ## env list @@ -2479,7 +2491,7 @@ should be provided. Organization handles can be listed with the `balena organization list` command. The fleet's default device type is specified with the `--type` option. -The `balena devices supported` command can be used to list the available +The `balena device-type list` command can be used to list the available device types. Interactive dropdowns will be shown for selection if no device type or @@ -2508,7 +2520,7 @@ handle of the organization the fleet should belong to #### -t, --type TYPE -fleet device type (Check available types with `balena devices supported`) +fleet device type (Check available types with `balena device-type list`) ## fleet @@ -2992,7 +3004,7 @@ expiry date assigned to generated provisioning api key (format: YYYY-MM-DD) ### Description Download an unconfigured OS image for the specified device type. -Check available device types with 'balena devices supported'. +Check available device types with 'balena device-type list'. Note: Currently this command only works with balenaCloud, not openBalena. If using openBalena, please download the OS from: https://www.balena.io/os/ @@ -3071,7 +3083,7 @@ path to OS image #### -t, --type TYPE -device type (Check available types with `balena devices supported`) +device type (Check available types with `balena device-type list`) #### -d, --drive DRIVE @@ -3088,7 +3100,7 @@ answer "yes" to all questions (non interactive use) ### Description Show the available balenaOS versions for the given device type. -Check available types with `balena devices supported`. +Check available types with `balena device-type list`. balenaOS ESR versions can be listed with the '--esr' option. See also: https://www.balena.io/docs/reference/OS/extended-support-release/ diff --git a/src/commands/app/create.ts b/src/commands/app/create.ts index 398c3603..67242d30 100644 --- a/src/commands/app/create.ts +++ b/src/commands/app/create.ts @@ -31,7 +31,7 @@ export default class AppCreateCmd extends Command { \`balena organization list\` command. The app's default device type is specified with the \`--type\` option. - The \`balena devices supported\` command can be used to list the available + The \`balena device-type list\` command can be used to list the available device types. Interactive dropdowns will be shown for selection if no device type or @@ -62,7 +62,7 @@ export default class AppCreateCmd extends Command { type: Flags.string({ char: 't', description: - 'app device type (Check available types with `balena devices supported`)', + 'app device type (Check available types with `balena device-type list`)', }), help: cf.help, }; diff --git a/src/commands/block/create.ts b/src/commands/block/create.ts index 7b6a2301..0e69b6cc 100644 --- a/src/commands/block/create.ts +++ b/src/commands/block/create.ts @@ -31,7 +31,7 @@ export default class BlockCreateCmd extends Command { \`balena organization list\` command. The block's default device type is specified with the \`--type\` option. - The \`balena devices supported\` command can be used to list the available + The \`balena device-type list\` command can be used to list the available device types. Interactive dropdowns will be shown for selection if no device type or @@ -62,7 +62,7 @@ export default class BlockCreateCmd extends Command { type: Flags.string({ char: 't', description: - 'block device type (Check available types with `balena devices supported`)', + 'block device type (Check available types with `balena device-type list`)', }), help: cf.help, }; diff --git a/src/commands/config/generate.ts b/src/commands/config/generate.ts index 7bb6b4a6..ee95a0c7 100644 --- a/src/commands/config/generate.ts +++ b/src/commands/config/generate.ts @@ -82,7 +82,7 @@ export default class ConfigGenerateCmd extends Command { }), deviceType: Flags.string({ description: - "device type slug (run 'balena devices supported' for possible values)", + "device type slug (run 'balena device-type list' for possible values)", }), 'generate-device-api-key': Flags.boolean({ description: 'generate a fresh device key for the device', diff --git a/src/commands/device-type/list.ts b/src/commands/device-type/list.ts index 964d5b35..16e2b5b7 100644 --- a/src/commands/device-type/list.ts +++ b/src/commands/device-type/list.ts @@ -20,11 +20,13 @@ import * as _ from 'lodash'; import * as cf from '../../utils/common-flags'; import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy'; -export default class DevicesSupportedCmd extends Command { - public static description = stripIndent` - List the supported device types (like 'raspberrypi3' or 'intel-nuc'). +export default class DeviceTypeListCmd extends Command { + public static aliases = ['devices supported']; - List the supported device types (like 'raspberrypi3' or 'intel-nuc'). + public static description = stripIndent` + List the device types supported by balena (like 'raspberrypi3' or 'intel-nuc'). + + List the device types supported by balena (like 'raspberrypi3' or 'intel-nuc'). The --json option is recommended when scripting the output of this command, because the JSON format is less likely to change and it better represents data @@ -33,8 +35,8 @@ export default class DevicesSupportedCmd extends Command { (https://stedolan.github.io/jq/manual/). `; public static examples = [ - '$ balena devices supported', - '$ balena devices supported --json', + '$ balena device-type list', + '$ balena device-type list --json', ]; public static flags = { @@ -46,7 +48,7 @@ export default class DevicesSupportedCmd extends Command { }; public async run() { - const { flags: options } = await this.parse(DevicesSupportedCmd); + const { flags: options } = await this.parse(DeviceTypeListCmd); const pineOptions = { $select: ['slug', 'name'], $expand: { diff --git a/src/commands/device/register.ts b/src/commands/device/register.ts index de756408..cefea070 100644 --- a/src/commands/device/register.ts +++ b/src/commands/device/register.ts @@ -50,7 +50,7 @@ export default class DeviceRegisterCmd extends Command { }), deviceType: Flags.string({ description: - "device type slug (run 'balena devices supported' for possible values)", + "device type slug (run 'balena device-type list' for possible values)", }), help: cf.help, }; diff --git a/src/commands/fleet/create.ts b/src/commands/fleet/create.ts index 53fd8938..2412ab59 100644 --- a/src/commands/fleet/create.ts +++ b/src/commands/fleet/create.ts @@ -31,7 +31,7 @@ export default class FleetCreateCmd extends Command { \`balena organization list\` command. The fleet's default device type is specified with the \`--type\` option. - The \`balena devices supported\` command can be used to list the available + The \`balena device-type list\` command can be used to list the available device types. Interactive dropdowns will be shown for selection if no device type or @@ -62,7 +62,7 @@ export default class FleetCreateCmd extends Command { type: Flags.string({ char: 't', description: - 'fleet device type (Check available types with `balena devices supported`)', + 'fleet device type (Check available types with `balena device-type list`)', }), help: cf.help, }; diff --git a/src/commands/os/download.ts b/src/commands/os/download.ts index 122d479d..00ae0787 100644 --- a/src/commands/os/download.ts +++ b/src/commands/os/download.ts @@ -24,7 +24,7 @@ export default class OsDownloadCmd extends Command { Download an unconfigured OS image. Download an unconfigured OS image for the specified device type. - Check available device types with 'balena devices supported'. + Check available device types with 'balena device-type list'. Note: Currently this command only works with balenaCloud, not openBalena. If using openBalena, please download the OS from: https://www.balena.io/os/ diff --git a/src/commands/os/versions.ts b/src/commands/os/versions.ts index 60ec4936..bdd1c0b8 100644 --- a/src/commands/os/versions.ts +++ b/src/commands/os/versions.ts @@ -24,7 +24,7 @@ export default class OsVersionsCmd extends Command { Show available balenaOS versions for the given device type. Show the available balenaOS versions for the given device type. - Check available types with \`balena devices supported\`. + Check available types with \`balena device-type list\`. balenaOS ESR versions can be listed with the '--esr' option. See also: https://www.balena.io/docs/reference/OS/extended-support-release/ diff --git a/src/errors.ts b/src/errors.ts index 90e365dd..f099305f 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -190,7 +190,7 @@ const messages: { const slug = error.deviceTypeSlug ? `"${error.deviceTypeSlug}"` : 'slug'; return stripIndent` Device type ${slug} not recognized. Perhaps misspelled? - Check available device types with "balena devices supported"`; + Check available device types with "balena device-type list"`; }, }; diff --git a/src/utils/common-flags.ts b/src/utils/common-flags.ts index 7707e6c9..8f687cf1 100644 --- a/src/utils/common-flags.ts +++ b/src/utils/common-flags.ts @@ -94,7 +94,7 @@ export const driveOrImg = Flags.string({ export const deviceType = Flags.string({ description: - 'device type (Check available types with `balena devices supported`)', + 'device type (Check available types with `balena device-type list`)', char: 't', required: true, }); diff --git a/tests/commands/device-type/list.spec.ts b/tests/commands/device-type/list.spec.ts index eec1b379..64bce186 100644 --- a/tests/commands/device-type/list.spec.ts +++ b/tests/commands/device-type/list.spec.ts @@ -20,7 +20,7 @@ import { expect } from 'chai'; import { BalenaAPIMock } from '../../nock/balena-api-mock'; import { cleanOutput, runCommand } from '../../helpers'; -describe('balena devices supported', function () { +describe('balena device-type list', function () { let api: BalenaAPIMock; beforeEach(() => { @@ -34,9 +34,9 @@ describe('balena devices supported', function () { }); it('should print help text with the -h flag', async () => { - const { out, err } = await runCommand('devices supported -h'); + const { out, err } = await runCommand('device-type list -h'); - expect(cleanOutput(out)).to.contain('$ balena devices supported'); + expect(cleanOutput(out)).to.contain('$ balena device-type list'); expect(err).to.eql([]); }); @@ -44,7 +44,7 @@ describe('balena devices supported', function () { it('should list currently supported devices, with correct filtering', async () => { api.expectGetDeviceTypes(); - const { out, err } = await runCommand('devices supported'); + const { out, err } = await runCommand('device-type list'); const lines = cleanOutput(out, true); diff --git a/tests/commands/help.spec.ts b/tests/commands/help.spec.ts index 916f3a32..0b395232 100644 --- a/tests/commands/help.spec.ts +++ b/tests/commands/help.spec.ts @@ -64,7 +64,7 @@ ADDITIONAL COMMANDS device shutdown shutdown a device device ssh SSH into the host or application container of a device device tunnel tunnel local ports to your balenaOS device - devices supported list the supported device types (like 'raspberrypi3' or 'intel-nuc') + device-type list list the device types supported by balena (like 'raspberrypi3' or 'intel-nuc'). env set add or update env or config variable to application(s), device(s) or service(s) env list list the environment or config variables of an application, device or service env rename change the value of a config or env var for an app, device or service diff --git a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt index 417366c2..ea57acd5 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt @@ -141,7 +141,7 @@ %2: build/commands/device/tunnel.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/devices/supported.js + %2: build/commands/device-type/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/env/list.js diff --git a/tests/test-data/pkg/expected-warnings-darwin-x64.txt b/tests/test-data/pkg/expected-warnings-darwin-x64.txt index 4495b433..46e6bf32 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-x64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-x64.txt @@ -141,7 +141,7 @@ %2: build/commands/device/tunnel.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/devices/supported.js + %2: build/commands/device-type/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/env/list.js diff --git a/tests/test-data/pkg/expected-warnings-linux-arm64.txt b/tests/test-data/pkg/expected-warnings-linux-arm64.txt index 417366c2..ea57acd5 100644 --- a/tests/test-data/pkg/expected-warnings-linux-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-arm64.txt @@ -141,7 +141,7 @@ %2: build/commands/device/tunnel.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/devices/supported.js + %2: build/commands/device-type/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/env/list.js diff --git a/tests/test-data/pkg/expected-warnings-linux-x64.txt b/tests/test-data/pkg/expected-warnings-linux-x64.txt index 4495b433..46e6bf32 100644 --- a/tests/test-data/pkg/expected-warnings-linux-x64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-x64.txt @@ -141,7 +141,7 @@ %2: build/commands/device/tunnel.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/devices/supported.js + %2: build/commands/device-type/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/env/list.js diff --git a/tests/test-data/pkg/expected-warnings-win32-x64.txt b/tests/test-data/pkg/expected-warnings-win32-x64.txt index b0a258a3..1965f13a 100644 --- a/tests/test-data/pkg/expected-warnings-win32-x64.txt +++ b/tests/test-data/pkg/expected-warnings-win32-x64.txt @@ -141,7 +141,7 @@ %2: build\commands\device\tunnel.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json - %2: build\commands\devices\supported.js + %2: build\commands\device-type\list.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\env\list.js