-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
191 lines (176 loc) · 5.32 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env node
import boxen from "boxen";
import chalk from "chalk";
import clear from "clear";
import inquirer from "inquirer";
import open from "open";
const random = Math.floor(Math.random() * 3);
const choices = ["Rock", "Paper", "Scissors", "About the author", "Quit"];
// Clear the console
clear();
function aboutMe() {
let name = "Vinesh Rajpurohit ⬢";
const data = {
name: chalk.white.bold(name),
handle: chalk.white("@vinesh27"),
title: chalk.hex("#6495ED")("Java and JavaScript Dev"),
fact: chalk.hex("#00FFFF")(
"I love to work, and I like to contribute to open source!"
),
email: chalk.hex("#5887FF")("mailto:[email protected]"),
discord: chalk.hex("#44BBA4")(
"https://discord.com/users/547025590587359233 || vN1t#4632"
),
twitter: chalk.hex("#55C1FF")("https://twitter.com/vineshCodes"),
github: chalk.hex("#E3DAFF")("https://github.com/vinesh27"),
website: chalk.hex("#9FFFCB")("https://vinesh.codes [WIP]"),
npx: chalk.hex("#06D6A0")("npx vinesh"),
labelName: chalk.white.bold(" Name:"),
labelTitle: chalk.hex("#6a8ed2").bold(" Title:"),
labelFact: chalk.hex("#2bfbaa").bold(" Fun Fact:"),
labelEmail: chalk.hex("#12c2e9").bold(" Email:"),
labelTwitter: chalk.hex("#28DCD4").bold(" Twitter:"),
labelGitHub: chalk.hex("#C0BABC").bold(" GitHub:"),
labelDiscord: chalk.hex("#7AE582").bold(" Discord:"),
labelHashnode: chalk.hex("#A959FF").bold(" Hashnode:"),
labelLinkedin: chalk.hex("#F8C537").bold(" Linkedin:"),
labelWebsite: chalk.hex("#59FFC8").bold(" Website:"),
labelCard: chalk.hex("#76e600").bold(" Card:"),
};
const me = boxen(
[
`${data.labelName} ${data.name}`,
`${data.labelTitle} ${data.title}`,
`${data.labelFact} ${data.fact}`,
`${data.labelEmail} ${data.email}`,
`${data.labelTwitter} ${data.twitter}`,
`${data.labelGitHub} ${data.github}`,
`${data.labelDiscord} ${data.discord}`,
`${data.labelWebsite} ${data.website}`,
`${data.labelCard} ${data.npx}`,
``,
`${chalk.bold(
"Hi there! I'm 👨💻 Vinesh. I'm a Full Stack Web Developer 🌐"
)}`,
`${chalk.bold("and a Homosapien 👨 (Shoutout to all my homosapien ")}`,
`${chalk.bold(
"friends) from India 🌏. I love to explore, learn, innovate and "
)}`,
`${chalk.bold(
"build stuff! Feel free to toss me an email mail 📩, Twitter 🐦 DM or Discord 😃 DM"
)}`,
`${chalk.bold("if you want to get in touch or collab!")}`,
].join("\n"),
{
margin: 1,
padding: 1,
float: "center",
borderStyle: "bold",
borderColor: "blue",
}
);
// Show the boxen
console.log(me);
// Show the tips
const tip = [
`Tip: ${chalk.cyanBright.bold(
"cmd/ctrl + click"
)} on the links above to open them in your broswer.`,
"",
];
console.log(tip.join("\n"));
const prompt = inquirer.createPromptModule();
const questions = [
{
type: "list",
name: "action",
message: "What do you want to do?",
choices: [
{
name: `Toss me an ${chalk.blueBright.bold("email")}? 📩`,
value: () => {
open("mailto:[email protected]");
console.log(
"Looking forward to hearing your message and replying to you!"
);
},
},
{
name: `Visit my ${chalk.cyanBright.bold("site")}? [WIP] 🚀`,
value: () => {
open("https://vinesh.codes");
console.log("Thanks for the visit to my site!");
},
},
{
name: "Exit 👋",
value: () => {
console.log("👋 Bye");
},
},
],
},
];
prompt(questions).then((answer) => answer.action());
}
function calculateWin(option) {
switch (option) {
case "Rock":
if (random === 0) return "Tie";
if (random === 1) return "Lose";
if (random === 2) return "Win";
break;
case "Paper":
if (random === 0) return "Win";
if (random === 1) return "Tie";
if (random === 2) return "Lose";
break;
case "Scissors":
if (random === 0) return "Lose";
if (random === 1) return "Win";
if (random === 2) return "Tie";
break;
case "Quit":
return "Quit";
case "About the author":
return "About";
}
}
function play() {
inquirer
.prompt([
{
type: "list",
name: "name",
message: "Select your move:",
choices,
},
])
.then((answers) => {
let result = calculateWin(answers.name);
if (result === "Quit") {
console.log("👋 Bye!");
} else if (result === "About") {
aboutMe();
} else {
console.log(
`You chose ${answers.name} and computer chose ${choices[random]}.`
);
console.log(`You ${result}!`);
inquirer
.prompt([
{
type: "confirm",
name: "continue",
message: "Do you want to play again?",
default: true,
},
])
.then((answers) => {
if (answers.continue) play();
else console.log("👋 Bye!\n");
});
}
});
}
play();