mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-27 14:30:07 +00:00
use individual methods promisification instead of promisifyAll
This commit is contained in:
parent
6cf32e445a
commit
08b3db717e
@ -49,10 +49,9 @@ exports.login = {
|
|||||||
],
|
],
|
||||||
primary: true,
|
primary: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, _, auth, capitano, form, login, messages, patterns, resin;
|
var Promise, _, auth, form, login, messages, patterns, resin;
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
capitano = Promise.promisifyAll(require('capitano'));
|
|
||||||
resin = require('resin-sdk-preconfigured');
|
resin = require('resin-sdk-preconfigured');
|
||||||
auth = require('resin-cli-auth');
|
auth = require('resin-cli-auth');
|
||||||
form = require('resin-cli-form');
|
form = require('resin-cli-form');
|
||||||
@ -77,8 +76,10 @@ exports.login = {
|
|||||||
return auth.login();
|
return auth.login();
|
||||||
}
|
}
|
||||||
return patterns.askLoginType().then(function(loginType) {
|
return patterns.askLoginType().then(function(loginType) {
|
||||||
|
var capitanoRunAsync;
|
||||||
if (loginType === 'register') {
|
if (loginType === 'register') {
|
||||||
return capitano.runAsync('signup');
|
capitanoRunAsync = Promise.promisify(require('capitano').run);
|
||||||
|
return capitanoRunAsync('signup');
|
||||||
}
|
}
|
||||||
options[loginType] = true;
|
options[loginType] = true;
|
||||||
return login(options);
|
return login(options);
|
||||||
|
@ -40,15 +40,15 @@ exports.read = {
|
|||||||
permission: 'user',
|
permission: 'user',
|
||||||
root: true,
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, config, prettyjson, umount, visuals;
|
var Promise, config, prettyjson, umountAsync, visuals;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
config = require('resin-config-json');
|
config = require('resin-config-json');
|
||||||
visuals = require('resin-cli-visuals');
|
visuals = require('resin-cli-visuals');
|
||||||
umount = Promise.promisifyAll(require('umount'));
|
umountAsync = Promise.promisify(require('umount').umount);
|
||||||
prettyjson = require('prettyjson');
|
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(umountAsync).then(function(drive) {
|
||||||
return config.read(drive, options.type);
|
return config.read(drive, options.type);
|
||||||
}).tap(function(configJSON) {
|
}).tap(function(configJSON) {
|
||||||
return console.info(prettyjson.render(configJSON));
|
return console.info(prettyjson.render(configJSON));
|
||||||
@ -77,21 +77,21 @@ exports.write = {
|
|||||||
permission: 'user',
|
permission: 'user',
|
||||||
root: true,
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, _, config, umount, visuals;
|
var Promise, _, config, umountAsync, visuals;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
config = require('resin-config-json');
|
config = require('resin-config-json');
|
||||||
visuals = require('resin-cli-visuals');
|
visuals = require('resin-cli-visuals');
|
||||||
umount = Promise.promisifyAll(require('umount'));
|
umountAsync = Promise.promisify(require('umount').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(umountAsync).then(function(drive) {
|
||||||
return config.read(drive, options.type).then(function(configJSON) {
|
return config.read(drive, options.type).then(function(configJSON) {
|
||||||
console.info("Setting " + params.key + " to " + params.value);
|
console.info("Setting " + params.key + " to " + params.value);
|
||||||
_.set(configJSON, params.key, params.value);
|
_.set(configJSON, params.key, params.value);
|
||||||
return configJSON;
|
return configJSON;
|
||||||
}).tap(function() {
|
}).tap(function() {
|
||||||
return umount.umountAsync(drive);
|
return umountAsync(drive);
|
||||||
}).then(function(configJSON) {
|
}).then(function(configJSON) {
|
||||||
return config.write(drive, options.type, configJSON);
|
return config.write(drive, options.type, configJSON);
|
||||||
});
|
});
|
||||||
@ -122,16 +122,16 @@ exports.inject = {
|
|||||||
permission: 'user',
|
permission: 'user',
|
||||||
root: true,
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, config, fs, umount, visuals;
|
var Promise, config, readFileAsync, umountAsync, visuals;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
config = require('resin-config-json');
|
config = require('resin-config-json');
|
||||||
visuals = require('resin-cli-visuals');
|
visuals = require('resin-cli-visuals');
|
||||||
umount = Promise.promisifyAll(require('umount'));
|
umountAsync = Promise.promisify(require('umount').umount);
|
||||||
fs = Promise.promisifyAll(require('fs'));
|
readFileAsync = Promise.promisify(require('fs').readFile);
|
||||||
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(umountAsync).then(function(drive) {
|
||||||
return fs.readFileAsync(params.file, 'utf8').then(JSON.parse).then(function(configJSON) {
|
return readFileAsync(params.file, 'utf8').then(JSON.parse).then(function(configJSON) {
|
||||||
return config.write(drive, options.type, configJSON);
|
return config.write(drive, options.type, configJSON);
|
||||||
});
|
});
|
||||||
}).tap(function() {
|
}).tap(function() {
|
||||||
@ -166,24 +166,24 @@ exports.reconfigure = {
|
|||||||
permission: 'user',
|
permission: 'user',
|
||||||
root: true,
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, capitano, config, umount, visuals;
|
var Promise, capitanoRunAsync, config, umountAsync, visuals;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
config = require('resin-config-json');
|
config = require('resin-config-json');
|
||||||
visuals = require('resin-cli-visuals');
|
visuals = require('resin-cli-visuals');
|
||||||
capitano = Promise.promisifyAll(require('capitano'));
|
capitanoRunAsync = Promise.promisify(require('capitano').run);
|
||||||
umount = Promise.promisifyAll(require('umount'));
|
umountAsync = Promise.promisify(require('umount').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(umountAsync).then(function(drive) {
|
||||||
return config.read(drive, options.type).get('uuid').tap(function() {
|
return config.read(drive, options.type).get('uuid').tap(function() {
|
||||||
return umount.umountAsync(drive);
|
return umountAsync(drive);
|
||||||
}).then(function(uuid) {
|
}).then(function(uuid) {
|
||||||
var configureCommand;
|
var configureCommand;
|
||||||
configureCommand = "os configure " + drive + " " + uuid;
|
configureCommand = "os configure " + drive + " " + uuid;
|
||||||
if (options.advanced) {
|
if (options.advanced) {
|
||||||
configureCommand += ' --advanced';
|
configureCommand += ' --advanced';
|
||||||
}
|
}
|
||||||
return capitano.runAsync(configureCommand);
|
return capitanoRunAsync(configureCommand);
|
||||||
});
|
});
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return console.info('Done');
|
return console.info('Done');
|
||||||
@ -205,9 +205,9 @@ exports.generate = {
|
|||||||
],
|
],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, _, deviceConfig, form, fs, prettyjson, resin;
|
var Promise, _, deviceConfig, form, prettyjson, resin, writeFileAsync;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
fs = Promise.promisifyAll(require('fs'));
|
writeFileAsync = Promise.promisify(require('fs').writeFile);
|
||||||
resin = require('resin-sdk-preconfigured');
|
resin = require('resin-sdk-preconfigured');
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
form = require('resin-cli-form');
|
form = require('resin-cli-form');
|
||||||
@ -230,7 +230,7 @@ exports.generate = {
|
|||||||
});
|
});
|
||||||
}).then(function(config) {
|
}).then(function(config) {
|
||||||
if (options.output != null) {
|
if (options.output != null) {
|
||||||
return fs.writeFileAsync(options.output, JSON.stringify(config));
|
return writeFileAsync(options.output, JSON.stringify(config));
|
||||||
}
|
}
|
||||||
return console.log(prettyjson.render(config));
|
return console.log(prettyjson.render(config));
|
||||||
}).nodeify(done);
|
}).nodeify(done);
|
||||||
|
@ -274,11 +274,12 @@ exports.init = {
|
|||||||
],
|
],
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, capitano, helpers, patterns, resin, rimraf, tmp;
|
var Promise, capitanoRunAsync, helpers, patterns, resin, rimraf, tmp, tmpNameAsync;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
capitano = Promise.promisifyAll(require('capitano'));
|
capitanoRunAsync = Promise.promisify(require('capitano').run);
|
||||||
rimraf = Promise.promisify(require('rimraf'));
|
rimraf = Promise.promisify(require('rimraf'));
|
||||||
tmp = Promise.promisifyAll(require('tmp'));
|
tmp = require('tmp');
|
||||||
|
tmpNameAsync = Promise.promisify(tmp.tmpName);
|
||||||
tmp.setGracefulCleanup();
|
tmp.setGracefulCleanup();
|
||||||
resin = require('resin-sdk-preconfigured');
|
resin = require('resin-sdk-preconfigured');
|
||||||
helpers = require('../utils/helpers');
|
helpers = require('../utils/helpers');
|
||||||
@ -291,23 +292,23 @@ exports.init = {
|
|||||||
}).then(resin.models.application.get).then(function(application) {
|
}).then(resin.models.application.get).then(function(application) {
|
||||||
var download;
|
var download;
|
||||||
download = function() {
|
download = function() {
|
||||||
return tmp.tmpNameAsync().then(function(tempPath) {
|
return tmpNameAsync().then(function(tempPath) {
|
||||||
return capitano.runAsync("os download " + application.device_type + " --output '" + tempPath + "' --version default");
|
return capitanoRunAsync("os download " + application.device_type + " --output '" + tempPath + "' --version default");
|
||||||
}).disposer(function(tempPath) {
|
}).disposer(function(tempPath) {
|
||||||
return rimraf(tempPath);
|
return rimraf(tempPath);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return Promise.using(download(), function(tempPath) {
|
return Promise.using(download(), function(tempPath) {
|
||||||
return capitano.runAsync("device register " + application.app_name).then(resin.models.device.get).tap(function(device) {
|
return capitanoRunAsync("device register " + application.app_name).then(resin.models.device.get).tap(function(device) {
|
||||||
var configureCommand;
|
var configureCommand;
|
||||||
configureCommand = "os configure '" + tempPath + "' " + device.uuid;
|
configureCommand = "os configure '" + tempPath + "' " + device.uuid;
|
||||||
if (options.advanced) {
|
if (options.advanced) {
|
||||||
configureCommand += ' --advanced';
|
configureCommand += ' --advanced';
|
||||||
}
|
}
|
||||||
return capitano.runAsync(configureCommand).then(function() {
|
return capitanoRunAsync(configureCommand).then(function() {
|
||||||
var osInitCommand;
|
var osInitCommand;
|
||||||
osInitCommand = "os initialize '" + tempPath + "' --type " + application.device_type;
|
osInitCommand = "os initialize '" + tempPath + "' --type " + application.device_type;
|
||||||
return capitano.runAsync(osInitCommand);
|
return capitanoRunAsync(osInitCommand);
|
||||||
})["catch"](function(error) {
|
})["catch"](function(error) {
|
||||||
return resin.models.device.remove(device.uuid)["finally"](function() {
|
return resin.models.device.remove(device.uuid)["finally"](function() {
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -72,15 +72,15 @@ exports.add = {
|
|||||||
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, fs, resin;
|
var Promise, _, capitano, readFileAsync, resin;
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
fs = Promise.promisifyAll(require('fs'));
|
readFileAsync = Promise.promisify(require('fs').readFile);
|
||||||
capitano = require('capitano');
|
capitano = require('capitano');
|
||||||
resin = require('resin-sdk-preconfigured');
|
resin = require('resin-sdk-preconfigured');
|
||||||
return Promise["try"](function() {
|
return Promise["try"](function() {
|
||||||
if (params.path != null) {
|
if (params.path != null) {
|
||||||
return fs.readFileAsync(params.path, {
|
return readFileAsync(params.path, {
|
||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -66,18 +66,20 @@ module.exports = {
|
|||||||
help: 'Use this command to configure or reconfigure a resinOS drive or image.\n\nExamples:\n\n $ resin local configure /dev/sdc\n $ resin local configure path/to/image.img',
|
help: 'Use this command to configure or reconfigure a resinOS drive or image.\n\nExamples:\n\n $ resin local configure /dev/sdc\n $ resin local configure path/to/image.img',
|
||||||
root: true,
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, _, denymount, inquirer, reconfix, umount;
|
var Promise, _, denymount, inquirer, isMountedAsync, reconfix, umount, umountAsync;
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
umount = Promise.promisifyAll(require('umount'));
|
umount = require('umount');
|
||||||
|
umountAsync = Promise.promisify(umount.umount);
|
||||||
|
isMountedAsync = Promise.promisify(umount.isMounted);
|
||||||
inquirer = require('inquirer');
|
inquirer = require('inquirer');
|
||||||
reconfix = require('reconfix');
|
reconfix = require('reconfix');
|
||||||
denymount = Promise.promisify(require('denymount'));
|
denymount = Promise.promisify(require('denymount'));
|
||||||
return umount.isMountedAsync(params.target).then(function(isMounted) {
|
return isMountedAsync(params.target).then(function(isMounted) {
|
||||||
if (!isMounted) {
|
if (!isMounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return umount.umountAsync(params.target);
|
return umountAsync(params.target);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return denymount(params.target, function(cb) {
|
return denymount(params.target, function(cb) {
|
||||||
return reconfix.readConfiguration(CONFIGURATION_SCHEMA, params.target).then(function(data) {
|
return reconfix.readConfiguration(CONFIGURATION_SCHEMA, params.target).then(function(data) {
|
||||||
|
@ -34,13 +34,13 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
root: true,
|
root: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, _, chalk, drivelist, form, fs, imageWrite, os, umount, visuals;
|
var Promise, _, chalk, driveListAsync, form, fs, imageWrite, os, umountAsync, visuals;
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
os = require('os');
|
os = require('os');
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
umount = Promise.promisifyAll(require('umount'));
|
umountAsync = Promise.promisify(require('umount').umount);
|
||||||
fs = Promise.promisifyAll(require('fs'));
|
fs = Promise.promisifyAll(require('fs'));
|
||||||
drivelist = Promise.promisifyAll(require('drivelist'));
|
driveListAsync = Promise.promisify(require('drivelist').list);
|
||||||
chalk = require('chalk');
|
chalk = require('chalk');
|
||||||
visuals = require('resin-cli-visuals');
|
visuals = require('resin-cli-visuals');
|
||||||
form = require('resin-cli-form');
|
form = require('resin-cli-form');
|
||||||
@ -71,7 +71,7 @@ module.exports = {
|
|||||||
console.log(chalk.red.bold('Aborted image flash'));
|
console.log(chalk.red.bold('Aborted image flash'));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
return drivelist.listAsync().then(function(drives) {
|
return driveListAsync().then(function(drives) {
|
||||||
var selectedDrive;
|
var selectedDrive;
|
||||||
selectedDrive = _.find(drives, {
|
selectedDrive = _.find(drives, {
|
||||||
device: answers.drive
|
device: answers.drive
|
||||||
@ -87,7 +87,7 @@ module.exports = {
|
|||||||
write: new visuals.Progress('Flashing'),
|
write: new visuals.Progress('Flashing'),
|
||||||
check: new visuals.Progress('Validating')
|
check: new visuals.Progress('Validating')
|
||||||
};
|
};
|
||||||
return umount.umountAsync(selectedDrive.device).then(function() {
|
return umountAsync(selectedDrive.device).then(function() {
|
||||||
return Promise.props({
|
return Promise.props({
|
||||||
imageSize: fs.statAsync(params.image).get('size'),
|
imageSize: fs.statAsync(params.image).get('size'),
|
||||||
imageStream: Promise.resolve(fs.createReadStream(params.image)),
|
imageStream: Promise.resolve(fs.createReadStream(params.image)),
|
||||||
@ -113,12 +113,12 @@ module.exports = {
|
|||||||
return writer.on('done', resolve);
|
return writer.on('done', resolve);
|
||||||
});
|
});
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
var removedrive;
|
var ejectAsync;
|
||||||
if ((os.platform() === 'win32') && (selectedDrive.mountpoint != null)) {
|
if ((os.platform() === 'win32') && (selectedDrive.mountpoint != null)) {
|
||||||
removedrive = Promise.promisifyAll(require('removedrive'));
|
ejectAsync = Promise.promisify(require('removedrive').eject);
|
||||||
return removedrive.ejectAsync(selectedDrive.mountpoint);
|
return ejectAsync(selectedDrive.mountpoint);
|
||||||
}
|
}
|
||||||
return umount.umountAsync(selectedDrive.device);
|
return umountAsync(selectedDrive.device);
|
||||||
});
|
});
|
||||||
}).asCallback(done);
|
}).asCallback(done);
|
||||||
}
|
}
|
||||||
|
@ -185,9 +185,9 @@ exports.initialize = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, form, helpers, patterns, umount;
|
var Promise, form, helpers, patterns, umountAsync;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
umount = Promise.promisifyAll(require('umount'));
|
umountAsync = Promise.promisify(require('umount').umount);
|
||||||
form = require('resin-cli-form');
|
form = require('resin-cli-form');
|
||||||
patterns = require('../utils/patterns');
|
patterns = require('../utils/patterns');
|
||||||
helpers = require('../utils/helpers');
|
helpers = require('../utils/helpers');
|
||||||
@ -207,14 +207,14 @@ exports.initialize = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
message = "This will erase " + answers.drive + ". Are you sure?";
|
message = "This will erase " + answers.drive + ". Are you sure?";
|
||||||
return patterns.confirm(options.yes, message)["return"](answers.drive).then(umount.umountAsync);
|
return patterns.confirm(options.yes, message)["return"](answers.drive).then(umountAsync);
|
||||||
}).tap(function(answers) {
|
}).tap(function(answers) {
|
||||||
return helpers.sudo(['internal', 'osinit', params.image, options.type, JSON.stringify(answers)]);
|
return helpers.sudo(['internal', 'osinit', params.image, options.type, JSON.stringify(answers)]);
|
||||||
}).then(function(answers) {
|
}).then(function(answers) {
|
||||||
if (answers.drive == null) {
|
if (answers.drive == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return umount.umountAsync(answers.drive).tap(function() {
|
return umountAsync(answers.drive).tap(function() {
|
||||||
return console.info("You can safely remove " + answers.drive + " now");
|
return console.info("You can safely remove " + answers.drive + " now");
|
||||||
});
|
});
|
||||||
}).nodeify(done);
|
}).nodeify(done);
|
||||||
|
@ -21,9 +21,9 @@ exports.wizard = {
|
|||||||
help: 'Use this command to run a friendly wizard to get started with resin.io.\n\nThe wizard will guide you through:\n\n - Create an application.\n - Initialise an SDCard with the resin.io operating system.\n - Associate an existing project directory with your resin.io application.\n - Push your project to your devices.\n\nExamples:\n\n $ resin quickstart\n $ resin quickstart MyApp',
|
help: 'Use this command to run a friendly wizard to get started with resin.io.\n\nThe wizard will guide you through:\n\n - Create an application.\n - Initialise an SDCard with the resin.io operating system.\n - Associate an existing project directory with your resin.io application.\n - Push your project to your devices.\n\nExamples:\n\n $ resin quickstart\n $ resin quickstart MyApp',
|
||||||
primary: true,
|
primary: true,
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var Promise, capitano, patterns, resin;
|
var Promise, capitanoRunAsync, patterns, resin;
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
capitano = Promise.promisifyAll(require('capitano'));
|
capitanoRunAsync = Promise.promisify(require('capitano').run);
|
||||||
resin = require('resin-sdk-preconfigured');
|
resin = require('resin-sdk-preconfigured');
|
||||||
patterns = require('../utils/patterns');
|
patterns = require('../utils/patterns');
|
||||||
return resin.auth.isLoggedIn().then(function(isLoggedIn) {
|
return resin.auth.isLoggedIn().then(function(isLoggedIn) {
|
||||||
@ -32,7 +32,7 @@ exports.wizard = {
|
|||||||
}
|
}
|
||||||
console.info('Looks like you\'re not logged in yet!');
|
console.info('Looks like you\'re not logged in yet!');
|
||||||
console.info('Lets go through a quick wizard to get you started.\n');
|
console.info('Lets go through a quick wizard to get you started.\n');
|
||||||
return capitano.runAsync('login');
|
return capitanoRunAsync('login');
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
if (params.name != null) {
|
if (params.name != null) {
|
||||||
return;
|
return;
|
||||||
@ -42,15 +42,15 @@ exports.wizard = {
|
|||||||
if (hasApplication) {
|
if (hasApplication) {
|
||||||
return applicationName;
|
return applicationName;
|
||||||
}
|
}
|
||||||
return capitano.runAsync("app create " + applicationName);
|
return capitanoRunAsync("app create " + applicationName);
|
||||||
});
|
});
|
||||||
}).then(function(applicationName) {
|
}).then(function(applicationName) {
|
||||||
return params.name = applicationName;
|
return params.name = applicationName;
|
||||||
});
|
});
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return capitano.runAsync("device init --application " + params.name);
|
return capitanoRunAsync("device init --application " + params.name);
|
||||||
}).tap(patterns.awaitDevice).then(function(uuid) {
|
}).tap(patterns.awaitDevice).then(function(uuid) {
|
||||||
return capitano.runAsync("device " + uuid);
|
return capitanoRunAsync("device " + uuid);
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
return resin.models.application.get(params.name);
|
return resin.models.application.get(params.name);
|
||||||
}).then(function(application) {
|
}).then(function(application) {
|
||||||
|
10
build/app.js
10
build/app.js
@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
var Promise, Raven, _, actions, capitano, errors, events, plugins, resin, update;
|
var Promise, Raven, _, actions, capitano, capitanoExecuteAsync, errors, events, plugins, resin, update;
|
||||||
|
|
||||||
Raven = require('raven');
|
Raven = require('raven');
|
||||||
|
|
||||||
@ -30,7 +30,9 @@ _ = require('lodash');
|
|||||||
|
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
|
||||||
capitano = Promise.promisifyAll(require('capitano'));
|
capitano = require('capitano');
|
||||||
|
|
||||||
|
capitanoExecuteAsync = Promise.promisify(capitano.execute);
|
||||||
|
|
||||||
resin = require('resin-sdk-preconfigured');
|
resin = require('resin-sdk-preconfigured');
|
||||||
|
|
||||||
@ -189,10 +191,10 @@ plugins.register(/^resin-plugin-(.+)$/).then(function() {
|
|||||||
return events.trackCommand(cli).then(function() {
|
return events.trackCommand(cli).then(function() {
|
||||||
var ref, ref1;
|
var ref, ref1;
|
||||||
if ((ref = cli.global) != null ? ref.help : void 0) {
|
if ((ref = cli.global) != null ? ref.help : void 0) {
|
||||||
return capitano.executeAsync({
|
return capitanoExecuteAsync({
|
||||||
command: "help " + ((ref1 = cli.command) != null ? ref1 : '')
|
command: "help " + ((ref1 = cli.command) != null ? ref1 : '')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return capitano.executeAsync(cli);
|
return capitanoExecuteAsync(cli);
|
||||||
});
|
});
|
||||||
})["catch"](errors.handle);
|
})["catch"](errors.handle);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Generated by CoffeeScript 1.12.4
|
// Generated by CoffeeScript 1.12.4
|
||||||
var Mixpanel, Promise, _, capitanoState, packageJSON, resin;
|
var Mixpanel, Promise, _, packageJSON, resin;
|
||||||
|
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
|
|
||||||
@ -9,8 +9,6 @@ Promise = require('bluebird');
|
|||||||
|
|
||||||
resin = require('resin-sdk-preconfigured');
|
resin = require('resin-sdk-preconfigured');
|
||||||
|
|
||||||
capitanoState = Promise.promisifyAll(require('capitano').state);
|
|
||||||
|
|
||||||
packageJSON = require('../package.json');
|
packageJSON = require('../package.json');
|
||||||
|
|
||||||
exports.getLoggerInstance = _.memoize(function() {
|
exports.getLoggerInstance = _.memoize(function() {
|
||||||
@ -18,12 +16,14 @@ exports.getLoggerInstance = _.memoize(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
exports.trackCommand = function(capitanoCommand) {
|
exports.trackCommand = function(capitanoCommand) {
|
||||||
|
var capitanoStateGetMatchCommandAsync;
|
||||||
|
capitanoStateGetMatchCommandAsync = Promise.promisify(require('capitano').state.getMatchCommand);
|
||||||
return Promise.props({
|
return Promise.props({
|
||||||
resinUrl: resin.settings.get('resinUrl'),
|
resinUrl: resin.settings.get('resinUrl'),
|
||||||
username: resin.auth.whoami(),
|
username: resin.auth.whoami(),
|
||||||
mixpanel: exports.getLoggerInstance()
|
mixpanel: exports.getLoggerInstance()
|
||||||
}).then(function(data) {
|
}).then(function(data) {
|
||||||
return capitanoState.getMatchCommandAsync(capitanoCommand.command).then(function(command) {
|
return capitanoStateGetMatchCommandAsync(capitanoCommand.command).then(function(command) {
|
||||||
return data.mixpanel.track("[CLI] " + (command.signature.toString()), {
|
return data.mixpanel.track("[CLI] " + (command.signature.toString()), {
|
||||||
distinct_id: data.username,
|
distinct_id: data.username,
|
||||||
argv: process.argv.join(' '),
|
argv: process.argv.join(' '),
|
||||||
|
@ -15,14 +15,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
var Promise, capitano, president;
|
var Promise;
|
||||||
|
|
||||||
Promise = require('bluebird');
|
Promise = require('bluebird');
|
||||||
|
|
||||||
capitano = Promise.promisifyAll(require('capitano'));
|
|
||||||
|
|
||||||
president = Promise.promisifyAll(require('president'));
|
|
||||||
|
|
||||||
exports.getGroupDefaults = function(group) {
|
exports.getGroupDefaults = function(group) {
|
||||||
var _;
|
var _;
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
@ -50,14 +46,15 @@ exports.stateToString = function(state) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.sudo = function(command) {
|
exports.sudo = function(command) {
|
||||||
var _, os;
|
var _, os, presidentExecuteAsync;
|
||||||
_ = require('lodash');
|
_ = require('lodash');
|
||||||
os = require('os');
|
os = require('os');
|
||||||
if (os.platform() !== 'win32') {
|
if (os.platform() !== 'win32') {
|
||||||
console.log('If asked please type your computer password to continue');
|
console.log('If asked please type your computer password to continue');
|
||||||
}
|
}
|
||||||
command = _.union(_.take(process.argv, 2), command);
|
command = _.union(_.take(process.argv, 2), command);
|
||||||
return president.executeAsync(command);
|
presidentExecuteAsync = Promise.promisify(require('president').execute);
|
||||||
|
return presidentExecuteAsync(command);
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.getManifest = function(image, deviceType) {
|
exports.getManifest = function(image, deviceType) {
|
||||||
|
@ -73,7 +73,6 @@ exports.login =
|
|||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
capitano = Promise.promisifyAll(require('capitano'))
|
|
||||||
resin = require('resin-sdk-preconfigured')
|
resin = require('resin-sdk-preconfigured')
|
||||||
auth = require('resin-cli-auth')
|
auth = require('resin-cli-auth')
|
||||||
form = require('resin-cli-form')
|
form = require('resin-cli-form')
|
||||||
@ -98,7 +97,8 @@ exports.login =
|
|||||||
return patterns.askLoginType().then (loginType) ->
|
return patterns.askLoginType().then (loginType) ->
|
||||||
|
|
||||||
if loginType is 'register'
|
if loginType is 'register'
|
||||||
return capitano.runAsync('signup')
|
capitanoRunAsync = Promise.promisify(require('capitano').run)
|
||||||
|
return capitanoRunAsync('signup')
|
||||||
|
|
||||||
options[loginType] = true
|
options[loginType] = true
|
||||||
return login(options)
|
return login(options)
|
||||||
|
@ -48,12 +48,12 @@ exports.read =
|
|||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
config = require('resin-config-json')
|
config = require('resin-config-json')
|
||||||
visuals = require('resin-cli-visuals')
|
visuals = require('resin-cli-visuals')
|
||||||
umount = Promise.promisifyAll(require('umount'))
|
umountAsync = Promise.promisify(require('umount').umount)
|
||||||
prettyjson = require('prettyjson')
|
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(umountAsync)
|
||||||
.then (drive) ->
|
.then (drive) ->
|
||||||
return config.read(drive, options.type)
|
return config.read(drive, options.type)
|
||||||
.tap (configJSON) ->
|
.tap (configJSON) ->
|
||||||
@ -94,18 +94,18 @@ exports.write =
|
|||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
config = require('resin-config-json')
|
config = require('resin-config-json')
|
||||||
visuals = require('resin-cli-visuals')
|
visuals = require('resin-cli-visuals')
|
||||||
umount = Promise.promisifyAll(require('umount'))
|
umountAsync = Promise.promisify(require('umount').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(umountAsync)
|
||||||
.then (drive) ->
|
.then (drive) ->
|
||||||
config.read(drive, options.type).then (configJSON) ->
|
config.read(drive, options.type).then (configJSON) ->
|
||||||
console.info("Setting #{params.key} to #{params.value}")
|
console.info("Setting #{params.key} to #{params.value}")
|
||||||
_.set(configJSON, params.key, params.value)
|
_.set(configJSON, params.key, params.value)
|
||||||
return configJSON
|
return configJSON
|
||||||
.tap ->
|
.tap ->
|
||||||
return umount.umountAsync(drive)
|
return umountAsync(drive)
|
||||||
.then (configJSON) ->
|
.then (configJSON) ->
|
||||||
return config.write(drive, options.type, configJSON)
|
return config.write(drive, options.type, configJSON)
|
||||||
.tap ->
|
.tap ->
|
||||||
@ -144,14 +144,14 @@ exports.inject =
|
|||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
config = require('resin-config-json')
|
config = require('resin-config-json')
|
||||||
visuals = require('resin-cli-visuals')
|
visuals = require('resin-cli-visuals')
|
||||||
umount = Promise.promisifyAll(require('umount'))
|
umountAsync = Promise.promisify(require('umount').umount)
|
||||||
fs = Promise.promisifyAll(require('fs'))
|
readFileAsync = Promise.promisify(require('fs').readFile)
|
||||||
|
|
||||||
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(umountAsync)
|
||||||
.then (drive) ->
|
.then (drive) ->
|
||||||
fs.readFileAsync(params.file, 'utf8').then(JSON.parse).then (configJSON) ->
|
readFileAsync(params.file, 'utf8').then(JSON.parse).then (configJSON) ->
|
||||||
return config.write(drive, options.type, configJSON)
|
return config.write(drive, options.type, configJSON)
|
||||||
.tap ->
|
.tap ->
|
||||||
console.info('Done')
|
console.info('Done')
|
||||||
@ -196,21 +196,21 @@ exports.reconfigure =
|
|||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
config = require('resin-config-json')
|
config = require('resin-config-json')
|
||||||
visuals = require('resin-cli-visuals')
|
visuals = require('resin-cli-visuals')
|
||||||
capitano = Promise.promisifyAll(require('capitano'))
|
capitanoRunAsync = Promise.promisify(require('capitano').run)
|
||||||
umount = Promise.promisifyAll(require('umount'))
|
umountAsync = Promise.promisify(require('umount').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(umountAsync)
|
||||||
.then (drive) ->
|
.then (drive) ->
|
||||||
config.read(drive, options.type).get('uuid')
|
config.read(drive, options.type).get('uuid')
|
||||||
.tap ->
|
.tap ->
|
||||||
umount.umountAsync(drive)
|
umountAsync(drive)
|
||||||
.then (uuid) ->
|
.then (uuid) ->
|
||||||
configureCommand = "os configure #{drive} #{uuid}"
|
configureCommand = "os configure #{drive} #{uuid}"
|
||||||
if options.advanced
|
if options.advanced
|
||||||
configureCommand += ' --advanced'
|
configureCommand += ' --advanced'
|
||||||
return capitano.runAsync(configureCommand)
|
return capitanoRunAsync(configureCommand)
|
||||||
.then ->
|
.then ->
|
||||||
console.info('Done')
|
console.info('Done')
|
||||||
.nodeify(done)
|
.nodeify(done)
|
||||||
@ -241,7 +241,7 @@ exports.generate =
|
|||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
fs = Promise.promisifyAll(require('fs'))
|
writeFileAsync = Promise.promisify(require('fs').writeFile)
|
||||||
resin = require('resin-sdk-preconfigured')
|
resin = require('resin-sdk-preconfigured')
|
||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
form = require('resin-cli-form')
|
form = require('resin-cli-form')
|
||||||
@ -271,7 +271,7 @@ exports.generate =
|
|||||||
return deviceConfig.getByApplication(resource.app_name, answers)
|
return deviceConfig.getByApplication(resource.app_name, answers)
|
||||||
.then (config) ->
|
.then (config) ->
|
||||||
if options.output?
|
if options.output?
|
||||||
return fs.writeFileAsync(options.output, JSON.stringify(config))
|
return writeFileAsync(options.output, JSON.stringify(config))
|
||||||
|
|
||||||
console.log(prettyjson.render(config))
|
console.log(prettyjson.render(config))
|
||||||
.nodeify(done)
|
.nodeify(done)
|
||||||
|
@ -376,9 +376,10 @@ exports.init =
|
|||||||
permission: 'user'
|
permission: 'user'
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
capitano = Promise.promisifyAll(require('capitano'))
|
capitanoRunAsync = Promise.promisify(require('capitano').run)
|
||||||
rimraf = Promise.promisify(require('rimraf'))
|
rimraf = Promise.promisify(require('rimraf'))
|
||||||
tmp = Promise.promisifyAll(require('tmp'))
|
tmp = require('tmp')
|
||||||
|
tmpNameAsync = Promise.promisify(tmp.tmpName)
|
||||||
tmp.setGracefulCleanup()
|
tmp.setGracefulCleanup()
|
||||||
|
|
||||||
resin = require('resin-sdk-preconfigured')
|
resin = require('resin-sdk-preconfigured')
|
||||||
@ -392,23 +393,23 @@ exports.init =
|
|||||||
.then (application) ->
|
.then (application) ->
|
||||||
|
|
||||||
download = ->
|
download = ->
|
||||||
tmp.tmpNameAsync().then (tempPath) ->
|
tmpNameAsync().then (tempPath) ->
|
||||||
# TODO: allow version selection
|
# TODO: allow version selection
|
||||||
capitano.runAsync("os download #{application.device_type} --output '#{tempPath}' --version default")
|
capitanoRunAsync("os download #{application.device_type} --output '#{tempPath}' --version default")
|
||||||
.disposer (tempPath) ->
|
.disposer (tempPath) ->
|
||||||
return rimraf(tempPath)
|
return rimraf(tempPath)
|
||||||
|
|
||||||
Promise.using download(), (tempPath) ->
|
Promise.using download(), (tempPath) ->
|
||||||
capitano.runAsync("device register #{application.app_name}")
|
capitanoRunAsync("device register #{application.app_name}")
|
||||||
.then(resin.models.device.get)
|
.then(resin.models.device.get)
|
||||||
.tap (device) ->
|
.tap (device) ->
|
||||||
configureCommand = "os configure '#{tempPath}' #{device.uuid}"
|
configureCommand = "os configure '#{tempPath}' #{device.uuid}"
|
||||||
if options.advanced
|
if options.advanced
|
||||||
configureCommand += ' --advanced'
|
configureCommand += ' --advanced'
|
||||||
capitano.runAsync(configureCommand)
|
capitanoRunAsync(configureCommand)
|
||||||
.then ->
|
.then ->
|
||||||
osInitCommand = "os initialize '#{tempPath}' --type #{application.device_type}"
|
osInitCommand = "os initialize '#{tempPath}' --type #{application.device_type}"
|
||||||
capitano.runAsync(osInitCommand)
|
capitanoRunAsync(osInitCommand)
|
||||||
# Make sure the device resource is removed if there is an
|
# Make sure the device resource is removed if there is an
|
||||||
# error when configuring or initializing a device image
|
# error when configuring or initializing a device image
|
||||||
.catch (error) ->
|
.catch (error) ->
|
||||||
|
@ -107,13 +107,14 @@ exports.add =
|
|||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
fs = Promise.promisifyAll(require('fs'))
|
readFileAsync = Promise.promisify(require('fs').readFile)
|
||||||
capitano = require('capitano')
|
capitano = require('capitano')
|
||||||
resin = require('resin-sdk-preconfigured')
|
resin = require('resin-sdk-preconfigured')
|
||||||
|
|
||||||
Promise.try ->
|
Promise.try ->
|
||||||
return fs.readFileAsync(params.path, encoding: 'utf8') if params.path?
|
return readFileAsync(params.path, encoding: 'utf8') if params.path?
|
||||||
|
|
||||||
|
# TODO: should this be promisified for consistency?
|
||||||
Promise.fromNode (callback) ->
|
Promise.fromNode (callback) ->
|
||||||
capitano.utils.getStdin (data) ->
|
capitano.utils.getStdin (data) ->
|
||||||
return callback(null, data)
|
return callback(null, data)
|
||||||
|
@ -67,14 +67,16 @@ module.exports =
|
|||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
umount = Promise.promisifyAll(require('umount'))
|
umount = require('umount')
|
||||||
|
umountAsync = Promise.promisify(umount.umount)
|
||||||
|
isMountedAsync = Promise.promisify(umount.isMounted)
|
||||||
inquirer = require('inquirer')
|
inquirer = require('inquirer')
|
||||||
reconfix = require('reconfix')
|
reconfix = require('reconfix')
|
||||||
denymount = Promise.promisify(require('denymount'))
|
denymount = Promise.promisify(require('denymount'))
|
||||||
|
|
||||||
umount.isMountedAsync(params.target).then (isMounted) ->
|
isMountedAsync(params.target).then (isMounted) ->
|
||||||
return if not isMounted
|
return if not isMounted
|
||||||
umount.umountAsync(params.target)
|
umountAsync(params.target)
|
||||||
.then ->
|
.then ->
|
||||||
denymount params.target, (cb) ->
|
denymount params.target, (cb) ->
|
||||||
reconfix.readConfiguration(CONFIGURATION_SCHEMA, params.target).then (data) ->
|
reconfix.readConfiguration(CONFIGURATION_SCHEMA, params.target).then (data) ->
|
||||||
|
@ -43,15 +43,15 @@ module.exports =
|
|||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
os = require('os')
|
os = require('os')
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
umount = Promise.promisifyAll(require('umount'))
|
umountAsync = Promise.promisify(require('umount').umount)
|
||||||
fs = Promise.promisifyAll(require('fs'))
|
fs = Promise.promisifyAll(require('fs'))
|
||||||
drivelist = Promise.promisifyAll(require('drivelist'))
|
driveListAsync = Promise.promisify(require('drivelist').list)
|
||||||
chalk = require('chalk')
|
chalk = require('chalk')
|
||||||
visuals = require('resin-cli-visuals')
|
visuals = require('resin-cli-visuals')
|
||||||
form = require('resin-cli-form')
|
form = require('resin-cli-form')
|
||||||
|
|
||||||
|
|
||||||
# XXX: Find a better ES6 module loading story/contract between resin.io modules
|
# TODO: Find a better ES6 module loading story/contract between resin.io modules
|
||||||
require('babel-register')({
|
require('babel-register')({
|
||||||
only: /etcher-image-write|bmapflash/
|
only: /etcher-image-write|bmapflash/
|
||||||
presets: ['es2015']
|
presets: ['es2015']
|
||||||
@ -84,7 +84,7 @@ module.exports =
|
|||||||
console.log(chalk.red.bold('Aborted image flash'))
|
console.log(chalk.red.bold('Aborted image flash'))
|
||||||
process.exit(0)
|
process.exit(0)
|
||||||
|
|
||||||
drivelist.listAsync().then (drives) ->
|
driveListAsync().then (drives) ->
|
||||||
selectedDrive = _.find(drives, device: answers.drive)
|
selectedDrive = _.find(drives, device: answers.drive)
|
||||||
|
|
||||||
if not selectedDrive?
|
if not selectedDrive?
|
||||||
@ -96,7 +96,7 @@ module.exports =
|
|||||||
write: new visuals.Progress('Flashing')
|
write: new visuals.Progress('Flashing')
|
||||||
check: new visuals.Progress('Validating')
|
check: new visuals.Progress('Validating')
|
||||||
|
|
||||||
umount.umountAsync(selectedDrive.device).then ->
|
umountAsync(selectedDrive.device).then ->
|
||||||
Promise.props
|
Promise.props
|
||||||
imageSize: fs.statAsync(params.image).get('size'),
|
imageSize: fs.statAsync(params.image).get('size'),
|
||||||
imageStream: Promise.resolve(fs.createReadStream(params.image))
|
imageStream: Promise.resolve(fs.createReadStream(params.image))
|
||||||
@ -119,8 +119,8 @@ module.exports =
|
|||||||
writer.on('done', resolve)
|
writer.on('done', resolve)
|
||||||
.then ->
|
.then ->
|
||||||
if (os.platform() is 'win32') and selectedDrive.mountpoint?
|
if (os.platform() is 'win32') and selectedDrive.mountpoint?
|
||||||
removedrive = Promise.promisifyAll(require('removedrive'))
|
ejectAsync = Promise.promisify(require('removedrive').eject)
|
||||||
return removedrive.ejectAsync(selectedDrive.mountpoint)
|
return ejectAsync(selectedDrive.mountpoint)
|
||||||
|
|
||||||
return umount.umountAsync(selectedDrive.device)
|
return umountAsync(selectedDrive.device)
|
||||||
.asCallback(done)
|
.asCallback(done)
|
||||||
|
@ -212,7 +212,7 @@ exports.initialize =
|
|||||||
]
|
]
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
umount = Promise.promisifyAll(require('umount'))
|
umountAsync = Promise.promisify(require('umount').umount)
|
||||||
form = require('resin-cli-form')
|
form = require('resin-cli-form')
|
||||||
patterns = require('../utils/patterns')
|
patterns = require('../utils/patterns')
|
||||||
helpers = require('../utils/helpers')
|
helpers = require('../utils/helpers')
|
||||||
@ -234,7 +234,7 @@ exports.initialize =
|
|||||||
message = "This will erase #{answers.drive}. Are you sure?"
|
message = "This will erase #{answers.drive}. Are you sure?"
|
||||||
patterns.confirm(options.yes, message)
|
patterns.confirm(options.yes, message)
|
||||||
.return(answers.drive)
|
.return(answers.drive)
|
||||||
.then(umount.umountAsync)
|
.then(umountAsync)
|
||||||
.tap (answers) ->
|
.tap (answers) ->
|
||||||
return helpers.sudo([
|
return helpers.sudo([
|
||||||
'internal'
|
'internal'
|
||||||
@ -245,6 +245,6 @@ exports.initialize =
|
|||||||
])
|
])
|
||||||
.then (answers) ->
|
.then (answers) ->
|
||||||
return if not answers.drive?
|
return if not answers.drive?
|
||||||
umount.umountAsync(answers.drive).tap ->
|
umountAsync(answers.drive).tap ->
|
||||||
console.info("You can safely remove #{answers.drive} now")
|
console.info("You can safely remove #{answers.drive} now")
|
||||||
.nodeify(done)
|
.nodeify(done)
|
||||||
|
@ -35,7 +35,7 @@ exports.wizard =
|
|||||||
primary: true
|
primary: true
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
capitano = Promise.promisifyAll(require('capitano'))
|
capitanoRunAsync = Promise.promisify(require('capitano').run)
|
||||||
resin = require('resin-sdk-preconfigured')
|
resin = require('resin-sdk-preconfigured')
|
||||||
patterns = require('../utils/patterns')
|
patterns = require('../utils/patterns')
|
||||||
|
|
||||||
@ -43,20 +43,20 @@ exports.wizard =
|
|||||||
return if isLoggedIn
|
return if isLoggedIn
|
||||||
console.info('Looks like you\'re not logged in yet!')
|
console.info('Looks like you\'re not logged in yet!')
|
||||||
console.info('Lets go through a quick wizard to get you started.\n')
|
console.info('Lets go through a quick wizard to get you started.\n')
|
||||||
return capitano.runAsync('login')
|
return capitanoRunAsync('login')
|
||||||
.then ->
|
.then ->
|
||||||
return if params.name?
|
return if params.name?
|
||||||
patterns.selectOrCreateApplication().tap (applicationName) ->
|
patterns.selectOrCreateApplication().tap (applicationName) ->
|
||||||
resin.models.application.has(applicationName).then (hasApplication) ->
|
resin.models.application.has(applicationName).then (hasApplication) ->
|
||||||
return applicationName if hasApplication
|
return applicationName if hasApplication
|
||||||
capitano.runAsync("app create #{applicationName}")
|
capitanoRunAsync("app create #{applicationName}")
|
||||||
.then (applicationName) ->
|
.then (applicationName) ->
|
||||||
params.name = applicationName
|
params.name = applicationName
|
||||||
.then ->
|
.then ->
|
||||||
return capitano.runAsync("device init --application #{params.name}")
|
return capitanoRunAsync("device init --application #{params.name}")
|
||||||
.tap(patterns.awaitDevice)
|
.tap(patterns.awaitDevice)
|
||||||
.then (uuid) ->
|
.then (uuid) ->
|
||||||
return capitano.runAsync("device #{uuid}")
|
return capitanoRunAsync("device #{uuid}")
|
||||||
.then ->
|
.then ->
|
||||||
return resin.models.application.get(params.name)
|
return resin.models.application.get(params.name)
|
||||||
.then (application) ->
|
.then (application) ->
|
||||||
|
@ -24,7 +24,8 @@ Raven.config(
|
|||||||
|
|
||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
capitano = Promise.promisifyAll(require('capitano'))
|
capitano = require('capitano')
|
||||||
|
capitanoExecuteAsync = Promise.promisify(capitano.execute)
|
||||||
resin = require('resin-sdk-preconfigured')
|
resin = require('resin-sdk-preconfigured')
|
||||||
actions = require('./actions')
|
actions = require('./actions')
|
||||||
errors = require('./errors')
|
errors = require('./errors')
|
||||||
@ -152,7 +153,7 @@ plugins.register(/^resin-plugin-(.+)$/).then ->
|
|||||||
|
|
||||||
events.trackCommand(cli).then ->
|
events.trackCommand(cli).then ->
|
||||||
if cli.global?.help
|
if cli.global?.help
|
||||||
return capitano.executeAsync(command: "help #{cli.command ? ''}")
|
return capitanoExecuteAsync(command: "help #{cli.command ? ''}")
|
||||||
capitano.executeAsync(cli)
|
capitanoExecuteAsync(cli)
|
||||||
|
|
||||||
.catch(errors.handle)
|
.catch(errors.handle)
|
||||||
|
@ -2,19 +2,20 @@ _ = require('lodash')
|
|||||||
Mixpanel = require('mixpanel')
|
Mixpanel = require('mixpanel')
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
resin = require('resin-sdk-preconfigured')
|
resin = require('resin-sdk-preconfigured')
|
||||||
capitanoState = Promise.promisifyAll(require('capitano').state)
|
|
||||||
packageJSON = require('../package.json')
|
packageJSON = require('../package.json')
|
||||||
|
|
||||||
exports.getLoggerInstance = _.memoize ->
|
exports.getLoggerInstance = _.memoize ->
|
||||||
return resin.models.config.getMixpanelToken().then(Mixpanel.init)
|
return resin.models.config.getMixpanelToken().then(Mixpanel.init)
|
||||||
|
|
||||||
exports.trackCommand = (capitanoCommand) ->
|
exports.trackCommand = (capitanoCommand) ->
|
||||||
|
capitanoStateGetMatchCommandAsync = Promise.promisify(require('capitano').state.getMatchCommand)
|
||||||
|
|
||||||
return Promise.props
|
return Promise.props
|
||||||
resinUrl: resin.settings.get('resinUrl')
|
resinUrl: resin.settings.get('resinUrl')
|
||||||
username: resin.auth.whoami()
|
username: resin.auth.whoami()
|
||||||
mixpanel: exports.getLoggerInstance()
|
mixpanel: exports.getLoggerInstance()
|
||||||
.then (data) ->
|
.then (data) ->
|
||||||
return capitanoState.getMatchCommandAsync(capitanoCommand.command).then (command) ->
|
return capitanoStateGetMatchCommandAsync(capitanoCommand.command).then (command) ->
|
||||||
data.mixpanel.track "[CLI] #{command.signature.toString()}",
|
data.mixpanel.track "[CLI] #{command.signature.toString()}",
|
||||||
distinct_id: data.username
|
distinct_id: data.username
|
||||||
argv: process.argv.join(' ')
|
argv: process.argv.join(' ')
|
||||||
|
@ -15,8 +15,6 @@ limitations under the License.
|
|||||||
###
|
###
|
||||||
|
|
||||||
Promise = require('bluebird')
|
Promise = require('bluebird')
|
||||||
capitano = Promise.promisifyAll(require('capitano'))
|
|
||||||
president = Promise.promisifyAll(require('president'))
|
|
||||||
|
|
||||||
exports.getGroupDefaults = (group) ->
|
exports.getGroupDefaults = (group) ->
|
||||||
_ = require('lodash')
|
_ = require('lodash')
|
||||||
@ -53,7 +51,8 @@ exports.sudo = (command) ->
|
|||||||
console.log('If asked please type your computer password to continue')
|
console.log('If asked please type your computer password to continue')
|
||||||
|
|
||||||
command = _.union(_.take(process.argv, 2), command)
|
command = _.union(_.take(process.argv, 2), command)
|
||||||
return president.executeAsync(command)
|
presidentExecuteAsync = Promise.promisify(require('president').execute)
|
||||||
|
return presidentExecuteAsync(command)
|
||||||
|
|
||||||
exports.getManifest = (image, deviceType) ->
|
exports.getManifest = (image, deviceType) ->
|
||||||
rindle = require('rindle')
|
rindle = require('rindle')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user