(refactor): improve CLI logic, update README, and remove unused assets

This commit is contained in:
2025-07-26 15:03:47 +05:30
parent 905deca9e6
commit c1bf88da0d
5 changed files with 1180 additions and 57 deletions

View File

@@ -11,7 +11,7 @@
#### A sleek, interactive CLI business card - showcasing contact links, resume also more right from your terminal. #### A sleek, interactive CLI business card - showcasing contact links, resume also more right from your terminal.
[![status](https://img.shields.io/badge/status-active-brightgreen.svg?style=flat)](https://github.com/xodivorce/npm-xodivorce/) [![status](https://img.shields.io/badge/status-active-brightgreen.svg?style=flat)](https://github.com/xodivorce/npm-xodivorce/)
[![version](https://img.shields.io/badge/version-v1.0.0-yellow.svg?style=flat)](https://github.com/xodivorce/npm-xodivorce/) [![version](https://img.shields.io/badge/version-v1.1.0-yellow.svg?style=flat)](https://github.com/xodivorce/npm-xodivorce/)
[![PRs](https://img.shields.io/badge/PRs-welcome-blue.svg?style=flat)](https://github.com/xodivorce/npm-xodivorce/) [![PRs](https://img.shields.io/badge/PRs-welcome-blue.svg?style=flat)](https://github.com/xodivorce/npm-xodivorce/)
> **🥰 Like this project? Please consider giving it a Star (🌟) on GitHub to show us your appreciation. Thank you!** > **🥰 Like this project? Please consider giving it a Star (🌟) on GitHub to show us your appreciation. Thank you!**

View File

@@ -1,9 +0,0 @@
// Node.js script to make an HTTPS GET request and log status and content type.
// Expects: Status: 200; Content-Type: application/pdf
import https from "https";
https.get("<https://your-domain/path/to/your-resume.pdf>", (res) => {
console.log("Status:", res.statusCode);
console.log("Content-Type:", res.headers["content-type"]);
});

View File

@@ -1,12 +1,10 @@
#!/usr/bin/env node #!/usr/bin/env node
import chalk from "chalk"; import chalk from "chalk";
import boxen from "boxen"; import boxen from "boxen";
import inquirer from "inquirer"; import inquirer from "inquirer";
import open from "open"; import open from "open";
import os from "os";
import fs from "fs";
import https from "https";
import path from "path";
const newline = "\n"; const newline = "\n";
const label = (text) => chalk.bold.white(text.padEnd(14)); const label = (text) => chalk.bold.white(text.padEnd(14));
@@ -47,6 +45,13 @@ const boxed = boxen(content, {
console.log(boxed); console.log(boxed);
// Graceful exit on Ctrl+C
process.on("SIGINT", () => {
console.log("\n" + chalk.bold.white("Exited gracefully."));
process.exit(0);
});
// Main prompt
inquirer inquirer
.prompt([ .prompt([
{ {
@@ -56,59 +61,85 @@ inquirer
choices: [ choices: [
{ {
name: chalk.white("📧 Send Email"), name: chalk.white("📧 Send Email"),
value: () => { value: async () => {
try {
console.log(chalk.gray("→ Opening email client...")); console.log(chalk.gray("→ Opening email client..."));
return open("mailto:" + data.email); await open("mailto:" + data.email);
console.log(chalk.green("✔ Email client opened."));
} catch (error) {
console.error(
chalk.red("✖ Failed to open email client:"),
chalk.gray(error?.message || "Unknown error")
);
}
}, },
}, },
{ {
name: chalk.white("📄 Download Resume"), name: chalk.white("📄 View Resume"),
value: () => { value: async () => {
const fileUrl = "https://xodivorce.in/assets/pdf/CV_PRASID.pdf"; const fileUrl = "https://xodivorce.in/core/pdf_config.php";
const downloadPath = path.join(os.homedir(), "prasid-mandal-resume.pdf"); try {
console.log(chalk.gray("→ Downloading Resume...")); console.log(chalk.gray("→ Opening resume in browser..."));
await open(fileUrl);
const file = fs.createWriteStream(downloadPath); console.log(
chalk.green("✔ Resume opened in your default browser.")
https.get(fileUrl, (response) => { );
response.pipe(file); } catch (error) {
console.error(
file.on("finish", () => { chalk.red("✖ Failed to open resume:"),
file.close(() => { chalk.gray(error?.message || "Unknown error")
console.log(chalk.green("✔ Resume Downloaded at: ") + chalk.white(downloadPath)); );
}); }
});
}).on("error", (err) => {
fs.unlink(downloadPath, () => {});
console.error(chalk.red("✖ Download failed:"), chalk.gray(err.message));
});
}, },
}, },
{ {
name: chalk.white("📅 Book a Meeting"), name: chalk.white("📅 Setup Meeting"),
value: () => { value: async () => {
try {
console.log(chalk.gray("→ Opening calendar...")); console.log(chalk.gray("→ Opening calendar..."));
return open("https://cal.com/xodivorce"); await open("https://cal.com/xodivorce");
console.log(
chalk.green("✔ Calendar opened in your default browser.")
);
} catch (error) {
console.error(
chalk.red("✖ Failed to open calendar:"),
chalk.gray(error?.message || "Unknown error")
);
}
}, },
}, },
{ {
name: chalk.gray("x Exit"), name: chalk.gray("x Exit"),
value: () => { value: () => {
try {
console.log(""); console.log("");
console.log(chalk.bold.white("Thank you!")); console.log(chalk.bold.white("Thank you!"));
console.log(chalk.gray("Have a great day.")); console.log(chalk.gray("Have a great day."));
console.log(""); console.log("");
process.exit(0); process.exit(0);
} catch (error) {
console.error(
chalk.red("✖ Failed to exit:"),
chalk.gray(error?.message || "Unknown error")
);
process.exit(1);
}
}, },
}, },
], ],
pageSize: 5, pageSize: 5,
}, },
]) ])
.then((answer) => { .then(async (answer) => {
return answer.action(); if (typeof answer.action === "function") {
await answer.action();
}
}) })
.catch((error) => { .catch((error) => {
console.error(chalk.white("Error:"), chalk.gray(error.message)); console.error(
chalk.red("✖ Unexpected error occurred:"),
chalk.gray(error?.message || "Unknown error")
);
process.exit(1); process.exit(1);
}); });

1105
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -9,12 +9,18 @@
"author": "Prasid Mandal <hey@xodivorce.in>", "author": "Prasid Mandal <hey@xodivorce.in>",
"license": "MIT", "license": "MIT",
"type": "module", "type": "module",
"keywords": ["cli", "card", "npx", "xodivorce"], "keywords": [
"cli",
"card",
"npx",
"xodivorce"
],
"dependencies": { "dependencies": {
"boxen": "^8.0.1", "boxen": "^8.0.1",
"chalk": "^5.4.1", "chalk": "^5.4.1",
"dotenv": "^17.2.1", "dotenv": "^17.2.1",
"inquirer": "^12.8.2", "inquirer": "^12.8.2",
"open": "^10.2.0" "open": "^10.2.0",
"puppeteer": "^24.15.0"
} }
} }