brianmmaina 1.1.9 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +250 -228
  2. package/package.json +4 -1
package/index.js CHANGED
@@ -1,43 +1,54 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';
3
- import inquirer from 'inquirer';
4
- import open from 'open';
5
- import figlet from 'figlet';
6
- import chalk from 'chalk';
7
- import chalkAnimation from 'chalk-animation';
8
- import boxen from 'boxen';
9
- import gradient from 'gradient-string';
10
- import Table from 'cli-table3';
11
- import { createSpinner } from 'nanospinner';
2
+ 'use strict'
3
+
4
+ import chalk from 'chalk'
5
+ import boxen from 'boxen'
6
+ import clear from 'clear'
7
+ import inquirer from 'inquirer'
8
+ import Enquirer from 'enquirer'
9
+ import gradient from 'gradient-string'
10
+ import Table from 'cli-table3'
11
+ import { createSpinner } from 'nanospinner'
12
+ import open from 'open'
13
+
14
+ import fs from 'fs'
15
+ import { fileURLToPath } from 'url'
16
+ import { dirname } from 'path'
17
+ import * as path from 'path'
18
+ const __filename = fileURLToPath(import.meta.url);
19
+ const __dirname = dirname(__filename);
20
+
21
+ const sleep = (ms = 2000) => new Promise((r) => setTimeout(r, ms));
12
22
 
13
23
  // Placeholder URLs - replace with actual ones
14
24
  const resumeUrl = 'https://drive.google.com/your-resume-link';
15
25
  const githubUrl = 'https://github.com/your-github';
16
26
 
17
- const sleep = (ms = 2000) => new Promise((r) => setTimeout(r, ms));
27
+ const data = {
28
+ name: chalk.bold.green('Brian Maina'),
29
+ website: chalk.green('👨‍💻 Full Stack Developer'),
30
+ labelWebsite: chalk.white('Role:'),
31
+ github: chalk.green('github.com/brianmmaina'),
32
+ labelGithub: chalk.white('GitHub:'),
33
+ email: chalk.green('brian@example.com'),
34
+ labelEmail: chalk.white('Email:')
35
+ }
18
36
 
19
- const showIntro = async () => {
20
- console.clear();
21
- const msg = 'Brian Maina';
22
-
23
- return new Promise((resolve) => {
24
- figlet(msg, (err, data) => {
25
- console.log(gradient.pastel.multiline(data) + '\n');
26
-
27
- const intro = gradient.cristal('Hi, I\'m Brian Maina! A passionate developer who loves coding, movies, and video games.');
28
- const box = boxen(intro, {
29
- padding: 1,
30
- margin: 1,
31
- borderStyle: 'double',
32
- borderColor: 'cyan',
33
- backgroundColor: '#000',
34
- float: 'center'
35
- });
36
- console.log(box);
37
- resolve();
38
- });
39
- });
40
- };
37
+ const card = boxen(
38
+ [
39
+ `${data.name}`,
40
+ ``,
41
+ `${data.labelWebsite} ${data.website}`,
42
+ `${data.labelGithub} ${data.github}`,
43
+ `${data.labelEmail} ${data.email}`
44
+ ].join('\n'),
45
+ {
46
+ margin: 1,
47
+ padding: 1,
48
+ borderStyle: 'double',
49
+ borderColor: 'green'
50
+ }
51
+ );
41
52
 
