mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-18 18:56:25 +00:00
Merge pull request #70 from resin-io/refactor/new-visuals
Upgrade Resin CLI Visuals and use it's new capabilities
This commit is contained in:
commit
381e63bfc9
@ -39,12 +39,7 @@
|
||||
if (options.type != null) {
|
||||
return callback(null, options.type);
|
||||
}
|
||||
return resin.models.device.getSupportedDeviceTypes(function(error, deviceTypes) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
return visuals.widgets.select('Select a type', deviceTypes, callback);
|
||||
});
|
||||
return visuals.patterns.selectDeviceType(callback);
|
||||
}, function(type, callback) {
|
||||
options.type = type;
|
||||
return resin.models.application.create(params.name, options.type, callback);
|
||||
@ -162,7 +157,12 @@
|
||||
function(callback) {
|
||||
var currentDirectoryBasename;
|
||||
currentDirectoryBasename = path.basename(currentDirectory);
|
||||
return visuals.widgets.ask('What is the name of your application?', currentDirectoryBasename, callback);
|
||||
return visuals.form.ask({
|
||||
label: 'What is the name of your application?',
|
||||
name: 'application',
|
||||
type: 'text',
|
||||
value: currentDirectoryBasename
|
||||
}, callback);
|
||||
}, function(applicationName, callback) {
|
||||
return exports.create.action({
|
||||
name: applicationName
|
||||
|
@ -32,7 +32,7 @@
|
||||
if (error != null) {
|
||||
console.error("Unable to open a web browser in the current environment.\nPlease visit " + TOKEN_URL + " manually.");
|
||||
}
|
||||
return visuals.widgets.ask('What\'s your token? (visible in the preferences page)', null, callback);
|
||||
return visuals.patterns.loginWithToken(callback);
|
||||
});
|
||||
}, function(token, callback) {
|
||||
return resin.auth.loginWithToken(token, callback);
|
||||
@ -97,7 +97,7 @@
|
||||
if (hasOptionCredentials) {
|
||||
return callback(null, options);
|
||||
}
|
||||
return visuals.widgets.register(callback);
|
||||
return visuals.patterns.register(callback);
|
||||
}, function(credentials, callback) {
|
||||
return resin.auth.register(credentials, function(error, token) {
|
||||
return callback(error, credentials);
|
||||
|
@ -106,7 +106,11 @@
|
||||
if (!_.isEmpty(params.newName)) {
|
||||
return callback(null, params.newName);
|
||||
}
|
||||
return visuals.widgets.ask('How do you want to name this device?', null, callback);
|
||||
return visuals.form.ask({
|
||||
label: 'How do you want to name this device?',
|
||||
name: 'device',
|
||||
type: 'text'
|
||||
}, callback);
|
||||
}, function(newName, callback) {
|
||||
return resin.models.device.rename(params.name, newName, callback);
|
||||
}
|
||||
|
@ -44,10 +44,7 @@ exports.create =
|
||||
return callback(new Error('You already have an application with that name!'))
|
||||
|
||||
return callback(null, options.type) if options.type?
|
||||
|
||||
resin.models.device.getSupportedDeviceTypes (error, deviceTypes) ->
|
||||
return callback(error) if error?
|
||||
visuals.widgets.select('Select a type', deviceTypes, callback)
|
||||
visuals.patterns.selectDeviceType(callback)
|
||||
|
||||
(type, callback) ->
|
||||
options.type = type
|
||||
@ -216,7 +213,12 @@ exports.init =
|
||||
|
||||
(callback) ->
|
||||
currentDirectoryBasename = path.basename(currentDirectory)
|
||||
visuals.widgets.ask('What is the name of your application?', currentDirectoryBasename, callback)
|
||||
visuals.form.ask
|
||||
label: 'What is the name of your application?'
|
||||
name: 'application'
|
||||
type: 'text'
|
||||
value: currentDirectoryBasename
|
||||
, callback
|
||||
|
||||
(applicationName, callback) ->
|
||||
|
||||
|
@ -44,7 +44,7 @@ exports.login =
|
||||
Please visit #{TOKEN_URL} manually.
|
||||
"""
|
||||
|
||||
visuals.widgets.ask('What\'s your token? (visible in the preferences page)', null, callback)
|
||||
visuals.patterns.loginWithToken(callback)
|
||||
|
||||
(token, callback) ->
|
||||
resin.auth.loginWithToken(token, callback)
|
||||
@ -131,7 +131,7 @@ exports.signup =
|
||||
|
||||
(callback) ->
|
||||
return callback(null, options) if hasOptionCredentials
|
||||
visuals.widgets.register(callback)
|
||||
visuals.patterns.register(callback)
|
||||
|
||||
(credentials, callback) ->
|
||||
resin.auth.register credentials, (error, token) ->
|
||||
|
@ -145,7 +145,12 @@ exports.rename =
|
||||
(callback) ->
|
||||
if not _.isEmpty(params.newName)
|
||||
return callback(null, params.newName)
|
||||
visuals.widgets.ask('How do you want to name this device?', null, callback)
|
||||
|
||||
visuals.form.ask
|
||||
label: 'How do you want to name this device?'
|
||||
name: 'device'
|
||||
type: 'text'
|
||||
, callback
|
||||
|
||||
(newName, callback) ->
|
||||
resin.models.device.rename(params.name, newName, callback)
|
||||
|
@ -59,7 +59,7 @@
|
||||
"nplugm": "^2.2.0",
|
||||
"npm": "^2.6.1",
|
||||
"open": "0.0.5",
|
||||
"resin-cli-visuals": "^0.1.1",
|
||||
"resin-cli-visuals": "^0.2.0",
|
||||
"resin-config-inject": "^2.0.0",
|
||||
"resin-image": "^1.1.3",
|
||||
"resin-image-manager": "^1.1.0",
|
||||
|
Loading…
Reference in New Issue
Block a user