mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-21 01:42:26 +00:00
resin sync/ssh: only accept uuid as destination
Also change --port option alias to '-p' from '-t'
This commit is contained in:
parent
7d606568f6
commit
af8d20ea3f
@ -36,7 +36,7 @@ getSubShellCommand = (command) ->
|
||||
}
|
||||
|
||||
module.exports =
|
||||
signature: 'ssh [destination]'
|
||||
signature: 'ssh [uuid]'
|
||||
description: '(beta) get a shell into the running app container of a device'
|
||||
help: '''
|
||||
WARNING: If you're running Windows, this command only supports `cmd.exe`.
|
||||
@ -44,8 +44,6 @@ module.exports =
|
||||
Use this command to get a shell into the running application container of
|
||||
your device.
|
||||
|
||||
The `destination` argument can be either a device uuid or an application name.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin ssh MyApp
|
||||
@ -59,7 +57,7 @@ module.exports =
|
||||
signature: 'port'
|
||||
parameter: 'port'
|
||||
description: 'ssh gateway port'
|
||||
alias: 't'
|
||||
alias: 'p'
|
||||
,
|
||||
signature: 'verbose'
|
||||
boolean: true
|
||||
@ -78,11 +76,11 @@ module.exports =
|
||||
|
||||
verbose = if options.verbose then '-vvv' else ''
|
||||
|
||||
resin.models.device.has(params.destination).then (isValidUUID) ->
|
||||
resin.models.device.has(params.uuid).then (isValidUUID) ->
|
||||
if isValidUUID
|
||||
return params.destination
|
||||
return params.uuid
|
||||
|
||||
return patterns.inferOrSelectDevice(params.destination)
|
||||
return patterns.inferOrSelectDevice()
|
||||
.then (uuid) ->
|
||||
console.info("Connecting with: #{uuid}")
|
||||
resin.models.device.get(uuid)
|
||||
|
@ -15,15 +15,13 @@ limitations under the License.
|
||||
###
|
||||
|
||||
module.exports =
|
||||
signature: 'sync [destination]'
|
||||
signature: 'sync [uuid]'
|
||||
description: '(beta) sync your changes with a device'
|
||||
help: '''
|
||||
WARNING: If you're running Windows, this command only supports `cmd.exe`.
|
||||
|
||||
Use this command to sync your local changes to a certain device on the fly.
|
||||
|
||||
The `destination` argument can be either a device uuid or an application name.
|
||||
|
||||
You can save all the options mentioned below in a `resin-sync.yml` file,
|
||||
by using the same option names as keys. For example:
|
||||
|
||||
@ -82,18 +80,34 @@ module.exports =
|
||||
]
|
||||
action: (params, options, done) ->
|
||||
resin = require('resin-sdk')
|
||||
Promise = require('bluebird')
|
||||
resinSync = require('resin-sync')
|
||||
patterns = require('../utils/patterns')
|
||||
{ loadConfig } = require('../utils/helpers')
|
||||
|
||||
# TODO: Add comma separated options to Capitano
|
||||
if options.ignore?
|
||||
options.ignore = options.ignore.split(',')
|
||||
Promise.try ->
|
||||
try
|
||||
fs.accessSync(path.join(process.cwd(), '.resin-sync.yml'))
|
||||
catch
|
||||
if not options.source?
|
||||
throw new Error('No --source option passed and no \'.resin-sync.yml\' file found in current directory.')
|
||||
|
||||
resin.models.device.has(params.destination).then (isValidUUID) ->
|
||||
if isValidUUID
|
||||
return params.destination
|
||||
options.source ?= process.cwd()
|
||||
|
||||
return patterns.inferOrSelectDevice(params.destination)
|
||||
.then (uuid) ->
|
||||
resinSync.sync(uuid, options)
|
||||
# TODO: Add comma separated options to Capitano
|
||||
if options.ignore?
|
||||
options.ignore = options.ignore.split(',')
|
||||
|
||||
Promise.resolve(params.uuid ? loadConfig(options.source).uuid)
|
||||
.then (uuid) ->
|
||||
if not uuid?
|
||||
return patterns.inferOrSelectDevice()
|
||||
|
||||
resin.models.device.has(uuid)
|
||||
.then (hasDevice) ->
|
||||
if not hasDevice
|
||||
throw new Error("Device not found: #{uuid}")
|
||||
return uuid
|
||||
.then (uuid) ->
|
||||
resinSync.sync(uuid, options)
|
||||
.nodeify(done)
|
||||
|
Loading…
x
Reference in New Issue
Block a user