balena-cli
Version:
The official balena Command Line Interface
55 lines (53 loc) • 2.14 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const lazy_1 = require("../../utils/lazy");
const pine_1 = require("../../utils/pine");
class DevicePinCmd extends core_1.Command {
async run() {
const { args: params } = await this.parse(DevicePinCmd);
const balena = (0, lazy_1.getBalenaSdk)();
const device = await balena.models.device.get(params.uuid, {
$expand: {
is_pinned_on__release: {
$select: 'commit',
},
belongs_to__application: {
$select: 'slug',
},
},
});
const pinnedRelease = (0, pine_1.getExpandedProp)(device.is_pinned_on__release, 'commit');
const appSlug = (0, pine_1.getExpandedProp)(device.belongs_to__application, 'slug');
const releaseToPinTo = params.releaseToPinTo;
if (!releaseToPinTo) {
console.log(`${pinnedRelease
? `This device is currently pinned to ${pinnedRelease}.`
: 'This device is not currently pinned to any release.'} \n\nTo see a list of all releases this device can be pinned to, run \`balena release list ${appSlug}\`.`);
}
else {
await balena.models.device.pinToRelease(params.uuid, releaseToPinTo);
}
}
}
DevicePinCmd.description = (0, lazy_1.stripIndent) `
Pin a device to a release.
Pin a device to a release.
Note, if the commit is omitted, the currently pinned release will be printed, with instructions for how to see a list of releases
`;
DevicePinCmd.examples = [
'$ balena device pin 7cf02a6',
'$ balena device pin 7cf02a6 91165e5',
];
DevicePinCmd.args = {
uuid: core_1.Args.string({
description: 'the uuid of the device to pin to a release',
required: true,
}),
releaseToPinTo: core_1.Args.string({
description: 'the commit of the release for the device to get pinned to',
}),
};
DevicePinCmd.authenticated = true;
exports.default = DevicePinCmd;
//# sourceMappingURL=pin.js.map
;