Something went wrong. Try again.
fork of hey-api/openapi-ts because I need some additional things
Something went wrong. Try again.
1.5 kB · 54 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import colors from 'ansi-colors';
import { loadPackageJson } from './tsConfig';
const textAscii = `888 | e 888~-_ 888888___| e88~~8e Y88b / d8b 888 \\ 888888 | d888 88b Y888/ /Y88b 888 | 888888 | 8888__888 Y8/ / Y88b 888 / 888888 | Y888 , Y /____Y88b 888_-~ 888888 | "88___/ / / Y88b 888 888 _/`;
const asciiToLines = ( ascii: string, options?: { padding?: number; },) => { const lines: Array<string> = []; const padding = Array.from<string>({ length: options?.padding ?? 0 }).fill(''); lines.push(...padding); let maxLineLength = 0; let line = ''; for (const char of ascii) { if (char === '\n') { if (line) { lines.push(line); maxLineLength = Math.max(maxLineLength, line.length); line = ''; } } else { line += char; } } lines.push(...padding); return { lines, maxLineLength };};
// TODO: show ascii logo only in `--help` and `--version` commandsexport function printCliIntro(initialDir: string, showLogo: boolean = false): void { const packageJson = loadPackageJson(initialDir); if (packageJson) { if (showLogo) { const text = asciiToLines(textAscii, { padding: 1 }); for (const line of text.lines) { console.log(colors.cyan(line)); } } console.log(colors.gray(`${packageJson.name} v${packageJson.version}`)); } console.log('');}