2020-07-09 14:39:33 +00:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright 2019-2020 Balena Ltd.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
import { expect } from 'chai';
|
2020-07-09 14:39:33 +00:00
|
|
|
|
|
|
|
import { BalenaAPIMock } from '../balena-api-mock';
|
2019-11-15 09:45:14 +00:00
|
|
|
import { cleanOutput, runCommand } from '../helpers';
|
2019-08-15 12:40:55 +00:00
|
|
|
|
|
|
|
const SIMPLE_HELP = `
|
|
|
|
Usage: balena [COMMAND] [OPTIONS]
|
|
|
|
|
|
|
|
Primary commands:
|
|
|
|
|
|
|
|
help [command...] show help
|
|
|
|
login login to balena
|
2020-07-24 12:25:46 +00:00
|
|
|
push <applicationordevice> start a remote build on the balena cloud build servers or a local mode device
|
2020-07-01 13:52:33 +00:00
|
|
|
logs <device> show device logs
|
2020-06-24 13:24:54 +00:00
|
|
|
ssh <applicationordevice> [servicename] SSH into the host or application container of a device
|
2019-08-15 12:40:55 +00:00
|
|
|
apps list all applications
|
2020-04-22 16:08:11 +00:00
|
|
|
app <name> display information about a single application
|
2019-08-15 12:40:55 +00:00
|
|
|
devices list all devices
|
2020-06-17 13:46:25 +00:00
|
|
|
device <uuid> show info about a single device
|
2020-06-29 12:45:32 +00:00
|
|
|
tunnel <deviceorapplication> tunnel local ports to your balenaOS device
|
2019-08-15 12:40:55 +00:00
|
|
|
preload <image> preload an app on a disk image (or Edison zip archive)
|
2020-07-30 08:39:05 +00:00
|
|
|
build [source] build a project locally
|
2020-08-21 08:57:14 +00:00
|
|
|
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
|
2020-03-13 11:32:29 +00:00
|
|
|
scan scan for balenaOS devices on your local network
|
2019-08-15 12:40:55 +00:00
|
|
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
const ADDITIONAL_HELP = `
|
|
|
|
Additional commands:
|
|
|
|
|
2020-04-22 11:47:12 +00:00
|
|
|
api-key generate <name> generate a new balenaCloud API key
|
2019-08-15 12:40:55 +00:00
|
|
|
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
|
2020-07-28 12:40:47 +00:00
|
|
|
config inject <file> inject a configuration file into 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 write <key> <value> write a key-value pair to configuration of a device or OS image
|
2020-06-17 13:46:25 +00:00
|
|
|
device identify <uuid> identify a device
|
2019-08-15 12:40:55 +00:00
|
|
|
device init initialise a device with balenaOS
|
2020-07-15 14:26:31 +00:00
|
|
|
device move <uuid(s)> move one or more devices to another application
|
2020-06-18 13:36:46 +00:00
|
|
|
device os-update <uuid> start a Host OS update for a device
|
2020-06-02 08:01:04 +00:00
|
|
|
device public-url <uuid> get or manage the public URL for a device
|
2019-08-15 12:40:55 +00:00
|
|
|
device reboot <uuid> restart a device
|
|
|
|
device register <application> register a device
|
2020-06-17 13:46:25 +00:00
|
|
|
device rename <uuid> [newname] rename a device
|
2020-07-17 12:14:45 +00:00
|
|
|
device rm <uuid(s)> remove one or more devices
|
2019-08-15 12:40:55 +00:00
|
|
|
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')
|
2020-08-21 10:43:12 +00:00
|
|
|
env add <name> [value] add env or config variable to application(s), device(s) or service(s)
|
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
|
2020-07-09 13:38:04 +00:00
|
|
|
local flash <image> flash an image to a drive
|
2019-08-15 12:40:55 +00:00
|
|
|
logout logout from balena
|
|
|
|
note <|note> set a device note
|
2020-07-16 10:15:06 +00:00
|
|
|
os build-config <image> <device-type> build an OS config and save it to a JSON file
|
2019-10-31 01:46:14 +00:00
|
|
|
os configure <image> configure a previously downloaded balenaOS image
|
2020-07-13 13:07:51 +00:00
|
|
|
os download <type> download an unconfigured OS image
|
2020-07-15 19:13:18 +00:00
|
|
|
os initialize <image> initialize an os image for a device
|
2020-07-14 13:23:45 +00:00
|
|
|
os versions <type> show available balenaOS versions for the given device type
|
2019-08-15 12:40:55 +00:00
|
|
|
settings print current settings
|
2020-05-26 09:17:30 +00:00
|
|
|
tag rm <tagkey> remove a tag from an application, device or release
|
|
|
|
tag set <tagkey> [value] set a tag on an application, device or release
|
|
|
|
tags list all tags for an application, device or release
|
2019-08-15 12:40:55 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
2020-05-01 12:38:53 +00:00
|
|
|
const LIST_ADDITIONAL = `
|
|
|
|
Run \`balena help --verbose\` to list additional commands
|
|
|
|
`;
|
|
|
|
|
2019-08-15 12:40:55 +00:00
|
|
|
const GLOBAL_OPTIONS = `
|
|
|
|
Global Options:
|
|
|
|
|
|
|
|
--help, -h
|
|
|
|
--version, -v
|
2020-05-01 12:38:53 +00:00
|
|
|
--debug
|
|
|
|
`;
|
|
|
|
|
|
|
|
const ONLINE_RESOURCES = `
|
|
|
|
For help, visit our support forums: https://forums.balena.io
|
|
|
|
For bug reports or feature requests, see: https://github.com/balena-io/balena-cli/issues/
|
2019-08-15 12:40:55 +00:00
|
|
|
`;
|
|
|
|
|
2020-06-15 22:53:07 +00:00
|
|
|
describe('balena help', function () {
|
2020-07-09 14:39:33 +00:00
|
|
|
let api: BalenaAPIMock;
|
|
|
|
|
|
|
|
this.beforeEach(() => {
|
|
|
|
api = new BalenaAPIMock();
|
|
|
|
api.expectGetMixpanel({ optional: true });
|
|
|
|
});
|
|
|
|
|
|
|
|
this.afterEach(() => {
|
|
|
|
// Check all expected api calls have been made and clean up.
|
|
|
|
api.done();
|
|
|
|
});
|
|
|
|
|
2020-03-13 11:32:29 +00:00
|
|
|
it('should list primary command summaries', async () => {
|
2019-08-15 12:40:55 +00:00
|
|
|
const { out, err } = await runCommand('help');
|
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(cleanOutput(out)).to.deep.equal(
|
|
|
|
cleanOutput([
|
|
|
|
SIMPLE_HELP,
|
2020-05-01 12:38:53 +00:00
|
|
|
LIST_ADDITIONAL,
|
2019-11-15 09:45:14 +00:00
|
|
|
GLOBAL_OPTIONS,
|
2020-05-01 12:38:53 +00:00
|
|
|
ONLINE_RESOURCES,
|
2019-11-15 09:45:14 +00:00
|
|
|
]),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(err.join('')).to.equal('');
|
2019-08-15 12:40:55 +00:00
|
|
|
});
|
|
|
|
|
2020-03-13 11:32:29 +00:00
|
|
|
it('should list all command summaries with the -v flag', async () => {
|
2019-08-15 12:40:55 +00:00
|
|
|
const { out, err } = await runCommand('help -v');
|
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(cleanOutput(out)).to.deep.equal(
|
2020-05-01 12:38:53 +00:00
|
|
|
cleanOutput([
|
|
|
|
SIMPLE_HELP,
|
|
|
|
ADDITIONAL_HELP,
|
|
|
|
GLOBAL_OPTIONS,
|
|
|
|
ONLINE_RESOURCES,
|
|
|
|
]),
|
2019-11-15 09:45:14 +00:00
|
|
|
);
|
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
|
|
|
|
2020-03-13 11:32:29 +00:00
|
|
|
it('should list primary command summaries', async () => {
|
2019-11-01 13:45:45 +00:00
|
|
|
const { out, err } = await runCommand('');
|
|
|
|
|
2019-11-15 09:45:14 +00:00
|
|
|
expect(cleanOutput(out)).to.deep.equal(
|
|
|
|
cleanOutput([
|
|
|
|
SIMPLE_HELP,
|
2020-05-01 12:38:53 +00:00
|
|
|
LIST_ADDITIONAL,
|
2019-11-15 09:45:14 +00:00
|
|
|
GLOBAL_OPTIONS,
|
2020-05-01 12:38:53 +00:00
|
|
|
ONLINE_RESOURCES,
|
2019-11-15 09:45:14 +00:00
|
|
|
]),
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(err.join('')).to.equal('');
|
2019-11-01 13:45:45 +00:00
|
|
|
});
|
2019-08-15 12:40:55 +00:00
|
|
|
});
|