dragadix
Version:
A flirty, powerful CLI experience built by Aditya š
63 lines (54 loc) ⢠1.87 kB
JavaScript
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."));
}
}