@cto.ai/ops-rc
Version:
š» CTO.ai Ops - The CLI built for Teams š
74 lines (73 loc) ⢠3.35 kB
JavaScript
;
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' }),
};