UNPKG

meet-simen

Version:

Get to know Simen via `npx meet-simen`

126 lines (124 loc) 4.69 kB
import chalk from 'chalk'; import boxen from 'boxen'; // Function to display welcome message (only used in development) export function displayWelcome(name, version, description) { console.log(boxen(`${chalk.yellow.bold(name)} v${version}\n\n${chalk.white(description)}\n\n${chalk.dim('Howdy, nice to meet ya!')}`, { padding: 1, margin: 1, borderStyle: 'round', borderColor: 'yellow', })); } // Function to display bio export function displayBio(bio) { const titleClr = chalk.hex('#FADC00').bold.inverse; const bioText = `${titleClr(` ${bio.name} `)} ${chalk.dim(`- ${bio.title}`)} ${chalk.italic(bio.description)}`; console.log(bioText); } // Function to display social links with GitHub stats export function displaySocialWithGitHub(social, githubStats) { let socialText = `${chalk.bold.underline('WHERE TO FIND ME')} ${chalk.dim('(I promise I\'m friendly)')}\n\n`; // Find the longest name for alignment const longestName = social.links.reduce((max, link) => Math.max(max, link.name.length), 0); for (const link of social.links) { // Create padded name for alignment const paddedName = link.name.padEnd(longestName, ' '); const label = chalk.hex(link.color).bold(`${paddedName}`); socialText += `${link.icon} ${label} ${chalk.dim(link.url)}\n`; } // Add GitHub stats if available if (githubStats) { socialText += `\n${chalk.bold.underline('GITHUB STATS')} ${chalk.dim('(Yes, I actually write code)')}\n\n`; socialText += `📊 ${chalk.bold('Followers:')} ${chalk.cyan('323')} 📚 ${chalk.bold('Repositories:')} ${chalk.cyan('103')}`; } console.log(boxen(socialText, { padding: 1, borderStyle: 'round', borderColor: 'cyan', title: '🔗 Connect & Collaborate', titleAlignment: 'center', })); } // Function to display social links (original version) export function displaySocial(social) { let socialText = '\n'; for (const link of social.links) { const label = chalk.hex(link.color).inverse.bold(` ${link.name} `); socialText += `${link.icon} ${label} ${chalk.dim(link.url)}\n`; } console.log(socialText); } // Function to display ad/CTA export function displayAd(message, color) { // Fix the TypeScript error by using a type-safe approach let coloredMessage; switch (color) { case 'cyan': coloredMessage = chalk.cyan.bold(message); break; case 'green': coloredMessage = chalk.green.bold(message); break; case 'yellow': coloredMessage = chalk.yellow.bold(message); break; case 'blue': coloredMessage = chalk.blue.bold(message); break; case 'magenta': coloredMessage = chalk.magenta.bold(message); break; case 'red': coloredMessage = chalk.red.bold(message); break; default: coloredMessage = chalk.white.bold(message); } console.log(boxen(coloredMessage, { padding: 1, margin: 1, borderStyle: 'double', borderColor: color, title: '✨ HIRE ME, MAYBE?', titleAlignment: 'center', })); } // Function to display debug info export function displayDebug(options) { console.log(boxen(`${chalk.yellow.bold('Debug Information')}\n\n` + `Options: ${JSON.stringify(options, null, 2)}`, { padding: 1, borderStyle: 'round', borderColor: 'red', })); } // Function to display terminal size warning export function displayTerminalSizeWarning() { const { columns, rows } = process.stdout; if (columns < 80 || rows < 24) { console.log(chalk.yellow.bold('⚠️ Warning: Your terminal window might be too small for optimal viewing.\n' + ' For the best experience, please resize to at least 80x24.\n')); } } // Function to parse GitHub stats from string to object export function parseGitHubStats(statsString) { if (!statsString) return null; try { // Extract numbers from the stats string using regex const followersMatch = statsString.match(/Followers: (\d+)/); const reposMatch = statsString.match(/Repositories: (\d+)/); if (followersMatch && reposMatch) { return { followers: Number.parseInt(followersMatch[1], 10), repositories: Number.parseInt(reposMatch[1], 10) }; } return null; } catch (error) { console.error('Error parsing GitHub stats:', error); return null; } }