alwaysai
Version:
The alwaysAI command-line interface (CLI)
46 lines • 2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.userLogin = void 0;
const chalk = require("chalk");
const alwayscli_1 = require("@alwaysai/alwayscli");
const cli_inputs_1 = require("../../cli-inputs");
const user_1 = require("../../components/user");
const util_1 = require("../../util");
const post_tracking_data_to_hubspot_1 = require("../../infrastructure/post-tracking-data-to-hubspot");
const infrastructure_1 = require("../../infrastructure");
exports.userLogin = (0, alwayscli_1.CliLeaf)({
name: 'login',
description: 'Log in to the alwaysAI Cloud',
namedInputs: {
yes: cli_inputs_1.yesCliInput,
email: cli_inputs_1.alwaysaiUserEmailCliInput,
password: cli_inputs_1.alwaysaiUserPasswordCliInput
},
async action(_, { yes, email, password }) {
if (yes) {
if (!email || !password) {
throw new alwayscli_1.CliUsageError((0, util_1.RequiredWithYesMessage)('email', 'password'));
}
await (0, user_1.alwaysaiUserLoginYesComponent)({
alwaysaiUserEmail: email,
alwaysaiUserPassword: password
});
}
else {
const authenticationClient = (0, infrastructure_1.CliAuthenticationClient)();
if (authenticationClient.isSignedIn()) {
await (0, post_tracking_data_to_hubspot_1.postTrackingDataToHubspot)('activated_cli', true);
const { email } = await authenticationClient.getInfo();
(0, util_1.echo)(`Already logged in as ${chalk.bold(email)}`);
}
else {
await (0, user_1.alwaysaiUserLoginPromptComponent)({
alwaysaiUserEmail: email,
alwaysaiUserPassword: password
});
await (0, post_tracking_data_to_hubspot_1.postTrackingDataToHubspot)('activated_cli', true);
}
}
}
});
//# sourceMappingURL=login.js.map