UNPKG

alwaysai

Version:

The alwaysAI command-line interface (CLI)

26 lines 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkUserIsLoggedInComponent = void 0; const alwayscli_1 = require("@alwaysai/alwayscli"); const logSymbols = require("log-symbols"); const alwaysai_user_login_prompt_component_1 = require("./alwaysai-user-login-prompt-component"); const constants_1 = require("../../constants"); const util_1 = require("../../util"); const infrastructure_1 = require("../../infrastructure"); const YOU_MUST_BE_LOGGED_IN = 'You must be logged in to run this command.'; const REGISTER_ACCOUNT = 'Need a free alwaysAI account? Hold CTRL/CMD and click here to get started'; async function checkUserIsLoggedInComponent(props) { const { yes } = props; if (!(0, infrastructure_1.CliAuthenticationClient)().isSignedIn()) { if (yes) { throw new alwayscli_1.CliTerseError(`${YOU_MUST_BE_LOGGED_IN} Please either re-run this command without the "yes" flag, or run "${constants_1.ALWAYSAI_CLI_EXECUTABLE_NAME} user login" and try again.`); } else { (0, util_1.echo)(`${logSymbols.warning} ${YOU_MUST_BE_LOGGED_IN}`); (0, util_1.echo)(`${logSymbols.info} ${REGISTER_ACCOUNT}: ${(0, infrastructure_1.getBaseURL)()}/register`); await (0, alwaysai_user_login_prompt_component_1.alwaysaiUserLoginPromptComponent)(); } } } exports.checkUserIsLoggedInComponent = checkUserIsLoggedInComponent; //# sourceMappingURL=check-user-is-logged-in-component.js.map