Something went wrong. Try again.
fork of hey-api/openapi-ts because I need some additional things
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465import 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 };};
/** * Checks the current environment based on the HEYAPI_CODEGEN_ENV environment variable. */export function isEnvironment(value: 'development'): boolean { return process.env.HEYAPI_CODEGEN_ENV === value;}
// 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)); } } const versionString = isEnvironment('development') ? '[DEVELOPMENT]' : `v${packageJson.version}`; console.log(colors.gray(`${packageJson.name} ${versionString}`)); } console.log('');}