UNPKG

@cto.ai/ops-rc

Version:

šŸ’» CTO.ai Ops - The CLI built for Teams šŸš€

74 lines (73 loc) • 3.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const base_1 = tslib_1.__importStar(require("./../../base")); const env_1 = require("./../../constants/env"); const utils_1 = require("./../../utils"); const CustomErrors_1 = require("./../../errors/CustomErrors"); class AccountSignup extends base_1.default { constructor() { super(...arguments); this.logHelpMessage = () => { this.log(''); this.log(`šŸ’» ${this.ux.colors.multiBlue('CTO.ai Ops')} - ${this.ux.colors.actionBlue('The CLI built for Teams')} šŸš€`); this.log(''); this.log(`šŸ‘‹ ${this.ux.colors.white('Welcome to the')} ${this.ux.colors.callOutCyan('Ops CLI beta')}! \n`); this.log('ā” Let us know if you have questions...'); this.log(`šŸ“¬ You can always reach us by ${this.ux.url('email', `mailto:${env_1.INTERCOM_EMAIL}`)} ${this.ux.colors.dim(`(${env_1.INTERCOM_EMAIL})`)}.\n`); this.log(`āš”ļø Let's get you ${this.ux.colors.callOutCyan('started')}...`); }; this.logSignupWelcomeMessage = () => { this.log(`\nšŸŽ‰ Account sign up complete - Ready to go!\n`); this.log(`${this.ux.colors.actionBlue(`You're ready to build and share Ops with your team!`)}`); this.log(`Get started by trying the following commands:\n`); this.log(`${this.ux.colors.reset.green('→')} Search for an Op`); this.log(` ${utils_1.terminalText('ops search')}\n`); this.log(`${this.ux.colors.reset.green('→')} Create an Op`); this.log(` ${utils_1.terminalText('ops init')}\n`); this.log(`${this.ux.colors.reset.green('→')} Publish an Op`); this.log(` ${utils_1.terminalText('ops publish')}\n`); }; this.keycloakSignUpFlow = async () => { this.ux.spinner.start('Authenticating using Single Sign On'); const tokens = await this.services.keycloakService .keycloakSignUpFlow() .catch(() => { throw new CustomErrors_1.SSOError(); }); this.ux.spinner.stop('Finished'); return tokens; }; this.sendAnalytics = (config) => { try { this.services.analytics.track('Ops CLI Signup', { username: config.user.username, }, config); } catch (err) { this.debug('%O', err); throw new CustomErrors_1.AnalyticsError(err); } }; } async run() { this.parse(AccountSignup); try { await this.services.keycloakService.init(); this.logHelpMessage(); await this.invalidateKeycloakSession(); const signupPipeline = utils_1.asyncPipe(this.keycloakSignUpFlow, this.initConfig, this.sendAnalytics); await signupPipeline(); this.logSignupWelcomeMessage(); } catch (err) { this.debug('%O', err); this.config.runHook('error', { err }); } } } exports.default = AccountSignup; AccountSignup.description = 'Creates an account to use with ops CLI.'; AccountSignup.flags = { help: base_1.flags.help({ char: 'h' }), };