UNPKG

@cto.ai/ops

Version:

💻 CTO.ai - The CLI built for Teams 🚀

28 lines (27 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const cli_sdk_1 = require("@cto.ai/cli-sdk"); const utils_1 = require("./../../utils"); const hook = async function (opts) { try { if (opts.Command.id === 'update') return; const config = await (0, utils_1.readConfig)(this.config.configDir); const today = new Date(); if (config.lastUpdateCheckAt && today.getTime() - new Date(config.lastUpdateCheckAt).getTime() < 24 * 60 * 60 * 1000) { return; } await (0, utils_1.writeConfig)(config, { lastUpdateCheckAt: today }, this.config.configDir); const latest = await (0, utils_1.getLatestVersion)(); if (latest !== this.config.version) { this.log(cli_sdk_1.ux.colors.white(`⚠️ ${cli_sdk_1.ux.colors.actionBlue('UPDATE AVAILABLE')} - The latest version of ${cli_sdk_1.ux.colors.callOutCyan(`The Ops CLI is ${latest}`)}.\nTo update to the latest version please run '${cli_sdk_1.ux.colors.callOutCyan('ops update')}'\n`)); } } catch (err) { this.debug('%O', err); await this.config.runHook('error', { err }); } }; exports.default = hook;