vtex
Version:
The platform for e-commerce apps
33 lines (32 loc) • 1.64 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateNotify = void 0;
const tslib_1 = require("tslib");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const update_notifier_1 = tslib_1.__importDefault(require("update-notifier"));
const Colors_1 = require("./api/constants/Colors");
const Messages_1 = require("./lib/constants/Messages");
const pkg = tslib_1.__importStar(require("../package.json"));
const utils_1 = require("./modules/utils");
const ONE_HOUR = 1000 * 60 * 60 * 1;
function updateNotify() {
const distTag = utils_1.getDistTag(pkg.version);
const notifier = update_notifier_1.default({ pkg, distTag, updateCheckInterval: ONE_HOUR });
if (notifier.update && notifier.update.latest !== utils_1.getSimpleVersion(pkg.version)) {
const oldVersion = utils_1.getSimpleVersion(notifier.update.current);
const latestVersion = notifier.update.latest;
const changelog = `https://github.com/vtex/toolbelt/blob/master/CHANGELOG.md`;
notifier.notify({
isGlobal: true,
// @ts-ignore
isYarnGlobal: true,
message: [
`A new version is available for the VTEX Toolbelt: ${chalk_1.default.dim(oldVersion)} → ${chalk_1.default.green(latestVersion)}`,
`To update, you must use the same method you used to install. As the following example(s):`,
...Messages_1.updateMessageSwitch(),
`Changelog: ${Colors_1.ColorifyConstants.URL_INTERACTIVE(changelog)}`,
].join('\n'),
});
}
}
exports.updateNotify = updateNotify;