-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
Β·153 lines (136 loc) Β· 3.93 KB
/
cli.js
File metadata and controls
executable file
Β·153 lines (136 loc) Β· 3.93 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env node
import chalk from "chalk";
import boxen from "boxen";
import gradient from "gradient-string";
import chalkAnimation from "chalk-animation";
import inquirer from "inquirer";
import open from "open";
import ora from "ora";
import figlet from "figlet";
import data, { theme } from "./lib/data.js";
// --- Utility: typewriter effect ---
async function typewriter(text, delay = 30) {
for (let char of text) {
process.stdout.write(char);
await new Promise((r) => setTimeout(r, delay));
}
process.stdout.write("\n");
}
// --- Fade-out helper ---
async function fadeOut(text, steps = 5, delay = 120) {
let opacity = 1;
for (let i = 0; i < steps; i++) {
console.clear();
console.log(
chalk.rgb(
Math.floor(255 * opacity),
Math.floor(111 * opacity),
Math.floor(97 * opacity),
)(text),
);
opacity -= 1 / steps;
await new Promise((r) => setTimeout(r, delay));
}
console.clear();
}
// --- Banner ---
function renderBanner(text) {
return gradient([
"#00e0ff", // cyan
"#9d4edd", // violet (new stop adds depth)
"#ff6f61", // coral
]).multiline(figlet.textSync(text, { font: "Standard" }));
}
// --- Main Card ---
async function showCard() {
console.clear();
// π¬ Intro
await typewriter(chalk.green("> Booting developer profile..."));
const glitch = chalkAnimation.glitch("Loading portfolio...");
await new Promise((r) => setTimeout(r, 1500));
glitch.stop();
// π Fade-out glitch text
await fadeOut("Loading portfolio...");
// Welcome message
const welcomeAnim = chalkAnimation.rainbow(
"β¨ Welcome! Glad to have you here β¨",
);
await new Promise((r) => setTimeout(r, 1000));
welcomeAnim.stop();
console.log("\n");
// π·οΈ ASCII Banner
console.log(renderBanner("Anshul Singh Chauhan") + "\n");
// β¨ Elegant gradient header
console.log(
gradient(["#00e0ff", "#ff6f61"])("βββββββ Dev Card βββββββ") + "\n",
);
// π¦ Boxed card
const newline = "\n";
const heading = `${data.name} ${chalk.dim("/")} ${data.handle}`;
const working = `${chalk.bold("Work:")} ${data.work}`;
const twitter = `${chalk.bold("Twitter:")} ${data.linksColored.twitter}`;
const github = `${chalk.bold("GitHub:")} ${data.linksColored.github}`;
const linkedin = `${chalk.bold("LinkedIn:")} ${data.linksColored.linkedin}`;
const mail = `${chalk.bold("Email:")} ${data.linksColored.email}`;
const card = `${chalk.bold("Card:")} ${data.card}`;
const output = [
heading,
newline,
working,
github,
linkedin,
twitter,
newline,
card,
mail,
].join(newline);
console.log(
boxen(output, {
padding: 1,
margin: 1,
borderStyle: "round",
borderColor: "cyanBright",
}),
);
// π― Interactive menu
const answers = await inquirer.prompt([
{
type: "list",
name: "action",
message: "Where would you like to go?",
choices: [
{ name: "π» GitHub", value: "github" },
{ name: "π LinkedIn", value: "linkedin" },
{ name: "π¦ Twitter", value: "twitter" },
{ name: "π Exit", value: "exit" },
],
},
]);
await handleAction(answers.action);
}
// --- Handle actions with spinner ---
async function handleAction(action) {
let spinner;
switch (action) {
case "twitter":
spinner = ora("Opening Twitter...").start();
await open(data.twitter);
spinner.succeed("Twitter opened π");
break;
case "github":
spinner = ora("Opening GitHub...").start();
await open(data.github);
spinner.succeed("GitHub opened π");
break;
case "linkedin":
spinner = ora("Opening LinkedIn...").start();
await open(data.linkedin);
spinner.succeed("LinkedIn opened π");
break;
case "exit":
console.log(chalk.green("π Thanks for stopping by!"));
process.exit(0);
}
}
// --- Run ---
showCard();