|
| 1 | +import { colors, logger } from 'storybook/internal/node-logger'; |
| 2 | + |
| 3 | +import boxen, { type Options } from 'boxen'; |
| 4 | + |
| 5 | +const fancy = |
| 6 | + process.platform !== 'win32' || process.env.CI || process.env.TERM === 'xterm-256color'; |
| 7 | + |
| 8 | +export const step = colors.gray('›'); |
| 9 | +export const info = colors.blue(fancy ? 'ℹ' : 'i'); |
| 10 | +export const success = colors.green(fancy ? '✔' : '√'); |
| 11 | +export const warning = colors.orange(fancy ? '⚠' : '‼'); |
| 12 | +export const error = colors.red(fancy ? '✖' : '×'); |
| 13 | + |
| 14 | +const baseOptions: Options = { |
| 15 | + borderStyle: 'round', |
| 16 | + padding: 1, |
| 17 | +}; |
| 18 | + |
| 19 | +export const print = (message: string, options: Options) => { |
| 20 | + logger.line(1); |
| 21 | + logger.plain(boxen(message, { ...baseOptions, ...options })); |
| 22 | +}; |
| 23 | + |
| 24 | +export const printInfo = (title: string, message: string, options?: Options) => |
| 25 | + print(message, { borderColor: 'blue', title, ...options }); |
| 26 | + |
| 27 | +export const printWarning = (title: string, message: string, options?: Options) => |
| 28 | + print(message, { borderColor: 'yellow', title, ...options }); |
| 29 | + |
| 30 | +export const printError = (title: string, message: string, options?: Options) => |
| 31 | + print(message, { borderColor: 'red', title, ...options }); |
| 32 | + |
| 33 | +export const printSuccess = (title: string, message: string, options?: Options) => |
| 34 | + print(message, { borderColor: 'green', title, ...options }); |
0 commit comments