Merge pull request #280 from resin-io/feat/lazy-loading

Lazy load command actions dependencies
This commit is contained in:
Juan Cruz Viotti 2015-12-07 16:21:32 -03:00
commit bb78a3ca09
24 changed files with 328 additions and 239 deletions

View File

@ -1,16 +1,8 @@
(function() { (function() {
var commandOptions, events, patterns, resin, visuals; var commandOptions;
resin = require('resin-sdk');
visuals = require('resin-cli-visuals');
commandOptions = require('./command-options'); commandOptions = require('./command-options');
events = require('resin-cli-events');
patterns = require('../utils/patterns');
exports.create = { exports.create = {
signature: 'app create <name>', signature: 'app create <name>',
description: 'create an application', description: 'create an application',
@ -26,6 +18,10 @@
permission: 'user', permission: 'user',
primary: true, primary: true,
action: function(params, options, done) { action: function(params, options, done) {
var events, patterns, resin;
resin = require('resin-sdk');
events = require('resin-cli-events');
patterns = require('../utils/patterns');
return resin.models.application.has(params.name).then(function(hasApplication) { return resin.models.application.has(params.name).then(function(hasApplication) {
if (hasApplication) { if (hasApplication) {
throw new Error('You already have an application with that name!'); throw new Error('You already have an application with that name!');
@ -50,6 +46,9 @@
permission: 'user', permission: 'user',
primary: true, primary: true,
action: function(params, options, done) { action: function(params, options, done) {
var resin, visuals;
resin = require('resin-sdk');
visuals = require('resin-cli-visuals');
return resin.models.application.getAll().then(function(applications) { return resin.models.application.getAll().then(function(applications) {
return console.log(visuals.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); }).nodeify(done);
@ -63,6 +62,10 @@
permission: 'user', permission: 'user',
primary: true, primary: true,
action: function(params, options, done) { action: function(params, options, done) {
var events, resin, visuals;
resin = require('resin-sdk');
visuals = require('resin-cli-visuals');
events = require('resin-cli-events');
return resin.models.application.get(params.name).then(function(application) { return resin.models.application.get(params.name).then(function(application) {
console.log(visuals.table.vertical(application, ["$" + application.app_name + "$", 'id', 'device_type', 'git_repository', 'commit'])); console.log(visuals.table.vertical(application, ["$" + application.app_name + "$", 'id', 'device_type', 'git_repository', 'commit']));
return events.send('application.open', { return events.send('application.open', {
@ -78,6 +81,8 @@
help: 'Use this command to restart all devices that belongs to a certain application.\n\nExamples:\n\n $ resin app restart MyApp', help: 'Use this command to restart all devices that belongs to a certain application.\n\nExamples:\n\n $ resin app restart MyApp',
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
return resin.models.application.restart(params.name).nodeify(done); return resin.models.application.restart(params.name).nodeify(done);
} }
}; };
@ -89,6 +94,10 @@
options: [commandOptions.yes], options: [commandOptions.yes],
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var events, patterns, resin;
resin = require('resin-sdk');
events = require('resin-cli-events');
patterns = require('../utils/patterns');
return patterns.confirm(options.yes, 'Are you sure you want to delete the application?').then(function() { return patterns.confirm(options.yes, 'Are you sure you want to delete the application?').then(function() {
return resin.models.application.remove(params.name); return resin.models.application.remove(params.name);
}).tap(function() { }).tap(function() {

View File

@ -1,22 +1,4 @@
(function() { (function() {
var Promise, _, auth, events, form, resin, validation, visuals;
Promise = require('bluebird');
_ = require('lodash');
resin = require('resin-sdk');
form = require('resin-cli-form');
visuals = require('resin-cli-visuals');
events = require('resin-cli-events');
auth = require('resin-cli-auth');
validation = require('../utils/validation');
exports.login = { exports.login = {
signature: 'login', signature: 'login',
description: 'login to resin.io', description: 'login to resin.io',
@ -31,6 +13,11 @@
], ],
primary: true, primary: true,
action: function(params, options, done) { action: function(params, options, done) {
var Promise, auth, events, resin;
Promise = require('bluebird');
resin = require('resin-sdk');
events = require('resin-cli-events');
auth = require('resin-cli-auth');
return Promise["try"](function() { return Promise["try"](function() {
if (options.token != null) { if (options.token != null) {
return resin.auth.loginWithToken(options.token); return resin.auth.loginWithToken(options.token);
@ -50,6 +37,9 @@
help: 'Use this command to logout from your resin.io account.o\n\nExamples:\n\n $ resin logout', help: 'Use this command to logout from your resin.io account.o\n\nExamples:\n\n $ resin logout',
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var events, resin;
resin = require('resin-sdk');
events = require('resin-cli-events');
return resin.auth.logout().then(function() { return resin.auth.logout().then(function() {
return events.send('user.logout'); return events.send('user.logout');
}).nodeify(done); }).nodeify(done);
@ -61,6 +51,11 @@
description: 'signup to resin.io', description: 'signup to resin.io',
help: 'Use this command to signup for a resin.io account.\n\nIf signup is successful, you\'ll be logged in to your new user automatically.\n\nExamples:\n\n $ resin signup\n Email: me@mycompany.com\n Username: johndoe\n Password: ***********\n\n $ resin whoami\n johndoe', help: 'Use this command to signup for a resin.io account.\n\nIf signup is successful, you\'ll be logged in to your new user automatically.\n\nExamples:\n\n $ resin signup\n Email: me@mycompany.com\n Username: johndoe\n Password: ***********\n\n $ resin whoami\n johndoe',
action: function(params, options, done) { action: function(params, options, done) {
var events, form, resin, validation;
resin = require('resin-sdk');
form = require('resin-cli-form');
events = require('resin-cli-events');
validation = require('../utils/validation');
return form.run([ return form.run([
{ {
message: 'Email:', message: 'Email:',
@ -89,6 +84,10 @@
help: 'Use this command to find out the current logged in username and email address.\n\nExamples:\n\n $ resin whoami', help: 'Use this command to find out the current logged in username and email address.\n\nExamples:\n\n $ resin whoami',
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var Promise, resin, visuals;
Promise = require('bluebird');
resin = require('resin-sdk');
visuals = require('resin-cli-visuals');
return Promise.props({ return Promise.props({
username: resin.auth.whoami(), username: resin.auth.whoami(),
email: resin.auth.getEmail(), email: resin.auth.getEmail(),

View File

@ -1,20 +1,4 @@
(function() { (function() {
var Promise, _, capitano, config, prettyjson, umount, visuals;
_ = require('lodash');
Promise = require('bluebird');
capitano = Promise.promisifyAll(require('capitano'));
umount = Promise.promisifyAll(require('umount'));
visuals = require('resin-cli-visuals');
config = require('resin-config-json');
prettyjson = require('prettyjson');
exports.read = { exports.read = {
signature: 'config read', signature: 'config read',
description: 'read a device configuration', description: 'read a device configuration',
@ -36,6 +20,12 @@
permission: 'user', permission: 'user',
root: true, root: true,
action: function(params, options, done) { action: function(params, options, done) {
var Promise, config, prettyjson, umount, visuals;
Promise = require('bluebird');
config = require('resin-config-json');
visuals = require('resin-cli-visuals');
umount = Promise.promisifyAll(require('umount'));
prettyjson = require('prettyjson');
return Promise["try"](function() { return Promise["try"](function() {
return options.drive || visuals.drive('Select the device drive'); return options.drive || visuals.drive('Select the device drive');
}).tap(umount.umountAsync).then(function(drive) { }).tap(umount.umountAsync).then(function(drive) {
@ -67,6 +57,12 @@
permission: 'user', permission: 'user',
root: true, root: true,
action: function(params, options, done) { action: function(params, options, done) {
var Promise, _, config, umount, visuals;
Promise = require('bluebird');
_ = require('lodash');
config = require('resin-config-json');
visuals = require('resin-cli-visuals');
umount = Promise.promisifyAll(require('umount'));
return Promise["try"](function() { return Promise["try"](function() {
return options.drive || visuals.drive('Select the device drive'); return options.drive || visuals.drive('Select the device drive');
}).tap(umount.umountAsync).then(function(drive) { }).tap(umount.umountAsync).then(function(drive) {
@ -111,6 +107,12 @@
permission: 'user', permission: 'user',
root: true, root: true,
action: function(params, options, done) { action: function(params, options, done) {
var Promise, capitano, config, umount, visuals;
Promise = require('bluebird');
config = require('resin-config-json');
visuals = require('resin-cli-visuals');
capitano = Promise.promisifyAll(require('capitano'));
umount = Promise.promisifyAll(require('umount'));
return Promise["try"](function() { return Promise["try"](function() {
return options.drive || visuals.drive('Select the device drive'); return options.drive || visuals.drive('Select the device drive');
}).tap(umount.umountAsync).then(function(drive) { }).tap(umount.umountAsync).then(function(drive) {

View File

@ -1,29 +1,5 @@
(function() { (function() {
var Promise, _, capitano, commandOptions, events, form, helpers, patterns, resin, rimraf, tmp, visuals; var commandOptions;
Promise = require('bluebird');
capitano = Promise.promisifyAll(require('capitano'));
_ = require('lodash');
resin = require('resin-sdk');
visuals = require('resin-cli-visuals');
form = require('resin-cli-form');
events = require('resin-cli-events');
rimraf = Promise.promisify(require('rimraf'));
patterns = require('../utils/patterns');
helpers = require('../utils/helpers');
tmp = Promise.promisifyAll(require('tmp'));
tmp.setGracefulCleanup();
commandOptions = require('./command-options'); commandOptions = require('./command-options');
@ -35,6 +11,10 @@
permission: 'user', permission: 'user',
primary: true, primary: true,
action: function(params, options, done) { action: function(params, options, done) {
var Promise, resin, visuals;
Promise = require('bluebird');
resin = require('resin-sdk');
visuals = require('resin-cli-visuals');
return Promise["try"](function() { return Promise["try"](function() {
if (options.application != null) { if (options.application != null) {
return resin.models.device.getAllByApplication(options.application); return resin.models.device.getAllByApplication(options.application);
@ -53,6 +33,10 @@
permission: 'user', permission: 'user',
primary: true, primary: true,
action: function(params, options, done) { action: function(params, options, done) {
var events, resin, visuals;
resin = require('resin-sdk');
visuals = require('resin-cli-visuals');
events = require('resin-cli-events');
return resin.models.device.get(params.uuid).then(function(device) { return resin.models.device.get(params.uuid).then(function(device) {
if (device.last_seen == null) { if (device.last_seen == null) {
device.last_seen = 'Not seen'; device.last_seen = 'Not seen';
@ -79,6 +63,9 @@
} }
], ],
action: function(params, options, done) { action: function(params, options, done) {
var Promise, resin;
Promise = require('bluebird');
resin = require('resin-sdk');
return resin.models.application.get(params.application).then(function(application) { return resin.models.application.get(params.application).then(function(application) {
return Promise["try"](function() { return Promise["try"](function() {
return options.uuid || resin.models.device.generateUUID(); return options.uuid || resin.models.device.generateUUID();
@ -97,6 +84,10 @@
options: [commandOptions.yes], options: [commandOptions.yes],
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var events, patterns, resin;
resin = require('resin-sdk');
events = require('resin-cli-events');
patterns = require('../utils/patterns');
return patterns.confirm(options.yes, 'Are you sure you want to delete the device?').then(function() { return patterns.confirm(options.yes, 'Are you sure you want to delete the device?').then(function() {
return resin.models.device.remove(params.uuid); return resin.models.device.remove(params.uuid);
}).tap(function() { }).tap(function() {
@ -113,6 +104,8 @@
help: 'Use this command to identify a device.\n\nIn the Raspberry Pi, the ACT led is blinked several times.\n\nExamples:\n\n $ resin device identify 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828', help: 'Use this command to identify a device.\n\nIn the Raspberry Pi, the ACT led is blinked several times.\n\nExamples:\n\n $ resin device identify 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828',
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
return resin.models.device.identify(params.uuid).nodeify(done); return resin.models.device.identify(params.uuid).nodeify(done);
} }
}; };
@ -123,6 +116,12 @@
help: 'Use this command to rename a device.\n\nIf you omit the name, you\'ll get asked for it interactively.\n\nExamples:\n\n $ resin device rename 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9 MyPi\n $ resin device rename 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9', help: 'Use this command to rename a device.\n\nIf you omit the name, you\'ll get asked for it interactively.\n\nExamples:\n\n $ resin device rename 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9 MyPi\n $ resin device rename 7cf02a62a3a84440b1bb5579a3d57469148943278630b17e7fc6c4f7b465c9',
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var Promise, _, events, form, resin;
Promise = require('bluebird');
_ = require('lodash');
resin = require('resin-sdk');
events = require('resin-cli-events');
form = require('resin-cli-form');
return Promise["try"](function() { return Promise["try"](function() {
if (!_.isEmpty(params.newName)) { if (!_.isEmpty(params.newName)) {
return params.newName; return params.newName;
@ -146,6 +145,10 @@
permission: 'user', permission: 'user',
options: [commandOptions.optionalApplication], options: [commandOptions.optionalApplication],
action: function(params, options, done) { action: function(params, options, done) {
var _, patterns, resin;
resin = require('resin-sdk');
_ = require('lodash');
patterns = require('../utils/patterns');
return resin.models.device.get(params.uuid).then(function(device) { return resin.models.device.get(params.uuid).then(function(device) {
return options.application || patterns.selectApplication(function(application) { return options.application || patterns.selectApplication(function(application) {
return _.all([application.device_type === device.device_type, device.application_name !== application.app_name]); return _.all([application.device_type === device.device_type, device.application_name !== application.app_name]);
@ -173,6 +176,15 @@
permission: 'user', permission: 'user',
primary: true, primary: true,
action: function(params, options, done) { action: function(params, options, done) {
var Promise, capitano, helpers, patterns, resin, rimraf, tmp;
Promise = require('bluebird');
capitano = Promise.promisifyAll(require('capitano'));
rimraf = Promise.promisify(require('rimraf'));
tmp = Promise.promisifyAll(require('tmp'));
tmp.setGracefulCleanup();
resin = require('resin-sdk');
helpers = require('../utils/helpers');
patterns = require('../utils/patterns');
return Promise["try"](function() { return Promise["try"](function() {
if (options.application != null) { if (options.application != null) {
return options.application; return options.application;

View File

@ -1,20 +1,8 @@
(function() { (function() {
var Promise, _, commandOptions, events, patterns, resin, visuals; var commandOptions;
Promise = require('bluebird');
_ = require('lodash');
resin = require('resin-sdk');
visuals = require('resin-cli-visuals');
events = require('resin-cli-events');
commandOptions = require('./command-options'); commandOptions = require('./command-options');
patterns = require('../utils/patterns');
exports.list = { exports.list = {
signature: 'envs', signature: 'envs',
description: 'list all environment variables', description: 'list all environment variables',
@ -29,6 +17,11 @@
], ],
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var Promise, _, resin, visuals;
Promise = require('bluebird');
_ = require('lodash');
resin = require('resin-sdk');
visuals = require('resin-cli-visuals');
return Promise["try"](function() { return Promise["try"](function() {
if (options.application != null) { if (options.application != null) {
return resin.models.environmentVariables.getAllByApplication(options.application); return resin.models.environmentVariables.getAllByApplication(options.application);
@ -58,6 +51,10 @@
options: [commandOptions.yes, commandOptions.booleanDevice], options: [commandOptions.yes, commandOptions.booleanDevice],
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var events, patterns, resin;
resin = require('resin-sdk');
events = require('resin-cli-events');
patterns = require('../utils/patterns');
return patterns.confirm(options.yes, 'Are you sure you want to delete the environment variable?').then(function() { return patterns.confirm(options.yes, 'Are you sure you want to delete the environment variable?').then(function() {
if (options.device) { if (options.device) {
resin.models.environmentVariables.device.remove(params.id); resin.models.environmentVariables.device.remove(params.id);
@ -81,6 +78,10 @@
options: [commandOptions.optionalApplication, commandOptions.optionalDevice], options: [commandOptions.optionalApplication, commandOptions.optionalDevice],
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var Promise, events, resin;
Promise = require('bluebird');
resin = require('resin-sdk');
events = require('resin-cli-events');
return Promise["try"](function() { return Promise["try"](function() {
if (params.value == null) { if (params.value == null) {
params.value = process.env[params.key]; params.value = process.env[params.key];
@ -118,6 +119,10 @@
permission: 'user', permission: 'user',
options: [commandOptions.booleanDevice], options: [commandOptions.booleanDevice],
action: function(params, options, done) { action: function(params, options, done) {
var Promise, events, resin;
Promise = require('bluebird');
resin = require('resin-sdk');
events = require('resin-cli-events');
return Promise["try"](function() { return Promise["try"](function() {
if (options.device) { if (options.device) {
return resin.models.environmentVariables.device.update(params.id, params.value).then(function() { return resin.models.environmentVariables.device.update(params.id, params.value).then(function() {

View File

@ -1,13 +1,11 @@
(function() { (function() {
var packageJSON;
packageJSON = require('../../package.json');
exports.version = { exports.version = {
signature: 'version', signature: 'version',
description: 'output the version number', description: 'output the version number',
help: 'Display the Resin CLI version.', help: 'Display the Resin CLI version.',
action: function(params, options, done) { action: function(params, options, done) {
var packageJSON;
packageJSON = require('../../package.json');
console.log(packageJSON.version); console.log(packageJSON.version);
return done(); return done();
} }

View File

@ -1,30 +1,17 @@
(function() { (function() {
var Promise, _, capitano, commandOptions, events, fs, patterns, resin, visuals; var commandOptions;
Promise = require('bluebird');
fs = Promise.promisifyAll(require('fs'));
_ = require('lodash');
resin = require('resin-sdk');
capitano = require('capitano');
visuals = require('resin-cli-visuals');
events = require('resin-cli-events');
commandOptions = require('./command-options'); commandOptions = require('./command-options');
patterns = require('../utils/patterns');
exports.list = { exports.list = {
signature: 'keys', signature: 'keys',
description: 'list all ssh keys', description: 'list all ssh keys',
help: 'Use this command to list all your SSH keys.\n\nExamples:\n\n $ resin keys', help: 'Use this command to list all your SSH keys.\n\nExamples:\n\n $ resin keys',
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var resin, visuals;
resin = require('resin-sdk');
visuals = require('resin-cli-visuals');
return resin.models.key.getAll().then(function(keys) { return resin.models.key.getAll().then(function(keys) {
return console.log(visuals.table.horizontal(keys, ['id', 'title'])); return console.log(visuals.table.horizontal(keys, ['id', 'title']));
}).nodeify(done); }).nodeify(done);
@ -37,6 +24,9 @@
help: 'Use this command to show information about a single SSH key.\n\nExamples:\n\n $ resin key 17', help: 'Use this command to show information about a single SSH key.\n\nExamples:\n\n $ resin key 17',
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var resin, visuals;
resin = require('resin-sdk');
visuals = require('resin-cli-visuals');
return resin.models.key.get(params.id).then(function(key) { return resin.models.key.get(params.id).then(function(key) {
console.log(visuals.table.vertical(key, ['id', 'title'])); console.log(visuals.table.vertical(key, ['id', 'title']));
return console.log('\n' + key.public_key); return console.log('\n' + key.public_key);
@ -51,6 +41,10 @@
options: [commandOptions.yes], options: [commandOptions.yes],
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var events, patterns, resin;
resin = require('resin-sdk');
events = require('resin-cli-events');
patterns = require('../utils/patterns');
return patterns.confirm(options.yes, 'Are you sure you want to delete the key?').then(function() { return patterns.confirm(options.yes, 'Are you sure you want to delete the key?').then(function() {
return resin.models.key.remove(params.id); return resin.models.key.remove(params.id);
}).tap(function() { }).tap(function() {
@ -67,6 +61,13 @@
help: 'Use this command to associate a new SSH key with your account.\n\nIf `path` is omitted, the command will attempt\nto read the SSH key from stdin.\n\nExamples:\n\n $ resin key add Main ~/.ssh/id_rsa.pub\n $ cat ~/.ssh/id_rsa.pub | resin key add Main', help: 'Use this command to associate a new SSH key with your account.\n\nIf `path` is omitted, the command will attempt\nto read the SSH key from stdin.\n\nExamples:\n\n $ resin key add Main ~/.ssh/id_rsa.pub\n $ cat ~/.ssh/id_rsa.pub | resin key add Main',
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var Promise, _, capitano, events, fs, resin;
_ = require('lodash');
Promise = require('bluebird');
fs = Promise.promisifyAll(require('fs'));
capitano = require('capitano');
resin = require('resin-sdk');
events = require('resin-cli-events');
return Promise["try"](function() { return Promise["try"](function() {
if (params.path != null) { if (params.path != null) {
return fs.readFileAsync(params.path, { return fs.readFileAsync(params.path, {

View File

@ -1,10 +1,4 @@
(function() { (function() {
var _, resin;
_ = require('lodash');
resin = require('resin-sdk');
module.exports = { module.exports = {
signature: 'logs <uuid>', signature: 'logs <uuid>',
description: 'show device logs', description: 'show device logs',
@ -20,7 +14,9 @@
permission: 'user', permission: 'user',
primary: true, primary: true,
action: function(params, options, done) { action: function(params, options, done) {
var promise; var _, promise, resin;
_ = require('lodash');
resin = require('resin-sdk');
promise = resin.logs.history(params.uuid).each(function(line) { promise = resin.logs.history(params.uuid).each(function(line) {
return console.log(line.message); return console.log(line.message);
}); });

View File

@ -1,12 +1,4 @@
(function() { (function() {
var Promise, _, resin;
Promise = require('bluebird');
_ = require('lodash');
resin = require('resin-sdk');
exports.set = { exports.set = {
signature: 'note <|note>', signature: 'note <|note>',
description: 'set a device note', description: 'set a device note',
@ -22,6 +14,10 @@
], ],
permission: 'user', permission: 'user',
action: function(params, options, done) { action: function(params, options, done) {
var Promise, _, resin;
Promise = require('bluebird');
_ = require('lodash');
resin = require('resin-sdk');
return Promise["try"](function() { return Promise["try"](function() {
if (_.isEmpty(params.note)) { if (_.isEmpty(params.note)) {
throw new Error('Missing note content'); throw new Error('Missing note content');

View File

@ -1,34 +1,8 @@
(function() { (function() {
var Promise, _, commandOptions, form, fs, helpers, init, manager, patterns, resin, rindle, stepHandler, umount, unzip, visuals; var commandOptions, stepHandler;
fs = require('fs');
_ = require('lodash');
Promise = require('bluebird');
umount = Promise.promisifyAll(require('umount'));
unzip = require('unzip2');
rindle = require('rindle');
resin = require('resin-sdk');
manager = require('resin-image-manager');
visuals = require('resin-cli-visuals');
form = require('resin-cli-form');
init = require('resin-device-init');
commandOptions = require('./command-options'); commandOptions = require('./command-options');
helpers = require('../utils/helpers');
patterns = require('../utils/patterns');
exports.download = { exports.download = {
signature: 'os download <type>', signature: 'os download <type>',
description: 'download an unconfigured os image', description: 'download an unconfigured os image',
@ -44,6 +18,12 @@
} }
], ],
action: function(params, options, done) { action: function(params, options, done) {
var fs, manager, rindle, unzip, visuals;
unzip = require('unzip2');
fs = require('fs');
rindle = require('rindle');
manager = require('resin-image-manager');
visuals = require('resin-cli-visuals');
console.info("Getting device operating system for " + params.type); console.info("Getting device operating system for " + params.type);
return manager.get(params.type).then(function(stream) { return manager.get(params.type).then(function(stream) {
var bar, output, spinner; var bar, output, spinner;
@ -74,7 +54,11 @@
}; };
stepHandler = function(step) { stepHandler = function(step) {
var bar; var _, bar, helpers, rindle, visuals;
_ = require('lodash');
rindle = require('rindle');
visuals = require('resin-cli-visuals');
helpers = require('../utils/helpers');
step.on('stdout', _.bind(process.stdout.write, process.stdout)); step.on('stdout', _.bind(process.stdout.write, process.stdout));
step.on('stderr', _.bind(process.stderr.write, process.stderr)); step.on('stderr', _.bind(process.stderr.write, process.stderr));
step.on('state', function(state) { step.on('state', function(state) {
@ -102,6 +86,12 @@
} }
], ],
action: function(params, options, done) { action: function(params, options, done) {
var _, form, helpers, init, resin;
_ = require('lodash');
resin = require('resin-sdk');
form = require('resin-cli-form');
init = require('resin-device-init');
helpers = require('../utils/helpers');
console.info('Configuring operating system image'); console.info('Configuring operating system image');
return resin.models.device.get(params.uuid).get('device_type').then(resin.models.device.getManifestBySlug).get('options').then(function(questions) { return resin.models.device.get(params.uuid).get('device_type').then(resin.models.device.getManifestBySlug).get('options').then(function(questions) {
var advancedGroup, override; var advancedGroup, override;
@ -144,6 +134,13 @@
], ],
root: true, root: true,
action: function(params, options, done) { action: function(params, options, done) {
var Promise, form, init, patterns, resin, umount;
Promise = require('bluebird');
umount = Promise.promisifyAll(require('umount'));
resin = require('resin-sdk');
form = require('resin-cli-form');
init = require('resin-device-init');
patterns = require('../utils/patterns');
console.info('Initializing device'); console.info('Initializing device');
return resin.models.device.getManifestBySlug(options.type).then(function(manifest) { return resin.models.device.getManifestBySlug(options.type).then(function(manifest) {
var ref; var ref;

View File

@ -1,15 +1,12 @@
(function() { (function() {
var prettyjson, resin;
resin = require('resin-sdk');
prettyjson = require('prettyjson');
exports.list = { exports.list = {
signature: 'settings', signature: 'settings',
description: 'print current settings', description: 'print current settings',
help: 'Use this command to display detected settings\n\nExamples:\n\n $ resin settings', help: 'Use this command to display detected settings\n\nExamples:\n\n $ resin settings',
action: function(params, options, done) { action: function(params, options, done) {
var prettyjson, resin;
resin = require('resin-sdk');
prettyjson = require('prettyjson');
return resin.settings.getAll().then(prettyjson.render).then(console.log).nodeify(done); return resin.settings.getAll().then(prettyjson.render).then(console.log).nodeify(done);
} }
}; };

View File

@ -1,14 +1,4 @@
(function() { (function() {
var Promise, capitano, patterns, resin;
Promise = require('bluebird');
capitano = Promise.promisifyAll(require('capitano'));
resin = require('resin-sdk');
patterns = require('../utils/patterns');
exports.wizard = { exports.wizard = {
signature: 'quickstart [name]', signature: 'quickstart [name]',
description: 'getting started with resin.io', description: 'getting started with resin.io',
@ -16,6 +6,11 @@
permission: 'user', permission: 'user',
primary: true, primary: true,
action: function(params, options, done) { action: function(params, options, done) {
var Promise, capitano, patterns, resin;
Promise = require('bluebird');
capitano = Promise.promisifyAll(require('capitano'));
resin = require('resin-sdk');
patterns = require('../utils/patterns');
return Promise["try"](function() { return Promise["try"](function() {
if (params.name != null) { if (params.name != null) {
return; return;

View File

@ -1,8 +1,4 @@
resin = require('resin-sdk')
visuals = require('resin-cli-visuals')
commandOptions = require('./command-options') commandOptions = require('./command-options')
events = require('resin-cli-events')
patterns = require('../utils/patterns')
exports.create = exports.create =
signature: 'app create <name>' signature: 'app create <name>'
@ -33,6 +29,9 @@ exports.create =
permission: 'user' permission: 'user'
primary: true primary: true
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
events = require('resin-cli-events')
patterns = require('../utils/patterns')
# Validate the the application name is available # Validate the the application name is available
# before asking the device type. # before asking the device type.
@ -66,6 +65,9 @@ exports.list =
permission: 'user' permission: 'user'
primary: true primary: true
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
visuals = require('resin-cli-visuals')
resin.models.application.getAll().then (applications) -> resin.models.application.getAll().then (applications) ->
console.log visuals.table.horizontal applications, [ console.log visuals.table.horizontal applications, [
'id' 'id'
@ -89,6 +91,10 @@ exports.info =
permission: 'user' permission: 'user'
primary: true primary: true
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
visuals = require('resin-cli-visuals')
events = require('resin-cli-events')
resin.models.application.get(params.name).then (application) -> resin.models.application.get(params.name).then (application) ->
console.log visuals.table.vertical application, [ console.log visuals.table.vertical application, [
"$#{application.app_name}$" "$#{application.app_name}$"
@ -112,6 +118,7 @@ exports.restart =
''' '''
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
resin.models.application.restart(params.name).nodeify(done) resin.models.application.restart(params.name).nodeify(done)
exports.remove = exports.remove =
@ -131,6 +138,10 @@ exports.remove =
options: [ commandOptions.yes ] options: [ commandOptions.yes ]
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
events = require('resin-cli-events')
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the application?').then -> patterns.confirm(options.yes, 'Are you sure you want to delete the application?').then ->
resin.models.application.remove(params.name) resin.models.application.remove(params.name)
.tap -> .tap ->

View File

@ -1,12 +1,3 @@
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk')
form = require('resin-cli-form')
visuals = require('resin-cli-visuals')
events = require('resin-cli-events')
auth = require('resin-cli-auth')
validation = require('../utils/validation')
exports.login = exports.login =
signature: 'login' signature: 'login'
description: 'login to resin.io' description: 'login to resin.io'
@ -33,6 +24,11 @@ exports.login =
] ]
primary: true primary: true
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk')
events = require('resin-cli-events')
auth = require('resin-cli-auth')
Promise.try -> Promise.try ->
if options.token? if options.token?
return resin.auth.loginWithToken(options.token) return resin.auth.loginWithToken(options.token)
@ -57,6 +53,9 @@ exports.logout =
''' '''
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
events = require('resin-cli-events')
resin.auth.logout().then -> resin.auth.logout().then ->
events.send('user.logout') events.send('user.logout')
.nodeify(done) .nodeify(done)
@ -80,6 +79,11 @@ exports.signup =
johndoe johndoe
''' '''
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
form = require('resin-cli-form')
events = require('resin-cli-events')
validation = require('../utils/validation')
form.run [ form.run [
message: 'Email:' message: 'Email:'
name: 'email' name: 'email'
@ -114,6 +118,10 @@ exports.whoami =
''' '''
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk')
visuals = require('resin-cli-visuals')
Promise.props Promise.props
username: resin.auth.whoami() username: resin.auth.whoami()
email: resin.auth.getEmail() email: resin.auth.getEmail()

View File

@ -1,11 +1,3 @@
_ = require('lodash')
Promise = require('bluebird')
capitano = Promise.promisifyAll(require('capitano'))
umount = Promise.promisifyAll(require('umount'))
visuals = require('resin-cli-visuals')
config = require('resin-config-json')
prettyjson = require('prettyjson')
exports.read = exports.read =
signature: 'config read' signature: 'config read'
description: 'read a device configuration' description: 'read a device configuration'
@ -35,6 +27,12 @@ exports.read =
permission: 'user' permission: 'user'
root: true root: true
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
config = require('resin-config-json')
visuals = require('resin-cli-visuals')
umount = Promise.promisifyAll(require('umount'))
prettyjson = require('prettyjson')
Promise.try -> Promise.try ->
return options.drive or visuals.drive('Select the device drive') return options.drive or visuals.drive('Select the device drive')
.tap(umount.umountAsync) .tap(umount.umountAsync)
@ -74,6 +72,12 @@ exports.write =
permission: 'user' permission: 'user'
root: true root: true
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
_ = require('lodash')
config = require('resin-config-json')
visuals = require('resin-cli-visuals')
umount = Promise.promisifyAll(require('umount'))
Promise.try -> Promise.try ->
return options.drive or visuals.drive('Select the device drive') return options.drive or visuals.drive('Select the device drive')
.tap(umount.umountAsync) .tap(umount.umountAsync)
@ -126,6 +130,12 @@ exports.reconfigure =
permission: 'user' permission: 'user'
root: true root: true
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
config = require('resin-config-json')
visuals = require('resin-cli-visuals')
capitano = Promise.promisifyAll(require('capitano'))
umount = Promise.promisifyAll(require('umount'))
Promise.try -> Promise.try ->
return options.drive or visuals.drive('Select the device drive') return options.drive or visuals.drive('Select the device drive')
.tap(umount.umountAsync) .tap(umount.umountAsync)

View File

@ -1,16 +1,3 @@
Promise = require('bluebird')
capitano = Promise.promisifyAll(require('capitano'))
_ = require('lodash')
resin = require('resin-sdk')
visuals = require('resin-cli-visuals')
form = require('resin-cli-form')
events = require('resin-cli-events')
rimraf = Promise.promisify(require('rimraf'))
patterns = require('../utils/patterns')
helpers = require('../utils/helpers')
tmp = Promise.promisifyAll(require('tmp'))
tmp.setGracefulCleanup()
commandOptions = require('./command-options') commandOptions = require('./command-options')
exports.list = exports.list =
@ -32,6 +19,10 @@ exports.list =
permission: 'user' permission: 'user'
primary: true primary: true
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk')
visuals = require('resin-cli-visuals')
Promise.try -> Promise.try ->
if options.application? if options.application?
return resin.models.device.getAllByApplication(options.application) return resin.models.device.getAllByApplication(options.application)
@ -61,6 +52,10 @@ exports.info =
permission: 'user' permission: 'user'
primary: true primary: true
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
visuals = require('resin-cli-visuals')
events = require('resin-cli-events')
resin.models.device.get(params.uuid).then (device) -> resin.models.device.get(params.uuid).then (device) ->
# TODO: We should outsource this logic and probably # TODO: We should outsource this logic and probably
@ -104,6 +99,9 @@ exports.register =
alias: 'u' alias: 'u'
] ]
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk')
resin.models.application.get(params.application).then (application) -> resin.models.application.get(params.application).then (application) ->
Promise.try -> Promise.try ->
@ -131,6 +129,10 @@ exports.remove =
options: [ commandOptions.yes ] options: [ commandOptions.yes ]
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
events = require('resin-cli-events')
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the device?').then -> patterns.confirm(options.yes, 'Are you sure you want to delete the device?').then ->
resin.models.device.remove(params.uuid) resin.models.device.remove(params.uuid)
.tap -> .tap ->
@ -151,6 +153,7 @@ exports.identify =
''' '''
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
resin.models.device.identify(params.uuid).nodeify(done) resin.models.device.identify(params.uuid).nodeify(done)
exports.rename = exports.rename =
@ -168,6 +171,12 @@ exports.rename =
''' '''
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk')
events = require('resin-cli-events')
form = require('resin-cli-form')
Promise.try -> Promise.try ->
return params.newName if not _.isEmpty(params.newName) return params.newName if not _.isEmpty(params.newName)
@ -196,6 +205,10 @@ exports.move =
permission: 'user' permission: 'user'
options: [ commandOptions.optionalApplication ] options: [ commandOptions.optionalApplication ]
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
_ = require('lodash')
patterns = require('../utils/patterns')
resin.models.device.get(params.uuid).then (device) -> resin.models.device.get(params.uuid).then (device) ->
return options.application or patterns.selectApplication (application) -> return options.application or patterns.selectApplication (application) ->
return _.all [ return _.all [
@ -235,6 +248,16 @@ exports.init =
permission: 'user' permission: 'user'
primary: true primary: true
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
capitano = Promise.promisifyAll(require('capitano'))
rimraf = Promise.promisify(require('rimraf'))
tmp = Promise.promisifyAll(require('tmp'))
tmp.setGracefulCleanup()
resin = require('resin-sdk')
helpers = require('../utils/helpers')
patterns = require('../utils/patterns')
Promise.try -> Promise.try ->
return options.application if options.application? return options.application if options.application?
return patterns.selectApplication() return patterns.selectApplication()

View File

@ -1,10 +1,4 @@
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk')
visuals = require('resin-cli-visuals')
events = require('resin-cli-events')
commandOptions = require('./command-options') commandOptions = require('./command-options')
patterns = require('../utils/patterns')
exports.list = exports.list =
signature: 'envs' signature: 'envs'
@ -36,6 +30,11 @@ exports.list =
] ]
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk')
visuals = require('resin-cli-visuals')
Promise.try -> Promise.try ->
if options.application? if options.application?
return resin.models.environmentVariables.getAllByApplication(options.application) return resin.models.environmentVariables.getAllByApplication(options.application)
@ -83,6 +82,10 @@ exports.remove =
] ]
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
events = require('resin-cli-events')
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the environment variable?').then -> patterns.confirm(options.yes, 'Are you sure you want to delete the environment variable?').then ->
if options.device if options.device
resin.models.environmentVariables.device.remove(params.id) resin.models.environmentVariables.device.remove(params.id)
@ -119,6 +122,10 @@ exports.add =
] ]
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk')
events = require('resin-cli-events')
Promise.try -> Promise.try ->
if not params.value? if not params.value?
params.value = process.env[params.key] params.value = process.env[params.key]
@ -155,6 +162,10 @@ exports.rename =
permission: 'user' permission: 'user'
options: [ commandOptions.booleanDevice ] options: [ commandOptions.booleanDevice ]
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk')
events = require('resin-cli-events')
Promise.try -> Promise.try ->
if options.device if options.device
resin.models.environmentVariables.device.update(params.id, params.value).then -> resin.models.environmentVariables.device.update(params.id, params.value).then ->

View File

@ -1,5 +1,3 @@
packageJSON = require('../../package.json')
exports.version = exports.version =
signature: 'version' signature: 'version'
description: 'output the version number' description: 'output the version number'
@ -7,5 +5,6 @@ exports.version =
Display the Resin CLI version. Display the Resin CLI version.
''' '''
action: (params, options, done) -> action: (params, options, done) ->
packageJSON = require('../../package.json')
console.log(packageJSON.version) console.log(packageJSON.version)
return done() return done()

View File

@ -1,12 +1,4 @@
Promise = require('bluebird')
fs = Promise.promisifyAll(require('fs'))
_ = require('lodash')
resin = require('resin-sdk')
capitano = require('capitano')
visuals = require('resin-cli-visuals')
events = require('resin-cli-events')
commandOptions = require('./command-options') commandOptions = require('./command-options')
patterns = require('../utils/patterns')
exports.list = exports.list =
signature: 'keys' signature: 'keys'
@ -20,6 +12,9 @@ exports.list =
''' '''
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
visuals = require('resin-cli-visuals')
resin.models.key.getAll().then (keys) -> resin.models.key.getAll().then (keys) ->
console.log visuals.table.horizontal keys, [ console.log visuals.table.horizontal keys, [
'id' 'id'
@ -39,6 +34,9 @@ exports.info =
''' '''
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
visuals = require('resin-cli-visuals')
resin.models.key.get(params.id).then (key) -> resin.models.key.get(params.id).then (key) ->
console.log visuals.table.vertical key, [ console.log visuals.table.vertical key, [
'id' 'id'
@ -68,6 +66,10 @@ exports.remove =
options: [ commandOptions.yes ] options: [ commandOptions.yes ]
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
events = require('resin-cli-events')
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the key?').then -> patterns.confirm(options.yes, 'Are you sure you want to delete the key?').then ->
resin.models.key.remove(params.id) resin.models.key.remove(params.id)
.tap -> .tap ->
@ -90,6 +92,13 @@ exports.add =
''' '''
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
_ = require('lodash')
Promise = require('bluebird')
fs = Promise.promisifyAll(require('fs'))
capitano = require('capitano')
resin = require('resin-sdk')
events = require('resin-cli-events')
Promise.try -> Promise.try ->
return fs.readFileAsync(params.path, encoding: 'utf8') if params.path? return fs.readFileAsync(params.path, encoding: 'utf8') if params.path?

View File

@ -1,6 +1,3 @@
_ = require('lodash')
resin = require('resin-sdk')
module.exports = module.exports =
signature: 'logs <uuid>' signature: 'logs <uuid>'
description: 'show device logs' description: 'show device logs'
@ -31,6 +28,9 @@ module.exports =
permission: 'user' permission: 'user'
primary: true primary: true
action: (params, options, done) -> action: (params, options, done) ->
_ = require('lodash')
resin = require('resin-sdk')
promise = resin.logs.history(params.uuid).each (line) -> promise = resin.logs.history(params.uuid).each (line) ->
console.log(line.message) console.log(line.message)

View File

@ -1,7 +1,3 @@
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk')
exports.set = exports.set =
signature: 'note <|note>' signature: 'note <|note>'
description: 'set a device note' description: 'set a device note'
@ -26,6 +22,10 @@ exports.set =
] ]
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk')
Promise.try -> Promise.try ->
if _.isEmpty(params.note) if _.isEmpty(params.note)
throw new Error('Missing note content') throw new Error('Missing note content')

View File

@ -1,17 +1,4 @@
fs = require('fs')
_ = require('lodash')
Promise = require('bluebird')
umount = Promise.promisifyAll(require('umount'))
unzip = require('unzip2')
rindle = require('rindle')
resin = require('resin-sdk')
manager = require('resin-image-manager')
visuals = require('resin-cli-visuals')
form = require('resin-cli-form')
init = require('resin-device-init')
commandOptions = require('./command-options') commandOptions = require('./command-options')
helpers = require('../utils/helpers')
patterns = require('../utils/patterns')
exports.download = exports.download =
signature: 'os download <type>' signature: 'os download <type>'
@ -32,6 +19,12 @@ exports.download =
required: 'You have to specify an output location' required: 'You have to specify an output location'
] ]
action: (params, options, done) -> action: (params, options, done) ->
unzip = require('unzip2')
fs = require('fs')
rindle = require('rindle')
manager = require('resin-image-manager')
visuals = require('resin-cli-visuals')
console.info("Getting device operating system for #{params.type}") console.info("Getting device operating system for #{params.type}")
manager.get(params.type).then (stream) -> manager.get(params.type).then (stream) ->
@ -61,6 +54,11 @@ exports.download =
.nodeify(done) .nodeify(done)
stepHandler = (step) -> stepHandler = (step) ->
_ = require('lodash')
rindle = require('rindle')
visuals = require('resin-cli-visuals')
helpers = require('../utils/helpers')
step.on('stdout', _.bind(process.stdout.write, process.stdout)) step.on('stdout', _.bind(process.stdout.write, process.stdout))
step.on('stderr', _.bind(process.stderr.write, process.stderr)) step.on('stderr', _.bind(process.stderr.write, process.stderr))
@ -92,6 +90,12 @@ exports.configure =
alias: 'v' alias: 'v'
] ]
action: (params, options, done) -> action: (params, options, done) ->
_ = require('lodash')
resin = require('resin-sdk')
form = require('resin-cli-form')
init = require('resin-device-init')
helpers = require('../utils/helpers')
console.info('Configuring operating system image') console.info('Configuring operating system image')
resin.models.device.get(params.uuid) resin.models.device.get(params.uuid)
.get('device_type') .get('device_type')
@ -141,6 +145,13 @@ exports.initialize =
] ]
root: true root: true
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
umount = Promise.promisifyAll(require('umount'))
resin = require('resin-sdk')
form = require('resin-cli-form')
init = require('resin-device-init')
patterns = require('../utils/patterns')
console.info('Initializing device') console.info('Initializing device')
resin.models.device.getManifestBySlug(options.type) resin.models.device.getManifestBySlug(options.type)
.then (manifest) -> .then (manifest) ->

View File

@ -1,6 +1,3 @@
resin = require('resin-sdk')
prettyjson = require('prettyjson')
exports.list = exports.list =
signature: 'settings' signature: 'settings'
description: 'print current settings' description: 'print current settings'
@ -12,6 +9,9 @@ exports.list =
$ resin settings $ resin settings
''' '''
action: (params, options, done) -> action: (params, options, done) ->
resin = require('resin-sdk')
prettyjson = require('prettyjson')
resin.settings.getAll() resin.settings.getAll()
.then(prettyjson.render) .then(prettyjson.render)
.then(console.log) .then(console.log)

View File

@ -1,8 +1,3 @@
Promise = require('bluebird')
capitano = Promise.promisifyAll(require('capitano'))
resin = require('resin-sdk')
patterns = require('../utils/patterns')
exports.wizard = exports.wizard =
signature: 'quickstart [name]' signature: 'quickstart [name]'
description: 'getting started with resin.io' description: 'getting started with resin.io'
@ -24,6 +19,11 @@ exports.wizard =
permission: 'user' permission: 'user'
primary: true primary: true
action: (params, options, done) -> action: (params, options, done) ->
Promise = require('bluebird')
capitano = Promise.promisifyAll(require('capitano'))
resin = require('resin-sdk')
patterns = require('../utils/patterns')
Promise.try -> Promise.try ->
return if params.name? return if params.name?
patterns.selectOrCreateApplication().tap (applicationName) -> patterns.selectOrCreateApplication().tap (applicationName) ->