UNPKG

2.05 kBTypeScriptView Raw
1import ConfigStore from "configstore";
2
3import type { Options as BoxenOptions } from "boxen";
4
5export default class UpdateNotifier {
6 constructor(settings: Settings);
7 readonly config?: ConfigStore | undefined;
8 readonly update?: UpdateInfo | undefined;
9 check(): void;
10 /**
11 * Check update information
12 * @async
13 */
14 fetchInfo(): UpdateInfo | Promise<UpdateInfo>;
15 /** Convenience method to display a notification message */
16 notify(customMessage?: NotifyOptions): void;
17}
18
19interface Settings {
20 /**
21 * Which dist-tag to use to find the latest version
22 * @default 'latest'
23 */
24 distTag?: string | undefined;
25 pkg?: Package | undefined;
26 /**
27 * @deprecated use `pkg.name`
28 */
29 packageName?: string | undefined;
30 /**
31 * @deprecated use `pkg.version`
32 */
33 packageVersion?: string | undefined;
34 /** How often to check for updates */
35 updateCheckInterval?: number | undefined;
36 /** Allows notification to be shown when running as an npm script */
37 shouldNotifyInNpmScript?: boolean | undefined;
38}
39
40interface NotifyOptions {
41 /** Message that will be shown when an update is available */
42 message?: string | undefined;
43 /** Defer showing the notification to after the process has exited */
44 defer?: boolean | undefined;
45 /** Include the -g argument in the default message's npm i recommendation */
46 isGlobal?: boolean | undefined;
47 /**
48 * Options object that will be passed to `boxen`
49 * See https://github.com/sindresorhus/boxen/blob/master/index.d.ts
50 */
51 boxenOptions?: BoxenOptions | undefined;
52}
53
54interface Package {
55 name: string;
56 version: string;
57}
58
59interface UpdateInfo {
60 /** Latest version */
61 readonly latest: string;
62 /** Current version */
63 readonly current: string;
64 /** Type of current update */
65 readonly type: "latest" | "major" | "minor" | "patch" | "prerelease" | "build";
66 /** Package name */
67 name: string;
68}
69
70export type { NotifyOptions, Package, Settings, UpdateInfo };