mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-23 15:32:22 +00:00
allow specifying the version
This commit is contained in:
parent
4231f50c4c
commit
3619b2f117
@ -22,7 +22,7 @@ commandOptions = require('./command-options');
|
|||||||
exports.download = {
|
exports.download = {
|
||||||
signature: 'os download <type>',
|
signature: 'os download <type>',
|
||||||
description: 'download an unconfigured os image',
|
description: 'download an unconfigured os image',
|
||||||
help: 'Use this command to download an unconfigured os image for a certain device type.\n\nExamples:\n\n $ resin os download parallella -o ../foo/bar/parallella.img',
|
help: 'Use this command to download an unconfigured os image for a certain device type.\nIf version is not specified the newest stable (non-pre-release) version of OS\nis downloaded if available, or the newest version otherwise (if all existing\nversions for the given device type are pre-release).\n\nExamples:\n\n $ resin os download raspberrypi3 -o ../foo/bar/raspberry-pi.img\n $ resin os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version 1.24.1\n $ resin os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version ^1.20.0\n $ resin os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version latest\n $ resin os download raspberrypi3 -o ../foo/bar/raspberry-pi.img --version default',
|
||||||
permission: 'user',
|
permission: 'user',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
@ -31,20 +31,32 @@ exports.download = {
|
|||||||
parameter: 'output',
|
parameter: 'output',
|
||||||
alias: 'o',
|
alias: 'o',
|
||||||
required: 'You have to specify the output location'
|
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)",
|
||||||
|
parameter: 'version'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
action: function(params, options, done) {
|
action: function(params, options, done) {
|
||||||
var fs, manager, rindle, unzip, visuals;
|
var displayVersion, fs, manager, rindle, unzip, version, visuals;
|
||||||
unzip = require('unzip2');
|
unzip = require('unzip2');
|
||||||
fs = require('fs');
|
fs = require('fs');
|
||||||
rindle = require('rindle');
|
rindle = require('rindle');
|
||||||
manager = require('resin-image-manager');
|
manager = require('resin-image-manager');
|
||||||
visuals = require('resin-cli-visuals');
|
visuals = require('resin-cli-visuals');
|
||||||
console.info("Getting device operating system for " + params.type);
|
console.info("Getting device operating system for " + params.type);
|
||||||
return manager.get(params.type, 'default').then(function(stream) {
|
version = options.version;
|
||||||
|
if (!version) {
|
||||||
|
version = 'default';
|
||||||
|
displayVersion = '';
|
||||||
|
console.warn('OS version is not specified, using the default version: the newest stable (non-pre-release) version if available, or the newest version otherwise (if all existing versions for the given device type are pre-release)');
|
||||||
|
} else {
|
||||||
|
displayVersion = " " + version;
|
||||||
|
}
|
||||||
|
return manager.get(params.type, version).then(function(stream) {
|
||||||
var bar, output, spinner;
|
var bar, output, spinner;
|
||||||
bar = new visuals.Progress('Downloading Device OS');
|
bar = new visuals.Progress("Downloading Device OS" + displayVersion);
|
||||||
spinner = new visuals.Spinner('Downloading Device OS (size unknown)');
|
spinner = new visuals.Spinner("Downloading Device OS" + displayVersion + " (size unknown)");
|
||||||
stream.on('progress', function(state) {
|
stream.on('progress', function(state) {
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
return bar.update(state);
|
return bar.update(state);
|
||||||
|
@ -21,18 +21,37 @@ exports.download =
|
|||||||
description: 'download an unconfigured os image'
|
description: 'download an unconfigured os image'
|
||||||
help: '''
|
help: '''
|
||||||
Use this command to download an unconfigured os image for a certain device type.
|
Use this command to download an unconfigured os image for a certain device type.
|
||||||
|
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
|
||||||
|
versions for the given device type are pre-release).
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
$ resin os download parallella -o ../foo/bar/parallella.img
|
$ 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
|
||||||
'''
|
'''
|
||||||
permission: 'user'
|
permission: 'user'
|
||||||
options: [
|
options: [
|
||||||
signature: 'output'
|
{
|
||||||
description: 'output path'
|
signature: 'output'
|
||||||
parameter: 'output'
|
description: 'output path'
|
||||||
alias: 'o'
|
parameter: 'output'
|
||||||
required: 'You have to specify the output location'
|
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)
|
||||||
|
"""
|
||||||
|
parameter: 'version'
|
||||||
|
}
|
||||||
]
|
]
|
||||||
action: (params, options, done) ->
|
action: (params, options, done) ->
|
||||||
unzip = require('unzip2')
|
unzip = require('unzip2')
|
||||||
@ -43,9 +62,20 @@ exports.download =
|
|||||||
|
|
||||||
console.info("Getting device operating system for #{params.type}")
|
console.info("Getting device operating system for #{params.type}")
|
||||||
|
|
||||||
manager.get(params.type, 'default').then (stream) ->
|
version = options.version
|
||||||
bar = new visuals.Progress('Downloading Device OS')
|
if not version
|
||||||
spinner = new visuals.Spinner('Downloading Device OS (size unknown)')
|
version = 'default'
|
||||||
|
displayVersion = ''
|
||||||
|
console.warn('OS version is not specified, using the default version:
|
||||||
|
the newest stable (non-pre-release) version if available,
|
||||||
|
or the newest version otherwise (if all existing
|
||||||
|
versions for the given device type are pre-release)')
|
||||||
|
else
|
||||||
|
displayVersion = " #{version}"
|
||||||
|
|
||||||
|
manager.get(params.type, version).then (stream) ->
|
||||||
|
bar = new visuals.Progress("Downloading Device OS#{displayVersion}")
|
||||||
|
spinner = new visuals.Spinner("Downloading Device OS#{displayVersion} (size unknown)")
|
||||||
|
|
||||||
stream.on 'progress', (state) ->
|
stream.on 'progress', (state) ->
|
||||||
if state?
|
if state?
|
||||||
|
Loading…
Reference in New Issue
Block a user