1 | // Type definitions for update-notifier 5.1
|
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
|
9 | import boxen = require('boxen');
|
10 | import ConfigStore = require('configstore');
|
11 |
|
12 | export = UpdateNotifier;
|
13 |
|
14 | /** Checks if there is an available update */
|
15 | declare function UpdateNotifier(settings?: UpdateNotifier.Settings): UpdateNotifier.UpdateNotifier;
|
16 |
|
17 | declare namespace UpdateNotifier {
|
18 | class UpdateNotifier {
|
19 | constructor(settings?: Settings);
|
20 |
|
21 | readonly config: ConfigStore;
|
22 | readonly update?: UpdateInfo | undefined;
|
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 | undefined;
|
39 | pkg?: Package | undefined;
|
40 | /**
|
41 | * @deprecated use `pkg.name`
|
42 | */
|
43 | packageName?: string | undefined;
|
44 | /**
|
45 | * @deprecated use `pkg.version`
|
46 | */
|
47 | packageVersion?: string | undefined;
|
48 | /** How often to check for updates */
|
49 | updateCheckInterval?: number | undefined;
|
50 | /** Allows notification to be shown when running as an npm script */
|
51 | shouldNotifyInNpmScript?: boolean | undefined;
|
52 | }
|
53 |
|
54 | interface NotifyOptions {
|
55 | /** Message that will be shown when an update is available */
|
56 | message?: string | undefined;
|
57 | /** Defer showing the notification to after the process has exited */
|
58 | defer?: boolean | undefined;
|
59 | /** Include the -g argument in the default message's npm i recommendation */
|
60 | isGlobal?: boolean | undefined;
|
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 | undefined;
|
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 | }
|