Repository: withastro/astro
File: packages/upgrade/src/messages.ts (TypeScript)

Code before:
	log(`${label(prefix, color.bgCyan, color.black)}  ${text}`);
};

export const info = async (prefix: string, text: string, version = '') => {
	const length = 11 + prefix.length + text.length + version?.length;
	const symbol = '◼';
	if (length > stdout.columns) {
		log(`${' '.repeat(5)} ${color.cyan(symbol)}  ${prefix}`);
		log(`${' '.repeat(9)}${color.dim(text)} ${color.reset(version)}`);
	} else {
		log(
			`${' '.repeat(5)} ${color.cyan(symbol)}  ${prefix} ${color.dim(text)} ${color.reset(version)}`,
		);
	}
};

export const upgrade = async (packageInfo: PackageInfo, text: string) => {
	const { name, isMajor = false, targetVersion, currentVersion } = packageInfo;

	const bg = isMajor ? (v: string) => color.bgYellow(color.black(` ${v} `)) : color.green;
	const style = isMajor ? color.yellow : color.green;
	const symbol = isMajor ? '▲' : '●';

	const fromVersion = currentVersion.replace(/^\D+/, '');
	const toVersion = targetVersion.replace(/^\D+/, '');
	const version = `v${fromVersion} → v${toVersion}`;

	const length = 12 + name.length + text.length + version.length;
	if (length > stdout.columns) {
		log(`${' '.repeat(5)} ${style(symbol)}  ${name}`);
		log(`${' '.repeat(9)}${color.dim(text)} ${bg(version)}`);
	} else {
		log(`${' '.repeat(5)} ${style(symbol)}  ${name} ${color.dim(text)} ${bg(version)}`);
	}
};

export const title = (text: string) =>
	align(label(text, color.bgYellow, color.black), 'end', 7) + ' ';

export const success = async (prefix: string, text: string) => {
	const length = 10 + prefix.length + text.length;
	if (length > stdout.columns) {
		log(`${' '.repeat(5)} ${color.green('✔')}  ${prefix}`);
		log(`${' '.repeat(9)}${color.dim(text)}`);
	} else {
		log(`${' '.repeat(5)} ${color.green('✔')}  ${prefix} ${color.dim(text)}`);
	}
};

export const error = async (prefix: string, text: string) => {
	if (stdout.columns < 80) {

Review comment (suggestion):
```suggestion
	const version = `from v${fromVersion} to v${toVersion}`;
```

Code after:
	log(`${label(prefix, color.bgCyan, color.black)}  ${text}`);
};

export const info = async (prefix: string, text: string, version = '') => {
	const length = 11 + prefix.length + text.length + version?.length;
	const symbol = '◼';
	if (length > stdout.columns) {
		log(`${' '.repeat(5)} ${color.cyan(symbol)}  ${prefix}`);
		log(`${' '.repeat(9)}${color.dim(text)} ${color.reset(version)}`);
	} else {
		log(
			`${' '.repeat(5)} ${color.cyan(symbol)}  ${prefix} ${color.dim(text)} ${color.reset(version)}`,
		);
	}
};

export const upgrade = async (packageInfo: PackageInfo, text: string) => {
	const { name, isMajor = false, targetVersion, currentVersion } = packageInfo;

	const bg = isMajor ? (v: string) => color.bgYellow(color.black(` ${v} `)) : color.green;
	const style = isMajor ? color.yellow : color.green;
	const symbol = isMajor ? '▲' : '●';

	const fromVersion = currentVersion.replace(/^\D+/, '');
	const toVersion = targetVersion.replace(/^\D+/, '');
	const version = `from v${fromVersion} to v${toVersion}`;

	const length = 12 + name.length + text.length + version.length;
	if (length > stdout.columns) {
		log(`${' '.repeat(5)} ${style(symbol)}  ${name}`);
		log(`${' '.repeat(9)}${color.dim(text)} ${bg(version)}`);
	} else {
		log(`${' '.repeat(5)} ${style(symbol)}  ${name} ${color.dim(text)} ${bg(version)}`);
	}
};

export const title = (text: string) =>
	align(label(text, color.bgYellow, color.black), 'end', 7) + ' ';

export const success = async (prefix: string, text: string) => {
	const length = 10 + prefix.length + text.length;
	if (length > stdout.columns) {
		log(`${' '.repeat(5)} ${color.green('✔')}  ${prefix}`);
		log(`${' '.repeat(9)}${color.dim(text)}`);
	} else {
		log(`${' '.repeat(5)} ${color.green('✔')}  ${prefix} ${color.dim(text)}`);
	}
};

export const error = async (prefix: string, text: string) => {
	if (stdout.columns < 80) {