From 34b4ac2d9f4a759a1e9c1f313bd2e6691f8f8c12 Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Tue, 11 Oct 2022 20:52:02 +0300 Subject: [PATCH] device register: Add support for the `--deviceType` option Resolves: #2531 Change-type: minor Signed-off-by: Thodoris Greasidis --- docs/balena-cli.md | 5 +++++ lib/commands/device/register.ts | 12 +++++++++++- npm-shrinkwrap.json | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/balena-cli.md b/docs/balena-cli.md index ddb1586b..2c83cc7e 100644 --- a/docs/balena-cli.md +++ b/docs/balena-cli.md @@ -1037,6 +1037,7 @@ Examples: $ balena device register MyFleet $ balena device register MyFleet --uuid $ balena device register myorg/myfleet --uuid + $ balena device register myorg/myfleet --uuid --deviceType ### Arguments @@ -1050,6 +1051,10 @@ fleet name or slug (preferred) custom uuid +#### --deviceType DEVICETYPE + +device type slug (run 'balena devices supported' for possible values) + ## device rename <uuid> [newName] Rename a device. diff --git a/lib/commands/device/register.ts b/lib/commands/device/register.ts index 89cc29eb..8389902f 100644 --- a/lib/commands/device/register.ts +++ b/lib/commands/device/register.ts @@ -25,6 +25,7 @@ import { applicationIdInfo } from '../../utils/messages'; interface FlagsDef { uuid?: string; + deviceType?: string; help: void; } @@ -47,6 +48,7 @@ export default class DeviceRegisterCmd extends Command { '$ balena device register MyFleet', '$ balena device register MyFleet --uuid ', '$ balena device register myorg/myfleet --uuid ', + '$ balena device register myorg/myfleet --uuid --deviceType ', ]; public static args: Array> = [ca.fleetRequired]; @@ -58,6 +60,10 @@ export default class DeviceRegisterCmd extends Command { description: 'custom uuid', char: 'u', }), + deviceType: flags.string({ + description: + "device type slug (run 'balena devices supported' for possible values)", + }), help: cf.help, }; @@ -77,7 +83,11 @@ export default class DeviceRegisterCmd extends Command { console.info(`Registering to ${application.slug}: ${uuid}`); - const result = await balena.models.device.register(application.id, uuid); + const result = await balena.models.device.register( + application.id, + uuid, + options.deviceType, + ); return result && result.uuid; } diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 629fb266..fc8d9626 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -4616,7 +4616,7 @@ "buffer-shims": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", - "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=" + "integrity": "sha512-Zy8ZXMyxIT6RMTeY7OP/bDndfj6bwCan7SS98CEndS6deHwWPpseeHlwarNcBim+etXnF9HBc1non5JgDaJU1g==" }, "buffers": { "version": "0.1.1", @@ -16909,7 +16909,7 @@ "bluebird": { "version": "3.4.7", "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz", - "integrity": "sha1-9y12C+Cbf3bQjtj66Ysomo0F+rM=" + "integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==" }, "process-nextick-args": { "version": "1.0.7",