mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-07 12:47:49 +00:00
feat: add notification about available new version (#853)
Co-authored-by: Anton Kozachuk <antonkozachuk@Antons-MacBook-Pro.local>
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
stringifyYaml,
|
||||
} from '@redocly/openapi-core';
|
||||
import { Totals, outputExtensions, Entrypoint } from './types';
|
||||
import * as updateNotifier from 'update-notifier';
|
||||
|
||||
export async function getFallbackApisOrExit(
|
||||
argsApis: string[] | undefined,
|
||||
@@ -323,3 +324,16 @@ export function isSubdir(parent: string, dir: string): boolean {
|
||||
const relative = path.relative(parent, dir);
|
||||
return !!relative && !/^..($|\/)/.test(relative) && !path.isAbsolute(relative);
|
||||
}
|
||||
|
||||
export function notifyUpdateCliVersion() {
|
||||
const pkg = require('../package.json');
|
||||
const notifier = updateNotifier({
|
||||
pkg,
|
||||
updateCheckInterval: 0,
|
||||
shouldNotifyInNpmScript: true,
|
||||
});
|
||||
notifier.notify({
|
||||
message:
|
||||
'A new version of Redocly CLI ({latestVersion}) is available.\nUpdate now: `npx @redocly/cli@latest upgrade`.\nChangelog: https://redocly.com/docs/cli/changelog',
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user