Integrate with SDK v1.0.0

This commit is contained in:
Juan Cruz Viotti 2015-03-19 11:45:07 -04:00
parent 4b3decbe03
commit a524bffaa2
7 changed files with 15 additions and 23 deletions

View File

@ -1,5 +1,5 @@
(function() { (function() {
var _, async, capitano, commandOptions, fs, resin, visuals; var SSH_KEY_WIDTH, _, async, capitano, commandOptions, fs, resin, visuals;
_ = require('lodash'); _ = require('lodash');
@ -33,6 +33,8 @@
} }
}; };
SSH_KEY_WIDTH = 43;
exports.info = { exports.info = {
signature: 'key <id>', signature: 'key <id>',
description: 'list a single ssh key', description: 'list a single ssh key',
@ -40,12 +42,10 @@
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
return resin.models.key.get(params.id, function(error, key) { return resin.models.key.get(params.id, function(error, key) {
var sshKeyWidth;
if (error != null) { if (error != null) {
return done(error); return done(error);
} }
sshKeyWidth = resin.settings.get('sshKeyWidth'); key.public_key = '\n' + visuals.helpers.chop(key.public_key, SSH_KEY_WIDTH);
key.public_key = '\n' + visuals.helpers.chop(key.public_key, sshKeyWidth);
console.log(visuals.widgets.table.vertical(key, ['id', 'title', 'public_key'])); console.log(visuals.widgets.table.vertical(key, ['id', 'title', 'public_key']));
return done(); return done();
}); });

View File

@ -1,11 +1,11 @@
(function() { (function() {
var open, resin, url; var open, settings, url;
open = require('open'); open = require('open');
url = require('url'); url = require('url');
resin = require('resin-sdk'); settings = require('resin-settings-client');
exports.preferences = { exports.preferences = {
signature: 'preferences', signature: 'preferences',
@ -13,9 +13,8 @@
help: 'Use this command to open the preferences form.\n\nIn the future, we will allow changing all preferences directly from the terminal.\nFor now, we open your default web browser and point it to the web based preferences form.\n\nExamples:\n\n $ resin preferences', help: 'Use this command to open the preferences form.\n\nIn the future, we will allow changing all preferences directly from the terminal.\nFor now, we open your default web browser and point it to the web based preferences form.\n\nExamples:\n\n $ resin preferences',
permission: 'user', permission: 'user',
action: function() { action: function() {
var absUrl, preferencesUrl; var absUrl;
preferencesUrl = resin.settings.get('urls.preferences'); absUrl = url.resolve(settings.get('remoteUrl'), '/preferences');
absUrl = url.resolve(resin.settings.get('remoteUrl'), preferencesUrl);
return open(absUrl); return open(absUrl);
} }
}; };

View File

@ -152,10 +152,6 @@
return update.check(callback); return update.check(callback);
}, function(callback) { }, function(callback) {
return plugins.register('resin-plugin-', callback); return plugins.register('resin-plugin-', callback);
}, function(callback) {
var dataPrefix;
dataPrefix = resin.settings.get('dataPrefix');
return resin.data.prefix.set(dataPrefix, callback);
}, function(callback) { }, function(callback) {
var cli; var cli;
cli = capitano.parse(process.argv); cli = capitano.parse(process.argv);

View File

@ -24,6 +24,8 @@ exports.list =
console.log visuals.widgets.table.horizontal keys, [ 'id', 'title' ] console.log visuals.widgets.table.horizontal keys, [ 'id', 'title' ]
return done() return done()
SSH_KEY_WIDTH = 43
exports.info = exports.info =
signature: 'key <id>' signature: 'key <id>'
description: 'list a single ssh key' description: 'list a single ssh key'
@ -39,8 +41,7 @@ exports.info =
resin.models.key.get params.id, (error, key) -> resin.models.key.get params.id, (error, key) ->
return done(error) if error? return done(error) if error?
sshKeyWidth = resin.settings.get('sshKeyWidth') key.public_key = '\n' + visuals.helpers.chop(key.public_key, SSH_KEY_WIDTH)
key.public_key = '\n' + visuals.helpers.chop(key.public_key, sshKeyWidth)
console.log(visuals.widgets.table.vertical(key, [ 'id', 'title', 'public_key' ])) console.log(visuals.widgets.table.vertical(key, [ 'id', 'title', 'public_key' ]))
return done() return done()

View File

@ -1,6 +1,6 @@
open = require('open') open = require('open')
url = require('url') url = require('url')
resin = require('resin-sdk') settings = require('resin-settings-client')
exports.preferences = exports.preferences =
signature: 'preferences' signature: 'preferences'
@ -17,6 +17,5 @@ exports.preferences =
''' '''
permission: 'user' permission: 'user'
action: -> action: ->
preferencesUrl = resin.settings.get('urls.preferences') absUrl = url.resolve(settings.get('remoteUrl'), '/preferences')
absUrl = url.resolve(resin.settings.get('remoteUrl'), preferencesUrl)
open(absUrl) open(absUrl)

View File

@ -125,10 +125,6 @@ async.waterfall([
(callback) -> (callback) ->
plugins.register('resin-plugin-', callback) plugins.register('resin-plugin-', callback)
(callback) ->
dataPrefix = resin.settings.get('dataPrefix')
resin.data.prefix.set(dataPrefix, callback)
(callback) -> (callback) ->
cli = capitano.parse(process.argv) cli = capitano.parse(process.argv)

View File

@ -62,7 +62,8 @@
"open": "0.0.5", "open": "0.0.5",
"progress-stream": "^0.5.0", "progress-stream": "^0.5.0",
"resin-cli-visuals": "^0.1.0", "resin-cli-visuals": "^0.1.0",
"resin-sdk": "^0.0.4", "resin-sdk": "^1.0.0",
"resin-settings-client": "^1.0.0",
"resin-vcs": "^1.0.0", "resin-vcs": "^1.0.0",
"underscore.string": "~2.4.0", "underscore.string": "~2.4.0",
"update-notifier": "^0.3.1" "update-notifier": "^0.3.1"