UNPKG

2.75 kBTypeScriptView Raw
1// Type definitions for update-notifier 5.0
2// Project: https://github.com/yeoman/update-notifier
3// Definitions by: vvakame <https://github.com/vvakame>
4// Noah Chen <https://github.com/nchen63>
5// Jason Dreyzehner <https://github.com/bitjson>
6// Michael Grinich <https://github.com/grinich>
7// Piotr Błażejewicz <https://github.com/peterblazejewicz>
8// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
9import boxen = require('boxen');
10import ConfigStore = require('configstore');
11
12export = UpdateNotifier;
13
14/** Checks if there is an available update */
15declare function UpdateNotifier(settings?: UpdateNotifier.Settings): UpdateNotifier.UpdateNotifier;
16
17declare namespace UpdateNotifier {
18 class UpdateNotifier {
19 constructor(settings?: Settings);
20
21 readonly config: ConfigStore;
22 readonly update?: UpdateInfo;
23 check(): void;
24 /**
25 * Check update information
26 * @async
27 */
28 fetchInfo(): UpdateInfo | Promise<UpdateInfo>;
29 /** Convenience method to display a notification message */
30 notify(customMessage?: NotifyOptions): void;
31 }
32
33 interface Settings {
34 /**
35 * Which dist-tag to use to find the latest version
36 * @default 'latest'
37 */
38 distTag?: string;
39 pkg?: Package;
40 /**
41 * @deprecated use `pkg.name`
42 */
43 packageName?: string;
44 /**
45 * @deprecated use `pkg.version`
46 */
47 packageVersion?: string;
48 /** How often to check for updates */
49 updateCheckInterval?: number;
50 /** Allows notification to be shown when running as an npm script */
51 shouldNotifyInNpmScript?: boolean;
52 }
53
54 interface NotifyOptions {
55 /** Message that will be shown when an update is available */
56 message?: string;
57 /** Defer showing the notification to after the process has exited */
58 defer?: boolean;
59 /** Include the -g argument in the default message's npm i recommendation */
60 isGlobal?: boolean;
61 /**
62 * Options object that will be passed to `boxen`
63 * See https://github.com/sindresorhus/boxen/blob/master/index.d.ts
64 */
65 boxenOptions?: boxen.Options;
66 }
67
68 interface Package {
69 name: string;
70 version: string;
71 }
72
73 interface UpdateInfo {
74 /** Latest version */
75 readonly latest: string;
76 /** Current version */
77 readonly current: string;
78 /** Type of current update */
79 readonly type: 'latest' | 'major' | 'minor' | 'patch' | 'prerelease' | 'build';
80 /** Package name */
81 name: string;
82 }
83}