-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard.js
executable file
·139 lines (123 loc) · 4.13 KB
/
card.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env node
"use strict";
const boxen = require("boxen");
const chalk = require("chalk");
const inquirer = require("inquirer");
const clear = require("clear");
const open = require("open");
const fs = require("fs");
const path = require("path");
const ora = require("ora");
const cliSpinners = require("cli-spinners");
const axios = require("axios");
clear();
const prompt = inquirer.createPromptModule();
const questions = [
{
type: "list",
name: "action",
message: "What action would you like to take?",
choices: [
{
name: `Send me an ${chalk.blue.bold("email")}?`,
value: () => {
open("mailto:[email protected]");
console.log("\nDone, see you soon at inbox.\n");
},
},
{
name: `Download my ${chalk.magentaBright.bold("Resume")}?`,
value: () => {
const downloadPDF = (url, destinationPath) => {
return new Promise((resolve, reject) => {
axios
.get(url, { responseType: "stream" })
.then((response) => {
const writeStream = fs.createWriteStream(destinationPath);
response.data.pipe(writeStream);
writeStream.on("finish", resolve);
writeStream.on("error", reject);
})
.catch(reject);
});
};
// ...
const downloadResume = async (pdfUrl, outputFilename) => {
try {
const downloadPath = path.join(process.cwd(), outputFilename);
const loader = ora({
text: " Downloading Resume",
spinner: cliSpinners.material,
}).start();
await downloadPDF(pdfUrl, downloadPath);
loader.succeed("Resume Downloaded!");
console.log(`Resume Downloaded at ${downloadPath} \n`);
} catch (error) {
loader.fail("Failed to download Resume");
console.error("Error:", error);
}
};
// Example usage
const pdfUrl =
"https://raw.githubusercontent.com/akshay-99h/portfolio/main/Akshay%20Prabhat%20Mishra%20-%20Resume.pdf";
const outputFilename = "akshay-resume.pdf";
downloadResume(pdfUrl, outputFilename);
},
},
{
name: "Quit card.",
value: () => {
console.log("See you around!\n");
},
},
],
},
];
const data = {
name: chalk.bold.blue(" Akshay Prabhat Mishra"),
info:
" " + chalk.bgCyanBright("Community person looking for SDE job roles"),
handle: chalk.white("@akshay-99h"),
twitter: chalk.cyanBright("https://twitter.com/akshay_99h"),
github: chalk.greenBright("https://github.com/akshay-99h"),
linkedin: chalk.blueBright("https://linkedin.com/in/akshay-99h"),
web: chalk.redBright("https://akshay-99h.codes"),
biolink: chalk.yellowBright("https://apm.bio.link"),
labelTwitter: chalk.white.bold(" Twitter:"),
labelGitHub: chalk.white.bold(" GitHub:"),
labelLinkedIn: chalk.white.bold(" LinkedIn:"),
labelWeb: chalk.white.bold(" Website:"),
// labelCard: chalk.white.bold(" Card:"),
labelBioLink: chalk.white.bold(" BioLink:"),
};
const me = boxen(
[
`${data.name}`,
`${data.info}`,
``,
`${chalk.italic(" I am dedicated to software development and")}`,
`${chalk.italic(" tech in general, specialising in full - stack")}`,
`${chalk.italic(" web development. My DMs are always open for")}`,
`${chalk.italic(" a chat, or if you have any questions.")}`,
``,
`${data.labelLinkedIn} ${data.linkedin}`,
`${data.labelTwitter} ${data.twitter}`,
`${data.labelGitHub} ${data.github}`,
`${data.labelBioLink} ${data.biolink}`,
`${data.labelWeb} ${data.web}`,
].join("\n"),
{
margin: 1,
float: "center",
padding: 1,
borderStyle: "single",
borderColor: "blue",
}
);
console.log(me);
const tip = [
`Tip: Try ${chalk.cyanBright.bold("cmd/ctrl + click")} on the links above`,
"",
].join("\n");
console.log(tip);
prompt(questions).then((answer) => answer.action());