Skip to content

Commit 0bf2db7

Browse files
authored
feat: beautify update notif and link to release notes (#7237)
1 parent 759cc88 commit 0bf2db7

File tree

3 files changed

+212
-3
lines changed

3 files changed

+212
-3
lines changed

bin/run.js

+20-3
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,37 @@ import { maybeEnableCompileCache } from '../dist/utils/nodejs-compile-cache.js'
66
// 12 hours
77
const UPDATE_CHECK_INTERVAL = 432e5
88

9+
const NETLIFY_CYAN_HEX = '#28b5ac'
10+
const UPDATE_BOXEN_OPTIONS = {
11+
padding: 1,
12+
margin: 1,
13+
textAlignment: 'center',
14+
borderStyle: 'round',
15+
borderColor: NETLIFY_CYAN_HEX,
16+
float: 'center',
17+
title: '⬥ ',
18+
titleAlignment: 'center',
19+
}
20+
921
const main = async () => {
22+
const { default: chalk } = await import('chalk')
1023
const { default: updateNotifier } = await import('update-notifier')
24+
const { default: terminalLink } = await import('terminal-link')
1125
const { createMainCommand } = await import('../dist/commands/main.js')
1226
const { logError } = await import('../dist/utils/command-helpers.js')
1327
const { default: getPackageJson } = await import('../dist/utils/get-cli-package-json.js')
1428
const { runProgram } = await import('../dist/utils/run-program.js')
1529

16-
const pkg = await getPackageJson()
17-
1830
try {
31+
const pkg = await getPackageJson()
32+
const message = `Update available ${chalk.dim('{currentVersion}')}${chalk.green('{latestVersion}')}
33+
See what's new in the ${terminalLink('release notes', 'https://ntl.fyi/cli-versions')}
34+
35+
Run ${chalk.inverse.hex(NETLIFY_CYAN_HEX)('{updateCommand}')} to update`
1936
updateNotifier({
2037
pkg,
2138
updateCheckInterval: UPDATE_CHECK_INTERVAL,
22-
}).notify()
39+
}).notify({ message, boxenOptions: UPDATE_BOXEN_OPTIONS })
2340
} catch (error) {
2441
logError(`Error checking for updates: ${error?.toString()}`)
2542
}

package-lock.json

+191
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
"@types/semver": "7.7.0",
186186
"@types/serialize-javascript": "^5.0.4",
187187
"@types/source-map-support": "0.5.10",
188+
"@types/update-notifier": "^6.0.8",
188189
"@types/write-file-atomic": "4.0.3",
189190
"@types/ws": "8.18.1",
190191
"@vitest/coverage-v8": "3.1.1",

0 commit comments

Comments
 (0)