42
53
  const questions = [
43
54
  {
@@ -45,32 +56,36 @@ const questions = [
45
56
  name: "action",
46
57
  message: "What would you like to explore?",
47
58
  choices: [
48
- {
49
- name: `📄 View Resume`,
50
- value: async () => {
51
- const spinner = createSpinner('Opening resume...').start();
52
- await sleep(1000);
53
- await open(resumeUrl);
54
- spinner.success({ text: 'Resume opened in browser!' });
55
- }
56
- },
57
- {
58
- name: `🐙 View GitHub`,
59
- value: async () => {
60
- const spinner = createSpinner('Opening GitHub...').start();
61
- await sleep(1000);
62
- await open(githubUrl);
63
- spinner.success({ text: 'GitHub opened in browser!' });
64
- }
65
- },
66
- {
67
- name: `🎵 Play Song with Dance`,
68
- value: async () => {
69
- console.clear();
70
- console.log(gradient.fruit('🎵 Now playing: "Your Favorite Song" 🎵\n'));
71
-
72
- const frames = [
73
- `
59
+ { name: `📄 View Resume`, value: 'resume' },
60
+ { name: `🐙 View GitHub`, value: 'github' },
61
+ { name: `🎵 Play Song with Dance`, value: 'song' },
62
+ { name: `🏓 Play Ping Pong`, value: 'pingpong' },
63
+ { name: `💼 View Skills & Portfolio`, value: 'portfolio' },
64
+ { name: `📞 Contact Info`, value: 'contact' },
65
+ { name: `🚪 Exit`, value: 'exit' }
66
+ ]
67
+ }
68
+ ];
69
+
70
+ const handleResume = async () => {
71
+ const spinner = createSpinner('Opening resume...').start();
72
+ await sleep(1000);
73
+ await open(resumeUrl);
74
+ spinner.success({ text: 'Resume opened in browser!' });
75
+ };
76
+
77
+ const handleGitHub = async () => {
78
+ const spinner = createSpinner('Opening GitHub...').start();
79
+ await sleep(1000);
80
+ await open(githubUrl);
81
+ spinner.success({ text: 'GitHub opened in browser!' });
82
+ };
83
+
84
+ const handleSong = async () => {
85
+ console.log(gradient.fruit('🎵 Now playing: "Your Favorite Song" 🎵\n'));
86
+
87
+ const frames = [
88
+ `
74
89
  🎸
75
90
  /|\\
76
91
  / | \\
@@ -80,7 +95,7 @@ const questions = [
80
95
  / | \\
81
96
  / | \\
82
97
  `,
83
- `
98
+ `
84
99
  🎸
85
100
  /|\\
86
101
  / | \\
@@ -93,7 +108,7 @@ const questions = [
93
108
  / \\
94
109
  / \\
95
110
  `,
96
- `
111
+ `
97
112
  🎸
98
113
  /|\\
99
114
  / | \\
@@ -108,7 +123,7 @@ const questions = [
108
123
  \\ /
109
124
  \\___/
110
125
  `,
111
- `
126
+ `
112
127
  🎸
113
128
  /|\\
114
129
  / | \\
@@ -125,184 +140,191 @@ const questions = [
125
140
  | |
126
141
  | |
127
142
  `
128
- ];
129
-
130
- let frame = 0;
131
- const lyrics = [
132
- "♪ La la la la ♪",
133
- "♪ Your favorite tune ♪",
134
- "♪ Dancing in the terminal ♪",
135
- "♪ So much fun! ♪"
136
- ];
137
-
138
- const interval = setInterval(() => {
139
- console.clear();
140
- console.log(gradient.fruit(frames[frame]));
141
- console.log(gradient.pastel(lyrics[frame % lyrics.length]));
142
- frame = (frame + 1) % frames.length;
143
- }, 800);
144
-
145
- await sleep(10000);
146
- clearInterval(interval);
147
- console.log(gradient.cristal('\n🎉 Song ended! Hope you enjoyed the dance! 🎉'));
148
- }
149
- },
150
- {
151
- name: `🏓 Play Ping Pong`,
152
- value: async () => {
153
- console.clear();
154
- console.log(gradient.fruit('🏓 Ping Pong Championship! 🏓\n'));
155
- console.log('Controls: A/D to move paddle, Q to quit\n');
156
-
157
- let paddlePos = 15;
158
- let ballX = 20;
159
- let ballY = 10;
160
- let ballDirX = 1;
161
- let ballDirY = 1;
162
- const width = 40;
163
- const height = 20;
164
- let score = 0;
165
-
166
- process.stdin.setRawMode(true);
167
- process.stdin.resume();
168
-
169
- const render = () => {
170
- console.clear();
171
- console.log(gradient.fruit(`Score: ${score}`));
172
- for (let y = 0; y < height; y++) {
173
- let line = '';
174
- for (let x = 0; x < width; x++) {
175
- if (y === ballY && x === ballX) {
176
- line += gradient.fruit('●');
177
- } else if (y === height - 1 && x >= paddlePos && x < paddlePos + 8) {
178
- line += gradient.cristal('█');
179
- } else if (y === 0 || y === height - 1 || x === 0 || x === width - 1) {
180
- line += '│';
181
- } else {
182
- line += ' ';
183
- }
184
- }
185
- console.log(line);
186
- }
187
- };
188
-
189
- const gameLoop = setInterval(() => {
190
- ballX += ballDirX;
191
- ballY += ballDirY;
192
-
193
- if (ballX <= 1 || ballX >= width - 2) ballDirX *= -1;
194
- if (ballY <= 1) ballDirY *= -1;
195
- if (ballY >= height - 2 && ballX >= paddlePos && ballX < paddlePos + 8) {
196
- ballDirY *= -1;
197
- score++;
198
- }
199
- if (ballY >= height - 1) {
200
- console.log(gradient.pastel(`\nGame Over! Final Score: ${score}`));
201
- clearInterval(gameLoop);
202
- process.stdin.setRawMode(false);
203
- process.stdin.pause();
204
- return;
205
- }
206
-
207
- render();
208
- }, 150);
209
-
210
- process.stdin.on('data', (key) => {
211
- if (key[0] === 97) { // 'a'
212
- paddlePos = Math.max(1, paddlePos - 2);
213
- } else if (key[0] === 100) { // 'd'
214
- paddlePos = Math.min(width - 9, paddlePos + 2);
215
- } else if (key[0] === 113) { // 'q'
216
- clearInterval(gameLoop);
217
- process.stdin.setRawMode(false);
218
- process.stdin.pause();
219
- console.log(gradient.pastel('\nGame quit!'));
220
- }
221
- });
222
- }
223
- },
224
- {
225
- name: `💼 View Skills & Portfolio`,
226
- value: async () => {
227
- console.clear();
228
- console.log(gradient.fruit('💼 My Skills & Portfolio 💼\n'));
229
-
230
- const table = new Table({
231
- head: [gradient.cristal('Skill'), gradient.cristal('Level')],
232
- colWidths: [20, 20],
233
- style: { head: [], border: [] }
234
- });
235
-
236
- table.push(
237
- ['JavaScript', '⭐⭐⭐⭐⭐'],
238
- ['Node.js', '⭐⭐⭐⭐⭐'],
239
- ['React', '⭐⭐⭐⭐'],
240
- ['Python', '⭐⭐⭐⭐'],
241
- ['Terminal Magic', '⭐⭐⭐⭐⭐']
242
- );
243
-
244
- console.log(table.toString());
245
-
246
- console.log('\n' + gradient.pastel('Projects:'));
247
- console.log('• Terminal Business Card (You\'re using it!)');
248
- console.log('• Awesome CLI Tools');
249
- console.log('• Web Applications');
250
- }
251
- },
252
- {
253
- name: `📞 Contact Info`,
254
- value: async () => {
255
- console.clear();
256
- console.log(gradient.fruit('📞 Contact Information 📞\n'));
257
-
258
- const contactTable = new Table({
259
- style: { head: [], border: [] }
260
- });
261
-
262
- contactTable.push(
263
- { 'Email': 'brian@example.com' },
264
- { 'LinkedIn': 'linkedin.com/in/brianmaina' },
265
- { 'Twitter': 'twitter.com/brianmaina' }
266
- );
267
-
268
- console.log(contactTable.toString());
269
- }
270
- },
271
- {
272
- name: `🚪 Exit`,
273
- value: () => {
274
- console.log(gradient.pastel('Thanks for visiting! Goodbye! 👋'));
275
- process.exit(0);
143
+ ];
144
+
145
+ let frame = 0;
146
+ const lyrics = [
147
+ "♪ La la la la ♪",
148
+ "♪ Your favorite tune ♪",
149
+ "♪ Dancing in the terminal ♪",
150
+ "♪ So much fun! ♪"
151
+ ];
152
+
153
+ const interval = setInterval(() => {
154
+ console.clear();
155
+ console.log(gradient.fruit(frames[frame]));
156
+ console.log(gradient.pastel(lyrics[frame % lyrics.length]));
157
+ frame = (frame + 1) % frames.length;
158
+ }, 800);
159
+
160
+ await sleep(10000);
161
+ clearInterval(interval);
162
+ console.log(gradient.cristal('\n🎉 Song ended! Hope you enjoyed the dance! 🎉'));
163
+ };
164
+
165
+ const handlePingPong = async () => {
166
+ console.log(gradient.fruit('🏓 Ping Pong Championship! 🏓\n'));
167
+ console.log('Controls: A/D to move paddle, Q to quit\n');
168
+
169
+ let paddlePos = 15;
170
+ let ballX = 20;
171
+ let ballY = 10;
172
+ let ballDirX = 1;
173
+ let ballDirY = 1;
174
+ const width = 40;
175
+ const height = 20;
176
+ let score = 0;
177
+
178
+ process.stdin.setRawMode(true);
179
+ process.stdin.resume();
180
+
181
+ const render = () => {
182
+ console.clear();
183
+ console.log(gradient.fruit(`Score: ${score}`));
184
+ for (let y = 0; y < height; y++) {
185
+ let line = '';
186
+ for (let x = 0; x < width; x++) {
187
+ if (y === ballY && x === ballX) {
188
+ line += gradient.fruit('');
189
+ } else if (y === height - 1 && x >= paddlePos && x < paddlePos + 8) {
190
+ line += gradient.cristal('█');
191
+ } else if (y === 0 || y === height - 1 || x === 0 || x === width - 1) {
192
+ line += '│';
193
+ } else {
194
+ line += ' ';
276
195
  }
277
196
  }
278
- ]
279
- }
280
- ];
197
+ console.log(line);
198
+ }
199
+ };
200
+
201
+ const gameLoop = setInterval(() => {
202
+ ballX += ballDirX;
203
+ ballY += ballDirY;
204
+
205
+ if (ballX <= 1 || ballX >= width - 2) ballDirX *= -1;
206
+ if (ballY <= 1) ballDirY *= -1;
207
+ if (ballY >= height - 2 && ballX >= paddlePos && ballX < paddlePos + 8) {
208
+ ballDirY *= -1;
209
+ score++;
210
+ }
211
+ if (ballY >= height - 1) {
212
+ console.log(gradient.pastel(`\nGame Over! Final Score: ${score}`));
213
+ clearInterval(gameLoop);
214
+ process.stdin.setRawMode(false);
215
+ process.stdin.pause();
216
+ return;
217
+ }
218
+
219
+ render();
220
+ }, 150);
221
+
222
+ process.stdin.on('data', (key) => {
223
+ if (key[0] === 97) { // 'a'
224
+ paddlePos = Math.max(1, paddlePos - 2);
225
+ } else if (key[0] === 100) { // 'd'
226
+ paddlePos = Math.min(width - 9, paddlePos + 2);
227
+ } else if (key[0] === 113) { // 'q'
228
+ clearInterval(gameLoop);
229
+ process.stdin.setRawMode(false);
230
+ process.stdin.pause();
231
+ console.log(gradient.pastel('\nGame quit!'));
232
+ }
233
+ });
234
+ };
235
+
236
+ const handlePortfolio = async () => {
237
+ console.log(gradient.fruit('💼 My Skills & Portfolio 💼\n'));
238
+
239
+ const table = new Table({
240
+ head: [gradient.cristal('Skill'), gradient.cristal('Level')],
241
+ colWidths: [20, 20],
242
+ style: { head: [], border: [] }
243
+ });
244
+
245
+ table.push(
246
+ ['JavaScript', '⭐⭐⭐⭐⭐'],
247
+ ['Node.js', '⭐⭐⭐⭐⭐'],
248
+ ['React', '⭐⭐⭐⭐'],
249
+ ['Python', '⭐⭐⭐⭐'],
250
+ ['Terminal Magic', '⭐⭐⭐⭐⭐']
251
+ );
252
+
253
+ console.log(table.toString());
254
+
255
+ console.log('\n' + gradient.pastel('Projects:'));
256
+ console.log('• Terminal Business Card (You\'re using it!)');
257
+ console.log('• Awesome CLI Tools');
258
+ console.log('• Web Applications');
259
+ };
260
+
261
+ const handleContact = async () => {
262
+ console.log(gradient.fruit('📞 Contact Information 📞\n'));
263
+
264
+ const contactTable = new Table({
265
+ style: { head: [], border: [] }
266
+ });
267
+
268
+ contactTable.push(
269
+ { 'Email': 'brian@example.com' },
270
+ { 'LinkedIn': 'linkedin.com/in/brianmaina' },
271
+ { 'Twitter': 'twitter.com/brianmaina' }
272
+ );
273
+
274
+ console.log(contactTable.toString());
275
+ };
276
+
277
+ const prompt = inquirer.createPromptModule();
281
278
 
282
279
  const followup = [
283
280
  {
284
- type: "confirm",
285
- name: "continue",
286
- message: "Would you like to explore more?",
287
- default: true
281
+ type: "toggle",
282
+ name: "exit",
283
+ message: "Exit?",
284
+ enabled: 'Yes',
285
+ disabled: 'No',
286
+ default: false
288
287
  }
289
288
  ];
290
289
 
291
- const prompt = inquirer.createPromptModule();
292
-
293
290
  async function init() {
294
- await showIntro();
295
- await prompt(questions).then(answer => answer.action());
296
- await prompt(followup).then(answer => {
297
- if (answer.continue) {
291
+ clear();
292
+ console.log(card);
293
+ await prompt(questions).then(async answer => {
294
+ switch(answer.action) {
295
+ case 'resume':
296
+ await handleResume();
297
+ break;
298
+ case 'github':
299
+ await handleGitHub();
300
+ break;
301
+ case 'song':
302
+ await handleSong();
303
+ break;
304
+ case 'pingpong':
305
+ await handlePingPong();
306
+ break;
307
+ case 'portfolio':
308
+ await handlePortfolio();
309
+ break;
310
+ case 'contact':
311
+ await handleContact();
312
+ break;
313
+ case 'exit':
314
+ console.log(gradient.pastel("Have a nice day!\n"));
315
+ process.exit();
316
+ }
317
+ });
318
+
319
+ await Enquirer.prompt(followup).then(answer => {
320
+ if (!answer.exit) {
298
321
  init();
299
322
  } else {
300
- console.log(gradient.pastel('Thanks for exploring! Goodbye! 👋'));
301
- process.exit(0);
323
+ console.log(gradient.pastel("Have a nice day!\n"));
324
+ process.exit();
302
325
  }
303
326
  });
304
327
  }
305
328
 
306
- (async () => {
307
- await init();
308
- })();
329
+ process.removeAllListeners('warning');
330
+ init();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brianmmaina",
3
- "version": "1.1.9",
3
+ "version": "1.1.12",
4
4
  "description": "My terminal business card",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -16,8 +16,11 @@
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
18
  "boxen": "^8.0.1",
19
+ "chalk": "^5.3.0",
19
20
  "chalk-animation": "^2.0.3",
20
21
  "cli-table3": "^0.6.5",
22
+ "clear": "^0.1.0",
23
+ "enquirer": "^2.4.1",
21
24
  "figlet": "^1.10.0",
22
25
  "gradient-string": "^3.0.0",
23
26
  "inquirer": "^13.2.5",