From 1a1861bfcb68bce75ee9659b4c75a8a6ac36e8ff Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Thu, 16 May 2019 08:53:24 +0100 Subject: [PATCH] Remove or move most local namespaced commands Change-type: major Signed-off-by: Cameron Diver --- automation/capitanodoc/capitanodoc.ts | 4 - doc/cli.markdown | 328 +------------------------- lib/actions/{local => }/flash.ts | 10 +- lib/actions/index.coffee | 3 +- lib/actions/local/index.coffee | 6 - lib/actions/{local => }/scan.coffee | 14 +- lib/actions/ssh.ts | 1 + lib/actions/sync.ts | 44 ---- lib/app-capitano.coffee | 11 +- 9 files changed, 19 insertions(+), 402 deletions(-) rename lib/actions/{local => }/flash.ts (90%) rename lib/actions/{local => }/scan.coffee (90%) delete mode 100644 lib/actions/sync.ts diff --git a/automation/capitanodoc/capitanodoc.ts b/automation/capitanodoc/capitanodoc.ts index b599a9fc..c98b66d7 100644 --- a/automation/capitanodoc/capitanodoc.ts +++ b/automation/capitanodoc/capitanodoc.ts @@ -73,10 +73,6 @@ const capitanoDoc = { title: 'Logs', files: ['build/actions/logs.js'], }, - { - title: 'Sync', - files: ['build/actions/sync.js'], - }, { title: 'SSH', files: ['build/actions/ssh.js', 'build/actions/tunnel.js'], diff --git a/doc/cli.markdown b/doc/cli.markdown index cc616a6e..2254e86f 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -138,10 +138,6 @@ If you come across any problems or would like to get in touch: - [logs <uuidOrDevice>](#logs-uuidordevice) -- Sync - - - [sync [uuid]](#sync-uuid) - - SSH - [ssh <applicationOrDevice> [serviceName]](#ssh-applicationordevice-servicename) @@ -182,12 +178,6 @@ If you come across any problems or would like to get in touch: - Local - [local configure <target>](#local-configure-target) - - [local flash <image>](#local-flash-image) - - [local logs [deviceIp]](#local-logs-deviceip) - - [local scan](#local-scan) - - [local ssh [deviceIp]](#local-ssh-deviceip) - - [local push [deviceIp]](#local-push-deviceip) - - [local stop [deviceIp]](#local-stop-deviceip) - Deploy @@ -893,93 +883,6 @@ Only show logs for a single service. This can be used in combination with --syst Only show system logs. This can be used in combination with --service. -# Sync - -## sync [uuid] - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Deprecation notice: please note that `balena sync` is deprecated and will -be removed in a future release of the CLI. We are working on an exciting -replacement that will be released soon! -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Warning: 'balena sync' requires an openssh-compatible client and 'rsync' to -be correctly installed in your shell environment. For more information (including -Windows support) please check the README here: https://github.com/balena-io/balena-cli - -Use this command to sync your local changes to a certain device on the fly. - -After every 'balena sync' the updated settings will be saved in -'/.balena-sync.yml' and will be used in later invocations. You can -also change any option by editing '.balena-sync.yml' directly. - -Here is an example '.balena-sync.yml' : - - $ cat $PWD/.balena-sync.yml - uuid: 7cf02a6 - destination: '/usr/src/app' - before: 'echo Hello' - after: 'echo Done' - ignore: - - .git - - node_modules/ - -Command line options have precedence over the ones saved in '.balena-sync.yml'. - -If '.gitignore' is found in the source directory then all explicitly listed files will be -excluded from the syncing process. You can choose to change this default behavior with the -'--skip-gitignore' option. - -Examples: - - $ balena sync 7cf02a6 --source . --destination /usr/src/app - $ balena sync 7cf02a6 -s /home/user/myBalenaProject -d /usr/src/app --before 'echo Hello' --after 'echo Done' - $ balena sync --ignore lib/ - $ balena sync --verbose false - $ balena sync - -### Options - -#### --source, -s <path> - -local directory path to synchronize to device - -#### --destination, -d <path> - -destination path on device - -#### --ignore, -i <paths> - -comma delimited paths to ignore when syncing - -#### --skip-gitignore - -do not parse excluded/included files from .gitignore - -#### --skip-restart - -do not restart container after syncing - -#### --before, -b <command> - -execute a command before syncing - -#### --after, -a <command> - -execute a command after syncing - -#### --port, -t <port> - -ssh port - -#### --progress, -p - -show progress - -#### --verbose, -v - -increase verbosity - # SSH ## ssh <applicationOrDevice> [serviceName] @@ -1402,9 +1305,8 @@ id of the application to preload #### --commit, -c <hash> -The commit hash for a specific application release to preload, use "current" to specify the current -release (ignored if no appId is given). The current release is usually also the latest, but can be -manually pinned using https://github.com/balena-io-projects/staged-releases . +the commit hash for a specific application release to preload, use "latest" to specify the latest release +(ignored if no appId is given) #### --splash-image, -s <splashImage.png> @@ -1580,232 +1482,6 @@ Examples: $ balena local configure /dev/sdc $ balena local configure path/to/image.img -## local flash <image> - -Use this command to flash a balenaOS image to a drive. - -Examples: - - $ balena local flash path/to/balenaos.img[.zip|.gz|.bz2|.xz] - $ balena local flash path/to/balenaos.img --drive /dev/disk2 - $ balena local flash path/to/balenaos.img --drive /dev/disk2 --yes - -### Options - -#### --yes, -y - -confirm non-interactively - -#### --drive, -d <drive> - -drive - -## local logs [deviceIp] - - -Examples: - - $ balena local logs - $ balena local logs -f - $ balena local logs 192.168.1.10 - $ balena local logs 192.168.1.10 -f - $ balena local logs 192.168.1.10 -f --app-name myapp - -### Options - -#### --follow, -f - -follow log - -#### --app-name, -a <name> - -name of container to get logs from - -## local scan - - -Examples: - - $ balena local scan - $ balena local scan --timeout 120 - $ balena local scan --verbose - -### Options - -#### --verbose, -v - -Display full info - -#### --timeout, -t <timeout> - -Scan timeout in seconds - -## local ssh [deviceIp] - -Warning: 'balena local ssh' requires an openssh-compatible client to be correctly -installed in your shell environment. For more information (including Windows -support) please check the README here: https://github.com/balena-io/balena-cli - -Use this command to get a shell into the running application container of -your device. - -The '--host' option will get you a shell into the Host OS of the balenaOS device. -No option will return a list of containers to enter or you can explicitly select -one by passing its name to the --container option - -Examples: - - $ balena local ssh - $ balena local ssh --host - $ balena local ssh --container chaotic_water - $ balena local ssh --container chaotic_water --port 22222 - $ balena local ssh --verbose - -### Options - -#### --verbose, -v - -increase verbosity - -#### --host, -s - -get a shell into the host OS - -#### --container, -c <container> - -name of container to access - -#### --port, -p <port> - -ssh port number (default: 22222) - -## local push [deviceIp] - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Deprecation notice: `balena local push` is deprecated and will be removed in a -future release of the CLI. Please use `balena push ` instead. -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Use this command to push your local changes to a container on a LAN-accessible -balenaOS device on the fly. - -This command requires an openssh-compatible 'ssh' client and 'rsync' to be -available in the executable PATH of the shell environment. For more information -(including Windows support) please check the README at: -https://github.com/balena-io/balena-cli - -If `Dockerfile` or any file in the 'build-triggers' list is changed, -a new container will be built and run on your device. -If not, changes will simply be synced with `rsync` into the application container. - -After every 'balena local push' the updated settings will be saved in -'/.balena-sync.yml' and will be used in later invocations. You can -also change any option by editing '.balena-sync.yml' directly. - -Here is an example '.balena-sync.yml' : - - $ cat $PWD/.balena-sync.yml - local_balenaos: - app-name: local-app - build-triggers: - - Dockerfile: file-hash-abcdefabcdefabcdefabcdefabcdefabcdef - - package.json: file-hash-abcdefabcdefabcdefabcdefabcdefabcdef - environment: - - MY_VARIABLE=123 - - -Command line options have precedence over the ones saved in '.balena-sync.yml'. - -If '.gitignore' is found in the source directory then all explicitly listed files will be -excluded when using rsync to update the container. You can choose to change this default behavior with the -'--skip-gitignore' option. - -Examples: - - $ balena local push - $ balena local push --app-name test-server --build-triggers package.json,requirements.txt - $ balena local push --force-build - $ balena local push --force-build --skip-logs - $ balena local push --ignore lib/ - $ balena local push --verbose false - $ balena local push 192.168.2.10 --source . --destination /usr/src/app - $ balena local push 192.168.2.10 -s /home/user/balenaProject -d /usr/src/app --before 'echo Hello' --after 'echo Done' - -### Options - -#### --source, -s <path> - -root of project directory to push - -#### --destination, -d <path> - -destination path on device container - -#### --ignore, -i <paths> - -comma delimited paths to ignore when syncing with 'rsync' - -#### --skip-gitignore - -do not parse excluded/included files from .gitignore - -#### --before, -b <command> - -execute a command before pushing - -#### --after, -a <command> - -execute a command after pushing - -#### --progress, -p - -show progress - -#### --skip-logs - -do not stream logs after push - -#### --verbose, -v - -increase verbosity - -#### --app-name, -n <name> - -application name - may contain lowercase characters, digits and one or more dashes. It may not start or end with a dash. - -#### --build-triggers, -r <files> - -comma delimited file list that will trigger a container rebuild if changed - -#### --force-build, -f - -force a container build and run - -#### --env, -e <env> - -environment variable (e.g. --env 'ENV=value'). Multiple --env parameters are supported. - -## local stop [deviceIp] - - -Examples: - - $ balena local stop - $ balena local stop --app-name myapp - $ balena local stop --all - $ balena local stop 192.168.1.10 - $ balena local stop 192.168.1.10 --app-name myapp - -### Options - -#### --all - -stop all containers - -#### --app-name, -a <name> - -name of container to stop - # Deploy ## build [source] diff --git a/lib/actions/local/flash.ts b/lib/actions/flash.ts similarity index 90% rename from lib/actions/local/flash.ts rename to lib/actions/flash.ts index b11c406b..2bbced85 100644 --- a/lib/actions/local/flash.ts +++ b/lib/actions/flash.ts @@ -35,7 +35,7 @@ async function getDrive(options: { } drive = d; } else { - const { DriveList } = await import('../../utils/visuals/drive-list'); + const { DriveList } = await import('../utils/visuals/drive-list'); const driveList = new DriveList(scanner); drive = await driveList.run(); } @@ -47,16 +47,16 @@ export const flash: CommandDefinition< { image: string }, { drive: string; yes: boolean } > = { - signature: 'local flash ', + signature: 'flash ', description: 'Flash an image to a drive', help: stripIndent` Use this command to flash a balenaOS image to a drive. Examples: - $ balena local flash path/to/balenaos.img[.zip|.gz|.bz2|.xz] - $ balena local flash path/to/balenaos.img --drive /dev/disk2 - $ balena local flash path/to/balenaos.img --drive /dev/disk2 --yes + $ balena flash path/to/balenaos.img[.zip|.gz|.bz2|.xz] + $ balena flash path/to/balenaos.img --drive /dev/disk2 + $ balena flash path/to/balenaos.img --drive /dev/disk2 --yes `, options: [ { diff --git a/lib/actions/index.coffee b/lib/actions/index.coffee index 7ccad6ca..f16e27eb 100644 --- a/lib/actions/index.coffee +++ b/lib/actions/index.coffee @@ -25,12 +25,13 @@ module.exports = keys: require('./keys') logs: require('./logs') local: require('./local') + scan: require('./scan') + flash: require('./flash').flash notes: require('./notes') help: require('./help') os: require('./os') settings: require('./settings') config: require('./config') - sync: require('./sync') ssh: require('./ssh') internal: require('./internal') build: require('./build') diff --git a/lib/actions/local/index.coffee b/lib/actions/local/index.coffee index 9557997e..eb6484b2 100644 --- a/lib/actions/local/index.coffee +++ b/lib/actions/local/index.coffee @@ -15,9 +15,3 @@ limitations under the License. ### exports.configure = require('./configure') -exports.flash = require('./flash').flash -exports.logs = require('./logs') -exports.scan = require('./scan') -exports.ssh = require('./ssh') -exports.push = require('./push') -exports.stop = require('./stop') diff --git a/lib/actions/local/scan.coffee b/lib/actions/scan.coffee similarity index 90% rename from lib/actions/local/scan.coffee rename to lib/actions/scan.coffee index 999df1b3..9254335a 100644 --- a/lib/actions/local/scan.coffee +++ b/lib/actions/scan.coffee @@ -33,15 +33,15 @@ dockerVersionProperties = [ ] module.exports = - signature: 'local scan' + signature: 'scan' description: 'Scan for balenaOS devices in your local network' help: ''' Examples: - $ balena local scan - $ balena local scan --timeout 120 - $ balena local scan --verbose + $ balena scan + $ balena scan --timeout 120 + $ balena scan --verbose ''' options: [ signature: 'verbose' @@ -62,9 +62,9 @@ module.exports = prettyjson = require('prettyjson') { discover } = require('balena-sync') { SpinnerPromise } = require('resin-cli-visuals') - { dockerPort, dockerTimeout } = require('./common') - dockerUtils = require('../../utils/docker') - { exitWithExpectedError } = require('../../utils/patterns') + { dockerPort, dockerTimeout } = require('./local/common') + dockerUtils = require('../utils/docker') + { exitWithExpectedError } = require('../utils/patterns') if options.timeout? options.timeout *= 1000 diff --git a/lib/actions/ssh.ts b/lib/actions/ssh.ts index 43dda4ef..709428cf 100644 --- a/lib/actions/ssh.ts +++ b/lib/actions/ssh.ts @@ -249,6 +249,7 @@ export const ssh: CommandDefinition< > = { signature: 'ssh [serviceName]', description: 'SSH into the host or application container of a device', + primary: true, help: stripIndent` This command can be used to start a shell on a local or remote device. diff --git a/lib/actions/sync.ts b/lib/actions/sync.ts deleted file mode 100644 index d646480c..00000000 --- a/lib/actions/sync.ts +++ /dev/null @@ -1,44 +0,0 @@ -/* -Copyright 2016-2019 Balena - -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. -*/ - -import * as BalenaSync from 'balena-sync'; -import { CommandDefinition } from 'capitano'; -import { stripIndent } from 'common-tags'; - -export = deprecateSyncCmd(BalenaSync.capitano('balena-cli')); - -const deprecationMsg = stripIndent`\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Deprecation notice: please note that \`balena sync\` is deprecated and will - be removed in a future release of the CLI. We are working on an exciting - replacement that will be released soon! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`; - -function deprecateSyncCmd(syncCmd: CommandDefinition): CommandDefinition { - syncCmd.primary = false; - syncCmd.description = syncCmd.description.replace( - '(beta)', - '[deprecated: see "help sync"]', - ); - syncCmd.help = deprecationMsg + '\n\n' + syncCmd.help; - const originalAction = syncCmd.action; - syncCmd.action = (params, options, done): void => { - console.log(deprecationMsg); - originalAction(params, options, done); - }; - return syncCmd; -} diff --git a/lib/app-capitano.coffee b/lib/app-capitano.coffee index c5e9d253..d9848934 100644 --- a/lib/app-capitano.coffee +++ b/lib/app-capitano.coffee @@ -111,9 +111,6 @@ capitano.command(actions.settings.list) # ---------- Logs Module ---------- capitano.command(actions.logs.logs) -# ---------- Sync Module ---------- -capitano.command(actions.sync) - # ---------- Tunnel Module ---------- capitano.command(actions.tunnel.tunnel) @@ -125,12 +122,8 @@ capitano.command(actions.ssh.ssh) # ---------- Local balenaOS Module ---------- capitano.command(actions.local.configure) -capitano.command(actions.local.flash) -capitano.command(actions.local.logs) -capitano.command(actions.local.push) -capitano.command(actions.local.ssh) -capitano.command(actions.local.scan) -capitano.command(actions.local.stop) +capitano.command(actions.flash) +capitano.command(actions.scan) # ---------- Public utils ---------- capitano.command(actions.util.availableDrives)