diff --git a/INSTALL-ADVANCED.md b/INSTALL-ADVANCED.md index c828e37b..fc030993 100644 --- a/INSTALL-ADVANCED.md +++ b/INSTALL-ADVANCED.md @@ -145,7 +145,7 @@ container) in order to allow npm scripts like `postinstall` to be executed. ## Additional Dependencies -The `balena ssh`, `scan`, `build`, `deploy` and `preload` commands may require +The `balena ssh`, `device detect`, `build`, `deploy` and `preload` commands may require additional software to be installed. Check the Additional Dependencies sections for each operating system: diff --git a/INSTALL-LINUX.md b/INSTALL-LINUX.md index f544336d..ca0a4940 100644 --- a/INSTALL-LINUX.md +++ b/INSTALL-LINUX.md @@ -33,7 +33,7 @@ as described above. ## sudo configuration -A few CLI commands require execution through sudo, e.g. `sudo balena scan`. +A few CLI commands require execution through sudo, e.g. `sudo balena device detect`. If your Linux distribution has an `/etc/sudoers` file that defines a `secure_path` setting, run `sudo visudo` to edit it and add the balena CLI's installation folder to the ***pre-existing*** `secure_path` setting, for example: @@ -71,9 +71,9 @@ The `balena ssh` command also requires an SSH key to be added to your balena acc Access documentation](https://www.balena.io/docs/learn/manage/ssh-access/). The `balena key*` command set can also be used to list and manage SSH keys: see `balena help -v`. -### balena scan +### balena device detect -The `balena scan` command requires a multicast DNS (mDNS) service like +The `balena device detect` command requires a multicast DNS (mDNS) service like [Avahi](https://en.wikipedia.org/wiki/Avahi_(software)), which is installed by default on most desktop Linux distributions. Otherwise, on Debian or Ubuntu, the installation command would be `sudo apt-get install avahi-daemon`. diff --git a/INSTALL-WINDOWS.md b/INSTALL-WINDOWS.md index 0ff33c9a..d12a6496 100644 --- a/INSTALL-WINDOWS.md +++ b/INSTALL-WINDOWS.md @@ -19,7 +19,7 @@ Selected operating system: **Windows** - On the command prompt, type `balena version` and hit Enter. It should display the version of the balena CLI that you have installed. -No further steps are required to run most CLI commands. The `balena ssh`, `scan`, `build`, +No further steps are required to run most CLI commands. The `balena ssh`, `device detect`, `build`, `deploy` and `preload` commands may require additional software to be installed, as described below. @@ -48,9 +48,9 @@ The `balena ssh` command also requires an SSH key to be added to your balena acc Access documentation](https://www.balena.io/docs/learn/manage/ssh-access/). The `balena key*` command set can also be used to list and manage SSH keys: see `balena help -v`. -### balena scan +### balena device detect -The `balena scan` command requires a multicast DNS (mDNS) service like Apple's Bonjour. +The `balena device detect` command requires a multicast DNS (mDNS) service like Apple's Bonjour. Many Windows machines will already have this service installed, as it is bundled in popular applications such as Skype (Wikipedia lists [several others](https://en.wikipedia.org/wiki/Bonjour_(software))). Otherwise, Bonjour for Windows can be downloaded and installed from: https://support.apple.com/kb/DL999 diff --git a/automation/capitanodoc/capitanodoc.ts b/automation/capitanodoc/capitanodoc.ts index 1d0a9dd9..0e21bc66 100644 --- a/automation/capitanodoc/capitanodoc.ts +++ b/automation/capitanodoc/capitanodoc.ts @@ -62,7 +62,6 @@ const commandHeadings: { [key: string]: string } = { os: 'OS', util: 'Utilities', ssh: 'Network', - scan: 'Network', tunnel: 'Network', build: 'Deploy', join: 'Platform', diff --git a/completion/_balena b/completion/_balena index 547ef187..3dce4fd3 100644 --- a/completion/_balena +++ b/completion/_balena @@ -8,13 +8,13 @@ _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 logs notes organization os preload push release scan settings ssh ssh-key support tag tunnel util version whoami ) + main_commands=( api-key app block build config deploy device devices env fleet internal join leave local login logout logs notes organization os preload push release settings ssh ssh-key support tag tunnel 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_cmds=( deactivate identify init list local-mode move os-update pin public-url purge reboot register rename restart rm shutdown start-service stop-service track-fleet ) + device_cmds=( deactivate detect identify init list local-mode move os-update pin public-url purge reboot register rename restart rm shutdown start-service stop-service track-fleet ) devices_cmds=( supported ) env_cmds=( add list rename rm ) fleet_cmds=( create list pin purge rename restart rm track-latest ) diff --git a/completion/balena-completion.bash b/completion/balena-completion.bash index 4d831061..c0fca650 100644 --- a/completion/balena-completion.bash +++ b/completion/balena-completion.bash @@ -7,13 +7,13 @@ _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 logs notes organization os preload push release scan settings ssh ssh-key support tag tunnel util version whoami" + main_commands="api-key app block build config deploy device devices env fleet internal join leave local login logout logs notes organization os preload push release settings ssh ssh-key support tag tunnel 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_cmds="deactivate identify init list local-mode move os-update pin public-url purge reboot register rename restart rm shutdown start-service stop-service track-fleet" + device_cmds="deactivate detect identify init list local-mode move os-update pin public-url purge reboot register rename restart rm shutdown start-service stop-service track-fleet" devices_cmds="supported" env_cmds="add list rename rm" fleet_cmds="create list pin purge rename restart rm track-latest" diff --git a/docs/balena-cli.md b/docs/balena-cli.md index 638a9ed2..b1c738ae 100644 --- a/docs/balena-cli.md +++ b/docs/balena-cli.md @@ -196,6 +196,7 @@ are encouraged to regularly update the balena CLI to the latest version. - Devices - [device deactivate](#device-deactivate) + - [device detect](#device-detect) - [device identify](#device-identify) - [device](#device) - [device init](#device-init) @@ -247,7 +248,6 @@ are encouraged to regularly update the balena CLI to the latest version. - Network - - [scan](#scan) - [ssh](#ssh) - [tunnel](#tunnel) @@ -1257,6 +1257,44 @@ the UUID of the device to be deactivated answer "yes" to all questions (non interactive use) +## device detect + +### Aliases + +- `scan` + + +To use one of the aliases, replace `device detect` with the alias. + +### Description + +Scan for balenaOS devices on your local network. + +The output includes device information collected through balenaEngine for +devices running a development image of balenaOS. Devices running a production +image do not expose balenaEngine (on TCP port 2375), which is why less +information is printed about them. + +Examples: + + $ balena device detect + $ balena device detect --timeout 120 + $ balena device detect --verbose + +### Options + +#### -v, --verbose + +display full info + +#### -t, --timeout TIMEOUT + +scan timeout in seconds + +#### -j, --json + +produce JSON output instead of tabular output + ## device identify ### Description @@ -2595,37 +2633,6 @@ Only show system logs. This can be used in combination with --service. # Network -## scan - -### Description - -Scan for balenaOS devices on your local network. - -The output includes device information collected through balenaEngine for -devices running a development image of balenaOS. Devices running a production -image do not expose balenaEngine (on TCP port 2375), which is why less -information is printed about them. - -Examples: - - $ balena scan - $ balena scan --timeout 120 - $ balena scan --verbose - -### Options - -#### -v, --verbose - -display full info - -#### -t, --timeout TIMEOUT - -scan timeout in seconds - -#### -j, --json - -produce JSON output instead of tabular output - ## ssh ### Description diff --git a/src/commands/device/detect.ts b/src/commands/device/detect.ts index ec170e3c..0361d461 100644 --- a/src/commands/device/detect.ts +++ b/src/commands/device/detect.ts @@ -19,7 +19,9 @@ import { Flags, Command } from '@oclif/core'; import * as cf from '../../utils/common-flags'; import { getCliUx, stripIndent } from '../../utils/lazy'; -export default class ScanCmd extends Command { +export default class DeviceDetectCmd extends Command { + public static aliases = ['scan']; + public static description = stripIndent` Scan for balenaOS devices on your local network. @@ -32,9 +34,9 @@ export default class ScanCmd extends Command { `; public static examples = [ - '$ balena scan', - '$ balena scan --timeout 120', - '$ balena scan --verbose', + '$ balena device detect', + '$ balena device detect --timeout 120', + '$ balena device detect --verbose', ]; public static flags = { @@ -70,7 +72,7 @@ export default class ScanCmd extends Command { const dockerPort = 2375; const dockerTimeout = 2000; - const { flags: options } = await this.parse(ScanCmd); + const { flags: options } = await this.parse(DeviceDetectCmd); const discoverTimeout = options.timeout != null ? options.timeout * 1000 : undefined; @@ -144,10 +146,10 @@ export default class ScanCmd extends Command { if (!options.verbose) { devicesInfo.forEach((d: any) => { d.dockerInfo = _.isObject(d.dockerInfo) - ? _.pick(d.dockerInfo, ScanCmd.dockerInfoProperties) + ? _.pick(d.dockerInfo, DeviceDetectCmd.dockerInfoProperties) : d.dockerInfo; d.dockerVersion = _.isObject(d.dockerVersion) - ? _.pick(d.dockerVersion, ScanCmd.dockerVersionProperties) + ? _.pick(d.dockerVersion, DeviceDetectCmd.dockerVersionProperties) : d.dockerVersion; }); } @@ -164,8 +166,9 @@ export default class ScanCmd extends Command { if (!options.json && cmdOutput.length === 0) { console.error( process.platform === 'win32' - ? ScanCmd.noDevicesFoundMessage + ScanCmd.windowsTipMessage - : ScanCmd.noDevicesFoundMessage, + ? DeviceDetectCmd.noDevicesFoundMessage + + DeviceDetectCmd.windowsTipMessage + : DeviceDetectCmd.noDevicesFoundMessage, ); return; } @@ -197,11 +200,11 @@ export default class ScanCmd extends Command { protected static windowsTipMessage = ` Note for Windows users: - The 'scan' command relies on the Bonjour service. Check whether Bonjour is + The 'device detect' command relies on the Bonjour service. Check whether Bonjour is installed (Control Panel > Programs and Features). If not, you can download Bonjour for Windows (included with Bonjour Print Services) from here: https://support.apple.com/kb/DL999 - After installing Bonjour, restart your PC and run the 'balena scan' command + After installing Bonjour, restart your PC and run the 'balena device detect' command again.`; } diff --git a/src/help.ts b/src/help.ts index 939d7f83..39c38771 100644 --- a/src/help.ts +++ b/src/help.ts @@ -237,6 +237,5 @@ See: https://git.io/JRHUW#deprecation-policy`, 'deploy', 'join', 'leave', - 'scan', ]; } diff --git a/tests/commands/help.spec.ts b/tests/commands/help.spec.ts index 48385e3d..c8654e7f 100644 --- a/tests/commands/help.spec.ts +++ b/tests/commands/help.spec.ts @@ -30,7 +30,6 @@ PRIMARY COMMANDS push start a remote build on the balenaCloud build servers or a local mode device logs show device logs ssh [service] SSH into the host or application container of a device - apps list all applications app display information about a single application device show info about a single device tunnel tunnel local ports to your balenaOS device @@ -39,7 +38,6 @@ PRIMARY COMMANDS deploy [image] deploy a single image or a multicontainer project to a balena application join [deviceIpOrHostname] move a local device to an application on another balena server leave [deviceIpOrHostname] remove a local device from its balena application - scan scan for balenaOS devices on your local network `; @@ -54,6 +52,7 @@ ADDITIONAL COMMANDS config read read the configuration of a device or OS image config reconfigure interactively reconfigure a device or OS image config write write a key-value pair to configuration of a device or OS image + device detect scan for balenaOS devices on your local network device identify identify a device device init initialise a device with balenaOS device list list all devices diff --git a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt index 366238b5..10cdbde5 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt @@ -67,6 +67,9 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/deactivate.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/device/detect.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/identify.js @@ -232,9 +235,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/release/validate.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/scan/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/settings/index.js diff --git a/tests/test-data/pkg/expected-warnings-darwin-x64.txt b/tests/test-data/pkg/expected-warnings-darwin-x64.txt index b13ae112..62f7814c 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-x64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-x64.txt @@ -67,6 +67,9 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/deactivate.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/device/detect.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/identify.js @@ -232,9 +235,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/release/validate.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/scan/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/settings/index.js diff --git a/tests/test-data/pkg/expected-warnings-linux-arm64.txt b/tests/test-data/pkg/expected-warnings-linux-arm64.txt index 366238b5..10cdbde5 100644 --- a/tests/test-data/pkg/expected-warnings-linux-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-arm64.txt @@ -67,6 +67,9 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/deactivate.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/device/detect.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/identify.js @@ -232,9 +235,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/release/validate.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/scan/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/settings/index.js diff --git a/tests/test-data/pkg/expected-warnings-linux-x64.txt b/tests/test-data/pkg/expected-warnings-linux-x64.txt index b13ae112..62f7814c 100644 --- a/tests/test-data/pkg/expected-warnings-linux-x64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-x64.txt @@ -67,6 +67,9 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/deactivate.js +> Warning Entry 'main' not found in %1 + %1: node_modules/@oclif/core/package.json + %2: build/commands/device/detect.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/device/identify.js @@ -232,9 +235,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/release/validate.js -> Warning Entry 'main' not found in %1 - %1: node_modules/@oclif/core/package.json - %2: build/commands/scan/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/settings/index.js diff --git a/tests/test-data/pkg/expected-warnings-win32-x64.txt b/tests/test-data/pkg/expected-warnings-win32-x64.txt index 10bca710..4eae0f76 100644 --- a/tests/test-data/pkg/expected-warnings-win32-x64.txt +++ b/tests/test-data/pkg/expected-warnings-win32-x64.txt @@ -67,6 +67,9 @@ > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\device\deactivate.js +> Warning Entry 'main' not found in %1 + %1: node_modules\@oclif\core\package.json + %2: build\commands\device\detect.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\device\identify.js @@ -232,9 +235,6 @@ > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\release\validate.js -> Warning Entry 'main' not found in %1 - %1: node_modules\@oclif\core\package.json - %2: build\commands\scan\index.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\settings\index.js