Add alias device detect for scan

Change-type: minor
This commit is contained in:
myarmolinsky 2024-09-26 08:02:01 -04:00
parent 9082e7b3f7
commit ba5bb7b12c
15 changed files with 80 additions and 73 deletions

View File

@ -145,7 +145,7 @@ container) in order to allow npm scripts like `postinstall` to be executed.
## Additional Dependencies ## 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 additional software to be installed. Check the Additional Dependencies sections for each operating
system: system:

View File

@ -33,7 +33,7 @@ as described above.
## sudo configuration ## 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` 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 setting, run `sudo visudo` to edit it and add the balena CLI's installation folder to
the ***pre-existing*** `secure_path` setting, for example: 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*` 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`. 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 [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 desktop Linux distributions. Otherwise, on Debian or Ubuntu, the installation command would be
`sudo apt-get install avahi-daemon`. `sudo apt-get install avahi-daemon`.

View File

@ -19,7 +19,7 @@ Selected operating system: **Windows**
- On the command prompt, type `balena version` and hit Enter. It should display - On the command prompt, type `balena version` and hit Enter. It should display
the version of the balena CLI that you have installed. 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 `deploy` and `preload` commands may require additional software to be installed, as
described below. 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*` 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`. 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 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))). 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 Otherwise, Bonjour for Windows can be downloaded and installed from: https://support.apple.com/kb/DL999

View File

