UNPKG

alwaysai

Version:

The alwaysAI command-line interface (CLI)

52 lines 2.59 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const alwayscli_1 = require("@alwaysai/alwayscli"); const yes_cli_input_1 = require("../../cli-inputs/yes-cli-input"); const app_configure_component_1 = require("../../components/app-configure-component"); const target_protocol_cli_input_1 = require("../../cli-inputs/target-protocol-cli-input"); const target_hostname_cli_input_1 = require("../../cli-inputs/target-hostname-cli-input"); const target_path_cli_input_1 = require("../../cli-inputs/target-path-cli-input"); const not_allowed_with_message_1 = require("../../util/not-allowed-with-message"); const required_with_yes_message_1 = require("../../util/required-with-yes-message"); const os_1 = require("os"); exports.appConfigureCliLeaf = alwayscli_1.createLeaf({ name: 'configure', description: 'Configure your application and deployment target', options: { yes: yes_cli_input_1.yesCliInput, protocol: target_protocol_cli_input_1.targetProtocolCliInput, hostname: target_hostname_cli_input_1.targetHostnameCliInput, path: target_path_cli_input_1.targetPathCliInput, }, async action(_, opts) { switch (opts.protocol) { case 'docker:': { if (os_1.platform() !== 'linux') { throw new alwayscli_1.UsageError(`Option "protocol" is not allowed to have value "${opts.protocol}" if your operating system platform is "${os_1.platform}"`); } if (opts.hostname) { throw new alwayscli_1.UsageError(not_allowed_with_message_1.NotAllowedWithMessage('hostname', 'protocol', opts.protocol)); } if (opts.path) { throw new alwayscli_1.UsageError(not_allowed_with_message_1.NotAllowedWithMessage('path', 'protocol', opts.protocol)); } break; } case 'ssh+docker:': { if (opts.yes) { if (!opts.hostname) { throw new alwayscli_1.UsageError(required_with_yes_message_1.RequiredWithYesMessage('hostname', undefined, `If "protocol" is "${opts.protocol}"`)); } } break; } } return await app_configure_component_1.appConfigureComponent({ yes: opts.yes, targetProtocol: opts.protocol || 'ssh+docker:', targetHostname: opts.hostname || '', targetPath: opts.path, }); }, }); //# sourceMappingURL=configure.js.map