device os-update: Add option for including pre-release versions in the list

Change-type: minor
This commit is contained in:
Thodoris Greasidis 2024-01-22 17:02:25 +02:00
parent 1166533482
commit cdada0aec8
2 changed files with 14 additions and 2 deletions

View File

@ -1454,6 +1454,7 @@ Examples:
$ balena device os-update 23c73a1
$ balena device os-update 23c73a1 --version 2.101.7
$ balena device os-update 23c73a1 --version 2.31.0+rev1.prod
$ balena device os-update 23c73a1 --include-draft
### Arguments
@ -1467,6 +1468,10 @@ the uuid of the device to update
a balenaOS version
#### --include-draft
include pre-release balenaOS versions
#### -y, --yes
answer "yes" to all questions (non interactive use)

View File

@ -37,6 +37,7 @@ export default class DeviceOsUpdateCmd extends Command {
'$ balena device os-update 23c73a1',
'$ balena device os-update 23c73a1 --version 2.101.7',
'$ balena device os-update 23c73a1 --version 2.31.0+rev1.prod',
'$ balena device os-update 23c73a1 --include-draft',
];
public static args = {
@ -51,6 +52,12 @@ export default class DeviceOsUpdateCmd extends Command {
public static flags = {
version: Flags.string({
description: 'a balenaOS version',
exclusive: ['include-draft'],
}),
'include-draft': Flags.boolean({
description: 'include pre-release balenaOS versions',
default: false,
exclusive: ['version'],
}),
yes: cf.yes,
help: cf.help,
@ -86,8 +93,8 @@ export default class DeviceOsUpdateCmd extends Command {
);
}
let includeDraft = false;
if (options.version != null) {
let includeDraft = options['include-draft'];
if (!includeDraft && options.version != null) {
const bSemver = await import('balena-semver');
const parsedVersion = bSemver.parse(options.version);
// When the user provides a draft version, we need to pass `includeDraft`