Skip to content

Commit d9523c7

Browse files
authored
fix: polish and improve postinstall onboarding message (#7248)
* refactor: simplify and type-check postinstall script * fix: polish postinstall script - Use a pretty cyan box with the Netlify diamond icon - Mention `ntl login` as a likely first step - Link to better CLI entrypoint URL - Link to main Netlify docs
1 parent 841d782 commit d9523c7

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

bin/run.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const UPDATE_BOXEN_OPTIONS = {
1414
borderStyle: 'round',
1515
borderColor: NETLIFY_CYAN_HEX,
1616
float: 'center',
17+
// This is an intentional half-width space to work around a unicode padding math bug in boxen
1718
title: '⬥ ',
1819
titleAlignment: 'center',
1920
}

scripts/postinstall.js

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,11 @@ import { fileURLToPath } from 'node:url'
99
import process from 'node:process'
1010
// eslint-disable-next-line no-restricted-imports
1111
import chalk from 'chalk'
12+
import boxen from 'boxen'
1213

1314
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1415

15-
const identity = (message) => message
16-
17-
/**
18-
*
19-
* @param {string} message
20-
* @param {Array<chalk['Color'] | chalk['Modifiers']>} styles
21-
* @returns
22-
*/
23-
const format = (message, styles) => {
24-
let func = identity
25-
try {
26-
func = chalk
27-
styles.forEach((style) => {
28-
func = func[style]
29-
})
30-
} catch {}
31-
return func(message)
32-
}
16+
const NETLIFY_CYAN_HEX = '#28b5ac'
3317

3418
const postInstall = async () => {
3519
const { createMainCommand } = await import('../dist/commands/index.js')
@@ -44,25 +28,37 @@ const postInstall = async () => {
4428
generateAutocompletion(program)
4529
}
4630

47-
console.log('')
48-
console.log(await format('Success! Netlify CLI has been installed!', ['greenBright', 'bold', 'underline']))
49-
console.log('')
50-
console.log('Your device is now configured to use Netlify CLI to deploy and manage your Netlify sites.')
51-
console.log('')
52-
console.log('Next steps:')
5331
console.log('')
5432
console.log(
55-
` ${await format('netlify init', [
56-
'cyanBright',
57-
'bold',
58-
])} Connect or create a Netlify site from current directory`,
33+
boxen(
34+
`Success! Netlify CLI has been installed!
35+
36+
You can now use Netlify CLI to develop, deploy, and manage your Netlify sites.
37+
38+
🚀 Now get building!`,
39+
{
40+
padding: 1,
41+
margin: 1,
42+
textAlignment: 'center',
43+
borderStyle: 'round',
44+
borderColor: NETLIFY_CYAN_HEX,
45+
// This is an intentional half-width space to work around a unicode padding math bug in boxen
46+
title: '⬥ ',
47+
titleAlignment: 'center',
48+
},
49+
),
5950
)
51+
console.log('Next steps:')
52+
console.log(` ${chalk.cyanBright.bold('netlify login')} Log in to your Netlify account`)
6053
console.log(
61-
` ${await format('netlify deploy', ['cyanBright', 'bold'])} Deploy the latest changes to your Netlify site`,
54+
` ${chalk.cyanBright.bold('netlify init')} Connect or create a Netlify site from the current directory`,
6255
)
56+
console.log(` ${chalk.cyanBright.bold('netlify deploy')} Deploy the latest changes to your Netlify site`)
57+
console.log(` ${chalk.cyanBright.bold('netlify help')} Find out what else you can do 👀`)
58+
console.log('')
59+
console.log(`For more help with the CLI, visit ${chalk.cyanBright.bold('https://developers.netlify.com/cli')}`)
6360
console.log('')
64-
console.log(`For more information on the CLI run ${await format('netlify help', ['cyanBright', 'bold'])}`)
65-
console.log(`Or visit the docs at ${await format('https://cli.netlify.com', ['cyanBright', 'bold'])}`)
61+
console.log(`For help with Netlify, visit ${chalk.cyanBright.bold('https://docs.netlify.com')}`)
6662
console.log('')
6763
}
6864

@@ -73,7 +69,7 @@ const main = async () => {
7369
try {
7470
await fs.stat(path.resolve(__dirname, '../.git'))
7571
} catch (err) {
76-
if (err.code === 'ENOENT') {
72+
if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
7773
isEndUserInstall = true
7874
}
7975
}

0 commit comments

Comments
 (0)