use the new SDK factory

This commit is contained in:
Eugene Mirotin 2016-12-16 17:34:05 +03:00 committed by Tim Perry
parent b690060bc4
commit f17cbb1205
No known key found for this signature in database
GPG Key ID: 0DDE38AFD3AF94F0
37 changed files with 119 additions and 175 deletions

View File

@ -37,7 +37,7 @@ limitations under the License.
primary: true,
action: function(params, options, done) {
var patterns, resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
patterns = require('../utils/patterns');
return resin.models.application.has(params.name).then(function(hasApplication) {
if (hasApplication) {
@ -61,7 +61,7 @@ limitations under the License.
primary: true,
action: function(params, options, done) {
var resin, visuals;
resin = require('resin-sdk');
resin = require('../resin-sdk');
visuals = require('resin-cli-visuals');
return resin.models.application.getAll().then(function(applications) {
return console.log(visuals.table.horizontal(applications, ['id', 'app_name', 'device_type', 'online_devices', 'devices_length']));
@ -77,7 +77,7 @@ limitations under the License.
primary: true,
action: function(params, options, done) {
var resin, visuals;
resin = require('resin-sdk');
resin = require('../resin-sdk');
visuals = require('resin-cli-visuals');
return resin.models.application.get(params.name).then(function(application) {
return console.log(visuals.table.vertical(application, ["$" + application.app_name + "$", 'id', 'device_type', 'git_repository', 'commit']));
@ -92,7 +92,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
return resin.models.application.restart(params.name).nodeify(done);
}
};
@ -105,7 +105,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var patterns, resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
patterns = require('../utils/patterns');
return patterns.confirm(options.yes, 'Are you sure you want to delete the application?').then(function() {
return resin.models.application.remove(params.name);

View File

@ -55,7 +55,7 @@ limitations under the License.
_ = require('lodash');
Promise = require('bluebird');
capitano = Promise.promisifyAll(require('capitano'));
resin = require('resin-sdk');
resin = require('../resin-sdk');
auth = require('resin-cli-auth');
form = require('resin-cli-form');
patterns = require('../utils/patterns');
@ -104,7 +104,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
return resin.auth.logout().nodeify(done);
}
};
@ -115,7 +115,7 @@ limitations under the License.
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) {
var form, resin, validation;
resin = require('resin-sdk');
resin = require('../resin-sdk');
form = require('resin-cli-form');
validation = require('../utils/validation');
return resin.settings.get('resinUrl').then(function(resinUrl) {
@ -149,7 +149,7 @@ limitations under the License.
action: function(params, options, done) {
var Promise, resin, visuals;
Promise = require('bluebird');
resin = require('resin-sdk');
resin = require('../resin-sdk');
visuals = require('resin-cli-visuals');
return Promise.props({
username: resin.auth.whoami(),

View File

@ -210,7 +210,7 @@ limitations under the License.
var Promise, _, deviceConfig, form, fs, prettyjson, resin;
Promise = require('bluebird');
fs = Promise.promisifyAll(require('fs'));
resin = require('resin-sdk');
resin = require('../resin-sdk');
_ = require('lodash');
form = require('resin-cli-form');
deviceConfig = require('resin-device-config');

View File

@ -32,7 +32,7 @@ limitations under the License.
var Promise, _, resin, visuals;
Promise = require('bluebird');
_ = require('lodash');
resin = require('resin-sdk');
resin = require('../resin-sdk');
visuals = require('resin-cli-visuals');
return Promise["try"](function() {
if (options.application != null) {
@ -57,7 +57,7 @@ limitations under the License.
primary: true,
action: function(params, options, done) {
var resin, visuals;
resin = require('resin-sdk');
resin = require('../resin-sdk');
visuals = require('resin-cli-visuals');
return resin.models.device.get(params.uuid).then(function(device) {
return resin.models.device.getStatus(device).then(function(status) {
@ -75,7 +75,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
return resin.models.config.getDeviceTypes().each(function(deviceType) {
return console.log(deviceType.slug);
}).nodeify(done);
@ -98,7 +98,7 @@ limitations under the License.
action: function(params, options, done) {
var Promise, resin;
Promise = require('bluebird');
resin = require('resin-sdk');
resin = require('../resin-sdk');
return resin.models.application.get(params.application).then(function(application) {
return Promise["try"](function() {
return options.uuid || resin.models.device.generateUUID();
@ -118,7 +118,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var patterns, resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
patterns = require('../utils/patterns');
return patterns.confirm(options.yes, 'Are you sure you want to delete the device?').then(function() {
return resin.models.device.remove(params.uuid);
@ -133,7 +133,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
return resin.models.device.identify(params.uuid).nodeify(done);
}
};
@ -146,7 +146,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
return resin.models.device.reboot(params.uuid, options).nodeify(done);
}
};
@ -159,7 +159,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
return resin.models.device.shutdown(params.uuid, options).nodeify(done);
}
};
@ -171,7 +171,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
return resin.models.device.enableDeviceUrl(params.uuid).nodeify(done);
}
};
@ -183,7 +183,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
return resin.models.device.disableDeviceUrl(params.uuid).nodeify(done);
}
};
@ -195,7 +195,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
return resin.models.device.getDeviceUrl(params.uuid).then(function(url) {
return console.log(url);
}).nodeify(done);
@ -209,7 +209,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
return resin.models.device.hasDeviceUrl(params.uuid).then(function(hasDeviceUrl) {
return console.log(hasDeviceUrl);
}).nodeify(done);
@ -225,7 +225,7 @@ limitations under the License.
var Promise, _, form, resin;
Promise = require('bluebird');
_ = require('lodash');
resin = require('resin-sdk');
resin = require('../resin-sdk');
form = require('resin-cli-form');
return Promise["try"](function() {
if (!_.isEmpty(params.newName)) {
@ -247,7 +247,7 @@ limitations under the License.
options: [commandOptions.optionalApplication],
action: function(params, options, done) {
var _, patterns, resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
_ = require('lodash');
patterns = require('../utils/patterns');
return resin.models.device.get(params.uuid).then(function(device) {
@ -282,7 +282,7 @@ limitations under the License.
rimraf = Promise.promisify(require('rimraf'));
tmp = Promise.promisifyAll(require('tmp'));
tmp.setGracefulCleanup();
resin = require('resin-sdk');
resin = require('../resin-sdk');
helpers = require('../utils/helpers');
patterns = require('../utils/patterns');
return Promise["try"](function() {

View File

@ -1,87 +0,0 @@
/*
Copyright 2016 Resin.io
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
(function() {
var getSubShellCommand;
getSubShellCommand = function(command) {
var os;
os = require('os');
if (os.platform() === 'win32') {
return {
program: 'sh',
args: ['-c', command]
};
} else {
return {
program: '/bin/sh',
args: ['-c', command]
};
}
};
module.exports = {
signature: 'enter <uuid>',
description: '(beta) get a shell into the running app container of a device',
help: 'Use this command to get a shell into the running application container of\nyour device.\n\nExamples:\n\n $ resin enter 7cf02a6\n $ resin enter 7cf02a6 --port 8080',
permission: 'user',
primary: true,
options: [
{
signature: 'port',
parameter: 'port',
description: 'ssh port',
alias: 't'
}
],
action: function(params, options, done) {
var Promise, child_process, resin, settings;
child_process = require('child_process');
Promise = require('bluebird');
resin = require('resin-sdk');
settings = require('resin-settings-client');
if (options.port == null) {
options.port = 22;
}
console.info("Connecting with: " + params.uuid);
return Promise.props({
isOnline: resin.models.device.isOnline(params.uuid),
username: resin.auth.whoami(),
uuid: resin.models.device.get(params.uuid).get('uuid'),
containerId: resin.models.device.getApplicationInfo(params.uuid).get('containerId')
}).then(function(arg) {
var containerId, isOnline, username, uuid;
isOnline = arg.isOnline, username = arg.username, uuid = arg.uuid, containerId = arg.containerId;
if (!isOnline) {
throw new Error('Device is not online');
}
if (containerId == null) {
throw new Error('Did not find running application container');
}
return Promise["try"](function() {
var command, spawn, subShellCommand;
command = "ssh -t -p " + options.port + " " + username + "@" + (settings.get('proxyUrl')) + " enter " + uuid + " " + containerId;
subShellCommand = getSubShellCommand(command);
return spawn = child_process.spawn(subShellCommand.program, subShellCommand.args, {
stdio: 'inherit'
});
});
});
}
};
}).call(this);

View File

@ -38,7 +38,7 @@ limitations under the License.
var Promise, _, resin, visuals;
Promise = require('bluebird');
_ = require('lodash');
resin = require('resin-sdk');
resin = require('../resin-sdk');
visuals = require('resin-cli-visuals');
return Promise["try"](function() {
if (options.application != null) {
@ -70,7 +70,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var patterns, resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
patterns = require('../utils/patterns');
return patterns.confirm(options.yes, 'Are you sure you want to delete the environment variable?').then(function() {
if (options.device) {
@ -91,7 +91,7 @@ limitations under the License.
action: function(params, options, done) {
var Promise, resin;
Promise = require('bluebird');
resin = require('resin-sdk');
resin = require('../resin-sdk');
return Promise["try"](function() {
if (params.value == null) {
params.value = process.env[params.key];
@ -121,7 +121,7 @@ limitations under the License.
action: function(params, options, done) {
var Promise, resin;
Promise = require('bluebird');
resin = require('resin-sdk');
resin = require('../resin-sdk');
return Promise["try"](function() {
if (options.device) {
return resin.models.environmentVariables.device.update(params.id, params.value);

View File

@ -28,7 +28,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin, visuals;
resin = require('resin-sdk');
resin = require('../resin-sdk');
visuals = require('resin-cli-visuals');
return resin.models.key.getAll().then(function(keys) {
return console.log(visuals.table.horizontal(keys, ['id', 'title']));
@ -43,7 +43,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var resin, visuals;
resin = require('resin-sdk');
resin = require('../resin-sdk');
visuals = require('resin-cli-visuals');
return resin.models.key.get(params.id).then(function(key) {
console.log(visuals.table.vertical(key, ['id', 'title']));
@ -60,7 +60,7 @@ limitations under the License.
permission: 'user',
action: function(params, options, done) {
var patterns, resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
patterns = require('../utils/patterns');
return patterns.confirm(options.yes, 'Are you sure you want to delete the key?').then(function() {
return resin.models.key.remove(params.id);
@ -79,7 +79,7 @@ limitations under the License.
Promise = require('bluebird');
fs = Promise.promisifyAll(require('fs'));
capitano = require('capitano');
resin = require('resin-sdk');
resin = require('../resin-sdk');
return Promise["try"](function() {
if (params.path != null) {
return fs.readFileAsync(params.path, {

View File

@ -34,7 +34,7 @@ limitations under the License.
action: function(params, options, done) {
var _, moment, printLine, promise, resin;
_ = require('lodash');
resin = require('resin-sdk');
resin = require('../resin-sdk');
moment = require('moment');
printLine = function(line) {
var timestamp;

View File

@ -35,7 +35,7 @@ limitations under the License.
var Promise, _, resin;
Promise = require('bluebird');
_ = require('lodash');
resin = require('resin-sdk');
resin = require('../resin-sdk');
return Promise["try"](function() {
if (_.isEmpty(params.note)) {
throw new Error('Missing note content');

View File

@ -106,7 +106,7 @@ limitations under the License.
action: function(params, options, done) {
var _, form, helpers, init, resin;
_ = require('lodash');
resin = require('resin-sdk');
resin = require('../resin-sdk');
form = require('resin-cli-form');
init = require('resin-device-init');
helpers = require('../utils/helpers');

View File

@ -23,7 +23,7 @@ limitations under the License.
help: 'Use this command to display detected settings\n\nExamples:\n\n $ resin settings',
action: function(params, options, done) {
var prettyjson, resin;
resin = require('resin-sdk');
resin = require('../resin-sdk');
prettyjson = require('prettyjson');
return resin.settings.getAll().then(prettyjson.render).then(console.log).nodeify(done);
}

View File

@ -58,7 +58,7 @@ limitations under the License.
var Promise, child_process, patterns, resin, settings, verbose;
child_process = require('child_process');
Promise = require('bluebird');
resin = require('resin-sdk');
resin = require('../resin-sdk');
settings = require('resin-settings-client');
patterns = require('../utils/patterns');
if (options.port == null) {

View File

@ -101,7 +101,7 @@ limitations under the License.
var Promise, fs, path, patterns, resin, resinSync;
fs = require('fs');
path = require('path');
resin = require('resin-sdk');
resin = require('../resin-sdk');
Promise = require('bluebird');
resinSync = require('resin-sync');
patterns = require('../utils/patterns');

View File

@ -26,7 +26,7 @@ limitations under the License.
var Promise, capitano, patterns, resin;
Promise = require('bluebird');
capitano = Promise.promisifyAll(require('capitano'));
resin = require('resin-sdk');
resin = require('../resin-sdk');
patterns = require('../utils/patterns');
return resin.auth.isLoggedIn().then(function(isLoggedIn) {
if (isLoggedIn) {

View File

@ -25,7 +25,7 @@ limitations under the License.
capitano = Promise.promisifyAll(require('capitano'));
resin = require('resin-sdk');
resin = require('./resin-sdk');
actions = require('./actions');

View File

@ -8,7 +8,7 @@
Promise = require('bluebird');
resin = require('resin-sdk');
resin = require('./resin-sdk');
capitanoState = Promise.promisifyAll(require('capitano').state);

18
build/resin-sdk.js Normal file
View File

@ -0,0 +1,18 @@
(function() {
var getSdk, opts, settings;
getSdk = require('resin-sdk');
settings = require('resin-settings-client');
opts = {
apiUrl: settings.get('apiUrl'),
imageMakerUrl: settings.get('imageMakerUrl'),
dataDirectory: settings.get('dataDirectory'),
apiVersion: 'v2',
retries: 2
};
module.exports = getSdk(opts);
}).call(this);

View File

@ -29,7 +29,7 @@ limitations under the License.
president = Promise.promisifyAll(require('president'));
resin = require('resin-sdk');
resin = require('./resin-sdk');
imagefs = require('resin-image-fs');

View File

@ -28,7 +28,7 @@ limitations under the License.
visuals = require('resin-cli-visuals');
resin = require('resin-sdk');
resin = require('./resin-sdk');
chalk = require('chalk');

View File

@ -45,7 +45,7 @@ exports.create =
permission: 'user'
primary: true
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
patterns = require('../utils/patterns')
# Validate the the application name is available
@ -79,7 +79,7 @@ exports.list =
permission: 'user'
primary: true
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
visuals = require('resin-cli-visuals')
resin.models.application.getAll().then (applications) ->
@ -105,7 +105,7 @@ exports.info =
permission: 'user'
primary: true
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
visuals = require('resin-cli-visuals')
resin.models.application.get(params.name).then (application) ->
@ -130,7 +130,7 @@ exports.restart =
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
resin.models.application.restart(params.name).nodeify(done)
exports.remove =
@ -150,7 +150,7 @@ exports.remove =
options: [ commandOptions.yes ]
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the application?').then ->

View File

@ -74,7 +74,7 @@ exports.login =
_ = require('lodash')
Promise = require('bluebird')
capitano = Promise.promisifyAll(require('capitano'))
resin = require('resin-sdk')
resin = require('../resin-sdk')
auth = require('resin-cli-auth')
form = require('resin-cli-form')
patterns = require('../utils/patterns')
@ -136,7 +136,7 @@ exports.logout =
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
resin.auth.logout().nodeify(done)
exports.signup =
@ -158,7 +158,7 @@ exports.signup =
johndoe
'''
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
form = require('resin-cli-form')
validation = require('../utils/validation')
@ -198,7 +198,7 @@ exports.whoami =
permission: 'user'
action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk')
resin = require('../resin-sdk')
visuals = require('resin-cli-visuals')
Promise.props

View File

@ -242,7 +242,7 @@ exports.generate =
action: (params, options, done) ->
Promise = require('bluebird')
fs = Promise.promisifyAll(require('fs'))
resin = require('resin-sdk')
resin = require('../resin-sdk')
_ = require('lodash')
form = require('resin-cli-form')
deviceConfig = require('resin-device-config')

View File

@ -37,7 +37,7 @@ exports.list =
action: (params, options, done) ->
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk')
resin = require('../resin-sdk')
visuals = require('resin-cli-visuals')
Promise.try ->
@ -76,7 +76,7 @@ exports.info =
permission: 'user'
primary: true
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
visuals = require('resin-cli-visuals')
resin.models.device.get(params.uuid).then (device) ->
@ -114,7 +114,7 @@ exports.supported =
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
resin.models.config.getDeviceTypes().each (deviceType) ->
console.log(deviceType.slug)
.nodeify(done)
@ -138,7 +138,7 @@ exports.register =
]
action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk')
resin = require('../resin-sdk')
resin.models.application.get(params.application).then (application) ->
@ -167,7 +167,7 @@ exports.remove =
options: [ commandOptions.yes ]
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the device?').then ->
@ -188,7 +188,7 @@ exports.identify =
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
resin.models.device.identify(params.uuid).nodeify(done)
exports.reboot =
@ -204,7 +204,7 @@ exports.reboot =
options: [ commandOptions.forceUpdateLock ]
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
resin.models.device.reboot(params.uuid, options).nodeify(done)
exports.shutdown =
@ -220,7 +220,7 @@ exports.shutdown =
options: [ commandOptions.forceUpdateLock ]
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
resin.models.device.shutdown(params.uuid, options).nodeify(done)
exports.enableDeviceUrl =
@ -235,7 +235,7 @@ exports.enableDeviceUrl =
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
resin.models.device.enableDeviceUrl(params.uuid).nodeify(done)
exports.disableDeviceUrl =
@ -250,7 +250,7 @@ exports.disableDeviceUrl =
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
resin.models.device.disableDeviceUrl(params.uuid).nodeify(done)
exports.getDeviceUrl =
@ -265,7 +265,7 @@ exports.getDeviceUrl =
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
resin.models.device.getDeviceUrl(params.uuid).then (url) ->
console.log(url)
.nodeify(done)
@ -282,7 +282,7 @@ exports.hasDeviceUrl =
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
resin.models.device.hasDeviceUrl(params.uuid).then (hasDeviceUrl) ->
console.log(hasDeviceUrl)
.nodeify(done)
@ -304,7 +304,7 @@ exports.rename =
action: (params, options, done) ->
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk')
resin = require('../resin-sdk')
form = require('resin-cli-form')
Promise.try ->
@ -333,7 +333,7 @@ exports.move =
permission: 'user'
options: [ commandOptions.optionalApplication ]
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
_ = require('lodash')
patterns = require('../utils/patterns')
@ -381,7 +381,7 @@ exports.init =
tmp = Promise.promisifyAll(require('tmp'))
tmp.setGracefulCleanup()
resin = require('resin-sdk')
resin = require('../resin-sdk')
helpers = require('../utils/helpers')
patterns = require('../utils/patterns')

View File

@ -48,7 +48,7 @@ exports.list =
action: (params, options, done) ->
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk')
resin = require('../resin-sdk')
visuals = require('resin-cli-visuals')
Promise.try ->
@ -98,7 +98,7 @@ exports.remove =
]
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the environment variable?').then ->
@ -136,7 +136,7 @@ exports.add =
permission: 'user'
action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk')
resin = require('../resin-sdk')
Promise.try ->
if not params.value?
@ -172,7 +172,7 @@ exports.rename =
options: [ commandOptions.booleanDevice ]
action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk')
resin = require('../resin-sdk')
Promise.try ->
if options.device

View File

@ -28,7 +28,7 @@ exports.list =
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
visuals = require('resin-cli-visuals')
resin.models.key.getAll().then (keys) ->
@ -50,7 +50,7 @@ exports.info =
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
visuals = require('resin-cli-visuals')
resin.models.key.get(params.id).then (key) ->
@ -82,7 +82,7 @@ exports.remove =
options: [ commandOptions.yes ]
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the key?').then ->
@ -109,7 +109,7 @@ exports.add =
Promise = require('bluebird')
fs = Promise.promisifyAll(require('fs'))
capitano = require('capitano')
resin = require('resin-sdk')
resin = require('../resin-sdk')
Promise.try ->
return fs.readFileAsync(params.path, encoding: 'utf8') if params.path?

View File

@ -45,7 +45,7 @@ module.exports =
primary: true
action: (params, options, done) ->
_ = require('lodash')
resin = require('resin-sdk')
resin = require('../resin-sdk')
moment = require('moment')
printLine = (line) ->

View File

@ -40,7 +40,7 @@ exports.set =
action: (params, options, done) ->
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk')
resin = require('../resin-sdk')
Promise.try ->
if _.isEmpty(params.note)

View File

@ -107,7 +107,7 @@ exports.configure =
]
action: (params, options, done) ->
_ = require('lodash')
resin = require('resin-sdk')
resin = require('../resin-sdk')
form = require('resin-cli-form')
init = require('resin-device-init')
helpers = require('../utils/helpers')

View File

@ -25,7 +25,7 @@ exports.list =
$ resin settings
'''
action: (params, options, done) ->
resin = require('resin-sdk')
resin = require('../resin-sdk')
prettyjson = require('prettyjson')
resin.settings.getAll()

View File

@ -69,7 +69,7 @@ module.exports =
action: (params, options, done) ->
child_process = require('child_process')
Promise = require 'bluebird'
resin = require('resin-sdk')
resin = require('../resin-sdk')
settings = require('resin-settings-client')
patterns = require('../utils/patterns')

View File

@ -130,7 +130,7 @@ module.exports =
action: (params, options, done) ->
fs = require('fs')
path = require('path')
resin = require('resin-sdk')
resin = require('../resin-sdk')
Promise = require('bluebird')
resinSync = require('resin-sync')
patterns = require('../utils/patterns')

View File

@ -36,7 +36,7 @@ exports.wizard =
action: (params, options, done) ->
Promise = require('bluebird')
capitano = Promise.promisifyAll(require('capitano'))
resin = require('resin-sdk')
resin = require('../resin-sdk')
patterns = require('../utils/patterns')
resin.auth.isLoggedIn().then (isLoggedIn) ->

View File

@ -17,7 +17,7 @@ limitations under the License.
_ = require('lodash')
Promise = require('bluebird')
capitano = Promise.promisifyAll(require('capitano'))
resin = require('resin-sdk')
resin = require('./resin-sdk')
actions = require('./actions')
errors = require('./errors')
events = require('./events')

View File

@ -1,7 +1,7 @@
_ = require('lodash')
Mixpanel = require('mixpanel')
Promise = require('bluebird')
resin = require('resin-sdk')
resin = require('./resin-sdk')
capitanoState = Promise.promisifyAll(require('capitano').state)
packageJSON = require('../package.json')

13
lib/resin-sdk.coffee Normal file
View File

@ -0,0 +1,13 @@
# This is a singleton Resin SDK instance builder
getSdk = require('resin-sdk')
settings = require('resin-settings-client')
opts =
apiUrl: settings.get('apiUrl')
imageMakerUrl: settings.get('imageMakerUrl')
dataDirectory: settings.get('dataDirectory')
apiVersion: 'v2'
retries: 2
module.exports = getSdk(opts)

View File

@ -19,7 +19,7 @@ capitano = Promise.promisifyAll(require('capitano'))
_ = require('lodash')
_.str = require('underscore.string')
president = Promise.promisifyAll(require('president'))
resin = require('resin-sdk')
resin = require('./resin-sdk')
imagefs = require('resin-image-fs')
rindle = require('rindle')
os = require('os')

View File

@ -18,7 +18,7 @@ _ = require('lodash')
Promise = require('bluebird')
form = require('resin-cli-form')
visuals = require('resin-cli-visuals')
resin = require('resin-sdk')
resin = require('./resin-sdk')
chalk = require('chalk')
validation = require('./validation')
messages = require('./messages')