From cf512cc01ba4e7301f00fb42a7e607ddfcb6fb2b Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 29 Jul 2015 16:34:31 +0300 Subject: [PATCH] Integrate new resin-cli-visuals functionality --- build/actions/app.js | 4 ++-- build/actions/device.js | 14 ++++++++------ build/actions/drive.js | 2 +- build/actions/environment-variables.js | 2 +- build/actions/examples.js | 4 ++-- build/actions/keys.js | 4 ++-- build/actions/plugin.js | 2 +- lib/actions/app.coffee | 6 +++--- lib/actions/device.coffee | 13 +++++++------ lib/actions/drive.coffee | 2 +- lib/actions/environment-variables.coffee | 2 +- lib/actions/examples.coffee | 9 +++------ lib/actions/keys.coffee | 4 ++-- lib/actions/plugin.coffee | 2 +- 14 files changed, 35 insertions(+), 35 deletions(-) diff --git a/build/actions/app.js b/build/actions/app.js index cbea9996..1d7adbc5 100644 --- a/build/actions/app.js +++ b/build/actions/app.js @@ -66,7 +66,7 @@ permission: 'user', action: function(params, options, done) { return resin.models.application.getAll().then(function(applications) { - return console.log(visuals.widgets.table.horizontal(applications, ['id', 'app_name', 'device_type', 'online_devices', 'devices_length'])); + return console.log(visuals.table.horizontal(applications, ['id', 'app_name', 'device_type', 'online_devices', 'devices_length'])); }).nodeify(done); } }; @@ -78,7 +78,7 @@ permission: 'user', action: function(params, options, done) { return resin.models.application.get(params.name).then(function(application) { - return console.log(visuals.widgets.table.vertical(application, ['id', 'app_name', 'device_type', 'git_repository', 'commit'])); + return console.log(visuals.table.vertical(application, ["$" + application.app_name + "$", 'id', 'device_type', 'git_repository', 'commit'])); }).nodeify(done); } }; diff --git a/build/actions/device.js b/build/actions/device.js index 571f2a3f..2ea06090 100644 --- a/build/actions/device.js +++ b/build/actions/device.js @@ -1,5 +1,5 @@ (function() { - var _, async, capitano, commandOptions, deviceConfig, form, fse, image, inject, manager, path, pine, registerDevice, resin, tmp, vcs, visuals; + var _, async, capitano, commandOptions, deviceConfig, drivelist, form, fse, image, inject, manager, path, pine, registerDevice, resin, tmp, vcs, visuals; fse = require('fs-extra'); @@ -33,6 +33,8 @@ form = require('resin-cli-form'); + drivelist = require('drivelist'); + tmp.setGracefulCleanup(); commandOptions = require('./command-options'); @@ -54,7 +56,7 @@ if (error != null) { return done(error); } - console.log(visuals.widgets.table.horizontal(devices, ['id', 'name', 'device_type', 'is_online', 'application_name', 'status', 'last_seen'])); + console.log(visuals.table.horizontal(devices, ['id', 'name', 'device_type', 'is_online', 'application_name', 'status', 'last_seen'])); return done(null, devices); }); } @@ -70,7 +72,7 @@ if (device.last_seen == null) { device.last_seen = 'Not seen'; } - return console.log(visuals.widgets.table.vertical(device, ['id', 'name', 'device_type', 'is_online', 'ip_address', 'application_name', 'status', 'last_seen', 'uuid', 'commit', 'supervisor_version', 'is_web_accessible', 'note'])); + return console.log(visuals.table.vertical(device, ["$" + device.name + "$", 'id', 'device_type', 'is_online', 'ip_address', 'application_name', 'status', 'last_seen', 'uuid', 'commit', 'supervisor_version', 'is_web_accessible', 'note'])); }).nodeify(done); } }; @@ -306,8 +308,8 @@ if (process.env.DEBUG) { console.log(results.config); } - bar = new visuals.widgets.Progress('Downloading Device OS'); - spinner = new visuals.widgets.Spinner('Downloading Device OS (size unknown)'); + bar = new visuals.Progress('Downloading Device OS'); + spinner = new visuals.Spinner('Downloading Device OS (size unknown)'); return manager.configure(results.manifest, results.config, function(error, imagePath, removeCallback) { spinner.stop(); return callback(error, imagePath, removeCallback); @@ -321,7 +323,7 @@ }, function(configuredImagePath, removeCallback, callback) { var bar; console.info('Attempting to write operating system image to drive'); - bar = new visuals.widgets.Progress('Writing Device OS'); + bar = new visuals.Progress('Writing Device OS'); return image.write({ device: params.device, image: configuredImagePath, diff --git a/build/actions/drive.js b/build/actions/drive.js index de1d83ab..c31ca74f 100644 --- a/build/actions/drive.js +++ b/build/actions/drive.js @@ -23,7 +23,7 @@ if (_.isEmpty(removableDrives)) { return done(new Error('No removable devices available')); } - console.log(visuals.widgets.table.horizontal(removableDrives, ['device', 'description', 'size'])); + console.log(visuals.table.horizontal(removableDrives, ['device', 'description', 'size'])); return done(); }); }); diff --git a/build/actions/environment-variables.js b/build/actions/environment-variables.js index 1f987fdd..343a4239 100644 --- a/build/actions/environment-variables.js +++ b/build/actions/environment-variables.js @@ -40,7 +40,7 @@ isSystemVariable = resin.models.environmentVariables.isSystemVariable; environmentVariables = _.reject(environmentVariables, isSystemVariable); } - console.log(visuals.widgets.table.horizontal(environmentVariables, ['id', 'name', 'value'])); + console.log(visuals.table.horizontal(environmentVariables, ['id', 'name', 'value'])); return callback(); } ], done); diff --git a/build/actions/examples.js b/build/actions/examples.js index 53fa83a7..06754d76 100644 --- a/build/actions/examples.js +++ b/build/actions/examples.js @@ -33,7 +33,7 @@ } return example; }); - return console.log(visuals.widgets.table.horizontal(examplesData, ['id', 'name', 'display_name', 'repository', 'author'])); + return console.log(visuals.table.horizontal(examplesData, ['name', 'display_name', 'author'])); } }; @@ -53,7 +53,7 @@ if (example.author == null) { example.author = 'Unknown'; } - console.log(visuals.widgets.table.vertical(example, ['name', 'display_name', 'description', 'author', 'repository'])); + console.log(visuals.table.vertical(example, ["$" + example.display_name + "$", 'description', 'author', 'repository'])); return done(); } }; diff --git a/build/actions/keys.js b/build/actions/keys.js index d3830d88..dfa1ea0d 100644 --- a/build/actions/keys.js +++ b/build/actions/keys.js @@ -26,7 +26,7 @@ permission: 'user', action: function(params, options, done) { return resin.models.key.getAll().then(function(keys) { - return console.log(visuals.widgets.table.horizontal(keys, ['id', 'title'])); + return console.log(visuals.table.horizontal(keys, ['id', 'title'])); }).nodeify(done); } }; @@ -40,7 +40,7 @@ permission: 'user', action: function(params, options, done) { return resin.models.key.get(params.id).then(function(key) { - return console.log(visuals.widgets.table.vertical(key, ['id', 'title', 'public_key'])); + return console.log(visuals.table.vertical(key, ['id', 'title', 'public_key'])); }).nodeify(done); } }; diff --git a/build/actions/plugin.js b/build/actions/plugin.js index 06e5b739..d0a29e99 100644 --- a/build/actions/plugin.js +++ b/build/actions/plugin.js @@ -27,7 +27,7 @@ console.log('You don\'t have any plugins yet'); return done(); } - console.log(visuals.widgets.table.horizontal(resinPlugins, ['name', 'version', 'description', 'license'])); + console.log(visuals.table.horizontal(resinPlugins, ['name', 'version', 'description', 'license'])); return done(); }); } diff --git a/lib/actions/app.coffee b/lib/actions/app.coffee index b70f790b..efc8c9ce 100644 --- a/lib/actions/app.coffee +++ b/lib/actions/app.coffee @@ -78,7 +78,7 @@ exports.list = permission: 'user' action: (params, options, done) -> resin.models.application.getAll().then (applications) -> - console.log visuals.widgets.table.horizontal applications, [ + console.log visuals.table.horizontal applications, [ 'id' 'app_name' 'device_type' @@ -100,9 +100,9 @@ exports.info = permission: 'user' action: (params, options, done) -> resin.models.application.get(params.name).then (application) -> - console.log visuals.widgets.table.vertical application, [ + console.log visuals.table.vertical application, [ + "$#{application.app_name}$" 'id' - 'app_name' 'device_type' 'git_repository' 'commit' diff --git a/lib/actions/device.coffee b/lib/actions/device.coffee index 56ecad91..3bcf7f6d 100644 --- a/lib/actions/device.coffee +++ b/lib/actions/device.coffee @@ -14,6 +14,7 @@ pine = require('resin-pine') tmp = require('tmp') deviceConfig = require('resin-device-config') form = require('resin-cli-form') +drivelist = require('drivelist') # Cleanup the temporary files even when an uncaught exception occurs tmp.setGracefulCleanup() @@ -45,7 +46,7 @@ exports.list = getFunction (error, devices) -> return done(error) if error? - console.log visuals.widgets.table.horizontal devices, [ + console.log visuals.table.horizontal devices, [ 'id' 'name' 'device_type' @@ -76,9 +77,9 @@ exports.info = # or have it parsed appropriately in the SDK. device.last_seen ?= 'Not seen' - console.log visuals.widgets.table.vertical device, [ + console.log visuals.table.vertical device, [ + "$#{device.name}$" 'id' - 'name' 'device_type' 'is_online' 'ip_address' @@ -384,8 +385,8 @@ exports.init = if process.env.DEBUG console.log(results.config) - bar = new visuals.widgets.Progress('Downloading Device OS') - spinner = new visuals.widgets.Spinner('Downloading Device OS (size unknown)') + bar = new visuals.Progress('Downloading Device OS') + spinner = new visuals.Spinner('Downloading Device OS (size unknown)') manager.configure results.manifest, results.config, (error, imagePath, removeCallback) -> spinner.stop() @@ -399,7 +400,7 @@ exports.init = (configuredImagePath, removeCallback, callback) -> console.info('Attempting to write operating system image to drive') - bar = new visuals.widgets.Progress('Writing Device OS') + bar = new visuals.Progress('Writing Device OS') image.write device: params.device image: configuredImagePath diff --git a/lib/actions/drive.coffee b/lib/actions/drive.coffee index cc80b035..ee76b5d2 100644 --- a/lib/actions/drive.coffee +++ b/lib/actions/drive.coffee @@ -23,7 +23,7 @@ exports.list = if _.isEmpty(removableDrives) return done(new Error('No removable devices available')) - console.log visuals.widgets.table.horizontal removableDrives, [ + console.log visuals.table.horizontal removableDrives, [ 'device' 'description' 'size' diff --git a/lib/actions/environment-variables.coffee b/lib/actions/environment-variables.coffee index 87a779e9..22a11e0e 100644 --- a/lib/actions/environment-variables.coffee +++ b/lib/actions/environment-variables.coffee @@ -50,7 +50,7 @@ exports.list = isSystemVariable = resin.models.environmentVariables.isSystemVariable environmentVariables = _.reject(environmentVariables, isSystemVariable) - console.log visuals.widgets.table.horizontal environmentVariables, [ + console.log visuals.table.horizontal environmentVariables, [ 'id' 'name' 'value' diff --git a/lib/actions/examples.coffee b/lib/actions/examples.coffee index 30f54499..696c8c17 100644 --- a/lib/actions/examples.coffee +++ b/lib/actions/examples.coffee @@ -27,11 +27,9 @@ exports.list = example.author ?= 'Unknown' return example - console.log visuals.widgets.table.horizontal examplesData, [ - 'id' + console.log visuals.table.horizontal examplesData, [ 'name' 'display_name' - 'repository' 'author' ] @@ -54,9 +52,8 @@ exports.info = example.author ?= 'Unknown' - console.log visuals.widgets.table.vertical example, [ - 'name' - 'display_name' + console.log visuals.table.vertical example, [ + "$#{example.display_name}$" 'description' 'author' 'repository' diff --git a/lib/actions/keys.coffee b/lib/actions/keys.coffee index 25ac9ebc..23564764 100644 --- a/lib/actions/keys.coffee +++ b/lib/actions/keys.coffee @@ -21,7 +21,7 @@ exports.list = permission: 'user' action: (params, options, done) -> resin.models.key.getAll().then (keys) -> - console.log visuals.widgets.table.horizontal keys, [ 'id', 'title' ] + console.log visuals.table.horizontal keys, [ 'id', 'title' ] .nodeify(done) SSH_KEY_WIDTH = 43 @@ -39,7 +39,7 @@ exports.info = permission: 'user' action: (params, options, done) -> resin.models.key.get(params.id).then (key) -> - console.log(visuals.widgets.table.vertical(key, [ 'id', 'title', 'public_key' ])) + console.log visuals.table.vertical key, [ 'id', 'title', 'public_key' ] .nodeify(done) exports.remove = diff --git a/lib/actions/plugin.coffee b/lib/actions/plugin.coffee index c685df5c..69e2139c 100644 --- a/lib/actions/plugin.coffee +++ b/lib/actions/plugin.coffee @@ -24,7 +24,7 @@ exports.list = console.log('You don\'t have any plugins yet') return done() - console.log visuals.widgets.table.horizontal resinPlugins, [ + console.log visuals.table.horizontal resinPlugins, [ 'name' 'version' 'description'