alwaysai
Version:
The alwaysAI command-line interface (CLI)
35 lines • 1.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const prompt_1 = require("../util/prompt");
const alwayscli_1 = require("@alwaysai/alwayscli");
const constants_1 = require("../constants");
const alwaysai_user_login_component_1 = require("./alwaysai-user-login-component");
async function alwaysaiUserPromptedLoginComponent(props = {}) {
const nonInteractiveStreamName = prompt_1.getNonInteractiveStreamName();
if (nonInteractiveStreamName) {
throw new alwayscli_1.TerseError(`We were about to prompt you to enter your alwaysAI user account credentials, 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 authenticate first with the command "alwaysai user login".`);
}
const answers = await prompt_1.prompt([
{
type: 'text',
name: 'email',
message: 'Email address associated with your alwaysAI user:',
initial: props.alwaysaiUserEmail,
validate: value => constants_1.VALID_EMAIL_REGULAR_EXPRESSION.test(value) ||
`"${value}" is not a valid email address`,
},
{
type: 'password',
name: 'password',
message: 'Password',
initial: props.alwaysaiUserPassword,
validate: value => value.length >= 8 || 'Password must be eight or more characters',
},
]);
await alwaysai_user_login_component_1.alwaysaiUserLoginComponent({
alwaysaiUserEmail: answers.email,
alwaysaiUserPassword: answers.password,
});
}
exports.alwaysaiUserPromptedLoginComponent = alwaysaiUserPromptedLoginComponent;
//# sourceMappingURL=alwaysai-user-prompted-login-component.js.map