@ -62,7 +62,6 @@ const commandHeadings: { [key: string]: string } = {
os: 'OS', os: 'OS',
util: 'Utilities', util: 'Utilities',
ssh: 'Network', ssh: 'Network',
scan: 'Network',
tunnel: 'Network', tunnel: 'Network',
build: 'Deploy', build: 'Deploy',
join: 'Platform', join: 'Platform',

View File

@ -8,13 +8,13 @@ _balena() {
local context state line curcontext="$curcontext" local context state line curcontext="$curcontext"
# Valid top-level completions # 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 # Sub-completions
api_key_cmds=( generate list revoke ) api_key_cmds=( generate list revoke )
app_cmds=( create ) app_cmds=( create )
block_cmds=( create ) block_cmds=( create )
config_cmds=( generate inject read reconfigure write ) 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 ) devices_cmds=( supported )
env_cmds=( add list rename rm ) env_cmds=( add list rename rm )
fleet_cmds=( create list pin purge rename restart rm track-latest ) fleet_cmds=( create list pin purge rename restart rm track-latest )

View File

@ -7,13 +7,13 @@ _balena_complete()
local cur prev local cur prev
# Valid top-level completions # 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 # Sub-completions
api_key_cmds="generate list revoke" api_key_cmds="generate list revoke"
app_cmds="create" app_cmds="create"
block_cmds="create" block_cmds="create"
config_cmds="generate inject read reconfigure write" 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" devices_cmds="supported"
env_cmds="add list rename rm" env_cmds="add list rename rm"
fleet_cmds="create list pin purge rename restart rm track-latest" fleet_cmds="create list pin purge rename restart rm track-latest"

View File

@ -196,6 +196,7 @@ are encouraged to regularly update the balena CLI to the latest version.
- Devices - Devices
- [device deactivate](#device-deactivate) - [device deactivate](#device-deactivate)
- [device detect](#device-detect)
- [device identify](#device-identify) - [device identify](#device-identify)
- [device](#device) - [device](#device)
- [device init](#device-init) - [device init](#device-init)
@ -247,7 +248,6 @@ are encouraged to regularly update the balena CLI to the latest version.
- Network - Network
- [scan](#scan)
- [ssh](#ssh) - [ssh](#ssh)
- [tunnel](#tunnel) - [tunnel](#tunnel)
@ -1257,6 +1257,44 @@ the UUID of the device to be deactivated
answer "yes" to all questions (non interactive use) 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 ## device identify
### Description ### Description
@ -2595,37 +2633,6 @@ Only show system logs. This can be used in combination with --service.
# Network # 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 ## ssh
### Description ### Description

View File

@ -19,7 +19,9 @@ import { Flags, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags'; import * as cf from '../../utils/common-flags';
import { getCliUx, stripIndent } from '../../utils/lazy'; 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` public static description = stripIndent`
Scan for balenaOS devices on your local network. Scan for balenaOS devices on your local network.
@ -32,9 +34,9 @@ export default class ScanCmd extends Command {
`; `;
public static examples = [ public static examples = [
'$ balena scan', '$ balena device detect',
'$ balena scan --timeout 120', '$ balena device detect --timeout 120',
'$ balena scan --verbose', '$ balena device detect --verbose',
]; ];
public static flags = { public static flags = {
@ -70,7 +72,7 @@ export default class ScanCmd extends Command {
const dockerPort = 2375; const dockerPort = 2375;
const dockerTimeout = 2000; const dockerTimeout = 2000;
const { flags: options } = await this.parse(ScanCmd); const { flags: options } = await this.parse(DeviceDetectCmd);
const discoverTimeout = const discoverTimeout =
options.timeout != null ? options.timeout * 1000 : undefined; options.timeout != null ? options.timeout * 1000 : undefined;
@ -144,10 +146,10 @@ export default class ScanCmd extends Command {
if (!options.verbose) { if (!options.verbose) {
devicesInfo.forEach((d: any) => { devicesInfo.forEach((d: any) => {
d.dockerInfo = _.isObject(d.dockerInfo) d.dockerInfo = _.isObject(d.dockerInfo)
? _.pick(d.dockerInfo, ScanCmd.dockerInfoProperties) ? _.pick(d.dockerInfo, DeviceDetectCmd.dockerInfoProperties)
: d.dockerInfo; : d.dockerInfo;
d.dockerVersion = _.isObject(d.dockerVersion) d.dockerVersion = _.isObject(d.dockerVersion)
? _.pick(d.dockerVersion, ScanCmd.dockerVersionProperties) ? _.pick(d.dockerVersion, DeviceDetectCmd.dockerVersionProperties)
: d.dockerVersion; : d.dockerVersion;
}); });
} }
@ -164,8 +166,9 @@ export default class ScanCmd extends Command {
if (!options.json && cmdOutput.length === 0) { if (!options.json && cmdOutput.length === 0) {
console.error( console.error(
process.platform === 'win32' process.platform === 'win32'
? ScanCmd.noDevicesFoundMessage + ScanCmd.windowsTipMessage ? DeviceDetectCmd.noDevicesFoundMessage +
: ScanCmd.noDevicesFoundMessage, DeviceDetectCmd.windowsTipMessage
: DeviceDetectCmd.noDevicesFoundMessage,
); );
return; return;
} }
@ -197,11 +200,11 @@ export default class ScanCmd extends Command {
protected static windowsTipMessage = ` protected static windowsTipMessage = `
Note for Windows users: 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 installed (Control Panel > Programs and Features). If not, you can download
Bonjour for Windows (included with Bonjour Print Services) from here: Bonjour for Windows (included with Bonjour Print Services) from here:
https://support.apple.com/kb/DL999 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.`; again.`;
} }

View File

@ -237,6 +237,5 @@ See: https://git.io/JRHUW#deprecation-policy`,
'deploy', 'deploy',
'join', 'join',
'leave', 'leave',
'scan',
]; ];
} }

View File

@ -30,7 +30,6 @@ PRIMARY COMMANDS
push <applicationOrDevice> start a remote build on the balenaCloud build servers or a local mode device push <applicationOrDevice> start a remote build on the balenaCloud build servers or a local mode device
logs <device> show device logs logs <device> show device logs
ssh <applicationOrDevice> [service] SSH into the host or application container of a device ssh <applicationOrDevice> [service] SSH into the host or application container of a device
apps list all applications
app <name> display information about a single application app <name> display information about a single application
device <uuid> show info about a single device device <uuid> show info about a single device
tunnel <deviceOrApplication> tunnel local ports to your balenaOS device tunnel <deviceOrApplication> tunnel local ports to your balenaOS device
@ -39,7 +38,6 @@ PRIMARY COMMANDS
deploy <appName> [image] deploy a single image or a multicontainer project to a balena application deploy <appName> [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 join [deviceIpOrHostname] move a local device to an application on another balena server
leave [deviceIpOrHostname] remove a local device from its balena application 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 read read the configuration of a device or OS image
config reconfigure interactively reconfigure a device or OS image config reconfigure interactively reconfigure a device or OS image
config write <key> <value> write a key-value pair to configuration of a device or OS image config write <key> <value> 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 <uuid> identify a device device identify <uuid> identify a device
device init initialise a device with balenaOS device init initialise a device with balenaOS
device list list all devices device list list all devices

View File

@ -67,6 +67,9 @@
> Warning Entry 'main' not found in %1 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/device/deactivate.js %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 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/device/identify.js %2: build/commands/device/identify.js
@ -232,9 +235,6 @@
> Warning Entry 'main' not found in %1 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/release/validate.js %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 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/settings/index.js %2: build/commands/settings/index.js

View File

@ -67,6 +67,9 @@
> Warning Entry 'main' not found in %1 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/device/deactivate.js %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 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/device/identify.js %2: build/commands/device/identify.js
@ -232,9 +235,6 @@
> Warning Entry 'main' not found in %1 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/release/validate.js %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 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/settings/index.js %2: build/commands/settings/index.js

View File

@ -67,6 +67,9 @@
> Warning Entry 'main' not found in %1 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/device/deactivate.js %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 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/device/identify.js %2: build/commands/device/identify.js
@ -232,9 +235,6 @@
> Warning Entry 'main' not found in %1 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/release/validate.js %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 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/settings/index.js %2: build/commands/settings/index.js

View File

@ -67,6 +67,9 @@
> Warning Entry 'main' not found in %1 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/device/deactivate.js %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 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/device/identify.js %2: build/commands/device/identify.js
@ -232,9 +235,6 @@
> Warning Entry 'main' not found in %1 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/release/validate.js %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 > Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json %1: node_modules/@oclif/core/package.json
%2: build/commands/settings/index.js %2: build/commands/settings/index.js

View File

@ -67,6 +67,9 @@
> Warning Entry 'main' not found in %1 > Warning Entry 'main' not found in %1
%1: node_modules\@oclif\core\package.json %1: node_modules\@oclif\core\package.json
%2: build\commands\device\deactivate.js %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 > Warning Entry 'main' not found in %1
%1: node_modules\@oclif\core\package.json %1: node_modules\@oclif\core\package.json
%2: build\commands\device\identify.js %2: build\commands\device\identify.js
@ -232,9 +235,6 @@
> Warning Entry 'main' not found in %1 > Warning Entry 'main' not found in %1
%1: node_modules\@oclif\core\package.json %1: node_modules\@oclif\core\package.json
%2: build\commands\release\validate.js %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 > Warning Entry 'main' not found in %1
%1: node_modules\@oclif\core\package.json %1: node_modules\@oclif\core\package.json
%2: build\commands\settings\index.js %2: build\commands\settings\index.js