os download: Use the hostApps instead of the device-types/v1 endpoint

Connects-to: #2318
Change-type: patch
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
This commit is contained in:
Thodoris Greasidis 2021-08-30 22:04:48 +00:00
parent a8c2724929
commit d34073f695

View File

@ -188,18 +188,21 @@ async function resolveOSVersion(deviceType: string, version: string) {
return version;
}
const { versions: vs, recommended } =
await getBalenaSdk().models.os.getSupportedVersions(deviceType);
const vs = (
(await getBalenaSdk().models.hostapp.getAllOsVersions([deviceType]))[
deviceType
] ?? []
).filter((v) => v.osType === 'default');
const choices = vs.map((v) => ({
value: v,
name: `v${v}` + (v === recommended ? ' (recommended)' : ''),
value: v.rawVersion,
name: `v${v.rawVersion}` + (v.isRecommended ? ' (recommended)' : ''),
}));
return getCliForm().ask({
message: 'Select the OS version:',
type: 'list',
choices,
default: recommended,
default: (vs.find((v) => v.isRecommended) ?? vs[0])?.rawVersion,
});
}