balena-cli
Version:
The official balena Command Line Interface
61 lines (58 loc) • 2.65 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const cf = require("../../utils/common-flags");
const lazy_1 = require("../../utils/lazy");
class ConfigReconfigureCmd extends core_1.Command {
async run() {
const { flags: options } = await this.parse(ConfigReconfigureCmd);
const { safeUmount } = await Promise.resolve().then(() => require('../../utils/umount'));
const drive = options.drive || (await (0, lazy_1.getVisuals)().drive('Select the device drive'));
await safeUmount(drive);
const config = await Promise.resolve().then(() => require('balena-config-json'));
const { uuid } = await config.read(drive, '');
await safeUmount(drive);
if (!uuid) {
const { ExpectedError } = await Promise.resolve().then(() => require('../../errors'));
throw new ExpectedError(`Error: UUID not found in 'config.json' file for '${drive}'`);
}
const configureCommand = ['os', 'configure', drive, '--device', uuid];
if (options.version) {
configureCommand.push('--version', options.version);
}
if (options.advanced) {
configureCommand.push('--advanced');
}
const { runCommand } = await Promise.resolve().then(() => require('../../utils/helpers'));
await runCommand(configureCommand);
console.info('Done');
}
}
ConfigReconfigureCmd.description = (0, lazy_1.stripIndent) `
Interactively reconfigure a balenaOS image file or attached media.
Interactively reconfigure a balenaOS image file or attached media.
This command extracts the device UUID from the 'config.json' file of the
chosen balenaOS image file or attached media, and then passes the UUID as
the '--device' argument to the 'balena os configure' command.
For finer-grained or scripted control of the operation, use the
'balena config read' and 'balena os configure' commands separately.
`;
ConfigReconfigureCmd.examples = [
'$ balena config reconfigure',
'$ balena config reconfigure --drive /dev/disk3',
'$ balena config reconfigure --drive balena.img --advanced',
];
ConfigReconfigureCmd.flags = {
drive: cf.driveOrImg,
advanced: core_1.Flags.boolean({
description: 'show advanced commands',
char: 'v',
}),
version: core_1.Flags.string({
description: 'balenaOS version, for example "2.32.0" or "2.44.0+rev1"',
}),
};
ConfigReconfigureCmd.authenticated = true;
ConfigReconfigureCmd.root = true;
exports.default = ConfigReconfigureCmd;
//# sourceMappingURL=reconfigure.js.map
;