@cto.ai/ops
Version:
💻 CTO.ai Ops - The CLI built for Teams 🚀
28 lines (27 loc) • 1.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const sdk_1 = require("@cto.ai/sdk");
const utils_1 = require("../../utils");
const hook = async function (opts) {
try {
if (opts.Command.id === 'update')
return;
const config = await 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 utils_1.writeConfig(config, { lastUpdateCheckAt: today }, this.config.configDir);
const latest = await utils_1.getLatestVersion();
if (latest !== this.config.version) {
this.log(sdk_1.ux.colors.white(`⚠️ ${sdk_1.ux.colors.actionBlue('UPDATE AVAILABLE')} - The latest version of ${sdk_1.ux.colors.callOutCyan(`CTO.ai Ops CLI is ${latest}`)}.\nTo update to the latest version please run '${sdk_1.ux.colors.callOutCyan('ops update')}'\n`));
}
}
catch (err) {
this.debug('%O', err);
await this.config.runHook('error', { err });
}
};
exports.default = hook;