mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-18 21:27:51 +00:00
choose version during device init, and list versions with resin os versions
This commit is contained in:
parent
24388811ad
commit
1cfe64e4a7
@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- Added ability to run an emulated build silently with `resin build`
|
||||
- Gzip images when uploading in `resin deploy`
|
||||
- Show a clear message immediately as the deploy starts, if we're deploying an image.
|
||||
- Allow OS version selection when doing `resin device init`
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -51,6 +51,12 @@ exports.booleanDevice = {
|
||||
alias: 'd'
|
||||
};
|
||||
|
||||
exports.osVersion = {
|
||||
signature: 'version',
|
||||
description: "exact version number, or a valid semver range,\nor 'latest' (includes pre-releases),\nor 'default' (excludes pre-releases if at least one stable version is available),\nor 'recommended' (excludes pre-releases, will fail if only pre-release versions are available),\nor 'menu' (will show the interactive menu)",
|
||||
parameter: 'version'
|
||||
};
|
||||
|
||||
exports.network = {
|
||||
signature: 'network',
|
||||
parameter: 'network',
|
||||
|
@ -15,10 +15,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
var commandOptions;
|
||||
var _, commandOptions;
|
||||
|
||||
commandOptions = require('./command-options');
|
||||
|
||||
_ = require('lodash');
|
||||
|
||||
exports.list = {
|
||||
signature: 'devices',
|
||||
description: 'list all devices',
|
||||
@ -27,9 +29,8 @@ exports.list = {
|
||||
permission: 'user',
|
||||
primary: true,
|
||||
action: function(params, options, done) {
|
||||
var Promise, _, resin, visuals;
|
||||
var Promise, resin, visuals;
|
||||
Promise = require('bluebird');
|
||||
_ = require('lodash');
|
||||
resin = require('resin-sdk-preconfigured');
|
||||
visuals = require('resin-cli-visuals');
|
||||
return Promise["try"](function() {
|
||||
@ -219,9 +220,8 @@ exports.rename = {
|
||||
help: 'Use this command to rename a device.\n\nIf you omit the name, you\'ll get asked for it interactively.\n\nExamples:\n\n $ resin device rename 7cf02a6\n $ resin device rename 7cf02a6 MyPi',
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
var Promise, _, form, resin;
|
||||
var Promise, form, resin;
|
||||
Promise = require('bluebird');
|
||||
_ = require('lodash');
|
||||
resin = require('resin-sdk-preconfigured');
|
||||
form = require('resin-cli-form');
|
||||
return Promise["try"](function() {
|
||||
@ -243,9 +243,8 @@ exports.move = {
|
||||
permission: 'user',
|
||||
options: [commandOptions.optionalApplication],
|
||||
action: function(params, options, done) {
|
||||
var _, patterns, resin;
|
||||
var patterns, resin;
|
||||
resin = require('resin-sdk-preconfigured');
|
||||
_ = require('lodash');
|
||||
patterns = require('../utils/patterns');
|
||||
return resin.models.device.get(params.uuid).then(function(device) {
|
||||
return options.application || patterns.selectApplication(function(application) {
|
||||
@ -269,7 +268,10 @@ exports.init = {
|
||||
description: 'enable advanced configuration',
|
||||
boolean: true,
|
||||
alias: 'v'
|
||||
}
|
||||
}, _.assign({}, commandOptions.osVersion, {
|
||||
signature: 'os-version',
|
||||
parameter: 'os-version'
|
||||
})
|
||||
],
|
||||
permission: 'user',
|
||||
action: function(params, options, done) {
|
||||
@ -292,7 +294,9 @@ exports.init = {
|
||||
var download;
|
||||
download = function() {
|
||||
return tmpNameAsync().then(function(tempPath) {
|
||||
return capitanoRunAsync("os download " + application.device_type + " --output '" + tempPath + "' --version default");
|
||||
var osVersion;
|
||||
osVersion = options['os-version'] || 'default';
|
||||
return capitanoRunAsync("os download " + application.device_type + " --output '" + tempPath + "' --version " + osVersion);
|
||||
}).disposer(function(tempPath) {
|
||||
return rimraf(tempPath);
|
||||
});
|
||||
|
@ -53,6 +53,23 @@ resolveVersion = function(deviceType, version) {
|
||||
});
|
||||
};
|
||||
|
||||
exports.versions = {
|
||||
signature: 'os versions <type>',
|
||||
description: 'show the available resinOS versions for the given device type',
|
||||
help: 'Use this command to show the available resinOS versions for a certain device type.\nCheck available types with `resin devices supported`\n\nExample:\n\n $ resin os versions raspberrypi3',
|
||||
action: function(params, options, done) {
|
||||
var resin;
|
||||
resin = require('resin-sdk-preconfigured');
|
||||
return resin.models.os.getSupportedVersions(params.type).then(function(arg) {
|
||||
var recommended, versions;
|
||||
versions = arg.versions, recommended = arg.recommended;
|
||||
return versions.forEach(function(v) {
|
||||
return console.log(formatVersion(v, v === recommended));
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
exports.download = {
|
||||
signature: 'os download <type>',
|
||||
description: 'download an unconfigured os image',
|
||||
@ -65,11 +82,7 @@ exports.download = {
|
||||
parameter: 'output',
|
||||
alias: 'o',
|
||||
required: 'You have to specify the output location'
|
||||
}, {
|
||||
signature: 'version',
|
||||
description: "exact version number, or a valid semver range,\nor 'latest' (includes pre-releases),\nor 'default' (excludes pre-releases if at least one stable version is available),\nor 'recommended' (excludes pre-releases, will fail if only pre-release versions are available),\nor 'menu' (will show the interactive menu)",
|
||||
parameter: 'version'
|
||||
}
|
||||
}, commandOptions.osVersion
|
||||
],
|
||||
action: function(params, options, done) {
|
||||
var Promise, displayVersion, fs, manager, rindle, unzip, visuals;
|
||||
|
@ -166,6 +166,8 @@ capitano.command(actions.env.rename);
|
||||
|
||||
capitano.command(actions.env.remove);
|
||||
|
||||
capitano.command(actions.os.versions);
|
||||
|
||||
capitano.command(actions.os.download);
|
||||
|
||||
capitano.command(actions.os.configure);
|
||||
|
@ -44,6 +44,17 @@ exports.booleanDevice =
|
||||
boolean: true
|
||||
alias: 'd'
|
||||
|
||||
exports.osVersion =
|
||||
signature: 'version'
|
||||
description: """
|
||||
exact version number, or a valid semver range,
|
||||
or 'latest' (includes pre-releases),
|
||||
or 'default' (excludes pre-releases if at least one stable version is available),
|
||||
or 'recommended' (excludes pre-releases, will fail if only pre-release versions are available),
|
||||
or 'menu' (will show the interactive menu)
|
||||
"""
|
||||
parameter: 'version'
|
||||
|
||||
exports.network =
|
||||
signature: 'network'
|
||||
parameter: 'network'
|
||||
|
@ -15,6 +15,7 @@ limitations under the License.
|
||||
###
|
||||
|
||||
commandOptions = require('./command-options')
|
||||
_ = require('lodash')
|
||||
|
||||
exports.list =
|
||||
signature: 'devices'
|
||||
@ -36,7 +37,6 @@ exports.list =
|
||||
primary: true
|
||||
action: (params, options, done) ->
|
||||
Promise = require('bluebird')
|
||||
_ = require('lodash')
|
||||
resin = require('resin-sdk-preconfigured')
|
||||
visuals = require('resin-cli-visuals')
|
||||
|
||||
@ -304,7 +304,6 @@ exports.rename =
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
Promise = require('bluebird')
|
||||
_ = require('lodash')
|
||||
resin = require('resin-sdk-preconfigured')
|
||||
form = require('resin-cli-form')
|
||||
|
||||
@ -335,7 +334,6 @@ exports.move =
|
||||
options: [ commandOptions.optionalApplication ]
|
||||
action: (params, options, done) ->
|
||||
resin = require('resin-sdk-preconfigured')
|
||||
_ = require('lodash')
|
||||
patterns = require('../utils/patterns')
|
||||
|
||||
resin.models.device.get(params.uuid).then (device) ->
|
||||
@ -373,6 +371,7 @@ exports.init =
|
||||
boolean: true
|
||||
alias: 'v'
|
||||
}
|
||||
_.assign({}, commandOptions.osVersion, { signature: 'os-version', parameter: 'os-version' })
|
||||
]
|
||||
permission: 'user'
|
||||
action: (params, options, done) ->
|
||||
@ -395,8 +394,8 @@ exports.init =
|
||||
|
||||
download = ->
|
||||
tmpNameAsync().then (tempPath) ->
|
||||
# TODO: allow version selection
|
||||
capitanoRunAsync("os download #{application.device_type} --output '#{tempPath}' --version default")
|
||||
osVersion = options['os-version'] or 'default'
|
||||
capitanoRunAsync("os download #{application.device_type} --output '#{tempPath}' --version #{osVersion}")
|
||||
.disposer (tempPath) ->
|
||||
return rimraf(tempPath)
|
||||
|
||||
|
@ -41,6 +41,25 @@ resolveVersion = (deviceType, version) ->
|
||||
choices: choices
|
||||
default: recommended
|
||||
|
||||
exports.versions =
|
||||
signature: 'os versions <type>'
|
||||
description: 'show the available resinOS 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`
|
||||
|
||||
Example:
|
||||
|
||||
$ resin os versions raspberrypi3
|
||||
'''
|
||||
action: (params, options, done) ->
|
||||
resin = require('resin-sdk-preconfigured')
|
||||
|
||||
resin.models.os.getSupportedVersions(params.type)
|
||||
.then ({ versions, recommended }) ->
|
||||
versions.forEach (v) ->
|
||||
console.log(formatVersion(v, v is recommended))
|
||||
|
||||
exports.download =
|
||||
signature: 'os download <type>'
|
||||
description: 'download an unconfigured os image'
|
||||
@ -73,17 +92,7 @@ exports.download =
|
||||
alias: 'o'
|
||||
required: 'You have to specify the output location'
|
||||
}
|
||||
{
|
||||
signature: 'version'
|
||||
description: """
|
||||
exact version number, or a valid semver range,
|
||||
or 'latest' (includes pre-releases),
|
||||
or 'default' (excludes pre-releases if at least one stable version is available),
|
||||
or 'recommended' (excludes pre-releases, will fail if only pre-release versions are available),
|
||||
or 'menu' (will show the interactive menu)
|
||||
"""
|
||||
parameter: 'version'
|
||||
}
|
||||
commandOptions.osVersion
|
||||
]
|
||||
action: (params, options, done) ->
|
||||
Promise = require('bluebird')
|
||||
|
@ -135,6 +135,7 @@ capitano.command(actions.env.rename)
|
||||
capitano.command(actions.env.remove)
|
||||
|
||||
# ---------- OS Module ----------
|
||||
capitano.command(actions.os.versions)
|
||||
capitano.command(actions.os.download)
|
||||
capitano.command(actions.os.configure)
|
||||
capitano.command(actions.os.initialize)
|
||||
|
Loading…
Reference in New Issue
Block a user