Upgrading chalk 4 to 5
Breaking4.1.2 → 5.6.2Breaking4Security1Platform1New3Changed10Fixed5Other1
BreakingUpgrade verdict
4 breaking changes and a platform requirement change and a security fix.
In plain terms
- Some helpers that used to hang off the main chalk object are now separate named imports.
- Five rarely used color helper methods are gone; you can get the same results with the color-convert package.
- Chalk can no longer be loaded with the old CommonJS require system; your project must use modern ES modules.
- If you used chalk as a template tag, you now need to install and import chalk-template instead.
Must act Top 5 of 6 that need code or config changes
Node.js requirement changed in 5.0.0: >=10 → ^12.17.0 || ^14.13 || >=16.0.0.
Drops ansi-styles, supports-color.
Installs 0 packages in all (was 5).
What you must change
Breaking4
Moves some properties off the default export to individual named exports: chalk.Instance to Chalk, chalk.supportsColor to supportsColor, chalk.stderr to chalkStderr, chalk.stderr.supportsColor to…
chalk.InstanceChalkchalk.supportsColorsupportsColorchalk.stderrchalkStderrchalk.stderr.supportsColorsupportsColorStderrRemoves the .keyword(), .hsl(), .hsv(), .hwb(), and .ansi() coloring methods.
.keyword().hsl().hsv().hwb().ansi()The package is now pure ESM, requiring ESM-aware tooling and TypeScript 4.7 or later.
Moves tagged template literal support into the separate chalk-template package.
chalk-templateSecurity1
Fixes a vulnerability introduced in 5.6.1.
Platform1
Requires Node.js 12.20 or later.
API changes
Generated by DepDelta from published .d.ts files. Not mixed with prose notes.
- removed:
call chalk.ChalkFunction(...text: unknown[]): string - removed:
call chalk.ChalkFunction(text: TemplateStringsArray, ...placeholders: unknown[]): string - removed:
const chalk: chalk.Chalk & chalk.ChalkFunction & { supportsColor: chalk.ColorSupport | false; Level: chalk.Level; Color: Color; ForegroundColor: ForegroundColor; Background… - removed:
export = chalk - removed:
interface chalk.Chalk extends ChalkFunction - removed:
interface chalk.ChalkFunction - removed:
interface chalk.ColorSupport - removed:
interface chalk.Options - removed:
method chalk.Chalk.ansi(code: number): Chalk - removed:
method chalk.Chalk.ansi256(index: number): Chalk - removed:
method chalk.Chalk.bgAnsi(code: number): Chalk - removed:
method chalk.Chalk.bgAnsi256(index: number): Chalk - removed:
method chalk.Chalk.bgHex(color: string): Chalk - removed:
method chalk.Chalk.bgHsl(hue: number, saturation: number, lightness: number): Chalk - removed:
method chalk.Chalk.bgHsv(hue: number, saturation: number, value: number): Chalk - removed:
method chalk.Chalk.bgHwb(hue: number, whiteness: number, blackness: number): Chalk - removed:
method chalk.Chalk.bgKeyword(color: string): Chalk - removed:
method chalk.Chalk.bgRgb(red: number, green: number, blue: number): Chalk - removed:
method chalk.Chalk.hex(color: string): Chalk - removed:
method chalk.Chalk.hsl(hue: number, saturation: number, lightness: number): Chalk - removed:
method chalk.Chalk.hsv(hue: number, saturation: number, value: number): Chalk - removed:
method chalk.Chalk.hwb(hue: number, whiteness: number, blackness: number): Chalk - removed:
method chalk.Chalk.keyword(color: string): Chalk - removed:
method chalk.Chalk.rgb(red: number, green: number, blue: number): Chalk - removed:
namespace chalk - removed:
property chalk.Chalk.Instance: Instance - removed:
property chalk.Chalk.level: Level - removed:
property chalk.ColorSupport.has16m: boolean - removed:
property chalk.ColorSupport.has256: boolean - removed:
property chalk.ColorSupport.hasBasic: boolean - removed:
property chalk.ColorSupport.level: Level - removed:
property chalk.Options.level?: Level - removed:
readonly property chalk.Chalk.bgBlack: Chalk - removed:
readonly property chalk.Chalk.bgBlackBright: Chalk - removed:
readonly property chalk.Chalk.bgBlue: Chalk - removed:
readonly property chalk.Chalk.bgBlueBright: Chalk - removed:
readonly property chalk.Chalk.bgCyan: Chalk - removed:
readonly property chalk.Chalk.bgCyanBright: Chalk - removed:
readonly property chalk.Chalk.bgGray: Chalk - removed:
readonly property chalk.Chalk.bgGreen: Chalk - removed:
readonly property chalk.Chalk.bgGreenBright: Chalk - removed:
readonly property chalk.Chalk.bgGrey: Chalk - removed:
readonly property chalk.Chalk.bgMagenta: Chalk - removed:
readonly property chalk.Chalk.bgMagentaBright: Chalk - removed:
readonly property chalk.Chalk.bgRed: Chalk - removed:
readonly property chalk.Chalk.bgRedBright: Chalk - removed:
readonly property chalk.Chalk.bgWhite: Chalk - removed:
readonly property chalk.Chalk.bgWhiteBright: Chalk - removed:
readonly property chalk.Chalk.bgYellow: Chalk - removed:
readonly property chalk.Chalk.bgYellowBright: Chalk - removed:
readonly property chalk.Chalk.black: Chalk - removed:
readonly property chalk.Chalk.blackBright: Chalk - removed:
readonly property chalk.Chalk.blue: Chalk - removed:
readonly property chalk.Chalk.blueBright: Chalk - removed:
readonly property chalk.Chalk.bold: Chalk - removed:
readonly property chalk.Chalk.cyan: Chalk - removed:
readonly property chalk.Chalk.cyanBright: Chalk - removed:
readonly property chalk.Chalk.dim: Chalk - removed:
readonly property chalk.Chalk.gray: Chalk - removed:
readonly property chalk.Chalk.green: Chalk - removed:
readonly property chalk.Chalk.greenBright: Chalk - removed:
readonly property chalk.Chalk.grey: Chalk - removed:
readonly property chalk.Chalk.hidden: Chalk - removed:
readonly property chalk.Chalk.inverse: Chalk - removed:
readonly property chalk.Chalk.italic: Chalk - removed:
readonly property chalk.Chalk.magenta: Chalk - removed:
readonly property chalk.Chalk.magentaBright: Chalk - removed:
readonly property chalk.Chalk.red: Chalk - removed:
readonly property chalk.Chalk.redBright: Chalk - removed:
readonly property chalk.Chalk.reset: Chalk - removed:
readonly property chalk.Chalk.strikethrough: Chalk - removed:
readonly property chalk.Chalk.underline: Chalk - removed:
readonly property chalk.Chalk.visible: Chalk - removed:
readonly property chalk.Chalk.white: Chalk - removed:
readonly property chalk.Chalk.whiteBright: Chalk - removed:
readonly property chalk.Chalk.yellow: Chalk - removed:
readonly property chalk.Chalk.yellowBright: Chalk - removed:
type chalk.Instance = new (options?: Options) => Chalk - removed:
type chalk.Level = 0 | 1 | 2 | 3
- added:
call ChalkInstance(...text: unknown[]): string - added:
const Chalk: new (options?: Options) => ChalkInstance - added:
const backgroundColors: readonly BackgroundColor[] - added:
const chalk: ChalkInstance - added:
const chalkStderr: typeof chalk - added:
const colors: readonly Color[] - added:
const foregroundColors: readonly ForegroundColor[] - added:
const modifiers: readonly Modifiers[] - added:
const supportsColor: ColorInfo - added:
const supportsColorStderr: typeof supportsColor - added:
default chalk - added:
export { BackgroundColorName } from './vendor/ansi-styles/index' - added:
export { ColorInfo } from './vendor/supports-color/index' - added:
export { ColorName } from './vendor/ansi-styles/index' - added:
export { ColorSupport } from './vendor/supports-color/index' - added:
export { ColorSupportLevel } from './vendor/supports-color/index' - added:
export { ForegroundColorName } from './vendor/ansi-styles/index' - added:
export { ModifierName } from './vendor/ansi-styles/index' - added:
export { backgroundColorNames } from './vendor/ansi-styles/index' - added:
export { colorNames } from './vendor/ansi-styles/index' - added:
export { foregroundColorNames } from './vendor/ansi-styles/index' - added:
export { modifierNames } from './vendor/ansi-styles/index' - added:
interface ChalkInstance - added:
interface Options - added:
property ChalkInstance.ansi256: (index: number) => this - added:
property ChalkInstance.bgAnsi256: (index: number) => this - added:
property ChalkInstance.bgHex: (color: string) => this - added:
property ChalkInstance.bgRgb: (red: number, green: number, blue: number) => this - added:
property ChalkInstance.hex: (color: string) => this - added:
property ChalkInstance.level: ColorSupportLevel - added:
property ChalkInstance.rgb: (red: number, green: number, blue: number) => this - added:
readonly property ChalkInstance.bgBlack: this - added:
readonly property ChalkInstance.bgBlackBright: this - added:
readonly property ChalkInstance.bgBlue: this - added:
readonly property ChalkInstance.bgBlueBright: this - added:
readonly property ChalkInstance.bgCyan: this - added:
readonly property ChalkInstance.bgCyanBright: this - added:
readonly property ChalkInstance.bgGray: this - added:
readonly property ChalkInstance.bgGreen: this - added:
readonly property ChalkInstance.bgGreenBright: this - added:
readonly property ChalkInstance.bgGrey: this - added:
readonly property ChalkInstance.bgMagenta: this - added:
readonly property ChalkInstance.bgMagentaBright: this - added:
readonly property ChalkInstance.bgRed: this - added:
readonly property ChalkInstance.bgRedBright: this - added:
readonly property ChalkInstance.bgWhite: this - added:
readonly property ChalkInstance.bgWhiteBright: this - added:
readonly property ChalkInstance.bgYellow: this - added:
readonly property ChalkInstance.bgYellowBright: this - added:
readonly property ChalkInstance.black: this - added:
readonly property ChalkInstance.blackBright: this - added:
readonly property ChalkInstance.blue: this - added:
readonly property ChalkInstance.blueBright: this - added:
readonly property ChalkInstance.bold: this - added:
readonly property ChalkInstance.cyan: this - added:
readonly property ChalkInstance.cyanBright: this - added:
readonly property ChalkInstance.dim: this - added:
readonly property ChalkInstance.gray: this - added:
readonly property ChalkInstance.green: this - added:
readonly property ChalkInstance.greenBright: this - added:
readonly property ChalkInstance.grey: this - added:
readonly property ChalkInstance.hidden: this - added:
readonly property ChalkInstance.inverse: this - added:
readonly property ChalkInstance.italic: this - added:
readonly property ChalkInstance.magenta: this - added:
readonly property ChalkInstance.magentaBright: this - added:
readonly property ChalkInstance.overline: this - added:
readonly property ChalkInstance.red: this - added:
readonly property ChalkInstance.redBright: this - added:
readonly property ChalkInstance.reset: this - added:
readonly property ChalkInstance.strikethrough: this - added:
readonly property ChalkInstance.underline: this - added:
readonly property ChalkInstance.visible: this - added:
readonly property ChalkInstance.white: this - added:
readonly property ChalkInstance.whiteBright: this - added:
readonly property ChalkInstance.yellow: this - added:
readonly property ChalkInstance.yellowBright: this - added:
readonly property Options.level?: ColorSupportLevel - added:
type BackgroundColor = BackgroundColorName - added:
type Color = ColorName - added:
type ForegroundColor = ForegroundColorName - added:
type Modifiers = ModifierName
- added:
const ansiStyles: { readonly modifier: Modifier; readonly color: ColorBase & ForegroundColor; readonly bgColor: ColorBase & BackgroundColor; readonly codes: ReadonlyMap<number,… - added:
const backgroundColorNames: readonly BackgroundColorName[] - added:
const colorNames: readonly ColorName[] - added:
const foregroundColorNames: readonly ForegroundColorName[] - added:
const modifierNames: readonly ModifierName[] - added:
default ansiStyles - added:
interface BackgroundColor - added:
interface CSPair - added:
interface ColorBase - added:
interface ConvertColor - added:
interface ForegroundColor - added:
interface Modifier - added:
method ColorBase.ansi(code: number): string - added:
method ColorBase.ansi16m(red: number, green: number, blue: number): string - added:
method ColorBase.ansi256(code: number): string - added:
method ConvertColor.ansi256ToAnsi(code: number): number - added:
method ConvertColor.hexToAnsi(hex: string): number - added:
method ConvertColor.hexToAnsi256(hex: string): number - added:
method ConvertColor.hexToRgb(hex: string): [red: number, green: number, blue: number] - added:
method ConvertColor.rgbToAnsi(red: number, green: number, blue: number): number - added:
method ConvertColor.rgbToAnsi256(red: number, green: number, blue: number): number - added:
readonly property BackgroundColor.bgBlack: CSPair - added:
readonly property BackgroundColor.bgBlackBright: CSPair - added:
readonly property BackgroundColor.bgBlue: CSPair - added:
readonly property BackgroundColor.bgBlueBright: CSPair - added:
readonly property BackgroundColor.bgCyan: CSPair - added:
readonly property BackgroundColor.bgCyanBright: CSPair - added:
readonly property BackgroundColor.bgGray: CSPair - added:
readonly property BackgroundColor.bgGreen: CSPair - added:
readonly property BackgroundColor.bgGreenBright: CSPair - added:
readonly property BackgroundColor.bgGrey: CSPair - added:
readonly property BackgroundColor.bgMagenta: CSPair - added:
readonly property BackgroundColor.bgMagentaBright: CSPair - added:
readonly property BackgroundColor.bgRed: CSPair - added:
readonly property BackgroundColor.bgRedBright: CSPair - added:
readonly property BackgroundColor.bgWhite: CSPair - added:
readonly property BackgroundColor.bgWhiteBright: CSPair - added:
readonly property BackgroundColor.bgYellow: CSPair - added:
readonly property BackgroundColor.bgYellowBright: CSPair - added:
readonly property CSPair.close: string - added:
readonly property CSPair.open: string - added:
readonly property ColorBase.close: string - added:
readonly property ForegroundColor.black: CSPair - added:
readonly property ForegroundColor.blackBright: CSPair - added:
readonly property ForegroundColor.blue: CSPair - added:
readonly property ForegroundColor.blueBright: CSPair - added:
readonly property ForegroundColor.cyan: CSPair - added:
readonly property ForegroundColor.cyanBright: CSPair - added:
readonly property ForegroundColor.gray: CSPair - added:
readonly property ForegroundColor.green: CSPair - added:
readonly property ForegroundColor.greenBright: CSPair - added:
readonly property ForegroundColor.grey: CSPair - added:
readonly property ForegroundColor.magenta: CSPair - added:
readonly property ForegroundColor.magentaBright: CSPair - added:
readonly property ForegroundColor.red: CSPair - added:
readonly property ForegroundColor.redBright: CSPair - added:
readonly property ForegroundColor.white: CSPair - added:
readonly property ForegroundColor.whiteBright: CSPair - added:
readonly property ForegroundColor.yellow: CSPair - added:
readonly property ForegroundColor.yellowBright: CSPair - added:
readonly property Modifier.bold: CSPair - added:
readonly property Modifier.dim: CSPair - added:
readonly property Modifier.hidden: CSPair - added:
readonly property Modifier.inverse: CSPair - added:
readonly property Modifier.italic: CSPair - added:
readonly property Modifier.overline: CSPair - added:
readonly property Modifier.reset: CSPair - added:
readonly property Modifier.strikethrough: CSPair - added:
readonly property Modifier.underline: CSPair - added:
type BackgroundColorName = keyof BackgroundColor - added:
type ColorName = ForegroundColorName | BackgroundColorName - added:
type ForegroundColorName = keyof ForegroundColor - added:
type ModifierName = keyof Modifier
- added:
export { default } from './index'
- added:
const supportsColor: { stdout: ColorInfo; stderr: ColorInfo } - added:
default supportsColor - added:
function createSupportsColor(stream?: WriteStream, options?: Options): ColorInfo - added:
type ColorInfo = ColorSupport | false - added:
type ColorSupport = { level: ColorSupportLevel; hasBasic: boolean; has256: boolean; has16m: boolean } - added:
type ColorSupportLevel = 0 | 1 | 2 | 3 - added:
type Options = { readonly sniffFlags?: boolean }