Skip to content

fix: polish and improve postinstall onboarding message #7248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const UPDATE_BOXEN_OPTIONS = {
borderStyle: 'round',
borderColor: NETLIFY_CYAN_HEX,
float: 'center',
// This is an intentional half-width space to work around a unicode padding math bug in boxen
title: '⬥ ',
titleAlignment: 'center',
}
Expand Down
60 changes: 28 additions & 32 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,11 @@ import { fileURLToPath } from 'node:url'
import process from 'node:process'
// eslint-disable-next-line no-restricted-imports
import chalk from 'chalk'
import boxen from 'boxen'

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

const identity = (message) => message

/**
*
* @param {string} message
* @param {Array<chalk['Color'] | chalk['Modifiers']>} styles
* @returns
*/
const format = (message, styles) => {
let func = identity
try {
func = chalk
styles.forEach((style) => {
func = func[style]
})
} catch {}
return func(message)
}
const NETLIFY_CYAN_HEX = '#28b5ac'

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

console.log('')
console.log(await format('Success! Netlify CLI has been installed!', ['greenBright', 'bold', 'underline']))
console.log('')
console.log('Your device is now configured to use Netlify CLI to deploy and manage your Netlify sites.')
console.log('')
console.log('Next steps:')
console.log('')
console.log(
` ${await format('netlify init', [
'cyanBright',
'bold',
])} Connect or create a Netlify site from current directory`,
boxen(
`Success! Netlify CLI has been installed!

You can now use Netlify CLI to develop, deploy, and manage your Netlify sites.

🚀 Now get building!`,
{
padding: 1,
margin: 1,
textAlignment: 'center',
borderStyle: 'round',
borderColor: NETLIFY_CYAN_HEX,
// This is an intentional half-width space to work around a unicode padding math bug in boxen
title: '⬥ ',
titleAlignment: 'center',
},
),
)
console.log('Next steps:')
console.log(` ${chalk.cyanBright.bold('netlify login')} Log in to your Netlify account`)
console.log(
` ${await format('netlify deploy', ['cyanBright', 'bold'])} Deploy the latest changes to your Netlify site`,
` ${chalk.cyanBright.bold('netlify init')} Connect or create a Netlify site from the current directory`,
)
console.log(` ${chalk.cyanBright.bold('netlify deploy')} Deploy the latest changes to your Netlify site`)
console.log(` ${chalk.cyanBright.bold('netlify help')} Find out what else you can do 👀`)
console.log('')
console.log(`For more help with the CLI, visit ${chalk.cyanBright.bold('https://developers.netlify.com/cli')}`)
console.log('')
console.log(`For more information on the CLI run ${await format('netlify help', ['cyanBright', 'bold'])}`)
console.log(`Or visit the docs at ${await format('https://cli.netlify.com', ['cyanBright', 'bold'])}`)
console.log(`For help with Netlify, visit ${chalk.cyanBright.bold('https://docs.netlify.com')}`)
console.log('')
}

Expand All @@ -73,7 +69,7 @@ const main = async () => {
try {
await fs.stat(path.resolve(__dirname, '../.git'))
} catch (err) {
if (err.code === 'ENOENT') {
if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {
isEndUserInstall = true
}
}
Expand Down
Loading