mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 05:37:51 +00:00
Merge branch 'master' into typo
This commit is contained in:
commit
8bbb1966a4
3
.gitignore
vendored
3
.gitignore
vendored
@ -39,3 +39,6 @@ balenarc.yml
|
||||
build/
|
||||
build-bin/
|
||||
build-zip/
|
||||
|
||||
# Ignore fast-boot cache file
|
||||
/bin/.fast-boot.json
|
||||
|
12
CHANGELOG.md
12
CHANGELOG.md
@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file
|
||||
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 9.10.0 - 2019-01-14
|
||||
|
||||
* Improve startup time by adding fast-boot [Shaun Mulligan]
|
||||
|
||||
## 9.9.4 - 2019-01-13
|
||||
|
||||
* Lazy load the sdk as much as possible [Pagan Gazzard]
|
||||
|
||||
## 9.9.3 - 2019-01-13
|
||||
|
||||
* Lazy-load docker-toolbelt [Pagan Gazzard]
|
||||
|
||||
## 9.9.2 - 2019-01-11
|
||||
|
||||
* Lazy-load etcher-sdk to speed up startup [Pagan Gazzard]
|
||||
|
@ -4,4 +4,8 @@
|
||||
// operations otherwise, if the pool runs out.
|
||||
process.env.UV_THREADPOOL_SIZE = '64';
|
||||
|
||||
// Use fast-boot to cache require lookups, speeding up startup
|
||||
require('fast-boot2').start({
|
||||
cacheFile: __dirname + '/.fast-boot.json'
|
||||
})
|
||||
require('../build/app');
|
||||
|
@ -9,6 +9,10 @@
|
||||
// operations otherwise, if the pool runs out.
|
||||
process.env.UV_THREADPOOL_SIZE = '64';
|
||||
|
||||
// Use fast-boot to cache require lookups, speeding up startup
|
||||
require('fast-boot2').start({
|
||||
cacheFile: '.fast-boot.json'
|
||||
})
|
||||
process.env['TS_NODE_PROJECT'] = require('path').dirname(__dirname);
|
||||
require('coffeescript/register');
|
||||
require('ts-node/register');
|
||||
|
@ -71,8 +71,6 @@ BalenaSdk.setSharedOptions(
|
||||
retries: 2
|
||||
)
|
||||
|
||||
balena = BalenaSdk.fromSharedOptions()
|
||||
|
||||
actions = require('./actions')
|
||||
errors = require('./errors')
|
||||
events = require('./events')
|
||||
@ -86,6 +84,7 @@ update = require('./utils/update')
|
||||
require('any-promise/register/bluebird')
|
||||
|
||||
capitano.permission 'user', (done) ->
|
||||
balena = BalenaSdk.fromSharedOptions()
|
||||
balena.auth.isLoggedIn().then (isLoggedIn) ->
|
||||
if not isLoggedIn
|
||||
exitWithExpectedError('''
|
||||
|
@ -7,16 +7,17 @@ import Promise = require('bluebird');
|
||||
import BalenaSdk = require('balena-sdk');
|
||||
import packageJSON = require('../package.json');
|
||||
|
||||
const balena = BalenaSdk.fromSharedOptions();
|
||||
const getBalenaSdk = _.once(() => BalenaSdk.fromSharedOptions());
|
||||
const getMatchCommandAsync = Promise.promisify(Capitano.state.getMatchCommand);
|
||||
const getMixpanel = _.memoize<any>(() =>
|
||||
balena.models.config
|
||||
.getAll()
|
||||
const getMixpanel = _.once<any>(() =>
|
||||
getBalenaSdk()
|
||||
.models.config.getAll()
|
||||
.get('mixpanelToken')
|
||||
.then(Mixpanel.init),
|
||||
);
|
||||
|
||||
export function trackCommand(capitanoCli: Capitano.Cli) {
|
||||
const balena = getBalenaSdk();
|
||||
return Promise.props({
|
||||
balenaUrl: balena.settings.get('balenaUrl'),
|
||||
username: balena.auth.whoami().catchReturn(undefined),
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Functions to help actions which rely on using docker
|
||||
|
||||
Promise = require('bluebird')
|
||||
_ = require('lodash')
|
||||
|
||||
# Use this function to seed an action's list of capitano options
|
||||
# with the docker options. Using this interface means that
|
||||
@ -153,14 +154,7 @@ exports.getDocker = (options) ->
|
||||
.then(createClient)
|
||||
.tap(ensureDockerSeemsAccessible)
|
||||
|
||||
exports.createClient = createClient = do ->
|
||||
# docker-toolbelt v3 is not backwards compatible as it removes all *Async
|
||||
# methods that are in wide use in the CLI. The workaround for now is to
|
||||
# manually promisify the client and replace all `new Docker()` calls with
|
||||
# this shared function that returns a promisified client.
|
||||
#
|
||||
# **New code must not use the *Async methods.**
|
||||
#
|
||||
getDockerToolbelt = _.once ->
|
||||
Docker = require('docker-toolbelt')
|
||||
Promise.promisifyAll Docker.prototype, {
|
||||
filter: (name) -> name == 'run'
|
||||
@ -169,9 +163,18 @@ exports.createClient = createClient = do ->
|
||||
Promise.promisifyAll(Docker.prototype)
|
||||
Promise.promisifyAll(new Docker({}).getImage().constructor.prototype)
|
||||
Promise.promisifyAll(new Docker({}).getContainer().constructor.prototype)
|
||||
return Docker
|
||||
|
||||
return (opts) ->
|
||||
return new Docker(opts)
|
||||
# docker-toolbelt v3 is not backwards compatible as it removes all *Async
|
||||
# methods that are in wide use in the CLI. The workaround for now is to
|
||||
# manually promisify the client and replace all `new Docker()` calls with
|
||||
# this shared function that returns a promisified client.
|
||||
#
|
||||
# **New code must not use the *Async methods.**
|
||||
#
|
||||
exports.createClient = createClient = (opts) ->
|
||||
Docker = getDockerToolbelt()
|
||||
return new Docker(opts)
|
||||
|
||||
ensureDockerSeemsAccessible = (docker) ->
|
||||
{ exitWithExpectedError } = require('./patterns')
|
||||
|
@ -23,12 +23,13 @@ import chalk from 'chalk';
|
||||
import validation = require('./validation');
|
||||
import messages = require('./messages');
|
||||
|
||||
const balena = BalenaSdk.fromSharedOptions();
|
||||
const getBalenaSdk = _.once(() => BalenaSdk.fromSharedOptions());
|
||||
|
||||
const getForm = _.once((): typeof _form => require('resin-cli-form'));
|
||||
const getVisuals = _.once((): typeof _visuals => require('resin-cli-visuals'));
|
||||
|
||||
export function authenticate(options: {}): Promise<void> {
|
||||
const balena = getBalenaSdk();
|
||||
return getForm()
|
||||
.run(
|
||||
[
|
||||
@ -101,17 +102,19 @@ export function askLoginType() {
|
||||
}
|
||||
|
||||
export function selectDeviceType() {
|
||||
return balena.models.config.getDeviceTypes().then(deviceTypes => {
|
||||
deviceTypes = _.sortBy(deviceTypes, 'name');
|
||||
return getForm().ask({
|
||||
message: 'Device Type',
|
||||
type: 'list',
|
||||
choices: _.map(deviceTypes, ({ slug: value, name }) => ({
|
||||
name,
|
||||
value,
|
||||
})),
|
||||
return getBalenaSdk()
|
||||
.models.config.getDeviceTypes()
|
||||
.then(deviceTypes => {
|
||||
deviceTypes = _.sortBy(deviceTypes, 'name');
|
||||
return getForm().ask({
|
||||
message: 'Device Type',
|
||||
type: 'list',
|
||||
choices: _.map(deviceTypes, ({ slug: value, name }) => ({
|
||||
name,
|
||||
value,
|
||||
})),
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function confirm(
|
||||
@ -142,6 +145,7 @@ export function confirm(
|
||||
export function selectApplication(
|
||||
filter: (app: BalenaSdk.Application) => boolean,
|
||||
) {
|
||||
const balena = getBalenaSdk();
|
||||
return balena.models.application
|
||||
.hasAny()
|
||||
.then(function(hasAnyApplications) {
|
||||
@ -165,6 +169,7 @@ export function selectApplication(
|
||||
}
|
||||
|
||||
export function selectOrCreateApplication() {
|
||||
const balena = getBalenaSdk();
|
||||
return balena.models.application
|
||||
.hasAny()
|
||||
.then(hasAnyApplications => {
|
||||
@ -205,6 +210,7 @@ export function selectOrCreateApplication() {
|
||||
}
|
||||
|
||||
export function awaitDevice(uuid: string) {
|
||||
const balena = getBalenaSdk();
|
||||
return balena.models.device.getName(uuid).then(deviceName => {
|
||||
const visuals = getVisuals();
|
||||
const spinner = new visuals.Spinner(
|
||||
@ -233,6 +239,7 @@ export function awaitDevice(uuid: string) {
|
||||
}
|
||||
|
||||
export function inferOrSelectDevice(preferredUuid: string) {
|
||||
const balena = getBalenaSdk();
|
||||
return balena.models.device
|
||||
.getAll()
|
||||
.filter<BalenaSdk.Device>(device => device.is_online)
|
||||
|
@ -17,7 +17,7 @@ export class DriveList extends CustomDynamicList<
|
||||
}
|
||||
|
||||
protected *getThings() {
|
||||
const sdk: typeof _sdk = require('etcher-sdk')
|
||||
const sdk: typeof _sdk = require('etcher-sdk');
|
||||
for (const drive of this.scanner.drives) {
|
||||
if (drive instanceof sdk.sourceDestination.BlockDevice) {
|
||||
yield drive;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "balena-cli",
|
||||
"version": "9.9.2",
|
||||
"version": "9.10.0",
|
||||
"description": "The official balena CLI tool",
|
||||
"main": "./build/actions/index.js",
|
||||
"homepage": "https://github.com/balena-io/balena-cli",
|
||||
@ -109,7 +109,7 @@
|
||||
"balena-preload": "^8.0.4",
|
||||
"balena-sdk": "^11.2.0",
|
||||
"balena-settings-client": "^4.0.0",
|
||||
"balena-sync": "^10.0.0",
|
||||
"balena-sync": "^10.0.2",
|
||||
"bash": "0.0.1",
|
||||
"bluebird": "^3.3.3",
|
||||
"body-parser": "^1.14.1",
|
||||
@ -130,6 +130,7 @@
|
||||
"etcher-sdk": "^0.2.0",
|
||||
"event-stream": "3.3.4",
|
||||
"express": "^4.13.3",
|
||||
"fast-boot2": "^1.0.9",
|
||||
"global-tunnel-ng": "^2.1.1",
|
||||
"hasbin": "^1.2.3",
|
||||
"humanize": "0.0.9",
|
||||
@ -153,7 +154,7 @@
|
||||
"reconfix": "^0.1.0",
|
||||
"request": "^2.81.0",
|
||||
"resin-bundle-resolve": "^0.6.0",
|
||||
"resin-cli-form": "^2.0.0",
|
||||
"resin-cli-form": "^2.0.1",
|
||||
"resin-cli-visuals": "^1.4.0",
|
||||
"resin-compose-parse": "^2.0.0",
|
||||
"resin-doodles": "0.0.1",
|
||||
|
Loading…
Reference in New Issue
Block a user