From 5d3625f6aee641e9775af750033a23ba15f01bba Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Tue, 14 Jul 2020 11:24:41 +0200 Subject: [PATCH] Remove `os download` command dependency for `device init` Change-type: patch Signed-off-by: Scott Lowe --- lib/actions-oclif/device/init.ts | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lib/actions-oclif/device/init.ts b/lib/actions-oclif/device/init.ts index 9e3c0c44..2f95a438 100644 --- a/lib/actions-oclif/device/init.ts +++ b/lib/actions-oclif/device/init.ts @@ -92,6 +92,7 @@ export default class DeviceInitCmd extends Command { const tmpNameAsync = promisify(tmp.tmpName); tmp.setGracefulCleanup(); const balena = getBalenaSdk(); + const { downloadOSImage } = await import('../../utils/cloud'); const Logger = await import('../../utils/logger'); const logger = Logger.getLogger(); @@ -116,7 +117,8 @@ export default class DeviceInitCmd extends Command { const tmpPath = (await tmpNameAsync()) as string; try { logger.logDebug(`Downloading OS image...`); - await this.downloadOsImage(tmpPath, application.device_type, options); + const osVersion = options['os-version'] || 'default'; + await downloadOSImage(application.device_type, tmpPath, osVersion); logger.logDebug(`Configuring OS image...`); await this.configureOsImage(tmpPath, device.uuid, options); @@ -142,19 +144,6 @@ export default class DeviceInitCmd extends Command { return device.uuid; } - async downloadOsImage(path: string, deviceType: string, options: FlagsDef) { - const osVersion = options['os-version'] || 'default'; - await runCommand([ - 'os', - 'download', - deviceType, - '--output', - path, - '--version', - osVersion, - ]); - } - async configureOsImage(path: string, uuid: string, options: FlagsDef) { const configureCommand = ['os', 'configure', path, '--device', uuid]; if (options.config) {