UNPKG

@szzbmy/lowcode-cli

Version:

🐇 lowcode-cli is an efficient cli tool for Rabbitpre plugin component secondary development. ❤️

40 lines (39 loc) 1.4 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkUpdate = exports.VERSION_RRG = void 0; /* * 检查CLI更新 * @Author: lilonglong * @Date: 2021-11-11 19:34:11 * @Last Modified by: chubiao Ni * @Last Modified time: 2022-04-14 17:24:54 */ const update_notifier_1 = __importDefault(require("update-notifier")); const config_1 = __importDefault(require("../config")); const logger_1 = __importDefault(require("./logger")); // 校验 lowcode-cli 版本号 exports.VERSION_RRG = /[a-zA-Z]/; async function checkUpdate() { const notifier = new update_notifier_1.default.UpdateNotifier({ pkg: config_1.default.cliPkgJson, updateCheckInterval: 0, shouldNotifyInNpmScript: true, }); try { const updateInfo = (await notifier.fetchInfo()); if (updateInfo.type === 'latest') return; notifier.config.set('update', updateInfo); notifier.check(); notifier.notify({ message: `发现新版本 ${updateInfo.latest} !\n\n运行 npm i @szzbmy/lowcode-cli@${updateInfo.latest} -g 命令来更新`, }); } catch (e) { logger_1.default.error('检查更新错误', e); } } exports.checkUpdate = checkUpdate;