UNPKG

dragadix

Version:

A flirty, powerful CLI experience built by Aditya šŸ’‹

63 lines (54 loc) • 1.87 kB
import chalk from "chalk"; import inquirer from "inquirer"; import open from "open"; import axios from "axios"; import { config } from "../config.js"; export async function showProjects() { const github = config?.socials?.github; if (!github) { console.log(chalk.red("āŒ GitHub URL not found in config.js")); return; } const choices = [ { name: "⭐ Featured Projects (Static)", value: "static" }, { name: "šŸ“” Fetch from GitHub", value: "github" }, { name: "ā†©ļø Return to Main Menu", value: "return" }, ]; const answer = await inquirer.prompt([ { type: "list", name: "mode", message: chalk.cyan("How do you want to see my sexy projects?"), choices, }, ]); if (answer.mode === "static") return showStaticProjects(); if (answer.mode === "github") return fetchGitHubRepos(github); } function showStaticProjects() { console.log(chalk.magentaBright("\n✨ Featured Projects ✨")); console.log(` šŸ“¦ dragadi CLI – A flirty interactive portfolio (this one!) 🌐 Portfolio Website – Full React + Firebase magic šŸ¤– GenAI Chatbot – Built with Gemini API, fully prompt-driven `); } async function fetchGitHubRepos(githubURL) { const username = githubURL.split("github.com/")[1]; if (!username) { console.log(chalk.red("āŒ Invalid GitHub link")); return; } try { const res = await axios.get(`https://api.github.com/users/${username}/repos`); const repos = res.data.slice(0, 5); // Only top 5 for now console.log(chalk.green(`\n🧠 Top Repos of @${username}:\n`)); repos.forEach(repo => { console.log(`šŸ“ ${chalk.bold(repo.name)} — ${repo.description || "No description"}`); console.log(chalk.gray(repo.html_url)); console.log(""); }); } catch (err) { console.log(chalk.red("🚫 Failed to fetch GitHub repos.")); } }