2019-11-15 09:45:14 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
import { cleanOutput, runCommand } from '../helpers';
|
2019-08-15 12:40:55 +00:00
|
|
|
|
|
|
|
const SIMPLE_HELP = `
|
|
|
|
Usage: balena [COMMAND] [OPTIONS]
|
|
|
|
|
|
|
|
If you need help, or just want to say hi, don't hesitate in reaching out
|
|
|
|
through our discussion and support forums at https://forums.balena.io
|
|
|
|
|
|
|
|
For bug reports or feature requests, have a look at the GitHub issues or
|
|
|
|
create a new one at: https://github.com/balena-io/balena-cli/issues/
|
|
|
|
|
|
|
|
Primary commands:
|
|
|
|
|
|
|
|
help [command...] show help
|
|
|
|
login login to balena
|
|
|
|
push <applicationOrDevice> Start a remote build on the balena cloud build servers or a local mode device
|
|
|
|
logs <uuidOrDevice> show device logs
|
|
|
|
ssh <applicationOrDevice> [serviceName] SSH into the host or application container of a device
|
|
|
|
apps list all applications
|
|
|
|
app <name> list a single application
|
|
|
|
devices list all devices
|
|
|
|
device <uuid> list a single device
|
|
|
|
tunnel <deviceOrApplication> Tunnel local ports to your balenaOS device
|
|
|
|
preload <image> preload an app on a disk image (or Edison zip archive)
|
|
|
|
build [source] Build a single image or a multicontainer project locally
|
|
|
|
deploy <appName> [image] Deploy a single image or a multicontainer project to a balena application
|
2020-04-09 14:34:24 +00:00
|
|
|
join [deviceiporhostname] move a local device to an application on another balena server
|
|
|
|
leave [deviceiporhostname] remove a local device from its balena application
|
2019-08-15 12:40:55 +00:00
|
|
|
scan Scan for balenaOS devices in your local network
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
const ADDITIONAL_HELP = `
|
|
|
|
Additional commands:
|
|
|
|
|
|
|
|
api-key generate <name> Generate a new API key with the given name
|
|
|
|
app create <name> create an application
|
|
|
|
app restart <name> restart an application
|
|
|
|
app rm <name> remove an application
|
|
|
|
config generate generate a config.json file
|
|
|
|
config inject <file> inject a device configuration file
|
|
|
|
config read read a device configuration
|
|
|
|
config reconfigure reconfigure a provisioned device
|
|
|
|
config write <key> <value> write a device configuration
|
|
|
|
device identify <uuid> identify a device with a UUID
|
|
|
|
device init initialise a device with balenaOS
|
|
|
|
device move <uuid> move a device to another application
|
|
|
|
device os-update <uuid> Start a Host OS update for a device
|
|
|
|
device public-url <uuid> gets the public URL of a device
|
|
|
|
device public-url disable <uuid> disable public URL for a device
|
|
|
|
device public-url enable <uuid> enable public URL for a device
|
|
|
|
device public-url status <uuid> Returns true if public URL is enabled for a device
|
|
|
|
device reboot <uuid> restart a device
|
|
|
|
device register <application> register a device
|
|
|
|
device rename <uuid> [newName] rename a balena device
|
|
|
|
device rm <uuid> remove a device
|
|
|
|
device shutdown <uuid> shutdown a device
|
2019-12-26 22:59:44 +00:00
|
|
|
devices supported list the supported device types (like 'raspberrypi3' or 'intel-nuc')
|
2019-12-10 00:07:16 +00:00
|
|
|
env add <name> [value] add an environment or config variable to an application, device or service
|
2019-12-11 17:47:54 +00:00
|
|
|
env rename <id> <value> change the value of a config or env var for an app, device or service
|
2019-12-11 00:43:55 +00:00
|
|
|
env rm <id> remove a config or env var from an application, device or service
|
2019-12-04 18:04:57 +00:00
|
|
|
envs list the environment or config variables of an application, device or service
|
2020-04-17 13:19:33 +00:00
|
|
|
key <id> display an SSH key
|
|
|
|
key add <name> [path] add an SSH key to balenaCloud
|
|
|
|
key rm <id> remove an SSH key from balenaCloud
|
|
|
|
keys list the SSH keys in balenaCloud
|
2019-08-15 12:40:55 +00:00
|
|
|
local configure <target> (Re)configure a balenaOS drive or image
|
|
|
|
local flash <image> Flash an image to a drive
|
|
|
|
logout logout from balena
|
|
|
|
note <|note> set a device note
|
|
|
|
os build-config <image> <device-type> build the OS config and save it to the JSON file
|
2019-10-31 01:46:14 +00:00
|
|
|
os configure <image> configure a previously downloaded balenaOS image
|
2019-08-15 12:40:55 +00:00
|
|
|
os download <type> download an unconfigured os image
|
|
|
|
os initialize <image> initialize an os image
|
|
|
|
os versions <type> show the available balenaOS versions for the given device type
|
|
|
|
settings print current settings
|
|
|
|
tag rm <tagKey> remove a resource tag
|
|
|
|
tag set <tagKey> [value] set a resource tag
|
|
|
|
tags list all resource tags
|
|
|
|
util available-drives list available drives
|
|
|
|
version display version information for the balena CLI and/or Node.js
|
|
|
|
whoami get current username and email address
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
const GLOBAL_OPTIONS = `
|
|
|
|
Global Options:
|
|
|
|
|
|
|
|
--help, -h
|
|
|
|
--version, -v
|
|
|
|
`;
|
|
|
|
|
|
|
|
describe('balena help', function() {
|
|
|
|
it('should print simple help text', async () => {
|
|
|
|
const { out, err } = await runCommand('help');
|
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(cleanOutput(out)).to.deep.equal(
|
|
|
|
cleanOutput([
|
|
|
|
SIMPLE_HELP,
|
|
|
|
'Run `balena help --verbose` to list additional commands',
|
|
|
|
GLOBAL_OPTIONS,
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(err.join('')).to.equal('');
|
2019-08-15 12:40:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should print additional commands with the -v flag', async () => {
|
|
|
|
const { out, err } = await runCommand('help -v');
|
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(cleanOutput(out)).to.deep.equal(
|
|
|
|
cleanOutput([SIMPLE_HELP, ADDITIONAL_HELP, GLOBAL_OPTIONS]),
|
|
|
|
);
|
2019-08-15 12:40:55 +00:00
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(err.join('')).to.equal('');
|
2019-08-15 12:40:55 +00:00
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(err.join('')).to.equal('');
|
2019-08-15 12:40:55 +00:00
|
|
|
});
|
2019-11-01 13:45:45 +00:00
|
|
|
|
|
|
|
it('should print simple help text when no arguments present', async () => {
|
|
|
|
const { out, err } = await runCommand('');
|
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(cleanOutput(out)).to.deep.equal(
|
|
|
|
cleanOutput([
|
|
|
|
SIMPLE_HELP,
|
|
|
|
'Run `balena help --verbose` to list additional commands',
|
|
|
|
GLOBAL_OPTIONS,
|
|
|
|
]),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(err.join('')).to.equal('');
|
2019-11-01 13:45:45 +00:00
|
|
|
});
|
2019-08-15 12:40:55 +00:00
|
|
|
});
|