alwaysai
Version:
The alwaysAI command-line interface (CLI)
38 lines • 1.91 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const os_1 = require("os");
const prompt_1 = require("../util/prompt");
const alwayscli_1 = require("@alwaysai/alwayscli");
const target_protocol_1 = require("../util/target-protocol");
async function targetProtocolPromptedInputComponent(props) {
const developerHostPlatform = props.developerHostPlatform || os_1.platform();
if (developerHostPlatform !== 'linux') {
return target_protocol_1.TargetProtocol['ssh+docker:'];
}
const nonInteractiveStreamName = prompt_1.getNonInteractiveStreamName();
if (nonInteractiveStreamName) {
throw new alwayscli_1.UsageError(`We were about to prompt you to choose whether you want to run your application here on this computer or on a remote device, but this shell is not fully interactive. ("${nonInteractiveStreamName}" is not a TTY.) You can re-run this command in a fully interactive shell, or you can provide the "protocol" command-line option together with the "yes" flag, which disables interactive prompts.`);
}
const choices = [
{ title: 'Your local computer', value: target_protocol_1.TargetProtocol['docker:'] },
{
title: 'Remote device',
value: target_protocol_1.TargetProtocol['ssh+docker:'],
},
];
const foundChoiceIndex = choices.findIndex(choice => choice.value === props.targetProtocol);
const initial = foundChoiceIndex > -1 ? foundChoiceIndex : 0;
const answer = await prompt_1.prompt([
{
type: 'select',
name: 'protocol',
message: 'What is the destination?',
initial,
choices,
},
]);
const protocol = answer.protocol;
return protocol;
}
exports.targetProtocolPromptedInputComponent = targetProtocolPromptedInputComponent;
//# sourceMappingURL=target-protocol-input-component.js.map