mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-06-24 18:45:07 +00:00
Compare commits
187 Commits
Author | SHA1 | Date | |
---|---|---|---|
5619bdbb67 | |||
381e63bfc9 | |||
e779347ff2 | |||
8fa906dd48 | |||
7e5ecd634d | |||
29cf4c1e89 | |||
73736abdea | |||
9ab411bade | |||
ef33156de7 | |||
6d8fd6e547 | |||
bab90a8bf2 | |||
43f0288c6c | |||
47e6371e2e | |||
5e400ed335 | |||
56a78b57af | |||
2bfeb7f42c | |||
37e0f12f89 | |||
fdd0e4a966 | |||
38df7e0038 | |||
e9efb78280 | |||
0424d7b640 | |||
2b80c7c91f | |||
142e2c0a65 | |||
1ed9ae7d60 | |||
329bf25dbd | |||
e18ffba183 | |||
ae3f0b429d | |||
34736c4e9b | |||
806678ee5f | |||
1e70401bdd | |||
3c7615f20d | |||
054d5e4879 | |||
b04ed43bed | |||
c2bbb952c5 | |||
63a9e1859b | |||
68ef069e6a | |||
72d4b21cb4 | |||
e8b931680d | |||
218b407f30 | |||
773cc27145 | |||
1c76e2e15b | |||
e466cfd6ff | |||
992b04d521 | |||
5c16c86871 | |||
78af9bbb10 | |||
b78c48d89f | |||
1f8c610bb0 | |||
d220728380 | |||
db58e9986c | |||
2a5e66eca6 | |||
e7e8ec296c | |||
80e69c56d0 | |||
ce3c6aecff | |||
300f76ba83 | |||
a4e8a38bf4 | |||
9bb04f43a8 | |||
9b0c08bd46 | |||
679d48e86e | |||
4b6bf60531 | |||
d8ce6648e2 | |||
402bc2d3a8 | |||
f3e193be0f | |||
f5b461612b | |||
d2514a3fc3 | |||
2019f9fdeb | |||
656f3e5cd9 | |||
741acfbba3 | |||
4b7eca02a0 | |||
c7788a80e1 | |||
08648894e3 | |||
4c5d5697bc | |||
c758a5b9ea | |||
2af54e2e28 | |||
cf9b23b987 | |||
f8380ec8e6 | |||
cd3245a631 | |||
144a155208 | |||
7f7ca13001 | |||
361e149063 | |||
fab85b381a | |||
faecf103bf | |||
a0f8c1aa8c | |||
24726b575d | |||
688b89a099 | |||
2e39110cc0 | |||
193cedae26 | |||
3d1f023ef5 | |||
9bb51d7146 | |||
84900aa588 | |||
b2bce3c4ac | |||
8c11620a42 | |||
7c1e0ac2e9 | |||
9a3c844336 | |||
69039d21c2 | |||
34c9cdd8bb | |||
0a8b30e824 | |||
ea5b521262 | |||
3bc71577b5 | |||
0fb24162fc | |||
d0d63f5bbb | |||
8041905144 | |||
37d96e238d | |||
ae8c941bfe | |||
4c16835ca4 | |||
7bd8922a4e | |||
42b2e2fcf0 | |||
f7256e9927 | |||
85444a5a6a | |||
ac115c7ea3 | |||
3c2a440553 | |||
b29ce3ee04 | |||
2b4394f3ce | |||
60f704eaa9 | |||
caa4fcf754 | |||
c4d1e4244e | |||
a6dc155028 | |||
9c65d11e66 | |||
26f50e7a74 | |||
e4773da1d7 | |||
dfd8086f63 | |||
ec513c61ad | |||
a96ab487ba | |||
cd28c985ce | |||
727af42ad4 | |||
e96d411f3e | |||
4a7d3d5945 | |||
03f05305cf | |||
af6e9ef85d | |||
8533a4a303 | |||
85f9234c74 | |||
064afd6705 | |||
978ff91f87 | |||
5cebbce7bb | |||
1cd0f02db5 | |||
77695bb505 | |||
4e4428fdbb | |||
6e978d74dd | |||
58974af77b | |||
11a0eae7a0 | |||
2a4ba895e5 | |||
19c019076e | |||
dfa18d3cb3 | |||
782c92885d | |||
a14dfa6cf1 | |||
f3b6f9d117 | |||
63b2b3feb6 | |||
9237dd25ac | |||
df9c4ce2fd | |||
fa5a7abbbf | |||
cd8bb7882e | |||
3c0378142a | |||
a524bffaa2 | |||
4b3decbe03 | |||
fa258a84cc | |||
5efa7309be | |||
6e6a01c33c | |||
94ce15bc2c | |||
b20ed34756 | |||
0b188b7ce9 | |||
80e0f20301 | |||
8410a709c9 | |||
13011cca23 | |||
53197856ab | |||
cb5bb69b47 | |||
4bfe52d73b | |||
58f557065e | |||
9d8228e1c6 | |||
fec840b897 | |||
8fbde4c452 | |||
0cc1765a1e | |||
f0346b1fd0 | |||
1bb798a8b8 | |||
4c35badcad | |||
6ba97cd961 | |||
af08a2f306 | |||
ded24432a5 | |||
bf124f196f | |||
6fc2d5eee1 | |||
dbe181ea84 | |||
dd169d356a | |||
4fbc016d18 | |||
e00ee40bea | |||
9c7b36e1d8 | |||
cefa9d1e31 | |||
e64f8fe0db | |||
06020c0344 | |||
9038b76d73 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -32,3 +32,4 @@ bin/node
|
||||
release/build
|
||||
|
||||
npm-shrinkwrap.json
|
||||
.resinconf
|
||||
|
5
.hound.yml
Normal file
5
.hound.yml
Normal file
@ -0,0 +1,5 @@
|
||||
coffee_script:
|
||||
config_file: coffeelint.json
|
||||
|
||||
java_script:
|
||||
enabled: false
|
@ -3,6 +3,7 @@
|
||||
[](http://badge.fury.io/js/resin-cli)
|
||||
[](https://david-dm.org/resin-io/resin-cli.png)
|
||||
[](https://travis-ci.org/resin-io/resin-cli)
|
||||
[](https://ci.appveyor.com/project/jviotti/resin-cli)
|
||||
|
||||
The official Resin CLI tool.
|
||||
|
||||
|
27
appveyor.yml
Normal file
27
appveyor.yml
Normal file
@ -0,0 +1,27 @@
|
||||
# appveyor file
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
|
||||
init:
|
||||
- git config --global core.autocrlf input
|
||||
|
||||
# what combinations to test
|
||||
environment:
|
||||
matrix:
|
||||
- nodejs_version: 0.10
|
||||
- nodejs_version: 0.11
|
||||
- nodejs_version: 0.12
|
||||
|
||||
install:
|
||||
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
|
||||
- npm -g install npm@2
|
||||
- set PATH=%APPDATA%\npm;%PATH%
|
||||
- npm install -g gulp
|
||||
- npm install
|
||||
|
||||
build: off
|
||||
|
||||
test_script:
|
||||
- node --version
|
||||
- npm --version
|
||||
- ps: gulp test
|
||||
- cmd: gulp test
|
@ -1,5 +1,7 @@
|
||||
(function() {
|
||||
var _, async, commandOptions, resin, visuals;
|
||||
var _, async, commandOptions, path, resin, vcs, visuals;
|
||||
|
||||
path = require('path');
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
|
||||
@ -11,6 +13,8 @@
|
||||
|
||||
commandOptions = require('./command-options');
|
||||
|
||||
vcs = require('resin-vcs');
|
||||
|
||||
exports.create = {
|
||||
signature: 'app create <name>',
|
||||
description: 'create an application',
|
||||
@ -27,17 +31,21 @@
|
||||
action: function(params, options, done) {
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
return resin.models.application.has(params.name, callback);
|
||||
}, function(hasApplication, callback) {
|
||||
if (hasApplication) {
|
||||
return callback(new Error('You already have an application with that name!'));
|
||||
}
|
||||
if (options.type != null) {
|
||||
return callback(null, options.type);
|
||||
}
|
||||
return resin.models.device.getSupportedDeviceTypes(function(error, deviceTypes) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
return visuals.widgets.select('Select a type', deviceTypes, callback);
|
||||
});
|
||||
return visuals.patterns.selectDeviceType(callback);
|
||||
}, function(type, callback) {
|
||||
return resin.models.application.create(params.name, type, callback);
|
||||
options.type = type;
|
||||
return resin.models.application.create(params.name, options.type, callback);
|
||||
}, function(applicationId, callback) {
|
||||
console.info("Application created: " + params.name + " (" + options.type + ", id " + applicationId + ")");
|
||||
return callback();
|
||||
}
|
||||
], done);
|
||||
}
|
||||
@ -46,7 +54,7 @@
|
||||
exports.list = {
|
||||
signature: 'apps',
|
||||
description: 'list all applications',
|
||||
help: 'Use this command to list all your applications.\n\nNotice this command only shows the most important bits of information for each app.\nIf you want detailed information, use resin app <id> instead.\n\nExamples:\n\n $ resin apps',
|
||||
help: 'Use this command to list all your applications.\n\nNotice this command only shows the most important bits of information for each app.\nIf you want detailed information, use resin app <name> instead.\n\nExamples:\n\n $ resin apps',
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return resin.models.application.getAll(function(error, applications) {
|
||||
@ -60,12 +68,12 @@
|
||||
};
|
||||
|
||||
exports.info = {
|
||||
signature: 'app <id>',
|
||||
signature: 'app <name>',
|
||||
description: 'list a single application',
|
||||
help: 'Use this command to show detailed information for a single application.\n\nExamples:\n\n $ resin app 91',
|
||||
help: 'Use this command to show detailed information for a single application.\n\nExamples:\n\n $ resin app MyApp',
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return resin.models.application.get(params.id, function(error, application) {
|
||||
return resin.models.application.get(params.name, function(error, application) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
@ -76,50 +84,98 @@
|
||||
};
|
||||
|
||||
exports.restart = {
|
||||
signature: 'app restart <id>',
|
||||
signature: 'app restart <name>',
|
||||
description: 'restart an application',
|
||||
help: 'Use this command to restart all devices that belongs to a certain application.\n\nExamples:\n\n $ resin app restart 91',
|
||||
help: 'Use this command to restart all devices that belongs to a certain application.\n\nExamples:\n\n $ resin app restart MyApp',
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return resin.models.application.restart(params.id, done);
|
||||
return resin.models.application.restart(params.name, done);
|
||||
}
|
||||
};
|
||||
|
||||
exports.remove = {
|
||||
signature: 'app rm <id>',
|
||||
signature: 'app rm <name>',
|
||||
description: 'remove an application',
|
||||
help: 'Use this command to remove a resin.io application.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin app rm 91\n $ resin app rm 91 --yes',
|
||||
help: 'Use this command to remove a resin.io application.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin app rm MyApp\n $ resin app rm MyApp --yes',
|
||||
options: [commandOptions.yes],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return visuals.patterns.remove('application', options.yes, function(callback) {
|
||||
return resin.models.application.remove(params.id, callback);
|
||||
return resin.models.application.remove(params.name, callback);
|
||||
}, done);
|
||||
}
|
||||
};
|
||||
|
||||
exports.init = {
|
||||
signature: 'init <id>',
|
||||
description: 'init an application',
|
||||
help: 'Use this command to associate a local project to an existing resin.io application.\n\nThe application should be a git repository before issuing this command.\nNotice this command adds a `resin` git remote to your application.\n\nExamples:\n\n $ cd myApp && resin init 91',
|
||||
exports.associate = {
|
||||
signature: 'app associate <name>',
|
||||
description: 'associate a resin project',
|
||||
help: 'Use this command to associate a project directory with a resin application.\n\nThis command adds a \'resin\' git remote to the directory and runs git init if necessary.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin app associate MyApp\n $ resin app associate MyApp --project my/app/directory',
|
||||
options: [commandOptions.yes],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
var currentDirectory;
|
||||
currentDirectory = process.cwd();
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
return resin.vcs.isResinProject(currentDirectory, callback);
|
||||
}, function(isResinProject, callback) {
|
||||
var error;
|
||||
if (isResinProject) {
|
||||
error = new Error('Project is already a resin application.');
|
||||
return callback(error);
|
||||
return resin.models.application.has(params.name, callback);
|
||||
}, function(hasApp, callback) {
|
||||
var message;
|
||||
if (!hasApp) {
|
||||
return callback(new Error("Invalid application: " + params.name));
|
||||
}
|
||||
return callback();
|
||||
message = "Are you sure you want to associate " + currentDirectory + " with " + params.name + "?";
|
||||
return visuals.patterns.confirm(options.yes, message, callback);
|
||||
}, function(confirmed, callback) {
|
||||
if (!confirmed) {
|
||||
return done();
|
||||
}
|
||||
return vcs.initialize(currentDirectory, callback);
|
||||
}, function(callback) {
|
||||
return resin.models.application.get(params.id, callback);
|
||||
return resin.models.application.get(params.name, callback);
|
||||
}, function(application, callback) {
|
||||
return resin.vcs.initProjectWithApplication(application, currentDirectory, callback);
|
||||
return vcs.addRemote(currentDirectory, application.git_repository, callback);
|
||||
}
|
||||
], function(error, remoteUrl) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
console.info("git repository added: " + remoteUrl);
|
||||
return done(null, remoteUrl);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.init = {
|
||||
signature: 'init',
|
||||
description: 'init an application',
|
||||
help: 'Use this command to initialise a directory as a resin application.\n\nThis command performs the following steps:\n - Create a resin.io application.\n - Initialize the current directory as a git repository.\n - Add the corresponding git remote to the application.\n\nExamples:\n\n $ resin init\n $ resin init --project my/app/directory',
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
var currentDirectory;
|
||||
currentDirectory = process.cwd();
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
var currentDirectoryBasename;
|
||||
currentDirectoryBasename = path.basename(currentDirectory);
|
||||
return visuals.form.ask({
|
||||
label: 'What is the name of your application?',
|
||||
name: 'application',
|
||||
type: 'text',
|
||||
value: currentDirectoryBasename
|
||||
}, callback);
|
||||
}, function(applicationName, callback) {
|
||||
return exports.create.action({
|
||||
name: applicationName
|
||||
}, options, function(error) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
return callback(null, applicationName);
|
||||
});
|
||||
}, function(applicationName, callback) {
|
||||
return exports.associate.action({
|
||||
name: applicationName
|
||||
}, options, callback);
|
||||
}
|
||||
], done);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
(function() {
|
||||
var _, async, resin, url, visuals;
|
||||
var TOKEN_URL, _, async, open, resin, settings, url, visuals;
|
||||
|
||||
open = require('open');
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
|
||||
@ -9,45 +11,36 @@
|
||||
|
||||
resin = require('resin-sdk');
|
||||
|
||||
settings = require('resin-settings-client');
|
||||
|
||||
visuals = require('resin-cli-visuals');
|
||||
|
||||
TOKEN_URL = url.resolve(settings.get('dashboardUrl'), '/preferences');
|
||||
|
||||
exports.login = {
|
||||
signature: 'login',
|
||||
signature: 'login [token]',
|
||||
description: 'login to resin.io',
|
||||
help: 'Use this command to login to your resin.io account.\nYou need to login before you can use most of the commands this tool provides.\n\nYou can pass your credentials as `--username` and `--password` options, or you can omit the\ncredentials, in which case the tool will present you with an interactive login form.\n\nExamples:\n\n $ resin login --username <username> --password <password>\n $ resin login',
|
||||
options: [
|
||||
{
|
||||
signature: 'username',
|
||||
parameter: 'username',
|
||||
description: 'user name',
|
||||
alias: 'u'
|
||||
}, {
|
||||
signature: 'password',
|
||||
parameter: 'password',
|
||||
description: 'user password',
|
||||
alias: 'p'
|
||||
}
|
||||
],
|
||||
help: "Use this command to login to your resin.io account.\n\nTo login, you need your token, which is accesible from the preferences page:\n\n " + TOKEN_URL + "\n\nExamples:\n\n $ resin login\n $ resin login \"eyJ0eXAiOiJKV1Qi...\"",
|
||||
action: function(params, options, done) {
|
||||
var hasOptionCredentials;
|
||||
hasOptionCredentials = !_.isEmpty(options);
|
||||
if (hasOptionCredentials) {
|
||||
if (!options.username) {
|
||||
return done(new Error('Missing username'));
|
||||
}
|
||||
if (!options.password) {
|
||||
return done(new Error('Missing password'));
|
||||
}
|
||||
}
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
if (hasOptionCredentials) {
|
||||
return callback(null, options);
|
||||
} else {
|
||||
return visuals.widgets.login(callback);
|
||||
if (params.token != null) {
|
||||
return callback(null, params.token);
|
||||
}
|
||||
}, function(credentials, callback) {
|
||||
return resin.auth.login(credentials, callback);
|
||||
console.info("To login to the Resin CLI, you need your unique token, which is accesible from\nthe preferences page at " + TOKEN_URL + "\n\nAttempting to open a browser at that location...");
|
||||
return open(TOKEN_URL, function(error) {
|
||||
if (error != null) {
|
||||
console.error("Unable to open a web browser in the current environment.\nPlease visit " + TOKEN_URL + " manually.");
|
||||
}
|
||||
return visuals.patterns.loginWithToken(callback);
|
||||
});
|
||||
}, function(token, callback) {
|
||||
return resin.auth.loginWithToken(token, callback);
|
||||
}, function(callback) {
|
||||
return resin.auth.whoami(callback);
|
||||
}, function(username, callback) {
|
||||
console.info("Successfully logged in as: " + username);
|
||||
return callback();
|
||||
}
|
||||
], done);
|
||||
}
|
||||
@ -104,7 +97,7 @@
|
||||
if (hasOptionCredentials) {
|
||||
return callback(null, options);
|
||||
}
|
||||
return visuals.widgets.register(callback);
|
||||
return visuals.patterns.register(callback);
|
||||
}, function(credentials, callback) {
|
||||
return resin.auth.register(credentials, function(error, token) {
|
||||
return callback(error, credentials);
|
||||
@ -123,10 +116,14 @@
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return resin.auth.whoami(function(error, username) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
if (username == null) {
|
||||
return done(new Error('Username not found'));
|
||||
}
|
||||
return console.log(username);
|
||||
console.log(username);
|
||||
return done();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,8 @@
|
||||
(function() {
|
||||
var _;
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
exports.yes = {
|
||||
signature: 'yes',
|
||||
description: 'confirm non interactively',
|
||||
@ -6,12 +10,29 @@
|
||||
alias: 'y'
|
||||
};
|
||||
|
||||
exports.application = {
|
||||
exports.optionalApplication = {
|
||||
signature: 'application',
|
||||
parameter: 'application',
|
||||
description: 'application id',
|
||||
alias: ['a', 'app'],
|
||||
description: 'application name',
|
||||
alias: ['a', 'app']
|
||||
};
|
||||
|
||||
exports.application = _.defaults({
|
||||
required: 'You have to specify an application'
|
||||
}, exports.optionalApplication);
|
||||
|
||||
exports.optionalDevice = {
|
||||
signature: 'device',
|
||||
parameter: 'device',
|
||||
description: 'device name',
|
||||
alias: 'd'
|
||||
};
|
||||
|
||||
exports.booleanDevice = {
|
||||
signature: 'device',
|
||||
description: 'device name',
|
||||
boolean: true,
|
||||
alias: 'd'
|
||||
};
|
||||
|
||||
exports.network = {
|
||||
|
@ -1,5 +1,9 @@
|
||||
(function() {
|
||||
var _, async, commandOptions, osAction, path, resin, visuals;
|
||||
var _, async, capitano, commandOptions, fse, image, inject, manager, path, pine, registerDevice, resin, tmp, vcs, visuals;
|
||||
|
||||
fse = require('fs-extra');
|
||||
|
||||
capitano = require('capitano');
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
|
||||
@ -11,34 +15,54 @@
|
||||
|
||||
visuals = require('resin-cli-visuals');
|
||||
|
||||
commandOptions = require('./command-options');
|
||||
vcs = require('resin-vcs');
|
||||
|
||||
osAction = require('./os');
|
||||
manager = require('resin-image-manager');
|
||||
|
||||
image = require('resin-image');
|
||||
|
||||
inject = require('resin-config-inject');
|
||||
|
||||
registerDevice = require('resin-register-device');
|
||||
|
||||
pine = require('resin-pine');
|
||||
|
||||
tmp = require('tmp');
|
||||
|
||||
tmp.setGracefulCleanup();
|
||||
|
||||
commandOptions = require('./command-options');
|
||||
|
||||
exports.list = {
|
||||
signature: 'devices',
|
||||
description: 'list all devices',
|
||||
help: 'Use this command to list all devices that belong to a certain application.\n\nExamples:\n\n $ resin devices --application 91',
|
||||
options: [commandOptions.application],
|
||||
help: 'Use this command to list all devices that belong to you.\n\nYou can filter the devices by application by using the `--application` option.\n\nExamples:\n\n $ resin devices\n $ resin devices --application MyApp\n $ resin devices --app MyApp\n $ resin devices -a MyApp',
|
||||
options: [commandOptions.optionalApplication],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return resin.models.device.getAllByApplication(options.application, function(error, devices) {
|
||||
var getFunction;
|
||||
if (options.application != null) {
|
||||
getFunction = _.partial(resin.models.device.getAllByApplication, options.application);
|
||||
} else {
|
||||
getFunction = resin.models.device.getAll;
|
||||
}
|
||||
return getFunction(function(error, devices) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
console.log(visuals.widgets.table.horizontal(devices, ['id', 'name', 'device_type', 'is_online', 'application_name', 'status', 'last_seen']));
|
||||
return done();
|
||||
return done(null, devices);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.info = {
|
||||
signature: 'device <id>',
|
||||
signature: 'device <name>',
|
||||
description: 'list a single device',
|
||||
help: 'Use this command to show information about a single device.\n\nExamples:\n\n $ resin device 317',
|
||||
help: 'Use this command to show information about a single device.\n\nExamples:\n\n $ resin device MyDevice',
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return resin.models.device.get(params.id, function(error, device) {
|
||||
return resin.models.device.get(params.name, function(error, device) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
@ -49,14 +73,14 @@
|
||||
};
|
||||
|
||||
exports.remove = {
|
||||
signature: 'device rm <id>',
|
||||
signature: 'device rm <name>',
|
||||
description: 'remove a device',
|
||||
help: 'Use this command to remove a device from resin.io.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin device rm 317\n $ resin device rm 317 --yes',
|
||||
help: 'Use this command to remove a device from resin.io.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin device rm MyDevice\n $ resin device rm MyDevice --yes',
|
||||
options: [commandOptions.yes],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return visuals.patterns.remove('device', options.yes, function(callback) {
|
||||
return resin.models.device.remove(params.id, callback);
|
||||
return resin.models.device.remove(params.name, callback);
|
||||
}, done);
|
||||
}
|
||||
};
|
||||
@ -72,19 +96,23 @@
|
||||
};
|
||||
|
||||
exports.rename = {
|
||||
signature: 'device rename <id> [name]',
|
||||
signature: 'device rename <name> [newName]',
|
||||
description: 'rename a resin device',
|
||||
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 317 MyPi\n $ resin device rename 317',
|
||||
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 MyDevice MyPi\n $ resin device rename MyDevice',
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
if (!_.isEmpty(params.name)) {
|
||||
return callback(null, params.name);
|
||||
if (!_.isEmpty(params.newName)) {
|
||||
return callback(null, params.newName);
|
||||
}
|
||||
return visuals.widgets.ask('How do you want to name this device?', callback);
|
||||
}, function(name, callback) {
|
||||
return resin.models.device.rename(params.id, name, callback);
|
||||
return visuals.form.ask({
|
||||
label: 'How do you want to name this device?',
|
||||
name: 'device',
|
||||
type: 'text'
|
||||
}, callback);
|
||||
}, function(newName, callback) {
|
||||
return resin.models.device.rename(params.name, newName, callback);
|
||||
}
|
||||
], done);
|
||||
}
|
||||
@ -106,32 +134,157 @@
|
||||
}
|
||||
};
|
||||
|
||||
exports.await = {
|
||||
signature: 'device await <name>',
|
||||
description: 'await for a device to become online',
|
||||
help: 'Use this command to await for a device to become online.\n\nThe process will exit when the device becomes online.\n\nNotice that there is no time limit for this command, so it might run forever.\n\nYou can configure the poll interval with the --interval option (defaults to 3000ms).\n\nExamples:\n\n $ resin device await MyDevice\n $ resin device await MyDevice --interval 1000',
|
||||
options: [
|
||||
{
|
||||
signature: 'interval',
|
||||
parameter: 'interval',
|
||||
description: 'poll interval',
|
||||
alias: 'i'
|
||||
}
|
||||
],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
var poll;
|
||||
if (options.interval == null) {
|
||||
options.interval = 3000;
|
||||
}
|
||||
poll = function() {
|
||||
return resin.models.device.isOnline(params.name, function(error, isOnline) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
if (isOnline) {
|
||||
console.info("Device became online: " + params.name);
|
||||
return done();
|
||||
} else {
|
||||
console.info("Polling device network status: " + params.name);
|
||||
return setTimeout(poll, options.interval);
|
||||
}
|
||||
});
|
||||
};
|
||||
return poll();
|
||||
}
|
||||
};
|
||||
|
||||
exports.init = {
|
||||
signature: 'device init [device]',
|
||||
description: 'initialise a device with resin os',
|
||||
help: 'Use this command to download the OS image of a certain application and write it to an SD Card.\n\nNote that this command requires admin privileges.\n\nIf `device` is omitted, you will be prompted to select a device interactively.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nYou can quiet the progress bar by passing the `--quiet` boolean option.\n\nYou may have to unmount the device before attempting this operation.\n\nYou need to configure the network type and other settings:\n\nEthernet:\n You can setup the device OS to use ethernet by setting the `--network` option to "ethernet".\n\nWifi:\n You can setup the device OS to use wifi by setting the `--network` option to "wifi".\n If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.\n\nExamples:\n\n $ resin device init --application 91 --network ethernet\n $ resin device init /dev/disk2 --application 91 --network wifi --ssid MyNetwork --key secret',
|
||||
options: [commandOptions.application, commandOptions.network, commandOptions.wifiSsid, commandOptions.wifiKey],
|
||||
help: 'Use this command to download the OS image of a certain application and write it to an SD Card.\n\nNote that this command requires admin privileges.\n\nIf `device` is omitted, you will be prompted to select a device interactively.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nYou can quiet the progress bar and other logging information by passing the `--quiet` boolean option.\n\nYou need to configure the network type and other settings:\n\nEthernet:\n You can setup the device OS to use ethernet by setting the `--network` option to "ethernet".\n\nWifi:\n You can setup the device OS to use wifi by setting the `--network` option to "wifi".\n If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.\n\nYou can omit network related options to be asked about them interactively.\n\nExamples:\n\n $ resin device init\n $ resin device init --application MyApp\n $ resin device init --application MyApp --network ethernet\n $ resin device init /dev/disk2 --application MyApp --network wifi --ssid MyNetwork --key secret',
|
||||
options: [commandOptions.optionalApplication, commandOptions.network, commandOptions.wifiSsid, commandOptions.wifiKey],
|
||||
permission: 'user',
|
||||
root: true,
|
||||
action: function(params, options, done) {
|
||||
params.id = options.application;
|
||||
var networkOptions;
|
||||
networkOptions = {
|
||||
network: options.network,
|
||||
wifiSsid: options.ssid,
|
||||
wifiKey: options.key
|
||||
};
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
if (options.application != null) {
|
||||
return callback(null, options.application);
|
||||
}
|
||||
return vcs.getApplicationName(process.cwd(), callback);
|
||||
}, function(applicationName, callback) {
|
||||
options.application = applicationName;
|
||||
return resin.models.application.has(options.application, callback);
|
||||
}, function(hasApplication, callback) {
|
||||
if (!hasApplication) {
|
||||
return callback(new Error("Invalid application: " + options.application));
|
||||
}
|
||||
if (params.device != null) {
|
||||
return callback(null, params.device);
|
||||
}
|
||||
return visuals.patterns.selectDrive(callback);
|
||||
}, function(device, callback) {
|
||||
var message;
|
||||
params.device = device;
|
||||
return visuals.patterns.confirm(options.yes, "This will completely erase " + params.device + ". Are you sure you want to continue?", callback);
|
||||
message = "This will completely erase " + params.device + ". Are you sure you want to continue?";
|
||||
return visuals.patterns.confirm(options.yes, message, callback);
|
||||
}, function(confirmed, callback) {
|
||||
if (!confirmed) {
|
||||
return done();
|
||||
}
|
||||
options.yes = confirmed;
|
||||
return osAction.download.action(params, options, callback);
|
||||
}, function(outputFile, callback) {
|
||||
params.image = outputFile;
|
||||
return osAction.install.action(params, options, callback);
|
||||
if (networkOptions.network != null) {
|
||||
return callback();
|
||||
}
|
||||
return visuals.patterns.selectNetworkParameters(function(error, parameters) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
_.extend(networkOptions, parameters);
|
||||
return callback();
|
||||
});
|
||||
}, function(callback) {
|
||||
console.info("Checking application: " + options.application);
|
||||
return resin.models.application.get(options.application, callback);
|
||||
}, function(application, callback) {
|
||||
return async.parallel({
|
||||
manifest: function(callback) {
|
||||
console.info('Getting device manifest for the application');
|
||||
return resin.models.device.getManifestBySlug(application.device_type, callback);
|
||||
},
|
||||
config: function(callback) {
|
||||
console.info('Fetching application configuration');
|
||||
return resin.models.application.getConfiguration(options.application, networkOptions, callback);
|
||||
}
|
||||
}, callback);
|
||||
}, function(results, callback) {
|
||||
console.info('Associating the device');
|
||||
return registerDevice.register(pine, results.config, function(error, device) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
results.config.deviceId = device.id;
|
||||
results.config.uuid = device.uuid;
|
||||
params.uuid = results.config.uuid;
|
||||
return callback(null, results);
|
||||
});
|
||||
}, function(results, callback) {
|
||||
var bar, spinner;
|
||||
console.info('Configuring device operating system image');
|
||||
if (process.env.DEBUG) {
|
||||
console.log(results.config);
|
||||
}
|
||||
bar = new visuals.widgets.Progress('Downloading Device OS');
|
||||
spinner = new visuals.widgets.Spinner('Downloading Device OS (size unknown)');
|
||||
return manager.configure(results.manifest, results.config, function(error, imagePath, removeCallback) {
|
||||
spinner.stop();
|
||||
return callback(error, imagePath, removeCallback);
|
||||
}, function(state) {
|
||||
if (state != null) {
|
||||
return bar.update(state);
|
||||
} else {
|
||||
return spinner.start();
|
||||
}
|
||||
});
|
||||
}, function(configuredImagePath, removeCallback, callback) {
|
||||
var bar;
|
||||
console.info('Attempting to write operating system image to drive');
|
||||
bar = new visuals.widgets.Progress('Writing Device OS');
|
||||
return image.write({
|
||||
device: params.device,
|
||||
image: configuredImagePath,
|
||||
progress: _.bind(bar.update, bar)
|
||||
}, function(error) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
return callback(null, configuredImagePath, removeCallback);
|
||||
});
|
||||
}, function(temporalImagePath, removeCallback, callback) {
|
||||
console.info('Image written successfully');
|
||||
return removeCallback(callback);
|
||||
}, function(callback) {
|
||||
return resin.models.device.getByUUID(params.uuid, callback);
|
||||
}, function(device, callback) {
|
||||
console.info("Device created: " + device.name);
|
||||
return callback(null, device.name);
|
||||
}
|
||||
], done);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
(function() {
|
||||
var _, commandOptions, resin, visuals;
|
||||
var _, async, commandOptions, resin, visuals;
|
||||
|
||||
async = require('async');
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
|
||||
@ -12,9 +14,9 @@
|
||||
exports.list = {
|
||||
signature: 'envs',
|
||||
description: 'list all environment variables',
|
||||
help: 'Use this command to list all environment variables for a particular application.\nNotice we will support per-device environment variables soon.\n\nThis command lists all custom environment variables set on the devices running\nthe application. If you want to see all environment variables, including private\nones used by resin, use the verbose option.\n\nExample:\n\n $ resin envs --application 91\n $ resin envs --application 91 --verbose',
|
||||
help: 'Use this command to list all environment variables for\na particular application or device.\n\nThis command lists all custom environment variables.\nIf you want to see all environment variables, including private\nones used by resin, use the verbose option.\n\nExample:\n\n $ resin envs --application MyApp\n $ resin envs --application MyApp --verbose\n $ resin envs --device MyDevice',
|
||||
options: [
|
||||
commandOptions.application, {
|
||||
commandOptions.optionalApplication, commandOptions.optionalDevice, {
|
||||
signature: 'verbose',
|
||||
description: 'show private environment variables',
|
||||
boolean: true,
|
||||
@ -23,28 +25,41 @@
|
||||
],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return resin.models.environmentVariables.getAllByApplication(options.application, function(error, environmentVariables) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
if (options.application != null) {
|
||||
return resin.models.environmentVariables.getAllByApplication(options.application, callback);
|
||||
} else if (options.device != null) {
|
||||
return resin.models.environmentVariables.device.getAll(options.device, callback);
|
||||
} else {
|
||||
return callback(new Error('You must specify an application or device'));
|
||||
}
|
||||
}, function(environmentVariables, callback) {
|
||||
var isSystemVariable;
|
||||
if (!options.verbose) {
|
||||
isSystemVariable = resin.models.environmentVariables.isSystemVariable;
|
||||
environmentVariables = _.reject(environmentVariables, isSystemVariable);
|
||||
}
|
||||
console.log(visuals.widgets.table.horizontal(environmentVariables, ['id', 'name', 'value']));
|
||||
return callback();
|
||||
}
|
||||
if (!options.verbose) {
|
||||
environmentVariables = _.reject(environmentVariables, resin.models.environmentVariables.isSystemVariable);
|
||||
}
|
||||
console.log(visuals.widgets.table.horizontal(environmentVariables, ['id', 'name', 'value']));
|
||||
return done();
|
||||
});
|
||||
], done);
|
||||
}
|
||||
};
|
||||
|
||||
exports.remove = {
|
||||
signature: 'env rm <id>',
|
||||
description: 'remove an environment variable',
|
||||
help: 'Use this command to remove an environment variable from an application.\n\nDon\'t remove resin specific variables, as things might not work as expected.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nExamples:\n\n $ resin env rm 215\n $ resin env rm 215 --yes',
|
||||
options: [commandOptions.yes],
|
||||
help: 'Use this command to remove an environment variable from an application.\n\nDon\'t remove resin specific variables, as things might not work as expected.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nIf you want to eliminate a device environment variable, pass the `--device` boolean option.\n\nExamples:\n\n $ resin env rm 215\n $ resin env rm 215 --yes\n $ resin env rm 215 --device',
|
||||
options: [commandOptions.yes, commandOptions.booleanDevice],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return visuals.patterns.remove('environment variable', options.yes, function(callback) {
|
||||
return resin.models.environmentVariables.remove(params.id, callback);
|
||||
if (options.device) {
|
||||
return resin.models.environmentVariables.device.remove(params.id, callback);
|
||||
} else {
|
||||
return resin.models.environmentVariables.remove(params.id, callback);
|
||||
}
|
||||
}, done);
|
||||
}
|
||||
};
|
||||
@ -52,8 +67,8 @@
|
||||
exports.add = {
|
||||
signature: 'env add <key> [value]',
|
||||
description: 'add an environment variable',
|
||||
help: 'Use this command to add an enviroment variable to an application.\n\nYou need to pass the `--application` option.\n\nIf value is omitted, the tool will attempt to use the variable\'s value\nas defined in your host machine.\n\nIf the value is grabbed from the environment, a warning message will be printed.\nUse `--quiet` to remove it.\n\nExamples:\n\n $ resin env add EDITOR vim -a 91\n $ resin env add TERM -a 91',
|
||||
options: [commandOptions.application],
|
||||
help: 'Use this command to add an enviroment variable to an application.\n\nIf value is omitted, the tool will attempt to use the variable\'s value\nas defined in your host machine.\n\nUse the `--device` option if you want to assign the environment variable\nto a specific device.\n\nIf the value is grabbed from the environment, a warning message will be printed.\nUse `--quiet` to remove it.\n\nExamples:\n\n $ resin env add EDITOR vim --application MyApp\n $ resin env add TERM --application MyApp\n $ resin env add EDITOR vim --device MyDevice',
|
||||
options: [commandOptions.optionalApplication, commandOptions.optionalDevice],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
if (params.value == null) {
|
||||
@ -64,17 +79,28 @@
|
||||
console.info("Warning: using " + params.key + "=" + params.value + " from host environment");
|
||||
}
|
||||
}
|
||||
return resin.models.environmentVariables.create(options.application, params.key, params.value, done);
|
||||
if (options.application != null) {
|
||||
return resin.models.environmentVariables.create(options.application, params.key, params.value, done);
|
||||
} else if (options.device != null) {
|
||||
return resin.models.environmentVariables.device.create(options.device, params.key, params.value, done);
|
||||
} else {
|
||||
return done(new Error('You must specify an application or device'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.rename = {
|
||||
signature: 'env rename <id> <value>',
|
||||
description: 'rename an environment variable',
|
||||
help: 'Use this command to rename an enviroment variable from an application.\n\nExamples:\n\n $ resin env rename 376 emacs',
|
||||
help: 'Use this command to rename an enviroment variable from an application.\n\nPass the `--device` boolean option if you want to rename a device environment variable.\n\nExamples:\n\n $ resin env rename 376 emacs\n $ resin env rename 376 emacs --device',
|
||||
permission: 'user',
|
||||
options: [commandOptions.booleanDevice],
|
||||
action: function(params, options, done) {
|
||||
return resin.models.environmentVariables.update(params.id, params.value, done);
|
||||
if (options.device) {
|
||||
return resin.models.environmentVariables.device.update(params.id, params.value, done);
|
||||
} else {
|
||||
return resin.models.environmentVariables.update(params.id, params.value, done);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
(function() {
|
||||
var _, async, examplesData, fs, gitCli, path, resin, visuals;
|
||||
var _, async, examplesData, fs, mkdirp, path, resin, vcs, visuals;
|
||||
|
||||
mkdirp = require('mkdirp');
|
||||
|
||||
async = require('async');
|
||||
|
||||
@ -9,12 +11,12 @@
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
gitCli = require('git-cli');
|
||||
|
||||
resin = require('resin-sdk');
|
||||
|
||||
visuals = require('resin-cli-visuals');
|
||||
|
||||
vcs = require('resin-vcs');
|
||||
|
||||
examplesData = require('../data/examples.json');
|
||||
|
||||
exports.list = {
|
||||
@ -33,59 +35,54 @@
|
||||
}
|
||||
return example;
|
||||
});
|
||||
return console.log(visuals.widgets.table.horizontal(examplesData, ['id', 'display_name', 'repository', 'author']));
|
||||
return console.log(visuals.widgets.table.horizontal(examplesData, ['id', 'name', 'display_name', 'repository', 'author']));
|
||||
}
|
||||
};
|
||||
|
||||
exports.info = {
|
||||
signature: 'example <id>',
|
||||
signature: 'example <name>',
|
||||
description: 'list a single example application',
|
||||
help: 'Use this command to show information of a single example application\n\nExample:\n\n $ resin example 3',
|
||||
help: 'Use this command to show information of a single example application\n\nExample:\n\n $ resin example cimon',
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
var example, id;
|
||||
id = params.id - 1;
|
||||
example = examplesData[id];
|
||||
var example;
|
||||
example = _.findWhere(examplesData, {
|
||||
name: params.name
|
||||
});
|
||||
if (example == null) {
|
||||
return done(new Error("Unknown example: " + id));
|
||||
return done(new Error("Unknown example: " + params.name));
|
||||
}
|
||||
example.id = id;
|
||||
if (example.author == null) {
|
||||
example.author = 'Unknown';
|
||||
}
|
||||
console.log(visuals.widgets.table.vertical(example, ['id', 'display_name', 'description', 'author', 'repository']));
|
||||
console.log(visuals.widgets.table.vertical(example, ['name', 'display_name', 'description', 'author', 'repository']));
|
||||
return done();
|
||||
}
|
||||
};
|
||||
|
||||
exports.clone = {
|
||||
signature: 'example clone <id>',
|
||||
signature: 'example clone <name>',
|
||||
description: 'clone an example application',
|
||||
help: 'Use this command to clone an example application to the current directory\n\nThis command outputs information about the cloning process.\nUse `--quiet` to remove that output.\n\nExample:\n\n $ resin example clone 3',
|
||||
help: 'Use this command to clone an example application to the current directory\n\nThis command outputs information about the cloning process.\nUse `--quiet` to remove that output.\n\nExample:\n\n $ resin example clone cimon',
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
var example;
|
||||
example = examplesData[params.id - 1];
|
||||
var currentDirectory, destination, example;
|
||||
example = _.findWhere(examplesData, {
|
||||
name: params.name
|
||||
});
|
||||
if (example == null) {
|
||||
return done(new Error("Unknown example: " + id));
|
||||
return done(new Error("Unknown example: " + params.name));
|
||||
}
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
var exampleAbsolutePath;
|
||||
exampleAbsolutePath = path.join(process.cwd(), example.name);
|
||||
return fs.exists(exampleAbsolutePath, function(exists) {
|
||||
var error;
|
||||
if (!exists) {
|
||||
return callback();
|
||||
}
|
||||
error = new Error("Directory exists: " + example.name);
|
||||
return callback(error);
|
||||
});
|
||||
}, function(callback) {
|
||||
console.info("Cloning " + example.display_name + " to " + example.name);
|
||||
return gitCli.Repository.clone(example.repository, example.name, callback);
|
||||
currentDirectory = process.cwd();
|
||||
destination = path.join(currentDirectory, example.name);
|
||||
return mkdirp(destination, function(error) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
], done);
|
||||
console.info("Cloning " + example.display_name + " to " + destination);
|
||||
vcs.clone(example.repository, destination, done);
|
||||
return done();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -10,10 +10,10 @@
|
||||
logs: require('./logs'),
|
||||
notes: require('./notes'),
|
||||
preferences: require('./preferences'),
|
||||
os: require('./os'),
|
||||
help: require('./help'),
|
||||
examples: require('./examples'),
|
||||
plugin: require('./plugin')
|
||||
plugin: require('./plugin'),
|
||||
update: require('./update')
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
@ -1,15 +1,32 @@
|
||||
(function() {
|
||||
var packageJSON;
|
||||
var packageJSON, settings;
|
||||
|
||||
settings = require('resin-settings-client');
|
||||
|
||||
packageJSON = require('../../package.json');
|
||||
|
||||
exports.version = {
|
||||
signature: 'version',
|
||||
description: 'output the version number',
|
||||
help: 'Display the Resin CLI, as well as the bundled NodeJS version.',
|
||||
action: function() {
|
||||
console.log(packageJSON.name + ": " + packageJSON.version);
|
||||
return console.log("node: " + process.version);
|
||||
help: 'Display the Resin CLI version.',
|
||||
action: function(params, options, done) {
|
||||
console.log(packageJSON.version);
|
||||
return done();
|
||||
}
|
||||
};
|
||||
|
||||
exports.config = {
|
||||
signature: 'config',
|
||||
description: 'see your current configuration',
|
||||
help: 'See your current Resin CLI configuration.\n\nConfiguration lives in $HOME/.resin/config.',
|
||||
action: function(params, options, done) {
|
||||
var key, ref, value;
|
||||
ref = settings.get();
|
||||
for (key in ref) {
|
||||
value = ref[key];
|
||||
console.log(key + ": " + value);
|
||||
}
|
||||
return done();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
(function() {
|
||||
var _, async, capitano, commandOptions, fs, resin, visuals;
|
||||
var SSH_KEY_WIDTH, _, async, capitano, commandOptions, fs, resin, visuals;
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
@ -33,6 +33,8 @@
|
||||
}
|
||||
};
|
||||
|
||||
SSH_KEY_WIDTH = 43;
|
||||
|
||||
exports.info = {
|
||||
signature: 'key <id>',
|
||||
description: 'list a single ssh key',
|
||||
@ -40,12 +42,9 @@
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return resin.models.key.get(params.id, function(error, key) {
|
||||
var sshKeyWidth;
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
sshKeyWidth = resin.settings.get('sshKeyWidth');
|
||||
key.public_key = '\n' + visuals.helpers.chop(key.public_key, sshKeyWidth);
|
||||
console.log(visuals.widgets.table.vertical(key, ['id', 'title', 'public_key']));
|
||||
return done();
|
||||
});
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
LOGS_HISTORY_COUNT = 200;
|
||||
|
||||
exports.logs = {
|
||||
module.exports = {
|
||||
signature: 'logs <uuid>',
|
||||
description: 'show device logs',
|
||||
help: 'Use this command to show logs for a specific device.\n\nBy default, the command prints all log messages and exit.\n\nTo limit the output to the n last lines, use the `--num` option along with a number.\nThis is similar to doing `resin logs <uuid> | tail -n X`.\n\nTo continuously stream output, and see new logs in real time, use the `--tail` option.\n\nNote that for now you need to provide the whole UUID for this command to work correctly,\nand the tool won\'t notice if you\'re using an invalid UUID.\n\nThis is due to some technical limitations that we plan to address soon.\n\nExamples:\n\n $ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828\n $ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828 --num 20\n $ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828 --tail',
|
||||
help: 'Use this command to show logs for a specific device.\n\nBy default, the command prints all log messages and exit.\n\nTo limit the output to the n last lines, use the `--num` option along with a number.\nThis is similar to doing `resin logs <uuid> | tail -n X`.\n\nTo continuously stream output, and see new logs in real time, use the `--tail` option.\n\nNote that for now you need to provide the whole UUID for this command to work correctly.\n\nThis is due to some technical limitations that we plan to address soon.\n\nExamples:\n\n $ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828\n $ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828 --num 20\n $ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828 --tail',
|
||||
options: [
|
||||
{
|
||||
signature: 'num',
|
||||
@ -35,10 +35,10 @@
|
||||
}
|
||||
if (_.isArray(message)) {
|
||||
_.each(message, function(line) {
|
||||
return console.log(line);
|
||||
return console.log(line.message);
|
||||
});
|
||||
} else {
|
||||
console.log(message);
|
||||
console.log(message.message);
|
||||
}
|
||||
return done();
|
||||
});
|
||||
|
@ -1,5 +1,7 @@
|
||||
(function() {
|
||||
var async, resin;
|
||||
var _, async, resin;
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
async = require('async');
|
||||
|
||||
@ -8,18 +10,21 @@
|
||||
exports.set = {
|
||||
signature: 'note <|note>',
|
||||
description: 'set a device note',
|
||||
help: 'Use this command to set or update a device note.\n\nIf note command isn\'t passed, the tool attempts to read from `stdin`.\n\nTo view the notes, use $ resin device <id>.\n\nExamples:\n\n $ resin note "My useful note" --device 317\n $ cat note.txt | resin note --device 317',
|
||||
help: 'Use this command to set or update a device note.\n\nIf note command isn\'t passed, the tool attempts to read from `stdin`.\n\nTo view the notes, use $ resin device <name>.\n\nExamples:\n\n $ resin note "My useful note" --device MyDevice\n $ cat note.txt | resin note --device MyDevice',
|
||||
options: [
|
||||
{
|
||||
signature: 'device',
|
||||
parameter: 'device',
|
||||
description: 'device id',
|
||||
description: 'device name',
|
||||
alias: ['d', 'dev'],
|
||||
required: 'You have to specify a device'
|
||||
}
|
||||
],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
if (_.isEmpty(params.note)) {
|
||||
return done(new Error('Missing note content'));
|
||||
}
|
||||
return resin.models.device.note(options.device, params.note, done);
|
||||
}
|
||||
};
|
||||
|
@ -1,137 +0,0 @@
|
||||
(function() {
|
||||
var _, async, commandOptions, diskio, fs, mkdirp, os, path, progressStream, resin, visuals;
|
||||
|
||||
_ = require('lodash-contrib');
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
os = require('os');
|
||||
|
||||
async = require('async');
|
||||
|
||||
path = require('path');
|
||||
|
||||
mkdirp = require('mkdirp');
|
||||
|
||||
resin = require('resin-sdk');
|
||||
|
||||
visuals = require('resin-cli-visuals');
|
||||
|
||||
progressStream = require('progress-stream');
|
||||
|
||||
diskio = require('diskio');
|
||||
|
||||
commandOptions = require('./command-options');
|
||||
|
||||
exports.download = {
|
||||
signature: 'os download <id>',
|
||||
description: 'download device OS',
|
||||
help: 'Use this command to download the device OS configured to a specific network.\n\nEthernet:\n You can setup the device OS to use ethernet by setting the `--network` option to "ethernet".\n\nWifi:\n You can setup the device OS to use wifi by setting the `--network` option to "wifi".\n If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.\n\nBy default, this command saved the downloaded image into a resin specific directory.\nYou can save it to a custom location by specifying the `--output` option.\n\nExamples:\n\n $ resin os download 91 --network ethernet\n $ resin os download 91 --network wifi --ssid MyNetwork --key secreykey123\n $ resin os download 91 --network ethernet --output ~/MyResinOS.zip',
|
||||
options: [
|
||||
commandOptions.network, commandOptions.wifiSsid, commandOptions.wifiKey, {
|
||||
signature: 'output',
|
||||
parameter: 'output',
|
||||
description: 'output file',
|
||||
alias: 'o'
|
||||
}
|
||||
],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
var fileName, osParams;
|
||||
osParams = {
|
||||
network: options.network,
|
||||
wifiSsid: options.ssid,
|
||||
wifiKey: options.key,
|
||||
appId: params.id
|
||||
};
|
||||
fileName = resin.models.os.generateCacheName(osParams);
|
||||
if (options.output == null) {
|
||||
options.output = path.join(resin.settings.get('directories.os'), fileName);
|
||||
}
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
return mkdirp(path.dirname(options.output), _.unary(callback));
|
||||
}, function(callback) {
|
||||
var bar;
|
||||
console.info("Destination file: " + options.output + "\n");
|
||||
bar = new visuals.widgets.Progress('Downloading Device OS');
|
||||
return resin.models.os.download(osParams, options.output, callback, function(state) {
|
||||
return bar.update(state);
|
||||
});
|
||||
}
|
||||
], function(error) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
console.info("\nFinished downloading " + options.output);
|
||||
return done(null, options.output);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.install = {
|
||||
signature: 'os install <image> [device]',
|
||||
description: 'write an operating system image to a device',
|
||||
help: 'Use this command to write an operating system image to a device.\n\nNote that this command requires admin privileges.\n\nIf `device` is omitted, you will be prompted to select a device interactively.\n\nNotice this command asks for confirmation interactively.\nYou can avoid this by passing the `--yes` boolean option.\n\nYou can quiet the progress bar by passing the `--quiet` boolean option.\n\nYou may have to unmount the device before attempting this operation.\n\nSee the `drives` command to get a list of all connected devices to your machine and their respective ids.\n\nIn Mac OS X:\n\n $ sudo diskutil unmountDisk /dev/xxx\n\nIn GNU/Linux:\n\n $ sudo umount /dev/xxx\n\nExamples:\n\n $ resin os install rpi.iso /dev/disk2',
|
||||
options: [commandOptions.yes],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
return async.waterfall([
|
||||
function(callback) {
|
||||
if (params.device != null) {
|
||||
return callback(null, params.device);
|
||||
}
|
||||
return visuals.patterns.selectDrive(function(error, device) {
|
||||
if (error != null) {
|
||||
return callback(error);
|
||||
}
|
||||
if (device == null) {
|
||||
return callback(new Error('No removable devices available'));
|
||||
}
|
||||
return callback(null, device);
|
||||
});
|
||||
}, function(device, callback) {
|
||||
var message;
|
||||
params.device = device;
|
||||
message = "This will completely erase " + params.device + ". Are you sure you want to continue?";
|
||||
return visuals.patterns.confirm(options.yes, message, callback);
|
||||
}, function(confirmed, callback) {
|
||||
var bar, error, imageFileSize, imageFileStream, progress;
|
||||
if (!confirmed) {
|
||||
return done();
|
||||
}
|
||||
imageFileSize = fs.statSync(params.image).size;
|
||||
if (imageFileSize === 0) {
|
||||
error = new Error("Invalid OS image: " + params.image + ". The image is 0 bytes.");
|
||||
return callback(error);
|
||||
}
|
||||
progress = progressStream({
|
||||
length: imageFileSize,
|
||||
time: 500
|
||||
});
|
||||
if (!options.quiet) {
|
||||
bar = new visuals.widgets.Progress('Writing Device OS');
|
||||
progress.on('progress', function(status) {
|
||||
return bar.update(status);
|
||||
});
|
||||
}
|
||||
imageFileStream = fs.createReadStream(params.image).pipe(progress);
|
||||
return diskio.writeStream(params.device, imageFileStream, callback);
|
||||
}
|
||||
], function(error) {
|
||||
var resinWritePath, windosu;
|
||||
if (error == null) {
|
||||
return done();
|
||||
}
|
||||
if (_.all([os.platform() === 'win32', error.code === 'EPERM' || error.code === 'EACCES', !options.fromScript])) {
|
||||
windosu = require('windosu');
|
||||
resinWritePath = "\"" + (path.join(__dirname, '..', '..', 'bin', 'resin-write')) + "\"";
|
||||
return windosu.exec("\"" + process.argv[0] + "\" " + resinWritePath + " \"" + params.image + "\" \"" + params.device + "\"");
|
||||
} else {
|
||||
return done(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
@ -1,11 +1,11 @@
|
||||
(function() {
|
||||
var open, resin, url;
|
||||
var open, settings, url;
|
||||
|
||||
open = require('open');
|
||||
|
||||
url = require('url');
|
||||
|
||||
resin = require('resin-sdk');
|
||||
settings = require('resin-settings-client');
|
||||
|
||||
exports.preferences = {
|
||||
signature: 'preferences',
|
||||
@ -13,9 +13,8 @@
|
||||
help: 'Use this command to open the preferences form.\n\nIn the future, we will allow changing all preferences directly from the terminal.\nFor now, we open your default web browser and point it to the web based preferences form.\n\nExamples:\n\n $ resin preferences',
|
||||
permission: 'user',
|
||||
action: function() {
|
||||
var absUrl, preferencesUrl;
|
||||
preferencesUrl = resin.settings.get('urls.preferences');
|
||||
absUrl = url.resolve(resin.settings.get('remoteUrl'), preferencesUrl);
|
||||
var absUrl;
|
||||
absUrl = url.resolve(settings.get('remoteUrl'), '/preferences');
|
||||
return open(absUrl);
|
||||
}
|
||||
};
|
||||
|
23
build/actions/update.js
Normal file
23
build/actions/update.js
Normal file
@ -0,0 +1,23 @@
|
||||
(function() {
|
||||
var packageJSON, selfupdate;
|
||||
|
||||
selfupdate = require('selfupdate');
|
||||
|
||||
packageJSON = require('../../package.json');
|
||||
|
||||
exports.update = {
|
||||
signature: 'update',
|
||||
description: 'update the resin cli',
|
||||
help: 'Use this command to update the Resin CLI\n\nThis command outputs information about the update process.\nUse `--quiet` to remove that output.\n\nThe Resin CLI checks for updates once per day.\n\nMajor updates require a manual update with this update command,\nwhile minor updates are applied automatically.\n\nExamples:\n\n $ resin update',
|
||||
action: function(params, options, done) {
|
||||
return selfupdate.update(packageJSON, function(error, version) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
console.info("Updated " + packageJSON.name + " to version " + version + ".");
|
||||
return done();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}).call(this);
|
48
build/app.js
48
build/app.js
@ -1,5 +1,5 @@
|
||||
(function() {
|
||||
var _, actions, async, capitano, changeProjectDirectory, errors, plugins, resin;
|
||||
var _, actions, async, capitano, changeProjectDirectory, errors, plugins, resin, update;
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
@ -15,8 +15,13 @@
|
||||
|
||||
plugins = require('./plugins');
|
||||
|
||||
update = require('./update');
|
||||
|
||||
capitano.permission('user', function(done) {
|
||||
return resin.auth.isLoggedIn(function(isLoggedIn) {
|
||||
return resin.auth.isLoggedIn(function(error, isLoggedIn) {
|
||||
if (error != null) {
|
||||
return done(error);
|
||||
}
|
||||
if (!isLoggedIn) {
|
||||
return done(new Error('You have to log in'));
|
||||
}
|
||||
@ -47,6 +52,13 @@
|
||||
alias: 'j'
|
||||
});
|
||||
|
||||
capitano.globalOption({
|
||||
signature: 'version',
|
||||
description: actions.info.version.description,
|
||||
boolean: true,
|
||||
alias: 'v'
|
||||
});
|
||||
|
||||
capitano.globalOption({
|
||||
signature: 'no-color',
|
||||
description: 'disable colour highlighting',
|
||||
@ -55,6 +67,8 @@
|
||||
|
||||
capitano.command(actions.info.version);
|
||||
|
||||
capitano.command(actions.info.config);
|
||||
|
||||
capitano.command(actions.help.help);
|
||||
|
||||
capitano.command(actions.auth.login);
|
||||
@ -69,14 +83,16 @@
|
||||
|
||||
capitano.command(actions.app.list);
|
||||
|
||||
capitano.command(actions.app.info);
|
||||
|
||||
capitano.command(actions.app.remove);
|
||||
|
||||
capitano.command(actions.app.restart);
|
||||
|
||||
capitano.command(actions.app.associate);
|
||||
|
||||
capitano.command(actions.app.init);
|
||||
|
||||
capitano.command(actions.app.info);
|
||||
|
||||
capitano.command(actions.device.list);
|
||||
|
||||
capitano.command(actions.device.supported);
|
||||
@ -85,6 +101,8 @@
|
||||
|
||||
capitano.command(actions.device.init);
|
||||
|
||||
capitano.command(actions.device.await);
|
||||
|
||||
capitano.command(actions.device.info);
|
||||
|
||||
capitano.command(actions.device.remove);
|
||||
@ -113,11 +131,7 @@
|
||||
|
||||
capitano.command(actions.env.remove);
|
||||
|
||||
capitano.command(actions.logs.logs);
|
||||
|
||||
capitano.command(actions.os.download);
|
||||
|
||||
capitano.command(actions.os.install);
|
||||
capitano.command(actions.logs);
|
||||
|
||||
capitano.command(actions.examples.list);
|
||||
|
||||
@ -133,6 +147,8 @@
|
||||
|
||||
capitano.command(actions.plugin.remove);
|
||||
|
||||
capitano.command(actions.update.update);
|
||||
|
||||
changeProjectDirectory = function(directory) {
|
||||
try {
|
||||
return process.chdir(directory);
|
||||
@ -143,21 +159,23 @@
|
||||
|
||||
async.waterfall([
|
||||
function(callback) {
|
||||
return plugins.register('resin-plugin-', callback);
|
||||
return update.check(callback);
|
||||
}, function(callback) {
|
||||
var dataPrefix;
|
||||
dataPrefix = resin.settings.get('dataPrefix');
|
||||
return resin.data.prefix.set(dataPrefix, callback);
|
||||
return plugins.register('resin-plugin-', callback);
|
||||
}, function(callback) {
|
||||
var cli;
|
||||
cli = capitano.parse(process.argv);
|
||||
if (cli.global.quiet) {
|
||||
if (cli.global.quiet || !process.stdout.isTTY) {
|
||||
console.info = _.noop;
|
||||
}
|
||||
if (cli.global.project != null) {
|
||||
changeProjectDirectory(cli.global.project);
|
||||
}
|
||||
return capitano.execute(cli, callback);
|
||||
if (cli.global.version) {
|
||||
return actions.info.version.action(null, null, callback);
|
||||
} else {
|
||||
return capitano.execute(cli, callback);
|
||||
}
|
||||
}
|
||||
], errors.handle);
|
||||
|
||||
|
25
build/elevate.js
Normal file
25
build/elevate.js
Normal file
@ -0,0 +1,25 @@
|
||||
(function() {
|
||||
var _, isWindows, os, path;
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
os = require('os');
|
||||
|
||||
path = require('path');
|
||||
|
||||
isWindows = function() {
|
||||
return os.platform() === 'win32';
|
||||
};
|
||||
|
||||
exports.shouldElevate = function(error) {
|
||||
return _.all([isWindows(), error.code === 'EPERM' || error.code === 'EACCES']);
|
||||
};
|
||||
|
||||
exports.run = function(command) {
|
||||
if (!isWindows()) {
|
||||
return;
|
||||
}
|
||||
return require('windosu').exec(command);
|
||||
};
|
||||
|
||||
}).call(this);
|
@ -28,6 +28,8 @@
|
||||
message += 'Try running this command again prefixing it with `sudo`.';
|
||||
}
|
||||
console.error(message);
|
||||
} else if (error.code === 'ENOGIT') {
|
||||
console.error('Git is not installed on this system.\nHead over to http://git-scm.com to install it and run this command again.');
|
||||
} else if (error.message != null) {
|
||||
console.error(error.message);
|
||||
}
|
||||
|
@ -1,68 +0,0 @@
|
||||
{
|
||||
"name": "resin-cli",
|
||||
"version": "0.0.1",
|
||||
"description": "Git Push to your devices",
|
||||
"main": "./lib/actions/index.coffee",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@bitbucket.org:rulemotion/resin-cli.git"
|
||||
},
|
||||
"preferGlobal": true,
|
||||
"bundled_engine": "v0.12.0",
|
||||
"man": [
|
||||
"./man/resin.1",
|
||||
"./man/resin-completion.1",
|
||||
"./man/resin-plugins.1"
|
||||
],
|
||||
"bin": {
|
||||
"resin": "./bin/resin"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "gulp build",
|
||||
"test": "gult test",
|
||||
"install": "node build/install-node.js bin/node"
|
||||
},
|
||||
"keywords": [
|
||||
"resin",
|
||||
"git"
|
||||
],
|
||||
"author": "Juan Cruz Viotti <juanchiviotti@gmail.com>",
|
||||
"license": "MIT",
|
||||
"optionalDependencies": {
|
||||
"windosu": "^0.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "~1.9.2",
|
||||
"gulp": "~3.8.9",
|
||||
"gulp-coffee": "^2.2.0",
|
||||
"gulp-coffeelint": "~0.4.0",
|
||||
"gulp-marked-man": "~0.3.1",
|
||||
"gulp-mocha": "~1.1.1",
|
||||
"gulp-shell": "^0.2.11",
|
||||
"gulp-util": "~3.0.1",
|
||||
"mocha": "~2.0.1",
|
||||
"mocha-notifier-reporter": "~0.1.0",
|
||||
"run-sequence": "~1.0.2",
|
||||
"sinon": "~1.12.1",
|
||||
"sinon-chai": "~2.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"async": "~0.9.0",
|
||||
"capitano": "~1.5.0",
|
||||
"coffee-script": "~1.8.0",
|
||||
"conf.js": "^0.1.1",
|
||||
"diskio": "^1.0.0",
|
||||
"drivelist": "^1.2.0",
|
||||
"git-cli": "~0.8.2",
|
||||
"lodash": "~2.4.1",
|
||||
"lodash-contrib": "~241.4.14",
|
||||
"mkdirp": "~0.5.0",
|
||||
"node-binary": "^1.0.1",
|
||||
"nplugm": "^2.0.0",
|
||||
"open": "0.0.5",
|
||||
"progress-stream": "^0.5.0",
|
||||
"resin-cli-visuals": "resin-io/resin-cli-visuals",
|
||||
"resin-sdk": "resin-io/resin-sdk",
|
||||
"underscore.string": "~2.4.0"
|
||||
}
|
||||
}
|
37
build/update.js
Normal file
37
build/update.js
Normal file
@ -0,0 +1,37 @@
|
||||
(function() {
|
||||
var packageJSON, updateAction, updateNotifier;
|
||||
|
||||
updateNotifier = require('update-notifier');
|
||||
|
||||
packageJSON = require('../package.json');
|
||||
|
||||
updateAction = require('./actions/update');
|
||||
|
||||
exports.perform = function(callback) {
|
||||
return updateAction.update.action(null, null, callback);
|
||||
};
|
||||
|
||||
exports.notify = function(update) {
|
||||
if (!process.stdout.isTTY) {
|
||||
return;
|
||||
}
|
||||
return console.log("> Major update available: " + update.current + " -> " + update.latest + "\n> Run resin update to update.\n> Beware that a major release might introduce breaking changes.\n");
|
||||
};
|
||||
|
||||
exports.check = function(callback) {
|
||||
var notifier;
|
||||
notifier = updateNotifier({
|
||||
pkg: packageJSON
|
||||
});
|
||||
if (notifier.update == null) {
|
||||
return callback();
|
||||
}
|
||||
if (notifier.update.type === 'major') {
|
||||
exports.notify(notifier.update);
|
||||
return callback();
|
||||
}
|
||||
console.log("Performing " + notifier.update.type + " update, hold tight...");
|
||||
return exports.perform(callback);
|
||||
};
|
||||
|
||||
}).call(this);
|
96
capitanodoc.json
Normal file
96
capitanodoc.json
Normal file
@ -0,0 +1,96 @@
|
||||
{
|
||||
"title": "Resin CLI Documentation",
|
||||
"introduction": "This tool allows you to interact with the resin.io api from the comfort of your command line.\n\nTo get started download the CLI from npm.\n\n\t$ npm install resin-cli -g\n\nThen authenticate yourself:\n\n\t$ resin login\n\nNow you have access to all the commands referenced below.",
|
||||
"categories": [
|
||||
{
|
||||
"title": "Application",
|
||||
"files": [
|
||||
"lib/actions/app.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Authentication",
|
||||
"files": [
|
||||
"lib/actions/auth.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Device",
|
||||
"files": [
|
||||
"lib/actions/device.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Drive",
|
||||
"files": [
|
||||
"lib/actions/drive.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Environment Variables",
|
||||
"files": [
|
||||
"lib/actions/environment-variables.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Examples",
|
||||
"files": [
|
||||
"lib/actions/examples.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Help",
|
||||
"files": [
|
||||
"lib/actions/help.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Information",
|
||||
"files": [
|
||||
"lib/actions/info.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Keys",
|
||||
"files": [
|
||||
"lib/actions/keys.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Logs",
|
||||
"files": [
|
||||
"lib/actions/logs.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Notes",
|
||||
"files": [
|
||||
"lib/actions/notes.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "OS",
|
||||
"files": [
|
||||
"lib/actions/os.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Plugin",
|
||||
"files": [
|
||||
"lib/actions/plugin.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Preferences",
|
||||
"files": [
|
||||
"lib/actions/preferences.coffee"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Update",
|
||||
"files": [
|
||||
"lib/actions/update.coffee"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
# app create <name>
|
||||
|
||||
Use this command to create a new resin.io application.
|
||||
|
||||
You can specify the application type with the `--type` option.
|
||||
Otherwise, an interactive dropdown will be shown for you to select from.
|
||||
|
||||
You can see a list of supported device types with
|
||||
|
||||
$ resin devices supported
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app create MyApp
|
||||
$ resin app create MyApp --type raspberry-pi
|
||||
|
||||
## Options
|
||||
|
||||
### --type, -t <type>
|
||||
|
||||
application type
|
@ -1,7 +0,0 @@
|
||||
# app <id>
|
||||
|
||||
Use this command to show detailed information for a single application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app 91
|
@ -1,10 +0,0 @@
|
||||
# init <id>
|
||||
|
||||
Use this command to associate a local project to an existing resin.io application.
|
||||
|
||||
The application should be a git repository before issuing this command.
|
||||
Notice this command adds a `resin` git remote to your application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ cd myApp && resin init 91
|
@ -1,10 +0,0 @@
|
||||
# apps
|
||||
|
||||
Use this command to list all your applications.
|
||||
|
||||
Notice this command only shows the most important bits of information for each app.
|
||||
If you want detailed information, use resin app <id> instead.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin apps
|
@ -1,17 +0,0 @@
|
||||
# app rm <id>
|
||||
|
||||
Use this command to remove a resin.io application.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app rm 91
|
||||
$ resin app rm 91 --yes
|
||||
|
||||
## Options
|
||||
|
||||
### --yes, -y
|
||||
|
||||
confirm non interactively
|
@ -1,7 +0,0 @@
|
||||
# app restart <id>
|
||||
|
||||
Use this command to restart all devices that belongs to a certain application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app restart 91
|
@ -1,22 +0,0 @@
|
||||
# login
|
||||
|
||||
Use this command to login to your resin.io account.
|
||||
You need to login before you can use most of the commands this tool provides.
|
||||
|
||||
You can pass your credentials as `--username` and `--password` options, or you can omit the
|
||||
credentials, in which case the tool will present you with an interactive login form.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin login --username <username> --password <password>
|
||||
$ resin login
|
||||
|
||||
## Options
|
||||
|
||||
### --username, -u <username>
|
||||
|
||||
user name
|
||||
|
||||
### --password, -p <password>
|
||||
|
||||
user password
|
@ -1,7 +0,0 @@
|
||||
# logout
|
||||
|
||||
Use this command to logout from your resin.io account.o
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin logout
|
@ -1,31 +0,0 @@
|
||||
# signup
|
||||
|
||||
Use this command to signup for a resin.io account.
|
||||
|
||||
If signup is successful, you'll be logged in to your new user automatically.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin signup
|
||||
Email: me@mycompany.com
|
||||
Username: johndoe
|
||||
Password: ***********
|
||||
|
||||
$ resin signup --email me@mycompany.com --username johndoe --password ***********
|
||||
|
||||
$ resin whoami
|
||||
johndoe
|
||||
|
||||
## Options
|
||||
|
||||
### --email, -e <email>
|
||||
|
||||
user email
|
||||
|
||||
### --username, -u <username>
|
||||
|
||||
user name
|
||||
|
||||
### --password, -p <user password>
|
||||
|
||||
user password
|
@ -1,7 +0,0 @@
|
||||
# whoami
|
||||
|
||||
Use this command to find out the current logged in username.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin whoami
|
791
doc/cli.markdown
Normal file
791
doc/cli.markdown
Normal file
@ -0,0 +1,791 @@
|
||||
# Resin CLI Documentation
|
||||
|
||||
This tool allows you to interact with the resin.io api from the comfort of your command line.
|
||||
|
||||
To get started download the CLI from npm.
|
||||
|
||||
$ npm install resin-cli -g
|
||||
|
||||
Then authenticate yourself:
|
||||
|
||||
$ resin login
|
||||
|
||||
Now you have access to all the commands referenced below.
|
||||
|
||||
# Table of contents
|
||||
|
||||
- Application
|
||||
|
||||
- [app create <name>](#/pages/using/cli.md#app-create-60-name-62-)
|
||||
- [apps](#/pages/using/cli.md#apps)
|
||||
- [app <name>](#/pages/using/cli.md#app-60-name-62-)
|
||||
- [app restart <name>](#/pages/using/cli.md#app-restart-60-name-62-)
|
||||
- [app rm <name>](#/pages/using/cli.md#app-rm-60-name-62-)
|
||||
- [app associate <name>](#/pages/using/cli.md#app-associate-60-name-62-)
|
||||
- [init](#/pages/using/cli.md#init)
|
||||
|
||||
- Authentication
|
||||
|
||||
- [login [token]](#/pages/using/cli.md#login-token-)
|
||||
- [logout](#/pages/using/cli.md#logout)
|
||||
- [signup](#/pages/using/cli.md#signup)
|
||||
- [whoami](#/pages/using/cli.md#whoami)
|
||||
|
||||
- Device
|
||||
|
||||
- [devices](#/pages/using/cli.md#devices)
|
||||
- [device <name>](#/pages/using/cli.md#device-60-name-62-)
|
||||
- [device rm <name>](#/pages/using/cli.md#device-rm-60-name-62-)
|
||||
- [device identify <uuid>](#/pages/using/cli.md#device-identify-60-uuid-62-)
|
||||
- [device rename <name> [newName]](#/pages/using/cli.md#device-rename-60-name-62-newname-)
|
||||
- [devices supported](#/pages/using/cli.md#devices-supported)
|
||||
- [device await <name>](#/pages/using/cli.md#device-await-60-name-62-)
|
||||
- [device init [device]](#/pages/using/cli.md#device-init-device-)
|
||||
|
||||
- Drive
|
||||
|
||||
- [drives](#/pages/using/cli.md#drives)
|
||||
|
||||
- Environment Variables
|
||||
|
||||
- [envs](#/pages/using/cli.md#envs)
|
||||
- [env rm <id>](#/pages/using/cli.md#env-rm-60-id-62-)
|
||||
- [env add <key> [value]](#/pages/using/cli.md#env-add-60-key-62-value-)
|
||||
- [env rename <id> <value>](#/pages/using/cli.md#env-rename-60-id-62-60-value-62-)
|
||||
|
||||
- Examples
|
||||
|
||||
- [examples](#/pages/using/cli.md#examples)
|
||||
- [example <id>](#/pages/using/cli.md#example-60-id-62-)
|
||||
- [example clone <id>](#/pages/using/cli.md#example-clone-60-id-62-)
|
||||
|
||||
- Help
|
||||
|
||||
- [help [command...]](#/pages/using/cli.md#help-command-)
|
||||
|
||||
- Information
|
||||
|
||||
- [version](#/pages/using/cli.md#version)
|
||||
|
||||
- Keys
|
||||
|
||||
- [keys](#/pages/using/cli.md#keys)
|
||||
- [key <id>](#/pages/using/cli.md#key-60-id-62-)
|
||||
- [key rm <id>](#/pages/using/cli.md#key-rm-60-id-62-)
|
||||
- [key add <name> [path]](#/pages/using/cli.md#key-add-60-name-62-path-)
|
||||
|
||||
- Logs
|
||||
|
||||
- [logs <uuid>](#/pages/using/cli.md#logs-60-uuid-62-)
|
||||
|
||||
- Notes
|
||||
|
||||
- [note <|note>](#/pages/using/cli.md#note-60-note-62-)
|
||||
|
||||
- OS
|
||||
|
||||
- [os download <name>](#/pages/using/cli.md#os-download-60-name-62-)
|
||||
- [os install <image> [device]](#/pages/using/cli.md#os-install-60-image-62-device-)
|
||||
|
||||
- Plugin
|
||||
|
||||
- [plugins](#/pages/using/cli.md#plugins)
|
||||
- [plugin install <name>](#/pages/using/cli.md#plugin-install-60-name-62-)
|
||||
- [plugin update <name>](#/pages/using/cli.md#plugin-update-60-name-62-)
|
||||
- [plugin rm <name>](#/pages/using/cli.md#plugin-rm-60-name-62-)
|
||||
|
||||
- Preferences
|
||||
|
||||
- [preferences](#/pages/using/cli.md#preferences)
|
||||
|
||||
- Update
|
||||
|
||||
- [update](#/pages/using/cli.md#update)
|
||||
|
||||
# Application
|
||||
|
||||
## app create <name>
|
||||
|
||||
Use this command to create a new resin.io application.
|
||||
|
||||
You can specify the application type with the `--type` option.
|
||||
Otherwise, an interactive dropdown will be shown for you to select from.
|
||||
|
||||
You can see a list of supported device types with
|
||||
|
||||
$ resin devices supported
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app create MyApp
|
||||
$ resin app create MyApp --type raspberry-pi
|
||||
|
||||
### Options
|
||||
|
||||
#### --type, -t <type>
|
||||
|
||||
application type
|
||||
|
||||
## apps
|
||||
|
||||
Use this command to list all your applications.
|
||||
|
||||
Notice this command only shows the most important bits of information for each app.
|
||||
If you want detailed information, use resin app <name> instead.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin apps
|
||||
|
||||
## app <name>
|
||||
|
||||
Use this command to show detailed information for a single application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app MyApp
|
||||
|
||||
## app restart <name>
|
||||
|
||||
Use this command to restart all devices that belongs to a certain application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app restart MyApp
|
||||
|
||||
## app rm <name>
|
||||
|
||||
Use this command to remove a resin.io application.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app rm MyApp
|
||||
$ resin app rm MyApp --yes
|
||||
|
||||
### Options
|
||||
|
||||
#### --yes, -y
|
||||
|
||||
confirm non interactively
|
||||
|
||||
## app associate <name>
|
||||
|
||||
Use this command to associate a project directory with a resin application.
|
||||
|
||||
This command adds a 'resin' git remote to the directory and runs git init if necessary.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app associate MyApp
|
||||
$ resin app associate MyApp --project my/app/directory
|
||||
|
||||
## init
|
||||
|
||||
Use this command to initialise a directory as a resin application.
|
||||
|
||||
This command performs the following steps:
|
||||
- Create a resin.io application.
|
||||
- Initialize the current directory as a git repository.
|
||||
- Add the corresponding git remote to the application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin init
|
||||
$ resin init --project my/app/directory
|
||||
|
||||
# Authentication
|
||||
|
||||
## login [token]
|
||||
|
||||
Use this command to login to your resin.io account.
|
||||
|
||||
To login, you need your token, which is accesible from the preferences page:
|
||||
|
||||
https://dashboard.resin.io/preferences
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin login
|
||||
$ resin login "eyJ0eXAiOiJKV1Qi..."
|
||||
|
||||
## logout
|
||||
|
||||
Use this command to logout from your resin.io account.o
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin logout
|
||||
|
||||
## signup
|
||||
|
||||
Use this command to signup for a resin.io account.
|
||||
|
||||
If signup is successful, you'll be logged in to your new user automatically.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin signup
|
||||
Email: me@mycompany.com
|
||||
Username: johndoe
|
||||
Password: ***********
|
||||
|
||||
$ resin signup --email me@mycompany.com --username johndoe --password ***********
|
||||
|
||||
$ resin whoami
|
||||
johndoe
|
||||
|
||||
### Options
|
||||
|
||||
#### --email, -e <email>
|
||||
|
||||
user email
|
||||
|
||||
#### --username, -u <username>
|
||||
|
||||
user name
|
||||
|
||||
#### --password, -p <user password>
|
||||
|
||||
user password
|
||||
|
||||
## whoami
|
||||
|
||||
Use this command to find out the current logged in username.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin whoami
|
||||
|
||||
# Device
|
||||
|
||||
## devices
|
||||
|
||||
Use this command to list all devices that belong to you.
|
||||
|
||||
You can filter the devices by application by using the `--application` option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin devices
|
||||
$ resin devices --application MyApp
|
||||
$ resin devices --app MyApp
|
||||
$ resin devices -a MyApp
|
||||
|
||||
### Options
|
||||
|
||||
#### --application, --a,app, --a,app <application>
|
||||
|
||||
application name
|
||||
|
||||
## device <name>
|
||||
|
||||
Use this command to show information about a single device.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device MyDevice
|
||||
|
||||
## device rm <name>
|
||||
|
||||
Use this command to remove a device from resin.io.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device rm MyDevice
|
||||
$ resin device rm MyDevice --yes
|
||||
|
||||
### Options
|
||||
|
||||
#### --yes, -y
|
||||
|
||||
confirm non interactively
|
||||
|
||||
## device identify <uuid>
|
||||
|
||||
Use this command to identify a device.
|
||||
|
||||
In the Raspberry Pi, the ACT led is blinked several times.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device identify 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
|
||||
|
||||
## device rename <name> [newName]
|
||||
|
||||
Use this command to rename a device.
|
||||
|
||||
If you omit the name, you'll get asked for it interactively.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device rename MyDevice MyPi
|
||||
$ resin device rename MyDevice
|
||||
|
||||
## devices supported
|
||||
|
||||
Use this command to get the list of all supported devices
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin devices supported
|
||||
|
||||
## device await <name>
|
||||
|
||||
Use this command to await for a device to become online.
|
||||
|
||||
The process will exit when the device becomes online.
|
||||
|
||||
Notice that there is no time limit for this command, so it might run forever.
|
||||
|
||||
You can configure the poll interval with the --interval option (defaults to 3000ms).
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device await MyDevice
|
||||
$ resin device await MyDevice --interval 1000
|
||||
|
||||
### Options
|
||||
|
||||
#### --interval, -i <interval>
|
||||
|
||||
poll interval
|
||||
|
||||
## device init [device]
|
||||
|
||||
Use this command to download the OS image of a certain application and write it to an SD Card.
|
||||
|
||||
Note that this command requires admin privileges.
|
||||
|
||||
If `device` is omitted, you will be prompted to select a device interactively.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
You can quiet the progress bar by passing the `--quiet` boolean option.
|
||||
|
||||
You may have to unmount the device before attempting this operation.
|
||||
|
||||
You need to configure the network type and other settings:
|
||||
|
||||
Ethernet:
|
||||
You can setup the device OS to use ethernet by setting the `--network` option to "ethernet".
|
||||
|
||||
Wifi:
|
||||
You can setup the device OS to use wifi by setting the `--network` option to "wifi".
|
||||
If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.
|
||||
|
||||
You can omit network related options to be asked about them interactively.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device init
|
||||
$ resin device init --application MyApp
|
||||
$ resin device init --application MyApp --network ethernet
|
||||
$ resin device init /dev/disk2 --application MyApp --network wifi --ssid MyNetwork --key secret
|
||||
|
||||
### Options
|
||||
|
||||
#### --application, --a,app, --a,app <application>
|
||||
|
||||
application name
|
||||
|
||||
#### --network, -n <network>
|
||||
|
||||
network type
|
||||
|
||||
#### --ssid, -s <ssid>
|
||||
|
||||
wifi ssid, if network is wifi
|
||||
|
||||
#### --key, -k <key>
|
||||
|
||||
wifi key, if network is wifi
|
||||
|
||||
# Drive
|
||||
|
||||
## drives
|
||||
|
||||
Use this command to list all drives that are connected to your machine.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin drives
|
||||
|
||||
# Environment Variables
|
||||
|
||||
## envs
|
||||
|
||||
Use this command to list all environment variables for a particular application.
|
||||
Notice we will support per-device environment variables soon.
|
||||
|
||||
This command lists all custom environment variables set on the devices running
|
||||
the application. If you want to see all environment variables, including private
|
||||
ones used by resin, use the verbose option.
|
||||
|
||||
Example:
|
||||
|
||||
$ resin envs --application 91
|
||||
$ resin envs --application 91 --verbose
|
||||
|
||||
### Options
|
||||
|
||||
#### --application, --a,app, --a,app <application>
|
||||
|
||||
application name
|
||||
|
||||
#### --verbose, -v
|
||||
|
||||
show private environment variables
|
||||
|
||||
## env rm <id>
|
||||
|
||||
Use this command to remove an environment variable from an application.
|
||||
|
||||
Don't remove resin specific variables, as things might not work as expected.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin env rm 215
|
||||
$ resin env rm 215 --yes
|
||||
|
||||
### Options
|
||||
|
||||
#### --yes, -y
|
||||
|
||||
confirm non interactively
|
||||
|
||||
## env add <key> [value]
|
||||
|
||||
Use this command to add an enviroment variable to an application.
|
||||
|
||||
You need to pass the `--application` option.
|
||||
|
||||
If value is omitted, the tool will attempt to use the variable's value
|
||||
as defined in your host machine.
|
||||
|
||||
If the value is grabbed from the environment, a warning message will be printed.
|
||||
Use `--quiet` to remove it.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin env add EDITOR vim -a 91
|
||||
$ resin env add TERM -a 91
|
||||
|
||||
### Options
|
||||
|
||||
#### --application, --a,app, --a,app <application>
|
||||
|
||||
application name
|
||||
|
||||
## env rename <id> <value>
|
||||
|
||||
Use this command to rename an enviroment variable from an application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin env rename 376 emacs
|
||||
|
||||
# Examples
|
||||
|
||||
## examples
|
||||
|
||||
Use this command to list available example applications from resin.io
|
||||
|
||||
Example:
|
||||
|
||||
$ resin examples
|
||||
|
||||
## example <id>
|
||||
|
||||
Use this command to show information of a single example application
|
||||
|
||||
Example:
|
||||
|
||||
$ resin example 3
|
||||
|
||||
## example clone <id>
|
||||
|
||||
Use this command to clone an example application to the current directory
|
||||
|
||||
This command outputs information about the cloning process.
|
||||
Use `--quiet` to remove that output.
|
||||
|
||||
Example:
|
||||
|
||||
$ resin example clone 3
|
||||
|
||||
# Help
|
||||
|
||||
## help [command...]
|
||||
|
||||
Get detailed help for an specific command.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin help apps
|
||||
$ resin help os download
|
||||
|
||||
# Information
|
||||
|
||||
## version
|
||||
|
||||
Display the Resin CLI version.
|
||||
|
||||
# Keys
|
||||
|
||||
## keys
|
||||
|
||||
Use this command to list all your SSH keys.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin keys
|
||||
|
||||
## key <id>
|
||||
|
||||
Use this command to show information about a single SSH key.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin key 17
|
||||
|
||||
## key rm <id>
|
||||
|
||||
Use this command to remove a SSH key from resin.io.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin key rm 17
|
||||
$ resin key rm 17 --yes
|
||||
|
||||
### Options
|
||||
|
||||
#### --yes, -y
|
||||
|
||||
confirm non interactively
|
||||
|
||||
## key add <name> [path]
|
||||
|
||||
Use this command to associate a new SSH key with your account.
|
||||
|
||||
If `path` is omitted, the command will attempt
|
||||
to read the SSH key from stdin.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin key add Main ~/.ssh/id_rsa.pub
|
||||
$ cat ~/.ssh/id_rsa.pub | resin key add Main
|
||||
|
||||
# Logs
|
||||
|
||||
## logs <uuid>
|
||||
|
||||
Use this command to show logs for a specific device.
|
||||
|
||||
By default, the command prints all log messages and exit.
|
||||
|
||||
To limit the output to the n last lines, use the `--num` option along with a number.
|
||||
This is similar to doing `resin logs <uuid> | tail -n X`.
|
||||
|
||||
To continuously stream output, and see new logs in real time, use the `--tail` option.
|
||||
|
||||
Note that for now you need to provide the whole UUID for this command to work correctly.
|
||||
|
||||
This is due to some technical limitations that we plan to address soon.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
|
||||
$ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828 --num 20
|
||||
$ resin logs 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828 --tail
|
||||
|
||||
### Options
|
||||
|
||||
#### --num, -n <num>
|
||||
|
||||
number of lines to display
|
||||
|
||||
#### --tail, -t
|
||||
|
||||
continuously stream output
|
||||
|
||||
# Notes
|
||||
|
||||
## note <|note>
|
||||
|
||||
Use this command to set or update a device note.
|
||||
|
||||
If note command isn't passed, the tool attempts to read from `stdin`.
|
||||
|
||||
To view the notes, use $ resin device <name>.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin note "My useful note" --device MyDevice
|
||||
$ cat note.txt | resin note --device MyDevice
|
||||
|
||||
### Options
|
||||
|
||||
#### --device, --d,dev, --d,dev <device>
|
||||
|
||||
device name
|
||||
|
||||
# OS
|
||||
|
||||
## os download <name>
|
||||
|
||||
Use this command to download the device OS configured to a specific network.
|
||||
|
||||
Ethernet:
|
||||
You can setup the device OS to use ethernet by setting the `--network` option to "ethernet".
|
||||
|
||||
Wifi:
|
||||
You can setup the device OS to use wifi by setting the `--network` option to "wifi".
|
||||
If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.
|
||||
|
||||
Alternatively, you can omit all kind of network configuration options to configure interactively.
|
||||
|
||||
You have to specify an output location with the `--output` option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin os download MyApp --output ~/MyResinOS.zip
|
||||
$ resin os download MyApp --network ethernet --output ~/MyResinOS.zip
|
||||
$ resin os download MyApp --network wifi --ssid MyNetwork --key secreykey123 --output ~/MyResinOS.zip
|
||||
$ resin os download MyApp --network ethernet --output ~/MyResinOS.zip
|
||||
|
||||
### Options
|
||||
|
||||
#### --network, -n <network>
|
||||
|
||||
network type
|
||||
|
||||
#### --ssid, -s <ssid>
|
||||
|
||||
wifi ssid, if network is wifi
|
||||
|
||||
#### --key, -k <key>
|
||||
|
||||
wifi key, if network is wifi
|
||||
|
||||
#### --output, -o <output>
|
||||
|
||||
output file
|
||||
|
||||
## os install <image> [device]
|
||||
|
||||
Use this command to write an operating system image to a device.
|
||||
|
||||
Note that this command requires admin privileges.
|
||||
|
||||
If `device` is omitted, you will be prompted to select a device interactively.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
You can quiet the progress bar by passing the `--quiet` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin os install rpi.iso /dev/disk2
|
||||
|
||||
### Options
|
||||
|
||||
#### --yes, -y
|
||||
|
||||
confirm non interactively
|
||||
|
||||
# Plugin
|
||||
|
||||
## plugins
|
||||
|
||||
Use this command to list all the installed resin plugins.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin plugins
|
||||
|
||||
## plugin install <name>
|
||||
|
||||
Use this command to install a resin plugin
|
||||
|
||||
Use `--quiet` to prevent information logging.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin plugin install hello
|
||||
|
||||
## plugin update <name>
|
||||
|
||||
Use this command to update a resin plugin
|
||||
|
||||
Use `--quiet` to prevent information logging.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin plugin update hello
|
||||
|
||||
## plugin rm <name>
|
||||
|
||||
Use this command to remove a resin.io plugin.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin plugin rm hello
|
||||
$ resin plugin rm hello --yes
|
||||
|
||||
### Options
|
||||
|
||||
#### --yes, -y
|
||||
|
||||
confirm non interactively
|
||||
|
||||
# Preferences
|
||||
|
||||
## preferences
|
||||
|
||||
Use this command to open the preferences form.
|
||||
|
||||
In the future, we will allow changing all preferences directly from the terminal.
|
||||
For now, we open your default web browser and point it to the web based preferences form.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin preferences
|
||||
|
||||
# Update
|
||||
|
||||
## update
|
||||
|
||||
Use this command to update the Resin CLI
|
||||
|
||||
This command outputs information about the update process.
|
||||
Use `--quiet` to remove that output.
|
||||
|
||||
The Resin CLI checks for updates once per day.
|
||||
|
||||
Major updates require a manual update with this update command,
|
||||
while minor updates are applied automatically.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin update
|
||||
|
@ -1,9 +0,0 @@
|
||||
# device identify <uuid>
|
||||
|
||||
Use this command to identify a device.
|
||||
|
||||
In the Raspberry Pi, the ACT led is blinked several times.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device identify 23c73a12e3527df55c60b9ce647640c1b7da1b32d71e6a39849ac0f00db828
|
@ -1,7 +0,0 @@
|
||||
# device <id>
|
||||
|
||||
Use this command to show information about a single device.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device 317
|
@ -1,46 +0,0 @@
|
||||
# device init [device]
|
||||
|
||||
Use this command to download the OS image of a certain application and write it to an SD Card.
|
||||
|
||||
Note that this command requires admin privileges.
|
||||
|
||||
If `device` is omitted, you will be prompted to select a device interactively.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
You can quiet the progress bar by passing the `--quiet` boolean option.
|
||||
|
||||
You may have to unmount the device before attempting this operation.
|
||||
|
||||
You need to configure the network type and other settings:
|
||||
|
||||
Ethernet:
|
||||
You can setup the device OS to use ethernet by setting the `--network` option to "ethernet".
|
||||
|
||||
Wifi:
|
||||
You can setup the device OS to use wifi by setting the `--network` option to "wifi".
|
||||
If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device init --application 91 --network ethernet
|
||||
$ resin device init /dev/disk2 --application 91 --network wifi --ssid MyNetwork --key secret
|
||||
|
||||
## Options
|
||||
|
||||
### --application, --a,app, --a,app <application>
|
||||
|
||||
application id
|
||||
|
||||
### --network, -n <network>
|
||||
|
||||
network type
|
||||
|
||||
### --ssid, -s <ssid>
|
||||
|
||||
wifi ssid, if network is wifi
|
||||
|
||||
### --key, -k <key>
|
||||
|
||||
wifi key, if network is wifi
|
@ -1,13 +0,0 @@
|
||||
# devices
|
||||
|
||||
Use this command to list all devices that belong to a certain application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin devices --application 91
|
||||
|
||||
## Options
|
||||
|
||||
### --application, --a,app, --a,app <application>
|
||||
|
||||
application id
|
@ -1,17 +0,0 @@
|
||||
# device rm <id>
|
||||
|
||||
Use this command to remove a device from resin.io.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device rm 317
|
||||
$ resin device rm 317 --yes
|
||||
|
||||
## Options
|
||||
|
||||
### --yes, -y
|
||||
|
||||
confirm non interactively
|
@ -1,10 +0,0 @@
|
||||
# device rename <id> [name]
|
||||
|
||||
Use this command to rename a device.
|
||||
|
||||
If you omit the name, you'll get asked for it interactively.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device rename 317 MyPi
|
||||
$ resin device rename 317
|
@ -1,7 +0,0 @@
|
||||
# devices supported
|
||||
|
||||
Use this command to get the list of all supported devices
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin devices supported
|
@ -1,7 +0,0 @@
|
||||
# drives
|
||||
|
||||
Use this command to list all drives that are connected to your machine.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin drives
|
@ -1,22 +0,0 @@
|
||||
# env add <key> [value]
|
||||
|
||||
Use this command to add an enviroment variable to an application.
|
||||
|
||||
You need to pass the `--application` option.
|
||||
|
||||
If value is omitted, the tool will attempt to use the variable's value
|
||||
as defined in your host machine.
|
||||
|
||||
If the value is grabbed from the environment, a warning message will be printed.
|
||||
Use `--quiet` to remove it.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin env add EDITOR vim -a 91
|
||||
$ resin env add TERM -a 91
|
||||
|
||||
## Options
|
||||
|
||||
### --application, --a,app, --a,app <application>
|
||||
|
||||
application id
|
@ -1,23 +0,0 @@
|
||||
# envs
|
||||
|
||||
Use this command to list all environment variables for a particular application.
|
||||
Notice we will support per-device environment variables soon.
|
||||
|
||||
This command lists all custom environment variables set on the devices running
|
||||
the application. If you want to see all environment variables, including private
|
||||
ones used by resin, use the verbose option.
|
||||
|
||||
Example:
|
||||
|
||||
$ resin envs --application 91
|
||||
$ resin envs --application 91 --verbose
|
||||
|
||||
## Options
|
||||
|
||||
### --application, --a,app, --a,app <application>
|
||||
|
||||
application id
|
||||
|
||||
### --verbose, -v
|
||||
|
||||
show private environment variables
|
@ -1,19 +0,0 @@
|
||||
# env rm <id>
|
||||
|
||||
Use this command to remove an environment variable from an application.
|
||||
|
||||
Don't remove resin specific variables, as things might not work as expected.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin env rm 215
|
||||
$ resin env rm 215 --yes
|
||||
|
||||
## Options
|
||||
|
||||
### --yes, -y
|
||||
|
||||
confirm non interactively
|
@ -1,7 +0,0 @@
|
||||
# env rename <id> <value>
|
||||
|
||||
Use this command to rename an enviroment variable from an application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin env rename 376 emacs
|
@ -1,10 +0,0 @@
|
||||
# example clone <id>
|
||||
|
||||
Use this command to clone an example application to the current directory
|
||||
|
||||
This command outputs information about the cloning process.
|
||||
Use `--quiet` to remove that output.
|
||||
|
||||
Example:
|
||||
|
||||
$ resin example clone 3
|
@ -1,7 +0,0 @@
|
||||
# example <id>
|
||||
|
||||
Use this command to show information of a single example application
|
||||
|
||||
Example:
|
||||
|
||||
$ resin example 3
|
@ -1,7 +0,0 @@
|
||||
# examples
|
||||
|
||||
Use this command to list available example applications from resin.io
|
||||
|
||||
Example:
|
||||
|
||||
$ resin examples
|
@ -1,8 +0,0 @@
|
||||
# help [command...]
|
||||
|
||||
Get detailed help for an specific command.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin help apps
|
||||
$ resin help os download
|
@ -1,3 +0,0 @@
|
||||
# version
|
||||
|
||||
Display the Resin CLI, as well as the bundled NodeJS version.
|
@ -1,11 +0,0 @@
|
||||
# key add <name> [path]
|
||||
|
||||
Use this command to associate a new SSH key with your account.
|
||||
|
||||
If `path` is omitted, the command will attempt
|
||||
to read the SSH key from stdin.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin key add Main ~/.ssh/id_rsa.pub
|
||||
$ cat ~/.ssh/id_rsa.pub | resin key add Main
|
@ -1,7 +0,0 @@
|
||||
# key <id>
|
||||
|
||||
Use this command to show information about a single SSH key.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin key 17
|
@ -1,7 +0,0 @@
|
||||
# keys
|
||||
|
||||
Use this command to list all your SSH keys.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin keys
|
@ -1,17 +0,0 @@
|
||||
# key rm <id>
|
||||
|
||||
Use this command to remove a SSH key from resin.io.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin key rm 17
|
||||
$ resin key rm 17 --yes
|
||||
|
||||
## Options
|
||||
|
||||
### --yes, -y
|
||||
|
||||
confirm non interactively
|
@ -1,18 +0,0 @@
|
||||
# note <|note>
|
||||
|
||||
Use this command to set or update a device note.
|
||||
|
||||
If note command isn't passed, the tool attempts to read from `stdin`.
|
||||
|
||||
To view the notes, use $ resin device <id>.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin note "My useful note" --device 317
|
||||
$ cat note.txt | resin note --device 317
|
||||
|
||||
## Options
|
||||
|
||||
### --device, --d,dev, --d,dev <device>
|
||||
|
||||
device id
|
@ -1,37 +0,0 @@
|
||||
# os download <id>
|
||||
|
||||
Use this command to download the device OS configured to a specific network.
|
||||
|
||||
Ethernet:
|
||||
You can setup the device OS to use ethernet by setting the `--network` option to "ethernet".
|
||||
|
||||
Wifi:
|
||||
You can setup the device OS to use wifi by setting the `--network` option to "wifi".
|
||||
If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.
|
||||
|
||||
By default, this command saved the downloaded image into a resin specific directory.
|
||||
You can save it to a custom location by specifying the `--output` option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin os download 91 --network ethernet
|
||||
$ resin os download 91 --network wifi --ssid MyNetwork --key secreykey123
|
||||
$ resin os download 91 --network ethernet --output ~/MyResinOS.zip
|
||||
|
||||
## Options
|
||||
|
||||
### --network, -n <network>
|
||||
|
||||
network type
|
||||
|
||||
### --ssid, -s <ssid>
|
||||
|
||||
wifi ssid, if network is wifi
|
||||
|
||||
### --key, -k <key>
|
||||
|
||||
wifi key, if network is wifi
|
||||
|
||||
### --output, -o <output>
|
||||
|
||||
output file
|
@ -1,34 +0,0 @@
|
||||
# os install <image> [device]
|
||||
|
||||
Use this command to write an operating system image to a device.
|
||||
|
||||
Note that this command requires admin privileges.
|
||||
|
||||
If `device` is omitted, you will be prompted to select a device interactively.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
You can quiet the progress bar by passing the `--quiet` boolean option.
|
||||
|
||||
You may have to unmount the device before attempting this operation.
|
||||
|
||||
See the `drives` command to get a list of all connected devices to your machine and their respective ids.
|
||||
|
||||
In Mac OS X:
|
||||
|
||||
$ sudo diskutil unmountDisk /dev/xxx
|
||||
|
||||
In GNU/Linux:
|
||||
|
||||
$ sudo umount /dev/xxx
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin os install rpi.iso /dev/disk2
|
||||
|
||||
## Options
|
||||
|
||||
### --yes, -y
|
||||
|
||||
confirm non interactively
|
@ -1,9 +0,0 @@
|
||||
# plugin install <name>
|
||||
|
||||
Use this command to install a resin plugin
|
||||
|
||||
Use `--quiet` to prevent information logging.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin plugin install hello
|
@ -1,7 +0,0 @@
|
||||
# plugins
|
||||
|
||||
Use this command to list all the installed resin plugins.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin plugins
|
@ -1,17 +0,0 @@
|
||||
# plugin rm <name>
|
||||
|
||||
Use this command to remove a resin.io plugin.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin plugin rm hello
|
||||
$ resin plugin rm hello --yes
|
||||
|
||||
## Options
|
||||
|
||||
### --yes, -y
|
||||
|
||||
confirm non interactively
|
@ -1,9 +0,0 @@
|
||||
# plugin update <name>
|
||||
|
||||
Use this command to update a resin plugin
|
||||
|
||||
Use `--quiet` to prevent information logging.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin plugin update hello
|
@ -1,10 +0,0 @@
|
||||
# preferences
|
||||
|
||||
Use this command to open the preferences form.
|
||||
|
||||
In the future, we will allow changing all preferences directly from the terminal.
|
||||
For now, we open your default web browser and point it to the web based preferences form.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin preferences
|
@ -1,20 +0,0 @@
|
||||
mkdirp = require('mkdirp')
|
||||
fs = require('fs')
|
||||
path = require('path')
|
||||
capitano = require('capitano')
|
||||
markdown = require('./markdown')
|
||||
|
||||
capitano.command
|
||||
signature: 'markdown <file> <output>'
|
||||
description: 'file to markdown'
|
||||
action: (params, options, done) ->
|
||||
mkdirp.sync(params.output)
|
||||
action = require(params.file)
|
||||
|
||||
for actionName, actionCommand of action
|
||||
output = path.join(params.output, "#{actionName}.md")
|
||||
fs.writeFileSync(output, markdown.command(actionCommand))
|
||||
|
||||
return done()
|
||||
|
||||
capitano.run(process.argv)
|
@ -1,23 +0,0 @@
|
||||
_ = require('lodash')
|
||||
utils = require('./utils')
|
||||
|
||||
exports.option = (option) ->
|
||||
result = utils.parseSignature(option)
|
||||
|
||||
exports.command = (command) ->
|
||||
result = """
|
||||
# #{command.signature}
|
||||
|
||||
#{command.help}\n
|
||||
"""
|
||||
|
||||
if not _.isEmpty(command.options)
|
||||
result += '\n## Options'
|
||||
|
||||
for option in command.options
|
||||
result += """
|
||||
\n\n### #{utils.parseSignature(option)}
|
||||
|
||||
#{option.description}
|
||||
"""
|
||||
return result
|
45
extras/capitanodoc/index.coffee
Normal file
45
extras/capitanodoc/index.coffee
Normal file
@ -0,0 +1,45 @@
|
||||
_ = require('lodash')
|
||||
capitanodoc = require('../../capitanodoc.json')
|
||||
markdown = require('./markdown')
|
||||
|
||||
result = {}
|
||||
result.title = capitanodoc.title
|
||||
result.introduction = capitanodoc.introduction
|
||||
result.categories = []
|
||||
|
||||
for commandCategory in capitanodoc.categories
|
||||
category = {}
|
||||
category.title = commandCategory.title
|
||||
category.commands = []
|
||||
|
||||
for file in commandCategory.files
|
||||
actions = require(file)
|
||||
|
||||
for actionName, actionCommand of actions
|
||||
category.commands.push(_.omit(actionCommand, 'action'))
|
||||
|
||||
result.categories.push(category)
|
||||
|
||||
result.toc = _.cloneDeep(result.categories)
|
||||
result.toc = _.map result.toc, (category) ->
|
||||
category.commands = _.map category.commands, (command) ->
|
||||
return {
|
||||
signature: command.signature
|
||||
|
||||
# TODO: Make anchor prefix a configurable setting
|
||||
# in capitanodoc.json
|
||||
anchor: '#/pages/using/cli.md#' + command.signature
|
||||
.replace(/\s/g,'-')
|
||||
.replace(/</g, '60-')
|
||||
.replace(/>/g, '-62-')
|
||||
.replace(/\[/g, '')
|
||||
.replace(/\]/g, '-')
|
||||
.replace(/--/g, '-')
|
||||
.replace(/\.\.\./g, '')
|
||||
.replace(/\|/g, '')
|
||||
.toLowerCase()
|
||||
}
|
||||
|
||||
return category
|
||||
|
||||
console.log(markdown.display(result))
|
66
extras/capitanodoc/markdown.coffee
Normal file
66
extras/capitanodoc/markdown.coffee
Normal file
@ -0,0 +1,66 @@
|
||||
_ = require('lodash')
|
||||
ent = require('ent')
|
||||
utils = require('./utils')
|
||||
|
||||
exports.command = (command) ->
|
||||
result = """
|
||||
## #{ent.encode(command.signature)}
|
||||
|
||||
#{command.help}\n
|
||||
"""
|
||||
|
||||
if not _.isEmpty(command.options)
|
||||
result += '\n### Options'
|
||||
|
||||
for option in command.options
|
||||
result += """
|
||||
\n\n#### #{utils.parseSignature(option)}
|
||||
|
||||
#{option.description}
|
||||
"""
|
||||
|
||||
result += '\n'
|
||||
|
||||
return result
|
||||
|
||||
exports.category = (category) ->
|
||||
result = """
|
||||
# #{category.title}\n
|
||||
"""
|
||||
|
||||
for command in category.commands
|
||||
result += '\n' + exports.command(command)
|
||||
|
||||
return result
|
||||
|
||||
exports.toc = (toc) ->
|
||||
result = '''
|
||||
# Table of contents\n
|
||||
'''
|
||||
|
||||
for category in toc
|
||||
|
||||
result += """
|
||||
\n- #{category.title}\n\n
|
||||
"""
|
||||
|
||||
for command in category.commands
|
||||
result += """
|
||||
\t- [#{ent.encode(command.signature)}](#{command.anchor})\n
|
||||
"""
|
||||
|
||||
return result
|
||||
|
||||
exports.display = (doc) ->
|
||||
result = """
|
||||
# #{doc.title}
|
||||
|
||||
#{doc.introduction}
|
||||
|
||||
#{exports.toc(doc.toc)}
|
||||
"""
|
||||
|
||||
for category in doc.categories
|
||||
result += '\n' + exports.category(category)
|
||||
|
||||
return result
|
@ -1,4 +1,5 @@
|
||||
_ = require('lodash')
|
||||
ent = require('ent')
|
||||
|
||||
exports.getOptionPrefix = (signature) ->
|
||||
if signature.length > 1
|
||||
@ -22,4 +23,4 @@ exports.parseSignature = (option) ->
|
||||
if option.parameter?
|
||||
result += " <#{option.parameter}>"
|
||||
|
||||
return result
|
||||
return ent.encode(result)
|
@ -6,7 +6,6 @@ coffee = require('gulp-coffee')
|
||||
markedMan = require('gulp-marked-man')
|
||||
coffeelint = require('gulp-coffeelint')
|
||||
shell = require('gulp-shell')
|
||||
mochaNotifierReporter = require('mocha-notifier-reporter')
|
||||
packageJSON = require('./package.json')
|
||||
|
||||
OPTIONS =
|
||||
@ -30,7 +29,7 @@ gulp.task 'man', ->
|
||||
gulp.task 'test', ->
|
||||
gulp.src(OPTIONS.files.tests, read: false)
|
||||
.pipe(mocha({
|
||||
reporter: mochaNotifierReporter.decorate('landing')
|
||||
reporter: 'min'
|
||||
}))
|
||||
|
||||
gulp.task 'coffee', [ 'test', 'lint', 'json' ], ->
|
||||
@ -54,6 +53,6 @@ gulp.task 'build', [
|
||||
'man'
|
||||
]
|
||||
|
||||
gulp.task 'watch', [ 'test', 'lint' ], ->
|
||||
gulp.task 'watch', [ 'test', 'lint', 'coffee' ], ->
|
||||
gulp.watch([ OPTIONS.files.coffee, OPTIONS.files.json ], [ 'coffee' ])
|
||||
gulp.watch([ OPTIONS.files.man ], [ 'man' ])
|
||||
|
@ -1,8 +1,10 @@
|
||||
path = require('path')
|
||||
_ = require('lodash-contrib')
|
||||
async = require('async')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
commandOptions = require('./command-options')
|
||||
vcs = require('resin-vcs')
|
||||
|
||||
exports.create =
|
||||
signature: 'app create <name>'
|
||||
@ -35,14 +37,22 @@ exports.create =
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
return callback(null, options.type) if options.type?
|
||||
resin.models.application.has(params.name, callback)
|
||||
|
||||
resin.models.device.getSupportedDeviceTypes (error, deviceTypes) ->
|
||||
return callback(error) if error?
|
||||
visuals.widgets.select('Select a type', deviceTypes, callback)
|
||||
(hasApplication, callback) ->
|
||||
if hasApplication
|
||||
return callback(new Error('You already have an application with that name!'))
|
||||
|
||||
return callback(null, options.type) if options.type?
|
||||
visuals.patterns.selectDeviceType(callback)
|
||||
|
||||
(type, callback) ->
|
||||
resin.models.application.create(params.name, type, callback)
|
||||
options.type = type
|
||||
resin.models.application.create(params.name, options.type, callback)
|
||||
|
||||
(applicationId, callback) ->
|
||||
console.info("Application created: #{params.name} (#{options.type}, id #{applicationId})")
|
||||
return callback()
|
||||
|
||||
], done)
|
||||
|
||||
@ -53,7 +63,7 @@ exports.list =
|
||||
Use this command to list all your applications.
|
||||
|
||||
Notice this command only shows the most important bits of information for each app.
|
||||
If you want detailed information, use resin app <id> instead.
|
||||
If you want detailed information, use resin app <name> instead.
|
||||
|
||||
Examples:
|
||||
|
||||
@ -73,18 +83,18 @@ exports.list =
|
||||
return done()
|
||||
|
||||
exports.info =
|
||||
signature: 'app <id>'
|
||||
signature: 'app <name>'
|
||||
description: 'list a single application'
|
||||
help: '''
|
||||
Use this command to show detailed information for a single application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app 91
|
||||
$ resin app MyApp
|
||||
'''
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
resin.models.application.get params.id, (error, application) ->
|
||||
resin.models.application.get params.name, (error, application) ->
|
||||
return done(error) if error?
|
||||
console.log visuals.widgets.table.vertical application, [
|
||||
'id'
|
||||
@ -96,21 +106,21 @@ exports.info =
|
||||
return done()
|
||||
|
||||
exports.restart =
|
||||
signature: 'app restart <id>'
|
||||
signature: 'app restart <name>'
|
||||
description: 'restart an application'
|
||||
help: '''
|
||||
Use this command to restart all devices that belongs to a certain application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app restart 91
|
||||
$ resin app restart MyApp
|
||||
'''
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
resin.models.application.restart(params.id, done)
|
||||
resin.models.application.restart(params.name, done)
|
||||
|
||||
exports.remove =
|
||||
signature: 'app rm <id>'
|
||||
signature: 'app rm <name>'
|
||||
description: 'remove an application'
|
||||
help: '''
|
||||
Use this command to remove a resin.io application.
|
||||
@ -120,29 +130,33 @@ exports.remove =
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin app rm 91
|
||||
$ resin app rm 91 --yes
|
||||
$ resin app rm MyApp
|
||||
$ resin app rm MyApp --yes
|
||||
'''
|
||||
options: [ commandOptions.yes ]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
visuals.patterns.remove 'application', options.yes, (callback) ->
|
||||
resin.models.application.remove(params.id, callback)
|
||||
resin.models.application.remove(params.name, callback)
|
||||
, done
|
||||
|
||||
exports.init =
|
||||
signature: 'init <id>'
|
||||
description: 'init an application'
|
||||
exports.associate =
|
||||
signature: 'app associate <name>'
|
||||
description: 'associate a resin project'
|
||||
help: '''
|
||||
Use this command to associate a local project to an existing resin.io application.
|
||||
Use this command to associate a project directory with a resin application.
|
||||
|
||||
The application should be a git repository before issuing this command.
|
||||
Notice this command adds a `resin` git remote to your application.
|
||||
This command adds a 'resin' git remote to the directory and runs git init if necessary.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ cd myApp && resin init 91
|
||||
$ resin app associate MyApp
|
||||
$ resin app associate MyApp --project my/app/directory
|
||||
'''
|
||||
options: [ commandOptions.yes ]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
currentDirectory = process.cwd()
|
||||
@ -150,18 +164,71 @@ exports.init =
|
||||
async.waterfall [
|
||||
|
||||
(callback) ->
|
||||
resin.vcs.isResinProject(currentDirectory, callback)
|
||||
resin.models.application.has(params.name, callback)
|
||||
|
||||
(isResinProject, callback) ->
|
||||
if isResinProject
|
||||
error = new Error('Project is already a resin application.')
|
||||
return callback(error)
|
||||
return callback()
|
||||
(hasApp, callback) ->
|
||||
if not hasApp
|
||||
return callback(new Error("Invalid application: #{params.name}"))
|
||||
|
||||
message = "Are you sure you want to associate #{currentDirectory} with #{params.name}?"
|
||||
visuals.patterns.confirm(options.yes, message, callback)
|
||||
|
||||
(confirmed, callback) ->
|
||||
return done() if not confirmed
|
||||
vcs.initialize(currentDirectory, callback)
|
||||
|
||||
(callback) ->
|
||||
resin.models.application.get(params.id, callback)
|
||||
resin.models.application.get(params.name, callback)
|
||||
|
||||
(application, callback) ->
|
||||
resin.vcs.initProjectWithApplication(application, currentDirectory, callback)
|
||||
vcs.addRemote(currentDirectory, application.git_repository, callback)
|
||||
|
||||
], done
|
||||
], (error, remoteUrl) ->
|
||||
return done(error) if error?
|
||||
console.info("git repository added: #{remoteUrl}")
|
||||
return done(null, remoteUrl)
|
||||
|
||||
exports.init =
|
||||
signature: 'init'
|
||||
description: 'init an application'
|
||||
help: '''
|
||||
Use this command to initialise a directory as a resin application.
|
||||
|
||||
This command performs the following steps:
|
||||
- Create a resin.io application.
|
||||
- Initialize the current directory as a git repository.
|
||||
- Add the corresponding git remote to the application.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin init
|
||||
$ resin init --project my/app/directory
|
||||
'''
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
|
||||
currentDirectory = process.cwd()
|
||||
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
currentDirectoryBasename = path.basename(currentDirectory)
|
||||
visuals.form.ask
|
||||
label: 'What is the name of your application?'
|
||||
name: 'application'
|
||||
type: 'text'
|
||||
value: currentDirectoryBasename
|
||||
, callback
|
||||
|
||||
(applicationName, callback) ->
|
||||
|
||||
# TODO: Make resin.models.application.create return
|
||||
# the whole application instead of just the id
|
||||
exports.create.action name: applicationName, options, (error) ->
|
||||
return callback(error) if error?
|
||||
return callback(null, applicationName)
|
||||
|
||||
(applicationName, callback) ->
|
||||
exports.associate.action(name: applicationName, options, callback)
|
||||
|
||||
], done)
|
||||
|
@ -1,62 +1,62 @@
|
||||
open = require('open')
|
||||
_ = require('lodash-contrib')
|
||||
url = require('url')
|
||||
async = require('async')
|
||||
resin = require('resin-sdk')
|
||||
settings = require('resin-settings-client')
|
||||
visuals = require('resin-cli-visuals')
|
||||
|
||||
exports.login =
|
||||
signature: 'login'
|
||||
description: 'login to resin.io'
|
||||
help: '''
|
||||
Use this command to login to your resin.io account.
|
||||
You need to login before you can use most of the commands this tool provides.
|
||||
TOKEN_URL = url.resolve(settings.get('dashboardUrl'), '/preferences')
|
||||
|
||||
You can pass your credentials as `--username` and `--password` options, or you can omit the
|
||||
credentials, in which case the tool will present you with an interactive login form.
|
||||
exports.login =
|
||||
signature: 'login [token]'
|
||||
description: 'login to resin.io'
|
||||
help: """
|
||||
Use this command to login to your resin.io account.
|
||||
|
||||
To login, you need your token, which is accesible from the preferences page:
|
||||
|
||||
#{TOKEN_URL}
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin login --username <username> --password <password>
|
||||
$ resin login
|
||||
'''
|
||||
options: [
|
||||
{
|
||||
signature: 'username'
|
||||
parameter: 'username'
|
||||
description: 'user name'
|
||||
alias: 'u'
|
||||
}
|
||||
{
|
||||
signature: 'password'
|
||||
parameter: 'password'
|
||||
description: 'user password'
|
||||
alias: 'p'
|
||||
}
|
||||
]
|
||||
$ resin login "eyJ0eXAiOiJKV1Qi..."
|
||||
"""
|
||||
action: (params, options, done) ->
|
||||
|
||||
hasOptionCredentials = not _.isEmpty(options)
|
||||
|
||||
if hasOptionCredentials
|
||||
|
||||
if not options.username
|
||||
return done(new Error('Missing username'))
|
||||
|
||||
if not options.password
|
||||
return done(new Error('Missing password'))
|
||||
|
||||
async.waterfall [
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
if hasOptionCredentials
|
||||
return callback(null, options)
|
||||
else
|
||||
return visuals.widgets.login(callback)
|
||||
return callback(null, params.token) if params.token?
|
||||
|
||||
(credentials, callback) ->
|
||||
resin.auth.login(credentials, callback)
|
||||
console.info """
|
||||
To login to the Resin CLI, you need your unique token, which is accesible from
|
||||
the preferences page at #{TOKEN_URL}
|
||||
|
||||
], done
|
||||
Attempting to open a browser at that location...
|
||||
"""
|
||||
|
||||
open TOKEN_URL, (error) ->
|
||||
if error?
|
||||
console.error """
|
||||
Unable to open a web browser in the current environment.
|
||||
Please visit #{TOKEN_URL} manually.
|
||||
"""
|
||||
|
||||
visuals.patterns.loginWithToken(callback)
|
||||
|
||||
(token, callback) ->
|
||||
resin.auth.loginWithToken(token, callback)
|
||||
|
||||
(callback) ->
|
||||
resin.auth.whoami(callback)
|
||||
|
||||
(username, callback) ->
|
||||
console.info("Successfully logged in as: #{username}")
|
||||
return callback()
|
||||
|
||||
], done)
|
||||
|
||||
exports.logout =
|
||||
signature: 'logout'
|
||||
@ -131,7 +131,7 @@ exports.signup =
|
||||
|
||||
(callback) ->
|
||||
return callback(null, options) if hasOptionCredentials
|
||||
visuals.widgets.register(callback)
|
||||
visuals.patterns.register(callback)
|
||||
|
||||
(credentials, callback) ->
|
||||
resin.auth.register credentials, (error, token) ->
|
||||
@ -155,8 +155,10 @@ exports.whoami =
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
resin.auth.whoami (error, username) ->
|
||||
return done(error) if error?
|
||||
|
||||
if not username?
|
||||
return done(new Error('Username not found'))
|
||||
|
||||
console.log(username)
|
||||
return done()
|
||||
|
@ -1,15 +1,32 @@
|
||||
_ = require('lodash')
|
||||
|
||||
exports.yes =
|
||||
signature: 'yes'
|
||||
description: 'confirm non interactively'
|
||||
boolean: true
|
||||
alias: 'y'
|
||||
|
||||
exports.application =
|
||||
exports.optionalApplication =
|
||||
signature: 'application'
|
||||
parameter: 'application'
|
||||
description: 'application id'
|
||||
description: 'application name'
|
||||
alias: [ 'a', 'app' ]
|
||||
|
||||
exports.application = _.defaults
|
||||
required: 'You have to specify an application'
|
||||
, exports.optionalApplication
|
||||
|
||||
exports.optionalDevice =
|
||||
signature: 'device'
|
||||
parameter: 'device'
|
||||
description: 'device name'
|
||||
alias: 'd'
|
||||
|
||||
exports.booleanDevice =
|
||||
signature: 'device'
|
||||
description: 'device name'
|
||||
boolean: true
|
||||
alias: 'd'
|
||||
|
||||
exports.network =
|
||||
signature: 'network'
|
||||
|
@ -1,25 +1,48 @@
|
||||
fse = require('fs-extra')
|
||||
capitano = require('capitano')
|
||||
_ = require('lodash-contrib')
|
||||
path = require('path')
|
||||
async = require('async')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
vcs = require('resin-vcs')
|
||||
manager = require('resin-image-manager')
|
||||
image = require('resin-image')
|
||||
inject = require('resin-config-inject')
|
||||
registerDevice = require('resin-register-device')
|
||||
pine = require('resin-pine')
|
||||
tmp = require('tmp')
|
||||
|
||||
# Cleanup the temporary files even when an uncaught exception occurs
|
||||
tmp.setGracefulCleanup()
|
||||
|
||||
commandOptions = require('./command-options')
|
||||
osAction = require('./os')
|
||||
|
||||
exports.list =
|
||||
signature: 'devices'
|
||||
description: 'list all devices'
|
||||
help: '''
|
||||
Use this command to list all devices that belong to a certain application.
|
||||
Use this command to list all devices that belong to you.
|
||||
|
||||
You can filter the devices by application by using the `--application` option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin devices --application 91
|
||||
$ resin devices
|
||||
$ resin devices --application MyApp
|
||||
$ resin devices --app MyApp
|
||||
$ resin devices -a MyApp
|
||||
'''
|
||||
options: [ commandOptions.application ]
|
||||
options: [ commandOptions.optionalApplication ]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
resin.models.device.getAllByApplication options.application, (error, devices) ->
|
||||
|
||||
if options.application?
|
||||
getFunction = _.partial(resin.models.device.getAllByApplication, options.application)
|
||||
else
|
||||
getFunction = resin.models.device.getAll
|
||||
|
||||
getFunction (error, devices) ->
|
||||
return done(error) if error?
|
||||
console.log visuals.widgets.table.horizontal devices, [
|
||||
'id'
|
||||
@ -31,21 +54,21 @@ exports.list =
|
||||
'last_seen'
|
||||
]
|
||||
|
||||
return done()
|
||||
return done(null, devices)
|
||||
|
||||
exports.info =
|
||||
signature: 'device <id>'
|
||||
signature: 'device <name>'
|
||||
description: 'list a single device'
|
||||
help: '''
|
||||
Use this command to show information about a single device.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device 317
|
||||
$ resin device MyDevice
|
||||
'''
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
resin.models.device.get params.id, (error, device) ->
|
||||
resin.models.device.get params.name, (error, device) ->
|
||||
return done(error) if error?
|
||||
console.log visuals.widgets.table.vertical device, [
|
||||
'id'
|
||||
@ -66,7 +89,7 @@ exports.info =
|
||||
return done()
|
||||
|
||||
exports.remove =
|
||||
signature: 'device rm <id>'
|
||||
signature: 'device rm <name>'
|
||||
description: 'remove a device'
|
||||
help: '''
|
||||
Use this command to remove a device from resin.io.
|
||||
@ -76,14 +99,14 @@ exports.remove =
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device rm 317
|
||||
$ resin device rm 317 --yes
|
||||
$ resin device rm MyDevice
|
||||
$ resin device rm MyDevice --yes
|
||||
'''
|
||||
options: [ commandOptions.yes ]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
visuals.patterns.remove 'device', options.yes, (callback) ->
|
||||
resin.models.device.remove(params.id, callback)
|
||||
resin.models.device.remove(params.name, callback)
|
||||
, done
|
||||
|
||||
exports.identify =
|
||||
@ -103,7 +126,7 @@ exports.identify =
|
||||
resin.models.device.identify(params.uuid, done)
|
||||
|
||||
exports.rename =
|
||||
signature: 'device rename <id> [name]'
|
||||
signature: 'device rename <name> [newName]'
|
||||
description: 'rename a resin device'
|
||||
help: '''
|
||||
Use this command to rename a device.
|
||||
@ -112,20 +135,25 @@ exports.rename =
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device rename 317 MyPi
|
||||
$ resin device rename 317
|
||||
$ resin device rename MyDevice MyPi
|
||||
$ resin device rename MyDevice
|
||||
'''
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
async.waterfall [
|
||||
|
||||
(callback) ->
|
||||
if not _.isEmpty(params.name)
|
||||
return callback(null, params.name)
|
||||
visuals.widgets.ask('How do you want to name this device?', callback)
|
||||
if not _.isEmpty(params.newName)
|
||||
return callback(null, params.newName)
|
||||
|
||||
(name, callback) ->
|
||||
resin.models.device.rename(params.id, name, callback)
|
||||
visuals.form.ask
|
||||
label: 'How do you want to name this device?'
|
||||
name: 'device'
|
||||
type: 'text'
|
||||
, callback
|
||||
|
||||
(newName, callback) ->
|
||||
resin.models.device.rename(params.name, newName, callback)
|
||||
|
||||
], done
|
||||
|
||||
@ -146,6 +174,46 @@ exports.supported =
|
||||
_.each(devices, _.unary(console.log))
|
||||
done()
|
||||
|
||||
exports.await =
|
||||
signature: 'device await <name>'
|
||||
description: 'await for a device to become online'
|
||||
help: '''
|
||||
Use this command to await for a device to become online.
|
||||
|
||||
The process will exit when the device becomes online.
|
||||
|
||||
Notice that there is no time limit for this command, so it might run forever.
|
||||
|
||||
You can configure the poll interval with the --interval option (defaults to 3000ms).
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device await MyDevice
|
||||
$ resin device await MyDevice --interval 1000
|
||||
'''
|
||||
options: [
|
||||
signature: 'interval'
|
||||
parameter: 'interval'
|
||||
description: 'poll interval'
|
||||
alias: 'i'
|
||||
]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
options.interval ?= 3000
|
||||
|
||||
poll = ->
|
||||
resin.models.device.isOnline params.name, (error, isOnline) ->
|
||||
return done(error) if error?
|
||||
|
||||
if isOnline
|
||||
console.info("Device became online: #{params.name}")
|
||||
return done()
|
||||
else
|
||||
console.info("Polling device network status: #{params.name}")
|
||||
setTimeout(poll, options.interval)
|
||||
|
||||
poll()
|
||||
|
||||
exports.init =
|
||||
signature: 'device init [device]'
|
||||
description: 'initialise a device with resin os'
|
||||
@ -159,9 +227,7 @@ exports.init =
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
You can quiet the progress bar by passing the `--quiet` boolean option.
|
||||
|
||||
You may have to unmount the device before attempting this operation.
|
||||
You can quiet the progress bar and other logging information by passing the `--quiet` boolean option.
|
||||
|
||||
You need to configure the network type and other settings:
|
||||
|
||||
@ -172,39 +238,130 @@ exports.init =
|
||||
You can setup the device OS to use wifi by setting the `--network` option to "wifi".
|
||||
If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.
|
||||
|
||||
You can omit network related options to be asked about them interactively.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin device init --application 91 --network ethernet
|
||||
$ resin device init /dev/disk2 --application 91 --network wifi --ssid MyNetwork --key secret
|
||||
$ resin device init
|
||||
$ resin device init --application MyApp
|
||||
$ resin device init --application MyApp --network ethernet
|
||||
$ resin device init /dev/disk2 --application MyApp --network wifi --ssid MyNetwork --key secret
|
||||
'''
|
||||
options: [
|
||||
commandOptions.application
|
||||
commandOptions.optionalApplication
|
||||
commandOptions.network
|
||||
commandOptions.wifiSsid
|
||||
commandOptions.wifiKey
|
||||
]
|
||||
permission: 'user'
|
||||
root: true
|
||||
action: (params, options, done) ->
|
||||
|
||||
params.id = options.application
|
||||
networkOptions =
|
||||
network: options.network
|
||||
wifiSsid: options.ssid
|
||||
wifiKey: options.key
|
||||
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
return callback(null, options.application) if options.application?
|
||||
vcs.getApplicationName(process.cwd(), callback)
|
||||
|
||||
(applicationName, callback) ->
|
||||
options.application = applicationName
|
||||
resin.models.application.has(options.application, callback)
|
||||
|
||||
(hasApplication, callback) ->
|
||||
if not hasApplication
|
||||
return callback(new Error("Invalid application: #{options.application}"))
|
||||
|
||||
return callback(null, params.device) if params.device?
|
||||
visuals.patterns.selectDrive(callback)
|
||||
|
||||
(device, callback) ->
|
||||
params.device = device
|
||||
visuals.patterns.confirm(options.yes, "This will completely erase #{params.device}. Are you sure you want to continue?", callback)
|
||||
message = "This will completely erase #{params.device}. Are you sure you want to continue?"
|
||||
visuals.patterns.confirm(options.yes, message, callback)
|
||||
|
||||
(confirmed, callback) ->
|
||||
return done() if not confirmed
|
||||
options.yes = confirmed
|
||||
osAction.download.action(params, options, callback)
|
||||
return callback() if networkOptions.network?
|
||||
visuals.patterns.selectNetworkParameters (error, parameters) ->
|
||||
return callback(error) if error?
|
||||
_.extend(networkOptions, parameters)
|
||||
return callback()
|
||||
|
||||
(outputFile, callback) ->
|
||||
params.image = outputFile
|
||||
osAction.install.action(params, options, callback)
|
||||
(callback) ->
|
||||
console.info("Checking application: #{options.application}")
|
||||
resin.models.application.get(options.application, callback)
|
||||
|
||||
(application, callback) ->
|
||||
async.parallel
|
||||
|
||||
manifest: (callback) ->
|
||||
console.info('Getting device manifest for the application')
|
||||
resin.models.device.getManifestBySlug(application.device_type, callback)
|
||||
|
||||
config: (callback) ->
|
||||
console.info('Fetching application configuration')
|
||||
resin.models.application.getConfiguration(options.application, networkOptions, callback)
|
||||
|
||||
, callback
|
||||
|
||||
(results, callback) ->
|
||||
console.info('Associating the device')
|
||||
|
||||
registerDevice.register pine, results.config, (error, device) ->
|
||||
return callback(error) if error?
|
||||
|
||||
# Associate a device
|
||||
results.config.deviceId = device.id
|
||||
results.config.uuid = device.uuid
|
||||
|
||||
params.uuid = results.config.uuid
|
||||
|
||||
return callback(null, results)
|
||||
|
||||
(results, callback) ->
|
||||
console.info('Configuring device operating system image')
|
||||
|
||||
if process.env.DEBUG
|
||||
console.log(results.config)
|
||||
|
||||
bar = new visuals.widgets.Progress('Downloading Device OS')
|
||||
spinner = new visuals.widgets.Spinner('Downloading Device OS (size unknown)')
|
||||
|
||||
manager.configure results.manifest, results.config, (error, imagePath, removeCallback) ->
|
||||
spinner.stop()
|
||||
return callback(error, imagePath, removeCallback)
|
||||
, (state) ->
|
||||
if state?
|
||||
bar.update(state)
|
||||
else
|
||||
spinner.start()
|
||||
|
||||
(configuredImagePath, removeCallback, callback) ->
|
||||
console.info('Attempting to write operating system image to drive')
|
||||
|
||||
bar = new visuals.widgets.Progress('Writing Device OS')
|
||||
image.write
|
||||
device: params.device
|
||||
image: configuredImagePath
|
||||
progress: _.bind(bar.update, bar)
|
||||
, (error) ->
|
||||
return callback(error) if error?
|
||||
return callback(null, configuredImagePath, removeCallback)
|
||||
|
||||
(temporalImagePath, removeCallback, callback) ->
|
||||
console.info('Image written successfully')
|
||||
removeCallback(callback)
|
||||
|
||||
(callback) ->
|
||||
resin.models.device.getByUUID(params.uuid, callback)
|
||||
|
||||
(device, callback) ->
|
||||
console.info("Device created: #{device.name}")
|
||||
return callback(null, device.name)
|
||||
|
||||
], done)
|
||||
|
@ -1,3 +1,4 @@
|
||||
async = require('async')
|
||||
_ = require('lodash-contrib')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
@ -7,20 +8,22 @@ exports.list =
|
||||
signature: 'envs'
|
||||
description: 'list all environment variables'
|
||||
help: '''
|
||||
Use this command to list all environment variables for a particular application.
|
||||
Notice we will support per-device environment variables soon.
|
||||
Use this command to list all environment variables for
|
||||
a particular application or device.
|
||||
|
||||
This command lists all custom environment variables set on the devices running
|
||||
the application. If you want to see all environment variables, including private
|
||||
This command lists all custom environment variables.
|
||||
If you want to see all environment variables, including private
|
||||
ones used by resin, use the verbose option.
|
||||
|
||||
Example:
|
||||
|
||||
$ resin envs --application 91
|
||||
$ resin envs --application 91 --verbose
|
||||
$ resin envs --application MyApp
|
||||
$ resin envs --application MyApp --verbose
|
||||
$ resin envs --device MyDevice
|
||||
'''
|
||||
options: [
|
||||
commandOptions.application
|
||||
commandOptions.optionalApplication
|
||||
commandOptions.optionalDevice
|
||||
|
||||
{
|
||||
signature: 'verbose'
|
||||
@ -31,19 +34,31 @@ exports.list =
|
||||
]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
resin.models.environmentVariables.getAllByApplication options.application, (error, environmentVariables) ->
|
||||
return done(error) if error?
|
||||
async.waterfall([
|
||||
|
||||
if not options.verbose
|
||||
environmentVariables = _.reject(environmentVariables, resin.models.environmentVariables.isSystemVariable)
|
||||
(callback) ->
|
||||
if options.application?
|
||||
resin.models.environmentVariables.getAllByApplication(options.application, callback)
|
||||
else if options.device?
|
||||
resin.models.environmentVariables.device.getAll(options.device, callback)
|
||||
else
|
||||
return callback(new Error('You must specify an application or device'))
|
||||
|
||||
console.log visuals.widgets.table.horizontal environmentVariables, [
|
||||
'id'
|
||||
'name'
|
||||
'value'
|
||||
]
|
||||
(environmentVariables, callback) ->
|
||||
|
||||
return done()
|
||||
if not options.verbose
|
||||
isSystemVariable = resin.models.environmentVariables.isSystemVariable
|
||||
environmentVariables = _.reject(environmentVariables, isSystemVariable)
|
||||
|
||||
console.log visuals.widgets.table.horizontal environmentVariables, [
|
||||
'id'
|
||||
'name'
|
||||
'value'
|
||||
]
|
||||
|
||||
return callback()
|
||||
|
||||
], done)
|
||||
|
||||
exports.remove =
|
||||
signature: 'env rm <id>'
|
||||
@ -56,16 +71,25 @@ exports.remove =
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
If you want to eliminate a device environment variable, pass the `--device` boolean option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin env rm 215
|
||||
$ resin env rm 215 --yes
|
||||
$ resin env rm 215 --device
|
||||
'''
|
||||
options: [ commandOptions.yes ]
|
||||
options: [
|
||||
commandOptions.yes
|
||||
commandOptions.booleanDevice
|
||||
]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
visuals.patterns.remove 'environment variable', options.yes, (callback) ->
|
||||
resin.models.environmentVariables.remove(params.id, callback)
|
||||
if options.device
|
||||
resin.models.environmentVariables.device.remove(params.id, callback)
|
||||
else
|
||||
resin.models.environmentVariables.remove(params.id, callback)
|
||||
, done
|
||||
|
||||
exports.add =
|
||||
@ -74,20 +98,25 @@ exports.add =
|
||||
help: '''
|
||||
Use this command to add an enviroment variable to an application.
|
||||
|
||||
You need to pass the `--application` option.
|
||||
|
||||
If value is omitted, the tool will attempt to use the variable's value
|
||||
as defined in your host machine.
|
||||
|
||||
Use the `--device` option if you want to assign the environment variable
|
||||
to a specific device.
|
||||
|
||||
If the value is grabbed from the environment, a warning message will be printed.
|
||||
Use `--quiet` to remove it.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin env add EDITOR vim -a 91
|
||||
$ resin env add TERM -a 91
|
||||
$ resin env add EDITOR vim --application MyApp
|
||||
$ resin env add TERM --application MyApp
|
||||
$ resin env add EDITOR vim --device MyDevice
|
||||
'''
|
||||
options: [ commandOptions.application ]
|
||||
options: [
|
||||
commandOptions.optionalApplication
|
||||
commandOptions.optionalDevice
|
||||
]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
if not params.value?
|
||||
@ -98,7 +127,12 @@ exports.add =
|
||||
else
|
||||
console.info("Warning: using #{params.key}=#{params.value} from host environment")
|
||||
|
||||
resin.models.environmentVariables.create(options.application, params.key, params.value, done)
|
||||
if options.application?
|
||||
resin.models.environmentVariables.create(options.application, params.key, params.value, done)
|
||||
else if options.device?
|
||||
resin.models.environmentVariables.device.create(options.device, params.key, params.value, done)
|
||||
else
|
||||
return done(new Error('You must specify an application or device'))
|
||||
|
||||
exports.rename =
|
||||
signature: 'env rename <id> <value>'
|
||||
@ -106,10 +140,17 @@ exports.rename =
|
||||
help: '''
|
||||
Use this command to rename an enviroment variable from an application.
|
||||
|
||||
Pass the `--device` boolean option if you want to rename a device environment variable.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin env rename 376 emacs
|
||||
$ resin env rename 376 emacs --device
|
||||
'''
|
||||
permission: 'user'
|
||||
options: [ commandOptions.booleanDevice ]
|
||||
action: (params, options, done) ->
|
||||
resin.models.environmentVariables.update(params.id, params.value, done)
|
||||
if options.device
|
||||
resin.models.environmentVariables.device.update(params.id, params.value, done)
|
||||
else
|
||||
resin.models.environmentVariables.update(params.id, params.value, done)
|
||||
|
@ -1,10 +1,11 @@
|
||||
mkdirp = require('mkdirp')
|
||||
async = require('async')
|
||||
fs = require('fs')
|
||||
path = require('path')
|
||||
_ = require('lodash')
|
||||
gitCli = require('git-cli')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
vcs = require('resin-vcs')
|
||||
examplesData = require('../data/examples.json')
|
||||
|
||||
exports.list =
|
||||
@ -29,34 +30,33 @@ exports.list =
|
||||
|
||||
console.log visuals.widgets.table.horizontal examplesData, [
|
||||
'id'
|
||||
'name'
|
||||
'display_name'
|
||||
'repository'
|
||||
'author'
|
||||
]
|
||||
|
||||
exports.info =
|
||||
signature: 'example <id>'
|
||||
signature: 'example <name>'
|
||||
description: 'list a single example application'
|
||||
help: '''
|
||||
Use this command to show information of a single example application
|
||||
|
||||
Example:
|
||||
|
||||
$ resin example 3
|
||||
$ resin example cimon
|
||||
'''
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
id = params.id - 1
|
||||
example = examplesData[id]
|
||||
example = _.findWhere(examplesData, name: params.name)
|
||||
|
||||
if not example?
|
||||
return done(new Error("Unknown example: #{id}"))
|
||||
return done(new Error("Unknown example: #{params.name}"))
|
||||
|
||||
example.id = id
|
||||
example.author ?= 'Unknown'
|
||||
|
||||
console.log visuals.widgets.table.vertical example, [
|
||||
'id'
|
||||
'name'
|
||||
'display_name'
|
||||
'description'
|
||||
'author'
|
||||
@ -66,7 +66,7 @@ exports.info =
|
||||
return done()
|
||||
|
||||
exports.clone =
|
||||
signature: 'example clone <id>'
|
||||
signature: 'example clone <name>'
|
||||
description: 'clone an example application'
|
||||
help: '''
|
||||
Use this command to clone an example application to the current directory
|
||||
@ -76,27 +76,20 @@ exports.clone =
|
||||
|
||||
Example:
|
||||
|
||||
$ resin example clone 3
|
||||
$ resin example clone cimon
|
||||
'''
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
example = examplesData[params.id - 1]
|
||||
example = _.findWhere(examplesData, name: params.name)
|
||||
|
||||
if not example?
|
||||
return done(new Error("Unknown example: #{id}"))
|
||||
return done(new Error("Unknown example: #{params.name}"))
|
||||
|
||||
async.waterfall [
|
||||
currentDirectory = process.cwd()
|
||||
destination = path.join(currentDirectory, example.name)
|
||||
|
||||
(callback) ->
|
||||
exampleAbsolutePath = path.join(process.cwd(), example.name)
|
||||
|
||||
fs.exists exampleAbsolutePath, (exists) ->
|
||||
return callback() if not exists
|
||||
error = new Error("Directory exists: #{example.name}")
|
||||
return callback(error)
|
||||
|
||||
(callback) ->
|
||||
console.info("Cloning #{example.display_name} to #{example.name}")
|
||||
gitCli.Repository.clone(example.repository, example.name, callback)
|
||||
|
||||
], done
|
||||
mkdirp destination, (error) ->
|
||||
return done(error) if error?
|
||||
console.info("Cloning #{example.display_name} to #{destination}")
|
||||
vcs.clone(example.repository, destination, done)
|
||||
return done()
|
||||
|
@ -9,7 +9,7 @@ module.exports =
|
||||
logs: require('./logs')
|
||||
notes: require('./notes')
|
||||
preferences: require('./preferences')
|
||||
os: require('./os')
|
||||
help: require('./help')
|
||||
examples: require('./examples')
|
||||
plugin: require('./plugin')
|
||||
update: require('./update')
|
||||
|
@ -1,11 +1,25 @@
|
||||
settings = require('resin-settings-client')
|
||||
packageJSON = require('../../package.json')
|
||||
|
||||
exports.version =
|
||||
signature: 'version'
|
||||
description: 'output the version number'
|
||||
help: '''
|
||||
Display the Resin CLI, as well as the bundled NodeJS version.
|
||||
Display the Resin CLI version.
|
||||
'''
|
||||
action: ->
|
||||
console.log("#{packageJSON.name}: #{packageJSON.version}")
|
||||
console.log("node: #{process.version}")
|
||||
action: (params, options, done) ->
|
||||
console.log(packageJSON.version)
|
||||
return done()
|
||||
|
||||
exports.config =
|
||||
signature: 'config'
|
||||
description: 'see your current configuration'
|
||||
help: '''
|
||||
See your current Resin CLI configuration.
|
||||
|
||||
Configuration lives in $HOME/.resin/config.
|
||||
'''
|
||||
action: (params, options, done) ->
|
||||
for key, value of settings.get()
|
||||
console.log("#{key}: #{value}")
|
||||
return done()
|
||||
|
@ -24,6 +24,8 @@ exports.list =
|
||||
console.log visuals.widgets.table.horizontal keys, [ 'id', 'title' ]
|
||||
return done()
|
||||
|
||||
SSH_KEY_WIDTH = 43
|
||||
|
||||
exports.info =
|
||||
signature: 'key <id>'
|
||||
description: 'list a single ssh key'
|
||||
@ -38,10 +40,6 @@ exports.info =
|
||||
action: (params, options, done) ->
|
||||
resin.models.key.get params.id, (error, key) ->
|
||||
return done(error) if error?
|
||||
|
||||
sshKeyWidth = resin.settings.get('sshKeyWidth')
|
||||
key.public_key = '\n' + visuals.helpers.chop(key.public_key, sshKeyWidth)
|
||||
|
||||
console.log(visuals.widgets.table.vertical(key, [ 'id', 'title', 'public_key' ]))
|
||||
return done()
|
||||
|
||||
|
@ -3,7 +3,7 @@ resin = require('resin-sdk')
|
||||
|
||||
LOGS_HISTORY_COUNT = 200
|
||||
|
||||
exports.logs =
|
||||
module.exports =
|
||||
signature: 'logs <uuid>'
|
||||
description: 'show device logs'
|
||||
help: '''
|
||||
@ -16,8 +16,7 @@ exports.logs =
|
||||
|
||||
To continuously stream output, and see new logs in real time, use the `--tail` option.
|
||||
|
||||
Note that for now you need to provide the whole UUID for this command to work correctly,
|
||||
and the tool won't notice if you're using an invalid UUID.
|
||||
Note that for now you need to provide the whole UUID for this command to work correctly.
|
||||
|
||||
This is due to some technical limitations that we plan to address soon.
|
||||
|
||||
@ -50,7 +49,7 @@ exports.logs =
|
||||
return done(error) if error?
|
||||
if _.isArray(message)
|
||||
_.each message, (line) ->
|
||||
console.log(line)
|
||||
console.log(line.message)
|
||||
else
|
||||
console.log(message)
|
||||
console.log(message.message)
|
||||
return done()
|
||||
|
@ -1,3 +1,4 @@
|
||||
_ = require('lodash')
|
||||
async = require('async')
|
||||
resin = require('resin-sdk')
|
||||
|
||||
@ -9,20 +10,24 @@ exports.set =
|
||||
|
||||
If note command isn't passed, the tool attempts to read from `stdin`.
|
||||
|
||||
To view the notes, use $ resin device <id>.
|
||||
To view the notes, use $ resin device <name>.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin note "My useful note" --device 317
|
||||
$ cat note.txt | resin note --device 317
|
||||
$ resin note "My useful note" --device MyDevice
|
||||
$ cat note.txt | resin note --device MyDevice
|
||||
'''
|
||||
options: [
|
||||
signature: 'device'
|
||||
parameter: 'device'
|
||||
description: 'device id'
|
||||
description: 'device name'
|
||||
alias: [ 'd', 'dev' ]
|
||||
required: 'You have to specify a device'
|
||||
]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
|
||||
if _.isEmpty(params.note)
|
||||
return done(new Error('Missing note content'))
|
||||
|
||||
resin.models.device.note(options.device, params.note, done)
|
||||
|
@ -1,171 +0,0 @@
|
||||
_ = require('lodash-contrib')
|
||||
fs = require('fs')
|
||||
os = require('os')
|
||||
async = require('async')
|
||||
path = require('path')
|
||||
mkdirp = require('mkdirp')
|
||||
resin = require('resin-sdk')
|
||||
visuals = require('resin-cli-visuals')
|
||||
progressStream = require('progress-stream')
|
||||
diskio = require('diskio')
|
||||
commandOptions = require('./command-options')
|
||||
|
||||
exports.download =
|
||||
signature: 'os download <id>'
|
||||
description: 'download device OS'
|
||||
help: '''
|
||||
Use this command to download the device OS configured to a specific network.
|
||||
|
||||
Ethernet:
|
||||
You can setup the device OS to use ethernet by setting the `--network` option to "ethernet".
|
||||
|
||||
Wifi:
|
||||
You can setup the device OS to use wifi by setting the `--network` option to "wifi".
|
||||
If you set "network" to "wifi", you will need to specify the `--ssid` and `--key` option as well.
|
||||
|
||||
By default, this command saved the downloaded image into a resin specific directory.
|
||||
You can save it to a custom location by specifying the `--output` option.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin os download 91 --network ethernet
|
||||
$ resin os download 91 --network wifi --ssid MyNetwork --key secreykey123
|
||||
$ resin os download 91 --network ethernet --output ~/MyResinOS.zip
|
||||
'''
|
||||
options: [
|
||||
commandOptions.network
|
||||
commandOptions.wifiSsid
|
||||
commandOptions.wifiKey
|
||||
|
||||
{
|
||||
signature: 'output'
|
||||
parameter: 'output'
|
||||
description: 'output file'
|
||||
alias: 'o'
|
||||
}
|
||||
]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
osParams =
|
||||
network: options.network
|
||||
wifiSsid: options.ssid
|
||||
wifiKey: options.key
|
||||
appId: params.id
|
||||
|
||||
fileName = resin.models.os.generateCacheName(osParams)
|
||||
options.output ?= path.join(resin.settings.get('directories.os'), fileName)
|
||||
|
||||
async.waterfall [
|
||||
|
||||
(callback) ->
|
||||
|
||||
# We need to ensure this directory exists
|
||||
mkdirp(path.dirname(options.output), _.unary(callback))
|
||||
|
||||
(callback) ->
|
||||
console.info("Destination file: #{options.output}\n")
|
||||
|
||||
bar = new visuals.widgets.Progress('Downloading Device OS')
|
||||
|
||||
resin.models.os.download osParams, options.output, callback, (state) ->
|
||||
bar.update(state)
|
||||
|
||||
], (error) ->
|
||||
return done(error) if error?
|
||||
console.info("\nFinished downloading #{options.output}")
|
||||
return done(null, options.output)
|
||||
|
||||
exports.install =
|
||||
signature: 'os install <image> [device]'
|
||||
description: 'write an operating system image to a device'
|
||||
help: '''
|
||||
Use this command to write an operating system image to a device.
|
||||
|
||||
Note that this command requires admin privileges.
|
||||
|
||||
If `device` is omitted, you will be prompted to select a device interactively.
|
||||
|
||||
Notice this command asks for confirmation interactively.
|
||||
You can avoid this by passing the `--yes` boolean option.
|
||||
|
||||
You can quiet the progress bar by passing the `--quiet` boolean option.
|
||||
|
||||
You may have to unmount the device before attempting this operation.
|
||||
|
||||
See the `drives` command to get a list of all connected devices to your machine and their respective ids.
|
||||
|
||||
In Mac OS X:
|
||||
|
||||
$ sudo diskutil unmountDisk /dev/xxx
|
||||
|
||||
In GNU/Linux:
|
||||
|
||||
$ sudo umount /dev/xxx
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin os install rpi.iso /dev/disk2
|
||||
'''
|
||||
options: [ commandOptions.yes ]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
async.waterfall [
|
||||
|
||||
(callback) ->
|
||||
return callback(null, params.device) if params.device?
|
||||
|
||||
# TODO: See if we can reuse the drives action somehow here
|
||||
visuals.patterns.selectDrive (error, device) ->
|
||||
return callback(error) if error?
|
||||
|
||||
if not device?
|
||||
return callback(new Error('No removable devices available'))
|
||||
|
||||
return callback(null, device)
|
||||
|
||||
(device, callback) ->
|
||||
params.device = device
|
||||
message = "This will completely erase #{params.device}. Are you sure you want to continue?"
|
||||
visuals.patterns.confirm(options.yes, message, callback)
|
||||
|
||||
(confirmed, callback) ->
|
||||
return done() if not confirmed
|
||||
|
||||
imageFileSize = fs.statSync(params.image).size
|
||||
|
||||
if imageFileSize is 0
|
||||
error = new Error("Invalid OS image: #{params.image}. The image is 0 bytes.")
|
||||
return callback(error)
|
||||
|
||||
progress = progressStream
|
||||
length: imageFileSize
|
||||
time: 500
|
||||
|
||||
if not options.quiet
|
||||
bar = new visuals.widgets.Progress('Writing Device OS')
|
||||
|
||||
progress.on 'progress', (status) ->
|
||||
bar.update(status)
|
||||
|
||||
imageFileStream = fs.createReadStream(params.image).pipe(progress)
|
||||
|
||||
diskio.writeStream(params.device, imageFileStream, callback)
|
||||
|
||||
], (error) ->
|
||||
return done() if not error?
|
||||
|
||||
if _.all [
|
||||
os.platform() is 'win32'
|
||||
error.code is 'EPERM' or error.code is 'EACCES'
|
||||
|
||||
# Prevent re-running resin-write infinitely
|
||||
# If we have an EPERM or EACCES even after running
|
||||
# windosu, we throw it as there is not much we can do
|
||||
not options.fromScript
|
||||
]
|
||||
windosu = require('windosu')
|
||||
# Need to escape every path to avoid errors
|
||||
resinWritePath = "\"#{path.join(__dirname, '..', '..', 'bin', 'resin-write')}\""
|
||||
windosu.exec("\"#{process.argv[0]}\" #{resinWritePath} \"#{params.image}\" \"#{params.device}\"")
|
||||
else
|
||||
return done(error)
|
@ -1,6 +1,6 @@
|
||||
open = require('open')
|
||||
url = require('url')
|
||||
resin = require('resin-sdk')
|
||||
settings = require('resin-settings-client')
|
||||
|
||||
exports.preferences =
|
||||
signature: 'preferences'
|
||||
@ -17,6 +17,5 @@ exports.preferences =
|
||||
'''
|
||||
permission: 'user'
|
||||
action: ->
|
||||
preferencesUrl = resin.settings.get('urls.preferences')
|
||||
absUrl = url.resolve(resin.settings.get('remoteUrl'), preferencesUrl)
|
||||
absUrl = url.resolve(settings.get('remoteUrl'), '/preferences')
|
||||
open(absUrl)
|
||||
|
26
lib/actions/update.coffee
Normal file
26
lib/actions/update.coffee
Normal file
@ -0,0 +1,26 @@
|
||||
selfupdate = require('selfupdate')
|
||||
packageJSON = require('../../package.json')
|
||||
|
||||
exports.update =
|
||||
signature: 'update'
|
||||
description: 'update the resin cli'
|
||||
help: '''
|
||||
Use this command to update the Resin CLI
|
||||
|
||||
This command outputs information about the update process.
|
||||
Use `--quiet` to remove that output.
|
||||
|
||||
The Resin CLI checks for updates once per day.
|
||||
|
||||
Major updates require a manual update with this update command,
|
||||
while minor updates are applied automatically.
|
||||
|
||||
Examples:
|
||||
|
||||
$ resin update
|
||||
'''
|
||||
action: (params, options, done) ->
|
||||
selfupdate.update packageJSON, (error, version) ->
|
||||
return done(error) if error?
|
||||
console.info("Updated #{packageJSON.name} to version #{version}.")
|
||||
return done()
|
@ -5,9 +5,11 @@ resin = require('resin-sdk')
|
||||
actions = require('./actions')
|
||||
errors = require('./errors')
|
||||
plugins = require('./plugins')
|
||||
update = require('./update')
|
||||
|
||||
capitano.permission 'user', (done) ->
|
||||
resin.auth.isLoggedIn (isLoggedIn) ->
|
||||
resin.auth.isLoggedIn (error, isLoggedIn) ->
|
||||
return done(error) if error?
|
||||
if not isLoggedIn
|
||||
return done(new Error('You have to log in'))
|
||||
return done()
|
||||
@ -30,6 +32,12 @@ capitano.globalOption
|
||||
description: 'project path'
|
||||
alias: 'j'
|
||||
|
||||
capitano.globalOption
|
||||
signature: 'version'
|
||||
description: actions.info.version.description
|
||||
boolean: true
|
||||
alias: 'v'
|
||||
|
||||
# We don't do anything in response to this options
|
||||
# explicitly. We use InquirerJS to provide CLI widgets,
|
||||
# and that module understands --no-color automatically.
|
||||
@ -40,6 +48,7 @@ capitano.globalOption
|
||||
|
||||
# ---------- Info Module ----------
|
||||
capitano.command(actions.info.version)
|
||||
capitano.command(actions.info.config)
|
||||
|
||||
# ---------- Help Module ----------
|
||||
capitano.command(actions.help.help)
|
||||
@ -53,16 +62,18 @@ capitano.command(actions.auth.whoami)
|
||||
# ---------- App Module ----------
|
||||
capitano.command(actions.app.create)
|
||||
capitano.command(actions.app.list)
|
||||
capitano.command(actions.app.info)
|
||||
capitano.command(actions.app.remove)
|
||||
capitano.command(actions.app.restart)
|
||||
capitano.command(actions.app.associate)
|
||||
capitano.command(actions.app.init)
|
||||
capitano.command(actions.app.info)
|
||||
|
||||
# ---------- Device Module ----------
|
||||
capitano.command(actions.device.list)
|
||||
capitano.command(actions.device.supported)
|
||||
capitano.command(actions.device.rename)
|
||||
capitano.command(actions.device.init)
|
||||
capitano.command(actions.device.await)
|
||||
capitano.command(actions.device.info)
|
||||
capitano.command(actions.device.remove)
|
||||
capitano.command(actions.device.identify)
|
||||
@ -89,11 +100,7 @@ capitano.command(actions.env.rename)
|
||||
capitano.command(actions.env.remove)
|
||||
|
||||
# ---------- Logs Module ----------
|
||||
capitano.command(actions.logs.logs)
|
||||
|
||||
# ---------- OS Module ----------
|
||||
capitano.command(actions.os.download)
|
||||
capitano.command(actions.os.install)
|
||||
capitano.command(actions.logs)
|
||||
|
||||
# ---------- Examples Module ----------
|
||||
capitano.command(actions.examples.list)
|
||||
@ -106,6 +113,9 @@ capitano.command(actions.plugin.install)
|
||||
capitano.command(actions.plugin.update)
|
||||
capitano.command(actions.plugin.remove)
|
||||
|
||||
# ---------- Update Module ----------
|
||||
capitano.command(actions.update.update)
|
||||
|
||||
changeProjectDirectory = (directory) ->
|
||||
try
|
||||
process.chdir(directory)
|
||||
@ -115,21 +125,23 @@ changeProjectDirectory = (directory) ->
|
||||
async.waterfall([
|
||||
|
||||
(callback) ->
|
||||
plugins.register('resin-plugin-', callback)
|
||||
update.check(callback)
|
||||
|
||||
(callback) ->
|
||||
dataPrefix = resin.settings.get('dataPrefix')
|
||||
resin.data.prefix.set(dataPrefix, callback)
|
||||
plugins.register('resin-plugin-', callback)
|
||||
|
||||
(callback) ->
|
||||
cli = capitano.parse(process.argv)
|
||||
|
||||
if cli.global.quiet
|
||||
if cli.global.quiet or not process.stdout.isTTY
|
||||
console.info = _.noop
|
||||
|
||||
if cli.global.project?
|
||||
changeProjectDirectory(cli.global.project)
|
||||
|
||||
capitano.execute(cli, callback)
|
||||
if cli.global.version
|
||||
actions.info.version.action(null, null, callback)
|
||||
else
|
||||
capitano.execute(cli, callback)
|
||||
|
||||
], errors.handle)
|
||||
|
16
lib/elevate.coffee
Normal file
16
lib/elevate.coffee
Normal file
@ -0,0 +1,16 @@
|
||||
_ = require('lodash')
|
||||
os = require('os')
|
||||
path = require('path')
|
||||
|
||||
isWindows = ->
|
||||
return os.platform() is 'win32'
|
||||
|
||||
exports.shouldElevate = (error) ->
|
||||
return _.all [
|
||||
isWindows()
|
||||
error.code is 'EPERM' or error.code is 'EACCES'
|
||||
]
|
||||
|
||||
exports.run = (command) ->
|
||||
return if not isWindows()
|
||||
require('windosu').exec(command)
|
@ -23,6 +23,12 @@ exports.handle = (error, exit = true) ->
|
||||
|
||||
console.error(message)
|
||||
|
||||
else if error.code is 'ENOGIT'
|
||||
console.error '''
|
||||
Git is not installed on this system.
|
||||
Head over to http://git-scm.com to install it and run this command again.
|
||||
'''
|
||||
|
||||
else if error.message?
|
||||
console.error(error.message)
|
||||
|
||||
|
26
lib/update.coffee
Normal file
26
lib/update.coffee
Normal file
@ -0,0 +1,26 @@
|
||||
updateNotifier = require('update-notifier')
|
||||
packageJSON = require('../package.json')
|
||||
updateAction = require('./actions/update')
|
||||
|
||||
exports.perform = (callback) ->
|
||||
updateAction.update.action(null, null, callback)
|
||||
|
||||
exports.notify = (update) ->
|
||||
return if not process.stdout.isTTY
|
||||
|
||||
console.log """
|
||||
> Major update available: #{update.current} -> #{update.latest}
|
||||
> Run resin update to update.
|
||||
> Beware that a major release might introduce breaking changes.\n
|
||||
"""
|
||||
|
||||
exports.check = (callback) ->
|
||||
notifier = updateNotifier(pkg: packageJSON)
|
||||
return callback() if not notifier.update?
|
||||
|
||||
if notifier.update.type is 'major'
|
||||
exports.notify(notifier.update)
|
||||
return callback()
|
||||
|
||||
console.log("Performing #{notifier.update.type} update, hold tight...")
|
||||
exports.perform(callback)
|
@ -1,4 +1,4 @@
|
||||
.TH "RESIN" "1" "March 2015" "" ""
|
||||
.TH "RESIN" "1" "May 2015" "" ""
|
||||
.SH "NAME"
|
||||
\fBresin\fR \- tab completion for resin
|
||||
.SH DESCRIPTION
|
||||
|
@ -1,4 +1,4 @@
|
||||
.TH "RESIN\-PLUGINS" "1" "March 2015" "" ""
|
||||
.TH "RESIN\-PLUGINS" "1" "May 2015" "" ""
|
||||
.SH "NAME"
|
||||
\fBresin-plugins\fR \- Creating Resin CLI plugins
|
||||
.SH DESCRIPTION
|
||||
|
@ -1,4 +1,4 @@
|
||||
.TH "RESIN" "1" "March 2015" "" ""
|
||||
.TH "RESIN" "1" "May 2015" "" ""
|
||||
.SH "NAME"
|
||||
\fBresin\fR \- command line tool to interact with resin\.io
|
||||
.SH SYNOPSIS
|
||||
|
35
package.json
35
package.json
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "resin-cli",
|
||||
"version": "0.1.0",
|
||||
"version": "0.11.1",
|
||||
"description": "Git Push to your devices",
|
||||
"main": "./lib/actions/index.coffee",
|
||||
"main": "./build/actions/index.js",
|
||||
"homepage": "https://github.com/resin-io/resin-cli",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -20,7 +20,7 @@
|
||||
"scripts": {
|
||||
"prepublish": "gulp build",
|
||||
"test": "gulp test",
|
||||
"doc": "./scripts/extract-documentation.sh doc lib/actions"
|
||||
"doc": "mkdir -p doc/ && coffee extras/capitanodoc/index.coffee > doc/cli.markdown"
|
||||
},
|
||||
"keywords": [
|
||||
"resin",
|
||||
@ -33,6 +33,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "~1.9.2",
|
||||
"ent": "^2.2.0",
|
||||
"gulp": "~3.8.9",
|
||||
"gulp-coffee": "^2.2.0",
|
||||
"gulp-coffeelint": "~0.4.0",
|
||||
@ -41,27 +42,35 @@
|
||||
"gulp-shell": "^0.2.11",
|
||||
"gulp-util": "~3.0.1",
|
||||
"mocha": "~2.0.1",
|
||||
"mocha-notifier-reporter": "~0.1.0",
|
||||
"run-sequence": "~1.0.2",
|
||||
"sinon": "~1.12.1",
|
||||
"sinon-chai": "~2.6.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"async": "~0.9.0",
|
||||
"capitano": "~1.5.0",
|
||||
"capitano": "~1.6.0",
|
||||
"coffee-script": "~1.8.0",
|
||||
"conf.js": "^0.1.1",
|
||||
"diskio": "^1.0.0",
|
||||
"drivelist": "^1.2.1",
|
||||
"git-cli": "~0.8.2",
|
||||
"drivelist": "^1.2.2",
|
||||
"fs-extra": "^0.18.3",
|
||||
"lodash": "~2.4.1",
|
||||
"lodash-contrib": "~241.4.14",
|
||||
"mkdirp": "~0.5.0",
|
||||
"nplugm": "^2.1.0",
|
||||
"nplugm": "^2.2.0",
|
||||
"npm": "^2.6.1",
|
||||
"open": "0.0.5",
|
||||
"progress-stream": "^0.5.0",
|
||||
"resin-cli-visuals": "resin-io/resin-cli-visuals",
|
||||
"resin-sdk": "^0.0.1",
|
||||
"underscore.string": "~2.4.0"
|
||||
"resin-cli-visuals": "^0.2.0",
|
||||
"resin-config-inject": "^2.0.0",
|
||||
"resin-image": "^1.1.3",
|
||||
"resin-image-manager": "^1.1.0",
|
||||
"resin-pine": "^1.1.1",
|
||||
"resin-register-device": "^1.0.1",
|
||||
"resin-sdk": "^1.7.4",
|
||||
"resin-settings-client": "^1.2.0",
|
||||
"resin-vcs": "^1.2.0",
|
||||
"selfupdate": "^1.1.0",
|
||||
"tmp": "^0.0.25",
|
||||
"underscore.string": "~2.4.0",
|
||||
"update-notifier": "^0.3.1"
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<installer-gui-script minSpecVersion="1">
|
||||
<title>Resin CLI</title>
|
||||
<organization>io.resin</organization>
|
||||
<domains enable_localSystem="true" />
|
||||
<options customize="never" require-scripts="true" />
|
||||
|
||||
<background file="background.png" alignment="bottomleft" mime-type="image/png" />
|
||||
|
||||
<!-- Define documents displayed at various steps -->
|
||||
<welcome file="welcome.txt" mime-type="text/plain" />
|
||||
<license file="license.txt" mime-type="text/plain" />
|
||||
<conclusion file="conclusion.txt" mime-type="text/plain" />
|
||||
|
||||
<!-- List all component packages -->
|
||||
<pkg-ref id="io.resin.cli">cli.pkg</pkg-ref>
|
||||
|
||||
<!-- List them again here -->
|
||||
<choices-outline>
|
||||
<line choice="io.resin.cli" />
|
||||
</choices-outline>
|
||||
|
||||
<!-- Define each choice above -->
|
||||
<choice
|
||||
customLocation="/opt/resin.io/cli"
|
||||
id="io.resin.cli"
|
||||
visible="false"
|
||||
title="Resin CLI"
|
||||
description="The Resin CLI tool"
|
||||
start_selected="true">
|
||||
<pkg-ref id="io.resin.cli" />
|
||||
</choice>
|
||||
</installer-gui-script>
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
@ -1 +0,0 @@
|
||||
Thanks for installing the Resin CLI. Enjoy!
|
@ -1,3 +0,0 @@
|
||||
Welcome to the installation of the Resin CLI tool, an advanced way to communicate with Resin.io
|
||||
|
||||
The Resin.io CLI tool will be installed in /opt/resin.io/cli.
|
@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Add binary symbolic link
|
||||
ln -s /opt/resin.io/cli/bin/resin /usr/bin/resin
|
@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Remove previous installations of the CLI
|
||||
rm -rf /opt/resin.io/cli
|
||||
|
||||
# Remove previous symbolic link
|
||||
rm -f /usr/bin/resin
|
@ -1,327 +0,0 @@
|
||||
/**
|
||||
* EnvVarUpdate.nsh
|
||||
* : Environmental Variables: append, prepend, and remove entries
|
||||
*
|
||||
* WARNING: If you use StrFunc.nsh header then include it before this file
|
||||
* with all required definitions. This is to avoid conflicts
|
||||
*
|
||||
* Usage:
|
||||
* ${EnvVarUpdate} "ResultVar" "EnvVarName" "Action" "RegLoc" "PathString"
|
||||
*
|
||||
* Credits:
|
||||
* Version 1.0
|
||||
* * Cal Turney (turnec2)
|
||||
* * Amir Szekely (KiCHiK) and e-circ for developing the forerunners of this
|
||||
* function: AddToPath, un.RemoveFromPath, AddToEnvVar, un.RemoveFromEnvVar,
|
||||
* WriteEnvStr, and un.DeleteEnvStr
|
||||
* * Diego Pedroso (deguix) for StrTok
|
||||
* * Kevin English (kenglish_hi) for StrContains
|
||||
* * Hendri Adriaens (Smile2Me), Diego Pedroso (deguix), and Dan Fuhry
|
||||
* (dandaman32) for StrReplace
|
||||
*
|
||||
* Version 1.1 (compatibility with StrFunc.nsh)
|
||||
* * techtonik
|
||||
*
|
||||
* http://nsis.sourceforge.net/Environmental_Variables:_append%2C_prepend%2C_and_remove_entries
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
!ifndef ENVVARUPDATE_FUNCTION
|
||||
!define ENVVARUPDATE_FUNCTION
|
||||
!verbose push
|
||||
!verbose 3
|
||||
!include "LogicLib.nsh"
|
||||
!include "WinMessages.NSH"
|
||||
!include "StrFunc.nsh"
|
||||
|
||||
; ---- Fix for conflict if StrFunc.nsh is already includes in main file -----------------------
|
||||
!macro _IncludeStrFunction StrFuncName
|
||||
!ifndef ${StrFuncName}_INCLUDED
|
||||
${${StrFuncName}}
|
||||
!endif
|
||||
!ifndef Un${StrFuncName}_INCLUDED
|
||||
${Un${StrFuncName}}
|
||||
!endif
|
||||
!define un.${StrFuncName} "${Un${StrFuncName}}"
|
||||
!macroend
|
||||
|
||||
!insertmacro _IncludeStrFunction StrTok
|
||||
!insertmacro _IncludeStrFunction StrStr
|
||||
!insertmacro _IncludeStrFunction StrRep
|
||||
|
||||
; ---------------------------------- Macro Definitions ----------------------------------------
|
||||
!macro _EnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString
|
||||
Push "${EnvVarName}"
|
||||
Push "${Action}"
|
||||
Push "${RegLoc}"
|
||||
Push "${PathString}"
|
||||
Call EnvVarUpdate
|
||||
Pop "${ResultVar}"
|
||||
!macroend
|
||||
!define EnvVarUpdate '!insertmacro "_EnvVarUpdateConstructor"'
|
||||
|
||||
!macro _unEnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString
|
||||
Push "${EnvVarName}"
|
||||
Push "${Action}"
|
||||
Push "${RegLoc}"
|
||||
Push "${PathString}"
|
||||
Call un.EnvVarUpdate
|
||||
Pop "${ResultVar}"
|
||||
!macroend
|
||||
!define un.EnvVarUpdate '!insertmacro "_unEnvVarUpdateConstructor"'
|
||||
; ---------------------------------- Macro Definitions end-------------------------------------
|
||||
|
||||
;----------------------------------- EnvVarUpdate start----------------------------------------
|
||||
!define hklm_all_users 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
|
||||
!define hkcu_current_user 'HKCU "Environment"'
|
||||
|
||||
!macro EnvVarUpdate UN
|
||||
|
||||
Function ${UN}EnvVarUpdate
|
||||
|
||||
Push $0
|
||||
Exch 4
|
||||
Exch $1
|
||||
Exch 3
|
||||
Exch $2
|
||||
Exch 2
|
||||
Exch $3
|
||||
Exch
|
||||
Exch $4
|
||||
Push $5
|
||||
Push $6
|
||||
Push $7
|
||||
Push $8
|
||||
Push $9
|
||||
Push $R0
|
||||
|
||||
/* After this point:
|
||||
-------------------------
|
||||
$0 = ResultVar (returned)
|
||||
$1 = EnvVarName (input)
|
||||
$2 = Action (input)
|
||||
$3 = RegLoc (input)
|
||||
$4 = PathString (input)
|
||||
$5 = Orig EnvVar (read from registry)
|
||||
$6 = Len of $0 (temp)
|
||||
$7 = tempstr1 (temp)
|
||||
$8 = Entry counter (temp)
|
||||
$9 = tempstr2 (temp)
|
||||
$R0 = tempChar (temp) */
|
||||
|
||||
; Step 1: Read contents of EnvVarName from RegLoc
|
||||
;
|
||||
; Check for empty EnvVarName
|
||||
${If} $1 == ""
|
||||
SetErrors
|
||||
DetailPrint "ERROR: EnvVarName is blank"
|
||||
Goto EnvVarUpdate_Restore_Vars
|
||||
${EndIf}
|
||||
|
||||
; Check for valid Action
|
||||
${If} $2 != "A"
|
||||
${AndIf} $2 != "P"
|
||||
${AndIf} $2 != "R"
|
||||
SetErrors
|
||||
DetailPrint "ERROR: Invalid Action - must be A, P, or R"
|
||||
Goto EnvVarUpdate_Restore_Vars
|
||||
${EndIf}
|
||||
|
||||
${If} $3 == HKLM
|
||||
ReadRegStr $5 ${hklm_all_users} $1 ; Get EnvVarName from all users into $5
|
||||
${ElseIf} $3 == HKCU
|
||||
ReadRegStr $5 ${hkcu_current_user} $1 ; Read EnvVarName from current user into $5
|
||||
${Else}
|
||||
SetErrors
|
||||
DetailPrint 'ERROR: Action is [$3] but must be "HKLM" or HKCU"'
|
||||
Goto EnvVarUpdate_Restore_Vars
|
||||
${EndIf}
|
||||
|
||||
; Check for empty PathString
|
||||
${If} $4 == ""
|
||||
SetErrors
|
||||
DetailPrint "ERROR: PathString is blank"
|
||||
Goto EnvVarUpdate_Restore_Vars
|
||||
${EndIf}
|
||||
|
||||
; Make sure we've got some work to do
|
||||
${If} $5 == ""
|
||||
${AndIf} $2 == "R"
|
||||
SetErrors
|
||||
DetailPrint "$1 is empty - Nothing to remove"
|
||||
Goto EnvVarUpdate_Restore_Vars
|
||||
${EndIf}
|
||||
|
||||
; Step 2: Scrub EnvVar
|
||||
;
|
||||
StrCpy $0 $5 ; Copy the contents to $0
|
||||
; Remove spaces around semicolons (NOTE: spaces before the 1st entry or
|
||||
; after the last one are not removed here but instead in Step 3)
|
||||
${If} $0 != "" ; If EnvVar is not empty ...
|
||||
${Do}
|
||||
${${UN}StrStr} $7 $0 " ;"
|
||||
${If} $7 == ""
|
||||
${ExitDo}
|
||||
${EndIf}
|
||||
${${UN}StrRep} $0 $0 " ;" ";" ; Remove '<space>;'
|
||||
${Loop}
|
||||
${Do}
|
||||
${${UN}StrStr} $7 $0 "; "
|
||||
${If} $7 == ""
|
||||
${ExitDo}
|
||||
${EndIf}
|
||||
${${UN}StrRep} $0 $0 "; " ";" ; Remove ';<space>'
|
||||
${Loop}
|
||||
${Do}
|
||||
${${UN}StrStr} $7 $0 ";;"
|
||||
${If} $7 == ""
|
||||
${ExitDo}
|
||||
${EndIf}
|
||||
${${UN}StrRep} $0 $0 ";;" ";"
|
||||
${Loop}
|
||||
|
||||
; Remove a leading or trailing semicolon from EnvVar
|
||||
StrCpy $7 $0 1 0
|
||||
${If} $7 == ";"
|
||||
StrCpy $0 $0 "" 1 ; Change ';<EnvVar>' to '<EnvVar>'
|
||||
${EndIf}
|
||||
StrLen $6 $0
|
||||
IntOp $6 $6 - 1
|
||||
StrCpy $7 $0 1 $6
|
||||
${If} $7 == ";"
|
||||
StrCpy $0 $0 $6 ; Change ';<EnvVar>' to '<EnvVar>'
|
||||
${EndIf}
|
||||
; DetailPrint "Scrubbed $1: [$0]" ; Uncomment to debug
|
||||
${EndIf}
|
||||
|
||||
/* Step 3. Remove all instances of the target path/string (even if "A" or "P")
|
||||
$6 = bool flag (1 = found and removed PathString)
|
||||
$7 = a string (e.g. path) delimited by semicolon(s)
|
||||
$8 = entry counter starting at 0
|
||||
$9 = copy of $0
|
||||
$R0 = tempChar */
|
||||
|
||||
${If} $5 != "" ; If EnvVar is not empty ...
|
||||
StrCpy $9 $0
|
||||
StrCpy $0 ""
|
||||
StrCpy $8 0
|
||||
StrCpy $6 0
|
||||
|
||||
${Do}
|
||||
${${UN}StrTok} $7 $9 ";" $8 "0" ; $7 = next entry, $8 = entry counter
|
||||
|
||||
${If} $7 == "" ; If we've run out of entries,
|
||||
${ExitDo} ; were done
|
||||
${EndIf} ;
|
||||
|
||||
; Remove leading and trailing spaces from this entry (critical step for Action=Remove)
|
||||
${Do}
|
||||
StrCpy $R0 $7 1
|
||||
${If} $R0 != " "
|
||||
${ExitDo}
|
||||
${EndIf}
|
||||
StrCpy $7 $7 "" 1 ; Remove leading space
|
||||
${Loop}
|
||||
${Do}
|
||||
StrCpy $R0 $7 1 -1
|
||||
${If} $R0 != " "
|
||||
${ExitDo}
|
||||
${EndIf}
|
||||
StrCpy $7 $7 -1 ; Remove trailing space
|
||||
${Loop}
|
||||
${If} $7 == $4 ; If string matches, remove it by not appending it
|
||||
StrCpy $6 1 ; Set 'found' flag
|
||||
${ElseIf} $7 != $4 ; If string does NOT match
|
||||
${AndIf} $0 == "" ; and the 1st string being added to $0,
|
||||
StrCpy $0 $7 ; copy it to $0 without a prepended semicolon
|
||||
${ElseIf} $7 != $4 ; If string does NOT match
|
||||
${AndIf} $0 != "" ; and this is NOT the 1st string to be added to $0,
|
||||
StrCpy $0 $0;$7 ; append path to $0 with a prepended semicolon
|
||||
${EndIf} ;
|
||||
|
||||
IntOp $8 $8 + 1 ; Bump counter
|
||||
${Loop} ; Check for duplicates until we run out of paths
|
||||
${EndIf}
|
||||
|
||||
; Step 4: Perform the requested Action
|
||||
;
|
||||
${If} $2 != "R" ; If Append or Prepend
|
||||
${If} $6 == 1 ; And if we found the target
|
||||
DetailPrint "Target is already present in $1. It will be removed and"
|
||||
${EndIf}
|
||||
${If} $0 == "" ; If EnvVar is (now) empty
|
||||
StrCpy $0 $4 ; just copy PathString to EnvVar
|
||||
${If} $6 == 0 ; If found flag is either 0
|
||||
${OrIf} $6 == "" ; or blank (if EnvVarName is empty)
|
||||
DetailPrint "$1 was empty and has been updated with the target"
|
||||
${EndIf}
|
||||
${ElseIf} $2 == "A" ; If Append (and EnvVar is not empty),
|
||||
StrCpy $0 $0;$4 ; append PathString
|
||||
${If} $6 == 1
|
||||
DetailPrint "appended to $1"
|
||||
${Else}
|
||||
DetailPrint "Target was appended to $1"
|
||||
${EndIf}
|
||||
${Else} ; If Prepend (and EnvVar is not empty),
|
||||
StrCpy $0 $4;$0 ; prepend PathString
|
||||
${If} $6 == 1
|
||||
DetailPrint "prepended to $1"
|
||||
${Else}
|
||||
DetailPrint "Target was prepended to $1"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
${Else} ; If Action = Remove
|
||||
${If} $6 == 1 ; and we found the target
|
||||
DetailPrint "Target was found and removed from $1"
|
||||
${Else}
|
||||
DetailPrint "Target was NOT found in $1 (nothing to remove)"
|
||||
${EndIf}
|
||||
${If} $0 == ""
|
||||
DetailPrint "$1 is now empty"
|
||||
${EndIf}
|
||||
${EndIf}
|
||||
|
||||
; Step 5: Update the registry at RegLoc with the updated EnvVar and announce the change
|
||||
;
|
||||
ClearErrors
|
||||
${If} $3 == HKLM
|
||||
WriteRegExpandStr ${hklm_all_users} $1 $0 ; Write it in all users section
|
||||
${ElseIf} $3 == HKCU
|
||||
WriteRegExpandStr ${hkcu_current_user} $1 $0 ; Write it to current user section
|
||||
${EndIf}
|
||||
|
||||
IfErrors 0 +4
|
||||
MessageBox MB_OK|MB_ICONEXCLAMATION "Could not write updated $1 to $3"
|
||||
DetailPrint "Could not write updated $1 to $3"
|
||||
Goto EnvVarUpdate_Restore_Vars
|
||||
|
||||
; "Export" our change
|
||||
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
|
||||
|
||||
EnvVarUpdate_Restore_Vars:
|
||||
;
|
||||
; Restore the user's variables and return ResultVar
|
||||
Pop $R0
|
||||
Pop $9
|
||||
Pop $8
|
||||
Pop $7
|
||||
Pop $6
|
||||
Pop $5
|
||||
Pop $4
|
||||
Pop $3
|
||||
Pop $2
|
||||
Pop $1
|
||||
Push $0 ; Push my $0 (ResultVar)
|
||||
Exch
|
||||
Pop $0 ; Restore his $0
|
||||
|
||||
FunctionEnd
|
||||
|
||||
!macroend ; EnvVarUpdate UN
|
||||
!insertmacro EnvVarUpdate ""
|
||||
!insertmacro EnvVarUpdate "un."
|
||||
;----------------------------------- EnvVarUpdate end----------------------------------------
|
||||
|
||||
!verbose pop
|
||||
!endif
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user