Both commands work with local devices by remotely invoking the `os-config` executable via SSH. This requires an as of yet unreleased resinOS (that will most likely be v2.14) and the commands ascertain compatibility merely by looking for the `os-config` executable in the device, and bail out if it’s not present.
`join` and `leave` accept a couple of optional arguments and implement a wizard-style interface if these are not given. They allow to interactively select the device and the application to promote to. If the user has no apps, `join` will offer the user to create one. `join` will also offer the user to login or create an account if they’re not logged in already without exiting the wizard.
`resin-sync` (that's used internally to discover local devices) requires admin privileges. If no device has been specified as an argument, the commands will launch the device scanning process in a privileged subprocess via two new internal commands: `internal sudo` and `internal scanDevices`. This avoids having the user to invoke the commands with sudo and only request escalation if truly needed. This commit also removes the dependency to “president”, implementing “sudo” functionality within the CLI.
Change-Type: minor
Before this point, if you had an invalid token, an expired token, or a
token for a different site, you couldn't log out to clear it properly.
Not a big deal, but awkward and messy, and easily fixed.
Change-Type: patch
This is part of a general push to demodularize any code that isn't
realistically reusable outside resin-cli, to make the codebase easier to
manage and understand. Once this is done, we'll deprecate the original
module itself.
Change-Type: patch
In my system (MBPr 13), printing the current version takes over 2
seconds:
```sh
$ time ./bin/resin version
2.4.0
./bin/resin version 1.37s user 0.19s system 73% cpu 2.130 total
```
The CLI takes almost all of these time to parse the dependency tree
before returning control over the actually called command.
To mitigate this problem, we only require the NPM dependencies a command
requires when executing such command, and thus prevent dependencies from
being required and parsed unnecessary.
After this improvement, printing the original example (`resin version`)
returns in less than a second (2x improvement):
```sh
$ time ./bin/resin version
2.4.0
./bin/resin version 0.88s user 0.09s system 102% cpu 0.938 total
```
This is useful in the scenario when the user is using the CLI in an
environment in which he/she doesn't have access to a web browser, like a
headless server or a Vagrant development environment.
When you change the `resinUrl` config from time to time it can be
confusing to remember where you're logging in, or in which host you're
in.
Currently I have to check the configuration files/environment variables
manually or run `resin settings`.
This PR prints the detected resin url on `resin login` and `resin
whoami` so it's always clear where you are.
This enforces all clients to use the Resin Settings Client version that
the SDK provides, reducing incompatibilities caused by different modules
requiring different Resin Settings Client versions.
Consider the following case:
The SDK is configured to point to staging, but the user passes a token
from production, or viceversa. Since the token is valid in a sense that
is valid JWT and contains real data, the CLI will report as a success.
The user will then get Unauthorized errors when using the API.