1
1
import type { request as RequestT } from "undici" ;
2
2
3
+ import boxen from "boxen" ;
4
+ import chalk from "chalk" ;
3
5
import { join } from "node:path" ;
4
6
import { mkdir , readFile , writeFile } from "node:fs/promises" ;
5
7
import semver from "semver" ;
14
16
const V3_RELEASE_VERSION_NOTIFIER_ASSET_NAME = "version-notifier-message.txt" ;
15
17
const V3_RELEASE_MAX_TIMES_SHOWN = 5 ;
16
18
19
+ const boxenOptions = {
20
+ padding : 1 ,
21
+ borderStyle : "round" ,
22
+ borderColor : "yellow" ,
23
+ } as const ;
24
+
17
25
interface VersionNotifierCache {
18
26
lastCheck : string | 0 ;
19
27
v3TimesShown : number ;
20
28
v3Release ?: Release ;
21
29
v3ReleaseMessage ?: string ;
22
30
}
23
31
32
+ /* eslint-disable @typescript-eslint/naming-convention */
24
33
interface Release {
25
34
name : string ;
26
- // eslint-disable-next-line @typescript-eslint/naming-convention
27
35
tag_name : string ;
28
36
draft : boolean ;
29
37
prerelease : boolean ;
30
- // eslint-disable-next-line @typescript-eslint/naming-convention
31
38
published_at : string ;
39
+ html_url : string ;
32
40
assets : Array < {
33
41
name : string ;
34
- // eslint-disable-next-line @typescript-eslint/naming-convention
35
42
browser_download_url : string ;
36
43
} > ;
37
44
body : string ; // release notes
38
45
}
46
+ /* eslint-enable @typescript-eslint/naming-convention */
39
47
40
48
export async function showNewVersionNotification ( ) {
41
49
const cache = await readCache ( ) ;
@@ -78,7 +86,16 @@ export async function showNewVersionNotification() {
78
86
79
87
if ( releaseVersion !== null && semver . gt ( releaseVersion , hardhatVersion ) ) {
80
88
console . log (
81
- `There's a new version of ${ GITHUB_REPO } available: ${ releaseVersion } ! Run "npm i ${ GITHUB_REPO } @${ releaseVersion } " to update.\n`
89
+ boxen (
90
+ `New Hardhat release available! ${ chalk . red (
91
+ hardhatVersion
92
+ ) } -> ${ chalk . green ( releaseVersion ) } .
93
+
94
+ Changelog: https://hardhat.org/release/${ releaseVersion }
95
+
96
+ Run "npm install hardhat@latest" to update.` ,
97
+ boxenOptions
98
+ )
82
99
) ;
83
100
}
84
101
}
@@ -91,7 +108,7 @@ export async function showNewVersionNotification() {
91
108
cache . v3ReleaseMessage =
92
109
cache . v3ReleaseMessage ?? ( await getV3ReleaseMessage ( v3Release ) ) ;
93
110
if ( cache . v3ReleaseMessage !== undefined ) {
94
- console . log ( cache . v3ReleaseMessage ) ;
111
+ console . log ( boxen ( cache . v3ReleaseMessage , boxenOptions ) ) ;
95
112
cache . v3TimesShown ++ ;
96
113
}
97
114
}
0 commit comments