@cto.ai/ops
Version:
💻 CTO.ai - The CLI built for Teams 🚀
46 lines (45 loc) • 1.75 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const base_1 = tslib_1.__importStar(require("./../../base"));
const utils_1 = require("./../../utils");
const CustomErrors_1 = require("./../../errors/CustomErrors");
class ConfigsList extends base_1.default {
constructor() {
super(...arguments);
this.logConfigValue = async (inputs) => {
this.log('');
this.log(inputs.selectedConfig.value);
return inputs;
};
this.sendAnalytics = async (inputs) => {
try {
const { config, teamConfigs } = inputs;
this.services.analytics.track('Ops CLI Configs:List', {
username: config.user.username,
results: teamConfigs.length,
}, config);
}
catch (err) {
this.debug('%O', err);
throw new CustomErrors_1.AnalyticsError(err);
}
};
}
async run() {
this.parse(ConfigsList);
try {
const config = await this.isLoggedIn();
const configsListPipeline = (0, utils_1.asyncPipe)(this.logConfigValue, this.sendAnalytics);
const inputs = await this.services.configService.runListPipeline(config, this.services.api);
await configsListPipeline(inputs);
}
catch (err) {
this.debug('%O', err);
this.config.runHook('error', { err, accessToken: this.accessToken });
}
}
}
exports.default = ConfigsList;
ConfigsList.description = 'List all the configs that are stored for the active team';
ConfigsList.flags = { help: base_1.flags.help({ char: 'h' }) };