From 30698c62e34c2cd398d9479bf56020c3c2c7e22a Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Tue, 2 Apr 2019 18:01:28 +0100 Subject: [PATCH] Remove 'quickstart' command and deprecate 'local push'. Change-type: major Signed-off-by: Paulo Castro --- capitanodoc.ts | 4 -- doc/cli.markdown | 45 +++++++++------------ lib/actions/help.coffee | 4 +- lib/actions/index.coffee | 1 - lib/actions/local/push.coffee | 30 ++++++++++---- lib/actions/os.coffee | 2 +- lib/actions/preload.coffee | 2 +- lib/actions/push.ts | 1 + lib/actions/ssh.coffee | 2 +- lib/actions/sync.ts | 30 +++++++++++++- lib/actions/wizard.coffee | 74 ----------------------------------- lib/app.coffee | 3 -- lib/utils/messages.ts | 14 ++++--- package.json | 2 +- 14 files changed, 84 insertions(+), 130 deletions(-) delete mode 100644 lib/actions/wizard.coffee diff --git a/capitanodoc.ts b/capitanodoc.ts index 6a9037af..48370600 100644 --- a/capitanodoc.ts +++ b/capitanodoc.ts @@ -152,10 +152,6 @@ environment variable (in the same standard URL format).\ title: 'Settings', files: ['build/actions/settings.js'], }, - { - title: 'Wizard', - files: ['build/actions/wizard.js'], - }, { title: 'Local', files: ['build/actions/local/index.js'], diff --git a/doc/cli.markdown b/doc/cli.markdown index 09efba6e..5a5d06d8 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -188,10 +188,6 @@ environment variable (in the same standard URL format). - [settings](#settings) -- Wizard - - - [quickstart [name]](#quickstart-name) - - Local - [local configure <target>](#local-configure-target) @@ -880,6 +876,12 @@ continuously stream output ## 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 +"live push" alternative: https://github.com/balena-io-modules/livepush +------------------------------------------------------------------------- + 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 @@ -1098,7 +1100,7 @@ Note that device api keys are only supported on balenaOS 2.0.3+. This command still supports the *deprecated* format where the UUID and optionally device key are passed directly on the command line, but the recommended way is to pass either an --app or ---device argument. The deprecated format will be remove in a future release. +--device argument. The deprecated format will be removed in a future release. In case that you want to configure an image for an application with mixed device types, you can pass the --device-type argument along with --app to specify the target device type. @@ -1453,24 +1455,6 @@ Examples: $ balena settings -# Wizard - -## quickstart [name] - -Use this command to run a friendly wizard to get started with balena. - -The wizard will guide you through: - - - Create an application. - - Initialise an SDCard with the balena operating system. - - Associate an existing project directory with your balena application. - - Push your project to your devices. - -Examples: - - $ balena quickstart - $ balena quickstart MyApp - # Local ## local configure <target> @@ -1583,11 +1567,18 @@ ssh port number (default: 22222) ## local push [deviceIp] -Warning: 'balena local push' 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 +------------------------------------------------------------------------------ +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. +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. diff --git a/lib/actions/help.coffee b/lib/actions/help.coffee index 5987a00c..adb5e57d 100644 --- a/lib/actions/help.coffee +++ b/lib/actions/help.coffee @@ -21,7 +21,7 @@ messages = require('../utils/messages') { exitWithExpectedError } = require('../utils/patterns') parse = (object) -> - return _.fromPairs _.map object, (item) -> + return _.fromPairs _.map(object, (item) -> # Hacky way to determine if an object is # a function or a command @@ -33,7 +33,7 @@ parse = (object) -> return [ signature item.description - ] + ]).sort() indent = (text) -> text = _.map text.split('\n'), (line) -> diff --git a/lib/actions/index.coffee b/lib/actions/index.coffee index 53f83eaa..7ccad6ca 100644 --- a/lib/actions/index.coffee +++ b/lib/actions/index.coffee @@ -15,7 +15,6 @@ limitations under the License. ### module.exports = - wizard: require('./wizard') apiKey: require('./api-key') app: require('./app') auth: require('./auth') diff --git a/lib/actions/local/push.coffee b/lib/actions/local/push.coffee index be50c395..65ce49fb 100644 --- a/lib/actions/local/push.coffee +++ b/lib/actions/local/push.coffee @@ -21,16 +21,27 @@ limitations under the License. _ = require('lodash') balenaPush = require('balena-sync').capitano('balena-toolbox') +originalAction = balenaPush.action # TODO: This is a temporary workaround to reuse the existing `rdt push` # capitano frontend in `balena local push`. -balenaPushHelp = ''' - Warning: 'balena local push' 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 +deprecationMsg = ''' + ------------------------------------------------------------------------------ + 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. +''' + +balenaPushHelp = """#{deprecationMsg} + 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. @@ -68,11 +79,16 @@ balenaPushHelp = ''' $ 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' -''' +""" + module.exports = _.assign balenaPush, signature: 'local push [deviceIp]' + description: '[deprecated: use "balena push ipAddress"] ' + balenaPush.description help: balenaPushHelp - primary: true + primary: false root: true + action: (params, options, done) -> + console.log deprecationMsg + originalAction(params, options, done) diff --git a/lib/actions/os.coffee b/lib/actions/os.coffee index 4a0df4f2..2045269f 100644 --- a/lib/actions/os.coffee +++ b/lib/actions/os.coffee @@ -217,7 +217,7 @@ exports.configure = This command still supports the *deprecated* format where the UUID and optionally device key are passed directly on the command line, but the recommended way is to pass either an --app or - --device argument. The deprecated format will be remove in a future release. + --device argument. The deprecated format will be removed in a future release. In case that you want to configure an image for an application with mixed device types, you can pass the --device-type argument along with --app to specify the target device type. diff --git a/lib/actions/preload.coffee b/lib/actions/preload.coffee index 5fb63129..eb13a379 100644 --- a/lib/actions/preload.coffee +++ b/lib/actions/preload.coffee @@ -132,7 +132,7 @@ offerToDisableAutomaticUpdates = (application, commit, pinDevice) -> module.exports = signature: 'preload ' - description: '(beta) preload an app on a disk image (or Edison zip archive)' + description: 'preload an app on a disk image (or Edison zip archive)' help: ''' Warning: "balena preload" requires Docker to be correctly installed in your shell environment. For more information (including Windows support) diff --git a/lib/actions/push.ts b/lib/actions/push.ts index f4787643..a8806bc1 100644 --- a/lib/actions/push.ts +++ b/lib/actions/push.ts @@ -110,6 +110,7 @@ export const push: CommandDefinition< } > = { signature: 'push ', + primary: true, description: 'Start a remote build on the balena cloud build servers or a local mode device', help: stripIndent` diff --git a/lib/actions/ssh.coffee b/lib/actions/ssh.coffee index 3ea802d4..5bb55f6a 100644 --- a/lib/actions/ssh.coffee +++ b/lib/actions/ssh.coffee @@ -19,7 +19,7 @@ commandOptions = require('./command-options') module.exports = signature: 'ssh [uuid]' - description: '(beta) get a shell into the running app container of a device' + description: 'get a shell into the running app container of a device' help: ''' Warning: 'balena ssh' requires an openssh-compatible client to be correctly installed in your shell environment. For more information (including Windows diff --git a/lib/actions/sync.ts b/lib/actions/sync.ts index 23cb9306..cd7c7b4d 100644 --- a/lib/actions/sync.ts +++ b/lib/actions/sync.ts @@ -1,5 +1,5 @@ /* -Copyright 2016-2017 Balena +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. @@ -15,4 +15,30 @@ limitations under the License. */ import * as BalenaSync from 'balena-sync'; -export = BalenaSync.capitano('balena-cli'); +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 + "live push" alternative: https://github.com/balena-io-modules/livepush + ------------------------------------------------------------------------- +`; + +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/actions/wizard.coffee b/lib/actions/wizard.coffee deleted file mode 100644 index 2bf97ae5..00000000 --- a/lib/actions/wizard.coffee +++ /dev/null @@ -1,74 +0,0 @@ -### -Copyright 2016-2017 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. -### - -exports.wizard = - signature: 'quickstart [name]' - description: 'getting started with balena' - help: ''' - Use this command to run a friendly wizard to get started with balena. - - The wizard will guide you through: - - - Create an application. - - Initialise an SDCard with the balena operating system. - - Associate an existing project directory with your balena application. - - Push your project to your devices. - - Examples: - - $ balena quickstart - $ balena quickstart MyApp - ''' - primary: true - action: (params, options, done) -> - balena = require('balena-sdk').fromSharedOptions() - patterns = require('../utils/patterns') - { runCommand } = require('../utils/helpers') - - balena.auth.isLoggedIn().then (isLoggedIn) -> - return if isLoggedIn - console.info('Looks like you\'re not logged in yet!') - console.info("Let's go through a quick wizard to get you started.\n") - return runCommand('login') - .then -> - return if params.name? - patterns.selectOrCreateApplication().tap (applicationName) -> - balena.models.application.has(applicationName).then (hasApplication) -> - return applicationName if hasApplication - runCommand("app create #{applicationName}") - .then (applicationName) -> - params.name = applicationName - .then -> - return runCommand("device init --application #{params.name}") - .tap(patterns.awaitDevice) - .then (uuid) -> - return runCommand("device #{uuid}") - .then -> - return balena.models.application.get(params.name) - .then (application) -> - console.log """ - Your device is ready to start pushing some code! - - Check our official documentation for more information: - - http://balena.io/docs/#/pages/introduction/introduction.md - - Clone an example or go to an existing application directory and run: - - $ git remote add balena #{application.git_repository} - $ git push balena master - """ - .nodeify(done) diff --git a/lib/app.coffee b/lib/app.coffee index 72a78c31..62f4f596 100644 --- a/lib/app.coffee +++ b/lib/app.coffee @@ -103,9 +103,6 @@ capitano.command(actions.info.version) # ---------- Help Module ---------- capitano.command(actions.help.help) -# ---------- Wizard Module ---------- -capitano.command(actions.wizard.wizard) - # ---------- Api key module ---------- capitano.command(actions.apiKey.generate) diff --git a/lib/utils/messages.ts b/lib/utils/messages.ts index 82ba39d9..253a71c0 100644 --- a/lib/utils/messages.ts +++ b/lib/utils/messages.ts @@ -1,10 +1,11 @@ const DEBUG_MODE = !!process.env.DEBUG; export const reachingOut = `\ -If you need help, or just want to say hi, don't hesitate in reaching out at: +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 - Forums: https://forums.balena.io - GitHub: https://github.com/balena-io/balena-cli/issues/new\ +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/\ `; const debugHint = `\ @@ -13,10 +14,11 @@ line with DEBUG=1, i.e.: DEBUG=1 balena ... `; export const getHelp = `${DEBUG_MODE ? '' : debugHint}\ -If you need help, don't hesitate in contacting us at: +If you need help, don't hesitate in contacting our support forums at +https://forums.balena.io - Forums: https://forums.balena.io - GitHub: https://github.com/balena-io/balena-cli/issues/new\ +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/\ `; export const balenaAsciiArt = `\ diff --git a/package.json b/package.json index 83c7a87f..69b763e5 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "balena-preload": "^8.0.4", "balena-sdk": "^11.2.0", "balena-settings-client": "^4.0.0", - "balena-sync": "^10.0.2", + "balena-sync": "^10.0.3", "bash": "0.0.1", "bluebird": "^3.5.3", "body-parser": "^1.14.1",