Rename everything from 'resin' to 'balena'

Change-type: major
This commit is contained in:
Tim Perry 2018-10-19 16:38:50 +02:00
parent ea1c1bb8d4
commit 4907fccf48
73 changed files with 968 additions and 1765 deletions

View File

@ -1,2 +1,2 @@
- **resin-cli version:**
- **Cli version:**
- **Operating system and architecture:**

2
.gitignore vendored
View File

@ -27,7 +27,9 @@ node_modules
npm-shrinkwrap.json
package-lock.json
.resinconf
.balenaconf
resinrc.yml
balenarc.yml
.idea
.vscode

View File

@ -16,4 +16,4 @@ deploy:
on:
tags: true
condition: "$TRAVIS_TAG =~ ^v?[[:digit:]]+\\.[[:digit:]]+\\.[[:digit:]]+"
repo: resin-io/resin-cli
repo: balena-io/balena-cli

View File

@ -1,11 +1,11 @@
Resin CLI
Balena CLI
=========
> The official resin.io CLI tool.
> The official balena CLI tool.
[![npm version](https://badge.fury.io/js/resin-cli.svg)](http://badge.fury.io/js/resin-cli)
[![dependencies](https://david-dm.org/resin-io/resin-cli.svg)](https://david-dm.org/resin-io/resin-cli)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/resin-io/chat)
[![npm version](https://badge.fury.io/js/balena-cli.svg)](http://badge.fury.io/js/balena-cli)
[![dependencies](https://david-dm.org/balena-io/balena-cli.svg)](https://david-dm.org/balena-io/balena-cli)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/balena-io/chat)
Requisites
----------
@ -16,15 +16,15 @@ we do now have an experimental standalone binary release available, see ['Standa
- [NodeJS](https://nodejs.org) (>= v6)
- [Git](https://git-scm.com)
- The following executables should be correctly installed in your shell environment:
- `ssh`: Any recent version of the OpenSSH ssh client (required by `resin sync` and `resin ssh`)
- `ssh`: Any recent version of the OpenSSH ssh client (required by `balena sync` and `balena ssh`)
- if you need `ssh` to work behind the proxy you also need [`proxytunnel`](http://proxytunnel.sourceforge.net/) installed (available as `proxytunnel` package for Ubuntu, for example)
- `rsync`: >= 2.6.9 (required by `resin sync`)
- `rsync`: >= 2.6.9 (required by `balena sync`)
##### Windows Support
Before installing resin-cli, you'll need a working node-gyp environment. If you don't already have one you'll see native module build errors during installation. To fix this, run `npm install -g --production windows-build-tools` in an administrator console (available as 'Command Prompt (Admin)' when pressing windows+x in Windows 7+).
Before installing balena-cli, you'll need a working node-gyp environment. If you don't already have one you'll see native module build errors during installation. To fix this, run `npm install -g --production windows-build-tools` in an administrator console (available as 'Command Prompt (Admin)' when pressing windows+x in Windows 7+).
`resin sync` and `resin ssh` have not been thoroughly tested on the standard Windows cmd.exe shell. We recommend using bash (or a similar) shell, like Bash for Windows 10 or [Git for Windows](https://git-for-windows.github.io/).
`balena sync` and `balena ssh` have not been thoroughly tested on the standard Windows cmd.exe shell. We recommend using bash (or a similar) shell, like Bash for Windows 10 or [Git for Windows](https://git-for-windows.github.io/).
If you still want to use `cmd.exe` you will have to use a package manager like MinGW or chocolatey. For MinGW the steps are:
@ -45,7 +45,7 @@ or if you have any trouble with this, please try the new standalone install step
This might require elevated privileges in some environments.
```sh
$ npm install resin-cli -g --production --unsafe-perm
$ npm install balena-cli -g --production --unsafe-perm
```
`--unsafe-perm` is only required on systems where the global install directory is not user-writable.
@ -64,70 +64,70 @@ well in initial cross-platform testing, so it may be useful, and we'd love your
To install the CLI as a standalone binary:
* Download the latest zip for your OS from https://github.com/resin-io/resin-cli/releases.
* Extract the contents, putting the `resin-cli` folder somewhere appropriate for your system (e.g. `C:/resin-cli`, `/usr/local/lib/resin-cli`, etc).
* Add the `resin-cli` folder to your `PATH` ([Windows instructions](https://www.computerhope.com/issues/ch000549.htm), [Linux instructions](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix), [OSX instructions](https://stackoverflow.com/questions/22465332/setting-path-environment-variable-in-osx-permanently))
* Running `resin` in a fresh command line should print the resin CLI help.
* Download the latest zip for your OS from https://github.com/balena-io/balena-cli/releases.
* Extract the contents, putting the `balena-cli` folder somewhere appropriate for your system (e.g. `C:/balena-cli`, `/usr/local/lib/balena-cli`, etc).
* Add the `balena-cli` folder to your `PATH` ([Windows instructions](https://www.computerhope.com/issues/ch000549.htm), [Linux instructions](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix), [OSX instructions](https://stackoverflow.com/questions/22465332/setting-path-environment-variable-in-osx-permanently))
* Running `balena` in a fresh command line should print the balena CLI help.
To update in future, simply download a new release and replace the extracted folder.
Have any problems, or see any unexpected behaviour? [Please file an issue!](https://github.com/resin-io/resin-cli/issues/new)
Have any problems, or see any unexpected behaviour? [Please file an issue!](https://github.com/balena-io/balena-cli/issues/new)
### Login
```sh
$ resin login
$ balena login
```
_(Typically useful, but not strictly required for all commands)_
### Run commands
Take a look at the full command documentation at [https://docs.resin.io/tools/cli/](https://docs.resin.io/tools/cli/#table-of-contents
), or by running `resin help`.
Take a look at the full command documentation at [https://balena.io/docs/tools/cli/](https://balena.io/docs/tools/cli/#table-of-contents
), or by running `balena help`.
### Bash completions
Optionally you can enable tab completions for the bash shell, enabling the shell to provide additional context and automatically complete arguments to`resin`. To enable bash completions, copy the `resin-completion.bash` file to the default bash completions directory (usually `/etc/bash_completion.d/`) or append it to the end of `~/.bash_completion`.
Optionally you can enable tab completions for the bash shell, enabling the shell to provide additional context and automatically complete arguments to`balena`. To enable bash completions, copy the `balena-completion.bash` file to the default bash completions directory (usually `/etc/bash_completion.d/`) or append it to the end of `~/.bash_completion`.
FAQ
---
### Where is my configuration file?
The per-user configuration file lives in `$HOME/.resinrc.yml` or `%UserProfile%\_resinrc.yml`, in Unix based operating systems and Windows respectively.
The per-user configuration file lives in `$HOME/.balenarc.yml` or `%UserProfile%\_balenarc.yml`, in Unix based operating systems and Windows respectively.
The Resin CLI also attempts to read a `resinrc.yml` file in the current directory, which takes precedence over the per-user configuration file.
The balena CLI also attempts to read a `balenarc.yml` file in the current directory, which takes precedence over the per-user configuration file.
### How do I point the Resin CLI to staging?
### How do I point the balena CLI to staging?
The easiest way is to set the `RESINRC_RESIN_URL=resinstaging.io` environment variable.
The easiest way is to set the `BALENARC_BALENA_URL=balena-staging.com` environment variable.
Alternatively, you can edit your configuration file and set `resinUrl: resinstaging.io` to persist this setting.
Alternatively, you can edit your configuration file and set `balenaUrl: balena-staging.com` to persist this setting.
### How do I make the Resin CLI persist data in another directory?
### How do I make the balena CLI persist data in another directory?
The Resin CLI persists your session token, as well as cached images in `$HOME/.resin` or `%UserProfile%\_resin`.
The balena CLI persists your session token, as well as cached images in `$HOME/.balena` or `%UserProfile%\_balena`.
Pointing the Resin CLI to persist data in another location is necessary in certain environments, like a server, where there is no home directory, or a device running resinOS, which erases all data after a restart.
Pointing the balena CLI to persist data in another location is necessary in certain environments, like a server, where there is no home directory, or a device running balenaOS, which erases all data after a restart.
You can accomplish this by setting `RESINRC_DATA_DIRECTORY=/opt/resin` or adding `dataDirectory: /opt/resin` to your configuration file, replacing `/opt/resin` with your desired directory.
You can accomplish this by setting `BALENARC_DATA_DIRECTORY=/opt/balena` or adding `dataDirectory: /opt/balena` to your configuration file, replacing `/opt/balena` with your desired directory.
Support
-------
If you're having any problems, check our [troubleshooting guide](https://github.com/resin-io/resin-cli/blob/master/TROUBLESHOOTING.md) and if your problem is not addressed there, please [raise an issue](https://github.com/resin-io/resin-cli/issues/new) on GitHub and the resin.io team will be happy to help.
If you're having any problems, check our [troubleshooting guide](https://github.com/balena-io/balena-cli/blob/master/TROUBLESHOOTING.md) and if your problem is not addressed there, please [raise an issue](https://github.com/balena-io/balena-cli/issues/new) on GitHub and the balena team will be happy to help.
You can also get in touch with us in the resin.io [forums](https://forums.resin.io/).
You can also get in touch with us in the balena [forums](https://forums.balena.io/).
Development guidelines
----------------------
After cloning this repository and running `npm install` you can build the CLI using `npm run build`.
You can then run the generated build using `./bin/resin`.
You can then run the generated build using `./bin/balena`.
In order to ease development:
* you can build the CLI using the `npm run build:fast` variant which skips some of the build steps or
* you can use `./bin/resin-dev` which live transpiles the sources of the CLI.
* you can use `./bin/balena-dev` which live transpiles the sources of the CLI.
In either case, before opening a PR make sure to also test your changes after doing a full build with `npm run build`.

View File

@ -1,13 +1,13 @@
Troubleshooting
===============
This document contains common issues related to the Resin CLI, and how to fix them.
This document contains common issues related to the balena CLI, and how to fix them.
### After burning to an sdcard, my device doesn't boot
- The downloaded image is not complete (download was interrupted).
Please clean the cache (`%HOME/.resin/cache` or `C:\Users\<user>\_resin\cache`) and run the command again. In the future, the CLI will check that the image is not complete and clean the cache for you.
Please clean the cache (`%HOME/.balena/cache` or `C:\Users\<user>\_balena\cache`) and run the command again. In the future, the CLI will check that the image is not complete and clean the cache for you.
### I get a permission error when burning to an sdcard
@ -24,10 +24,10 @@ net.js:156
Error: EINVAL, invalid argument
at new Socket (net.js:156:18)
at process.stdin (node.js:664:19)
at Object.Interface.createInterface (C:\cygwin\home\Juan Cruz Viotti\Projects\resin-cli\node_modules\inquirer\node_modules\readline2\index.js:31:43)
at PromptUI.UI (C:\cygwin\home\Juan Cruz Viotti\Projects\resin-cli\node_modules\inquirer\lib\ui\baseUI.js:23:40)
at new PromptUI (C:\cygwin\home\Juan Cruz Viotti\Projects\resin-cli\node_modules\inquirer\lib\ui\prompt.js:26:8)
at Object.promptModule [as prompt] (C:\cygwin\home\Juan Cruz Viotti\Projects\resin-cli\node_modules\inquirer\lib\inquirer.js:27:14)
at Object.Interface.createInterface (C:\cygwin\home\Juan Cruz Viotti\Projects\balena-cli\node_modules\inquirer\node_modules\readline2\index.js:31:43)
at PromptUI.UI (C:\cygwin\home\Juan Cruz Viotti\Projects\balena-cli\node_modules\inquirer\lib\ui\baseUI.js:23:40)
at new PromptUI (C:\cygwin\home\Juan Cruz Viotti\Projects\balena-cli\node_modules\inquirer\lib\ui\prompt.js:26:8)
at Object.promptModule [as prompt] (C:\cygwin\home\Juan Cruz Viotti\Projects\balena-cli\node_modules\inquirer\lib\inquirer.js:27:14)
```
- Some interactive widgets don't work on `Cygwin`. If you're running Windows, it's preferrable that you use `cmd.exe`, as `Cygwin` is [not official supported by Node.js](https://github.com/chjj/blessed/issues/56#issuecomment-42671945).
@ -39,21 +39,21 @@ This error, accompanied with something like: `Expected 0xAA55, but saw 0x29FE` u
Try clearing the cache with the following command and trying again:
```sh
$ rm -rf $HOME/.resin/cache
$ rm -rf $HOME/.balena/cache
```
Or in Windows:
```sh
> del /s /q %UserProfile%\_resin\cache
> del /s /q %UserProfile%\_balena\cache
```
### I get `EACCES: permission denied` when logging in
The Resin CLI stores the session token in `$HOME/.resin` or `C:\Users\<user>\_resin` in UNIX based operating systems and Windows respectively. This error usually indicates that the user doesn't have permissions over that directory, which can happen if you ran the Resin CLI as `root`, and thus the directory got owned by him.
The balena CLI stores the session token in `$HOME/.balena` or `C:\Users\<user>\_balena` in UNIX based operating systems and Windows respectively. This error usually indicates that the user doesn't have permissions over that directory, which can happen if you ran the balena CLI as `root`, and thus the directory got owned by him.
Try resetting the ownership by running:
```sh
$ sudo chown -R <user> $HOME/.resin
$ sudo chown -R <user> $HOME/.balena
```

View File

@ -7,7 +7,7 @@ const ROOT = path.join(__dirname, '..');
console.log('Building package...\n');
execPkg(['--target', 'host', '--output', 'build-bin/resin', 'package.json'])
execPkg(['--target', 'host', '--output', 'build-bin/balena', 'package.json'])
.then(() =>
fs.copy(
path.join(ROOT, 'node_modules', 'opn', 'xdg-open'),

View File

@ -17,7 +17,7 @@ const version = 'v' + packageJSON.version;
const outputFile = path.join(
ROOT,
'build-zip',
`resin-cli-${version}-${os.platform()}-${os.arch()}.zip`,
`balena-cli-${version}-${os.platform()}-${os.arch()}.zip`,
);
mkdirpAsync(path.dirname(outputFile))
@ -29,7 +29,7 @@ mkdirpAsync(path.dirname(outputFile))
let archive = archiver('zip', {
zlib: { level: 7 },
});
archive.directory(path.join(ROOT, 'build-bin'), 'resin-cli');
archive.directory(path.join(ROOT, 'build-bin'), 'balena-cli');
let outputStream = fs.createWriteStream(outputFile);
@ -49,10 +49,10 @@ mkdirpAsync(path.dirname(outputFile))
return publishReleaseAsync({
token: <string>GITHUB_TOKEN,
owner: 'resin-io',
repo: 'resin-cli',
owner: 'balena-io',
repo: 'balena-cli',
tag: version,
name: `Resin-CLI ${version}`,
name: `balena-CLI ${version}`,
reuseRelease: true,
assets: [outputFile],
});

View File

@ -1,6 +1,6 @@
#!/bin/bash
_resin_complete()
_balena_complete()
{
local cur prev
@ -70,4 +70,4 @@ _resin_complete()
fi
}
complete -F _resin_complete resin
complete -F _balena_complete balena

View File

@ -2,7 +2,7 @@
// ****************************************************************************
// THIS IS FOR DEV PERROSES ONLY AND WILL NOT BE PART OF THE PUBLISHED PACKAGE
// Before opening a PR you should build and test your changes using bin/resin
// Before opening a PR you should build and test your changes using bin/balena
// ****************************************************************************
// We boost the threadpool size as ext2fs can deadlock with some

View File

@ -1,9 +1,9 @@
export = {
title: 'Resin CLI Documentation',
title: 'Balena CLI Documentation',
introduction: `\
This tool allows you to interact with the resin.io api from the comfort of your command line.
This tool allows you to interact with the balena api from the comfort of your command line.
Please make sure your system meets the requirements as specified in the [README](https://github.com/resin-io/resin-cli).
Please make sure your system meets the requirements as specified in the [README](https://github.com/balena-io/balena-cli).
## Install the CLI
@ -11,7 +11,7 @@ Please make sure your system meets the requirements as specified in the [README]
The best supported way to install the CLI is from npm:
$ npm install resin-cli -g --production --unsafe-perm
$ npm install balena-cli -g --production --unsafe-perm
\`--unsafe-perm\` is only required on systems where the global install directory is not user-writable.
This allows npm install steps to download and save prebuilt native binaries. You may be able to omit it,
@ -25,13 +25,13 @@ initial cross-platform testing, so it may be useful, and we'd love your feedback
To install the CLI as a standalone binary:
* Download the latest zip for your OS from https://github.com/resin-io/resin-cli/releases.
* Extract the contents, putting the \`resin-cli\` folder somewhere appropriate for your system (e.g. \`C:/resin-cli\`, \`/usr/local/lib/resin-cli\`, etc).
* Add the \`resin-cli\` folder to your \`PATH\`. (
* Download the latest zip for your OS from https://github.com/balena-io/balena-cli/releases.
* Extract the contents, putting the \`balena-cli\` folder somewhere appropriate for your system (e.g. \`C:/balena-cli\`, \`/usr/local/lib/balena-cli\`, etc).
* Add the \`balena-cli\` folder to your \`PATH\`. (
[Windows instructions](https://www.computerhope.com/issues/ch000549.htm),
[Linux instructions](https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux-unix),
[OSX instructions](https://stackoverflow.com/questions/22465332/setting-path-environment-variable-in-osx-permanently))
* Running \`resin\` in a fresh command line should print the resin CLI help.
* Running \`balena\` in a fresh command line should print the balena CLI help.
To update in future, simply download a new release and replace the extracted folder.
@ -39,11 +39,11 @@ Have any problems, or see any unexpected behaviour? Please file an issue!
## Getting started
Once you have the CLI installed, you'll need to log in, so it can access everything in your resin.io account.
Once you have the CLI installed, you'll need to log in, so it can access everything in your balena account.
To authenticate yourself, run:
$ resin login
$ balena login
You now have access to all the commands referenced below.
@ -53,8 +53,8 @@ The CLI does support HTTP(S) proxies.
You can configure the proxy using several methods (in order of their precedence):
* set the \`RESINRC_PROXY\` environment variable in the URL format (with protocol, host, port, and optionally the basic auth),
* use the [resin config file](https://www.npmjs.com/package/resin-settings-client#documentation) (project-specific or user-level)
* set the \`BALENARC_PROXY\` environment variable in the URL format (with protocol, host, port, and optionally the basic auth),
* use the [balena config file](https://www.npmjs.com/package/balena-settings-client#documentation) (project-specific or user-level)
and set the \`proxy\` setting. This can be:
* a string in the URL format,
* or an object following [this format](https://www.npmjs.com/package/global-tunnel-ng#options), which allows more control,
@ -65,90 +65,87 @@ environment variable (in the same standard URL format).\
categories: [
{
title: 'Api keys',
files: [ 'build/actions/api-key.js' ],
files: ['build/actions/api-key.js'],
},
{
title: 'Application',
files: [ 'build/actions/app.js' ]
files: ['build/actions/app.js'],
},
{
title: 'Authentication',
files: [ 'build/actions/auth.js' ]
files: ['build/actions/auth.js'],
},
{
title: 'Device',
files: [ 'build/actions/device.js' ]
files: ['build/actions/device.js'],
},
{
title: 'Environment Variables',
files: [ 'build/actions/environment-variables.js' ]
files: ['build/actions/environment-variables.js'],
},
{
title: 'Help',
files: [ 'build/actions/help.js' ]
files: ['build/actions/help.js'],
},
{
title: 'Information',
files: [ 'build/actions/info.js' ]
files: ['build/actions/info.js'],
},
{
title: 'Keys',
files: [ 'build/actions/keys.js' ]
files: ['build/actions/keys.js'],
},
{
title: 'Logs',
files: [ 'build/actions/logs.js' ]
files: ['build/actions/logs.js'],
},
{
title: 'Sync',
files: [ 'build/actions/sync.js' ]
files: ['build/actions/sync.js'],
},
{
title: 'SSH',
files: [ 'build/actions/ssh.js' ]
files: ['build/actions/ssh.js'],
},
{
title: 'Notes',
files: [ 'build/actions/notes.js' ]
files: ['build/actions/notes.js'],
},
{
title: 'OS',
files: [ 'build/actions/os.js' ]
files: ['build/actions/os.js'],
},
{
title: 'Config',
files: [ 'build/actions/config.js' ]
files: ['build/actions/config.js'],
},
{
title: 'Preload',
files: [ 'build/actions/preload.js' ]
files: ['build/actions/preload.js'],
},
{
title: 'Push',
files: [ 'build/actions/push.js' ]
files: ['build/actions/push.js'],
},
{
title: 'Settings',
files: [ 'build/actions/settings.js' ]
files: ['build/actions/settings.js'],
},
{
title: 'Wizard',
files: [ 'build/actions/wizard.js' ]
files: ['build/actions/wizard.js'],
},
{
title: 'Local',
files: [ 'build/actions/local/index.js' ]
files: ['build/actions/local/index.js'],
},
{
title: 'Deploy',
files: [
'build/actions/build.js',
'build/actions/deploy.js'
]
files: ['build/actions/build.js', 'build/actions/deploy.js'],
},
{
title: 'Utilities',
files: [ 'build/actions/util.js' ]
files: ['build/actions/util.js'],
},
]
],
};

View File

@ -1,4 +1,4 @@
# Provisioning Resin.io devices in automated (non-interactive) mode
# Provisioning balena devices in automated (non-interactive) mode
This document describes how to run the `device init` command in non-interactive mode.
@ -7,7 +7,7 @@ It requires collecting some preliminary information _once_.
The final command to provision the device looks like this:
```bash
resin device init --app APP_ID --os-version OS_VERSION --drive DRIVE --config CONFIG_FILE --yes
balena device init --app APP_ID --os-version OS_VERSION --drive DRIVE --config CONFIG_FILE --yes
```
@ -20,15 +20,15 @@ But before you can run it you need to collect the parameters and build the confi
1. `DEVICE_TYPE`. Run
```bash
resin devices supported
balena devices supported
```
and find the _slug_ for your target device type, like _raspberrypi3_.
1. `APP_ID`. Create an application (`resin app create APP_NAME --type DEVICE_TYPE`) or find an existing one (`resin apps`) and notice its ID.
1. `APP_ID`. Create an application (`balena app create APP_NAME --type DEVICE_TYPE`) or find an existing one (`balena apps`) and notice its ID.
1. `OS_VERSION`. Run
```bash
resin os versions DEVICE_TYPE
balena os versions DEVICE_TYPE
```
and pick the version that you need, like _v2.0.6+rev1.prod_.
_Note_ that even though we support _semver ranges_ it's recommended to use the exact version when doing the automated provisioning as it
@ -36,10 +36,10 @@ But before you can run it you need to collect the parameters and build the confi
1. `DRIVE`. Plug in your target medium (SD card or the USB stick, depending on your device type) and run
```bash
resin util available-drives
balena util available-drives
```
and get the drive name, like _/dev/sdb_ or _/dev/mmcblk0_.
The resin CLI will not display the system drives to protect you,
The balena CLI will not display the system drives to protect you,
but still please check very carefully that you've picked the correct drive as it will be erased during the provisioning process.
Now we have all the parameters -- time to build the config file.
@ -50,21 +50,21 @@ Interactive device provisioning process often includes collecting some extra dev
To skip this interactive step we need to buid this configuration once and save it to the JSON file for later reuse.
Let's say we will place it into the `CONFIG_FILE` path, like _./resin-os/raspberrypi3-config.json_.
Let's say we will place it into the `CONFIG_FILE` path, like _./balena-os/raspberrypi3-config.json_.
We also need to put the OS image somewhere, let's call this path `OS_IMAGE_PATH`, it can be something like _./resin-os/raspberrypi3-v2.0.6+rev1.prod.img_.
We also need to put the OS image somewhere, let's call this path `OS_IMAGE_PATH`, it can be something like _./balena-os/raspberrypi3-v2.0.6+rev1.prod.img_.
1. First we need to download the OS image once. That's needed for building the config, and will speedup the subsequent operations as the downloaded OS image is placed into the local cache.
Run:
```bash
resin os download DEVICE_TYPE --output OS_IMAGE_PATH --version OS_VERSION
balena os download DEVICE_TYPE --output OS_IMAGE_PATH --version OS_VERSION
```
1. Now we're ready to build the config:
```bash
resin os build-config OS_IMAGE_PATH DEVICE_TYPE --output CONFIG_FILE
balena os build-config OS_IMAGE_PATH DEVICE_TYPE --output CONFIG_FILE
```
This will run you through the interactive configuration wizard and in the end save the generated config as `CONFIG_FILE`. You can then verify it's not empty:
@ -97,11 +97,11 @@ There are several ways to eliminate it and make the process fully non-interactiv
Obviously you shouldn't do that if the machine you're working on has access to any sensitive resources or information.
But if you're using a machine dedicated to resin provisioning this can be fine, and also the simplest thing to do.
But if you're using a machine dedicated to balena provisioning this can be fine, and also the simplest thing to do.
#### Option 2: `NOPASSWD` directive
You can configure the `resin` CLI command to be sudo-runnable without the password. Check [this post](https://askubuntu.com/questions/159007/how-do-i-run-specific-sudo-commands-without-a-password) for an example.
You can configure the `balena` CLI command to be sudo-runnable without the password. Check [this post](https://askubuntu.com/questions/159007/how-do-i-run-specific-sudo-commands-without-a-password) for an example.
### Extra initialization config
@ -109,4 +109,4 @@ As of June 2017 all the supported devices should not require any other interacti
But by the design of our system it is _possible_ (though it doesn't look very likely it's going to happen any time soon) that some extra initialization options may be requested for the specific device types.
If that is the case please raise the issue in the resin CLI repository and the maintainers will add the necessary options to build the similar JSON config for this step.
If that is the case please raise the issue in the balena CLI repository and the maintainers will add the necessary options to build the similar JSON config for this step.

File diff suppressed because it is too large Load Diff

View File

@ -10,17 +10,17 @@ export const generate: CommandDefinition<{
This command generates a new API key for the current user, with the given
name. The key will be logged to the console.
This key can be used to log into the CLI using 'resin login --token <key>',
This key can be used to log into the CLI using 'balena login --token <key>',
or to authenticate requests to the API with an 'Authorization: Bearer <key>' header.
Examples:
$ resin api-key generate "Jenkins Key"
$ balena api-key generate "Jenkins Key"
`,
async action(params, _options, done) {
const resin = (await import('resin-sdk')).fromSharedOptions();
const balena = (await import('balena-sdk')).fromSharedOptions();
resin.models.apiKey
balena.models.apiKey
.create(params.name)
.then(key => {
console.log(stripIndent`

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -20,45 +20,45 @@ exports.create =
signature: 'app create <name>'
description: 'create an application'
help: '''
Use this command to create a new resin.io application.
Use this command to create a new balena application.
You can specify the application device 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
$ balena devices supported
Examples:
$ resin app create MyApp
$ resin app create MyApp --type raspberry-pi
$ balena app create MyApp
$ balena app create MyApp --type raspberry-pi
'''
options: [
{
signature: 'type'
parameter: 'type'
description: 'application device type (Check available types with `resin devices supported`)'
description: 'application device type (Check available types with `balena devices supported`)'
alias: 't'
}
]
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
patterns = require('../utils/patterns')
# Validate the the application name is available
# before asking the device type.
# https://github.com/resin-io/resin-cli/issues/30
resin.models.application.has(params.name).then (hasApplication) ->
# https://github.com/balena-io/balena-cli/issues/30
balena.models.application.has(params.name).then (hasApplication) ->
if hasApplication
patterns.exitWithExpectedError('You already have an application with that name!')
.then ->
return options.type or patterns.selectDeviceType()
.then (deviceType) ->
return resin.models.application.create({
return balena.models.application.create({
name: params.name
deviceType
})
@ -73,19 +73,19 @@ 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 <name> instead.
If you want detailed information, use balena app <name> instead.
Examples:
$ resin apps
$ balena apps
'''
permission: 'user'
primary: true
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
visuals = require('resin-cli-visuals')
resin.models.application.getAll().then (applications) ->
balena.models.application.getAll().then (applications) ->
console.log visuals.table.horizontal applications, [
'id'
'app_name'
@ -103,15 +103,15 @@ exports.info =
Examples:
$ resin app MyApp
$ balena app MyApp
'''
permission: 'user'
primary: true
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
visuals = require('resin-cli-visuals')
resin.models.application.get(params.name).then (application) ->
balena.models.application.get(params.name).then (application) ->
console.log visuals.table.vertical application, [
"$#{application.app_name}$"
'id'
@ -129,33 +129,33 @@ exports.restart =
Examples:
$ resin app restart MyApp
$ balena app restart MyApp
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
resin.models.application.restart(params.name).nodeify(done)
balena = require('balena-sdk').fromSharedOptions()
balena.models.application.restart(params.name).nodeify(done)
exports.remove =
signature: 'app rm <name>'
description: 'remove an application'
help: '''
Use this command to remove a resin.io application.
Use this command to remove a balena 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
$ balena app rm MyApp
$ balena app rm MyApp --yes
'''
options: [ commandOptions.yes ]
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the application?').then ->
resin.models.application.remove(params.name)
balena.models.application.remove(params.name)
.nodeify(done)

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -16,9 +16,9 @@ limitations under the License.
exports.login =
signature: 'login'
description: 'login to resin.io'
description: 'login to balena'
help: '''
Use this command to login to your resin.io account.
Use this command to login to your balena account.
This command will prompt you to login using the following login types:
@ -31,11 +31,11 @@ exports.login =
Examples:
$ resin login
$ resin login --web
$ resin login --token "..."
$ resin login --credentials
$ resin login --credentials --email johndoe@gmail.com --password secret
$ balena login
$ balena login --web
$ balena login --token "..."
$ balena login --credentials
$ balena login --credentials --email johndoe@gmail.com --password secret
'''
options: [
{
@ -73,7 +73,7 @@ exports.login =
action: (params, options, done) ->
_ = require('lodash')
Promise = require('bluebird')
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
auth = require('../auth')
form = require('resin-cli-form')
patterns = require('../utils/patterns')
@ -87,9 +87,9 @@ exports.login =
message: 'Session token or API key (experimental) from the preferences page'
name: 'token'
type: 'input'
.then(resin.auth.loginWithToken)
.then(balena.auth.loginWithToken)
.tap ->
resin.auth.whoami()
balena.auth.whoami()
.then (username) ->
if !username
patterns.exitWithExpectedError('Token authentication failed')
@ -108,18 +108,18 @@ exports.login =
options[loginType] = true
return login(options)
resin.settings.get('resinUrl').then (resinUrl) ->
console.log(messages.resinAsciiArt)
console.log("\nLogging in to #{resinUrl}")
balena.settings.get('balenaUrl').then (balenaUrl) ->
console.log(messages.balenaAsciiArt)
console.log("\nLogging in to #{balenaUrl}")
return login(options)
.then(resin.auth.whoami)
.then(balena.auth.whoami)
.tap (username) ->
console.info("Successfully logged in as: #{username}")
console.info """
Find out about the available commands by running:
$ resin help
$ balena help
#{messages.reachingOut}
"""
@ -127,42 +127,42 @@ exports.login =
exports.logout =
signature: 'logout'
description: 'logout from resin.io'
description: 'logout from balena'
help: '''
Use this command to logout from your resin.io account.o
Use this command to logout from your balena account.o
Examples:
$ resin logout
$ balena logout
'''
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
resin.auth.logout().nodeify(done)
balena = require('balena-sdk').fromSharedOptions()
balena.auth.logout().nodeify(done)
exports.signup =
signature: 'signup'
description: 'signup to resin.io'
description: 'signup to balena'
help: '''
Use this command to signup for a resin.io account.
Use this command to signup for a balena account.
If signup is successful, you'll be logged in to your new user automatically.
Examples:
$ resin signup
$ balena signup
Email: johndoe@acme.com
Password: ***********
$ resin whoami
$ balena whoami
johndoe
'''
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
form = require('resin-cli-form')
validation = require('../utils/validation')
resin.settings.get('resinUrl').then (resinUrl) ->
console.log("\nRegistering to #{resinUrl}")
balena.settings.get('balenaUrl').then (balenaUrl) ->
console.log("\nRegistering to #{balenaUrl}")
form.run [
message: 'Email:'
@ -176,8 +176,8 @@ exports.signup =
validate: validation.validatePassword
]
.then(resin.auth.register)
.then(resin.auth.loginWithToken)
.then(balena.auth.register)
.then(balena.auth.loginWithToken)
.nodeify(done)
exports.whoami =
@ -188,18 +188,18 @@ exports.whoami =
Examples:
$ resin whoami
$ balena whoami
'''
permission: 'user'
action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
visuals = require('resin-cli-visuals')
Promise.props
username: resin.auth.whoami()
email: resin.auth.getEmail()
url: resin.settings.get('resinUrl')
username: balena.auth.whoami()
email: balena.auth.getEmail()
url: balena.settings.get('balenaUrl')
.then (results) ->
console.log visuals.table.vertical results, [
'$account information$'

View File

@ -53,7 +53,7 @@ module.exports =
with the provided docker daemon.
You must provide either an application or a device-type/architecture
pair to use the resin Dockerfile pre-processor
pair to use the balena Dockerfile pre-processor
(e.g. Dockerfile.template -> Dockerfile).
This command will look into the given source directory (or the current working
@ -64,12 +64,12 @@ module.exports =
Examples:
$ resin build
$ resin build ./source/
$ resin build --deviceType raspberrypi3 --arch armhf --emulated
$ resin build --application MyApp ./source/
$ resin build --docker '/var/run/docker.sock'
$ resin build --dockerHost my.docker.host --dockerPort 2376 --ca ca.pem --key key.pem --cert cert.pem
$ balena build
$ balena build ./source/
$ balena build --deviceType raspberrypi3 --arch armhf --emulated
$ balena build --application MyApp ./source/
$ balena build --docker '/var/run/docker.sock'
$ balena build --dockerHost my.docker.host --dockerPort 2376 --ca ca.pem --key key.pem --cert cert.pem
'''
options: dockerUtils.appendOptions compose.appendOptions [
{
@ -87,7 +87,7 @@ module.exports =
{
signature: 'application'
parameter: 'application'
description: 'The target resin.io application this build is for'
description: 'The target balena application this build is for'
alias: 'a'
},
]

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -40,13 +40,13 @@ exports.optionalDevice =
exports.optionalDeviceApiKey =
signature: 'deviceApiKey'
description: 'custom device key - note that this is only supported on ResinOS 2.0.3+'
description: 'custom device key - note that this is only supported on balenaOS 2.0.3+'
parameter: 'device-api-key'
alias: 'k'
exports.optionalOsVersion =
signature: 'version'
description: 'a resinOS version'
description: 'a balenaOS version'
parameter: 'version'
exports.osVersion = _.defaults
@ -98,7 +98,7 @@ exports.drive =
signature: 'drive'
description: 'the drive to write the image to, like `/dev/sdb` or `/dev/mmcblk0`.
Careful with this as you can erase your hard drive.
Check `resin util available-drives` for available options.'
Check `balena util available-drives` for available options.'
parameter: 'drive'
alias: 'd'
@ -111,5 +111,5 @@ exports.advancedConfig =
exports.hostOSAccess =
signature: 'host'
boolean: true
description: 'access host OS (for devices with Resin OS >= 2.7.5)'
description: 'access host OS (for devices with balenaOS >= 2.7.5)'
alias: 's'

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -25,13 +25,13 @@ exports.read =
Examples:
$ resin config read --type raspberry-pi
$ resin config read --type raspberry-pi --drive /dev/disk2
$ balena config read --type raspberry-pi
$ balena config read --type raspberry-pi --drive /dev/disk2
'''
options: [
{
signature: 'type'
description: 'device type (Check available types with `resin devices supported`)'
description: 'device type (Check available types with `balena devices supported`)'
parameter: 'type'
alias: 't'
required: 'You have to specify a device type'
@ -47,7 +47,7 @@ exports.read =
root: true
action: (params, options, done) ->
Promise = require('bluebird')
config = require('resin-config-json')
config = require('balena-config-json')
visuals = require('resin-cli-visuals')
umountAsync = Promise.promisify(require('umount').umount)
prettyjson = require('prettyjson')
@ -69,14 +69,14 @@ exports.write =
Examples:
$ resin config write --type raspberry-pi username johndoe
$ resin config write --type raspberry-pi --drive /dev/disk2 username johndoe
$ resin config write --type raspberry-pi files.network/settings "..."
$ balena config write --type raspberry-pi username johndoe
$ balena config write --type raspberry-pi --drive /dev/disk2 username johndoe
$ balena config write --type raspberry-pi files.network/settings "..."
'''
options: [
{
signature: 'type'
description: 'device type (Check available types with `resin devices supported`)'
description: 'device type (Check available types with `balena devices supported`)'
parameter: 'type'
alias: 't'
required: 'You have to specify a device type'
@ -93,7 +93,7 @@ exports.write =
action: (params, options, done) ->
Promise = require('bluebird')
_ = require('lodash')
config = require('resin-config-json')
config = require('balena-config-json')
visuals = require('resin-cli-visuals')
umountAsync = Promise.promisify(require('umount').umount)
@ -118,17 +118,17 @@ exports.inject =
description: 'inject a device configuration file'
help: '''
Use this command to inject a config.json file to the mounted filesystem
(e.g. SD card or mounted resinOS image) of a provisioned device"
(e.g. SD card or mounted balenaOS image) of a provisioned device"
Examples:
$ resin config inject my/config.json --type raspberry-pi
$ resin config inject my/config.json --type raspberry-pi --drive /dev/disk2
$ balena config inject my/config.json --type raspberry-pi
$ balena config inject my/config.json --type raspberry-pi --drive /dev/disk2
'''
options: [
{
signature: 'type'
description: 'device type (Check available types with `resin devices supported`)'
description: 'device type (Check available types with `balena devices supported`)'
parameter: 'type'
alias: 't'
required: 'You have to specify a device type'
@ -144,7 +144,7 @@ exports.inject =
root: true
action: (params, options, done) ->
Promise = require('bluebird')
config = require('resin-config-json')
config = require('balena-config-json')
visuals = require('resin-cli-visuals')
umountAsync = Promise.promisify(require('umount').umount)
readFileAsync = Promise.promisify(require('fs').readFile)
@ -167,14 +167,14 @@ exports.reconfigure =
Examples:
$ resin config reconfigure --type raspberry-pi
$ resin config reconfigure --type raspberry-pi --advanced
$ resin config reconfigure --type raspberry-pi --drive /dev/disk2
$ balena config reconfigure --type raspberry-pi
$ balena config reconfigure --type raspberry-pi --advanced
$ balena config reconfigure --type raspberry-pi --drive /dev/disk2
'''
options: [
{
signature: 'type'
description: 'device type (Check available types with `resin devices supported`)'
description: 'device type (Check available types with `balena devices supported`)'
parameter: 'type'
alias: 't'
required: 'You have to specify a device type'
@ -196,7 +196,7 @@ exports.reconfigure =
root: true
action: (params, options, done) ->
Promise = require('bluebird')
config = require('resin-config-json')
config = require('balena-config-json')
visuals = require('resin-cli-visuals')
{ runCommand } = require('../utils/helpers')
umountAsync = Promise.promisify(require('umount').umount)
@ -231,13 +231,13 @@ exports.generate =
Examples:
$ resin config generate --device 7cf02a6 --version 2.12.7
$ resin config generate --device 7cf02a6 --version 2.12.7 --generate-device-api-key
$ resin config generate --device 7cf02a6 --version 2.12.7 --device-api-key <existingDeviceKey>
$ resin config generate --device 7cf02a6 --version 2.12.7 --output config.json
$ resin config generate --app MyApp --version 2.12.7
$ resin config generate --app MyApp --version 2.12.7 --output config.json
$ resin config generate --app MyApp --version 2.12.7 \
$ balena config generate --device 7cf02a6 --version 2.12.7
$ balena config generate --device 7cf02a6 --version 2.12.7 --generate-device-api-key
$ balena config generate --device 7cf02a6 --version 2.12.7 --device-api-key <existingDeviceKey>
$ balena config generate --device 7cf02a6 --version 2.12.7 --output config.json
$ balena config generate --app MyApp --version 2.12.7
$ balena config generate --app MyApp --version 2.12.7 --output config.json
$ balena config generate --app MyApp --version 2.12.7 \
--network wifi --wifiSsid mySsid --wifiKey abcdefgh --appUpdatePollInterval 1
'''
options: [
@ -283,7 +283,7 @@ exports.generate =
normalizeUuidProp(options, 'device')
Promise = require('bluebird')
writeFileAsync = Promise.promisify(require('fs').writeFile)
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
form = require('resin-cli-form')
deviceConfig = require('resin-device-config')
prettyjson = require('prettyjson')
@ -297,15 +297,15 @@ exports.generate =
See the help page for examples:
$ resin help config generate
$ balena help config generate
'''
Promise.try ->
if options.device?
return resin.models.device.get(options.device)
return resin.models.application.get(options.application)
return balena.models.device.get(options.device)
return balena.models.application.get(options.application)
.then (resource) ->
resin.models.device.getManifestBySlug(resource.device_type)
balena.models.device.getManifestBySlug(resource.device_type)
.get('options')
.then (formOptions) ->
# Pass params as an override: if there is any param with exactly the same name as a

View File

@ -17,7 +17,7 @@ Opts must be an object with the following keys:
deployProject = (docker, logger, composeOpts, opts) ->
_ = require('lodash')
doodles = require('resin-doodles')
sdk = require('resin-sdk').fromSharedOptions()
sdk = require('balena-sdk').fromSharedOptions()
compose.loadProject(
logger
@ -81,7 +81,7 @@ deployProject = (docker, logger, composeOpts, opts) ->
logger
sdk.auth.getToken()
sdk.auth.whoami()
sdk.settings.get('resinUrl')
sdk.settings.get('balenaUrl')
{
appName: opts.app.app_name
imageName: images[0].name
@ -120,7 +120,7 @@ deployProject = (docker, logger, composeOpts, opts) ->
module.exports =
signature: 'deploy <appName> [image]'
description: 'Deploy a single image or a multicontainer project to a resin.io application'
description: 'Deploy a single image or a multicontainer project to a balena application'
help: '''
Use this command to deploy an image or a complete multicontainer project
to an application, optionally building it first.
@ -135,16 +135,16 @@ module.exports =
generate one.
To deploy to an app on which you're a collaborator, use
`resin deploy <appOwnerUsername>/<appName>`.
`balena deploy <appOwnerUsername>/<appName>`.
Note: If building with this command, all options supported by `resin build`
Note: If building with this command, all options supported by `balena build`
are also supported with this command.
Examples:
$ resin deploy myApp
$ resin deploy myApp --build --source myBuildDir/
$ resin deploy myApp myApp/myImage
$ balena deploy myApp
$ balena deploy myApp --build --source myBuildDir/
$ balena deploy myApp myApp/myImage
'''
permission: 'user'
primary: true
@ -181,7 +181,7 @@ module.exports =
Promise.try ->
{ appName, image } = params
# look into "resin build" options if appName isn't given
# look into "balena build" options if appName isn't given
appName = options.application if not appName?
delete options.application

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -32,27 +32,27 @@ exports.list =
Examples:
$ resin devices
$ resin devices --application MyApp
$ resin devices --app MyApp
$ resin devices -a MyApp
$ balena devices
$ balena devices --application MyApp
$ balena devices --app MyApp
$ balena devices -a MyApp
'''
options: [ commandOptions.optionalApplication ]
permission: 'user'
primary: true
action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
visuals = require('resin-cli-visuals')
Promise.try ->
if options.application?
return resin.models.device.getAllByApplication(options.application, expandForAppName)
return resin.models.device.getAll(expandForAppName)
return balena.models.device.getAllByApplication(options.application, expandForAppName)
return balena.models.device.getAll(expandForAppName)
.tap (devices) ->
devices = _.map devices, (device) ->
device.dashboard_url = resin.models.device.getDashboardUrl(device.uuid)
device.dashboard_url = balena.models.device.getDashboardUrl(device.uuid)
device.application_name = device.belongs_to__application[0].app_name
device.uuid = device.uuid.slice(0, 7)
return device
@ -79,20 +79,20 @@ exports.info =
Examples:
$ resin device 7cf02a6
$ balena device 7cf02a6
'''
permission: 'user'
primary: true
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
visuals = require('resin-cli-visuals')
resin.models.device.get(params.uuid, expandForAppName)
balena.models.device.get(params.uuid, expandForAppName)
.then (device) ->
resin.models.device.getStatus(device).then (status) ->
balena.models.device.getStatus(device).then (status) ->
device.status = status
device.dashboard_url = resin.models.device.getDashboardUrl(device.uuid)
device.dashboard_url = balena.models.device.getDashboardUrl(device.uuid)
device.application_name = device.belongs_to__application[0].app_name
device.commit = device.is_on__commit
@ -123,13 +123,13 @@ exports.supported =
Examples:
$ resin devices supported
$ balena devices supported
'''
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
visuals = require('resin-cli-visuals')
resin.models.config.getDeviceTypes().then (deviceTypes) ->
balena.models.config.getDeviceTypes().then (deviceTypes) ->
console.log visuals.table.horizontal deviceTypes, [
'slug'
'name'
@ -144,8 +144,8 @@ exports.register =
Examples:
$ resin device register MyApp
$ resin device register MyApp --uuid <uuid>
$ balena device register MyApp
$ balena device register MyApp --uuid <uuid>
'''
permission: 'user'
options: [
@ -158,14 +158,14 @@ exports.register =
]
action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
Promise.join(
resin.models.application.get(params.application)
options.uuid ? resin.models.device.generateUniqueKey()
balena.models.application.get(params.application)
options.uuid ? balena.models.device.generateUniqueKey()
(application, uuid) ->
console.info("Registering to #{application.app_name}: #{uuid}")
return resin.models.device.register(application.id, uuid)
return balena.models.device.register(application.id, uuid)
)
.get('uuid')
.nodeify(done)
@ -174,25 +174,25 @@ exports.remove =
signature: 'device rm <uuid>'
description: 'remove a device'
help: '''
Use this command to remove a device from resin.io.
Use this command to remove a device from balena.
Notice this command asks for confirmation interactively.
You can avoid this by passing the `--yes` boolean option.
Examples:
$ resin device rm 7cf02a6
$ resin device rm 7cf02a6 --yes
$ balena device rm 7cf02a6
$ balena device rm 7cf02a6 --yes
'''
options: [ commandOptions.yes ]
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the device?').then ->
resin.models.device.remove(params.uuid)
balena.models.device.remove(params.uuid)
.nodeify(done)
exports.identify =
@ -205,13 +205,13 @@ exports.identify =
Examples:
$ resin device identify 23c73a1
$ balena device identify 23c73a1
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk').fromSharedOptions()
resin.models.device.identify(params.uuid).nodeify(done)
balena = require('balena-sdk').fromSharedOptions()
balena.models.device.identify(params.uuid).nodeify(done)
exports.reboot =
signature: 'device reboot <uuid>'
@ -221,14 +221,14 @@ exports.reboot =
Examples:
$ resin device reboot 23c73a1
$ balena device reboot 23c73a1
'''
options: [ commandOptions.forceUpdateLock ]
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk').fromSharedOptions()
resin.models.device.reboot(params.uuid, options).nodeify(done)
balena = require('balena-sdk').fromSharedOptions()
balena.models.device.reboot(params.uuid, options).nodeify(done)
exports.shutdown =
signature: 'device shutdown <uuid>'
@ -238,14 +238,14 @@ exports.shutdown =
Examples:
$ resin device shutdown 23c73a1
$ balena device shutdown 23c73a1
'''
options: [ commandOptions.forceUpdateLock ]
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk').fromSharedOptions()
resin.models.device.shutdown(params.uuid, options).nodeify(done)
balena = require('balena-sdk').fromSharedOptions()
balena.models.device.shutdown(params.uuid, options).nodeify(done)
exports.enableDeviceUrl =
signature: 'device public-url enable <uuid>'
@ -255,13 +255,13 @@ exports.enableDeviceUrl =
Examples:
$ resin device public-url enable 23c73a1
$ balena device public-url enable 23c73a1
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk').fromSharedOptions()
resin.models.device.enableDeviceUrl(params.uuid).nodeify(done)
balena = require('balena-sdk').fromSharedOptions()
balena.models.device.enableDeviceUrl(params.uuid).nodeify(done)
exports.disableDeviceUrl =
signature: 'device public-url disable <uuid>'
@ -271,13 +271,13 @@ exports.disableDeviceUrl =
Examples:
$ resin device public-url disable 23c73a1
$ balena device public-url disable 23c73a1
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk').fromSharedOptions()
resin.models.device.disableDeviceUrl(params.uuid).nodeify(done)
balena = require('balena-sdk').fromSharedOptions()
balena.models.device.disableDeviceUrl(params.uuid).nodeify(done)
exports.getDeviceUrl =
signature: 'device public-url <uuid>'
@ -287,13 +287,13 @@ exports.getDeviceUrl =
Examples:
$ resin device public-url 23c73a1
$ balena device public-url 23c73a1
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk').fromSharedOptions()
resin.models.device.getDeviceUrl(params.uuid).then (url) ->
balena = require('balena-sdk').fromSharedOptions()
balena.models.device.getDeviceUrl(params.uuid).then (url) ->
console.log(url)
.nodeify(done)
@ -305,19 +305,19 @@ exports.hasDeviceUrl =
Examples:
$ resin device public-url status 23c73a1
$ balena device public-url status 23c73a1
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk').fromSharedOptions()
resin.models.device.hasDeviceUrl(params.uuid).then (hasDeviceUrl) ->
balena = require('balena-sdk').fromSharedOptions()
balena.models.device.hasDeviceUrl(params.uuid).then (hasDeviceUrl) ->
console.log(hasDeviceUrl)
.nodeify(done)
exports.rename =
signature: 'device rename <uuid> [newName]'
description: 'rename a resin device'
description: 'rename a balena device'
help: '''
Use this command to rename a device.
@ -325,14 +325,14 @@ exports.rename =
Examples:
$ resin device rename 7cf02a6
$ resin device rename 7cf02a6 MyPi
$ balena device rename 7cf02a6
$ balena device rename 7cf02a6 MyPi
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
Promise = require('bluebird')
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
form = require('resin-cli-form')
Promise.try ->
@ -342,7 +342,7 @@ exports.rename =
message: 'How do you want to name this device?'
type: 'input'
.then(_.partial(resin.models.device.rename, params.uuid))
.then(_.partial(balena.models.device.rename, params.uuid))
.nodeify(done)
exports.move =
@ -355,31 +355,31 @@ exports.move =
Examples:
$ resin device move 7cf02a6
$ resin device move 7cf02a6 --application MyNewApp
$ balena device move 7cf02a6
$ balena device move 7cf02a6 --application MyNewApp
'''
permission: 'user'
options: [ commandOptions.optionalApplication ]
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
patterns = require('../utils/patterns')
resin.models.device.get(params.uuid, expandForAppName).then (device) ->
balena.models.device.get(params.uuid, expandForAppName).then (device) ->
return options.application or patterns.selectApplication (application) ->
return _.every [
application.device_type is device.device_type
device.belongs_to__application[0].app_name isnt application.app_name
]
.tap (application) ->
return resin.models.device.move(params.uuid, application)
return balena.models.device.move(params.uuid, application)
.then (application) ->
console.info("#{params.uuid} was moved to #{application}")
.nodeify(done)
exports.init =
signature: 'device init'
description: 'initialise a device with resinOS'
description: 'initialise a device with balenaOS'
help: '''
Use this command to download the OS image of a certain application and write it to an SD Card.
@ -388,8 +388,8 @@ exports.init =
Examples:
$ resin device init
$ resin device init --application MyApp
$ balena device init
$ balena device init --application MyApp
'''
options: [
commandOptions.optionalApplication
@ -399,7 +399,7 @@ exports.init =
commandOptions.drive
{
signature: 'config'
description: 'path to the config JSON file, see `resin os build-config`'
description: 'path to the config JSON file, see `balena os build-config`'
parameter: 'config'
}
]
@ -411,14 +411,14 @@ exports.init =
tmpNameAsync = Promise.promisify(tmp.tmpName)
tmp.setGracefulCleanup()
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
patterns = require('../utils/patterns')
{ runCommand } = require('../utils/helpers')
Promise.try ->
return options.application if options.application?
return patterns.selectApplication()
.then(resin.models.application.get)
.then(balena.models.application.get)
.then (application) ->
download = ->
@ -430,7 +430,7 @@ exports.init =
Promise.using download(), (tempPath) ->
runCommand("device register #{application.app_name}")
.then(resin.models.device.get)
.then(balena.models.device.get)
.tap (device) ->
configureCommand = "os configure '#{tempPath}' --device #{device.uuid}"
if options.config
@ -448,7 +448,7 @@ exports.init =
# Make sure the device resource is removed if there is an
# error when configuring or initializing a device image
.catch (error) ->
resin.models.device.remove(device.uuid).finally ->
balena.models.device.remove(device.uuid).finally ->
throw error
.then (device) ->
console.log('Done')

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ exports.list =
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.
ones used by balena, use the verbose option.
At the moment the CLI doesn't fully support multi-container applications,
so the following commands will only show service variables,
@ -34,9 +34,9 @@ exports.list =
Example:
$ resin envs --application MyApp
$ resin envs --application MyApp --verbose
$ resin envs --device 7cf02a6
$ balena envs --application MyApp
$ balena envs --application MyApp --verbose
$ balena envs --device 7cf02a6
'''
options: [
commandOptions.optionalApplication
@ -54,16 +54,16 @@ exports.list =
normalizeUuidProp(options, 'device')
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk-preconfigured')
balena = require('resin-sdk-preconfigured')
visuals = require('resin-cli-visuals')
{ exitWithExpectedError } = require('../utils/patterns')
Promise.try ->
if options.application?
return resin.models.environmentVariables.getAllByApplication(options.application)
return balena.models.environmentVariables.getAllByApplication(options.application)
else if options.device?
return resin.models.environmentVariables.device.getAll(options.device)
return balena.models.environmentVariables.device.getAll(options.device)
else
exitWithExpectedError('You must specify an application or device')
@ -71,7 +71,7 @@ exports.list =
if _.isEmpty(environmentVariables)
exitWithExpectedError('No environment variables found')
if not options.verbose
isSystemVariable = resin.models.environmentVariables.isSystemVariable
isSystemVariable = balena.models.environmentVariables.isSystemVariable
environmentVariables = _.reject(environmentVariables, isSystemVariable)
console.log visuals.table.horizontal environmentVariables, [
@ -87,7 +87,7 @@ exports.remove =
help: '''
Use this command to remove an environment variable from an application.
Don't remove resin specific variables, as things might not work as expected.
Don't remove balena 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.
@ -96,9 +96,9 @@ exports.remove =
Examples:
$ resin env rm 215
$ resin env rm 215 --yes
$ resin env rm 215 --device
$ balena env rm 215
$ balena env rm 215 --yes
$ balena env rm 215 --device
'''
options: [
commandOptions.yes
@ -106,14 +106,14 @@ exports.remove =
]
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk-preconfigured')
balena = require('resin-sdk-preconfigured')
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the environment variable?').then ->
if options.device
resin.models.environmentVariables.device.remove(params.id)
balena.models.environmentVariables.device.remove(params.id)
else
resin.models.environmentVariables.remove(params.id)
balena.models.environmentVariables.remove(params.id)
.nodeify(done)
exports.add =
@ -137,9 +137,9 @@ exports.add =
Examples:
$ resin env add EDITOR vim --application MyApp
$ resin env add TERM --application MyApp
$ resin env add EDITOR vim --device 7cf02a6
$ balena env add EDITOR vim --application MyApp
$ balena env add TERM --application MyApp
$ balena env add EDITOR vim --device 7cf02a6
'''
options: [
commandOptions.optionalApplication
@ -149,7 +149,7 @@ exports.add =
action: (params, options, done) ->
normalizeUuidProp(options, 'device')
Promise = require('bluebird')
resin = require('resin-sdk-preconfigured')
balena = require('resin-sdk-preconfigured')
{ exitWithExpectedError } = require('../utils/patterns')
@ -163,9 +163,9 @@ exports.add =
console.info("Warning: using #{params.key}=#{params.value} from host environment")
if options.application?
resin.models.environmentVariables.create(options.application, params.key, params.value)
balena.models.environmentVariables.create(options.application, params.key, params.value)
else if options.device?
resin.models.environmentVariables.device.create(options.device, params.key, params.value)
balena.models.environmentVariables.device.create(options.device, params.key, params.value)
else
exitWithExpectedError('You must specify an application or device')
.nodeify(done)
@ -180,18 +180,18 @@ exports.rename =
Examples:
$ resin env rename 376 emacs
$ resin env rename 376 emacs --device
$ balena env rename 376 emacs
$ balena env rename 376 emacs --device
'''
permission: 'user'
options: [ commandOptions.booleanDevice ]
action: (params, options, done) ->
Promise = require('bluebird')
resin = require('resin-sdk-preconfigured')
balena = require('resin-sdk-preconfigured')
Promise.try ->
if options.device
resin.models.environmentVariables.device.update(params.id, params.value)
balena.models.environmentVariables.device.update(params.id, params.value)
else
resin.models.environmentVariables.update(params.id, params.value)
balena.models.environmentVariables.update(params.id, params.value)
.nodeify(done)

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ print = (data) ->
minWidth: 35
general = (params, options, done) ->
console.log('Usage: resin [COMMAND] [OPTIONS]\n')
console.log('Usage: balena [COMMAND] [OPTIONS]\n')
console.log(messages.reachingOut)
console.log('\nPrimary commands:\n')
@ -66,7 +66,7 @@ general = (params, options, done) ->
console.log('\nAdditional commands:\n')
print(parse(groupedCommands.secondary))
else
console.log('\nRun `resin help --verbose` to list additional commands')
console.log('\nRun `balena help --verbose` to list additional commands')
if not _.isEmpty(capitano.state.globalOptions)
console.log('\nGlobal Options:\n')
@ -102,8 +102,8 @@ exports.help =
Examples:
$ resin help apps
$ resin help os download
$ balena help apps
$ balena help os download
'''
primary: true
options: [

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ export const version: CommandDefinition = {
signature: 'version',
description: 'output the version number',
help: `\
Display the Resin CLI version.\
Display the balena CLI version.\
`,
async action(_params, _options, done) {
const packageJSON = await import('../../package.json');

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -21,7 +21,7 @@ exports.osInit =
signature: 'internal osinit <image> <type> <config>'
description: 'do actual init of the device with the preconfigured os image'
help: '''
Don't use this command directly! Use `resin os initialize <image>` instead.
Don't use this command directly! Use `balena os initialize <image>` instead.
'''
hidden: true
root: true
@ -38,7 +38,7 @@ exports.osInit =
exports.scanDevices =
signature: 'internal scandevices'
description: 'scan for local resin-enabled devices and show a picker to choose one'
description: 'scan for local balena-enabled devices and show a picker to choose one'
help: '''
Don't use this command directly!
'''
@ -46,10 +46,10 @@ exports.scanDevices =
root: true
action: (params, options, done) ->
Promise = require('bluebird')
{ forms } = require('resin-sync')
{ forms } = require('balena-sync')
return Promise.try ->
forms.selectLocalResinOsDevice()
forms.selectLocalBalenaOsDevice()
.then (hostnameOrIp) ->
console.error("==> Selected device: #{hostnameOrIp}")
.nodeify(done)
@ -61,9 +61,9 @@ exports.sudo =
Don't use this command directly!
<command> must be passed as a single argument. That means, you need to make sure
you enclose <command> in quotes (eg. resin internal sudo 'ls -alF') if for
you enclose <command> in quotes (eg. balena internal sudo 'ls -alF') if for
whatever reason you invoke the command directly or, typically, pass <command>
as a single argument to spawn (eg. `spawn('resin', [ 'internal', 'sudo', 'ls -alF' ])`).
as a single argument to spawn (eg. `spawn('balena', [ 'internal', 'sudo', 'ls -alF' ])`).
Furthermore, this command will naively split <command> on whitespace and directly
forward the parts as arguments to `sudo`, so be careful.

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -28,15 +28,15 @@ interface Options {
export const join: CommandDefinition<Args, Options> = {
signature: 'join [deviceIp]',
description:
'Promote a local device running unmanaged resinOS to join a resin.io application',
'Promote a local device running unmanaged balenaOS to join a balena application',
help: stripIndent`
Examples:
$ resin join
$ resin join resin.local
$ resin join resin.local --application MyApp
$ resin join 192.168.1.25
$ resin join 192.168.1.25 --application MyApp
$ balena join
$ balena join balena.local
$ balena join balena.local --application MyApp
$ balena join 192.168.1.25
$ balena join 192.168.1.25 --application MyApp
`,
options: [
{
@ -50,10 +50,10 @@ export const join: CommandDefinition<Args, Options> = {
primary: true,
async action(params, options, done) {
const resin = await import('resin-sdk');
const balena = await import('balena-sdk');
const Logger = await import('../utils/logger');
const promote = await import('../utils/promote');
const sdk = resin.fromSharedOptions();
const sdk = balena.fromSharedOptions();
const logger = new Logger();
return Bluebird.try(() => {
return promote.join(logger, sdk, params.deviceIp, options.application);

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -24,14 +24,14 @@ exports.list =
Examples:
$ resin keys
$ balena keys
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
visuals = require('resin-cli-visuals')
resin.models.key.getAll().then (keys) ->
balena.models.key.getAll().then (keys) ->
console.log visuals.table.horizontal keys, [
'id'
'title'
@ -46,14 +46,14 @@ exports.info =
Examples:
$ resin key 17
$ balena key 17
'''
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
visuals = require('resin-cli-visuals')
resin.models.key.get(params.id).then (key) ->
balena.models.key.get(params.id).then (key) ->
console.log visuals.table.vertical key, [
'id'
'title'
@ -61,7 +61,7 @@ exports.info =
# Since the public key string is long, it might
# wrap to lines below, causing the table layout to break.
# See https://github.com/resin-io/resin-cli/issues/151
# See https://github.com/balena-io/balena-cli/issues/151
console.log('\n' + key.public_key)
.nodeify(done)
@ -69,29 +69,29 @@ exports.remove =
signature: 'key rm <id>'
description: 'remove a ssh key'
help: '''
Use this command to remove a SSH key from resin.io.
Use this command to remove a SSH key from balena.
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
$ balena key rm 17
$ balena key rm 17 --yes
'''
options: [ commandOptions.yes ]
permission: 'user'
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
patterns = require('../utils/patterns')
patterns.confirm(options.yes, 'Are you sure you want to delete the key?').then ->
resin.models.key.remove(params.id)
balena.models.key.remove(params.id)
.nodeify(done)
exports.add =
signature: 'key add <name> [path]'
description: 'add a SSH key to resin.io'
description: 'add a SSH key to balena'
help: '''
Use this command to associate a new SSH key with your account.
@ -100,8 +100,8 @@ exports.add =
Examples:
$ resin key add Main ~/.ssh/id_rsa.pub
$ cat ~/.ssh/id_rsa.pub | resin key add Main
$ balena key add Main ~/.ssh/id_rsa.pub
$ cat ~/.ssh/id_rsa.pub | balena key add Main
'''
permission: 'user'
action: (params, options, done) ->
@ -109,7 +109,7 @@ exports.add =
Promise = require('bluebird')
readFileAsync = Promise.promisify(require('fs').readFile)
capitano = require('capitano')
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
Promise.try ->
return readFileAsync(params.path, encoding: 'utf8') if params.path?
@ -119,5 +119,5 @@ exports.add =
capitano.utils.getStdin (data) ->
return callback(null, data)
.then(_.partial(resin.models.key.create, params.name))
.then(_.partial(balena.models.key.create, params.name))
.nodeify(done)

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -23,13 +23,13 @@ interface Args {
export const leave: CommandDefinition<Args, {}> = {
signature: 'leave [deviceIp]',
description: 'Detach a local device from its resin.io application',
description: 'Detach a local device from its balena application',
help: stripIndent`
Examples:
$ resin leave
$ resin leave resin.local
$ resin leave 192.168.1.25
$ balena leave
$ balena leave balena.local
$ balena leave 192.168.1.25
`,
options: [],
@ -37,10 +37,10 @@ export const leave: CommandDefinition<Args, {}> = {
primary: true,
async action(params, _options, done) {
const resin = await import('resin-sdk');
const balena = await import('balena-sdk');
const Logger = await import('../utils/logger');
const promote = await import('../utils/promote');
const sdk = resin.fromSharedOptions();
const sdk = balena.fromSharedOptions();
const logger = new Logger();
return Bluebird.try(() => {
return promote.leave(logger, sdk, params.deviceIp);

View File

@ -11,7 +11,7 @@ exports.dockerTimeout = dockerTimeout = 2000
exports.filterOutSupervisorContainer = filterOutSupervisorContainer = (container) ->
for name in container.Names
return false if name.includes('resin_supervisor')
return false if (name.includes('resin_supervisor') or name.includes('balena_supervisor'))
return true
exports.selectContainerFromDevice = Promise.method (deviceIp, filterSupervisor = false) ->

View File

@ -1,5 +1,5 @@
###
Copyright 2017 Resin.io
Copyright 2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -153,7 +153,7 @@ prepareConnectionFile = (target) ->
if _.includes(files, 'resin-wifi')
return null
# Fresh image, new mode, accoding to https://github.com/resin-os/meta-resin/pull/770/files
# Fresh image, new mode, accoding to https://github.com/balena-os/meta-balena/pull/770/files
if _.includes(files, 'resin-sample.ignore')
return imagefs.copy
image: target
@ -193,14 +193,14 @@ removeHostname = (schema) ->
module.exports =
signature: 'local configure <target>'
description: '(Re)configure a resinOS drive or image'
description: '(Re)configure a balenaOS drive or image'
help: '''
Use this command to configure or reconfigure a resinOS drive or image.
Use this command to configure or reconfigure a balenaOS drive or image.
Examples:
$ resin local configure /dev/sdc
$ resin local configure path/to/image.img
$ balena local configure /dev/sdc
$ balena local configure path/to/image.img
'''
root: true
action: (params, options, done) ->

View File

@ -1,5 +1,5 @@
###
Copyright 2017 Resin.io
Copyright 2017 Balena
Licensed under the Apache License, Version 2.0 (the 'License');
you may not use this file except in compliance with the License.
@ -18,13 +18,13 @@ module.exports =
signature: 'local flash <image>'
description: 'Flash an image to a drive'
help: '''
Use this command to flash a resinOS image to a drive.
Use this command to flash a balenaOS image to a drive.
Examples:
$ resin local flash path/to/resinos.img
$ resin local flash path/to/resinos.img --drive /dev/disk2
$ resin local flash path/to/resinos.img --drive /dev/disk2 --yes
$ balena local flash path/to/balenaos.img
$ balena local flash path/to/balenaos.img --drive /dev/disk2
$ balena local flash path/to/balenaos.img --drive /dev/disk2 --yes
'''
options: [
signature: 'yes'

View File

@ -1,5 +1,5 @@
###
Copyright 2017 Resin.io
Copyright 2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
###
Copyright 2017 Resin.io
Copyright 2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -22,16 +22,16 @@ limitations under the License.
#
module.exports =
signature: 'local logs [deviceIp]'
description: 'Get or attach to logs of a running container on a resinOS device'
description: 'Get or attach to logs of a running container on a balenaOS device'
help: '''
Examples:
$ resin local logs
$ resin local logs -f
$ resin local logs 192.168.1.10
$ resin local logs 192.168.1.10 -f
$ resin local logs 192.168.1.10 -f --app-name myapp
$ balena local logs
$ balena local logs -f
$ balena local logs 192.168.1.10
$ balena local logs 192.168.1.10 -f
$ balena local logs 192.168.1.10 -f --app-name myapp
'''
options: [
signature: 'follow'
@ -47,12 +47,12 @@ module.exports =
root: true
action: (params, options, done) ->
Promise = require('bluebird')
{ forms } = require('resin-sync')
{ forms } = require('balena-sync')
{ selectContainerFromDevice, pipeContainerStream } = require('./common')
Promise.try ->
if not params.deviceIp?
return forms.selectLocalResinOsDevice()
return forms.selectLocalBalenaOsDevice()
return params.deviceIp
.then (@deviceIp) =>
if not options['app-name']?

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,36 +14,36 @@ See the License for the specific language governing permissions and
limitations under the License.
###
# Loads '.resin-sync.yml' configuration from 'source' directory.
# Loads '.balena-sync.yml' configuration from 'source' directory.
# Returns the configuration object on success
#
_ = require('lodash')
resinPush = require('resin-sync').capitano('resin-toolbox')
balenaPush = require('balena-sync').capitano('balena-toolbox')
# TODO: This is a temporary workaround to reuse the existing `rdt push`
# capitano frontend in `resin local push`.
# capitano frontend in `balena local push`.
resinPushHelp = '''
Warning: 'resin local push' requires an openssh-compatible client and 'rsync' to
balenaPushHelp = '''
Warning: 'balena local push' requires an openssh-compatible client and 'rsync' to
be correctly installed in your shell environment. For more information (including
Windows support) please check the README here: https://github.com/resin-io/resin-cli
Windows support) please check the README here: https://github.com/balena-io/balena-cli
Use this command to push your local changes to a container on a LAN-accessible resinOS device on the fly.
Use this command to push your local changes to a container on a LAN-accessible balenaOS device on the fly.
If `Dockerfile` or any file in the 'build-triggers' list is changed,
a new container will be built and run on your device.
If not, changes will simply be synced with `rsync` into the application container.
After every 'resin local push' the updated settings will be saved in
'<source>/.resin-sync.yml' and will be used in later invocations. You can
also change any option by editing '.resin-sync.yml' directly.
After every 'balena local push' the updated settings will be saved in
'<source>/.balena-sync.yml' and will be used in later invocations. You can
also change any option by editing '.balena-sync.yml' directly.
Here is an example '.resin-sync.yml' :
Here is an example '.balena-sync.yml' :
$ cat $PWD/.resin-sync.yml
local_resinos:
$ cat $PWD/.balena-sync.yml
local_balenaos:
app-name: local-app
build-triggers:
- Dockerfile: file-hash-abcdefabcdefabcdefabcdefabcdefabcdef
@ -52,7 +52,7 @@ resinPushHelp = '''
- MY_VARIABLE=123
Command line options have precedence over the ones saved in '.resin-sync.yml'.
Command line options have precedence over the ones saved in '.balena-sync.yml'.
If '.gitignore' is found in the source directory then all explicitly listed files will be
excluded when using rsync to update the container. You can choose to change this default behavior with the
@ -60,19 +60,19 @@ resinPushHelp = '''
Examples:
$ resin local push
$ resin local push --app-name test-server --build-triggers package.json,requirements.txt
$ resin local push --force-build
$ resin local push --force-build --skip-logs
$ resin local push --ignore lib/
$ resin local push --verbose false
$ resin local push 192.168.2.10 --source . --destination /usr/src/app
$ resin local push 192.168.2.10 -s /home/user/myResinProject -d /usr/src/app --before 'echo Hello' --after 'echo Done'
$ balena local push
$ balena local push --app-name test-server --build-triggers package.json,requirements.txt
$ balena local push --force-build
$ balena local push --force-build --skip-logs
$ balena local push --ignore lib/
$ balena local push --verbose false
$ balena local push 192.168.2.10 --source . --destination /usr/src/app
$ balena local push 192.168.2.10 -s /home/user/balenaProject -d /usr/src/app --before 'echo Hello' --after 'echo Done'
'''
module.exports = _.assign resinPush,
module.exports = _.assign balenaPush,
signature: 'local push [deviceIp]'
help: resinPushHelp
help: balenaPushHelp
primary: true
root: true

View File

@ -1,5 +1,5 @@
###
Copyright 2017 Resin.io
Copyright 2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -34,14 +34,14 @@ dockerVersionProperties = [
module.exports =
signature: 'local scan'
description: 'Scan for resinOS devices in your local network'
description: 'Scan for balenaOS devices in your local network'
help: '''
Examples:
$ resin local scan
$ resin local scan --timeout 120
$ resin local scan --verbose
$ balena local scan
$ balena local scan --timeout 120
$ balena local scan --verbose
'''
options: [
signature: 'verbose'
@ -60,7 +60,7 @@ module.exports =
Promise = require('bluebird')
_ = require('lodash')
prettyjson = require('prettyjson')
{ discover } = require('resin-sync')
{ discover } = require('balena-sync')
{ SpinnerPromise } = require('resin-cli-visuals')
{ dockerPort, dockerTimeout } = require('./common')
dockerUtils = require('../../utils/docker')
@ -71,8 +71,8 @@ module.exports =
Promise.try ->
new SpinnerPromise
promise: discover.discoverLocalResinOsDevices(options.timeout)
startMessage: 'Scanning for local resinOS devices..'
promise: discover.discoverLocalBalenaOsDevices(options.timeout)
startMessage: 'Scanning for local balenaOS devices..'
stopMessage: 'Reporting scan results'
.filter ({ address }) ->
Promise.try ->
@ -82,7 +82,7 @@ module.exports =
.catchReturn(false)
.tap (devices) ->
if _.isEmpty(devices)
exitWithExpectedError('Could not find any resinOS devices in the local network')
exitWithExpectedError('Could not find any balenaOS devices in the local network')
.map ({ host, address }) ->
docker = dockerUtils.createClient(host: address, port: dockerPort, timeout: dockerTimeout)
Promise.props

View File

@ -1,5 +1,5 @@
###
Copyright 2017 Resin.io
Copyright 2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -22,26 +22,26 @@ localHostOSAccessOption.description = 'get a shell into the host OS'
module.exports =
signature: 'local ssh [deviceIp]'
description: 'Get a shell into a resinOS device'
description: 'Get a shell into a balenaOS device'
help: '''
Warning: 'resin local ssh' requires an openssh-compatible client to be correctly
Warning: 'balena local ssh' requires an openssh-compatible client to be correctly
installed in your shell environment. For more information (including Windows
support) please check the README here: https://github.com/resin-io/resin-cli
support) please check the README here: https://github.com/balena-io/balena-cli
Use this command to get a shell into the running application container of
your device.
The '--host' option will get you a shell into the Host OS of the resinOS device.
The '--host' option will get you a shell into the Host OS of the balenaOS device.
No option will return a list of containers to enter or you can explicitly select
one by passing its name to the --container option
Examples:
$ resin local ssh
$ resin local ssh --host
$ resin local ssh --container chaotic_water
$ resin local ssh --container chaotic_water --port 22222
$ resin local ssh --verbose
$ balena local ssh
$ balena local ssh --host
$ balena local ssh --container chaotic_water
$ balena local ssh --container chaotic_water --port 22222
$ balena local ssh --verbose
'''
options: [
signature: 'verbose'
@ -66,7 +66,7 @@ module.exports =
child_process = require('child_process')
Promise = require 'bluebird'
_ = require('lodash')
{ forms } = require('resin-sync')
{ forms } = require('balena-sync')
{ selectContainerFromDevice, getSubShellCommand } = require('./common')
{ exitWithExpectedError } = require('../../utils/patterns')
@ -81,7 +81,7 @@ module.exports =
Promise.try ->
if not params.deviceIp?
return forms.selectLocalResinOsDevice()
return forms.selectLocalBalenaOsDevice()
return params.deviceIp
.then (deviceIp) ->
_.assign(options, { deviceIp })

View File

@ -1,5 +1,5 @@
###
Copyright 2017 Resin.io
Copyright 2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -22,16 +22,16 @@ limitations under the License.
#
module.exports =
signature: 'local stop [deviceIp]'
description: 'Stop a running container on a resinOS device'
description: 'Stop a running container on a balenaOS device'
help: '''
Examples:
$ resin local stop
$ resin local stop --app-name myapp
$ resin local stop --all
$ resin local stop 192.168.1.10
$ resin local stop 192.168.1.10 --app-name myapp
$ balena local stop
$ balena local stop --app-name myapp
$ balena local stop --all
$ balena local stop 192.168.1.10
$ balena local stop 192.168.1.10 --app-name myapp
'''
options: [
signature: 'all'
@ -47,15 +47,15 @@ module.exports =
action: (params, options, done) ->
Promise = require('bluebird')
chalk = require('chalk')
{ forms, config, ResinLocalDockerUtils } = require('resin-sync')
{ forms, config, BalenaLocalDockerUtils } = require('balena-sync')
{ selectContainerFromDevice, filterOutSupervisorContainer } = require('./common')
Promise.try ->
if not params.deviceIp?
return forms.selectLocalResinOsDevice()
return forms.selectLocalBalenaOsDevice()
return params.deviceIp
.then (@deviceIp) =>
@docker = new ResinLocalDockerUtils(@deviceIp)
@docker = new BalenaLocalDockerUtils(@deviceIp)
if options.all
# Only list running containers
@ -67,7 +67,7 @@ module.exports =
@docker.stopContainer(Id)
ymlConfig = config.load()
@appName = options['app-name'] ? ymlConfig['local_resinos']?['app-name']
@appName = options['app-name'] ? ymlConfig['local_balenaos']?['app-name']
@docker.checkForRunningContainer(@appName)
.then (isRunning) =>
if not isRunning

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -28,8 +28,8 @@ module.exports =
Examples:
$ resin logs 23c73a1
$ resin logs 23c73a1
$ balena logs 23c73a1
$ balena logs 23c73a1
'''
options: [
{
@ -43,7 +43,7 @@ module.exports =
primary: true
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
moment = require('moment')
printLine = (line) ->
@ -51,11 +51,11 @@ module.exports =
console.log("#{timestamp} #{line.message}")
if options.tail
resin.logs.subscribe(params.uuid, { count: 100 }).then (logs) ->
balena.logs.subscribe(params.uuid, { count: 100 }).then (logs) ->
logs.on('line', printLine)
logs.on('error', done)
.catch(done)
else
resin.logs.history(params.uuid)
balena.logs.history(params.uuid)
.each(printLine)
.catch(done)

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -24,12 +24,12 @@ exports.set =
If note command isn't passed, the tool attempts to read from `stdin`.
To view the notes, use $ resin device <uuid>.
To view the notes, use $ balena device <uuid>.
Examples:
$ resin note "My useful note" --device 7cf02a6
$ cat note.txt | resin note --device 7cf02a6
$ balena note "My useful note" --device 7cf02a6
$ cat note.txt | balena note --device 7cf02a6
'''
options: [
signature: 'device'
@ -43,7 +43,7 @@ exports.set =
normalizeUuidProp(options, 'device')
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
{ exitWithExpectedError } = require('../utils/patterns')
@ -51,5 +51,5 @@ exports.set =
if _.isEmpty(params.note)
exitWithExpectedError('Missing note content')
resin.models.device.note(options.device, params.note)
balena.models.device.note(options.device, params.note)
.nodeify(done)

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -31,9 +31,9 @@ resolveVersion = (deviceType, version) ->
return Promise.resolve(version)
form = require('resin-cli-form')
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
resin.models.os.getSupportedVersions(deviceType)
balena.models.os.getSupportedVersions(deviceType)
.then ({ versions, recommended }) ->
choices = versions.map (v) ->
value: v
@ -47,19 +47,19 @@ resolveVersion = (deviceType, version) ->
exports.versions =
signature: 'os versions <type>'
description: 'show the available resinOS versions for the given device type'
description: 'show the available balenaOS versions for the given device type'
help: '''
Use this command to show the available resinOS versions for a certain device type.
Check available types with `resin devices supported`
Use this command to show the available balenaOS versions for a certain device type.
Check available types with `balena devices supported`
Example:
$ resin os versions raspberrypi3
$ balena os versions raspberrypi3
'''
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
resin.models.os.getSupportedVersions(params.type)
balena.models.os.getSupportedVersions(params.type)
.then ({ versions, recommended }) ->
versions.forEach (v) ->
console.log(formatVersion(v, v is recommended))
@ -69,7 +69,7 @@ exports.download =
description: 'download an unconfigured os image'
help: '''
Use this command to download an unconfigured os image for a certain device type.
Check available types with `resin devices supported`
Check available types with `balena devices supported`
If version is not specified the newest stable (non-pre-release) version of OS
is downloaded if available, or the newest version otherwise (if all existing
@ -80,12 +80,12 @@ exports.download =
Examples:
$ resin os download raspberrypi3 -o ../foo/bar/raspberry-pi.img
$ resin os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version 1.24.1
$ resin os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version ^1.20.0
$ resin os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version latest
$ resin os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version default
$ resin os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version menu
$ balena os download raspberrypi3 -o ../foo/bar/raspberry-pi.img
$ balena os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version 1.24.1
$ balena os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version ^1.20.0
$ balena os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version latest
$ balena os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version default
$ balena os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version menu
'''
permission: 'user'
options: [
@ -103,7 +103,7 @@ exports.download =
unzip = require('unzip2')
fs = require('fs')
rindle = require('rindle')
manager = require('resin-image-manager')
manager = require('balena-image-manager')
visuals = require('resin-cli-visuals')
console.info("Getting device operating system for #{params.type}")
@ -168,12 +168,12 @@ exports.buildConfig =
signature: 'os build-config <image> <device-type>'
description: 'build the OS config and save it to the JSON file'
help: '''
Use this command to prebuild the OS config once and skip the interactive part of `resin os configure`.
Use this command to prebuild the OS config once and skip the interactive part of `balena os configure`.
Example:
$ resin os build-config ../path/rpi3.img raspberrypi3 --output rpi3-config.json
$ resin os configure ../path/rpi3.img 7cf02a6 --config "$(cat rpi3-config.json)"
$ balena os build-config ../path/rpi3.img raspberrypi3 --output rpi3-config.json
$ balena os configure ../path/rpi3.img 7cf02a6 --config "$(cat rpi3-config.json)"
'''
permission: 'user'
options: [
@ -205,7 +205,7 @@ exports.configure =
Calling this command with the exact version number of the targeted image is required.
Note that device api keys are only supported on ResinOS 2.0.3+.
Note that device api keys are only supported on balenaOS 2.0.3+.
This command still supports the *deprecated* format where the UUID and optionally device key
are passed directly on the command line, but the recommended way is to pass either an --app or
@ -213,9 +213,9 @@ exports.configure =
Examples:
$ resin os configure ../path/rpi.img --device 7cf02a6 --version 2.12.7
$ resin os configure ../path/rpi.img --device 7cf02a6 --version 2.12.7 --device-api-key <existingDeviceKey>
$ resin os configure ../path/rpi.img --app MyApp --version 2.12.7
$ balena os configure ../path/rpi.img --device 7cf02a6 --version 2.12.7
$ balena os configure ../path/rpi.img --device 7cf02a6 --version 2.12.7 --device-api-key <existingDeviceKey>
$ balena os configure ../path/rpi.img --app MyApp --version 2.12.7
'''
permission: 'user'
options: [
@ -226,7 +226,7 @@ exports.configure =
commandOptions.osVersion
{
signature: 'config'
description: 'path to the config JSON file, see `resin os build-config`'
description: 'path to the config JSON file, see `balena os build-config`'
parameter: 'config'
}
]
@ -235,7 +235,7 @@ exports.configure =
fs = require('fs')
Promise = require('bluebird')
readFileAsync = Promise.promisify(fs.readFile)
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
init = require('resin-device-init')
helpers = require('../utils/helpers')
patterns = require('../utils/patterns')
@ -253,7 +253,7 @@ exports.configure =
See the help page for examples:
$ resin help os configure
$ balena help os configure
'''
uuid = options.device
@ -263,7 +263,7 @@ exports.configure =
configurationResourceType = if uuid then 'device' else 'application'
resin.models[configurationResourceType].get(uuid || options.application)
balena.models[configurationResourceType].get(uuid || options.application)
.then (appOrDevice) ->
Promise.try ->
if options.config
@ -297,14 +297,14 @@ exports.initialize =
Examples:
$ resin os initialize ../path/rpi.img --type 'raspberry-pi'
$ balena os initialize ../path/rpi.img --type 'raspberry-pi'
"""
permission: 'user'
options: [
commandOptions.yes
{
signature: 'type'
description: 'device type (Check available types with `resin devices supported`)'
description: 'device type (Check available types with `balena devices supported`)'
parameter: 'type'
alias: 't'
required: 'You have to specify a device type'
@ -350,7 +350,7 @@ exports.initialize =
.then (answers) ->
return if not answers.drive?
# TODO: resin local makes use of ejectAsync, see below
# TODO: balena local makes use of ejectAsync, see below
# DO we need this / should we do that here?
# getDrive = (drive) ->

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -25,8 +25,8 @@ getDeviceTypes = ->
_ = require('lodash')
if allDeviceTypes != undefined
return Bluebird.resolve(allDeviceTypes)
resin = require('resin-sdk').fromSharedOptions()
resin.models.config.getDeviceTypes()
balena = require('balena-sdk').fromSharedOptions()
balena.models.config.getDeviceTypes()
.then (deviceTypes) ->
_.sortBy(deviceTypes, 'name')
.tap (dt) ->
@ -41,12 +41,12 @@ getDeviceTypesWithSameArch = (deviceTypeSlug) ->
_(deviceTypes).filter(arch: deviceType.arch).map('slug').value()
getApplicationsWithSuccessfulBuilds = (deviceType) ->
preload = require('resin-preload')
resin = require('resin-sdk').fromSharedOptions()
preload = require('balena-preload')
balena = require('balena-sdk').fromSharedOptions()
getDeviceTypesWithSameArch(deviceType)
.then (deviceTypes) ->
resin.pine.get
balena.pine.get
resource: 'my_application'
options:
$filter:
@ -100,7 +100,7 @@ selectApplicationCommit = (releases) ->
offerToDisableAutomaticUpdates = (application, commit) ->
Promise = require('bluebird')
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
form = require('resin-cli-form')
if commit == LATEST or not application.should_track_latest_release
@ -114,7 +114,7 @@ offerToDisableAutomaticUpdates = (application, commit) ->
Do you want to disable automatic updates for this application?
Warning: To re-enable this requires direct api calls,
see https://docs.resin.io/reference/api/resources/device/#set-device-to-release
see https://balena.io/docs/reference/api/resources/device/#set-device-to-release
'''
form.ask
message: message,
@ -122,7 +122,7 @@ offerToDisableAutomaticUpdates = (application, commit) ->
.then (update) ->
if not update
return
resin.pine.patch
balena.pine.patch
resource: 'application'
id: application.id
body:
@ -132,17 +132,17 @@ module.exports =
signature: 'preload <image>'
description: '(beta) preload an app on a disk image (or Edison zip archive)'
help: '''
Warning: "resin preload" requires Docker to be correctly installed in
Warning: "balena preload" requires Docker to be correctly installed in
your shell environment. For more information (including Windows support)
please check the README here: https://github.com/resin-io/resin-cli .
please check the README here: https://github.com/balena-io/balena-cli .
Use this command to preload an application to a local disk image (or
Edison zip archive) with a built release from Resin.io.
Edison zip archive) with a built release from balena.
Examples:
$ resin preload resin.img --app 1234 --commit e1f2592fc6ee949e68756d4f4a48e49bff8d72a0 --splash-image some-image.png
$ resin preload resin.img
$ balena preload balena.img --app 1234 --commit e1f2592fc6ee949e68756d4f4a48e49bff8d72a0 --splash-image image.png
$ balena preload balena.img
'''
permission: 'user'
primary: true
@ -183,8 +183,8 @@ module.exports =
action: (params, options, done) ->
_ = require('lodash')
Promise = require('bluebird')
resin = require('resin-sdk').fromSharedOptions()
preload = require('resin-preload')
balena = require('balena-sdk').fromSharedOptions()
preload = require('balena-preload')
visuals = require('resin-cli-visuals')
nodeCleanup = require('node-cleanup')
{ exitWithExpectedError } = require('../utils/patterns')
@ -229,7 +229,7 @@ module.exports =
.then (docker) ->
preloader = new preload.Preloader(
resin
balena
docker
options.appId
options.commit
@ -293,7 +293,7 @@ module.exports =
.then ->
# All options are ready: preload the image.
preloader.preload()
.catch(resin.errors.ResinError, exitWithExpectedError)
.catch(balena.errors.BalenaError, exitWithExpectedError)
.then(resolve)
.catch(reject)
.then(done)

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@ limitations under the License.
import { CommandDefinition } from 'capitano';
import { stripIndent } from 'common-tags';
import { ResinSDK } from 'resin-sdk';
import { BalenaSDK } from 'balena-sdk';
import { BuildError } from '../utils/device/errors';
@ -43,7 +43,7 @@ function getBuildTarget(appOrDevice: string): BuildTarget | null {
return null;
}
async function getAppOwner(sdk: ResinSDK, appName: string) {
async function getAppOwner(sdk: BalenaSDK, appName: string) {
const {
exitWithExpectedError,
selectFromList,
@ -110,13 +110,13 @@ export const push: CommandDefinition<
> = {
signature: 'push <applicationOrDevice>',
description:
'Start a remote build on the resin.io cloud build servers or a local mode device',
'Start a remote build on the balena cloud build servers or a local mode device',
help: stripIndent`
This command can be used to start a build on the remote
resin.io cloud builders, or a local mode resin device.
balena cloud builders, or a local mode balena device.
When building on the resin cloud the given source directory will be sent to the
resin.io builder, and the build will proceed. This can be used as a drop-in
When building on the balena cloud the given source directory will be sent to the
balena builder, and the build will proceed. This can be used as a drop-in
replacement for git push to deploy.
When building on a local mode device, the given source directory will be built on
@ -125,13 +125,13 @@ export const push: CommandDefinition<
Examples:
$ resin push myApp
$ resin push myApp --source <source directory>
$ resin push myApp -s <source directory>
$ balena push myApp
$ balena push myApp --source <source directory>
$ balena push myApp -s <source directory>
$ resin push 10.0.0.1
$ resin push 10.0.0.1 --source <source directory>
$ resin push 10.0.0.1 -s <source directory>
$ balena push 10.0.0.1
$ balena push 10.0.0.1 --source <source directory>
$ balena push 10.0.0.1 -s <source directory>
`,
permission: 'user',
options: [
@ -139,7 +139,7 @@ export const push: CommandDefinition<
signature: 'source',
alias: 's',
description:
'The source that should be sent to the resin builder to be built (defaults to the current directory)',
'The source that should be sent to the balena builder to be built (defaults to the current directory)',
parameter: 'source',
},
{
@ -156,7 +156,7 @@ export const push: CommandDefinition<
},
],
async action(params, options, done) {
const sdk = (await import('resin-sdk')).fromSharedOptions();
const sdk = (await import('balena-sdk')).fromSharedOptions();
const Bluebird = await import('bluebird');
const remote = await import('../utils/remote-build');
const deviceDeploy = await import('../utils/device/deploy');
@ -178,7 +178,7 @@ export const push: CommandDefinition<
const app = appOrDevice;
Bluebird.join(
sdk.auth.getToken(),
sdk.settings.get('resinUrl'),
sdk.settings.get('balenaUrl'),
getAppOwner(sdk, app),
(token, baseUrl, owner) => {
const opts = {

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -24,13 +24,13 @@ Use this command to display detected settings
Examples:
$ resin settings\
$ balena settings\
`,
async action(_params, _options, done) {
const resin = (await import('resin-sdk')).fromSharedOptions();
const balena = (await import('balena-sdk')).fromSharedOptions();
const prettyjson = await import('prettyjson');
return resin.settings
return balena.settings
.getAll()
.then(prettyjson.render)
.then(console.log)

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -21,20 +21,20 @@ module.exports =
signature: 'ssh [uuid]'
description: '(beta) get a shell into the running app container of a device'
help: '''
Warning: 'resin ssh' requires an openssh-compatible client to be correctly
Warning: 'balena ssh' requires an openssh-compatible client to be correctly
installed in your shell environment. For more information (including Windows
support) please check the README here: https://github.com/resin-io/resin-cli
support) please check the README here: https://github.com/balena-io/balena-cli
Use this command to get a shell into the running application container of
your device.
Examples:
$ resin ssh MyApp
$ resin ssh 7cf02a6
$ resin ssh 7cf02a6 --port 8080
$ resin ssh 7cf02a6 -v
$ resin ssh 7cf02a6 -s
$ balena ssh MyApp
$ balena ssh 7cf02a6
$ balena ssh 7cf02a6 --port 8080
$ balena ssh 7cf02a6 -v
$ balena ssh 7cf02a6 -s
'''
permission: 'user'
primary: true
@ -58,7 +58,7 @@ module.exports =
normalizeUuidProp(params)
child_process = require('child_process')
Promise = require('bluebird')
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
_ = require('lodash')
bash = require('bash')
hasbin = require('hasbin')
@ -78,8 +78,8 @@ module.exports =
if not hasTunnelBin
console.warn('''
Proxy is enabled but the `proxytunnel` binary cannot be found.
Please install it if you want to route the `resin ssh` requests through the proxy.
Alternatively you can pass `--noproxy` param to the `resin ssh` command to ignore the proxy config
Please install it if you want to route the `balena ssh` requests through the proxy.
Alternatively you can pass `--noproxy` param to the `balena ssh` command to ignore the proxy config
for the `ssh` requests.
Attemmpting the unproxied request for now.
@ -100,22 +100,22 @@ module.exports =
Promise.try ->
return false if not params.uuid
return resin.models.device.has(params.uuid)
return balena.models.device.has(params.uuid)
.then (uuidExists) ->
return params.uuid if uuidExists
return patterns.inferOrSelectDevice()
.then (uuid) ->
console.info("Connecting to: #{uuid}")
resin.models.device.get(uuid)
balena.models.device.get(uuid)
.then (device) ->
patterns.exitWithExpectedError('Device is not online') if not device.is_online
Promise.props
username: resin.auth.whoami()
username: balena.auth.whoami()
uuid: device.uuid
# get full uuid
containerId: if options.host then '' else resin.models.device.getApplicationInfo(device.uuid).get('containerId')
proxyUrl: resin.settings.get('proxyUrl')
containerId: if options.host then '' else balena.models.device.getApplicationInfo(device.uuid).get('containerId')
proxyUrl: balena.settings.get('proxyUrl')
hasTunnelBin: if useProxy then hasbin('proxytunnel') else null
.then ({ username, uuid, containerId, proxyUrl, hasTunnelBin }) ->

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import * as ResinSync from 'resin-sync';
export = ResinSync.capitano('resin-cli');
import * as BalenaSync from 'balena-sync';
export = BalenaSync.capitano('balena-cli');

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -17,7 +17,7 @@ limitations under the License.
_ = require('lodash')
exports.availableDrives =
# TODO: dedupe with https://github.com/resin-io-modules/resin-cli-visuals/blob/master/lib/widgets/drive/index.coffee
# TODO: dedupe with https://github.com/balena-io-modules/resin-cli-visuals/blob/master/lib/widgets/drive/index.coffee
signature: 'util available-drives'
description: 'list available drives'
help: """

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -16,29 +16,29 @@ limitations under the License.
exports.wizard =
signature: 'quickstart [name]'
description: 'getting started with resin.io'
description: 'getting started with balena'
help: '''
Use this command to run a friendly wizard to get started with resin.io.
Use this command to run a friendly wizard to get started with balena.
The wizard will guide you through:
- Create an application.
- Initialise an SDCard with the resin.io operating system.
- Associate an existing project directory with your resin.io application.
- Initialise an SDCard with the balena operating system.
- Associate an existing project directory with your balena application.
- Push your project to your devices.
Examples:
$ resin quickstart
$ resin quickstart MyApp
$ balena quickstart
$ balena quickstart MyApp
'''
primary: true
action: (params, options, done) ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
patterns = require('../utils/patterns')
{ runCommand } = require('../utils/helpers')
resin.auth.isLoggedIn().then (isLoggedIn) ->
balena.auth.isLoggedIn().then (isLoggedIn) ->
return if isLoggedIn
console.info('Looks like you\'re not logged in yet!')
console.info("Let's go through a quick wizard to get you started.\n")
@ -46,7 +46,7 @@ exports.wizard =
.then ->
return if params.name?
patterns.selectOrCreateApplication().tap (applicationName) ->
resin.models.application.has(applicationName).then (hasApplication) ->
balena.models.application.has(applicationName).then (hasApplication) ->
return applicationName if hasApplication
runCommand("app create #{applicationName}")
.then (applicationName) ->
@ -57,18 +57,18 @@ exports.wizard =
.then (uuid) ->
return runCommand("device #{uuid}")
.then ->
return resin.models.application.get(params.name)
return balena.models.application.get(params.name)
.then (application) ->
console.log """
Your device is ready to start pushing some code!
Check our official documentation for more information:
http://docs.resin.io/#/pages/introduction/introduction.md
http://balena.io/docs/#/pages/introduction/introduction.md
Clone an example or go to an existing application directory and run:
$ git remote add resin #{application.git_repository}
$ git push resin master
$ git remote add balena #{application.git_repository}
$ git push balena master
"""
.nodeify(done)

View File

@ -1,5 +1,5 @@
###
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -41,10 +41,10 @@ if not require('semver').satisfies(process.version, validNodeVersions)
# Doing this before requiring any other modules,
# including the 'resin-sdk', to prevent any module from reading the http proxy config
# including the 'balena-sdk', to prevent any module from reading the http proxy config
# before us
globalTunnel = require('global-tunnel-ng')
settings = require('resin-settings-client')
settings = require('balena-settings-client')
try
proxy = settings.get('proxy') or null
catch
@ -54,24 +54,24 @@ catch
# If that is not set as well the initialize will do nothing
globalTunnel.initialize(proxy)
# TODO: make this a feature of capitano https://github.com/resin-io/capitano/issues/48
# TODO: make this a feature of capitano https://github.com/balena-io/capitano/issues/48
global.PROXY_CONFIG = globalTunnel.proxyConfig
Promise = require('bluebird')
capitano = require('capitano')
capitanoExecuteAsync = Promise.promisify(capitano.execute)
# We don't yet use resin-sdk directly everywhere, but we set up shared
# We don't yet use balena-sdk directly everywhere, but we set up shared
# options correctly so we can do safely in submodules
ResinSdk = require('resin-sdk')
ResinSdk.setSharedOptions(
BalenaSdk = require('balena-sdk')
BalenaSdk.setSharedOptions(
apiUrl: settings.get('apiUrl')
imageMakerUrl: settings.get('imageMakerUrl')
dataDirectory: settings.get('dataDirectory')
retries: 2
)
resin = ResinSdk.fromSharedOptions()
balena = BalenaSdk.fromSharedOptions()
actions = require('./actions')
errors = require('./errors')
@ -86,14 +86,14 @@ update = require('./utils/update')
require('any-promise/register/bluebird')
capitano.permission 'user', (done) ->
resin.auth.isLoggedIn().then (isLoggedIn) ->
balena.auth.isLoggedIn().then (isLoggedIn) ->
if not isLoggedIn
exitWithExpectedError('''
You have to log in to continue
Run the following command to go through the login wizard:
$ resin login
$ balena login
''')
.nodeify(done)
@ -193,7 +193,7 @@ capitano.command(actions.preload)
# ---------- SSH Module ----------
capitano.command(actions.ssh)
# ---------- Local ResinOS Module ----------
# ---------- Local balenaOS Module ----------
capitano.command(actions.local.configure)
capitano.command(actions.local.flash)
capitano.command(actions.local.logs)

View File

@ -1,5 +1,5 @@
###
Copyright 2016 Resin.io
Copyright 2016 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -19,18 +19,18 @@ limitations under the License.
###
open = require('opn')
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
server = require('./server')
utils = require('./utils')
###*
# @summary Login to the Resin CLI using the web dashboard
# @summary Login to the balena CLI using the web dashboard
# @function
# @public
#
# @description
# This function opens the user's default browser and points it
# to the Resin.io dashboard where the session token exchange will
# to the balena dashboard where the session token exchange will
# take place.
#
# Once the the token is retrieved, it's automatically persisted.
@ -60,4 +60,4 @@ exports.login = ->
, 1000
return server.awaitForToken(options)
.tap(resin.auth.loginWithToken)
.tap(balena.auth.loginWithToken)

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Resin CLI - Error</title>
<title>Balena CLI - Error</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="./static/style.css" inline>
@ -12,10 +12,10 @@
<div class="center">
<img class="icon" src="./static/images/sad.png" inline>
<h1>Something went wrong</h1>
<p>You couldn't login to the Resin CLI for some reason</p>
<p>You couldn't login to the balena CLI for some reason</p>
<br>
<br>
<a href="https://forums.resin.io/" class="button danger">Get help in our forums</a>
<a href="https://forums.balena.io/" class="button danger">Get help in our forums</a>
</div>
</body>
</html>

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Resin CLI - Success</title>
<title>Balena CLI - Success</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="./static/style.css" inline>
@ -12,7 +12,7 @@
<div class="center">
<img class="icon" src="./static/images/happy.png" inline>
<h1>Success!</h1>
<p>You successfully logged in the Resin CLI</p>
<p>You successfully logged in the balena CLI</p>
<br>
<br>
<a href="<%= dashboardUrl %>" class="button normal">Go to the dashboard</a>

View File

@ -1,5 +1,5 @@
###
Copyright 2016 Resin.io
Copyright 2016 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -18,7 +18,7 @@ express = require('express')
path = require('path')
bodyParser = require('body-parser')
Promise = require('bluebird')
resin = require('resin-sdk-preconfigured')
balena = require('balena-sdk').fromSharedOptions()
utils = require('./utils')
createServer = ({ port, isDev } = {}) ->
@ -96,6 +96,6 @@ exports.awaitForToken = (options) ->
exports.getContext = getContext = (viewName) ->
if viewName is 'success'
return Promise.props
dashboardUrl: resin.settings.get('dashboardUrl')
dashboardUrl: balena.settings.get('dashboardUrl')
return Promise.resolve({})

View File

@ -1,5 +1,5 @@
###
Copyright 2016 Resin.io
Copyright 2016 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
###
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
_ = require('lodash')
url = require('url')
Promise = require('bluebird')
@ -38,7 +38,7 @@ exports.getDashboardLoginURL = (callbackUrl) ->
# characters to avoid angular getting confused.
callbackUrl = encodeURIComponent(callbackUrl).replace(/%/g, '%25')
resin.settings.get('dashboardUrl').then (dashboardUrl) ->
balena.settings.get('dashboardUrl').then (dashboardUrl) ->
return url.resolve(dashboardUrl, "/login/cli/#{callbackUrl}")
###*
@ -65,16 +65,16 @@ exports.loginIfTokenValid = (token) ->
if not token? or _.isEmpty(token.trim())
return Promise.resolve(false)
return resin.auth.getToken()
return balena.auth.getToken()
.catchReturn(undefined)
.then (currentToken) ->
resin.auth.loginWithToken(token)
balena.auth.loginWithToken(token)
.return(token)
.then(resin.auth.isLoggedIn)
.then(balena.auth.isLoggedIn)
.tap (isLoggedIn) ->
return if isLoggedIn
if currentToken?
return resin.auth.loginWithToken(currentToken)
return balena.auth.loginWithToken(currentToken)
else
return resin.auth.logout()
return balena.auth.logout()

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -98,10 +98,10 @@ const messages: {
}
`,
ResinExpiredToken: () => stripIndent`
BalenaExpiredToken: () => stripIndent`
Looks like your session token is expired.
Please try logging in again with:
$ resin login`,
$ balena login`,
};
exports.handle = function(error: any) {

View File

@ -4,13 +4,13 @@ import _ = require('lodash');
import Mixpanel = require('mixpanel');
import Raven = require('raven');
import Promise = require('bluebird');
import ResinSdk = require('resin-sdk');
import BalenaSdk = require('balena-sdk');
import packageJSON = require('../package.json');
const resin = ResinSdk.fromSharedOptions();
const balena = BalenaSdk.fromSharedOptions();
const getMatchCommandAsync = Promise.promisify(Capitano.state.getMatchCommand);
const getMixpanel = _.memoize<any>(() =>
resin.models.config
balena.models.config
.getAll()
.get('mixpanelToken')
.then(Mixpanel.init),
@ -18,11 +18,11 @@ const getMixpanel = _.memoize<any>(() =>
export function trackCommand(capitanoCli: Capitano.Cli) {
return Promise.props({
resinUrl: resin.settings.get('resinUrl'),
username: resin.auth.whoami().catchReturn(undefined),
balenaUrl: balena.settings.get('balenaUrl'),
username: balena.auth.whoami().catchReturn(undefined),
mixpanel: getMixpanel(),
})
.then(({ username, resinUrl, mixpanel }) => {
.then(({ username, balenaUrl, mixpanel }) => {
return getMatchCommandAsync(capitanoCli.command).then(command => {
Raven.mergeContext({
user: {
@ -37,7 +37,7 @@ export function trackCommand(capitanoCli: Capitano.Cli) {
version: packageJSON.version,
node: process.version,
arch: process.arch,
resinUrl,
balenaUrl,
platform: process.platform,
command: capitanoCli,
});

View File

@ -332,7 +332,7 @@ tagServiceImages = (docker, images, serviceImages) ->
authorizePush = (tokenAuthEndpoint, registry, images) ->
_ = require('lodash')
sdk = require('resin-sdk').fromSharedOptions()
sdk = require('balena-sdk').fromSharedOptions()
if not _.isArray(images)
images = [ images ]

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import Promise = require('bluebird');
import ResinSdk = require('resin-sdk');
import BalenaSdk = require('balena-sdk');
import * as semver from 'resin-semver';
const resin = ResinSdk.fromSharedOptions();
const balena = BalenaSdk.fromSharedOptions();
type ImgConfig = {
applicationName: string;
@ -51,7 +51,7 @@ type ImgConfig = {
};
export function generateBaseConfig(
application: ResinSdk.Application,
application: BalenaSdk.Application,
options: { version: string; appUpdatePollInterval?: number },
): Promise<ImgConfig> {
options = {
@ -59,7 +59,7 @@ export function generateBaseConfig(
appUpdatePollInterval: options.appUpdatePollInterval || 10,
};
const promise = resin.models.os.getConfig(
const promise = balena.models.os.getConfig(
application.app_name,
options,
) as Promise<ImgConfig & { apiKey?: string }>;
@ -70,7 +70,7 @@ export function generateBaseConfig(
}
export function generateApplicationConfig(
application: ResinSdk.Application,
application: BalenaSdk.Application,
options: { version: string },
) {
return generateBaseConfig(application, options).tap(config => {
@ -83,11 +83,13 @@ export function generateApplicationConfig(
}
export function generateDeviceConfig(
device: ResinSdk.Device & { belongs_to__application: ResinSdk.PineDeferred },
device: BalenaSdk.Device & {
belongs_to__application: BalenaSdk.PineDeferred;
},
deviceApiKey: string | true | null,
options: { version: string },
) {
return resin.models.application
return balena.models.application
.get(device.belongs_to__application.__id)
.then(application => {
return generateBaseConfig(application, options).tap(config => {
@ -112,7 +114,7 @@ export function generateDeviceConfig(
}
function addApplicationKey(config: any, applicationNameOrId: string | number) {
return resin.models.application
return balena.models.application
.generateApiKey(applicationNameOrId)
.tap(apiKey => {
config.apiKey = apiKey;
@ -120,7 +122,7 @@ function addApplicationKey(config: any, applicationNameOrId: string | number) {
}
function addProvisioningKey(config: any, applicationNameOrId: string | number) {
return resin.models.application
return balena.models.application
.generateProvisioningKey(applicationNameOrId)
.tap(apiKey => {
config.apiKey = apiKey;
@ -134,7 +136,7 @@ function addDeviceKey(
) {
return Promise.try(() => {
if (customDeviceApiKey === true) {
return resin.models.device.generateDeviceKey(uuid);
return balena.models.device.generateDeviceKey(uuid);
} else {
return customDeviceApiKey;
}

View File

@ -53,7 +53,7 @@ export async function deployToDevice(opts: DeviceDeployOptions): Promise<void> {
const versionError = new Error(
'The supervisor version on this remote device does not support multicontainer local mode. ' +
'Please update your device to resinOS v2.20.0 or greater from the dashboard.',
'Please update your device to balenaOS v2.20.0 or greater from the dashboard.',
);
try {

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -20,13 +20,13 @@ import _ = require('lodash');
import chalk from 'chalk';
import rindle = require('rindle');
import visuals = require('resin-cli-visuals');
import ResinSdk = require('resin-sdk');
import BalenaSdk = require('balena-sdk');
import { InitializeEmitter, OperationState } from 'resin-device-init';
const waitStreamAsync = Promise.promisify(rindle.wait);
const resin = ResinSdk.fromSharedOptions();
const balena = BalenaSdk.fromSharedOptions();
export function getGroupDefaults(group: {
options: { name: string; default?: string }[];
@ -83,7 +83,7 @@ export function runCommand(command: string): Promise<void> {
export function getManifest(
image: string,
deviceType: string,
): Promise<ResinSdk.DeviceType> {
): Promise<BalenaSdk.DeviceType> {
const imagefs = require('resin-image-fs');
// Attempt to read manifest from the first
// partition, but fallback to the API if
@ -95,7 +95,7 @@ export function getManifest(
path: '/device-type.json',
})
.then(JSON.parse)
.catch(() => resin.models.device.getManifestBySlug(deviceType));
.catch(() => balena.models.device.getManifestBySlug(deviceType));
}
export function osProgressHandler(step: InitializeEmitter) {
@ -124,7 +124,7 @@ export function getArchAndDeviceType(
): Promise<{ arch: string; device_type: string }> {
return Promise.join(
getApplication(applicationName),
resin.models.config.getDeviceTypes(),
balena.models.config.getDeviceTypes(),
function(app, deviceTypes) {
const config = _.find(deviceTypes, { slug: app.device_type });
@ -151,14 +151,14 @@ export function getApplication(applicationName: string) {
};
if (match.length > 1) {
return resin.models.application.getAppByOwner(
return balena.models.application.getAppByOwner(
match[1],
match[0],
extraOptions,
);
}
return resin.models.application.get(applicationName, extraOptions);
return balena.models.application.get(applicationName, extraOptions);
}
// A function to reliably execute a command

View File

@ -1,22 +1,21 @@
export const reachingOut = `\
If you need help, or just want to say hi, don't hesitate in reaching out at:
GitHub: https://github.com/resin-io/resin-cli/issues/new
Forums: https://forums.resin.io\
GitHub: https://github.com/balena-io/balena-cli/issues/new
Forums: https://forums.balena.io\
`;
export const getHelp = `\
If you need help, don't hesitate in contacting us at:
GitHub: https://github.com/resin-io/resin-cli/issues/new
Forums: https://forums.resin.io\
GitHub: https://github.com/balena-io/balena-cli/issues/new
Forums: https://forums.balena.io\
`;
export const resinAsciiArt = `\
______ _ _
| ___ \\ (_) (_)
| |_/ /___ ___ _ _ __ _ ___
| // _ \\/ __| | '_ \\ | |/ _ \\
| |\\ \\ __/\\__ \\ | | | |_| | (_) |
\\_| \\_\\___||___/_|_| |_(_)_|\\___/\
export const balenaAsciiArt = `\
_ _
| |__ __ _ | | ____ _ __ __ _
| '_ \\ / _\` || | / __ \\| '_ \\ / _\` |
| |_) | (_) || || ___/| | | || (_) |
|_.__/ \\__,_||_| \\____/|_| |_| \\__,_|
`;

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2018 Resin.io
Copyright 2016-2018 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -18,12 +18,12 @@ import _ = require('lodash');
import Promise = require('bluebird');
import form = require('resin-cli-form');
import visuals = require('resin-cli-visuals');
import ResinSdk = require('resin-sdk');
import BalenaSdk = require('balena-sdk');
import chalk from 'chalk';
import validation = require('./validation');
import messages = require('./messages');
const resin = ResinSdk.fromSharedOptions();
const balena = BalenaSdk.fromSharedOptions();
export function authenticate(options: {}): Promise<void> {
return form
@ -43,8 +43,8 @@ export function authenticate(options: {}): Promise<void> {
],
{ override: options },
)
.then(resin.auth.login)
.then(resin.auth.twoFactor.isPassed)
.then(balena.auth.login)
.then(balena.auth.twoFactor.isPassed)
.then((isTwoFactorAuthPassed: boolean) => {
if (isTwoFactorAuthPassed) {
return;
@ -56,11 +56,11 @@ export function authenticate(options: {}): Promise<void> {
name: 'code',
type: 'input',
})
.then(resin.auth.twoFactor.challenge)
.then(balena.auth.twoFactor.challenge)
.catch((error: any) => {
return resin.auth.logout().then(() => {
return balena.auth.logout().then(() => {
if (
error.name === 'ResinRequestError' &&
error.name === 'BalenaRequestError' &&
error.statusCode === 401
) {
throw new Error('Invalid two factor authentication code');
@ -90,7 +90,7 @@ export function askLoginType() {
value: 'token',
},
{
name: "I don't have a Resin account!",
name: "I don't have a balena account!",
value: 'register',
},
],
@ -98,7 +98,7 @@ export function askLoginType() {
}
export function selectDeviceType() {
return resin.models.config.getDeviceTypes().then(deviceTypes => {
return balena.models.config.getDeviceTypes().then(deviceTypes => {
deviceTypes = _.sortBy(deviceTypes, 'name');
return form.ask({
message: 'Device Type',
@ -137,16 +137,16 @@ export function confirm(
}
export function selectApplication(
filter: (app: ResinSdk.Application) => boolean,
filter: (app: BalenaSdk.Application) => boolean,
) {
return resin.models.application
return balena.models.application
.hasAny()
.then(function(hasAnyApplications) {
if (!hasAnyApplications) {
throw new Error("You don't have any applications");
}
return resin.models.application.getAll();
return balena.models.application.getAll();
})
.filter(filter || _.constant(true))
.then(applications => {
@ -162,14 +162,14 @@ export function selectApplication(
}
export function selectOrCreateApplication() {
return resin.models.application
return balena.models.application
.hasAny()
.then(hasAnyApplications => {
if (!hasAnyApplications) return;
return resin.models.application.getAll().then(applications => {
return balena.models.application.getAll().then(applications => {
const appOptions = _.map<
ResinSdk.Application,
BalenaSdk.Application,
{ name: string; value: string | null }
>(applications, application => ({
name: `${application.app_name} (${application.device_type})`,
@ -202,13 +202,13 @@ export function selectOrCreateApplication() {
}
export function awaitDevice(uuid: string) {
return resin.models.device.getName(uuid).then(deviceName => {
return balena.models.device.getName(uuid).then(deviceName => {
const spinner = new visuals.Spinner(
`Waiting for ${deviceName} to come online`,
);
const poll = (): Promise<void> => {
return resin.models.device.isOnline(uuid).then(function(isOnline) {
return balena.models.device.isOnline(uuid).then(function(isOnline) {
if (isOnline) {
spinner.stop();
console.info(`The device **${deviceName}** is online!`);
@ -223,15 +223,15 @@ export function awaitDevice(uuid: string) {
});
};
console.info(`Waiting for ${deviceName} to connect to resin...`);
console.info(`Waiting for ${deviceName} to connect to balena...`);
return poll().return(uuid);
});
}
export function inferOrSelectDevice(preferredUuid: string) {
return resin.models.device
return balena.models.device
.getAll()
.filter<ResinSdk.Device>(device => device.is_online)
.filter<BalenaSdk.Device>(device => device.is_online)
.then(onlineDevices => {
if (_.isEmpty(onlineDevices)) {
throw new Error("You don't have any devices online");

View File

@ -1,16 +1,16 @@
import { stripIndent } from 'common-tags';
import * as ResinSdk from 'resin-sdk';
import * as BalenaSdk from 'balena-sdk';
import Logger = require('./logger');
import { runCommand } from './helpers';
import { exec, execBuffered } from './ssh';
const MIN_RESINOS_VERSION = 'v2.14.0';
const MIN_BALENAOS_VERSION = 'v2.14.0';
export async function join(
logger: Logger,
sdk: ResinSdk.ResinSDK,
sdk: BalenaSdk.BalenaSDK,
deviceHostnameOrIp?: string,
appName?: string,
): Promise<void> {
@ -53,13 +53,13 @@ export async function join(
await configure(deviceIp, config);
logger.logDebug('All done.');
const platformUrl = await sdk.settings.get('resinUrl');
const platformUrl = await sdk.settings.get('balenaUrl');
logger.logSuccess(`Device successfully joined ${platformUrl}!`);
}
export async function leave(
logger: Logger,
_sdk: ResinSdk.ResinSDK,
_sdk: BalenaSdk.BalenaSDK,
deviceHostnameOrIp?: string,
): Promise<void> {
logger.logDebug('Determining device...');
@ -116,7 +116,7 @@ async function assertDeviceIsCompatible(deviceIp: string): Promise<void> {
} catch (err) {
exitWithExpectedError(stripIndent`
Device "${deviceIp}" is incompatible and cannot join or leave an application.
Please select or provision device with resinOS newer than ${MIN_RESINOS_VERSION}.`);
Please select or provision device with balenaOS newer than ${MIN_BALENAOS_VERSION}.`);
}
}
@ -173,7 +173,7 @@ async function getOrSelectLocalDevice(deviceIp?: string): Promise<string> {
return ip;
}
async function selectAppFromList(applications: ResinSdk.Application[]) {
async function selectAppFromList(applications: BalenaSdk.Application[]) {
const _ = await import('lodash');
const { selectFromList } = await import('../utils/patterns');
@ -188,10 +188,10 @@ async function selectAppFromList(applications: ResinSdk.Application[]) {
}
async function getOrSelectApplication(
sdk: ResinSdk.ResinSDK,
sdk: BalenaSdk.BalenaSDK,
deviceType: string,
appName?: string,
): Promise<ResinSdk.Application> {
): Promise<BalenaSdk.Application> {
const _ = await import('lodash');
const form = await import('resin-cli-form');
@ -230,7 +230,7 @@ async function getOrSelectApplication(
return selectAppFromList(applications);
}
const options: ResinSdk.PineOptionsFor<ResinSdk.Application> = {};
const options: BalenaSdk.PineOptionsFor<BalenaSdk.Application> = {};
// Check for an app of the form `user/application` and update the API query.
let name: string;
@ -280,17 +280,17 @@ async function getOrSelectApplication(
}
async function createApplication(
sdk: ResinSdk.ResinSDK,
sdk: BalenaSdk.BalenaSDK,
deviceType: string,
name?: string,
): Promise<ResinSdk.Application> {
): Promise<BalenaSdk.Application> {
const form = await import('resin-cli-form');
const validation = await import('./validation');
const patterns = await import('./patterns');
let username = await sdk.auth.whoami();
if (!username) {
throw new sdk.errors.ResinNotLoggedIn();
throw new sdk.errors.BalenaNotLoggedIn();
}
username = username.toLowerCase();
@ -333,8 +333,8 @@ async function createApplication(
}
async function generateApplicationConfig(
sdk: ResinSdk.ResinSDK,
app: ResinSdk.Application,
sdk: BalenaSdk.BalenaSDK,
app: BalenaSdk.Application,
options: { version: string },
) {
const form = await import('resin-cli-form');

View File

@ -15,7 +15,7 @@ exports.installQemuIfNeeded = Promise.method (emulated, logger) ->
exports.qemuPathInContext = (context) ->
path = require('path')
binDir = path.join(context, '.resin')
binDir = path.join(context, '.balena')
binPath = path.join(binDir, QEMU_BIN_NAME)
path.relative(context, binPath)
@ -23,7 +23,7 @@ exports.copyQemu = (context) ->
path = require('path')
fs = require('mz/fs')
# Create a hidden directory in the build context, containing qemu
binDir = path.join(context, '.resin')
binDir = path.join(context, '.balena')
binPath = path.join(binDir, QEMU_BIN_NAME)
Promise.resolve(fs.mkdir(binDir))
@ -52,11 +52,11 @@ hasQemu = ->
.catchReturn(false)
getQemuPath = ->
resin = require('resin-sdk').fromSharedOptions()
balena = require('balena-sdk').fromSharedOptions()
path = require('path')
fs = require('mz/fs')
resin.settings.get('binDirectory')
balena.settings.get('binDirectory')
.then (binDir) ->
Promise.resolve(fs.mkdir(binDir))
.catch(code: 'EEXIST', ->)
@ -76,7 +76,7 @@ installQemu = ->
.then (qemuPath) ->
new Promise (resolve, reject) ->
installStream = fs.createWriteStream(qemuPath)
qemuUrl = "https://github.com/resin-io/qemu/releases/download/#{QEMU_VERSION}/#{QEMU_BIN_NAME}.gz"
qemuUrl = "https://github.com/balena-io/qemu/releases/download/#{QEMU_VERSION}/#{QEMU_BIN_NAME}.gz"
request(qemuUrl)
.on('error', reject)
.pipe(zlib.createGunzip())

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -16,7 +16,7 @@ limitations under the License.
import * as JSONStream from 'JSONStream';
import * as request from 'request';
import { ResinSDK } from 'resin-sdk';
import { BalenaSDK } from 'balena-sdk';
import * as Stream from 'stream';
import { TypedError } from 'typed-error';
@ -40,7 +40,7 @@ export interface RemoteBuild {
baseUrl: string;
opts: BuildOpts;
sdk: ResinSDK;
sdk: BalenaSDK;
// For internal use
releaseId?: number;
@ -100,7 +100,7 @@ export async function startRemoteBuild(build: RemoteBuild): Promise<void> {
// This is necessary because the `exit-hook` module is used by several
// dependencies, and will exit without calling the following handler.
// Once https://github.com/resin-io/resin-cli/issues/867 has been solved,
// Once https://github.com/balena-io/balena-cli/issues/867 has been solved,
// we are free to (and definitely should) remove the below line
process.removeAllListeners('SIGINT');
process.on('SIGINT', () => {
@ -139,7 +139,7 @@ async function handleBuilderMetadata(obj: BuilderMessage, build: RemoteBuild) {
console.log(
stripIndent`
Warning: ignoring unknown builder command. You may experience
odd build output. Maybe you need to update resin-cli?`,
odd build output. Maybe you need to update balena-cli?`,
);
return;
}
@ -245,7 +245,7 @@ async function getRequestStream(build: RemoteBuild): Promise<Stream.Duplex> {
});
const uploadSpinner = new visuals.Spinner(
'Uploading source package to resin cloud',
'Uploading source package to balena cloud',
);
uploadSpinner.start();

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -20,7 +20,7 @@ import packageJSON = require('../../package.json');
// Check for an update once a day. 1 day granularity should be
// enough, rather than every run.
const resinUpdateInterval = 1000 * 60 * 60 * 24 * 1;
const balenaUpdateInterval = 1000 * 60 * 60 * 24 * 1;
let notifier: UpdateNotifier.UpdateNotifier;
@ -30,7 +30,7 @@ let notifier: UpdateNotifier.UpdateNotifier;
if (!isRoot()) {
notifier = UpdateNotifier({
pkg: packageJSON,
updateCheckInterval: resinUpdateInterval,
updateCheckInterval: balenaUpdateInterval,
});
}

View File

@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Resin.io
Copyright 2016-2017 Balena
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

View File

@ -1,27 +1,27 @@
{
"name": "resin-cli",
"name": "balena-cli",
"version": "8.1.0",
"description": "The official resin.io CLI tool",
"description": "The official balena CLI tool",
"main": "./build/actions/index.js",
"homepage": "https://github.com/resin-io/resin-cli",
"homepage": "https://github.com/balena-io/balena-cli",
"repository": {
"type": "git",
"url": "git@github.com:resin-io/resin-cli.git"
"url": "git@github.com:balena-io/balena-cli.git"
},
"preferGlobal": true,
"files": [
"bin/resin",
"bin/balena",
"build/",
"doc/",
"lib/"
],
"bin": {
"resin": "./bin/resin"
"balena": "./bin/balena"
},
"pkg": {
"scripts": [
"node_modules/resin-sync/build/capitano/*.js",
"node_modules/resin-sync/build/sync/*.js",
"node_modules/balena-sync/build/capitano/*.js",
"node_modules/balena-sync/build/sync/*.js",
"node_modules/resin-compose-parse/src/schemas/*.json",
"node_modules/raven/lib/instrumentation/*.js"
],
@ -49,10 +49,15 @@
"prepublishOnly": "npm run build"
},
"keywords": [
"balena",
"balena.io",
"balenaCloud",
"balenaOS",
"resin",
"resin.io",
"git"
],
"author": "Juan Cruz Viotti <juan@resin.io>",
"author": "Juan Cruz Viotti <juan@balena.io>",
"license": "Apache-2.0",
"engines": {
"node": ">=6.0"
@ -97,6 +102,12 @@
"ansi-escapes": "^2.0.0",
"any-promise": "^1.3.0",
"archiver": "^2.1.0",
"balena-config-json": "^2.0.0",
"balena-image-manager": "^6.0.0",
"balena-preload": "^8.0.0",
"balena-sdk": "^11.0.0",
"balena-settings-client": "^4.0.0",
"balena-sync": "^10.0.0",
"bash": "0.0.1",
"bluebird": "^3.3.3",
"body-parser": "^1.14.1",
@ -144,21 +155,14 @@
"resin-cli-form": "^2.0.0",
"resin-cli-visuals": "^1.4.0",
"resin-compose-parse": "^2.0.0",
"resin-config-json": "^1.0.0",
"resin-device-config": "^4.0.0",
"resin-device-config": "^5.0.0",
"resin-device-init": "^4.0.0",
"resin-doodles": "0.0.1",
"resin-image-fs": "^5.0.2",
"resin-image-manager": "^5.0.0",
"resin-multibuild": "^0.9.0",
"resin-preload": "^7.0.0",
"resin-release": "^1.2.0",
"resin-sdk": "11.0.0-balena-sdk-78e343d605d323cff37b039e8e40cae05b52fb36",
"resin-sdk-preconfigured": "^6.9.0",
"resin-semver": "^1.3.0",
"resin-settings-client": "^3.6.1",
"resin-semver": "^1.4.0",
"resin-stream-logger": "^0.1.0",
"resin-sync": "^9.3.3",
"rimraf": "^2.4.3",
"rindle": "^1.0.0",
"semver": "^5.3.0",

View File

@ -6,7 +6,7 @@ tokens = require('./tokens.json')
rewire = require('rewire')
utils = rewire('../../build/auth/utils')
resin = utils.__get__('resin')
balena = utils.__get__('balena')
describe 'Utils:', ->
@ -21,7 +21,7 @@ describe 'Utils:', ->
it 'should eventually contain an https protocol', ->
Promise.props
dashboardUrl: resin.settings.get('dashboardUrl')
dashboardUrl: balena.settings.get('dashboardUrl')
loginUrl: utils.getDashboardLoginURL('https://127.0.0.1:3000/callback')
.then ({ dashboardUrl, loginUrl }) ->
protocol = url.parse(loginUrl).protocol
@ -29,7 +29,7 @@ describe 'Utils:', ->
it 'should correctly escape a callback url without a path', ->
Promise.props
dashboardUrl: resin.settings.get('dashboardUrl')
dashboardUrl: balena.settings.get('dashboardUrl')
loginUrl: utils.getDashboardLoginURL('http://127.0.0.1:3000')
.then ({ dashboardUrl, loginUrl }) ->
expectedUrl = "#{dashboardUrl}/login/cli/http%253A%252F%252F127.0.0.1%253A3000"
@ -37,7 +37,7 @@ describe 'Utils:', ->
it 'should correctly escape a callback url with a path', ->
Promise.props
dashboardUrl: resin.settings.get('dashboardUrl')
dashboardUrl: balena.settings.get('dashboardUrl')
loginUrl: utils.getDashboardLoginURL('http://127.0.0.1:3000/callback')
.then ({ dashboardUrl, loginUrl }) ->
expectedUrl = "#{dashboardUrl}/login/cli/http%253A%252F%252F127.0.0.1%253A3000%252Fcallback"
@ -64,11 +64,11 @@ describe 'Utils:', ->
describe 'given the token does not authenticate with the server', ->
beforeEach ->
@resinAuthIsLoggedInStub = m.sinon.stub(resin.auth, 'isLoggedIn')
@resinAuthIsLoggedInStub.returns(Promise.resolve(false))
@balenaAuthIsLoggedInStub = m.sinon.stub(balena.auth, 'isLoggedIn')
@balenaAuthIsLoggedInStub.returns(Promise.resolve(false))
afterEach ->
@resinAuthIsLoggedInStub.restore()
@balenaAuthIsLoggedInStub.restore()
it 'should eventually be false', ->
promise = utils.loginIfTokenValid(tokens.johndoe.token)
@ -77,34 +77,34 @@ describe 'Utils:', ->
describe 'given there was a token already', ->
beforeEach ->
resin.auth.loginWithToken(tokens.janedoe.token)
balena.auth.loginWithToken(tokens.janedoe.token)
it 'should preserve the old token', ->
resin.auth.getToken().then (originalToken) ->
balena.auth.getToken().then (originalToken) ->
m.chai.expect(originalToken).to.equal(tokens.janedoe.token)
return utils.loginIfTokenValid(tokens.johndoe.token)
.then(resin.auth.getToken).then (currentToken) ->
.then(balena.auth.getToken).then (currentToken) ->
m.chai.expect(currentToken).to.equal(tokens.janedoe.token)
describe 'given there was no token', ->
beforeEach ->
resin.auth.logout()
balena.auth.logout()
it 'should stay without a token', ->
utils.loginIfTokenValid(tokens.johndoe.token).then ->
resin.auth.isLoggedIn()
balena.auth.isLoggedIn()
.then (isLoggedIn) ->
m.chai.expect(isLoggedIn).to.equal(false)
describe 'given the token does authenticate with the server', ->
beforeEach ->
@resinAuthIsLoggedInStub = m.sinon.stub(resin.auth, 'isLoggedIn')
@resinAuthIsLoggedInStub.returns(Promise.resolve(true))
@balenaAuthIsLoggedInStub = m.sinon.stub(balena.auth, 'isLoggedIn')
@balenaAuthIsLoggedInStub.returns(Promise.resolve(true))
afterEach ->
@resinAuthIsLoggedInStub.restore()
@balenaAuthIsLoggedInStub.restore()
it 'should eventually be true', ->
promise = utils.loginIfTokenValid(tokens.johndoe.token)

5
typings/balena-sync.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
declare module 'balena-sync' {
import { CommandDefinition } from 'capitano';
export function capitano(tool: 'balena-cli'): CommandDefinition;
}

View File

@ -1,801 +0,0 @@
declare module 'resin-sdk-preconfigured' {
import * as Promise from 'bluebird';
import { EventEmitter } from 'events';
import * as ResinErrors from 'resin-errors';
import { Readable } from 'stream';
/* tslint:disable:no-namespace */
namespace Pine {
// based on https://github.com/resin-io/pinejs-client-js/blob/master/core.d.ts
type RawFilter =
| string
| Array<string | Filter<any>>
| { $string: string; [index: string]: Filter<any> | string };
type Lambda<T> = {
$alias: string;
$expr: Filter<T>;
};
type OrderByValues = 'asc' | 'desc';
type OrderBy = string | string[] | { [index: string]: OrderByValues };
type ResourceObjFilter<T> = { [k in keyof T]?: object | number | string };
interface FilterArray<T> extends Array<Filter<T>> {}
type FilterExpressions<T> = {
$raw?: RawFilter;
$?: string | string[];
$and?: Filter<T> | FilterArray<T>;
$or?: Filter<T> | FilterArray<T>;
$in?: Filter<T> | FilterArray<T>;
$not?: Filter<T> | FilterArray<T>;
$any?: Lambda<T>;
$all?: Lambda<T>;
};
type Filter<T> = ResourceObjFilter<T> & FilterExpressions<T>;
type BaseExpandFor<T> = { [k in keyof T]?: object } | keyof T;
export type Expand<T> = BaseExpandFor<T> | Array<BaseExpandFor<T>>;
}
namespace ResinRequest {
interface ResinRequestOptions {
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
url: string;
apiKey?: string;
body?: any;
}
interface ResinRequestResponse extends Response {
body: any;
}
interface ResinRequest {
send: (options: ResinRequestOptions) => Promise<ResinRequestResponse>;
}
}
namespace ResinSdk {
interface Interceptor {
request?(response: any): Promise<any>;
response?(response: any): Promise<any>;
requestError?(error: Error): Promise<any>;
responseError?(error: Error): Promise<any>;
}
interface Config {
deployment: string | null;
deviceUrlsBase: string;
adminUrl: string;
apiUrl: string;
actionsUrl: string;
gitServerUrl: string;
pubnub: {
subscribe_key: string;
publish_key: string;
};
ga?: GaConfig;
mixpanelToken?: string;
intercomAppId?: string;
recurlyPublicKey?: string;
deviceTypes: DeviceType[];
DEVICE_ONLINE_ICON: string;
DEVICE_OFFLINE_ICON: string;
signupCodeRequired: boolean;
supportedSocialProviders: string[];
}
interface GaConfig {
site: string;
id: string;
}
interface DeviceType {
slug: string;
name: string;
arch: string;
state?: string;
isDependent?: boolean;
instructions?: string[] | DeviceTypeInstructions;
gettingStartedLink?: string | DeviceTypeGettingStartedLink;
stateInstructions?: { [key: string]: string[] };
options?: DeviceTypeOptions[];
initialization?: {
options?: DeviceInitializationOptions[];
operations: Array<{
command: string;
}>;
};
supportsBlink?: boolean;
yocto: {
fstype?: string;
deployArtifact: string;
};
}
interface DeviceTypeInstructions {
linux: string[];
osx: string[];
windows: string[];
}
interface DeviceTypeGettingStartedLink {
linux: string;
osx: string;
windows: string;
[key: string]: string;
}
interface DeviceTypeOptions {
options: DeviceTypeOptionsGroup[];
collapsed: boolean;
isCollapsible: boolean;
isGroup: boolean;
message: string;
name: string;
}
interface DeviceInitializationOptions {
message: string;
type: string;
name: string;
}
interface DeviceTypeOptionsGroup {
default: number | string;
message: string;
name: string;
type: string;
min?: number;
choices?: string[] | number[];
choicesLabels?: { [key: string]: string };
}
interface WithId {
id: number;
}
interface PineParams {
resource: string;
id?: number;
body?: object;
options?: PineOptions;
}
interface PineOptions {
filter?: object;
expand?: object | string;
orderBy?: Pine.OrderBy;
top?: string;
skip?: string;
select?: string | string[];
}
interface PineParamsFor<T> extends PineParams {
body?: Partial<T>;
options?: PineOptionsFor<T>;
}
interface PineParamsWithIdFor<T> extends PineParamsFor<T> {
id: number;
}
type PineFilterFor<T> = Pine.Filter<T>;
type PineExpandFor<T> = Pine.Expand<T>;
interface PineOptionsFor<T> extends PineOptions {
filter?: PineFilterFor<T>;
expand?: PineExpandFor<T>;
select?: Array<keyof T> | keyof T;
}
interface PineDeferred {
__id: number;
}
/**
* When not selected-out holds a deferred.
* When expanded hold an array with a single element.
*/
type NavigationResource<T = WithId> = T[] | PineDeferred;
/**
* When expanded holds an array, otherwise the property is not present.
* Selecting is not suggested,
* in that case it holds a deferred to the original resource.
*/
type ReverseNavigationResource<T = WithId> = T[] | undefined;
interface SocialServiceAccount {
provider: string;
display_name: string;
created_at: string;
id: number;
remote_id: string;
}
interface User {
id: number;
username: string;
email?: string;
first_name?: string;
last_name?: string;
company?: string;
account_type?: string;
has_disabled_newsletter?: boolean;
jwt_secret: string;
created_at: string;
twoFactorRequired?: boolean;
hasPasswordSet?: boolean;
needsPasswordReset?: boolean;
public_key?: boolean;
features?: string[];
intercomUserName?: string;
intercomUserHash?: string;
permissions?: string[];
loginAs?: boolean;
actualUser?: number;
// this is what the api route returns
social_service_account: ReverseNavigationResource<SocialServiceAccount>;
}
interface Application {
app_name: string;
device_type: string;
git_repository: string;
commit: string;
id: number;
device_type_info?: any;
has_dependent?: boolean;
should_track_latest_release: boolean;
user: NavigationResource<User>;
application_tag: ReverseNavigationResource<ApplicationTag>;
}
type BuildStatus =
| 'cancelled'
| 'error'
| 'interrupted'
| 'local'
| 'running'
| 'success'
| 'timeout'
| null;
interface Build {
log: string;
commit_hash: string;
created_at: string;
end_timestamp: string;
id: number;
message: string | null;
project_type: string;
push_timestamp: string | null;
start_timestamp: string;
status: BuildStatus;
update_timestamp: string | null;
}
interface BillingAccountAddressInfo {
address1: string;
address2: string;
city: string;
state: string;
zip: string;
country: string;
phone: string;
}
interface BillingAccountInfo {
account_state: string;
first_name: string;
last_name: string;
company_name: string;
cc_emails: string;
vat_number: string;
address: BillingAccountAddressInfo;
}
type BillingInfoType = 'bank_account' | 'credit_card' | 'paypal';
interface BillingInfo {
full_name: string;
first_name: string;
last_name: string;
company: string;
vat_number: string;
address1: string;
address2: string;
city: string;
state: string;
zip: string;
country: string;
phone: string;
type?: BillingInfoType;
}
interface CardBillingInfo extends BillingInfo {
card_type: string;
year: string;
month: string;
first_one: string;
last_four: string;
}
interface BankAccountBillingInfo extends BillingInfo {
account_type: string;
last_four: string;
name_on_account: string;
routing_number: string;
}
interface TokenBillingSubmitInfo {
token_id: string;
}
interface BillingPlanInfo {
name: string;
billing?: BillingPlanBillingInfo;
}
interface BillingPlanBillingInfo {
currency: string;
currencySymbol?: string;
}
interface InvoiceInfo {
closed_at: string;
created_at: string;
currency: string;
invoice_number: string;
subtotal_in_cents: string;
total_in_cents: string;
uuid: string;
}
interface Device {
created_at: string;
device_type: string;
id: number;
name: string;
os_version: string;
os_variant?: string;
status_sort_index?: number;
uuid: string;
ip_address: string | null;
vpn_address: string | null;
last_connectivity_event: string;
is_in_local_mode?: boolean;
app_name?: string;
state?: { key: string; name: string };
status: string;
provisioning_state: string;
is_online: boolean;
is_connected_to_vpn: boolean;
supervisor_version: string;
is_web_accessible: boolean;
has_dependent: boolean;
note: string;
location: string;
latitude?: string;
longitude?: string;
custom_latitude?: string;
custom_longitude?: string;
download_progress?: number;
provisioning_progress?: number;
local_id?: string;
device_environment_variable: ReverseNavigationResource<
DeviceEnvironmentVariable
>;
device_tag: ReverseNavigationResource<DeviceTag>;
}
interface LogMessage {
message: string;
isSystem: boolean;
timestamp: number | null;
serviceId: number | null;
}
interface LogsSubscription extends EventEmitter {
unsubscribe(): void;
}
interface SSHKey {
title: string;
public_key: string;
id: number;
created_at: string;
}
type ImgConfigOptions = {
network?: 'ethernet' | 'wifi';
appUpdatePollInterval?: number;
wifiKey?: string;
wifiSsid?: string;
ip?: string;
gateway?: string;
netmask?: string;
version?: string;
};
type OsVersions = {
latest: string;
recommended: string;
default: string;
versions: string[];
};
interface EnvironmentVariableBase {
id: number;
name: string;
value: string;
}
interface EnvironmentVariable extends EnvironmentVariableBase {
application: NavigationResource<Application>;
}
interface DeviceEnvironmentVariable extends EnvironmentVariableBase {
env_var_name?: string;
device: NavigationResource<Device>;
}
interface ResourceTagBase {
id: number;
tag_key: string;
value: string;
}
interface ApplicationTag extends ResourceTagBase {
application: NavigationResource<Application>;
}
interface DeviceTag extends ResourceTagBase {
device: NavigationResource<Device>;
}
type LogsPromise = Promise<LogMessage[]>;
interface ResinSDK {
auth: {
register: (
credentials: { email: string; password: string },
) => Promise<string>;
authenticate: (
credentials: { email: string; password: string },
) => Promise<string>;
login: (
credentials: { email: string; password: string },
) => Promise<void>;
loginWithToken: (authToken: string) => Promise<void>;
logout: () => Promise<void>;
getToken: () => Promise<string>;
whoami: () => Promise<string | undefined>;
isLoggedIn: () => Promise<boolean>;
getUserId: () => Promise<number>;
getEmail: () => Promise<string>;
twoFactor: {
isEnabled: () => Promise<boolean>;
isPassed: () => Promise<boolean>;
challenge: (code: string) => Promise<void>;
};
};
settings: {
get(key: string): Promise<string>;
getAll(): Promise<{ [key: string]: string }>;
};
request: ResinRequest.ResinRequest;
errors: {
ResinAmbiguousApplication: ResinErrors.ResinAmbiguousApplication;
ResinAmbiguousDevice: ResinErrors.ResinAmbiguousDevice;
ResinApplicationNotFound: ResinErrors.ResinApplicationNotFound;
ResinBuildNotFound: ResinErrors.ResinBuildNotFound;
ResinDeviceNotFound: ResinErrors.ResinDeviceNotFound;
ResinExpiredToken: ResinErrors.ResinExpiredToken;
ResinInvalidDeviceType: ResinErrors.ResinInvalidDeviceType;
ResinInvalidParameterError: ResinErrors.ResinInvalidParameterError;
ResinKeyNotFound: ResinErrors.ResinKeyNotFound;
ResinMalformedToken: ResinErrors.ResinMalformedToken;
ResinNotLoggedIn: ResinErrors.ResinNotLoggedIn;
ResinRequestError: ResinErrors.ResinRequestError;
ResinSupervisorLockedError: ResinErrors.ResinSupervisorLockedError;
};
models: {
application: {
create(
name: string,
deviceType: string,
parentNameOrId?: number | string,
): Promise<Application>;
get(
nameOrId: string | number,
options?: PineOptionsFor<Application>,
): Promise<Application>;
getAppByOwner(
appName: string,
owner: string,
options?: PineOptionsFor<Application>,
): Promise<Application>;
getAll(options?: PineOptionsFor<Application>): Promise<Application[]>;
has(name: string): Promise<boolean>;
hasAny(): Promise<boolean>;
remove(nameOrId: string | number): Promise<void>;
restart(nameOrId: string | number): Promise<void>;
enableDeviceUrls(nameOrId: string | number): Promise<void>;
disableDeviceUrls(nameOrId: string | number): Promise<void>;
grantSupportAccess(
nameOrId: string | number,
expiryTimestamp: number,
): Promise<void>;
revokeSupportAccess(nameOrId: string | number): Promise<void>;
reboot(appId: number, { force }: { force?: boolean }): Promise<void>;
shutdown(
appId: number,
{ force }: { force?: boolean },
): Promise<void>;
purge(appId: number): Promise<void>;
generateApiKey(nameOrId: string | number): Promise<string>;
generateProvisioningKey(nameOrId: string | number): Promise<string>;
tags: {
getAllByApplication(
nameOrId: string | number,
options?: PineOptionsFor<ApplicationTag>,
): Promise<ApplicationTag[]>;
getAll(
options?: PineOptionsFor<ApplicationTag>,
): Promise<ApplicationTag[]>;
set(
nameOrId: string | number,
tagKey: string,
value: string,
): Promise<void>;
remove(nameOrId: string | number, tagKey: string): Promise<void>;
};
};
build: {
get(id: number, options?: PineOptionsFor<Build>): Promise<Build>;
getAllByApplication(
nameOrId: string | number,
options?: PineOptionsFor<Build>,
): Promise<Build[]>;
};
billing: {
getAccount(): Promise<BillingAccountInfo>;
getPlan(): Promise<BillingPlanInfo>;
getBillingInfo(): Promise<BillingInfo>;
updateBillingInfo(
billingInfo: TokenBillingSubmitInfo,
): Promise<BillingInfo>;
getInvoices(): Promise<InvoiceInfo[]>;
downloadInvoice(invoiceNumber: string): Promise<Blob>;
};
device: {
get(
uuidOrId: string | number,
options?: PineOptionsFor<Device>,
): Promise<Device>;
getByName(
nameOrId: string | number,
options?: PineOptionsFor<Device>,
): Promise<Device[]>;
getAll(options?: PineOptionsFor<Device>): Promise<Device[]>;
getAllByApplication(
nameOrId: string | number,
options?: PineOptionsFor<Device>,
): Promise<Device[]>;
getAllByParentDevice(
parentUuidOrId: string | number,
options?: PineOptionsFor<Device>,
): Promise<Device[]>;
getName(uuidOrId: string | number): Promise<string>;
getApplicationName(uuidOrId: string | number): Promise<string>;
getApplicationInfo(
uuidOrId: string | number,
): Promise<{
appId: string;
commit: string;
containerId: string;
env: { [key: string]: string | number };
imageId: string;
}>;
has(uuidOrId: string | number): Promise<boolean>;
isOnline(uuidOrId: string | number): Promise<boolean>;
getLocalIPAddressess(uuidOrId: string | number): Promise<string[]>;
getDashboardUrl(uuid: string): string;
getSupportedDeviceTypes(): Promise<string[]>;
getManifestBySlug(slugOrName: string): Promise<DeviceType>;
getManifestByApplication(
nameOrId: string | number,
): Promise<DeviceType>;
move(
uuidOrId: string | number,
applicationNameOrId: string | number,
): Promise<void>;
note(uuidOrId: string | number, note: string): Promise<void>;
remove(uuidOrId: string | number): Promise<void>;
rename(uuidOrId: string | number, newName: string): Promise<void>;
setCustomLocation(
uuidOrId: string | number,
location: { latitude: number; longitude: number },
): Promise<void>;
unsetCustomLocation(uuidOrId: string | number): Promise<void>;
identify(uuidOrId: string | number): Promise<void>;
startApplication(uuidOrId: string | number): Promise<void>;
stopApplication(uuidOrId: string | number): Promise<void>;
restartApplication(uuidOrId: string | number): Promise<void>;
grantSupportAccess(
uuidOrId: string | number,
expiryTimestamp: number,
): Promise<void>;
revokeSupportAccess(uuidOrId: string | number): Promise<void>;
reboot(
uuidOrId: string | number,
{ force }?: { force?: boolean },
): Promise<void>;
shutdown(
uuidOrId: string | number,
{ force }?: { force?: boolean },
): Promise<void>;
purge(uuidOrId: string | number): Promise<void>;
update(
uuidOrId: string | number,
{ force }?: { force?: boolean },
): Promise<void>;
getDisplayName(deviceTypeName: string): string;
getDeviceSlug(deviceTypeName: string): string;
generateUniqueKey(): string;
register(
applicationNameOrId: string | number,
uuid?: string,
): Promise<object>;
generateDeviceKey(uuidOrId: string | number): Promise<string>;
enableDeviceUrl(uuidOrId: string | number): Promise<void>;
disableDeviceUrl(uuidOrId: string | number): Promise<void>;
hasDeviceUrl(uuidOrId: string | number): Promise<boolean>;
getDeviceUrl(uuidOrId: string | number): Promise<string>;
enableTcpPing(uuidOrId: string | number): Promise<void>;
disableTcpPing(uuidOrId: string | number): Promise<void>;
ping(uuidOrId: string | number): Promise<void>;
getStatus(device: object): string;
lastOnline(device: Device): string;
tags: {
getAllByApplication(
nameOrId: string | number,
options?: PineOptionsFor<DeviceTag>,
): Promise<DeviceTag[]>;
getAllByDevice(
uuidOrId: string | number,
options?: PineOptionsFor<DeviceTag>,
): Promise<DeviceTag[]>;
getAll(options?: PineOptionsFor<DeviceTag>): Promise<DeviceTag[]>;
set(
uuidOrId: string | number,
tagKey: string,
value: string,
): Promise<void>;
remove(uuidOrId: string | number, tagKey: string): Promise<void>;
};
};
environmentVariables: {
device: {
getAll(id: number): Promise<DeviceEnvironmentVariable[]>;
getAllByApplication(
applicationNameOrId: number | string,
): Promise<DeviceEnvironmentVariable[]>;
update(id: number, value: string): Promise<void>;
create(
uuidOrId: number | string,
name: string,
value: string,
): Promise<void>;
remove(id: number): Promise<void>;
};
getAllByApplication(
applicationNameOrId: number | string,
): Promise<EnvironmentVariable[]>;
update(id: number, value: string): Promise<void>;
create(
applicationNameOrId: number | string,
name: string,
value: string,
): Promise<void>;
remove(id: number): Promise<void>;
isSystemVariable(variable: { name: string }): boolean;
};
config: {
getAll: () => Promise<Config>;
getDeviceTypes: () => Promise<DeviceType[]>;
getDeviceOptions(
deviceType: string,
): Promise<Array<DeviceTypeOptions | DeviceInitializationOptions>>;
};
key: {
getAll(options?: PineOptionsFor<SSHKey>): Promise<SSHKey[]>;
get(id: string | number): Promise<SSHKey>;
remove(id: string | number): Promise<void>;
create(title: string, key: string): Promise<SSHKey>;
};
os: {
getConfig(
nameOrId: string | number,
options?: ImgConfigOptions,
): Promise<object>;
getDownloadSize(slug: string, version?: string): Promise<number>;
getSupportedVersions(slug: string): Promise<OsVersions>;
getMaxSatisfyingVersion(
deviceType: string,
versionOrRange: string,
): string;
getLastModified(deviceType: string, version?: string): Promise<Date>;
download(deviceType: string, version?: string): Promise<Readable>;
};
};
logs: {
history(uuid: string): LogsPromise;
historySinceLastClear(uuid: string): LogsPromise;
subscribe(uuid: string): Promise<LogsSubscription>;
clear(uuid: string): void;
};
pine: {
delete<T>(
params: PineParamsWithIdFor<T> | PineParamsFor<T>,
): Promise<string>;
get<T>(params: PineParamsWithIdFor<T>): Promise<T>;
get<T>(params: PineParamsFor<T>): Promise<T[]>;
get<T, Result>(params: PineParamsFor<T>): Promise<Result>;
post<T>(params: PineParams): Promise<T>;
patch<T>(params: PineParamsWithIdFor<T>): Promise<T>;
};
interceptors: Interceptor[];
}
}
interface SdkOptions {
apiUrl?: string;
/**
* @deprecated Use resin.auth.loginWithToken(apiKey) instead
*/
apiKey?: string;
imageMakerUrl?: string;
dataDirectory?: string;
isBrowser?: boolean;
debug?: boolean;
}
interface SdkConstructor {
(options?: SdkOptions): ResinSdk.ResinSDK;
setSharedOptions(options: SdkOptions): void;
fromSharedOptions: () => ResinSdk.ResinSDK;
}
const ResinSdk: ResinSdk.ResinSDK;
export = ResinSdk;
}

View File

@ -1,5 +0,0 @@
declare module 'resin-sync' {
import { CommandDefinition } from 'capitano';
export function capitano(tool: 'resin-cli'): CommandDefinition;
}