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
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:

View File

@ -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`.

View File

@ -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

View File

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

View File

@ -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 )

View File

@ -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"

View File

@ -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

View File

@ -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.`;
}

View File

@ -237,6 +237,5 @@ See: https://git.io/JRHUW#deprecation-policy`,
'deploy',
'join',
'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
logs <device> show device logs
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
device <uuid> show info about a single 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
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 <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 init initialise a device with balenaOS
device list list all devices

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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