-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
Β·163 lines (139 loc) Β· 4.58 KB
/
index.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env node
import figlet from 'figlet';
import gradient from 'gradient-string';
import inquirer from 'inquirer';
import chalk from 'chalk';
import boxen from 'boxen';
import { fileURLToPath } from 'url';
import { dirname } from 'path';
import open from 'open';
import readline from 'readline';
const __dirname = dirname(fileURLToPath(import.meta.url));
// Function to clear the console
const clearConsole = () => console.clear();
const createGradient = (...colors) => gradient(...colors);
// Function to generate ASCII art title
const generateTitle = (text, font = 'Slant') =>
new Promise((resolve, reject) =>
figlet.text(text, { font }, (err, data) => (err ? reject(err) : resolve(data)))
);
// Function to generate consistent boxes using boxen
const createBox = (content, title, color) => {
const boxTitle = chalk.bold(title);
return boxen(content, {
title: boxTitle,
padding: 1,
borderStyle: 'round',
borderColor: color,
});
};
// Function to generate sections
const generateSection = (title, data, color) => {
const content = data
.map(([key, value]) => ` ${chalk.bold(key.padEnd(12))} ${chalk.green(value)}`)
.join('\n');
return createBox(content, title, color);
};
// Function to generate personal details, skills, and connection info
const generateInfo = () => {
const personalDetails = [
['NAME', 'Souvik Ojha'],
['STATUS', 'Freelancer | Backend Engineer | Learner'],
['EMAIL', '[email protected]'],
['GITHUB', 'github.com/techsouvik'],
['WEBSITE', 'https://tecshouvik.github.io'],
];
const skills = [
['LANGUAGES', 'JavaScript, TypeScript, Python'],
['FRAMEWORKS', 'Node, FastAPI, Flask'],
['TECHNOLOGIES', 'Node.js, Express, Redis, Kafka'],
['DATABASES', 'MongoDB, PostgreSQL, SQL, DynamoDB'],
['DEVOPS', 'Docker, GitHub'],
['TOOLS', 'Git, Firebase, AWS LAMBDA, SQS'],
];
const connectInfo = `
π ${chalk.greenBright('Elevate Your Projects with Souvik')} π
β¨ ${chalk.greenBright('Innovative Freelancer')}
β¨ ${chalk.greenBright('Backend Developer')}
β¨ ${chalk.greenBright('Skilled Learner & Enthusiast')}
A Backend Engineer helping you to create a business impact in this world!
Let's collaborate and innovate something amazing.
Thank you for exploring the CUI version!`;
return `
${generateSection('π PERSONAL DETAILS', personalDetails, 'cyan')}
${generateSection('π οΈ SKILLS', skills, 'yellow')}
${createBox(connectInfo, "πΌ LET'S CONNECT", 'magenta')}
`;
};
// Function to display options
const displayOptions = () =>
inquirer.prompt([
{
type: 'list',
name: 'action',
message: 'What would you like to do?',
choices: [
{ name: 'π View LinkedIn Profile', value: 'linkedin' },
{ name: 'π View GitHub Profile', value: 'github' },
{ name: 'π Visit Website', value: 'website' },
{ name: 'π View Resume', value: 'resume' },
{ name: 'π§ Send Email', value: 'email' },
{ name: 'π Exit', value: 'exit' },
],
},
]);
// Function to handle selection actions
const handleSelection = async action => {
const links = {
linkedin: 'https://www.linkedin.com/in/souvikojha',
github: 'https://github.com/techsouvik',
website: 'https://techsouvik.github.io',
email: 'mailto:[email protected]',
resume: 'https://bit.ly/souvikojha_resume'
};
if (links[action]) {
await open(links[action]);
console.log(chalk.green(`Opening ${action} in your default browser...`));
}
};
// Function to pause and wait for user input
const pause = () => {
return new Promise(resolve => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question('\nPress Enter key to continue...', () => {
rl.close();
resolve();
});
});
};
// Main function
const main = async () => {
try {
clearConsole();
const titleGradient = createGradient('cyan', 'magenta', 'yellow');
const title = await generateTitle('SouvikOjha');
console.log(titleGradient(title));
const info = generateInfo();
console.log(info);
let continueLoop = true;
while (continueLoop) {
const { action } = await displayOptions();
if (action === 'exit') {
continueLoop = false;
} else {
await handleSelection(action);
await pause();
clearConsole();
console.log(titleGradient(title));
console.log(info);
}
}
console.log(chalk.cyan('Thanks for visiting! Goodbye!'));
} catch (error) {
console.error('An error occurred:', error);
}
};
main();