balena-cli
Version:
The official balena Command Line Interface
65 lines (63 loc) • 2.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const _ = require("lodash");
const lazy_1 = require("../../utils/lazy");
class DeviceTypeListCmd extends core_1.Command {
async run() {
const { flags: options } = await this.parse(DeviceTypeListCmd);
const pineOptions = {
$select: ['slug', 'name'],
$expand: {
is_of__cpu_architecture: { $select: 'slug' },
device_type_alias: {
$select: 'is_referenced_by__alias',
$orderby: { is_referenced_by__alias: 'asc' },
},
},
};
const dts = options.all
? await (0, lazy_1.getBalenaSdk)().models.deviceType.getAll(pineOptions)
: await (0, lazy_1.getBalenaSdk)().models.deviceType.getAllSupported(pineOptions);
let deviceTypes = dts.map((dt) => {
var _a, _b, _c;
const aliases = dt.device_type_alias
.map((dta) => dta.is_referenced_by__alias)
.filter((alias) => alias !== dt.slug);
return {
slug: dt.slug,
aliases: options.json ? aliases : [aliases.join(', ')],
arch: (_b = (_a = dt.is_of__cpu_architecture[0]) === null || _a === void 0 ? void 0 : _a.slug) !== null && _b !== void 0 ? _b : 'n/a',
name: (_c = dt.name) !== null && _c !== void 0 ? _c : 'N/A',
};
});
const fields = ['slug', 'aliases', 'arch', 'name'];
deviceTypes = _.sortBy(deviceTypes, fields);
if (options.json) {
return JSON.stringify(deviceTypes, null, 4);
}
const visuals = (0, lazy_1.getVisuals)();
const output = visuals.table.horizontal(deviceTypes, fields);
console.log(output);
}
}
DeviceTypeListCmd.enableJsonFlag = true;
DeviceTypeListCmd.description = (0, lazy_1.stripIndent) `
List the device types supported by balena (like 'raspberrypi3' or 'intel-nuc').
List the device types supported by balena (like 'raspberrypi3' or 'intel-nuc').
By default, only actively supported device types are listed.
The --all option can be used to list all device types, including those that are
no longer supported by balena.
`;
DeviceTypeListCmd.examples = [
'$ balena device-type list',
'$ balena device-type list --all',
];
DeviceTypeListCmd.flags = {
all: core_1.Flags.boolean({
description: 'include device types no longer supported by balena',
default: false,
}),
};
exports.default = DeviceTypeListCmd;
//# sourceMappingURL=list.js.map