-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feat: show more info on server start #18721
base: v5
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import readline from 'node:readline' | |
import colors from 'picocolors' | ||
import type { RollupError } from 'rollup' | ||
import type { ResolvedServerUrls } from './server' | ||
import { getLoadedEnvFileNamesForMode } from './env' | ||
|
||
export type LogType = 'error' | 'warn' | 'info' | ||
export type LogLevel = LogType | 'silent' | ||
|
@@ -158,19 +159,31 @@ export function createLogger( | |
return logger | ||
} | ||
|
||
export function printServerUrls( | ||
export function printServerInfo( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, we don't have to have a dedicated shortcut to show loaded env files and it's fine to print them with other info on server start and on demand. What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we could also print them indeed, maybe a shortcut is overengineered |
||
urls: ResolvedServerUrls, | ||
optionsHost: string | boolean | undefined, | ||
mode: string, | ||
envDir: string, | ||
info: Logger['info'], | ||
): void { | ||
const colorUrl = (url: string) => | ||
colors.cyan(url.replace(/:(\d+)\//, (_, port) => `:${colors.bold(port)}/`)) | ||
const formatUrl = (url: string) => | ||
url.replace(/:(\d+)\//, (_, port) => `:${colors.bold(port)}/`) | ||
|
||
for (const url of urls.local) { | ||
info(` ${colors.green('➜')} ${colors.bold('Local')}: ${colorUrl(url)}`) | ||
info( | ||
` ${colors.green('➜')} ${colors.bold('Local')}: ${colors.cyan(formatUrl(url))}`, | ||
) | ||
} | ||
for (const url of urls.network) { | ||
info(` ${colors.green('➜')} ${colors.bold('Network')}: ${colorUrl(url)}`) | ||
info( | ||
` ${colors.green('➜')} ${colors.bold('Network')}: ${colors.cyan(formatUrl(url))}`, | ||
) | ||
} | ||
info(` ${colors.green('➜')} ${colors.bold('Mode')}: ${mode}`) | ||
const envFiles = getLoadedEnvFileNamesForMode(mode, envDir) | ||
info( | ||
` ${colors.green('➜')} ${colors.bold('Env')}: ${envFiles.length ? envFiles.join(' ') : 'no env files loaded'}`, | ||
) | ||
if (urls.network.length === 0 && optionsHost === undefined) { | ||
info( | ||
colors.dim(` ${colors.green('➜')} ${colors.bold('Network')}: use `) + | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I keep deprecated property in documentation?